1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3074,6434,3011],{22509:function(e,t,i){"use strict";i.d(t,{w:function(){return s}});var a=i(2784),n=i(5632),r=i.n(n);let s=e=>{let{when:t,message:i}=e,s=(0,a.useRef)(t);s.current=t;let o=(0,a.useRef)(i);return o.current=i,(0,a.useEffect)(()=>{if(null===r()||void 0===r()?void 0:r().router)return r().router.change=function(){for(var e,t,i=arguments.length,a=Array(i),l=0;l<i;l++)a[l]=arguments[l];return s.current()?(null===(e=a[1])||void 0===e?void 0:e.startsWith("/editor"))||(null===(t=a[1])||void 0===t?void 0:t.startsWith("/flow-editor"))||window.confirm(o.current)?n.Router.prototype.change.apply(r().router,a):Promise.resolve(!1):n.Router.prototype.change.apply(r().router,a)},()=>{delete r().router.change}},[]),null}},93341:function(e,t,i){"use strict";i.d(t,{r:function(){return N}});var a=i(52322),n=i(2784),r=i(12524),s=i.n(r),o=i(27818),l=i(32945),d=i(83096),c=i(30118),u=i(80920),m=i(38420),p=i(19458),h=i(47182),x=i(35954),f=i(43821),g=i(80410),v=i(23746),b=i(92855),y=i(70333),j=i(33643),w=i.n(j);function N(){var e,t;let{playerStatus:i,audioElement:r,playableURL:j}=(0,d.FI)(),{waveformConfig:N}=(0,c._i)(),k=(0,u.e1)(),S=(0,m.b)(),E=null!==(e=null==k?void 0:k.trim)&&void 0!==e?e:null==N?void 0:N.trim,C=(0,n.useMemo)(()=>{var e,t;if(S!==p.SourceType.STOCK)return;let i=null==k?void 0:null===(e=k.audioResourceId)||void 0===e?void 0:e.replace(/^stock_/,"");return i?null===(t=(0,h.QP)(i))||void 0===t?void 0:t.durationSec:void 0},[S,null==k?void 0:k.audioResourceId]),[_,I]=(0,n.useState)(void 0),[D,R]=(0,n.useState)(0),[T,M]=(0,n.useState)(0),[P,A]=(0,n.useState)(0),[F,L]=(0,n.useState)(!1),[z,O]=(0,n.useState)(v.W_);(0,n.useEffect)(()=>((0,v.NQ)(z),()=>(0,v.NQ)(!1)),[z]);let U=(0,n.useMemo)(()=>(0,f.sF)(_,E),[_,E]),Z=(0,n.useCallback)(()=>{r&&U&&R((0,f.x$)(r.currentTime,U))},[r,U]);(0,n.useEffect)(()=>{if(!r){I(void 0),R(0);return}let e=()=>{let{duration:e}=r;I(Number.isFinite(e)&&e>0?e:C)};return e(),r.addEventListener("loadedmetadata",e),r.addEventListener("durationchange",e),r.addEventListener("loadeddata",e),r.addEventListener("emptied",e),()=>{r.removeEventListener("loadedmetadata",e),r.removeEventListener("durationchange",e),r.removeEventListener("loadeddata",e),r.removeEventListener("emptied",e)}},[r,j,C]),(0,n.useEffect)(()=>{if(!r)return;let e=()=>{F||Z()};return r.addEventListener("timeupdate",e),r.addEventListener("seeked",e),()=>{r.removeEventListener("timeupdate",e),r.removeEventListener("seeked",e)}},[r,F,Z]),(0,n.useEffect)(()=>{Z()},[U,Z]);let W=i===o.c.playing;(0,n.useEffect)(()=>{(!W||F)&&M(F?P:D)},[W,F,P,D]),(0,n.useEffect)(()=>{if(!W||F||!r||!U)return;let e=0,t=()=>{M((0,f.x$)(r.currentTime,U)),e=requestAnimationFrame(t)};return e=requestAnimationFrame(t),()=>cancelAnimationFrame(e)},[W,F,r,U]);let Q=(0,n.useCallback)(e=>{if(!r||!U)return;let t=(0,f.ZR)(e,U);r.currentTime=t,R((0,f.x$)(t,U)),i===o.c.playing&&l.EM.setTime((0,f.x$)(t,U))},[r,U,i]),B=(0,n.useCallback)(()=>{if(!r||!U)return;let{windowStart:e,windowEnd:t,windowDuration:i}=U,a=r.currentTime;(a<e||a>=t)&&(a=e,r.currentTime=e),l.EM.setDuration(i),r.play().catch(()=>void 0),l.EM.play(),l.EM.setTime((0,f.x$)(a,U))},[r,U]),H=(0,n.useCallback)(()=>{if(!r||!U||!J.current)return;let{windowStart:e,windowDuration:t}=U,a=i===o.c.playing;if(a&&r.pause(),r.currentTime=e,R(0),M(0),A(0),a){l.EM.setDuration(t),r.play().catch(()=>void 0),l.EM.play(),l.EM.setTime(0);return}l.EM.stop(),l.EM.setTime(0)},[r,U,i]),G=(0,n.useCallback)(()=>{if(!r||!U)return;let e=(0,f.x$)(r.currentTime,U);r.pause(),l.EM.stop(),l.EM.setTime(e),R(e),M(e),A(e)},[r,U]),V=(0,n.useCallback)(e=>{if(!J.current)return;let t=Number(e.target.value);Number.isFinite(t)&&(A(t),L(!0))},[]),K=(0,n.useCallback)(()=>{J.current&&(Q(P),L(!1))},[Q,P]),q=!!(0,g.e)(r)&&(S===p.SourceType.AUDIO||S===p.SourceType.STOCK||!!j&&S===p.SourceType.SAMPLE),Y=null!==(t=null==U?void 0:U.windowDuration)&&void 0!==t?t:0,X=F?P:T,$=!!(q&&U&&Y>0&&i!==o.c.loading&&i!==o.c.error),J=n.useRef($);J.current=$;let ee=Y>0?100*Math.min(X/Y,1):0;return q?(0,a.jsx)("div",{className:"w-full shrink-0 py-1","data-testid":b.z.AUDIO_PLAYER_BAR,children:(0,a.jsxs)("div",{className:s()("flex items-center gap-2.5 rounded-full bg-white px-2.5 py-2 shadow-md ring-1 ring-black/5 md:gap-3 md:px-3",!$&&"opacity-70"),children:[(0,a.jsx)(y.K,{isPlaying:W,canPlay:$,loop:z,onTogglePlay:()=>W?G():B(),onGoToStart:H,onToggleLoop:()=>O(e=>!e),playButtonTestId:b.z.AUDIO_PLAYER_ACTION_BUTTON,playAriaLabelPlaying:"Stop audio preview",playAriaLabelPaused:"Play audio preview"}),(0,a.jsxs)("div",{className:w().seekRow,children:[(0,a.jsx)("span",{className:w().timeLabelCurrent,"data-testid":b.z.AUDIO_PLAYER_CURRENT_TIME,children:(0,x.c)(X)}),(0,a.jsx)("input",{type:"range",min:0,max:Y||0,step:.01,value:Math.min(X,Y||0),onChange:V,onMouseUp:K,onTouchEnd:K,onKeyUp:K,"aria-disabled":!$,tabIndex:$?0:-1,style:{"--seek-progress":"".concat(ee,"%")},"aria-label":"Seek audio preview","data-testid":b.z.AUDIO_PLAYER_SEEK,className:s()(w().seekInput,!$&&w().seekInputDisabled,W&&!F&&w().seekInputPlaying)}),(0,a.jsx)("span",{className:w().timeLabelDuration,"data-testid":b.z.AUDIO_PLAYER_DURATION,children:(0,x.c)(Y)})]})]})}):null}},29121:function(e,t,i){"use strict";i.d(t,{U:function(){return o}});var a=i(52322);i(2784);var n=i(30118),r=i(5987),s=i(93341);let o=e=>{let{enabled:t}=e,{editorSize:i,frameConfig:o}=(0,n._i)();return!t||i.width<=0||i.height<=0?null:(0,a.jsx)("div",{className:"pointer-events-none absolute z-20",style:{left:o.offsetLeft,top:o.offsetTop+i.height+r.Z2,width:i.width},children:(0,a.jsx)("div",{className:"pointer-events-auto w-full",children:(0,a.jsx)(s.r,{})})})}},37567:function(e,t,i){"use strict";i.d(t,{k:function(){return ew}});var a,n,r=i(52322),s=i(2784),o=i(42670),l=i(99127),d=i(19458),c=i(92428),u=i(40805),m=i(21353),p=i(18997),h=i(38986),x=i(96284),f=i(30118),g=i(80920),v=i(3438),b=i(52522),y=i(83096),j=i(59134),w=i(65089),N=i(83553),k=i(118),S=i(42658),E=i(71680),C=i(71406),_=i(19994),I=i(46620);let D=()=>{let{editMode:e=N.uz.Locked}=(0,b.hl)(),t=e!==N.uz.Locked,i=e===N.uz.Editable;return{editMode:e,isEditable:t,canEditAudio:i}};var R=i(82423);let T=e=>{let{isSelectedWaveform:t,selectedSource:i,isUploading:a,audioElement:n,trim:o}
1=e,[l,c]=(0,s.useState)(null==n?void 0:n.duration);(0,s.useEffect)(()=>{if(!n){c(void 0);return}let e=()=>{let{duration:e}=n;c(Number.isFinite(e)&&!Number.isNaN(e)?e:void 0)};return e(),n.addEventListener("loadedmetadata",e),n.addEventListener("durationchange",e),n.addEventListener("loadeddata",e),n.addEventListener("emptied",e),()=>{n.removeEventListener("loadedmetadata",e),n.removeEventListener("durationchange",e),n.removeEventListener("loadeddata",e),n.removeEventListener("emptied",e)}},[n,t,i]);let u=(0,s.useMemo)(()=>{if(!t||i!==d.SourceType.AUDIO||a)return null;if(!l||!Number.isFinite(l)||Number.isNaN(l)||l<=0)return{fullDuration:null,trimmedDuration:null,trimStart:null,trimEnd:null,hasTrim:!1};let e=o&&"number"==typeof o.startRatio&&"number"==typeof o.endRatio?{start:o.startRatio,end:o.endRatio}:null;return null!==e&&e.start>=0&&e.end<=1&&e.start<e.end&&!(1e-6>Math.abs(e.start)&&1e-6>Math.abs(e.end-1))?{fullDuration:l,trimmedDuration:(e.end-e.start)*l,trimStart:e.start*l,trimEnd:e.end*l,hasTrim:!0}:{fullDuration:l,trimmedDuration:null,trimStart:null,trimEnd:null,hasTrim:!1}},[l,t,a,i,o]);return u?(0,r.jsx)("div",{className:"mb-3 p-2 bg-gray-50 rounded border border-gray-200",children:(0,r.jsx)("div",{className:"space-y-1 text-xs text-gray-700",children:null!==u.fullDuration?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsx)("span",{className:"font-medium",children:"Duration:"}),(0,r.jsx)("span",{className:"text-gray-900",children:(0,R.L)(u.fullDuration)})]}),u.hasTrim&&null!==u.trimmedDuration&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsx)("span",{className:"font-medium",children:"Trimmed duration:"}),(0,r.jsx)("span",{className:"text-gray-900",children:(0,R.L)(u.trimmedDuration)})]}),null!==u.trimStart&&null!==u.trimEnd&&(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsx)("span",{className:"font-medium",children:"Trimmed range:"}),(0,r.jsxs)("span",{className:"text-gray-900",children:[(0,R.L)(u.trimStart)," -"," ",(0,R.L)(u.trimEnd)]})]})]})]}):(0,r.jsx)("div",{className:"text-gray-500",children:"Duration: Loading..."})})}):null};var M=i(51574);let P=e=>{var t;let{waveform:i,isExpanded:a,canRemove:n,onToggle:s,onRemove:c,onTrim:u,onDownloadAudio:p,uploadProgress:x,uploadStatusLabel:v,uploadStatusDescription:b,showActionRow:j=!0,children:N}=e,{resources:k}=(0,w.o0)(),{audioElement:R}=(0,y.FI)(),P=(0,g.Q5)(),{waveformConfig:A}=(0,f._i)(),{canEditAudio:F}=D(),L=k[i.audioResourceId||h.AUDIO_ORIGINAL_FILE_ID],z=(null==L?void 0:L.name)||i.audioFileName,O=x>0&&x<99,U=i.id===P,Z=(null==L?void 0:L.type)===M.CustomFileType.bucket&&!!(null==L?void 0:L.pathInBucket);return(0,r.jsxs)("div",{className:"border border-gray-300 rounded-lg overflow-hidden select-none",children:[(0,r.jsxs)("div",{className:"px-3 py-2 flex items-center justify-between cursor-pointer transition-colors ".concat(a?"bg-blue-50 border-b border-gray-200":"hover:bg-gray-50"),onClick:s,children:[(0,r.jsxs)("div",{className:"flex items-center flex-1 min-w-0",children:[(0,r.jsx)("div",{className:"flex items-center mr-2 shrink-0",children:(()=>{switch(i.selectedSource){case d.SourceType.AUDIO:return(0,r.jsx)(S.ibD,{className:"text-lg"});case d.SourceType.SPOTIFY:case d.SourceType.SEARCH:return(0,r.jsx)(E.l4C,{className:"text-lg"});case d.SourceType.STOCK:case d.SourceType.SAMPLE:return(0,r.jsx)(C._5g,{className:"text-lg"});default:return(0,r.jsx)(S.ibD,{className:"text-lg"})}})()}),(0,r.jsx)("span",{className:"truncate text-sm font-medium text-gray-900",children:i.selectedSource===d.SourceType.SAMPLE?"No audio selected":z}),(0,r.jsx)("span",{className:"ml-2 px-2 py-0.5 text-xs bg-gray-100 text-gray-600 rounded",children:(()=>{switch(i.selectedSource){case d.SourceType.AUDIO:return"Audio";case d.SourceType.SPOTIFY:return"Spotify";case d.SourceType.SEARCH:return"Search";case d.SourceType.STOCK:return"Sample track";case d.SourceType.SAMPLE:return"Sample";default:return"Unknown"}})()})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2 ml-2",children:[a?(0,r.jsx)(E.s$2,{className:"text-gray-400"}):(0,r.jsx)(E.RiI,{className:"text-gray-400"}),n&&(0,r.jsx)(m.z,{size:"small",theme:"danger",onClick:e=>{e.stopPropagation(),c()},title:"Remove waveform",className:"px-2",children:(0,r.jsx)(E.Xm5,{className:"w-3 h-3"})})]})]}),a&&(0,r.jsxs)("div",{className:"px-3 py-4 bg-white border-t border-gray-200",children:[(i.selectedSource!==d.SourceType.SAMPLE||O)&&(0,r.jsxs)("div",{className:"mb-4",children:[O&&(0,r.jsxs)("div",{className:"w-full mb-2",children:[v&&(0,r.jsx)("p",{className:"mb-1 text-xs font-medium text-gray-700",children:v}),(0,r.jsx)("div",{className:"flex items-center w-full",children:(0,r.jsx)(I.E,{percent:x,className:"h-2"})}),b&&(0,r.jsx)("p",{className:"mt-1 text-xs text-gray-500",children:b})]}),j&&i.selectedSource!==d.SourceType.SAMPLE&&!O&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(T,{isSelectedWaveform:U,selectedSource:i.selectedSource,isUploading:O,audioElement:R,trim:null!==(t=i.trim)&&void 0!==t?t:null==A?void 0:A.trim}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsxs)(m.z,{theme:"light",size:"small",className:"px-2.5",onClick:u,"data-testid":"trim-audio-button",disabled:O,children:[(0,r.jsx)(_.tDd,{className:"mr-1",fontSize:16}),"Trim Audio"]}),Z&&(0,r.jsxs)(m.z,{theme:"light",size:"small",className:"px-2.5",onClick:p,"data-testid":"download-audio-button",disabled:O,children:[(0,r.jsx)(l.RFS,{className:"mr-1",fontSize:16}),(0,r.jsx)(o.Z,{id:"Editor.Source.DownloadAudio",defaultMessage:"Download audio"})]})]})]})]}),F&&(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("p",{className:"text-sm font-medium text-gray-700 mb-2",children:"Audio Source:"}),N]})]})]})};var A=i(44041),F=i(23083),L=i(12544),z=i(7062),O=i(18818),U=i(19487),Z=i(21571);function W(e){let{selectedSource:t,onUpload:i,layout:a}=e,{videoSourceUpload:n}=(0,Z.g)(),s=t===d.SourceType.AUDIO;return(0,r.jsx)(z.g,{customRequest:e=>(i(e),Promise.resolve()),fileList:[],showRemoveIcon:!1,className:"flex w-full",listType:"list","data-testid":"audio-file-picker",accept:(0,O.vT)().join(","),children:(0,r.jsx)(U.Z,{icon:E.Qvc,label:"Upload",description:n?"MP3, WAV, MP4 and short video clips":"MP3, WAV, M4A and more",layout:a,iconBg:"bg-blue-100 text-blue-600",isSelected:s,asDiv:!0})})}var Q=i(62214),B=i(15644),H=i(75590),G=i(54073),V=i.n(G),K=i(78369),q=i(30508),Y=i(82066),X=i(67638);let $=()=>(0,r.jsxs)("article",{className:"flex flex-row w-full p-2 mb-4 border border-gray-400",children:[(0,r.jsx)("div",{className:"w-16 h-16 bg-gray-300 rounded animate-pulse"}),(0,r.jsxs)("div",{className:"inline-flex flex-col w-auto pt-2",children:[(0,r.jsx)("div",{className:"h-4 mb-3 ml-3 bg-gray-300 rounded w-52 animate-pulse"}),(0,r.jsx)("div",{className:"w-32 h-4 ml-3 bg-gray-300 rounded animate-pulse"})]})]}),J=/[^a-zA-Z0-9_\-.\s]/g,ee=e=>{let{data:t,...i}=(0,Y.useQuery)(["search_songs",e],async()=>(e=e.replace(J,"").trim()).length<3?[]:(0,F.Ot)(e),{initialData:[],retry:!1,onError:e=>(0,p.H)(e)});return{tracks:null!=t?t:[],...i}},et=e=>{var t;let{hide:i}=e,{updateEditorState:a,setAudioTrimming:n,waveformConfig:l,captions:u}=(0,f._i)(),p=(0,g.Q5)(),{setStoredURL:x,setPlayableURL:b}=(0,y.FI)(),{setNotSaved:N}
1=(0,k.r)(),[S,E]=(0,s.useState)(),[C,_]=(0,s.useState)(""),I=ee(C),{upsertResource:D,setAudioBlob:R}=(0,w.o0)(),T=C.length>0&&C.length<3,P=(0,Y.useMutation)(["waveform",null==S?void 0:S.id],async()=>(null==S?void 0:S.id)?(0,F.oH)(null==S?void 0:S.id):null,{onSuccess(e){if(!e||!S)return;let t="".concat(S.artists[0].name," - ").concat(S.name),r="spotify_".concat(S.id),s=(null==l?void 0:l.trim)?{...l,trim:{startRatio:0,endRatio:1}}:void 0,o=(0,c.computeShownWaveformData)({waveformData:e,waveformConfig:s||l,width:l.reference.width,audioFileName:t,source:d.SourceType.SEARCH}),m=(0,X.WM)(u);if(p){let i=g.$X.getState().waveforms.find(e=>e.id===p),s=(null==i?void 0:i.audioResourceId)||(p?"".concat(h.AUDIO_ORIGINAL_FILE_ID,"_").concat(p):void 0);s&&R(s,void 0);let l={waveformData:e,shownWaveformData:o,audioFileName:t,selectedSource:d.SourceType.SEARCH,audioResourceId:r,trim:{startRatio:0,endRatio:1}};a({waveforms:g.$X.getState().waveforms.map(e=>e.id===p?{...e,...l}:e),selectedSource:d.SourceType.SEARCH,audioFileName:t,audioResourceId:r,status:d.EditorStatus.LOADED,...m},!1),n(!1)}else a((0,j.y)({waveformData:e,shownWaveformData:o,audioFileName:t,status:d.EditorStatus.LOADED,selectedSource:d.SourceType.SEARCH,audioResourceId:r,waveformConfig:s,...m})),n(!1);v.hj(d.SourceType.SEARCH),x(void 0),b(void 0),D(r,{type:M.CustomFileType.spotify,songId:S.id,publicURL:S.external_urls.spotify,name:t}),N(),i()}}),A=(0,s.useMemo)(()=>V()(async e=>_(e.target.value),300),[]),L=(0,s.useRef)(null),z=(0,s.useCallback)(e=>{let{tracks:t,isSuccess:i}=I;if("Enter"===e.key&&S&&i&&!P.isLoading){e.preventDefault(),P.mutate();return}if(0===t.length)return;let a=S?t.findIndex(e=>e.id===S.id):-1;if("ArrowDown"===e.key){e.preventDefault();let i=a<t.length-1?a+1:0;E(t[i])}else if("ArrowUp"===e.key){e.preventDefault();let i=a<=0?t.length-1:a-1;E(t[i])}},[I,S,P]);return(0,s.useEffect)(()=>{var e,t;null===(t=L.current)||void 0===t||null===(e=t.scrollIntoView)||void 0===e||e.call(t,{block:"nearest",behavior:"smooth"})},[null==S?void 0:S.id]),(0,r.jsxs)("div",{className:"flex min-h-0 flex-col overflow-hidden pt-4",onKeyDown:z,children:[(0,r.jsxs)("div",{className:"shrink-0",children:[(0,r.jsx)("p",{className:"mb-4",children:"Start typing to search for a song"}),I.isError&&(0,r.jsx)("p",{className:"mb-3 text-red-600",children:(0,r.jsx)(o.Z,{id:"Editor.Spotify.Errored"})}),I.isFetched&&C.length>3&&!I.tracks.length&&(0,r.jsx)("p",{className:"mb-3 text-red-600",children:(0,r.jsx)(o.Z,{id:"Editor.Spotify.NotFound"})}),(0,r.jsx)(K.I,{label:"Song name or artist","data-testid":"search-input",type:"text",className:"inline-flex w-full",placeholder:"Bohemian Rhapsody, Queen",onChange:A,onKeyDown:z,autoFocus:!0}),T&&(0,r.jsx)("p",{className:"my-1 text-xs italic text-gray-500",children:"minimum 3 characters needed to search"}),(0,r.jsx)("hr",{className:"my-4 border-gray-400"})]}),(0,r.jsxs)("div",{className:"relative min-h-0 overflow-y-auto overscroll-contain",children:[I.isFetching&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)($,{}),(0,r.jsx)($,{}),(0,r.jsx)($,{}),(0,r.jsx)($,{})]}),I.tracks.length>0&&(0,r.jsx)(q.Z,{name:"select-file-type","data-testid":"select-file-type",value:null!==(t=null==S?void 0:S.id)&&void 0!==t?t:"",onChange:e=>{E(I.tracks.find(t=>t.id===e))},spaceItems:!0,children:I.tracks.map(e=>{var t;let i=null===(t=e.album.images)||void 0===t?void 0:t[0],a=(null==S?void 0:S.id)===e.id;return(0,r.jsx)("div",{ref:a?L:void 0,children:(0,r.jsx)(q.z,{value:e.id,rounded:!0,children:(0,r.jsxs)("div",{className:"inline-flex flex-row",children:[(null==i?void 0:i.url)&&(0,r.jsx)("img",{src:i.url,width:i.width,height:i.height,draggable:!1,className:"w-16 h-16"}),(0,r.jsxs)("div",{className:"flex flex-col items-start w-full ml-4",children:[(0,r.jsx)("span",{className:"font-semibold",children:e.name}),(0,r.jsx)("span",{className:"text-sm",children:e.artists[0].name})]})]})})},e.id)})})]}),I.isSuccess&&(0,r.jsx)(m.z,{theme:"primary",className:"mt-2 shrink-0",onClick:()=>P.mutate(),loading:P.isLoading,disabled:!S,children:(0,r.jsx)(o.Z,{id:"Editor.Spotify.Confirm"})})]})};function ei(e){let{selectedSource:t,layout:i}
1=e,[a,n]=(0,s.useState)(!1),o=t===d.SourceType.SEARCH;return(0,r.jsxs)("div",{className:"p-0",children:[(0,r.jsx)(U.Z,{icon:l.RB5,label:"Search songs",description:"Find music from Spotify's catalog",layout:i,iconBg:"bg-violet-100 text-violet-600",isSelected:o,onClick:()=>n(!0),buttonProps:{"data-testid":"search-songs-button"}}),(0,r.jsxs)(B.Q,{open:a,onClose:()=>n(!1),className:"flex max-h-[calc(100dvh-2rem)] w-full max-w-xl flex-col sm:max-h-[calc(100dvh-4rem)] md:w-2/3 lg:w-1/2",dataTestId:"search-modal",children:[(0,r.jsxs)(H.$N,{as:"h3",className:"flex shrink-0 items-center text-base font-semibold leading-6 text-gray-900",children:[(0,r.jsx)(l.RB5,{className:"mr-2",fontSize:20}),(0,r.jsx)("span",{className:"whitespace-nowrap",children:"Search songs"})]}),(0,r.jsx)(et,{hide:()=>n(!1)})]})]})}var ea=i(94133),en=i(34646);(a=n||(n={}))[a.isInitial=0]="isInitial",a[a.isEmpty=1]="isEmpty",a[a.isInvalid=2]="isInvalid",a[a.isValidating=3]="isValidating",a[a.isValid=4]="isValid";let er=()=>{let[e,t]=(0,s.useState)(n.isInitial),[i,a]=(0,s.useState)(""),[r,o]=(0,s.use
1State)("");return{validate:e=>{if(o(e),0===e.length){t(n.isEmpty);return}let i=e.match(/^spotify:track:([0-9a-zA-Z]+)$/);if(i){a(i[1]),t(n.isValid);return}if(i=e.match(/^https:\/\/open\.spotify\.com\/([a-zA-Z-]+\/)?track\/([0-9a-zA-Z]{22})?/)){a(i[2]),t(n.isValid);return}t(n.isInvalid)},trackId:i,spotifyURL:r,isValid:e===n.isValid,isInvalid:e===n.isInvalid,isInitial:e===n.isInitial,isEmpty:e===n.isEmpty}},es=e=>{let{hide:t}=e,{updateEditorState:i,setAudioTrimming:a,waveformConfig:n,captions:s}=(0,f._i)(),l=(0,g.Q5)(),{setStoredURL:u,setPlayableURL:x}=(0,y.FI)(),{setNotSaved:b}=(0,k.r)(),N=er(),{upsertResource:S,setAudioBlob:E}=(0,w.o0)(),C=(0,Y.useQuery)(["fetch_track",N.trackId],async()=>{if(N.isValid&&N.trackId)return(0,F.OO)(N.trackId)}),_=(0,Y.useMutation)(["fetch_waveform",N.trackId],async()=>{if(C.data&&N.trackId)return(0,F.oH)(N.trackId)},{onSuccess(e){if(!e||!C.data)return;let r="".concat(C.data.name," - ").concat(C.data.artists[0].name),o="spotify_".concat(C.data.id),m=(null==n?void 0:n.trim)?{...n,trim:{startRatio:0,endRatio:1}}:void 0,p=(0,c.computeShownWaveformData)({waveformData:e,waveformConfig:m||n,width:n.reference.width,audioFileName:r,source:d.SourceType.SPOTIFY}),f=(0,X.WM)(s);if(l){let t=g.$X.getState().waveforms.find(e=>e.id===l),n=(null==t?void 0:t.audioResourceId)||(l?"".concat(h.AUDIO_ORIGINAL_FILE_ID,"_").concat(l):void 0);n&&E(n,void 0);let s={waveformData:e,shownWaveformData:p,audioFileName:r,selectedSource:d.SourceType.SPOTIFY,audioResourceId:o,trim:{startRatio:0,endRatio:1}};i({waveforms:g.$X.getState().waveforms.map(e=>e.id===l?{...e,...s}:e),selectedSource:d.SourceType.SPOTIFY,audioFileName:r,audioResourceId:o,status:d.EditorStatus.LOADED,...f},!1),a(!1)}else i((0,j.y)({waveformData:e,shownWaveformData:p,audioFileName:r,status:d.EditorStatus.LOADED,selectedSource:d.SourceType.SPOTIFY,audioResourceId:o,waveformConfig:m,...f})),a(!1);v.hj(d.SourceType.SPOTIFY),u(void 0),x(void 0),S(o,{type:M.CustomFileType.spotify,songId:C.data.id,publicURL:N.spotifyURL,name:r}),b(),t()},onError(e){(0,p.H)(e)}});return(0,r.jsxs)("div",{className:"flex flex-col pt-4",children:[(0,r.jsx)(en.dk,{className:"mb-4",children:(0,r.jsx)(o.Z,{id:"Editor.Source.GetSpotify"})}),C.data&&!C.isFetching&&(0,r.jsxs)("div",{className:"text-dark-blue flex flex-col mb-4 font-semibold",children:[(0,r.jsxs)("span",{className:"mb-2",children:["Song Name: ",C.data.name]}),(0,r.jsxs)("span",{children:["Artist: ",C.data.artists[0].name]})]}),C.isFetching?(0,r.jsx)("div",{className:"flex justify-center w-full",children:(0,r.jsx)(ea.p,{fontSize:60})}):(0,r.jsx)("div",{className:"flex flex-col",children:(0,r.jsx)(K.I,{autoFocus:!0,label:"Spotify Song Link",defaultValue:N.spotifyURL,"data-testid":"spotify-input",type:"url",className:"inline-flex flex-col w-full",placeholder:"https://open.spotify.com/track/3vT9XAmtjEushH29JZNEOv",onChange:e=>N.validate(e.target.value),errorText:N.isInvalid?(0,r.jsx)(o.Z,{id:"Editor.Spotify.InvalidURL"}):N.isEmpty?(0,r.jsx)(o.Z,{id:"Editor.Spotify.EmptyField"}):C.isError?(0,r.jsx)(o.Z,{id:"Editor.Spotify.Errored"}):void 0})}),N.isValid&&C.data&&C.isFetched&&(0,r.jsx)(m.z,{theme:"primary",className:"mt-4",onClick:()=>_.mutate(),loading:_.isLoading,"data-testid":"spotify-confirm",children:(0,r.jsx)(o.Z,{id:"Editor.Spotify.Confirm"})})]})};function eo(e){let{selectedSource:t,layout:i}=e,[a,n]=(0,s.useState)(!1),o=t===d.SourceType.SPOTIFY;return(0,r.jsxs)("div",{className:"p-0",children:[(0,r.jsx)(U.Z,{icon:E.l4C,label:"Spotify link",description:"Paste a track URL",layout:i,iconBg:"bg-green-100 text-green-600",isSelected:o,onClick:()=>n(!0),buttonProps:{"data-testid":"spotify-picker"}}),(0,r.jsxs)(B.Q,{open:a,onClose:()=>n(!1),className:"w-full md:w-2/3 lg:w-1/2 max-w-xl",dataTestId:"spotify-modal",children:[(0,r.jsxs)(H.$N,{as:"h3",className:"text-base font-semibold leading-6 text-gray-900 flex items-center",children:[(0,r.jsx)(E.l4C,{className:"mr-2",fontSize:20}),"Spotify link"]}),(0,r.jsx)(es,{hide:()=>n(!1)})]})]})}var el=i(54497),ed=i(56175),ec=i(52350),eu=i(47182);let em=new Map,ep=new Map;async function eh(e){let t=em.get(e.id);if(t)return t;let i=ep.get(e.id);if(i)return i;let a=(async()=>{let t=await fetch((0,eu.VS)(e.id));if(!t.ok)throw Error('Failed to load waveform for "'.concat(e.id,'" (HTTP ').concat(t.status,")"));let i=function(e,t){if(!Array.isArray(e)||0===e.length)throw Error('Stock waveform "'.concat(t,'" is not a non-empty array'));if(!e.every(e=>"number"==typeof e&&Number.isFinite(e)&&e>=0&&e<=h.SAMPLE_HEIGHT))throw Error('Stock waveform "'.concat(t,'" has values outside 0..').concat(h.SAMPLE_HEIGHT));return e}(await t.json(),e.id);return em.set(e.id,i),i})().finally(()=>{ep.delete(e.id)});return ep.set(e.id,a),a}let ex=e=>{let{hide:t}=e,{pickStockTrack:i}=function(){let{updateEditorState:e,setAudioTrimming:t,waveformConfig:i,captions:a}=(0,f._i)(),n=(0,g.Q5)(),{setPlayableURL:r,setStoredURL:o}=(0,y.FI)(),{upsertResource:l,setAudioBlob:m}=(0,w.o0)(),{setNotSaved:p}=(0,k.r)();return{pickStockTrack:(0,s.useCallback)(async s=>{var x,f,b;let y;let w=await eh(s),N=(0,eu.cz)(s.id),k=(null==i?void 0:i.trim)?{...i,trim:{startRatio:0,endRatio:1}}:void 0,S=(0,c.computeShownWaveformData)({waveformData:w,waveformConfig:k||i,width:i.reference.width,audioFileName:s.name,source:d.SourceType.STOCK}),E={waveformData:w,shownWaveformData:S,audioFileName:s.name,selectedSource:d.SourceType.STOCK,audioResourceId:N,trim:{startRatio:0,endRatio:1}},C=g.$X.getState().waveforms,_=n?(null===(x=C.find(e=>e.id===n))||void 0===x?void 0:x.audioResourceId)||"".concat(h.AUDIO_ORIGINAL_FILE_ID,"_").concat(n):(null===(f=C[0])||void 0===f?void 0:f.audioResourceId)||h.AUDIO_ORIGINAL_FILE_ID;_&&m(_,void 0),y=n?C.map(e=>e.id===n?{...e,...E}:e):C.length>0?C.map((e,t)=>0===t?{...e,...E}:e):[{...u.defaultEditorConfig.waveforms[0],...E}];let I=null!=n?n:null===(b=y[0])||void 0===b?void 0:b.id,D=(0,X.WM)(a);l(N,{type:M.CustomFileType.public,publicURL:s.publicURL,name:s.name}),o(s.publicURL),r(s.publicURL),e((0,j.y)({waveforms:y,...void 0!==I&&{selectedWaveformId:I},waveformData:w,shownWaveformData:S,status:d.EditorStatus.LOADED,selectedSource:d.SourceType.STOCK,audioFileName:s.name,audioResourceId:N,waveformConfig:k,...D}),!1),t(!1),v.hj(d.SourceType.STOCK),p()},[i,n,a,e,t,r,o,l,m,p])}}
1(),[a,n]=(0,s.useState)(null),[l,m]=(0,s.useState)(null),[p,x]=(0,s.useState)(null),b=(0,s.useRef)(null);(0,s.useEffect)(()=>()=>{var e;null===(e=b.current)||void 0===e||e.pause(),b.current=null},[]);let N=e=>{var t,i;if(a===e.id){null===(i=b.current)||void 0===i||i.pause(),n(null);return}null===(t=b.current)||void 0===t||t.pause();let r=new Audio(e.publicURL);r.onended=()=>n(null),b.current=r,r.play().catch(()=>n(null)),n(e.id)},S=async e=>{var a;if(!l){null===(a=b.current)||void 0===a||a.pause(),n(null),x(null),m(e.id);try{await i(e),t()}catch(t){m(null),x(e.id)}}};return 0===eu.NP.length?(0,r.jsx)("p",{className:"py-6 text-sm text-gray-500",children:(0,r.jsx)(o.Z,{id:"Editor.StockAudio.Empty",defaultMessage:"No sample tracks available yet."})}):(0,r.jsxs)("div",{className:"flex flex-col gap-2 pt-4",children:[(0,r.jsx)("p",{className:"mb-2 text-sm text-gray-600",children:(0,r.jsx)(o.Z,{id:"Editor.StockAudio.Subtitle",defaultMessage:"Pick a sample track to try out your design."})}),eu.NP.map(e=>{var t;return(0,r.jsxs)("div",{className:"flex flex-col gap-1 rounded-lg border border-gray-200 p-3",children:[(0,r.jsxs)("div",{className:"flex flex-row items-center gap-3",children:[(0,r.jsx)("button",{type:"button",onClick:()=>N(e),"aria-label":a===e.id?"Pause preview":"Play preview",className:"shrink-0 flex h-9 w-9 items-center justify-center rounded-full bg-blue-100 text-blue-600 hover:bg-blue-200",children:a===e.id?(0,r.jsx)(el.Z,{size:18}):(0,r.jsx)(ed.Z,{size:18})}),(0,r.jsxs)("div",{className:"min-w-0 flex flex-col",children:[(0,r.jsx)("span",{className:"truncate text-sm font-medium text-gray-900",children:e.name}),(0,r.jsx)("span",{className:"text-xs text-gray-500",children:(t=e.durationSec,"".concat(Math.floor(t/60),":").concat(Math.round(t%60).toString().padStart(2,"0")))})]}),(0,r.jsxs)("button",{type:"button",onClick:()=>S(e),disabled:null!==l,"data-testid":"stock-track-".concat(e.id),className:"ml-auto shrink-0 flex items-center gap-1.5 rounded-md bg-blue-600 px-3 py-1.5 text-sm font-medium text-white hover:bg-blue-700 disabled:opacity-50",children:[l===e.id&&(0,r.jsx)(ec.Z,{size:14,className:"animate-spin"}),(0,r.jsx)(o.Z,{id:"Editor.StockAudio.Use",defaultMessage:"Use"})]})]}),p===e.id&&(0,r.jsx)("p",{className:"text-xs text-red-600","data-testid":"stock-track-error-".concat(e.id),children:(0,r.jsx)(o.Z,{id:"Editor.StockAudio.LoadFailed",defaultMessage:"Couldn't load this track. Check your connection and try again."})})]},e.id)})]})};function ef(e){let{selectedSource:t,layout:i}=e,[a,n]=(0,s.useState)(!1),o=t===d.SourceType.STOCK;return(0,r.jsxs)("div",{className:"p-0",children:[(0,r.jsx)(U.Z,{icon:C._5g,label:"Sample tracks",description:"Try a stock track",layout:i,iconBg:"bg-purple-100 text-purple-600",isSelected:o,onClick:()=>n(!0),buttonProps:{"data-testid":"stock-picker"}}),(0,r.jsxs)(B.Q,{open:a,onClose:()=>n(!1),className:"w-full md:w-2/3 lg:w-1/2 max-w-xl",dataTestId:"stock-modal",children:[(0,r.jsxs)(H.$N,{as:"h3",className:"text-base font-semibold leading-6 text-gray-900 flex items-center",children:[(0,r.jsx)(C._5g,{className:"mr-2",fontSize:20}),"Sample tracks"]}),(0,r.jsx)(ex,{hide:()=>n(!1)})]})]})}function eg(e){let{selectedSource:t,onUpload:i,layout:a}=e,{stockAudio:n}=(0,Z.g)();return(0,r.jsxs)("div",{className:"list"===a?"flex flex-col gap-2":"grid grid-cols-2 gap-2 [&>*]:min-w-0",children:[(0,r.jsx)(W,{selectedSource:t,onUpload:i,layout:a}),(0,r.jsx)(Q.q,{onSave:i,layout:a}),(0,r.jsx)(ei,{selectedSource:t,layout:a}),(0,r.jsx)(eo,{selectedSource:t,layout:a}),n&&(0,r.jsx)(ef,{selectedSource:t,layout:a})]})}var ev=i(34826),eb=i(3752),ey=i(34747);let ej=(e,t,i,a)=>{let n=(null==e?void 0:e.trim)?{...e,trim:{startRatio:0,endRatio:1}}:void 0,r=(0,c.computeShownWaveformData)({waveformData:a,waveformConfig:n||e,width:e.reference.width,audioFileName:t,source:i});return(0,j.y)({waveformData:a,shownWaveformData:r,status:d.EditorStatus.LOADED,selectedSource:i,audioFileName:t,waveformConfig:n})},ew=()=>{let{uploadSourceMedia:e}=(0,ev.t)(),t=(0,f._i)(),i=(0,g.Q5)(),a=(0,eb.d)(),n=(0,ey._)(e=>e.uploads);return(0,r.jsx)(eN,{playerState:(0,y.FI)(),editorState:{...t,selectedWaveformId:i},saveState:(0,k.r)(),designState:(0,b.hl)(),resourceState:(0,w.o0)(),messageState:(0,A.G)(),uploadAudio:e,layout:!0===a?"list":"grid",uploads:n})};class eN extends s.Component{componentDidMount(){this.mounted=!0}componentWillUnmount(){this.mounted=!1}componentDidUpdate(){var e;let{waveforms:t=[],selectedWaveformId:i,updateEditorState:a}=this.props.editorState;1===t.length&&(null===(e=t[0])||void 0===e?void 0:e.selectedSource)===d.SourceType.SAMPLE&&!i&&t[0]&&a({selectedWaveformId:t[0].id},!1)}render(){var e,t,i,a;let{waveforms:n=[],selectedWaveformId:s,updateEditorState:c,addWaveform:u,removeWaveform:p}=this.props.editorState,{uploads:f}=this.props,g=n.find(e=>e.id===s),v=1===n.length&&(null===(e=n[0])||void 0===e?void 0:e.selectedSource)===d.SourceType.SAMPLE,b=v?n[0]:g,y=v?(a=null===(t=n[0])||void 0===t?void 0:t.id)&&f[a]?f[a]:Object.values(f)[0]:void 0,j=null!==(i=null==y?void 0:y.progress)&&void 0!==i?i:0,w=e=>{s===e?c({selectedWaveformId:void 0},!1):c({selectedWaveformId:e},!1)},k=b?(0,r.jsx)(eg,{selectedSource:b.selectedSource,onUpload:this.handleChange,onUseSample:this.useSample,layout:this.props.layout}):null;return(0,r.jsxs)(r.Fragment,{children:[v?(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-base font-semibold text-gray-900 mb-1",children:(0,r.jsx)(o.Z,{id:"Editor.Source.GetStarted",defaultMessage:"Add your audio"})}),(0,r.jsx)("p",{className:"text-sm text-gray-600 mb-4",children:(0,r.jsx)(o.Z,{id:"Editor.Source.GetStartedSubtitle",defaultMessage:"Choose how you want to add audio to your design"})})]}),j>0&&j<99&&y&&(0,r.jsxs)("div",{className:"w-full mb-3",children:[y.label&&(0,r.jsx)("p",{className:"mb-1 text-xs font-medium text-gray-700",children:y.label}),(0,r.jsx)(I.E,{percent:j,className:"h-2"}),y.description&&(0,r.jsx)("p",{className:"mt-1 text-xs text-gray-500",children:y.description})]}),k]}):n.length>0&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("p",{className:"text-sm text-gray-900 mb-3 font-medium",children:"Sound Waves"}),(0,r.jsx)("div",{className:"space-y-2 mb-4",children:n.map(e=>{var t;let i=f[e.id];return(0,r.jsx)(P,{waveform:e,isExpanded:e.id===s,canRemove:n.length>1&&this.props.designState.editMode===N.uz.Editable,onToggle:()=>w(e.id),onRemove:()=>p(e.id),onTrim:()=>this.props.editorState.setAudioTrimming(!0),onDownloadAudio:()=>this.downloadWaveformAudio(e.id),uploadProgress:null!==(t=null==i?void 0:i.progress)&&void 0!==t?t:0,uploadStatusLabel:null==i?void 0:i.label,uploadStatusDescription:null==i?void 0:i.description,showActionRow:e.selectedSource!==d.SourceType.SAMPLE,children:k},e.id)})})]}),this.props.designState.editMode===N.uz.Editable&&!v&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(x.i,{}),(0,r.jsxs)(m.z,{onClick:()=>u(),disabled:n.length>=h.MAX_WAVEFORMS,block:!0,theme:"light",justify:"start",children:[(0,r.jsx)(l.Lfi,{className:"mr-2",fontSize:20}),"Add Sound Wave",n.length>0&&" (".concat(n.length,"/").concat(h.MAX_WAVEFORMS,")")]})]})]})}constructor(e){super(e),this.mounted=!1,this.handleChange=async e=>{e.file&&this.mounted&&await this.props.uploadAudio(e.file,{onProgress:t=>{var i;null===(i=e.onProgress)||void 0===i||i.call(e,{percent:t},e.file)},onSuccess:()=>{var t;this.mounted&&(null===(t=e.onSuccess)||void 0===t||t.call(e,{status:"done"},e.file))},onError:t=>{var i,a,n;(0,p.H)(null!==(a=null==t?void 0:t.message)&&void 0!==a?a:t,{extra:{fileName:null===(i=e.file)||void 0===i?void 0:i.name,message:null==t?void 0:t.message}}),this.mounted&&(e.file&&(e.file.status="error",e.file.response="Couldn't process the audio file"),this.setState({currentFile:null!==(n=e.file)&&void 0!==n?n:null}))}})},this.useSample=()=>{let{selectedWaveformId:e,updateWaveform:t,updateEditorState:i,setAudioTrimming:a,waveformConfig:n,captions:r}
1=this.props.editorState,s=(0,X.WM)(r),o=ej(n,u.SAMPLE_FILE,d.SourceType.SAMPLE,u.initialContextData.waveformData);e?(t(e,{waveformData:u.initialContextData.waveformData,shownWaveformData:o.shownWaveformData,audioFileName:u.SAMPLE_FILE,selectedSource:d.SourceType.SAMPLE,audioResourceId:void 0,trim:{startRatio:0,endRatio:1}}),Object.keys(s).length>0&&i(s,!1)):i({...o,...s}),a(!1),v.hj(d.SourceType.SAMPLE)},this.downloadWaveformAudio=async e=>{var t,i;let a=null===(t=this.props.editorState.waveforms)||void 0===t?void 0:t.find(t=>t.id===e);if(!a)return;let n=a.audioResourceId||h.AUDIO_ORIGINAL_FILE_ID,s=null===(i=this.props.resourceState.resources)||void 0===i?void 0:i[n],l=(null==s?void 0:s.type)===M.CustomFileType.bucket?s.pathInBucket:void 0;if(l)try{let{url:e}=await (0,F.sH)(l);await (0,L.IG)(e,s.name||"Recorded audio.webm")}catch(t){(0,p.H)(t,{extra:{waveformId:e,pathInBucket:l}}),this.props.messageState.error((0,r.jsx)(o.Z,{id:"Editor.Source.DownloadAudioFailed",defaultMessage:"Failed to download audio."}))}},this.state={currentFile:null}}}},26607:function(e,t,i){"use strict";i.d(t,{X:function(){return W}});var a=i(52322),n=i(2784),r=i(33256),s=i(77298),o=i(12524),l=i.n(o),d=i(99127),c=i(42658),u=i(21353),m=i(40381),p=i(13366),h=i(40568),x=i(25139),f=i(38986),g=i(28407),v=i(18064),b=i(23083),y=i(63241),j=i(52522),w=i(30118),N=i(65089),k=i(14084),S=i(2431),E=i(44041),C=i(118),_=i(18997),I=i(95468),D=i(70082),R=i(11732),T=i(67638),M=i(3438),P=i(33065),A=i(96434),F=i(19382);let L="rounded-lg border border-gray-200 bg-white shadow-sm",z="".concat(L," p-3");function O(e){return Math.round(e/100)/10}let U=e=>{let{label:t,ms:i,onCommit:n}=e,r=(0,F.l)(O(i),e=>n(Math.round(1e3*e)));return(0,a.jsx)("input",{"aria-label":t,type:"number",min:0,step:.1,className:l()("w-11 border-0 bg-transparent p-0 text-xs tabular-nums text-gray-900 focus:outline-none focus:ring-0 [appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none","min-h-[44px] md:min-h-0"),...r})},Z=e=>{let{checked:t,onChange:i,label:n,description:s,testId:o}=e;return(0,a.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-sm font-medium text-gray-900",children:n}),(0,a.jsx)("p",{className:"mt-1 text-xs text-gray-600",children:s})]}),(0,a.jsxs)(r.rs,{checked:t,onChange:i,"aria-label":n,"data-testid":o,className:l()("relative inline-flex w-11 shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-indigo-500 focus-visible:ring-offset-2",t?"bg-indigo-600":"bg-gray-200"),children:[(0,a.jsx)("span",{className:"sr-only",children:n}),(0,a.jsx)("span",{"aria-hidden":!0,className:l()("pointer-events-none inline-block h-4 w-4 rounded-full bg-white shadow ring-0 transition",t?"translate-x-6":"translate-x-0")})]})]})},W=()=>{var e;let{designId:t,saveEverything:i}=(0,j.hl)(),{captions:r,updateEditorState:o,waveforms:F,audioResourceId:W}
1=(0,w._i)(),{resources:Q,pendingResourceCount:B}=(0,N.o0)(),H=(0,A.z)(e=>e.focusedCueIndex),G=(0,A.z)(e=>e.setFocusedCueIndex),V=(0,E.G)(),{setNotSaved:K}=(0,C.r)(),[q,Y]=(0,n.useState)(!1),[X,$]=(0,n.useState)(!0),[J,ee]=(0,n.useState)(!1),[et,ei]=(0,n.useState)(!1),[ea,en]=(0,n.useState)(null),er=(0,n.useMemo)(()=>(0,h.listCaptionsConfigCues)(r),[r]),es=(0,h.captionsConfigCueCount)(r),eo=es>0,el=(0,h.isCaptionsKaraokeModeEnabled)(r),ed=!(0,h.isCaptionsFontSizeStable)(r),ec=(0,h.captionsConfigCuesMissingWordTimingsCount)(r),eu=(0,S.YZ)(e=>e.designJobs),em=t?eu["".concat(x.A9).concat(t)]:void 0,ep=(null==em?void 0:em.status)===m.E.queued||(null==em?void 0:em.status)===m.E.inprogress,eh=q||ep,ex=(0,g._l)(Q[(null==F?void 0:null===(e=F[0])||void 0===e?void 0:e.audioResourceId)||W||f.AUDIO_ORIGINAL_FILE_ID]),ef="unsupported"===ex.kind,eg=B>0,ev="missing"===ex.kind,eb=eh||ef||eg||ev,ey=eg?"Your audio is still uploading. Transcribe will unlock when the upload finishes so we can read the file from storage.":ef?"Upload an audio or video file to transcribe. Spotify and YouTube tracks cannot be transcribed.":ev?"Upload and save your audio first. Transcription needs the file in cloud storage, not only on this device.":void 0;(0,n.useEffect)(()=>()=>G(null),[G]);let ej=(0,n.useCallback)(function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];o({captions:t?(0,p.ff)(e):e}),K(),en(null)},[K,o]);(0,n.useEffect)(()=>{ep&&(0,T.ZF)()},[ep]);let ew=(0,k.s)(e=>{var t,i;return null===(i=e.designDocument)||void 0===i?void 0:null===(t=i.config)||void 0===t?void 0:t.captions});(0,n.useEffect)(()=>{!eo&&(null==em?void 0:em.status)===m.E.completed&&(0,T.n)(ew)&&o({captions:(0,p.ff)(ew)},!1)},[eo,null==em?void 0:em.status,ew,o]);let eN=(0,n.useCallback)(async()=>{if(ep)return;let e=eo?r:null;ee(!1),en(null),Y(!0);try{var a,n,s,l;let r=null!=t?t:await i();if(!r){V.error("Save the design before transcribing."),M.N({surface:"editor",failure_code:"save_required"});return}M.gJ({surface:"editor",designId:r,retranscribe:!!e});let{jobName:d}=await (0,b.um)({},r);await S.YZ.getState().waitForDesignJobCompletion(d,r,I.KK);let c=await (0,b.rT)(r,v.Pm.BASIC).catch(()=>void 0),u=null!==(l=null==c?void 0:null===(a=c.config)||void 0===a?void 0:a.captions)&&void 0!==l?l:null===(s=k.s.getState().designDocument)||void 0===s?void 0:null===(n=s.config)||void 0===n?void 0:n.captions,m=(0,D.Gx)(u);e?(m.has_captions&&u&&(o({captions:(0,p.ff)((0,h.replaceCaptionsConfigCues)(e,u))}),en(e)),K()):(0,T.n)(u)&&o({captions:(0,p.ff)(u)},!1),M.nR({surface:"editor",designId:r,...m}),m.has_captions||V.info("No speech found",e?"Transcription finished but found no words in this audio. Your existing captions were kept.":"Transcription finished but found no words in this audio. Check that the file has speech.")}catch(i){let e=(0,P.P8)(i);(0,_.H)(Error(e)),M.N({surface:"editor",designId:null!=t?t:void 0,failure_code:(0,D.B8)(i),...(0,D.HS)(i)}),V.error(e)}finally{Y(!1)}},[r,t,eo,V,i,K,ep,o]),ek=(0,n.useCallback)(()=>{r&&(G(null),ei(!1),(0,T.HV)(),ej((0,h.clearCaptionsConfigCues)(r)))},[r,G,ej]),eS=(0,n.useCallback)(()=>{ea&&(o({captions:ea}),K(),en(null))},[ea,K,o]);return(0,a.jsxs)("div",{"data-testid":"captions-panel",className:"flex min-h-0 flex-col gap-4 lg:h-[calc(100vh-7.5rem)]",children:[(0,a.jsxs)("div",{className:"hidden shrink-0 lg:block",children:[(0,a.jsx)("p",{className:"mb-1 text-base font-semibold text-gray-900",children:"Captions"}),(0,a.jsx)("p",{className:"text-sm text-gray-600",children:"Transcribe the uploaded audio, then fix the wording and timing."})]}),(0,a.jsxs)("div",{className:"shrink-0 space-y-2",children:[J&&!eh?(0,a.jsxs)("div",{role:"alertdialog","aria-labelledby":"retranscribe-confirm-title","aria-describedby":"retranscribe-confirm-body",className:"space-y-2 rounded-lg border border-amber-200 bg-amber-50 p-3",children:[(0,a.jsxs)("p",{id:"retranscribe-confirm-title",className:"text-sm font-medium text-gray-900",children:["Replace all ",es," ",1===es?"cue":"cues","?"]}),(0,a.jsx)("p",{id:"retranscribe-confirm-body",className:"text-xs text-gray-700",children:"A new transcription replaces your caption text and timing edits. Karaoke mode and font size settings are kept."}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(u.z,{type:"button",theme:"primary",size:"small",onClick:eN,children:"Replace captions"}),(0,a.jsx)(u.z,{type:"button",theme:"light",size:"small",onClick:()=>ee(!1),children:"Cancel"})]})]}):(0,a.jsx)(u.z,{type:"button",theme:eo?"light":"primary",block:!0,loading:eh,disabled:eb,title:ey,onClick:eo?()=>ee(!0):eN,children:eh?"Transcribingâ¦":eo?"Re-transcribe":"Transcribe"}),!eh&&ey&&(0,a.jsxs)("p",{className:"flex items-start gap-1.5 text-xs text-amber-800","data-testid":"transcribe-disabled-reason",children:[(0,a.jsx)(d.ocf,{className:"mt-0.5 shrink-0","aria-hidden":!0}),(0,a.jsx)("span",{children:ey})]}),eh&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(y.L,{job:ep?em:void 0}),(0,a.jsx)("p",{className:"text-xs text-gray-500",children:eo?"Transcribing again â your current captions stay until the new ones are ready. This can take a few minutes; it keeps running if you switch tabs.":"Transcribing the uploaded audio â this can take a few minutes. Feel free to switch tabs; it keeps running."})]}),!eh&&ea&&(0,a.jsxs)("div",{role:"status",className:"flex items-center justify-between gap-2 rounded-md bg-indigo-50 px-2 py-1.5 text-xs text-indigo-900",children:[(0,a.jsx)("span",{children:"Captions replaced with a new transcription."}),(0,a.jsx)("button",{type:"button",onClick:eS,className:"shrink-0 font-medium text-indigo-700 underline hover:text-indigo-900",children:"Undo"})]})]}),eo?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("fieldset",{disabled:eh,className:"contents",children:(0,a.jsxs)("section",{className:l()(z,"shrink-0 space-y-2"),"data-testid":"captions-options",children:[(0,a.jsx)(Z,{checked:ed,onChange:e=>{r&&((0,R.Zv)({adaptiveFontSize:e}),ej((0,h.updateCaptionsConfigOptions)(r,{fontSizeMode:e?"adaptive":"stable"})))},label:"Adaptive font size",description:"Resize each cue to fit its text. Off keeps one size for every cue.",testId:"captions-adaptive-font-size"}),(0,a.jsx)(Z,{checked:el,onChange:e=>{r&&((0,R.Zv)({karaokeMode:e}
1),ej((0,h.updateCaptionsConfigOptions)(r,{karaokeMode:e})))},label:"Karaoke mode",description:"Highlight each word in sync with speech in the exported video.",testId:"captions-karaoke-mode"}),el&&ec>0&&(0,a.jsxs)("p",{className:"flex items-start gap-1.5 rounded-md bg-amber-50 px-2 py-1.5 text-xs text-amber-800",children:[(0,a.jsx)(d.ocf,{className:"mt-0.5 shrink-0","aria-hidden":!0}),(0,a.jsxs)("span",{children:[ec," edited ",1===ec?"cue":"cues"," ","lost ",1===ec?"its":"their"," word timing and will fade in instead of highlighting word by word."]})]})]})}),(0,a.jsxs)("section",{"data-testid":"caption-cues-panel",className:l()(L,"flex flex-col",X&&!et?"min-h-0 flex-1":"shrink-0"),children:[(0,a.jsxs)("div",{className:"flex w-full items-center gap-2 p-3",children:[(0,a.jsxs)("button",{type:"button",onClick:()=>$(e=>!e),"aria-expanded":X,className:"flex min-w-0 flex-1 items-center justify-between gap-2 text-left",children:[(0,a.jsxs)("span",{className:"text-sm font-medium text-gray-900",children:["Caption cues",(0,a.jsxs)("span",{className:"ml-1.5 font-normal text-gray-500",children:["(",es,")"]})]}),(0,a.jsx)(s.v4q,{className:l()("h-4 w-4 shrink-0 text-gray-400 transition-transform duration-200",X&&"rotate-180"),"aria-hidden":!0})]}),(0,a.jsx)("button",{type:"button",onClick:()=>ei(!0),disabled:eh||et,className:"shrink-0 text-xs font-medium text-gray-500 hover:text-red-600 disabled:cursor-not-allowed disabled:opacity-40",children:"Delete captions"})]}),et?(0,a.jsxs)("div",{role:"alertdialog","aria-labelledby":"delete-captions-confirm-title","aria-describedby":"delete-captions-confirm-body",className:"space-y-2 border-t border-amber-100 bg-amber-50 p-3",children:[(0,a.jsx)("p",{id:"delete-captions-confirm-title",className:"text-sm font-medium text-gray-900",children:"Delete all captions?"}),(0,a.jsx)("p",{id:"delete-captions-confirm-body",className:"text-xs text-gray-700",children:"This removes every caption cue. You can transcribe again afterward."}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(u.z,{type:"button",theme:"primary",size:"small",onClick:ek,children:"Delete all cues"}),(0,a.jsx)(u.z,{type:"button",theme:"light",size:"small",onClick:()=>ei(!1),children:"Cancel"})]})]}):null,!et&&X?(0,a.jsx)("fieldset",{disabled:eh,className:"contents",children:(0,a.jsx)("ul",{className:"min-h-0 flex-1 space-y-1.5 overflow-y-auto overscroll-contain border-t border-gray-100 p-3",children:er.map(e=>{var t,i;let n=H===e.cueIndex;return(0,a.jsxs)("li",{className:l()("rounded-lg p-2 ring-1 ring-inset",n?"bg-indigo-50/70 ring-2 ring-indigo-500":"bg-gray-50 ring-gray-200"),children:[(0,a.jsxs)("div",{className:"flex items-start gap-2",children:[(0,a.jsx)("span",{className:l()("mt-1.5 w-4 shrink-0 text-right text-[11px] tabular-nums",n?"font-semibold text-indigo-600":"text-gray-400"),"aria-hidden":!0,children:e.cueIndex+1}),(0,a.jsx)("textarea",{"aria-label":"Caption text",rows:2,className:"w-full resize-none rounded-md border border-gray-200 bg-white px-2 py-1.5 text-sm leading-snug text-gray-900",value:e.text,onFocus:()=>G(e.cueIndex),onChange:t=>{r&&ej((0,h.updateCaptionsConfigCue)(r,e.trackId,e.cueIndex,{text:t.target.value}))},onBlur:t=>{G(null),r&&ej((0,h.updateCaptionsConfigCue)(r,e.trackId,e.cueIndex,{text:t.currentTarget.value}),!0)}})]}),(0,a.jsxs)("div",{className:"mt-1.5 flex items-center gap-1.5 pl-6",children:[(0,a.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-md border border-gray-200 bg-white px-1.5 py-1",children:[(0,a.jsx)("span",{className:"text-[10px] uppercase tracking-wide text-gray-400",children:"In"}),(0,a.jsx)(U,{label:"Cue start seconds",ms:e.startMs,onCommit:t=>{r&&ej((0,h.updateCaptionsConfigCue)(r,e.trackId,e.cueIndex,{startMs:t}),!0)}})]}),(0,a.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-md border border-gray-200 bg-white px-1.5 py-1",children:[(0,a.jsx)("span",{className:"text-[10px] uppercase tracking-wide text-gray-400",children:"Out"}),(0,a.jsx)(U,{label:"Cue end seconds",ms:e.endMs,onCommit:t=>{r&&ej((0,h.updateCaptionsConfigCue)(r,e.trackId,e.cueIndex,{endMs:t}),!0)}})]}),(0,a.jsx)("span",{className:"ml-auto text-[11px] tabular-nums text-gray-400",children:(t=e.startMs,i=e.endMs,"".concat(O(Math.max(0,i-t)),"s"))}),(0,a.jsx)("button",{type:"button","aria-label":"Delete cue ".concat(e.cueIndex+1),onClick:()=>
1{if(!r)return;G(null);let t=(0,h.removeCaptionsConfigCue)(r,e.trackId,e.cueIndex);(0,h.captionsConfigCueCount)(t)||(0,T.HV)(),ej(t)},className:"rounded p-1 text-gray-400 hover:bg-gray-200 hover:text-red-600",children:(0,a.jsx)(d.VPh,{className:"h-3.5 w-3.5","aria-hidden":!0})})]})]},"".concat(e.trackId,"-").concat(e.cueIndex))})})}):null]})]}):(0,a.jsxs)("div",{className:"flex items-start gap-2 rounded-lg border border-dashed border-gray-200 bg-gray-50 p-3 text-xs text-gray-500",children:[(0,a.jsx)(c.W3p,{className:"mt-0.5 shrink-0 text-gray-400",fontSize:16,"aria-hidden":!0}),(0,a.jsx)("span",{children:eh?"Transcribing⦠cues will appear here once it finishes.":"No captions yet. Transcribe to generate timed cues from the uploaded audio."})]})]})}},65725:function(e,t,i){"use strict";i.d(t,{P:function(){return b}});var a=i(52322),n=i(2784),r=i(19458),s=i(38372),o=i(42670),l=i(75803),d=i(3438),c=i(56197),u=i(20177),m=i(18003),p=i(7355),h=i(52522),x=i(68951),f=i(14924);let g=()=>{var e,t,i,r;let s=(0,p.aC)(),{designId:g}=(0,h.hl)(),{mutateWithCredit:v,onCheckout:b,paymentStatus:y,price:j,priceReady:w,canPayWithCredit:N}=(0,m._)({screenName:"HybridExportSubMenu"}),k=(null!==(r=null===(e=s.userDetails)||void 0===e?void 0:e.credit)&&void 0!==r?r:0)>0,S=(0,x.p)(e=>e.exportFileType),E="motion"===(0,f.i)(S);return(0,n.useEffect)(()=>{d.uo()},[]),(0,a.jsxs)("div",{className:"min-w-0 overflow-hidden rounded-lg w-full",children:[(0,a.jsx)("p",{className:"mb-3 min-w-0 break-words rounded-lg border border-green-200/90 bg-green-50 px-3 py-2.5 text-sm font-medium leading-snug text-green-950 shadow-sm",children:(0,a.jsx)(o.Z,{id:E?"Editor.Export.UnlockHDIncludes.motion":"Editor.Export.UnlockHDIncludes"})}),N&&(0,a.jsx)("div",{className:"mb-3 min-w-0",children:(0,a.jsx)(c.s,{credit:(null===(t=s.userDetails)||void 0===t?void 0:t.credit)||0,onPay:()=>{d.yu({cta:"credit"}),v.mutate()},loading:y===l.b.loading,subscriptions:(null===(i=s.userDetails)||void 0===i?void 0:i.subscriptions)||[],designId:g,compact:!0,screenName:"HybridExportSubMenu"})}),!k&&(0,a.jsx)("div",{className:"min-w-0",children:(0,a.jsx)(u.I,{loading:y!==l.b.initial||!w,onCheckout:()=>{d.yu({cta:"checkout"}),b()},price:j,screenName:"HybridExportSubMenu"})})]})};var v=i(99433);let b=()=>{var e;let t=(0,p.aC)(),{isSelectionFreeTier:i,hasUnlimited:o,isPaid:l,isHybridExport:d,permittedSizesForPngJpg:c}=(0,v.d)(),{setExportFileType:u,setExportSize:m}=(0,x.p)(),h=(0,n.useRef)(!1),f=!!(t.isLoggedIn&&t.userDetails&&(null!==(e=t.userDetails.credit)&&void 0!==e?e:0)>0);(0,n.useEffect)(()=>{if(d&&!l&&!o&&!h.current){if(i&&!f){h.current=!0;return}if(f)u(r.ExportFileType.PDF),m(r.ExportSize.large);else{var e;let t=null!==(e=c[0])&&void 0!==e?e:r.ExportSize.optimized;u(r.ExportFileType.PNG),m(t)}h.current=!0}},[d,l,o,i,f,c,u,m]);let b=(0,n.useMemo)(()=>{if(!l&&!o&&!i)return(0,a.jsx)(g,{})},[l,o,i]);return(0,a.jsx)(s.e,{primaryActionSlot:b})}},96434:function(e,t,i){"use strict";i.d(t,{s:function(){return N},z:function(){return b.z}});var a=i(2784),n=i(19458),r=i(27818),s=i(13366),o=i(95669),l=i(28687),d=i(40568),c=i(11080),u=i(16867),m=i(30118),p=i(83096),h=i(14084),x=i(118),f=i(11732),g=i(67638),v=i(34729),b=i(21369),y=i(15343),j=i(3809);function w(e,t){var i;let a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,r=arguments.length>4?arguments[4]:void 0,s=arguments.length>5?arguments[5]:void 0,o=arguments.length>6?arguments[6]:void 0,c=(0,d.listCaptionsConfigCues)(e),u=null!=n?c[n]:void 0,m=null!==(i=null==u?void 0:u.text)&&void 0!==i?i:(0,d.previewCaptionsConfigCueText)(e,a),p=y.ReferenceDimensions[t],h=(0,l.isUsableCaptionAuthoredSlot)(r)?r:void 0;return(0,j.captionSlotLayoutPatch)({text:m,canvasWidth:p.width,canvasHeight:p.height,anchorFontSize:s,heldFontSize:o,fontSizeMode:(0,d.captionsFontSizeMode)(e),...h?{slotWidth:h.width,slotHeight:h.height}:{}})}let N=()=>{let{captions:e,canvasAspectRatio:t,status:i,updateEditorState:y}=(0,m._i)(),{textNodes:j,addTextLayer:N,updateTextLayer:k}=(0,u.Gg)(),{audioElement:S,playerStatus:E}=(0,p.FI)(),C=(0,h.s)(e=>{var t,i;return null===(i=e.designDocument)||void 0===i?void 0:null===(t=i.config)||void 0===t?void 0:t.captions}),_=(0,b.z)(e=>
1e.focusedCueIndex),I=(0,b.z)(e=>e.previewTimeMs),D=(0,b.z)(e=>e.setPreviewTimeMs),R=(0,a.useRef)(void 0),T=(0,a.useRef)(void 0),M=(0,a.useRef)(null),P=(0,x.r)(e=>e.setNotSaved);return(0,a.useEffect)(()=>{if(!S){D(0);return}let e=()=>{let e=Math.max(0,1e3*S.currentTime);D(Number.isFinite(e)?e:0)};e(),S.addEventListener("timeupdate",e),S.addEventListener("seeked",e),S.addEventListener("play",e);let t=0,i=()=>{e(),t=requestAnimationFrame(i)};return E===r.c.playing&&(t=requestAnimationFrame(i)),()=>{cancelAnimationFrame(t),S.removeEventListener("timeupdate",e),S.removeEventListener("seeked",e),S.removeEventListener("play",e)}},[S,E,D]),(0,a.useEffect)(()=>{let t=e=>{let t=(0,f._6)(e);return t!==e&&P(),t};if(R.current===C){if(e&&(0,d.captionsConfigCueCount)(e)>0){let i=t(e);i!==e&&y({captions:i},!1)}return}if(!(0,g.Er)(e,C)){if((0,v.Y)(h.s.getState().subscribedDesignId))return;if((0,g.n)(C)&&T.current!==C&&(T.current=C,P()),e&&(0,d.captionsConfigCueCount)(e)>0){let i=t(e);i!==e&&y({captions:i},!1)}return}R.current=C,y({captions:t((0,s.ff)(C))},!1)},[e,C,P,y]),(0,a.useEffect)(()=>{if(i!==n.EditorStatus.LOADED)return;if(!(0,d.captionsConfigCueCount)(e)){var a;let e=j.find(e=>e.name===c.CAPTION_TEXT_NODE_NAME);e&&(null!==(a=e.text)&&void 0!==a?a:"")!==""&&k(c.CAPTION_TEXT_NODE_NAME,{text:""},!1);return}let r=j.find(e=>e.name===c.CAPTION_TEXT_NODE_NAME),s=(0,o.captionFillOrDefault)(null==r?void 0:r.fillColor);if(!r){N({name:c.CAPTION_TEXT_NODE_NAME,fontFamily:"Open Sans",...w(e,t,I,_),fillColor:s});return}let u=null!=r.captionAnchorFontSize&&r.captionAnchorFontSize>0?r.captionAnchorFontSize:void 0,m=(0,d.isCaptionsFontSizeStable)(e),p=!m&&null!=M.current&&r.width===M.current.width&&r.height===M.current.height,h={...function(e,t){var i,a;let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,s=arguments.length>4?arguments[4]:void 0,o=arguments.length>5?arguments[5]:void 0,d=arguments.length>6?arguments[6]:void 0,c=w(e,t,n,r,s,o,d),u=(0,l.isUsableCaptionAuthoredSlot)(s)?s:void 0;return{text:c.text,fontSize:c.fontSize,width:null!==(i=null==u?void 0:u.width)&&void 0!==i?i:c.width,height:null!==(a=null==u?void 0:u.height)&&void 0!==a?a:c.height,originX:c.originX,originY:c.originY,textAlign:c.textAlign}}(e,t,I,_,!m&&!p&&null==u&&(0,l.isUsableCaptionAuthoredSlot)(r)?{width:r.width,height:r.height}:void 0,u,m&&null!=r.fontSize&&r.fontSize>0?r.fontSize:void 0),fillColor:s};m&&h.width>0&&h.height>0?M.current={width:h.width,height:h.height}:p||(M.current=null),(r.text!==h.text||r.fontSize!==h.fontSize||r.width!==h.width||r.height!==h.height||r.textAlign!==h.textAlign||r.fillColor!==h.fillColor)&&k(c.CAPTION_TEXT_NODE_NAME,h,!1)},[N,t,e,_,I,i,j,k]),null}},11673:function(e,t,i){"use strict";i.d(t,{i:function(){return q}});var a=i(52322),n=i(2784),r=i(18997),s=i(7355),o=i(52522),l=i(30118),d=i(38420),c=i(93873),u=i(70082),m=i(3438),p=i(34444),h=i(72282),x=i(75803),f=i(18003),g=i(42670),v=i(19458),b=i(15297),y=i(75822),j=i(40457),w=i(35113);let N=[{icon:y.NNQ,titleId:"Editor.DigitalCheckout.BenefitInstantTitle",titleDefault:"Instant download",descId:"Editor.DigitalCheckout.BenefitInstantDesc",descDefault:"Files emailed the moment you pay â stills + video",motionDescId:"Editor.DigitalCheckout.BenefitInstantDescMotion",motionDescDefault:"Export MP4, MOV or GIF right after you pay â plus every image format"},{icon:y.LsQ,titleId:"Editor.DigitalCheckout.BenefitEditTitle",titleDefault:"Edit free for 3 days",descId:"Editor.DigitalCheckout.BenefitEditDesc",descDefault:"Re-open the editor, tweak, and re-export anytime"},{icon:j.yW5,titleId:"Editor.DigitalCheckout.BenefitGuaranteeTitle",titleDefault:"30-day guarantee",descId:"Editor.DigitalCheckout.BenefitGuaranteeDesc",descDefault:"Not happy? Message us and we'll make it right"}],k=e=>{let{productId:t,leadWithMotion:i=!1,onSelectOneTime:r}=e,{canvasAspectRatio:s}=(0,l._i)(),o=(0,w.k$)(t,{leadWithMotion:i}),d=(0,n.useMemo)(()=>(0,b.h)(s,v.Unit.pixel,v.ExportSize.large),[s]),c=(0,w.YA)();return(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:["digitalDownload"===t&&(0,a.jsx)(y.dvR,{className:"h-4 w-4 shrink-0 text-violet-500","aria-hidden":!0}),(0,a.jsx)("h3",{className:"text-lg font-bold tracking-tight text-gray-900",children:o.title})]}),(0,a.jsx)("p",{className:"mt-1 text-sm text-gray-500",children:o.subtitle}),"digitalDownload"!==t&&r&&(0,a.jsx)("button",{type:"button",onClick:r,className:"mt-2 text-xs font-medium text-violet-600 hover:text-violet-800 hover:underline",children:(0,a.jsx)(g.Z,{id:"Editor.DigitalCheckout.BackToOneTime",defaultMessage:"Or pay once for this design only"})})]}),"digitalDownload"===t&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,a.jsx)("span",{className:"rounded-full border border-gray-200 px-3 py-1 text-xs font-medium text-gray-600",children:i?"1080p \xb7 60fps":d}),(0,a.jsx)("span",{className:"rounded-full border border-gray-200 px-3 py-1 text-xs font-medium text-gray-600",children:i?(0,a.jsx)(g.Z,{id:"Editor.DigitalCheckout.BadgeNoWatermark",defaultMessage:"No watermark"}):"300 DPI"}),(0,a.jsx)("span",{className:"rounded-full border border-gray-200 px-3 py-1 text-xs font-medium text-gray-600",children:(0,a.jsx)(g.Z,{id:"Editor.DigitalCheckout.FormatCount",defaultMessage:"{count} formats",values:{count:c}})})]}),(0,a.jsx)("ul",{className:"space-y-4",children:N.map(e=>{let t=e.icon;return(0,a.jsxs)("li",{className:"flex gap-3",children:[(0,a.jsx)("span",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-violet-100 text-violet-600",children:(0,a.jsx)(t,{className:"h-4 w-4","aria-hidden":!0})}),(0,a.jsxs)("div",{className:"min-w-0 pt-0.5",children:[(0,a.jsx)("p",{className:"text-sm font-semibold text-gray-900",children:(0,a.jsx)(g.Z,{id:e.titleId,defaultMessage:e.titleDefault})}),(0,a.jsx)("p",{className:"mt-0.5 text-xs leading-snug text-gray-500",children:i&&"motionDescId"in e?(0,a.jsx)(g.Z,{id:e.motionDescId,defaultMessage:e.motionDescDefault}):(0,a.jsx)(g.Z,{id:e.descId,defaultMessage:e.descDefault})})]})]},e.titleId)})})]})]})};var S=i(12524),E=i.n(S),C=i(92855),_=i(63271),I=i(61872);let D={digitalDownload:{id:"Editor.DigitalCheckout.PriceHintOneTime",defaultMessage:"one-time \xb7 incl. taxes"},unlimitedPlan:{id:"Editor.DigitalCheckout.PriceHintSubscription",defaultMessage:"per month \xb7 incl. taxes"},creditPack100:{id:"Editor.DigitalCheckout.PriceHintCredits",defaultMessage:"credit pack \xb7 incl. taxes"}},R=e=>{let{price:t,loading:i,onCheckout:n,selectedProductId:r,screenName:s}=e,{blockCheckout:o,pendingUploads:l,saveFailed:d}=(0,I.X)({screenName:s}),c=D[r];return(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsx)(_.R,{pendingUploads:l,saveFailed:d}),(0,a.jsxs)("div",{className:"flex items-end gap-3",children:[t?(0,a.jsx)("p",{className:"text-4xl font-bold tabular-nums tracking-tight text-gray-900",children:t}):(0,a.jsx)("div",{className:"h-10 w-28 animate-pulse rounded-lg bg-gray-200"}),(0,a.jsx)("p",{className:"pb-1.5 text-xs leading-snug text-gray-400",children:(0,a.jsx)(g.Z,{id:c.id,defaultMessage:c.defaultMessage})})]}),(0,a.jsxs)("button",{type:"button",onClick:n,disabled:o||i,"data-testid":C.z.CHECKOUT_BUTTON,className:E()("flex w-full items-center justify-center gap-2 rounded-xl py-3.5 text-base font-semibold text-white shadow-md transition-opacity","bg-gradient-to-r from-blue-500 to-violet-600 hover:from-blue-600 hover:to-violet-700","disabled:cursor-not-allowed disabled:opacity-60"),children:[i?(0,a.jsx)("span",{className:"inline-block h-5 w-5 animate-spin rounded-full border-2 border-white border-t-transparent"}):(0,a.jsx)(y.yFZ,{className:"h-5 w-5 shrink-0","aria-hidden":!0}),(0,a.jsx)(g.Z,{id:"Editor.Export.ContinuePay"})]}),(0,a.jsxs)("p",{className:"flex flex-wrap items-center justify-center gap-x-2 gap-y-1 text-center text-[11px] text-gray-400",children:[(0,a.jsxs)("span",{className:"inline-flex items-center gap-1",children:[(0,a.jsx)(j.OSh,{className:"h-3 w-3","aria-hidden":!0}),(0,a.jsx)(g.Z,{id:"Editor.DigitalCheckout.TrustSsl",defaultMessage:"SSL encrypted"})]}
1),(0,a.jsx)("span",{"aria-hidden":!0,children:"\xb7"}),(0,a.jsx)(g.Z,{id:"Editor.DigitalCheckout.TrustPaddle",defaultMessage:"Powered by Paddle"})]})]})};var T=i(77298);let M={creditPack100:j.y6p,unlimitedPlan:j.Vj4},P=e=>{let{productId:t,selected:i,price:n,onSelect:r}=e,s=(0,w.vP)(t),o=n?(0,w.mC)(t,n):void 0,l=M[t];return(0,a.jsxs)("button",{type:"button",onClick:()=>r(t),className:E()("flex w-full items-center gap-3 rounded-xl border p-3 text-left transition-colors",i?"border-violet-400 bg-violet-50/80 ring-1 ring-violet-400":"border-gray-200 bg-white hover:border-gray-300"),"aria-pressed":i,children:[l&&(0,a.jsx)("span",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-violet-50 text-violet-600",children:(0,a.jsx)(l,{className:"h-5 w-5","aria-hidden":!0})}),(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsx)("p",{className:"text-sm font-bold text-gray-900",children:s.title}),(0,a.jsx)("p",{className:"mt-0.5 text-xs text-gray-500",children:s.subtitle})]}),o?(0,a.jsx)("span",{className:"shrink-0 text-base font-bold tabular-nums text-gray-900",children:o}):(0,a.jsx)("span",{className:"h-5 w-14 shrink-0 animate-pulse rounded bg-gray-200","aria-hidden":!0})]})},A=e=>{let{selectedProductId:t,productPrices:i,onSelectProduct:r}=e,[s,o]=(0,n.useState)(!0),l=(0,w.$z)();return(0,a.jsxs)("div",{className:"border-t border-gray-100",children:[(0,a.jsxs)("button",{type:"button",onClick:()=>o(e=>!e),className:"flex w-full items-center gap-2 py-3.5 text-left","aria-expanded":s,children:[(0,a.jsx)(y.iDf,{className:"h-4 w-4 shrink-0 text-violet-500","aria-hidden":!0}),(0,a.jsx)("span",{className:"flex-1 text-sm font-medium text-gray-800",children:(0,a.jsx)(g.Z,{id:"Editor.DigitalCheckout.MakingMoreThanOne",defaultMessage:"Making more than one?"})}),(0,a.jsx)(T.v4q,{className:E()("h-4 w-4 shrink-0 text-gray-400 transition-transform duration-200",s&&"rotate-180"),"aria-hidden":!0})]}),s&&(0,a.jsx)("div",{className:"space-y-2",children:l.map(e=>(0,a.jsx)(P,{productId:e,selected:t===e,price:i[e],onSelect:r},e))})]})};var F=i(21353),L=i(71406),z=i(99127),O=i(15961),U=i(16572);let Z=e=>{let{credit:t,hasUnlimited:i,subscriptions:n,loading:r,onPay:s,screenName:o}=e,{blockCheckout:l,pendingUploads:d,saveFailed:c}=(0,I.X)({screenName:o}),u=(0,U.YE)(t,n);return(0,a.jsxs)("div",{className:"space-y-4 mb-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h3",{className:"text-base font-semibold text-gray-900",children:i?(0,a.jsx)(g.Z,{id:"Editor.DigitalCheckout.UnlimitedReady",defaultMessage:"Included with your Unlimited plan"}):(0,a.jsx)(g.Z,{id:"Editor.DigitalCheckout.CreditReady",defaultMessage:"Use a credit to unlock this design"})}),(0,a.jsx)("p",{className:"mt-1 text-sm text-gray-600",children:(0,a.jsx)(g.Z,{id:"Editor.DigitalCheckout.RedemptionSub",defaultMessage:"Export in high resolution right away â no checkout needed."})})]}),(0,a.jsxs)("ul",{className:"space-y-2",children:[(0,a.jsxs)("li",{className:"flex items-start gap-2 text-sm text-gray-700",children:[(0,a.jsx)(z.bzc,{className:"mt-0.5 h-4 w-4 shrink-0 text-green-600","aria-hidden":!0}),(0,a.jsx)(g.Z,{id:"Editor.DigitalCheckout.BenefitInstant",defaultMessage:"Instant download after purchase"})]}),(0,a.jsxs)("li",{className:"flex items-start gap-2 text-sm text-gray-700",children:[(0,a.jsx)(z.bzc,{className:"mt-0.5 h-4 w-4 shrink-0 text-green-600","aria-hidden":!0}),(0,a.jsx)(g.Z,{id:"Editor.DigitalCheckout.BenefitEdit",defaultMessage:"Edit free for 3 days"})]})]}),(0,a.jsx)(_.R,{pendingUploads:d,saveFailed:c}),(0,a.jsxs)("div",{className:"flex flex-row items-center justify-between gap-3",children:[(0,a.jsx)(F.z,{theme:"blue",onClick:s,icon:L.E6I,loading:r,disabled:l,className:"w-52 md:w-48",children:i?(0,a.jsx)(g.Z,{id:"Editor.DigitalCheckout.ExportWithUnlimited",defaultMessage:"Export with Unlimited"}):(0,a.jsx)(g.Z,{id:"Editor.Export.CheckoutWithCredit"})}),(0,a.jsx)(O.g,{className:"w-24",size:"small",label:"Your balance",content:u})]})]})};var W=i(83112),Q=i(14924),B=i(68951),H=i(61796),G=i(3011);let V=e=>{let{leadWithMotion:t=!1}=e,i=(0,W.Z)(),{canvasAspectRatio:r}=(0,l._i)(),s=(0,B.p)(e=>e.exportFileType),o="motion"===(0,Q.i)(s)||t,d=(0,n.useMemo)(()=>({pixel:(0,b.h)(r,v.Unit.pixel,v.ExportSize.large),cm:(0,b.h)(r,v.Unit.cm,v.ExportSize.large),inch:(0,b.h)(r,v.Unit.inch,v.ExportSize.large)}),[r]),c=i.formatMessage({id:"Editor.DigitalCheckout.DpiTooltipAria",defaultMessage:"How cm and inch sizes are calculated"});return(0,a.jsx)(G.UQ,{type:"single",collapsible:!0,className:"w-full",children:(0,a.jsxs)(G.Qd,{value:"export-details",className:"border-t border-gray-100",children:[(0,a.jsx)(G.o4,{className:"py-3.5 text-[11px] font-bold uppercase tracking-wider text-gray-400 hover:no-underline",children:(0,a.jsx)(g.Z,{id:"Editor.DigitalCheckout.ExportDetailsTrigger",defaultMessage:"Full export details"})}),(0,a.jsx)(G.vF,{children:(0,a.jsxs)("div",{className:"space-y-4 pb-4 text-xs text-gray-600",children:[(0,a.jsxs)("div",{className:"space-y-1",children:[(0,a.jsx)("p",{className:"text-[10px] font-semibold uppercase tracking-wide text-gray-400",children:(0,a.jsx)(g.Z,{id:"Editor.DigitalCheckout.SectionFormats",defaultMessage:"Export formats"})}),(o?["motion","still"]:["still","motion"]).map(e=>(0,a.jsx)("p",{className:"leading-snug text-gray-700",children:"still"===e?(0,a.jsx)(g.Z,{id:"Editor.DigitalCheckout.FormatsStill",defaultMessage:"Still images: PNG, JPG, PDF, SVG."}):(0,a.jsx)(g.Z,{id:"Editor.DigitalCheckout.FormatsMotion",defaultMessage:"Video: MP4, GIF, WebM, MOV (1080p at 60fps)."})},e))]}),!o&&(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsxs)("p",{className:"inline-flex items-center gap-1.5 text-[11px] font-semibold text-gray-800",children:[(0,a.jsx)(g.Z,{id:"Editor.DigitalCheckout.MaxRasterHint",defaultMessage:"Image size at full quality"}),(0,a.jsx)(H.u,{content:(0,a.jsx)(g.Z,{id:"Editor.Export.ResolutionInfo"}),side:"top",children:(0,a.jsx)("span",{className:"inline-flex cursor-help text-gray-400 hover:text-gray-600",children:(0,a.jsx)(z.ocf,{className:"h-4 w-4 shrink-0","aria-label":c})})})]}),(0,a.jsx)("p",{className:"text-[10px] leading-snug text-gray-500",children:(0,a.jsx)(g.Z,{id:"Editor.DigitalCheckout.MaxRasterSub",defaultMessage:"Applies to PNG and JPG; PDF and SVG are vector."})}),(0,a.jsxs)("div",{className:"space-y-1.5 font-mono text-[11px] tabular-nums text-gray-800",children:[(0,a.jsxs)("p",{className:"flex justify-between gap-4",children:[(0,a.jsx)("span",{className:"shrink-0 font-sans font-normal text-gray-500",children:(0,a.jsx)(g.Z,{id:"Editor.DigitalCheckout.LabelPixels",defaultMessage:"Pixels"})}),(0,a.jsx)("span",{className:"min-w-0 text-right",children:d.pixel})]}),(0,a.jsxs)("p",{className:"flex justify-between gap-4",children:[(0,a.jsx)("span",{className:"shrink-0 font-sans font-normal text-gray-500",children:(0,a.jsx)(g.Z,{id:"Editor.DigitalCheckout.LabelCm",defaultMessage:"Centimeters"})}),(0,a.jsx)("span",{className:"min-w-0 text-right",children:d.cm})]}),(0,a.jsxs)("p",{className:"flex justify-between gap-4",children:[(0,a.jsx)("span",{className:"shrink-0 font-sans font-normal text-gray-500",children:(0,a.jsx)(g.Z,{id:"Editor.DigitalCheckout.LabelInches",defaultMessage:"Inches"})}),(0,a.jsx)("span",{className:"min-w-0 text-right",children:d.inch})]})]})]})]})})]})})},K=e=>{let{intent:t}
1=e,i="motion"===t,[r,s]=(0,n.useState)((0,w.jF)()),{mutateWithCredit:o,onCheckout:l,paymentStatus:d,price:c,priceReady:u,productPrices:m,hasRedemptionAccess:p,hasUnlimited:h,credit:g,subscriptions:v}=(0,f._)({screenName:"DigitalCheckoutSubMenu",selectedProductId:r});return p?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(Z,{credit:g,hasUnlimited:h,subscriptions:v,loading:d===x.b.loading,onPay:()=>o.mutate(),screenName:"DigitalCheckoutSubMenu"}),(0,a.jsx)(V,{leadWithMotion:i})]}):(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsx)(k,{productId:r,leadWithMotion:i,onSelectOneTime:"digitalDownload"!==r?()=>s((0,w.jF)()):void 0}),(0,a.jsx)(R,{price:c,loading:d!==x.b.initial||!u,onCheckout:l,selectedProductId:r,screenName:"DigitalCheckoutSubMenu"}),(0,a.jsx)(A,{selectedProductId:r,productPrices:m,onSelectProduct:s}),(0,a.jsx)(V,{leadWithMotion:i})]})},q=()=>{var e;let t=(0,s.aC)(),{designId:i}=(0,o.hl)(),{captions:x,canvasAspectRatio:f}=(0,l._i)(),g=(0,d.b)(),v=(0,c.P)();(0,n.useEffect)(()=>{var e,i;(0,r.Kz)("digital_checkout_tab",{is_logged_in:t.isLoggedIn,has_credit:!!(null===(e=t.userDetails)||void 0===e?void 0:e.credit)&&(null===(i=t.userDetails)||void 0===i?void 0:i.credit)>0,...(0,u.Gx)(x)})},[t.isLoggedIn,null===(e=t.userDetails)||void 0===e?void 0:e.credit,x]);let[b]=(0,n.useState)(()=>{let e=(0,h.Uy)();return{landingPath:e,...(0,p.v)({aspectRatio:f,audioSource:g,landingPath:e})}}),y=(0,n.useRef)(!1);return(0,n.useEffect)(()=>{y.current||(y.current=!0,m.IN({designId:null!=i?i:void 0,aspectRatio:f,audioSource:g,landingPath:b.landingPath,resolvedIntent:b.intent,intentScore:b.score,intentSource:b.source,candidateSignals:v}))},[]),(0,a.jsx)(K,{intent:b.intent})}},39220:function(e,t,i){"use strict";i.d(t,{A:function(){return M}});var a=i(52322),n=i(2784),r=i(51510),s=i(18997),o=i(30118),l=i(21353),d=i(83112),c=i(96577),u=i.n(c),m=i(3741);function p(e,t){return(null==t?void 0:t.unit_amount)?e.formatNumber(t.unit_amount/100,{style:"currency",currency:t.currency}):""}var h=i(9223);let x=e=>{let{productCategory:t,setProductCategory:i,priceMap:n}=e,s=(0,d.Z)();switch(t){case r.V0.unframed_poster:return(0,a.jsxs)("div",{className:"normal-button w-full mb-4 border border-indigo-200 rounded grid grid-cols-3 grid-rows-2 gap-0.5 bg-gray-50 hover:border-indigo-500 hover:text-indigo-500",children:[(0,a.jsx)("p",{className:"col-span-2",children:"Unframed Posters"}),(0,a.jsxs)("p",{className:"font-semibold col-span-2",children:["(Starting from ",p(s,n[r.V0.unframed_poster]),")"]}),(0,a.jsx)(l.z,{theme:"link",justify:"end",className:"row-span-2 col-start-3 row-start-1",size:null,onClick:()=>i(),children:"Change"})]});case r.V0.wood_framed_poster:return(0,a.jsxs)("div",{className:"normal-button w-full mb-4 border border-indigo-200 rounded grid grid-cols-3 grid-rows-2 gap-0.5 bg-gray-50 hover:border-indigo-500 hover:text-indigo-500",children:[(0,a.jsx)("p",{className:"col-span-2",children:"Framed Posters"}),(0,a.jsxs)("p",{className:"font-semibold col-span-2",children:["(Starting from"," ",p(s,n[r.V0.wood_framed_poster]),")"]}),(0,a.jsx)(l.z,{theme:"link",justify:"end",className:"row-span-2 col-start-3 row-start-1",size:null,onClick:()=>i(),children:"Change"})]})}return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("p",{className:"mb-4 text-sm",children:"Select the final product you would like receive. Download your artwork, or get it printed."}),(0,a.jsxs)("div",{role:"button",className:"normal-button w-full mt-4 border border-indigo-100 rounded bg-gray-50 transition-all hover:border-indigo-500 hover:text-indigo-500 max-w-sm",onClick:()=>i(r.V0.unframed_poster),children:[(0,a.jsx)("div",{className:"w-full h-32 mb-1 overflow-hidden",children:(0,a.jsx)(u(),{loader:h._,src:"/editor-page/poster-example.jpeg",width:360,height:360,alt:"Printed poster thumbnail",draggable:!1,className:"-translate-y-1/4",style:{maxWidth:"100%",height:"auto"}})}),(0,a.jsx)("label",{children:"Poster"}),(0,a.jsxs)("p",{className:"font-semibold",children:["(Starting from ",p(s,n[r.V0.unframed_poster]),")"]})]}),m.featureFlags.framedPrintOption&&n[r.V0.wood_framed_poster]&&(0,a.jsxs)("div",{role:"button",className:"normal-button w-full mt-4 border border-indigo-100 rounded bg-gray-50 transition-all hover:border-indigo-500 hover:text-indigo-500 max-w-sm",onClick:()=>i(r.V0.wood_framed_poster),children:[(0,a.jsx)("div",{className:"w-full h-32 mb-1 overflow-hidden",children:(0,a.jsx)(u(),{loader:h._,src:"/editor-page/wood-framed-poster-example.jpeg",width:360,height:360,alt:"Printed and framed poster thumbnail",draggable:!1,
1className:"-translate-y-1/4",style:{maxWidth:"100%",height:"auto"}})}),(0,a.jsx)("label",{children:"Wooden Framed Poster"}),(0,a.jsxs)("p",{className:"font-semibold",children:["(Starting from"," ",p(s,n[r.V0.wood_framed_poster]),")"]})]})]})};var f=i(12524),g=i.n(f),v=i(30508),b=i(82066),y=i(20177),j=i(23083),w=i(52522),N=i(96862),k=i(92442);let S=e=>{var t;let{products:i}=e,{designId:o,saveEverything:l}=(0,w.hl)(),c=(0,d.Z)(),{selectedProduct:u,setSelectedProduct:m}=(0,k.a)(),[h,x]=(0,n.useMemo)(()=>{let e=[],t=[];return i.forEach(i=>{i.name.startsWith("Matte Poster")?e.push({...i,name:i.name.substring(13)}):t.push({...i,name:i.name.substring(14)})}),[e,t]},[i]),{mutate:f,isLoading:S}=(0,b.useMutation)(["checkout",o,null==u?void 0:u.gelatoUID],async()=>{let e=o||await l();if(!e)throw Error("PosterSubMenu: Could not save design");if(!(null==u?void 0:u.gelatoUID))throw Error("PosterSubMenu: No product selected");let t=i.find(e=>e.id===u.gelatoUID);if(!t)throw Error("PosterSubMenu: Selected product not found");return(0,N.v)(e,t,"PosterSubMenu"),(0,j.lo)({productId:u.gelatoUID,designId:e})},{onSuccess:e=>{let{sesionURL:t}=e;window.location.href=t},onError:e=>{(0,s.H)(e)}});return(0,a.jsx)(a.Fragment,{children:(0,a.jsxs)(v.Z,{name:"select-unframed-poster-size","data-testid":"select-unframed-poster-size",value:(null==u?void 0:u.gelatoUID)||"",onChange:e=>{e&&m(r.V0.unframed_poster,String(e))},direction:"column",children:[(0,a.jsx)("p",{className:"mb-4 text-sm font-bold",children:"Unframed Matte Posters"}),(0,a.jsx)("div",{className:"flex flex-col",children:h.map((e,t)=>(0,a.jsx)(v.z,{value:e.id,appearance:"compact",className:g()({"rounded-t-lg":0===t,"rounded-b-lg":t===h.length-1,"border-t-0":0!==t}),children:(0,a.jsxs)("div",{className:"flex flex-col",children:[(0,a.jsx)("span",{children:e.name}),(0,a.jsx)("span",{className:"font-semibold",children:p(c,e.price)})]})},e.id))}),(0,a.jsx)("p",{className:"my-4 text-sm font-bold",children:"Unframed Glossy Posters"}),(0,a.jsx)("div",{className:"flex flex-col mb-6",children:x.map((e,t)=>(0,a.jsx)(v.z,{value:e.id,appearance:"compact",className:g()({"rounded-t-lg":0===t,"rounded-b-lg":t===h.length-1,"border-t-0":0!==t}),children:(0,a.jsxs)("div",{className:"flex flex-col",children:[(0,a.jsx)("span",{children:e.name}),(0,a.jsx)("span",{className:"font-semibold",children:p(c,e.price)})]})},e.id))}),(0,a.jsx)(y.I,{loading:S,onCheckout:f,price:p(c,null===(t=i.find(e=>e.id===(null==u?void 0:u.gelatoUID)))||void 0===t?void 0:t.price),screenName:"PosterSubMenu"})]})})},E=e=>{let t=e.match(/with\s([\w\s]+)\sframe\s(.+)/i);if(!t)throw Error("Invalid frame product name: ".concat(e));let[,i,a]=t;return{color:i,sizeName:a}},C=(e,t)=>{let i=new Map;return e.forEach(e=>{let{color:a,sizeName:n}=E(e.name);if(n!==t)return;if(!i.has(a)){i.set(a,e);return}let r=i.get(a);(null==r?void 0:r.price.unit_amount)&&e.price.unit_amount&&r.price.unit_amount>e.price.unit_amount&&i.set(a,e)}),i},_=(e,t)=>{let i=new Map;return e.forEach(e=>{let{color:a,sizeName:n}=E(e.name);a===t&&i.set(n,e)}),i},I=e=>{var t,i;let{products:o}=e,{selectedProduct:l,setSelectedProduct:c}=(0,k.a)(),u=null!==(i=o.find(e=>e.id===(null==l?void 0:l.gelatoUID)))&&void 0!==i?i:o[2],{color:m}=E(u.name),[h,x]=(0,n.useState)(m),[f,S]=(0,n.useState)(E(null==u?void 0:u.name).sizeName),{designId:I,saveEverything:D}=(0,w.hl)(),R=(0,d.Z)(),{mutate:T,isLoading:M}=(0,b.useMutation)(["checkout",I,null==l?void 0:l.gelatoUID],async()=>{let e=I||await D();if(!e)throw Error("WoodFramedPosterSubMenu: Could not save design");if(!(null==l?void 0:l.gelatoUID))throw Error("WoodFramedPosterSubMenu: No product selected");let t=o.find(e=>e.id===l.gelatoUID);if(!t)throw Error("WoodFramedPosterSubMenu: Selected product not found");return(0,N.v)(e,t,"WoodFramedPosterSubMenu"),(0,j.lo)({productId:l.gelatoUID,designId:e})},{onSuccess:e=>{let{sesionURL:t}=e;window.location.href=t},onError:e=>{(0,s.H)(e)}}),P=(0,n.useMemo)(()=>C(o,f),[o,f]),A=(0,n.useMemo)(()=>_(o,h),[o,h]);return(0,a.jsxs)(v.Z,{name:"select-unframed-poster-size","data-testid":"select-unframed-poster-size",value:(null==l?void 0:l.gelatoUID)||"",onChange:e=>{if(!e||"string"!=typeof e)return;let t=o.find(t=>
1t.id===e);if(!t)throw Error("Could not find product with id ".concat(e));let{color:i,sizeName:a}=E(t.name);x(i),S(a),c(r.V0.wood_framed_poster,e)},direction:"column",children:[(0,a.jsx)("p",{className:"mb-3 text-sm font-semibold",children:"Frame Size"}),(0,a.jsx)("div",{className:"flex flex-col",children:Array.from(A).map((e,t)=>{let[i,{price:n,id:r}]=e;return(0,a.jsx)(v.z,{value:r,appearance:"compact",className:g()({"rounded-t-lg":0===t,"rounded-b-lg":t===A.size-1,"border-t-0":0!==t}),children:(0,a.jsxs)("div",{className:"flex flex-col",children:[(0,a.jsx)("span",{children:i}),(0,a.jsx)("span",{className:"font-semibold",children:p(R,n)})]})},i)})}),(0,a.jsx)("p",{className:"my-3 text-sm font-semibold",children:"Frame Color"}),(0,a.jsx)("div",{className:"flex flex-col w-full mb-6",children:Array.from(P).sort().map((e,t)=>{let[i,{price:n,id:r}]=e;return(0,a.jsxs)(v.z,{value:r,appearance:"compact",className:g()({"rounded-t-lg":0===t,"rounded-b-lg":t===P.size-1,"border-t-0":0!==t}),children:[(0,a.jsx)("span",{className:"mr-3",children:i}),(0,a.jsx)("span",{className:"font-semibold place-self-end",children:p(R,n)})]},i)})}),(0,a.jsx)(y.I,{loading:M,onCheckout:T,price:p(R,null===(t=o.find(e=>e.id===(null==l?void 0:l.gelatoUID)))||void 0===t?void 0:t.price),screenName:"WoodFramedPosterSubMenu"})]})};var D=i(71680);function R(){return(0,a.jsxs)("div",{className:"rounded-lg border border-gray-200/50 p-4 text-center bg-gray-100 mt-4",children:[(0,a.jsxs)("dt",{className:"",children:[(0,a.jsx)(D.C5q,{className:"h-6 w-6 shrink-0 text-gray-400 mb-2 inline-block mr-2","aria-hidden":"true"}),(0,a.jsx)("span",{className:"text-sm font-medium text-gray-900",children:"Free Shipping"})]}),(0,a.jsx)("dd",{className:"mt-1 text-sm text-gray-500",children:"Free international shipping is included with all print orders"})]},"Free International Shipping")}var T=i(60432);let M=()=>{var e,t,i;let{canvasAspectRatio:l}=(0,o._i)(),[d,c]=(0,n.useState)(),{posterPrices:u,framedPosterPrices:m,canvasPrices:p}=(0,T.R)(l),{setSelectedProduct:h}=(0,k.a)();(0,n.useEffect)(()=>{(0,s.Kz)("print_checkout_tab")},[]),(0,n.useEffect)(()=>()=>{h(void 0,void 0)},[h]);let f=e=>e===r.V0.unframed_poster&&u.length>0?u[0].id:e===r.V0.wood_framed_poster&&m.length>0?m[2].id:e===r.V0.canvas&&p.length>0?p[0].id:"";return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(x,{productCategory:d,setProductCategory:e=>{(0,s.Kz)("print_product_selection",{productCategory:e}),c(e);let t=e?f(e):void 0;h(e,t)},priceMap:{[r.V0.unframed_poster]:null===(e=u[0])||void 0===e?void 0:e.price,[r.V0.wood_framed_poster]:null===(t=m[0])||void 0===t?void 0:t.price,[r.V0.canvas]:null===(i=p[0])||void 0===i?void 0:i.price}}),d===r.V0.unframed_poster&&(0,a.jsx)(S,{products:u}),d===r.V0.wood_framed_poster&&m.length>0&&(0,a.jsx)(I,{products:m}),(0,a.jsx)(R,{})]})}},18003:function(e,t,i){"use strict";i.d(t,{_:function(){return P}});var a=i(52322),n=i(2784),r=i(82066),s=i(42670),o=i(75803),l=i(7355),d=i(44041),c=i(18997),u=i(5632),m=i(53665),p=i(19613),h=i(52522),x=i(30118),f=i(3438),g=i(34444),v=i(72282),b=i(23083),y=i(48025),j=i(38986),w=i(83553),N=i(84309),k=i(74304),S=i(92141),E=i(67148),C=i(38420),_=i(2877),I=i(16572),D=i(35113),R=i(70082);let{paddle:T}=k.feconfig;async function M(e,t){var i,a,n,r;let s=(null===(i=y.P.findObjectByName(e,j.LEFT_RECT_OBJECT_NAME))||void 0===i?void 0:i.getScaledWidth())||0,o=(null===(a=y.P.findObjectByName(e,j.TOP_RECT_OBJECT_NAME))||void 0===a?void 0:a.getScaledHeight())||0,l=(null===(n=y.P.findObjectByName(e,j.RIGHT_RECT_OBJECT_NAME))||void 0===n?void 0:n.getScaledWidth())||0,d=(null===(r=y.P.findObjectByName(e,j.BOTTOM_RECT_OBJECT_NAME))||void 0===r?void 0:r.getScaledHeight())||0;try{let i=e.toDataURL({format:"png",left:s,top:o,width:e.getWidth()-s-l,height:e.getHeight()-o-d});(0,p.Dv)(t,i)}catch(e){(0,c.H)(e)}}function P(){var e,t,i,p,y;let j=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{screenName:k="ExportUpsellBlock",selectedProductId:P=(0,D.jF)()}=j,[A,F]=(0,n.useState)(o.b.initial),[L,z]=(0,n.useState)({}),O=L[P],{canvasAspectRatio:U,captions:Z}=(0,x._i)(),W=(0,C.b)(),Q=(0,l.aC)(),{designId:B,saveEverything:H,setIsPaid:G,isPaid:V,canvas:K,setEditMode:q}=(0,h.hl)(),Y=(0,d.G)(e=>e.error),X=(0,u.useRouter)(),$=(0,E.m)(),J=Q.isLoggedIn&&!!(null==Q?void 0:Q.userDetails),ee=null!==(p=null===(e=Q.userDetails)||void 0===e?void 0:e.credit)&&void 0!==p?p:0,et=null!==(y=null===(t=Q.userDetails)||void 0===t?void 0:t.subscriptions)&&void 0!==y?y:[],ei=(0,I.mv)(et),ea=Q.isLoggedIn&&!!Q.userDetails&&(ee>0||ei),{product:en,ready:er}=(0,_.U)(),es=(0,n.useCallback)(e=>"digitalDownload"===e?en:(0,D.kp)(e),[en]),eo=(0,n.useMemo)(()=>es(P),[es,P]),el=(0,r.useMutation)(["pay_with_credit"],async()=>
1{if(V)return(0,c.H)(Error("already paid")),{aborted:!0};F(o.b.loading);let e=await H();return e?(await (0,b.PZ)({},e),{aborted:!1,designId:e}):((0,c.H)(Error("cannot fetch designId")),Y((0,a.jsx)(s.Z,{id:"Editor.DigitalCheckout.SaveFailed",defaultMessage:"Couldn't save your design. Check your connection and try again."})),F(o.b.initial),{aborted:!0})},{onSuccess(e){if(!e||e.aborted)return;G(!0),q(w.uz.Without_Audio),F(o.b.successful);let t=(0,g.v)({aspectRatio:U,audioSource:W,landingPath:(0,v.Uy)()});f.ES({designId:e.designId,selectedSource:W,...(0,R.Gx)(Z),eventParams:{event_category:"Checkout",screen_name:k,resolved_intent:t.intent,intent_score:t.score,intent_source:t.source}})},onError(){F(o.b.errored)}});return(0,n.useEffect)(()=>{$.current&&!V&&er&&async function(){try{var e,t;let i=B?(0,S.j)(en.productId,null!==(t=null===(e=Q.userDetails)||void 0===e?void 0:e.uid)&&void 0!==t?t:"",B):Promise.resolve();await Promise.all([N.B.setup({vendorId:T.vendorId,sandbox:m.isDevEnvironment}),i]);let a=await Promise.all((0,D.bG)().map(async e=>{let t=es(e).productId,i=await new Promise((e,i)=>{try{N.B.getPaddle().Product.Price("gross",t,1,t=>{e(t)})}catch(e){i(e)}});return[e,i]}));$.current&&z(Object.fromEntries(a))}catch(e){(0,c.H)(e)}}()},[null===(i=Q.userDetails)||void 0===i?void 0:i.uid,B,V,$,en,es,er]),(0,n.useEffect)(()=>{var e;let t=()=>{F(e=>e===o.b.loading?o.b.initial:e)},i=e=>{e.startsWith("/editor")&&t()},a=e=>{e.persisted&&t()};return null===(e=X.events)||void 0===e||e.on("routeChangeComplete",i),window.addEventListener("pageshow",a),()=>{var e;null===(e=X.events)||void 0===e||e.off("routeChangeComplete",i),window.removeEventListener("pageshow",a)}},[X.events]),{mutateWithCredit:el,onCheckout:(0,n.useCallback)(async()=>{if(!er)return;F(o.b.loading);let e=await H();if(!e){(0,c.H)(Error("cannot fetch designId")),Y((0,a.jsx)(s.Z,{id:"Editor.DigitalCheckout.SaveFailed",defaultMessage:"Couldn't save your design. Check your connection and try again."})),F(o.b.initial);return}K&&await M(K,e),F(o.b.initial);let t=new URLSearchParams({did:e||"",pid:eo.productId,aspectRatio:U.toString(),audioSource:W,screenName:k});(0,R.wP)(t,(0,R.Gx)(Z)),X.push("/checkout?".concat(t.toString()))},[U,Z,X,H,W,K,k,eo.productId,Y,er]),paymentStatus:A,price:O,priceReady:er,productPrices:L,canPayWithCredit:J,hasRedemptionAccess:ea,hasUnlimited:ei,credit:ee,subscriptions:et,selectedProductId:P}}},35113:function(e,t,i){"use strict";i.d(t,{$z:function(){return u},YA:function(){return x},bG:function(){return c},jF:function(){return l},k$:function(){return h},kp:function(){return d},mC:function(){return m},vP:function(){return p}});var a=i(78422),n=i(22581),r=i(53665);let s=["digitalDownload","creditPack100","unlimitedPlan"],o=(0,n.il)(r.isDevEnv
1ironment).mapped;function l(){return"digitalDownload"}function d(e){return({digitalDownload:o.digitalDownload,creditPack100:o.creditPack100,unlimitedPlan:o.unlimitedPlan})[e]}function c(){return[...s]}function u(){return["creditPack100","unlimitedPlan"]}function m(e,t){var i;return(null===(i=d(e).subscription)||void 0===i?void 0:i.interval)==="month"?"".concat(t,"/mo"):t}function p(e){var t;let i=d(e);return"digitalDownload"===e?{title:"This design only",subtitle:"One-time high-res download"}:null!=i.creditPack?{title:"Make more later",subtitle:"".concat(i.creditPack," design credits \xb7 never expire")}:(null===(t=i.subscription)||void 0===t?void 0:t.name)===a.SubscriptionPlan.unlimited?{title:"Unlimited",subtitle:"For creators and shops \xb7 cancel anytime"}:{title:i.name,subtitle:i.description||""}}function h(e,t){if("digitalDownload"===e&&(null==t?void 0:t.leadWithMotion))return{title:"Your video is ready",subtitle:"MP4 with your audio, ready to post. Image formats included."};if("digitalDownload"===e)return{title:"Your design is ready",subtitle:"Download in high-res and keep it forever."};let i=p(e);return{title:i.title,subtitle:i.subtitle}}function x(){return 8}},96862:function(e,t,i){"use strict";i.d(t,{g:function(){return r},v:function(){return n}});var a=i(3438);let n=(e,t,i)=>{let n=t.price.currency.toUpperCase();(0,a.eD)({designId:e,productId:t.id,eventParams:{event_category:"Checkout",tax:0,shipping:0,currency:n,value:Number(t.price.unit_amount),screen_name:i},ecommerce:{currency:n,value:Number(t.price.unit_amount)/100,items:[{item_id:t.id,item_name:t.name,item_category:"printed",price:Number(t.price.unit_amount)/100,quantity:1}]}})},r=e=>{let{designId:t,productId:i,productName:n,currency:r,amount:s,email:o,countryCode:l}=e;(0,a.e_)({productId:i,designId:t,event_category:"Checkout",tax:0,shipping:0,value:s,currency:r,user_country:l,user_email:o,ecommerce:{currency:r,value:s,items:[{item_id:i,item_name:n,item_category:"printed",price:s,quantity:1}]}})}},55750:function(e,t,i){"use strict";i.d(t,{a:function(){return A}});var a=i(52322),n=i(2784),r=i(99127),s=i(71680),o=i(16484),l=i(42670),d=i(30811),c=i(72152),u=i(30535),m=i(92244),p=i(32434),h=i(19458),x=i(21353),f=i(96284),g=i(52522),v=i(30118),b=i(92855),y=i(57855),j=i(3420),w=i(40457),N=i(83553),k=i(25586);function S(){let{qr:e}=(0,v._i)(),{designId:t,editMode:i}=(0,g.hl)(),{codeState:s,updateQRCode:o,generatedSVG:d}=(0,y.O)(),c=(0,n.useCallback)(async i=>{if(null==e?void 0:e.svg){if("svg"===i){let i=window.document.createElement("a");i.download="".concat(t,"-qr.svg"),i.href="data:image/svg+xml;base64,".concat(window.btoa(e.svg)),i.click()}else{let i=document.createElement("canvas"),a=i.getContext("2d"),n=new Image;n.onload=()=>{i.width=2*n.width,i.height=2*n.height,null==a||a.drawImage(n,0,0);let e=document.createElement("a");e.download="".concat(t,"-qr.png"),e.href=i.toDataURL("image/png"),e.click()},n.src="data:image/svg+xml;base64,".concat(window.btoa(e.svg))}}},[t,null==e?void 0:e.svg]);return(0,a.jsx)("div",{className:"mx-auto mt-3 mb-6 w-full border rounded py-2 px-4 bg-gray-50 items-center flex justify-between",children:(null==e?void 0:e.svg)?(0,a.jsxs)(a.Fragment,{children:[e.svg.includes("viewBox")?(0,a.jsx)("span",{className:"w-28 flex h-28",style:{color:null==e?void 0:e.fillColor},dangerouslySetInnerHTML:{__html:e.svg}}):(0,a.jsx)("span",{className:"w-28 flex h-28",children:(0,a.jsx)("img",{src:"data:image/svg+xml;base64,".concat(d),width:null==e?void 0:e.width,height:null==e?void 0:e.height,draggable:!1})}),(0,a.jsxs)("div",{className:"flex flex-col items-center",children:[(null==e?void 0:e.fillColor)&&(0,a.jsxs)("div",{className:"flex flex-col mb-2",children:[(0,a.jsx)("span",{className:"mb-2",children:(0,a.jsx)(l.Z,{id:"Editor.Menu.Text.Color"})}),(0,a.jsx)("span",{children:(0,a.jsx)(j.zH,{onChange:e=>o({fillColor:e}),color:e.fillColor,"data-testid":"color-circle-0",readonly:i===N.uz.Locked})})]}),s===h.QRCodeState.success&&(0,a.jsxs)(k.v2,{as:"div",className:"relative",children:[(0,a.jsxs)(k.j2,{className:"flex items-center gap-2 text-2xl md:text-xl p-3 bg-white border rounded hover:bg-gray-50 light-button",children:[(0,a.jsx)(w.eEq,{}),(0,a.jsx)(w.IAR,{className:"text-sm"})]}),(0,a.jsxs)(k.sd,{className:"absolute right-0 mt-1 w-48 bg-white border rounded shadow-lg z-50 border-light-blue",children:[(0,a.jsx)(k.sN,{children:e=>{let{active:t}=e;return(0,a.jsx)("button",{className:"".concat(t?"bg-gray-100":""," w-full text-left px-4 py-2"),onClick:()=>c("svg"),children:"Download as SVG"})}}),(0,a.jsx)(k.sN,{children:e=>{let{active:t}=e;return(0,a.jsx)("button",{className:"".concat(t?"bg-gray-100":""," w-full text-left px-4 py-2"),onClick:()=>c("png"),children:"Download as PNG"})}})]})]})]})]}):(0,a.jsxs)("span",{className:"flex flex-row items-center",children:[(0,a.jsx)(r.E2A,{fontSize:100}),(0,a.jsx)("p",{className:"text-center text-sm",children:"QR code will appear here"})]})})}var E=i(18997),C=i(65089),_=i(51574),I=i(83096);let D=e=>{let{destination:t}=e,i=(0,n.useCallback)(()=>{r.current&&(r.current.select(),r.current.setSelectionRange(0,99999))},[]),r=(0,n.useRef)(null);return(0,a.jsx)("div",{className:"flex flex-row items-center justify-between w-full my-2 text-black bg-gray-200 border-0 rounded shadow cursor-pointer",onClick:i,children:(0,a.jsx)("input",{type:"text",value:t,readOnly:!0,className:"w-full p-2 pl-4 bg-transparent",ref:r,"aria-label":"Shareable page URL"})})};var R=i(78369),T=i(87732);function M(){let{codeState:e,fetchQRCode:t}=(0,y.O)(),{links:i,qr:r}=(0,v._i)(),[s,o]=n.useState((null==r?void 0:r.destination)||"");return(0,a.jsxs)("form",{onSubmit:e=>{e.stopPropagation(),e.preventDefault(),t(h.QRDestination.custom,s),(0,E.Kz)("change-qr-destination",{destination:h.QRDestination.custom})},children:[(0,a.jsx)("div",{className:"mt-2",children:(0,a.jsx)(R.I,{type:"url",name:"custom-qr-destination",label:"Custom URL",className:"w-full",autoFocus:!0,placeholder:"https://example.com/your-custom-url",value:s,onChange:e=>o(e.target.value),autoComplete:"off"})}),(0,a.jsx)(x.z,{theme:"blue",block:!0,className:"mt-3",loading:e===h.QRCodeState.loading,icon:T.TBd,"data-testid":b.z.QR_CODE_GENERATE_BUTTON,disabled:!s||(null==i?void 0:i.custom_qr_dest)===s,type:"submit",children:"Save"})]})}var P=i(59637);let A=()=>{let{qr:e,links:t}=(0,v._i)(),{editMode:i}=(0,g.hl)(),{codeState:j,updateQRCode:w,fetchQRCode:k}=(0,y.O)(),R=(0,C.dy)(),{pendingResourceCount:T}=(0,C.o0)(),{storedURL:A,externalURL:F}=(0,I.FI)(),L=F||((null==R?void 0:R.type)===_.CustomFileType.spotify?null==R?void 0:R.publicURL:null),[z,O]=(0,n.use
1State)(()=>(null==e?void 0:e.destinationLinkId)?e.destinationLinkId:L&&(null==t?void 0:t.short_spotify)===(null==e?void 0:e.destination)?h.QRDestination.spotify:A&&(null==t?void 0:t.short_audio)===(null==e?void 0:e.destination)?h.QRDestination.audio:(null==t?void 0:t.custom_qr_dest)&&t.custom_qr_dest===(null==e?void 0:e.destination)?h.QRDestination.custom:h.QRDestination.design),U=(null==R?void 0:R.type)===_.CustomFileType.bucket&&!!R.pathInBucket,Z=z===h.QRDestination.audio&&(T>0||!U),W=(0,n.useCallback)(async()=>{w({imported:!1})},[w]),Q=(0,n.useCallback)(async()=>{w({imported:!0})},[w]),B=(0,n.useMemo)(()=>({...(null==R?void 0:R.type)===_.CustomFileType.bucket?{[h.QRDestination.audio]:"Uploaded audio"}:{},...(null==R?void 0:R.type)===_.CustomFileType.spotify?{[h.QRDestination.spotify]:"Song on Spotify"}:{},design:"Design landing page",[h.QRDestination.custom]:"Custom URL"}),[R]),H=(0,n.useMemo)(()=>{let e=[h.QRDestination.audio,h.QRDestination.spotify,h.QRDestination.design,h.QRDestination.custom],t={[h.QRDestination.audio]:d.Z,[h.QRDestination.spotify]:d.Z,[h.QRDestination.design]:c.Z,[h.QRDestination.custom]:u.Z};return e.filter(e=>B[e]).map(e=>({destination:e,label:B[e],Icon:t[e]}))},[B]),G=(0,n.useMemo)(()=>{var e,t;return null!==(t=null!==(e=H.find(e=>e.destination===z))&&void 0!==e?e:H[0])&&void 0!==t?t:null},[H,z]);return(0,n.useEffect)(()=>{(null==R?void 0:R.type)===_.CustomFileType.bucket&&z===h.QRDestination.spotify?O(h.QRDestination.audio):(null==R?void 0:R.type)===_.CustomFileType.spotify&&z===h.QRDestination.audio&&O(h.QRDestination.spotify)},[R,z]),(0,a.jsxs)("div",{className:"pb-4",children:[(0,a.jsx)("p",{className:"mb-3 text-sm",children:z===h.QRDestination.spotify?"A QR code that opens your song on Spotify":"A QR code that leads to your design with audio"}),(0,a.jsx)(S,{}),(0,a.jsxs)("div",{className:"mt-3",children:[(0,a.jsx)("p",{className:"mb-2 text-xs font-semibold uppercase tracking-wide text-gray-600",children:"QR code destination"}),(0,a.jsxs)(P.h_,{children:[(0,a.jsx)(P.$F,{asChild:!0,children:(0,a.jsxs)("button",{type:"button",className:"flex w-full items-center justify-between rounded-lg border border-gray-500 bg-white px-3 py-2 text-left text-sm text-gray-900 shadow-sm transition-colors hover:border-gray-600 hover:bg-gray-50 disabled:cursor-not-allowed disabled:opacity-60",disabled:i===N.uz.Locked||!G,"data-testid":"select-qr-destination","aria-label":"QR code destination",children:[G&&(0,a.jsxs)("span",{className:"flex items-center gap-2",children:[(0,a.jsx)(G.Icon,{className:"h-4 w-4 shrink-0 text-gray-600"}),(0,a.jsx)("span",{children:G.label})]}),(0,a.jsx)(m.Z,{className:"h-4 w-4 text-gray-500","aria-hidden":!0})]})}),(0,a.jsx)(P.AW,{align:"start",className:"w-[var(--radix-dropdown-menu-trigger-width)] border-gray-500 bg-white shadow-lg",children:H.map(e=>(0,a.jsx)(P.Xi,{className:"rounded-md text-gray-900 focus:bg-gray-100 focus:text-gray-900",onSelect:()=>{O(e.destination),e.destination!==h.QRDestination.custom&&(e.destination!==h.QRDestination.audio||!(T>0)&&U)&&(k(e.destination),(0,E.Kz)("change-qr-destination",{destination:e.destination}))},children:(0,a.jsxs)("span",{className:"flex w-full items-center gap-2",children:[(0,a.jsx)(e.Icon,{className:"h-4 w-4 shrink-0 text-gray-700","aria-hidden":!0}),(0,a.jsx)("span",{children:e.label}),e.destination===z&&(0,a.jsx)(p.Z,{className:"ml-auto h-4 w-4 text-gray-700","aria-hidden":!0})]})},e.destination))})]})]}),(null==e?void 0:e.destination)&&(0,a.jsx)(D,{destination:e.destination}),z===h.QRDestination.custom&&(0,a.jsx)(M,{}),(0,a.jsx)(f.i,{}),j!==h.QRCodeState.success&&z!==h.QRDestination.custom&&(0,a.jsx)(x.z,{theme:"blue",block:!0,className:"mt-3",onClick:()=>k(z),loading:j===h.QRCodeState.loading,disabled:Z,icon:o.A$d,"data-testid":b.z.QR_CODE_GENERATE_BUTTON,children:(0,a.jsx)(l.Z,{id:"Editor.Menu.QR.Generate"})}),j===h.QRCodeState.success&&i!==N.uz.Locked&&(0,a.jsx)(a.Fragment,{children:(null==e?void 0:e.imported)?(0,a.jsx)(x.z,{theme:"danger",block:!0,className:"mt-2",onClick:W,icon:r.VPh,children:(0,a.jsx)(l.Z,{id:"Editor.Menu.QR.Remove"})}):(0,a.jsx)(x.z,{theme:"blue",block:!0,className:"mt-2",onClick:Q,icon:s.u$v,children:(0,a.jsx)(l.Z,{id:"Editor.Menu.QR.Add"})})}),(0,a.jsx)("p",{className:"text-xs mt-4",children:"Once purchased, your QR code will never expire as long as WaveVisual is in business."})]})}},12979:function(e,t,i){"use strict";i.d(t,{d:function(){return B}});var a=i(52322),n=i(2784),r=i(71406),s=i(99127),o=i(40457),l=i(42670),d=i(42658),c=i(79130),u=i.n(c),m=i(43034),p=i(49695),h=i.n(p),x=i(38372),f=i(65725),g=i(32656),v=i(37365),b=i(37567),y=i(55750),j=i(39220),w=i(96332),N=i(11673),k=i(8188),S=i(95978),E=i(19458),C=i(21571),_=i(16867),I=i(88745),D=i(7496);function R(){let{extraData:e}=(0,n.useContext)(m.q5),{target:t}=null!=e?e:{};return"background"===t?(0,a.jsx)(M,{}):(0,a.jsx)(T,{})}function T(){let{waveformConfig:e,updateWaveformConfig:t}=(0,D.d)(),i=(0,C.g)().waveGradientDirectionPicker&&e.style!==E.SoundWaveStyle.horizontal_bezier;return(0,a.jsxs)("div",{className:"flex flex-col",children:[(0,a.jsx)(m.Ab,{title:(0,a.jsx)(l.Z,{id:"Editor.Menu.Colors.Wave"})}),(0,a.jsx)(I.V,{colors:e.waveColors,onColorsChange:e=>t({waveColors:e}),disableAlpha:!0,gradientDirection:e.waveGradientDirection,onGradientDirectionChange:i?e=>t({waveGradientDirection:e}):void 0,lightArrow:!0,defaultColor:"#000000","data-testid":"color-stops-picker-wave"})]})}function M(){let{background:{colors:e,gradientDirection:t}
1,updateBackground:i}=(0,_.Dq)();return(0,a.jsxs)("div",{className:"flex flex-col",children:[(0,a.jsx)(m.Ab,{title:(0,a.jsx)(l.Z,{id:"Editor.Menu.Background.Colors"})}),(0,a.jsx)(I.V,{colors:e,onColorsChange:e=>i({colors:e}),canBeTransparent:!0,gradientDirection:t,onGradientDirectionChange:e=>i({gradientDirection:e}),defaultColor:"#ffffff","data-testid":"color-stops-picker-background"})]})}var P=i(69095),A=i(70312),F=i(78958),L=i(88319),z=i(69886),O=i(26607),U=i(52522),Z=i(30118),W=i(45539);let Q=u().bind(h()),B=e=>{let{position:t,tabOptions:i,lockTab:c}=e,{shownTab:u,setShownTab:p,collapsed:h,setCollapsed:C}=(0,n.useContext)(m.q5),{isPaid:_}=(0,U.hl)(),{status:I}=(0,Z._i)(),D=(0,W.A)(W.T.FREE_PREVIEW_DOWNLOAD),T=(0,n.useMemo)(()=>i.reduce((e,t)=>({...e,[t]:function(e,t){switch(e){case F.e.source:return{header:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(d.ibD,{fontSize:20}),(0,a.jsx)("span",{className:"mt-1 text-xs whitespace-nowrap",children:(0,a.jsx)(l.Z,{id:"Editor.Menu.Source"})})]}),content:(0,a.jsx)(b.k,{}),key:e};case F.e.soundwave:return{header:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(r._5g,{fontSize:30,className:"-mt-0.5"}),(0,a.jsx)("span",{className:"text-xs whitespace-nowrap",children:(0,a.jsx)(l.Z,{id:"Editor.Menu.SoundWave"})})]}),key:"soundwave",content:(0,a.jsx)(k.N,{})};case F.e.background:return{header:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("svg",{style:{width:26,height:26},xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",children:(0,a.jsx)("path",{d:"M4.03 21.03a.75.75 0 0 1-1.06-1.06l17-17a.75.75 0 0 1 1.06 1.06l-17 17zm4.5.5a.75.75 0 0 1-1.06-1.06l13-13a.75.75 0 0 1 1.06 1.06l-13 13zm5 0a.75.75 0 0 1-1.06-1.06l8-8a.75.75 0 0 1 1.06 1.06l-8 8zm5.5-.5a.75.75 0 0 1-1.06-1.06l2-2a.75.75 0 0 1 1.06 1.06l-2 2zm-15.5-4.5a.75.75 0 0 1-1.06-1.06l13-13a.75.75 0 0 1 1.06 1.06l-13 13zm0-5a.75.75 0 0 1-1.06-1.06l8-8a.75.75 0 0 1 1.06 1.06l-8 8zm.5-5.5a.75.75 0 0 1-1.06-1.06l2-2a.75.75 0 0 1 1.06 1.06l-2 2z",fill:"currentColor"})}),(0,a.jsx)("span",{className:"text-xs whitespace-nowrap",children:(0,a.jsx)(l.Z,{id:"Editor.Menu.Background"})})]}),key:"background",content:(0,a.jsx)(v.T,{})};case F.e.text:return{header:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(s.JCu,{fontSize:26}),(0,a.jsx)("span",{className:"text-xs whitespace-nowrap",children:(0,a.jsx)(l.Z,{id:"Editor.Menu.Text"})})]}),key:"text",content:(0,a.jsx)(g.x,{})};case F.e.qr:return{header:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(s.E2A,{fontSize:26}),(0,a.jsx)("span",{className:"text-xs whitespace-nowrap",children:(0,a.jsx)(l.Z,{id:"Editor.Menu.QR.Title"})})]}),key:"qr",content:(0,a.jsx)(y.a,{})};case F.e.export:return{header:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(o.eEq,{fontSize:26}),(0,a.jsx)("span",{className:"text-xs whitespace-nowrap",children:(0,a.jsx)(l.Z,{id:"Editor.Menu.Export"})})]}),key:"export",content:t?(0,a.jsx)(f.P,{}):(0,a.jsx)(x.e,{})};case F.e.digitalCheckout:return{header:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(o.eEq,{fontSize:26}),(0,a.jsx)("span",{className:"text-xs whitespace-nowrap",children:(0,a.jsx)(l.Z,{id:"Editor.Menu.Export"})})]}),key:"digitalCheckout",content:(0,a.jsx)(N.i,{})};case F.e.templates:return{header:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(s.As9,{fontSize:26}),(0,a.jsx)("span",{className:"text-xs whitespace-nowrap",children:(0,a.jsx)(l.Z,{id:"Editor.Menu.Templates"})})]}),key:"templates",content:(0,a.jsx)(w.U,{})};case F.e.print:return{header:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(s.Ypm,{fontSize:26}),(0,a.jsx)("span",{className:"text-xs whitespace-nowrap",children:"Print"})]}),key:"print",content:(0,a.jsx)(j.A,{})};case F.e.colorPicker:return{header:null,key:"colorPicker",content:(0,a.jsx)(S.a,{})};case F.e.colorStopsPicker:return{header:null,key:"colorStopsPicker",content:(0,a.jsx)(R,{})};case F.e.fontPicker:return{header:null,key:"fontPicker",content:(0,a.jsx)(P.S,{})};case F.e.effectsPicker:return{header:null,key:"effectsPicker",content:(0,a.jsx)(A.D,{})};case F.e.layers:return{header:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(s.t5C,{fontSize:26}),(0,a.jsx)("span",{className:"text-xs whitespace-nowrap",children:(0,a.jsx)(l.Z,{id:"Editor.Menu.Layers",defaultMessage:"Layers"})})]}),key:"layers",content:(0,a.jsx)(L.f,{})};case F.e.animation:return{header:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(d.Jj,{fontSize:26}),(0,a.jsx)("span",{className:"text-xs whitespace-nowrap",children:(0,a.jsx)(l.Z,{id:"Editor.Menu.Animation",defaultMessage:"Animation"})})]}),key:"animation",content:(0,a.jsx)(z.T,{})};case F.e.captions:return{header:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(d.W3p,{fontSize:26}),(0,a.jsx)("span",{className:"mt-1 text-xs whitespace-nowrap",children:"Captions"})]}),key:"captions",content:(0,a.jsx)(O.X,{})};default:return{header:null,key:"empty",content:null}}}(t,"on"===D)}),{}),[i,D]);(0,n.useEffect)(()=>{I===E.EditorStatus.LOADED&&(u&&i.includes(u)?p(u):p(_?F.e.export:i[0]))},[_,p,u,i,I]);let M="left"===t;return(0,a.jsx)(m.mQ,{shownTab:u,setShownTab:p,tabPosition:t,lockTabWithKey:c,collapse:M?h:void 0,setCollapsed:M?C:void 0,className:Q("tabMenu","bg-white border-t border-soft-border text-gray-600",{tabMenuCollapsed:M&&h}),data:T})}},96332:function(e,t,i){"use strict";i.d(t,{U:function(){return es}});var a=i(52322),n=i(2784),r=i(83112),s=i(82066),o=i(71680),l=i(30118),d=i(118),c=i(74978),u=i(23083),m=i(96284),p=i(52522),h=i(65089);let x=["h-28","h-20","h-36","h-24","h-16","h-32","h-20","h-28","h-16","h-24","h-32","h-20","h-28","h-16","h-24","h-36","h-20","h-28"];function f(){return(0,a.jsx)("div",{className:"columns-2 gap-2",children:x.map((e,t)=>(0,a.jsx)("div",{className:"".concat(e," animate-pulse bg-gray-200 rounded break-inside-avoid mb-2")},t))})}var g=i(96577),v=i.n(g),b=i(15343),y=i(18997),j=i(9223),w=i(26140),N=i(7355);function k(e){let{name:t,config:i,resources:n,slug:r,applyTemplate:s,id:o,updatedAt:l,isPublic:d}=e,c=(0,N.aC)();return(0,a.jsxs)("button",{type:"button",className:"cursor-pointer rounded-md touch-manipulation overflow-hidden shadow hover:shadow-md border border-gray-400 hover:border-indigo-600 hover:shadow-indigo-200 focus:outline outline-offset-0 outline-4 outline-indigo-300 flex-1 flex items-center relative",onClick:()=>{s({config:i,resources:n}),(0,y.Kz)("template-click",{templateName:t})},children:[(0,a.jsx)(v(),{loader:o?w.Ww:j._,src:o?"/img/t/".concat(o,".jpg?cb=").concat(l||"1"):"/template-thumbs/".concat(r,".jpg"),alt:t||"Template thumbnail",draggable:!1,...i.canvasAspectRatio?b.ReferenceDimensions[i.canvasAspectRatio]:{},style:{maxWidth:"100%",height:"auto"}}),d&&c.isAdmin&&(0,a.jsx)("span",{className:"absolute top-2 left-2 bg-green-500 text-white text-xs font-semibold px-2 py-1 rounded-full shadow-md",children:"Public"})]})}var S=i(55313);let E={highlight:"Highlight",quote:"Quote",guest:"Guest",teaser:"Teaser"};function C(e){var t;let{name:i,slug:n,description:r,podcastJob:s,podcastRatio:o,config:l,resources:d,applyTemplate:c}=e,u=s?E[s]:i,m=null!==(t=null==o?void 0:o.replace("-","â¶"))&&void 0!==t?t:"";return(0,a.jsx)("button",{type:"button",className:"cursor-pointer rounded-md touch-manipulation overflow-hidden shadow hover:shadow-md border border-gray-400 hover:border-indigo-600 hover:shadow-indigo-200 focus:outline outline-offset-0 outline-4 outline-indigo-300 w-full text-left break-inside-avoid mb-2",onClick:()=>{c({config:l,resources:d}),(0,y.Kz)("template-click",{templateName:i,podcastJob:s,podcastRatio:o})},"aria-label":"Apply ".concat(i),children:(0,a.jsxs)("div",{className:"p-3 min-h-[5.5rem] flex flex-col justify-center",style:{background:"linear-gradient(180deg, ".concat(S.PODCAST_BRAND_KIT.colors.background[0],", ").concat(S.PODCAST_BRAND_KIT.colors.background[1],")")},children:[(0,a.jsx)("p",{className:"text-[10px] font-semibold uppercase tracking-wide",style:{color:S.PODCAST_BRAND_KIT.colors.wave[0]},children:m}),(0,a.jsx)("p",{className:"text-sm font-semibold text-white leading-snug",children:u}),r?(0,a.jsx)("p",{className:"mt-1 text-[11px] leading-snug line-clamp-2",style:{color:S.PODCAST_BRAND_KIT.colors.typeMuted},children:r}):null,n?(0,a.jsx)("span",{className:"sr-only",children:n}):null]})})}var _=i(40457),I=i(59637);function D(e){let{showCopyLink:t=!1,showUpdate:i=!1,showDelete:n=!1,onCopyLink:r,onUpdate:s,onDelete:l}=e;return t||i||n?(0,a.jsxs)(I.h_,{children:[(0,a.jsx)(I.$F,{asChild:!0,children:(0,a.jsx)("button",{type:"button","aria-label":"Template actions",className:"absolute top-2 right-2 z-10 inline-flex items-center justify-center p-1.5 bg-white/95 rounded-full shadow-md opacity-90 hover:opacity-100 transition-opacity text-gray-700 hover:text-gray-900",onClick:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation(),children:(0,a.jsx)(_.evw,{size:14,"aria-hidden":!0})})}),(0,a.jsxs)(I.AW,{align:"end",className:"min-w-[10rem]",onClick:e=>e.stopPropagation(),children:[t&&(0,a.jsxs)(I.Xi,{onSelect:e=>{e.preventDefault(),null==r||r()},children:[(0,a.jsx)(o.gjK,{className:"mr-2 shrink-0",size:14,"aria-hidden":!0}),"Copy link"]}),i&&(0,a.jsxs)(I.Xi,{onSelect:e=>{e.preventDefault(),null==s||s()},children:[(0,a.jsx)(o.GVn,{className:"mr-2 shrink-0",size:14,"aria-hidden":!0}),"Update"]}),n&&(0,a.jsxs)(I.Xi,{className:"text-red-600 focus:text-red-600",onSelect:e=>{e.preventDefault(),null==l||l()},children:[(0,a.jsx)(o.Xm5,{className:"mr-2 shrink-0",size:14,"aria-hidden":!0}),"Delete"]})]})]}):null}var R=i(60417),T=i.n(R),M=i(72818),P=i(96335),A=i(1023),F=i(52305),L=i(38986),z=i(80917),O=i(40568),U=i(64820);function Z(e){return(0,M.CE)((0,P.Gc)(e),"minScaleLimit","shouldSyncRect")}function W(e){return(0,M.CE)((0,P.y$)(e),"minScaleLimit","shouldSyncRect")}function Q(e,t){let i=e.resourceId&&(null==t?void 0:t[e.resourceId])?t[e.resourceId]:void 0,a=i&&"publicURL"in i&&"string"==typeof i.publicURL?i.publicURL:void 0;return a&&!e.url?{...e,url:a}:e}function B(e,t,i){var a,n,r;let s=(0,A.Z)(e.getObjects()),o=s.filter(e=>{var t;return null===(t=e.name)||void 0===t?void 0:t.startsWith(L.WAVEFORM_NODE_PREFIX)}),l=s.find(e=>e.name===L.QRCODE_OBJECT_NAME),{canvasAspectRatio:d,editorSize:c,waveformConfig:u,frameConfig:m,waveforms:p}=t;if(0===o.length){let e=Error("No waveforms present on canvas");throw(0,y.H)(e),e}let h=(p||[]).map(e=>
1{let t=o.find(t=>t.name===e.id),a=t?(0,F.convertActualToReferenceObject)(W(t),c.ratioToReference,m):e.rect,n=(0,z.T)(e.centerImage),r=(null==n?void 0:n.resourceId)&&(null==i?void 0:i[n.resourceId])?i[n.resourceId]:void 0,s=n&&(null==r?void 0:r.publicURL)&&!n.url?{...n,url:r.publicURL}:n,l={id:e.id,rect:a,...void 0!==s?{centerImage:s}:{}},d=Array.isArray(e.waveformData)&&e.waveformData.length>0?e.waveformData:void 0;return d?{...l,mockWaveformData:d}:l}),x=t.qr?(0,M.CE)(t.qr,"minScaleLimit"):{},f=l?(0,F.convertActualToReferenceObject)(W(l),c.ratioToReference,m):{},{svg:g,publicURL:v,...b}={svg:void 0,publicURL:void 0,imported:!1,...x,...f},j=t.background.imageURL||t.background.imageResourceId&&(null==i?void 0:null===(a=i[t.background.imageResourceId])||void 0===a?void 0:a.publicURL)||void 0,w=s.filter(e=>{var t;return null===(t=e.name)||void 0===t?void 0:t.startsWith(L.IMAGE_LAYER_OBJECT_NAME_PREFIX)}),N=(t.images||[]).filter(e=>"asset"===e.kind).map(e=>{var t,a,n,r,s,o;let l=w.find(t=>t.name===e.id);if(l){let t=(0,F.convertActualToReferenceObject)(W(l),c.ratioToReference,m),s=null!==(r=null!==(n=null===(a=e.rect)||void 0===a?void 0:a.zIndex)&&void 0!==n?n:e.zIndex)&&void 0!==r?r:U.LAYER_ZINDEX.full.assetImage;return Q({...(0,M.CE)(e,"zIndex"),rect:{...t,zIndex:s}},i)}let d=null!==(o=null!==(s=null===(t=e.rect)||void 0===t?void 0:t.zIndex)&&void 0!==s?s:e.zIndex)&&void 0!==o?o:U.LAYER_ZINDEX.full.assetImage;return Q(e.rect?{...(0,M.CE)(e,"zIndex"),rect:{...e.rect,zIndex:d}}:{...(0,M.CE)(e,"zIndex"),rect:{zIndex:d}},i)}),k=t.background,S=j||(null==k?void 0:k.imageResourceId)?Q({id:L.CUSTOM_BG_IMAGE_FILE_ID,kind:"background",resourceId:(null==k?void 0:k.imageResourceId)||L.CUSTOM_BG_IMAGE_FILE_ID,url:null!==(n=null!=j?j:null==k?void 0:k.imageURL)&&void 0!==n?n:null,rect:(null==k?void 0:k.imageRect)&&!(0,M.xb)(k.imageRect)?{...Z(k.imageRect),zIndex:U.LAYER_ZINDEX.full.bgImage}:{zIndex:U.LAYER_ZINDEX.full.bgImage},backgroundSize:null!==(r=null==k?void 0:k.backgroundSize)&&void 0!==r?r:void 0,visible:!0},i):null,E=S?[S,...N]:N,C=function(e,t,i){if(!i)return;let a=T()([e.background.imageResourceId,...(e.waveforms||[]).map(e=>{var t;return null===(t=e.centerImage)||void 0===t?void 0:t.resourceId}),...t.map(e=>e.resourceId),...t.map(e=>e.posterResourceId)]).reduce((e,t)=>(t&&i[t]&&(e[t]=i[t]),e),{});return Object.keys(a).length>0?a:void 0}(t,E,i);return{config:{canvasAspectRatio:d,waveformConfig:{...u,trim:{startRatio:0,endRatio:1}},waveforms:h,textNodes:T()(t.textNodes.map(e=>{let i=(0,O.shouldKeepEmptyCaptionTextNode)(e.name,t.captions);if(""===e.text&&!i)return null;let a=s.find(t=>t.name===e.name);return a?{...(0,M.CE)(e,"minScaleLimit"),...(0,F.convertActualToReferenceObject)(W(a),c.ratioToReference,m)}:i?(0,M.CE)(e,"minScaleLimit"):((0,y.H)(Error("EditorContext and Fabric nodes are not synced somehow")),null)})),background:{...t.background,...j?{imageURL:j}:{},imageRect:t.background.imageRect&&!(0,M.xb)(t.background.imageRect)?Z(t.background.imageRect):void 0},qr:b,images:E},...C?{resources:C}:{}}}var H=i(62995),G=i(54935),V=i(15644),K=i(21353),q=i(1825),Y=i(3438),X=i(95747),$=i(8959),J=i(63591),ee=i(17129);function et(e){var t;return e.isLoggedIn||(null===(t=e.userDetails)||void 0===t?void 0:t.role)===G.i4.admin}function ei(e){var t;return(null===(t=e.userDetails)||void 0===t?void 0:t.role)===G.i4.admin}let ea=e=>"id"in e&&"string"==typeof e.id;function en(e){return ea(e)?e.id:e.slug?e.slug:null}async function er(e){try{await navigator.clipboard.writeText((0,$.FP)(e)),(0,q.e)({theme:"success",content:"Template link copied",ms:2e3,position:"bottom"})}catch(e){(0,H.logError)(e),(0,q.e)({theme:"error",content:"Failed to copy template link",ms:2e3,position:"bottom"})}}let es=()=>{var e;let t=(0,N.aC)(),{data:i,isFetching:n,refetch:r}=(0,s.useQuery)(["templates",null===(e=t.userDetails)||void 0===e?void 0:e.uid],async()=>(0,u.Lg)(),{staleTime:864e5});return(0,a.jsxs)("div",{children:[n&&(0,a.jsx)(f,{}),i&&(0,a.jsx)(eo,{templates:i,refetch:r})]})};function eo(e){let{templates:t,refetch:i}
1=e,[x,f]=(0,n.useState)(null),[g,v]=(0,n.useState)(null),b=(0,l._i)(),{resources:y,mergePendingResources:j}=(0,h.o0)(),{setNotSaved:w}=(0,d.r)(),{canvas:S,designId:E}=(0,p.hl)(),_=(0,s.useMutation)("addTemplate",()=>{if(!S)return Promise.reject(Error("Canvas not found"));let e=B(S,b,y);return(0,u.eC)(e)},{onSuccess:i,onError(e){(0,H.logError)(e)}}),I=(0,s.useMutation)("addPublicTemplate",()=>{if(!S)return Promise.reject(Error("Canvas not found"));let e=B(S,b,y);return(0,u.RH)(e)},{onSuccess:i,onError(e){(0,H.logError)(e),(0,q.e)({theme:"error",content:"Failed to save public template",ms:2e3,position:"bottom"})}}),R=(0,s.useMutation)("deleteTemplate",e=>{let{templateId:t,isPublic:i}=e;return i&&ei(M)?(0,u.ap)(t):(0,u.cE)(t)},{onSuccess:()=>{i(),(0,q.e)({theme:"success",content:"Template deleted successfully",ms:2e3,position:"bottom"})},onError(e){(0,H.logError)(e),(0,q.e)({theme:"error",content:"Failed to delete template",ms:2e3,position:"bottom"})}}),T=(0,s.useMutation)("updateTemplate",e=>{let{templateId:t,isPublic:i}=e;if(!S)return Promise.reject(Error("Canvas not found"));let a=B(S,b,y);return i&&ei(M)?(0,u.aL)(a,t):(0,u.z1)(a,t)},{onSuccess:()=>{i(),(0,q.e)({theme:"success",content:"Public template updated successfully",ms:2e3,position:"bottom"})},onError(e){(0,H.logError)(e),(0,q.e)({theme:"error",content:"Failed to update public template",ms:2e3,position:"bottom"})}}),M=(0,N.aC)(),P=(0,r.Z)(),A=(0,X.Q)(e=>e.requestAuthWall),F=!et(M),L=e=>{(0,c.d1)(e.config,b,e.resources,j),w(),E&&(0,Y.kI)({designId:E}),(0,q.e)({theme:"info",content:"Template applied",ms:2e3,position:"bottom"})};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("p",{className:"w-full text-sm text-gray-900 mb-2",children:"Your Templates"}),(0,a.jsxs)("div",{className:"columns-2 gap-2",children:[(0,a.jsxs)("button",{type:"button",className:"flex flex-col items-center justify-center gap-1 p-1 h-24 w-full text-gray-900 border border-gray-400 border-dashed cursor-pointer rounded-md bg-gray-50 hover:text-violet-600 hover:border-violet-600 break-inside-avoid mb-2",onClick:()=>{if(!et(M)){A("template_save");return}_.mutate()},title:F?P.formatMessage({id:"Templates.AuthWall.Tooltip"}):void 0,"aria-label":F?P.formatMessage({id:"Templates.AuthWall.Tooltip"}):void 0,children:[F&&(0,a.jsx)(o.kUi,{className:"shrink-0",size:14,"aria-hidden":!0}),(0,a.jsx)("span",{children:"Save design as template"})]}),et(M)&&(0,a.jsxs)(a.Fragment,{children:[ei(M)&&(0,a.jsx)("button",{type:"button",className:"flex items-center justify-center p-1 h-24 w-full text-gray-900 border border-gray-400 border-dashed cursor-pointer rounded-md bg-blue-50 hover:text-blue-600 hover:border-blue-600 break-inside-avoid mb-2",onClick:()=>I.mutate(),children:"Save design as Public Template"}),null==t?void 0:t.private.map(e=>{let t=en(e);return(0,a.jsxs)("div",{className:"group relative break-inside-avoid mb-2",children:[(0,a.jsx)(k,{...e,applyTemplate:L,id:e.id}),(0,a.jsx)(D,{showCopyLink:ei(M)&&!!e.isPublic&&!!t,showUpdate:!0,showDelete:!0,onCopyLink:t?()=>er(t):void 0,onUpdate:()=>v({templateId:e.id,isPublic:!!e.isPublic}),onDelete:()=>f({templateId:e.id,isPublic:!!e.isPublic})})]},e.id)})]})]}),(0,a.jsx)(m.i,{}),ee.SHOW_PODCAST_JOB_TEMPLATES?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("p",{className:"w-full text-sm text-gray-900 mb-2",children:"Podcast"}),(0,a.jsx)("p",{className:"w-full text-xs text-gray-500 mb-2",children:"Highlight, Quote, Guest, Teaser â pick a job and ratio, then drop in this episode."}),(0,a.jsx)("div",{className:"columns-2 gap-2",children:t.public.filter(J.isPodcastJobTemplate).map(e=>{let t=en(e),i=ea(e),n=i?e.id:void 0;return(0,a.jsxs)("div",{className:"group relative break-inside-avoid mb-2",children:[(0,a.jsx)(C,{...e,applyTemplate:L}),ei(M)&&(0,a.jsx)(D,{showCopyLink:!!t,showUpdate:i,showDelete:i,onCopyLink:t?()=>er(t):void 0,onUpdate:n?()=>v({templateId:n,isPublic:!1}):void 0,onDelete:n?()=>f({templateId:n,isPublic:!0}):void 0})]},i?e.id:e.slug)})}),(0,a.jsx)(m.i,{})]}):null,(0,a.jsx)("p",{className:"w-full text-sm text-gray-900 mb-2",children:"All Templates"}),(0,a.jsx)("div",{className:"columns-2 gap-2",children:t.public.filter(e=>
1!(0,J.isPodcastJobTemplate)(e)).map(e=>{let t=en(e),i=ea(e),n=i?e.id:void 0;return(0,a.jsxs)("div",{className:"group relative break-inside-avoid mb-2",children:[(0,a.jsx)(k,{...e,applyTemplate:L}),ei(M)&&(0,a.jsx)(D,{showCopyLink:!!t,showUpdate:i,showDelete:i,onCopyLink:t?()=>er(t):void 0,onUpdate:n?()=>v({templateId:n,isPublic:!1}):void 0,onDelete:n?()=>f({templateId:n,isPublic:!0}):void 0})]},i?e.id:e.slug)})}),(0,a.jsx)(V.Q,{open:!!g,onClose:()=>v(null),className:"sm:max-w-lg",children:(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsx)("h3",{className:"text-lg font-medium leading-6 text-gray-900",children:"Update Template"}),(0,a.jsx)("p",{className:"text-sm text-gray-500",children:"This will overwrite the selected template with your current design state."}),(0,a.jsxs)("div",{className:"mt-5 flex justify-end gap-3",children:[(0,a.jsx)(K.z,{theme:"light",onClick:()=>v(null),children:"Cancel"}),(0,a.jsx)(K.z,{theme:"primary",loading:T.isLoading,onClick:()=>{g&&(T.mutate({templateId:g.templateId,isPublic:g.isPublic}),v(null))},children:"Update"})]})]})}),(0,a.jsx)(V.Q,{open:!!x,onClose:()=>f(null),className:"sm:max-w-lg",children:(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsx)("h3",{className:"text-lg font-medium leading-6 text-gray-900",children:"Delete Template"}),(0,a.jsx)("p",{className:"text-sm text-gray-500",children:"Are you sure you want to delete this template? This action cannot be undone."}),(0,a.jsxs)("div",{className:"mt-5 flex justify-end gap-3",children:[(0,a.jsx)(K.z,{theme:"light",onClick:()=>f(null),children:"Cancel"}),(0,a.jsx)(K.z,{theme:"danger",loading:R.isLoading,onClick:()=>{x&&(R.mutate({templateId:x.templateId,isPublic:x.isPublic}),f(null))},children:"Confirm"})]})]})})]})}},3011:function(e,t,i){"use strict";i.d(t,{Qd:function(){return c},UQ:function(){return d},o4:function(){return u},vF:function(){return m}});var a=i(52322),n=i(2784),r=i(16170),s=i(77298),o=i(12524),l=i.n(o);let d=r.fC,c=n.forwardRef((e,t)=>{let{className:i,...n}=e;return(0,a.jsx)(r.ck,{ref:t,className:l()("border-b",i),...n})});c.displayName="AccordionItem";let u=n.forwardRef((e,t)=>{let{className:i,children:n,...o}=e;return(0,a.jsx)(r.h4,{className:"flex",children:(0,a.jsxs)(r.xz,{ref:t,className:l()("flex flex-1 items-center justify-between py-4 text-sm font-medium transition-all hover:underline text-left [&[data-state=open]>svg]:rotate-180",i),...o,children:[n,(0,a.jsx)(s.v4q,{className:"text-muted-foreground h-4 w-4 shrink-0 transition-transform duration-200"})]})})});u.displayName=r.xz.displayName;let m=n.forwardRef((e,t)=>{let{className:i,children:n,...s}=e;return(0,a.jsx)(r.VY,{ref:t,className:"data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down overflow-hidden text-sm",...s,children:(0,a.jsx)("div",{className:l()("pb-4 pt-0",i),children:n})})});m.displayName=r.VY.displayName},78128:function(e,t,i){"use strict";i.d(t,{p:function(){return r}});var a=i(3752),n=i(21571);function r(){let e=(0,a.d)(),{editorAudioPlayerBarMobile:t}=(0,n.g)();return!e||t}},67148:function(e,t,i){"use strict";i.d(t,{m:function(){return n}});var a=i(2784);let n=()=>{let e=(0,a.useRef)(!1);return(0,a.useEffect)(()=>(e.current=!0,()=>{e.current=!1}),[]),e}},60432:function(e,t,i){"use strict";i.d(t,{R:function(){return l}});var a=i(82066),n=i(38986),r=i(23083),s=i(21571);function o(e,t,i){var a;return null==e?void 0:null===(a=e.filter(e=>e.aspectRatio===t&&e.id.startsWith(i)))||void 0===a?void 0:a.sort((e,t)=>((null==e?void 0:e.price.unit_amount)||0)-((null==t?void 0:t.price.unit_amount)||0))}function l(e){let{enablePrinting:t}=(0,s.g)(),{data:i}=(0,a.useQuery)("product_prices",()=>(0,r.vD)(),{staleTime:36e5,enabled:t}),l=t&&i?i:null;return{canvasPrices:l?o(l,e,n.GELATO_CANVAS_ID_START):[],posterPrices:l?o(l,e,n.GELATO_POSTER_ID_START):[],framedPosterPrices:l?o(l,e,n.GELATO_FRAMED_POSTER_ID_START):[],isLoading:t&&!i}}},50249:function(e,t,i){"use strict";i.d(t,{u:function(){return r}});var a=i(2784),n=i(3438);let r=e=>{(0,a.useEffect)(()=>{(0,n.tN)(e)},[e])}},605:function(e,t,i){"use strict";i.d(t,{Z:function(){return r}});var a=i(18997),n=i(67201);function r(e,t){let{stage:i,productId:r,designId:s,videoProjectId:o,checkoutId:l,httpStatus:d,errorCode:c,errorMessage:u,errorSource:m,retryCount:p,paddleSdkVersion:h}=t,x=null!=m?m:(0,n.Rc)(e),f=(0,n.N6)(null!=u?u:e instanceof Error?e.message:String(null!=e?e:"Unknown checkout error")),g={checkout_error_stage:i,error_source:x,...c?{error_code:c}:{},...r?{product_id:r}:{},...s?{design_id:s}:{},...o?{video_project_id:o}:{},...l?{checkout_id:l}:{},...null!=d?{http_status:d}:{},...null!=p?{retry_count:p}:{}};(0,a.ee)(e,g),(0,a.Kz)("paddle_checkout_error",{checkout_error_stage:i,error_source:x,error_message:f,product_id:r,design_id:s,...o?{video_project_id:o}:{},checkout_id:l,...c?{error_code:c}:{},...null!=d?{http_status:d}:{},...null!=p?{retry_count:p}:{},...h?{paddle_sdk_version:h}:{}}).catch(()=>void 0)}},67201:function(e,t,i){"use strict";function a(e){return e.length<=500?e:"".concat(e.slice(0,499),"â¦")}function n(e){var t,i,n,r,s;let o=null!=e?e:{},l=null!==(s=null!==(r=o.error)&&void 0!==r?r:null===(t=o.checkout)||void 0===t?void 0:t.error)&&void 0!==s?s:{},d=function(){for(var e=arguments.length,t=Array(e),i=0;i<e;i++)t[i]=arguments[i];let a=t.find(e=>"string"==typeof e&&""!==e.trim()||"number"==typeof e&&Number.isFinite(e));return null==a?void 0:String(a)}(l.code,l.error_code,l.type,o.error_code,o.code,null===(i=o.checkout)||void 0===i?void 0:i.error_code),c=function(){for(var e=arguments.length,t=Array(e),i=0;i<e;i++)t[i]=arguments[i];return t.find(e=>"string"==typeof e&&""!==e.trim())}("string"==typeof l?l:void 0,l.message,l.error_message,l.detail,l.description,o.error_message,o.message,null===(n=o.checkout)||void 0===n?void 0:n.error_message);if(d||c)return{errorCode:d,errorMessage:c?a(c):void 0,errorSource:"paddle_sdk"};let u=Object.keys(o);return{errorMessage:a(u.length>0?"Unrecognised Paddle Checkout.Error payload; keys: ".concat(u.sort().join(",")):"Paddle Checkout.Error fired with an empty payload"),errorSource:"unknown"}}function r(e){let t=e instanceof Error?e.message:String(null!=e?e:"");
1return/network|fetch|timeout|ECONN|Failed to fetch|Load failed/i.test(t)?"network":"our_code"}i.d(t,{N6:function(){return a},Rc:function(){return r},rv:function(){return n}})},19613:function(e,t,i){"use strict";i.d(t,{Dv:function(){return o},FH:function(){return d},ak:function(){return s},rc:function(){return l}});var a=i(6993);let n=e=>"design-preview:".concat(e);function r(e){return e.startsWith("blob:")}function s(e){return e.startsWith("data:")||r(e)}function o(e,t){a.t8(n(e),t)}function l(e){if(function(){if("undefined"==typeof performance)return!1;let e=performance.getEntriesByType("navigation")[0];return(null==e?void 0:e.type)==="reload"}()){d(e);return}let t=a.U2(n(e));if(t&&"string"==typeof t){if(r(t)){a.Od(n(e));return}return t}}function d(e){a.Od(n(e))}},92141:function(e,t,i){"use strict";i.d(t,{j:function(){return d}});var a=i(23083),n=i(18997),r=i(605),s=i(6993),o=i(40258),l=i(61189);let d=async(e,t,i,d)=>{var c;let u=(0,n.yo)(),m=null!==(c=null==d?void 0:d.videoProjectId)&&void 0!==c?c:i,p="pay-code-".concat((0,o.Z)(new Date,"yyyy-MM-dd"),"-").concat(e,"-").concat(t,"-").concat(m,"-").concat(null!=u?u:"anon");if(!(null==d?void 0:d.forceRefresh)&&s.e$(p))return s.U2(p);let h=await l.E.fetchQuery({queryKey:[p],queryFn:()=>(0,a.H6)(e,i,null==d?void 0:d.videoProjectId,u),retry:3,retryDelay:500});if(!h){(0,r.Z)(Error("payCode fetch failed for product: ".concat(e)),{stage:"paycode_null",productId:e,designId:i,videoProjectId:null==d?void 0:d.videoProjectId});return}return s.t8(p,h),h}},69218:function(e,t,i){"use strict";i.d(t,{P:function(){return x}});var a=i(52322),n=i(2784),r=i(25237),s=i.n(r),o=i(52522),l=i(3741),d=i(83553),c=i(14084),u=i(32896),m=i(45539),p=i(3438);let h=s()(()=>i.e(5710).then(i.bind(i,55710)).then(e=>({default:e.PreEditSizeSelectorModal})),{loadableGenerated:{webpack:()=>[55710]},ssr:!1});function x(){let{designId:e}=(0,o.hl)(),{shouldShowBlocker:t,experimentVariant:i,posthogFlagResolved:r,assignsPreEditViaPosthog:s}=function(){var e;let{designId:t,isPaid:i,editMode:a}=(0,o.hl)(),r=(0,c.s)(e=>e.isLoading),s=(0,m.A)(m.T.PRE_EDIT_SIZE_SELECTOR),p=null===(e=l.featureFlags.posthogOverrides)||void 0===e?void 0:e.preEditSizeSelector,h=(0,n.useRef)(new URLSearchParams(window.location.search).has("id")).current,x=(0,n.useRef)(new URLSearchParams(window.location.search).has("templateId")).current,f=(0,n.useRef)(new URLSearchParams(window.location.search).has("job")&&new URLSearchParams(window.location.search).has("ratio")).current,g=(0,n.useMemo)(()=>"blocker"===p||"control"===p?p:"blocker"===s||!0===s?"blocker":"control",[p,s]),v=void 0===p,b=(0,n.useMemo)(()=>"blocker"===p||"control"===p||void 0!==s,[p,s]);return{shouldShowBlocker:(0,n.useMemo)(()=>!(h||x||f||i||a!==d.uz.Editable||"blocker"!==g||!b||r||t&&(0,u.U)(t)),[h,x,f,t,a,g,r,i,b]),experimentVariant:g,posthogFlagResolved:b,assignsPreEditViaPosthog:v}}(),[x,f]=(0,n.useState)(!1),g=(0,n.useRef)(!1),v=(0,n.useRef)(!1),b=(0,n.useRef)(!1),y=(0,n.useRef)(void 0);return(0,n.useEffect)(()=>{let t=y.current;y.current=e,v.current=!1,void 0!==t&&t!==e&&(g.current=!1)},[e]),(0,n.useEffect)(()=>{r&&s&&!g.current&&(g.current=!0,p.iA({designId:null!=e?e:"",experiment_variant:i}))},[s,e,i,r]),(0,n.useEffect)(()=>{t&&!b.current&&f(!0)},[t]),(0,n.useEffect)(()=>{x&&!v.current&&(v.current=!0,p.g({designId:null!=e?e:"",experiment_variant:i}))},[e,i,x]),(0,a.jsx)(h,{open:x,designId:null!=e?e:"",experimentVariant:i,onSkip:()=>{b.current=!0,f(!1)},onCompleted:()=>{b.current=!0,f(!1)}})}},92442:function(e,t,i){"use strict";i.d(t,{a:function(){return a}});let a=(0,i(43841).U)(e=>({selectedProduct:{category:void 0,gelatoUID:void 0},preview:{isLoading:!1},setSelectedProduct:(t,i)=>e({selectedProduct:{category:t,gelatoUID:i}})}))},11732:function(e,t,i){"use strict";i.d(t,{Zv:function(){return o},_6:function(){return l}});var a=i(40568);let n="wavevisual:captionDisplayPreferences";function r(e){return void 0===e.karaokeMode&&void 0===e.adaptiveFontSize}function s(){try{let e=window.localStorage.getItem(n);if(!e)return null;let t=JSON.parse(e),i={};return"boolean"==typeof(null==t?void 0:t.karaokeMode)&&(i.karaokeMode=t.karaokeMode),"boolean"==typeof(null==t?void 0:t.adaptiveFontSize)&&(i.adaptiveFontSize=t.adaptiveFontSize),r(i)?null:i}catch(e){return null}}function o(e){var t;let i={...null!==(t=s())&&void 0!==t?t:{},...e};if(!r(i))try{window.localStorage.setItem(n,JSON.stringify(i))}catch(e){}}function l(e){let t=s();if(!t)return e;let i={};if(void 0!==t.karaokeMode&&t.karaokeMode!==(0,a.isCaptionsKaraokeModeEnabled)(e)&&(i.karaokeMode=t.karaokeMode),void 0!==t.adaptiveFontSize){let n=t.adaptiveFontSize?"adaptive":"stable";n!==(0,a.captionsFontSizeMode)(e)&&(i.fontSizeMode=n)}return void 0===i.karaokeMode&&void 0===i.fontSizeMode?e:(0,a.updateCaptionsConfigOptions)(e,i)}},5987:function(e,t,i){"use strict";i.d(t,{Z2:function(){return a},rZ:function(){return n}});let a=12;function n(e){return e?80:0}},95768:function(e,t,i){"use strict";i.d(t,{Z:function(){return r}});var a=i(19458);let n={[a.AspectRatio["2/1"]]:"h-60",[a.AspectRatio["3/1"]]:"h-60",[a.AspectRatio["16/9"]]:"h-60",[a.AspectRatio["297/210"]]:"h-60",[a.AspectRatio["22/17"]]:"h-60",[a.AspectRatio["5/4"]]:"h-80",[a.AspectRatio["1/1"]]:"h-72",[a.AspectRatio["3/2"]]:"h-72",[a.AspectRatio["4/3"]]:"h-72",[a.AspectRatio["4/5"]]:"h-96",[a.AspectRatio["2/3"]]:"h-96",[a.AspectRatio["27/35"]]:"h-96",[a.AspectRatio["11/14"]]:"h-96",[a.AspectRatio["9/16"]]:"h-96",[a.AspectRatio["210/297"]]:"h-96",[a.AspectRatio["17/22"]]:"h-96",[a.AspectRatio["1/2"]]:"h-96"};function r(e){return n[e]}},32896:function(e,t,i){"use strict";i.d(t,{M:function(){return r},U:function(){return n}});let a="wv:preEditSizeBlocker:";function n(e){try{let t=window.localStorage.getItem("".concat(a).concat(e));if("skipped"===t||"completed"===t)return t;return null}catch(e){return null}}function r(e,t){try{window.localStorage.setItem("".concat(a).concat(e),t)}catch(e){}}},84309:function(e,t,i){"use strict";let a;i.d(t,{B:function(){return r}});let n=!1,r={setup:async function(e){let{vendorId:t,sandbox:i}=e;return new Promise((e,r)=>{if(n){e();return}if(!window.paddleEmitter){let e;window.paddleEmitter=(e=[],{on(t){e.push(t)}
1,emit(t){e.forEach(e=>e(t))},clear(){e=[]}})}(a=document.createElement("script")).src="https://cdn.paddle.com/paddle/paddle.js",a.async=!0,a.onload=()=>{(function(e){let{vendorId:t,sandbox:i}=e;if(!window.Paddle)throw Error("Paddle script not loaded");if(!window.paddleEmitter)throw Error("Paddle emitter not loaded");i&&window.Paddle.Environment.set("sandbox"),window.Paddle.Setup({vendor:t,eventCallback:window.paddleEmitter.emit}),n=!0})({vendorId:t,sandbox:i}),e()},a.onerror=r,document.body.appendChild(a)})},isPaddleReady:function(){return n},onEvent:function(e){var t;return null===(t=window.paddleEmitter)||void 0===t?void 0:t.on(e)},open:function(e){if(!window.Paddle)throw Error("Paddle script not loaded");window.Paddle.Checkout.open(e)},close:function(){var e;window.Paddle&&"function"==typeof(null===(e=window.Paddle.Checkout)||void 0===e?void 0:e.close)&&window.Paddle.Checkout.close()},getPaddle:function(){return window.Paddle},orderDetails:function(){for(var e=arguments.length,t=Array(e),i=0;i<e;i++)t[i]=arguments[i];if(!window.Paddle)throw Error("Paddle script not loaded");window.Paddle.Order.details(...t)}}},47182:function(e,t){"use strict";t.cz=t.QP=t.NP=t.VS=t.Eg=void 0,t.Eg="https://image-server-proxy.wavevisual.workers.dev/audio",t.VS=e=>"".concat(t.Eg,"/").concat(e,".json"),t.NP=[{id:"lofi-beats",name:"Lofi Beats",durationSec:57.96,publicURL:"".concat(t.Eg,"/lofi-beats.mp3")},{id:"cinematic",name:"Cinematic Swell",durationSec:118.02,publicURL:"".concat(t.Eg,"/cinematic.mp3")},{id:"emotional-piano",name:"Emotional Piano",durationSec:107.57,publicURL:"".concat(t.Eg,"/emotional-piano.mp3")},{id:"epic-trailer",name:"Epic Trailer",durationSec:48.07,publicURL:"".concat(t.Eg,"/epic-trailer.mp3")},{id:"folk-acoustic",name:"Folk Acoustic",durationSec:75.05,publicURL:"".concat(t.Eg,"/folk-acoustic.mp3")},{id:"upbeat-corporate",name:"Upbeat Corporate",durationSec:75.05,publicURL:"".concat(t.Eg,"/upbeat-corporate.mp3")},{id:"jazz",name:"Jazz Lounge",durationSec:75.05,publicURL:"".concat(t.Eg,"/jazz.mp3")}],t.QP=e=>t.NP.find(t=>t.id===e),t.cz=e=>"stock_".concat(e)},51510:function(e,t){"use strict";var i,a,n,r;t.V0=void 0,(n=i||(i={})).digital="digital",n.canvas="canvas",n.matte_poster="matte_poster",n.glossy_poster="glossy_poster",n.wood_framed_poster_print="wood_framed_poster_print",(r=a||(t.V0=a={})).canvas="canvas",r.unframed_poster="unframed_poster",r.wood_framed_poster="wood_framed_poster"},18064:function(e,t){"use strict";var i,a,n,r;t.Pm=t.f2=void 0,(n=i||(t.f2=i={})).all="all",n.paid="paid",n.draft="draft",n.trash="trash",(r=a||(t.Pm=a={})).FULL="FULL",r.BASIC="BASIC",r.BARE_MIN="BARE_MIN"},57632:function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.syntheticCaptionWords=l,t.splitSegmentsForCaptions=function(e){return e.flatMap(c)};let a=i(95669),n=[".","!","?","â¦"],r=[",",";",":"];function s(e){return e.map(e=>e.text).join(" ")}function o(e,t){if(!t)return 100;let i=e.text.replace(/["')\]}>]+$/g,"");return n.some(e=>i.endsWith(e))?90:t.start-e.end>=a.CAPTION_PAUSE_GAP_S?80:r.some(e=>i.endsWith(e))?70:0}function l(e,t,i){let a=e.trim().split(/\s+/).filter(e=>e.length>0);if(!a.length)return[];let n=Math.max(0,i-t),r=a.reduce((e,t)=>e+t.length,0)||1,s=t;return a.map((e,t)=>{let o=e.length/r*n,l=t===a.length-1?i:s+o,d={start:s,end:l,text:e};return s=l,d})}function d(e){let t=e.start,i=e.end<t?t:e.end;return{start:t,end:i,text:(e.text||"").trim()}}function c(e){let t=(e.text||"").trim();if(!t)return[];let i=(e.words||[]).map(d).filter(e=>e.text);return(i.length||(i=l(t,e.start,e.end)),i.length)?function(e,t){let i=e.length-1,a=[];return e.forEach((n,r)=>{let o=0===r?t.start:n[0].start,l=r===i?t.end:n[n.length-1].end;if(r<i){let t=e[r+1][0].start;t-l>=0&&t-l<.08&&(l=t)}r>0&&o<a[a.length-1].end&&(o=a[a.length-1].end),l<o&&(l=o),a.push({start:o,end:l,text:s(n),words:n})}),a}(function(e){let t=e.length,i=0,n=[];for(;i<t;){let r=i+1;for(;r<t&&function(e){if(!e.length)return!0;let t=e[e.length-1].end-e[0].start;return s(e).length<=a.CAPTION_MAX_CUE_CHARS&&e.length<=a.CAPTION_MAX_CUE_WORDS&&t<=a.CAPTION_MAX_CUE_DURATION_S}(e.slice(i,r+1));)r+=1;if(r===t){n.push(e.slice(i,t));break}let l=r,d=-1;for(let n=i+1;n<=r;n+=1){let r=o(e[n-1],n<t?e[n]:void 0);if(r<=0)continue;let s=n-i;r<90&&s<a.CAPTION_MIN_WORDS_FOR_SOFT_BREAK||!(r>=d)||(d=r,l=n)}n.push(e.slice(i,l)),i=l}return function(e){if(e.length<2)return e;let t=[e[0]];
1return e.slice(1).forEach(e=>{e.length>1&&o(e[0],e[1])>=70?(t.push(e.slice(0,1)),t.push(e.slice(1))):t.push(e)}),t}(n)}(i),e):[]}},13366:function(e,t,i){"use strict";t.ff=function(e){return{...e,tracks:e.tracks.map(e=>({...e,cues:e.cues.flatMap(r)}))}};let a=i(57632);function n(e){var t;return(null!==(t=e.match(/\S+/g))&&void 0!==t?t:[]).join(" ")}function r(e){if(!e.text.trim())return[e];let t=(0,a.splitSegmentsForCaptions)([{start:e.startMs/1e3,end:e.endMs/1e3,text:e.text,words:function(e){var t;if(null===(t=e.wordTimings)||void 0===t?void 0:t.length){let t=e.wordTimings.map(t=>({start:t.startMs/1e3,end:t.endMs/1e3,text:e.text.slice(t.charStart,t.charEnd).trim()})).filter(e=>e.text);if(n(t.map(e=>e.text).join(" "))===n(e.text))return t}return(0,a.syntheticCaptionWords)(e.text,e.startMs/1e3,e.endMs/1e3)}(e)}]);return t.length?t.map(t=>{let i=t.text.trim(),a=function(e,t){let i=[],a=0;return t.forEach(t=>{let n=t.text.trim();if(!n)return;let r=e.indexOf(n,a);if(-1===r&&(r=e.indexOf(n)),-1===r)return;let s=r+n.length;i.push({startMs:Math.round(1e3*t.start),endMs:Math.round(1e3*t.end),charStart:r,charEnd:s}),a=s}),i}(i,t.words);return{startMs:Math.round(1e3*t.start),endMs:Math.round(1e3*t.end),text:i,fadeInMs:e.fadeInMs,fadeOutMs:e.fadeOutMs,...a.length?{wordTimings:a}:{}}}):[e]}},28407:function(e,t,i){"use strict";t._l=function(e){return e?e.type===a.CustomFileType.spotify?{kind:"unsupported",source:"spotify"}:e.type===a.CustomFileType.youtube?{kind:"unsupported",source:"youtube"}:e.type===a.CustomFileType.bucket&&e.pathInBucket?{kind:"bucket",pathInBucket:e.pathInBucket}:e.publicURL?{kind:"url",audioUrl:e.publicURL}:{kind:"missing"}:{kind:"missing"}};let a=i(51574)},92576:function(e){e.exports={"single-menu":"WaveformEditor_single-menu__HDYHp","canvas-wrapper":"WaveformEditor_canvas-wrapper__6G6_H"}},33643:function(e){e.exports={seekRow:"AudioPlayerBar_seekRow__8BMWd",timeLabel:"AudioPlayerBar_timeLabel__VjQub",timeLabelDuration:"AudioPlayerBar_timeLabelDuration__4vlCM",timeLabelCurrent:"AudioPlayerBar_timeLabelCurrent__fnQfm",seekInput:"AudioPlayerBar_seekInput__NSTQg",seekInputDisabled:"AudioPlayerBar_seekInputDisabled__mg1U7",seekInputPlaying:"AudioPlayerBar_seekInputPlaying__Tzz2M"}},24785:function(e){e.exports={editorWrapper:"EditorPage_editorWrapper__KtHAC"}}}]);
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.