PageSourceSearch

https://app.adstra.ai/_next/static/chunks/pages/apps/ai-video/[[...step]]-10e404d7e113db0e.js

js adstra.ai collected 2026-10-05 11:49:47 UTC 42,818 bytes, 1 lines download raw bytes

1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[57622],{44760:function(e,t,s){(window.__NEXT_P=window.__NEXT_P||[]).push(["/apps/ai-video/[[...step]]",function(){return s(15395)}])},83508:function(e,t,s){"use strict";var a=s(28598),r=s(82684),l=s(32e3),i=s.n(l);s(92884);const n=r.memo((e=>{const{entry:t,title:s,filterItems:l,selectedItem:n,selectItem:o}=e,[c,d]=(0,r.useState)(!1),[u,m]=(0,r.useState)({min:0,max:1e4}),[x,p]=(0,r.useState)({min:0,max:1e4}),[f,h]=(0,r.useState)(!1);return(0,r.useEffect)((()=>{if("duration"===t&&"object"===typeof n&&l.length>0){const e=Math.min(...l.map((e=>Number(e)))),t=Math.max(...l.map((e=>Number(e))));m({min:e,max:t});0===n.max&&0===n.min?(o({min:e,max:t}),p({min:e,max:t})):p({min:n.min,max:n.max}),d(!0)}}),[JSON.stringify(l)]),(0,a.jsxs)("div",{className:"sector w-full mb-4",children:[(0,a.jsx)("div",{className:"title w-full font-bold border-b mb-2 text-black",children:s}),c&&"object"===typeof n?(0,a.jsxs)("div",{className:"",children:[(0,a.jsx)(i(),{range:{min:u.min,max:u.max},start:[x.min,x.max],step:1,connect:!0,onSlide:(e,s,a,r,l)=>{"duration"===t&&o({min:a[0],max:a[1]})},className:"bg-white text-black"}),(0,a.jsxs)("div",{className:"flex justify-between mt-3",children:[(0,a.jsx)("div",{children:"object"===typeof n?Math.round(n.min):""}),(0,a.jsx)("div",{children:"object"===typeof n?Math.round(n.max):""})]})]}):(0,a.jsx)(a.Fragment,{children:l.map((e=>(0,a.jsxs)("ul",{className:"flex gap-2 items-center text-black",children:[(0,a.jsx)("input",{type:"checkbox",checked:n===e,onChange:()=>o(e===n?"":e)}),(0,a.jsx)("p",{children:e})]},e)))})]})}));t.Z=n},9247:function(e,t,s){"use strict";var a=s(28598),r=s(82684),l=s(90211);t.Z=e=>{const{preview:t,templateName:s,afterLoadCallback:i,posterTime:n}=e,o=null!==n&&void 0!==n?n:0,[c,d]=(0,r.useState)(!1),[u,m]=(0,r.useState)(!1),[x,p]=(0,r.useState)(o),f=(0,r.useRef)(null),h=(0,r.useRef)(null);(0,r.useEffect)((()=>{const e=new ResizeObserver((e=>{for(let t of e)t.contentRect.width&&t.contentRect.height&&i&&i()}));return f.current&&e.observe(f.current),()=>{f.current&&e.unobserve(f.current)}}),[]);(0,r.useEffect)((()=>{h.current&&0===x&&!u&&(d(!0),h.current.currentTime=0,h.current.play(),m(!0))}),[x]);return(0,a.jsxs)("div",{className:"video-card ".concat(""," flex flex-col rounded border shadow overflow-hidden"),ref:f,children:[t&&(0,a.jsx)(l.Z,{videoSrc:t,videoClassName:"bg-black bg-opacity-50 max-h-[600px]",onHoverStart:()=>{p(0)},onHoverEnd:()=>{h.current&&(d(!1),h.current.paused||h.current.pause(),m(!1),p(o))},playbackStartDelay:100,videoRef:h,playbackRangeStart:x,controls:c,restartOnPaused:!0,preload:"auto"}),(0,a.jsx)("div",{className:"p-2 font-bold text-gray-800",children:s})]})}},33139:function(e,t,s){"use strict";s.d(t,{Z:function(){return r}});var a=s(28598);s(82684);function r(){return(0,a.jsxs)("svg",{"aria-hidden":"true",className:"h-12 w-12 animate-spin fill-blue-600 text-gray-200 dark:text-gray-600",viewBox:"0 0 100 101",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,a.jsx)("path",{d:"M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z",fill:"currentColor"}),(0,a.jsx)("path",{d:"M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z",fill:"currentFill"})]})}},15395:function(e,t,s){"use strict";s.r(t),s.d(t,{__N_SSP:function(){return ne},default:function(){return oe}});var a=s(28598),r=s(1887),l=s.n(r),i=s(68015),n=s(38178),o=s(82684),c=s(34376),d=s(83508),u=s(9247),m=s(68939);var x=e=>{const{keywords:t,searchKey:s,setSearchKey:r}=e,l=t.map(((e,t)=>({id:t,name:e})));return(0,a.jsx)("div",{className:"search-field",children:(0,a.jsx)(m.ReactSearchAutocomplete,{items:l,fuseOptions:{keys:["name"]},onSearch:(e,t)=>{""===e&&r("")},onHover:e=>{},onSelect:e=>{r(e.name)}
1,onFocus:()=>{},autoFocus:!0,inputSearchString:s,formatResult:e=>(0,a.jsx)(a.Fragment,{children:(0,a.jsx)("p",{className:"text-sm font-bold",children:e.name})}),styling:{borderRadius:"0.25rem"}})})};const p=(0,o.createContext)({});var f=s(85754),h=s(83777),g=s(23708),v=s(81385),j=s(1766);var b=e=>{const{t:t}=(0,v.$G)(),r=(0,c.useRouter)(),{showTemplateDetailSector:l,showTemplateSelector:i,selectTemplate:n,selectedAspectRatio:m,setAspectRatio:j,selectedDurationRange:b,setDurationRange:N,selectedNumOfImages:y,setNumOfImages:w,selectedNumOfTexts:S,setNumOfTexts:C,searchKey:k,setSearchKey:E,setVideoJob:T}=(0,o.useContext)(p),{originalTemplates:I,isLoading:R,setAllImages:O}=e,[L,M]=(0,o.useState)(null),[A,J]=(0,o.useState)(!1),[D,G]=(0,o.useState)(!1),Z=(0,o.useRef)(null),{isWhitelabel:z}=(0,g.y)();(0,o.useEffect)((()=>{T({templateName:"",templateDirectory:"",aspectRatio:"",duration:0,textValues:[],colors:[],images:[],music:"",musicTempo:"",musicEmotion:"",musicGenre:"",musicOffset:0}),e.setGoNextStep(0),localStorage.setItem("trackUrl",JSON.stringify("")),O([])}),[]);const P=(0,o.useMemo)((()=>I?Array.from(new Set(I.map((e=>e.aspectRatio)))).sort():[]),[JSON.stringify(I)]),V=(0,o.useMemo)((()=>[...new Set(null===I||void 0===I?void 0:I.map((e=>e.duration)))].sort(((e,t)=>e-t))),[JSON.stringify(I)]),F=(0,o.useMemo)((()=>[...new Set(null===I||void 0===I?void 0:I.map((e=>e.images.length)))].sort(((e,t)=>e-t))),[JSON.stringify(I)]),U=(0,o.useMemo)((()=>[...new Set(null===I||void 0===I?void 0:I.map((e=>e.text.length)))].sort(((e,t)=>e-t))),[JSON.stringify(I)]),_=["grunge cinematic"],K=(0,o.useMemo)((()=>({aspectRatio:{title:"Aspect Ratio",items:P},duration:{title:"Duration",items:V},images:{title:"Number of images",items:F},texts:{title:"Number of texts",items:U}})),[JSON.stringify(P),JSON.stringify(V),JSON.stringify(F),JSON.stringify(U)]),$=(0,o.useMemo)((()=>(null===I||void 0===I?void 0:I.filter((e=>{const t=e.templateName.toLowerCase();if(_.includes(t)&&z)return!1;const s=!m||e.aspectRatio===m,a=e.duration>=b.min&&e.duration<=b.max,r=!y||e.images.length===y,l=!S||e.text.length===S;return s&&a&&r&&l})))||[]),[JSON.stringify(I),m,JSON.stringify(b),y,S,z]),B=(0,o.useMemo)((()=>$.filter((e=>e.templateName.includes(k)||e.keywords.some((e=>e.toLowerCase().includes(k.toLowerCase())))))),[JSON.stringify($),k]),Q=(0,o.useMemo)((()=>Array.from(I.reduce(((e,t)=>(t.keywords.forEach((t=>e.add(t))),e)),new Set))||[]),[JSON.stringify(I)]);return(0,o.useEffect)((()=>{(async()=>{const e=(await Promise.all([s.e(78079),s.e(93827)]).then(s.bind(s,93827))).default;M(e)})()}),[]),(0,o.useEffect)((()=>{var e;A&&(J(!1),Z.current&&(null===(e=Z.current.grid)||void 0===e||e.refreshItems().layout()))}),[A]),(0,a.jsx)("div",{className:"video-template-selection",children:(0,a.jsxs)("div",{className:" flex flex-col container w-full gap-5 md:flex-row md:gap-12",children:[(0,a.jsx)("div",{className:"md:hidden flex justify-start p-4",children:(0,a.jsx)("button",{onClick:()=>{G(!D)},children:D?(0,a.jsx)(f.aHS,{size:24}):(0,a.jsx)(f.Fm7,{size:24})})}),D&&(0,a.jsxs)("nav",{className:"w-48 shrink-0 transition-transform duration-300 translate-x-0 md:hidden",children:[(0,a.jsx)("div",{className:"pb-3 mb-5 border-b z-50",children:(0,a.jsx)(x,{keywords:Q,searchKey:k,setSearchKey:E})}),Object.entries(K).map((e=>{let[t,s]=e;return(0,a.jsx)(d.Z,{entry:t,title:s.title,filterItems:s.items,selectedItem:"aspectRatio"===t?m:"duration"===t?b:"images"===t?y:"texts"===t?S:0,selectItem:"aspectRatio"===t?j:"duration"===t?N:"images"===t?w:"texts"===t?C:()=>{}},t)}))]}),(0,a.jsxs)("nav",{className:"hidden w-48 shrink-0 transition-transform duration-300 translate-x-0 md:block",children:[(0,a.jsx)("div",{className:"pb-3 mb-5 border-b",children:(0,a.jsx)(x,{keywords:Q,searchKey:k,setSearchKey:E})}),Object.entries(K).map((e=>{let[t,s]=e;return(0,a.jsx)(d.Z,{entry:t,title:s.title,filterItems:s.items,selectedItem:"aspectRatio"===t?m:"duration"===t?b:"images"===t?y:"texts"===t?S:0,selectItem:"aspectRatio"===t?j:"duration"===t?N:"images"===t?w:"texts"===t?C:()=>{}},t)}))]}),(0,a.jsx)("div",{className:"main-area grow",children:R?(0,a.jsx)("div",{children:t("Loading...")}):(0,a.jsxs)(a.Fragment,{children:[0===(null===B||void 0===B?void 0:B.length)&&(0,a.jsx)("div",{className:"w-full h-full flex justify-center items-center text-gray-300 font-bold",children:t("No template found with your filter. Please use another filter items.")}),L&&(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"flex justify-center items-center gap-x-3",children:[(0,a.jsx)("p",{className:"text-2xl",children:t("Select a Template to Begin")}),(0,a.jsx)("div",{children:(0,a.jsx)(h.Z,{})})]}),(0,a.jsx)("div",{className:"border-t my-3"}),(0,a.jsx)(L,{data:null===B||void 0===B?void 0:B.map(((e,t)=>({id:"id-".concat(e.templateName).concat(t),template:e}))),renderItem:(e,t)=>
1{let{template:s}=e;return(0,a.jsx)("div",{onClick:()=>{i(!1),l(!0),r.push("/apps/ai-video/detail-selector/".concat(s.id))},className:"w-72 m-2",children:(0,a.jsx)(u.Z,{posterTime:s.posterTime,preview:s.preview,templateName:s.templateName,afterLoadCallback:()=>{J(!0)}})},"card-container-".concat(s.templateName).concat(t))},dragEnabled:!1,ref:Z})]})]})})]})})};(0,j.z)();function N(e){const{t:t}=(0,v.$G)(),{setVideoJob:s,videoJob:r,Index:l,setGoNextStep:i,setAllImages:n,allImages:o}=e;return(0,a.jsx)("div",{className:"flex flex-col gap-2 w-full",children:(0,a.jsxs)("label",{className:"flex justify-center w-full min-h-[15rem] max-h-[20rem] px-4 transition bg-white border-2 border-gray-300 border-dashed rounded-md appearance-none cursor-pointer hover:border-gray-400 focus:outline-none",onDragOver:e=>{e.preventDefault()},onDrop:e=>{e.preventDefault();const t=e.dataTransfer.files[0];if(t){const e=URL.createObjectURL(t),a=r.images||[];let c;c=-1!==l?a.map(((t,s)=>l===s?e:t)):[...a,e],n([...o,t]),s({...r,images:c}),i((e=>e+1))}},children:[(0,a.jsxs)("span",{className:"flex flex-col gap-2 justify-center space-x-2",children:[(0,a.jsxs)("span",{className:"flex gap-1 font-medium text-gray-600",children:[(0,a.jsx)(f.Qvc,{className:"w-5 h-5"}),t("Drop Image to Attach")]}),(0,a.jsxs)("span",{className:"font-medium text-gray-600",children:[t("or")," ",(0,a.jsx)("span",{className:"text-blue-600 underline",children:t("browse")})]})]}),(0,a.jsx)("input",{type:"file",name:"file_upload",accept:"image/*",className:"hidden",onChange:e=>{const t=e.target.files&&e.target.files[0];if(t){const e=URL.createObjectURL(t),a=r.images||[];let c;c=-1!==l?a.map(((t,s)=>l===s?e:t)):[...a,e],n([...o,t]),s({...r,images:c}),i((e=>e+1))}}})]})})}(0,j.z)();var y=s(71393),w=s(13323),S=s(48704),C=s(42957);const k=e=>{const t=e.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);if(t){return[parseInt(t[1],10),parseInt(t[2],10),parseInt(t[3],10)]}throw new Error("Invalid RGB string format")},E=e=>{if(e){const t=null===e||void 0===e?void 0:e.replace(/[^\d,]/g,"").split(",");return(.2126*parseInt(t[0],10)+.7152*parseInt(t[1],10)+.0722*parseInt(t[2],10))/255>.5}};(0,j.z)();var T=e=>{const{t:t}=(0,v.$G)(),{selectedTemplate:s,videoJob:r,selectTemplate:l,setVideoJob:i,setErrors:n,errors:c}=(0,o.useContext)(p),[d,m]=(0,o.useState)(0),[x,h]=(0,o.useState)(),[g,j]=(0,o.useState)([]),[b]=S.r.useAddColorsMutation(),[T]=S.r.useLazyGetColorsQuery(),[I]=S.r.useDeleteColorsMutation(),[R,O]=(0,o.useState)([]),[L,M]=(0,o.useState)(null),[A,J]=(0,o.useState)([]),[D,G]=(0,o.useState)(0);(0,o.useEffect)((()=>{let e=[];(async()=>{const t=await T({});"data"in t&&(t.data.favoriteColors.map((t=>{const s="rgb(".concat(null===(a=t)||void 0===a?void 0:a.join(", "),")");var a;e.push(s)})),J(e))})()}),[D]);const{templateName:Z,preview:z,text:P,aspectRatio:V,colors:F}=s||{},{textValues:U=[],images:_=[]}=r;(0,o.useEffect)((()=>{if(U.length>g.length){const e=[...g];for(;e.length<U.length;)e.push(x);F&&F.length>0&&(O((e=>{const t=[...e];return F.forEach(((e,s)=>{t[s]=e})),t})),j((e=>{const t=[...e];return F.forEach(((e,s)=>{const a="rgb(".concat(e.join(", "),")");t[s]=a})),t})))}}),[U,g,x,F]);(0,o.useEffect)((()=>{R.length>0&&(l({...s,colors:R}),i({...r,colors:R}))}),[R]);return(0,a.jsxs)("div",{className:"video-detail-sector",children:[s&&(0,a.jsx)("div",{className:"flex justify-center items-center w-full pb-5",children:(0,a.jsx)("div",{className:"box ".concat("9:16"===V?"w-60 m-auto":"w-[83%]"),children:(0,a.jsx)(u.Z,{preview:z,templateName:Z})})}),(0,a.jsx)("div",{className:"border-t my-3"}),(0,a.jsx)("div",{className:"flex justify-center text-center p-5 text-2xl",children:t("Add Texts")}),(0,a.jsxs)("div",{className:"flex flex-col",children:[(0,a.jsx)("div",{className:"flex flex-wrap justify-center gap-3 my-5",children:null===P||void 0===P?void 0:P.map(((e,t)=>(0,a.jsxs)("div",{className:"w-52",children:[(0,a.jsxs)("div",{className:"flex gap-2 items-center p-1",children:[(0,a.jsx)("label",{className:"m-0 text-sm font-bold text-gray-700",children:e.replace(/DEAL\.AI/g,"")}),L===t&&(0,a.jsx)(f._TT,{fill:"#4361ee"})]}),(0,a.jsx)("input",{type:"text",value:U[t]||"",onChange:e=>((e,t)=>{if(e.target.value.length>120)n((e=>{const s=[...e];return s[t]="Text cannot exceed 120 characters",s}));else{const s=[...U];s[t]=e.target.value,i({...r,textValues:s}),n((e=>e.filter(((e,s)=>s!==t))))}})(e,t),onFocus:()=>(e=>{M(e),m(e)})(t),className:"rounded border focus:outline-none px-3 py-1.5 pr-7",style:{color:g[t],backgroundColor:E(g[t])?"rgb(112,112,112)":"white",transition:"background-color 0.5s ease-in-out"}}),c[t]&&(0,a.jsx)("p",{className:"text-red-500 text-xs mt-1",children:c[t]})]},"text-".concat(t))))}),(0,a.jsxs)("div",{className:"flex flex-col justify-center items-center gap-2 mb-2",children:[(0,a.jsxs)("div",{className:"flex flex-col items-center justify-center gap-2 w-1/2",children:[A.length>0&&(0,a.jsx)("div",{className:"flex flex-col items-center w-[50%]",children:(0,a.jsx)("div",{className:"flex flex-wrap",children:A.length>0&&A.map(((e,t)=>(0,a.jsx)("div",{className:"relative w-8 h-8 m-1 rounded-full cursor-pointer",style:{backgroundColor:e},onClick:()=>{h(e),(e=>{h(e),j((t=>{const s=[...t];return s[d]=e,s})),O((t=>{const s=[...t];return s[d]=k(e),s}))})(e)},children:(0,a.jsx)(y.FU5,{className:"absolute top-[-3px] right-[-5px] w-4 h-4 text-white bg-primary rounded-full",onClick:t=>{t.stopPropagation(),(async e=>{if(e){const t=k(e);"data"in await I({color:t})&&(G((e=>e+1)),(0,C.NK)({title:"Color deleted"}))}})(e)},fill:"white"})},t)))})}),(0,a.jsx)(w.xS,{color:g[d],onChange:e=>{const{r:t,g:s,b:a}=e.rgb,r=[t,s,a],l="rgb(".concat(t,", ").concat(s,", ").concat(a,")");h(l),O((e=>{const t=[...e];return t[d]=r,t})),j((e=>{const t=[...e];return t[d]=l,t}))},width:"250px",disableAlpha:!0}),(0,a.jsx)("div",{})]}),(0,a.jsxs)("div",{className:"flex gap-2 mb-2",children:[(0,a.jsx)("button",{onClick:async()=>
1{if(!A.includes(x)){const e=k(x),t=await b({favoriteColors:[e]});"data"in t&&(G((e=>e+1)),(0,C.NK)({title:t.data.message}))}},className:"mt-2 rounded btn btn-primary py-1 px-3 text-sm font-semibold text-white",disabled:!x,children:t("Add to Favorites")}),(0,a.jsx)("button",{onClick:()=>{j(g.map((()=>x))),O(g.map((()=>k(x))))},className:"mt-2 rounded btn btn-primary py-1 px-3 text-sm font-semibold text-white",disabled:!x,children:t("Apply Color to All Texts")})]})]})]}),(0,a.jsx)("div",{className:"border-t pt-5",children:(0,a.jsxs)("div",{className:"border rounded-md p-5 pt-0 shadow-lg",children:[(0,a.jsx)("p",{className:"text-center p-5 text-2xl",children:t("Add Images")}),(0,a.jsx)("div",{className:"selected-image-group flex flex-wrap justify-center gap-3",children:_.map(((t,l)=>(0,a.jsx)("div",{className:"relative flex flex-col items-center justify-center w-72",children:t.startsWith("blob")?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("button",{className:"absolute top-0 right-0 m-2 bg-gray-200 rounded-full p-1",onClick:()=>(t=>{const a=r.images.findIndex((e=>e===t));-1!==a&&e.setAllImages((e=>e.filter(((e,t)=>t!==a)))),i({...r,images:r.images.map(((e,a)=>e===t?s.images[a]:e))}),e.setGoNextStep((e=>e-1)),d>0&&m(d-1)})(t),children:(0,a.jsx)(y.FU5,{className:"w-4 h-4"})}),(0,a.jsx)("div",{className:"border rounded-lg",children:(0,a.jsx)("img",{src:t,className:"object-cover object-center max-h-[15rem]"})})]}):(0,a.jsxs)("div",{className:"flex items-center gap-2 flex-col w-full",children:[(0,a.jsx)("p",{className:"text-lg",children:_[l]}),(0,a.jsx)(N,{goNextStep:e.goNextStep,Index:l,setVideoJob:i,videoJob:r,setGoNextStep:e.setGoNextStep,allImages:e.allImages,setAllImages:e.setAllImages})]})},"image-".concat(l))))})]})})]})},I=s(9616),R=s(29736),O=s(23562),L=s(33139),M=s(57917);var A=e=>{const{selectedTemplate:t,selectTemplate:s,videoJob:r,setVideoJob:l}=(0,o.useContext)(p),i=(0,o.useRef)(null),n=(0,o.useRef)(null),{musicOffset:c=0,music:d}=r||{},[u,m]=(0,o.useState)(!1),[x,f]=(0,o.useState)(),[h,g]=(0,o.useState)(),[v,j]=(0,o.useState)(0),b=(0,o.useRef)(v);(0,o.useEffect)((()=>{b.current=c}),[c]),(0,o.useEffect)((()=>{const e=e=>{if(!x||!h)return;const s=h.getDuration();let a=s*e.offsetX/n.current.clientWidth;const r=(null===t||void 0===t?void 0:t.duration)||0;a<0?a=0:a+r>s&&(a=s-r),b.current=a;const i=a+r;x.clearRegions(),x.addRegion({start:a,end:i,resize:!1,color:"rgba(3, 134, 224, 0.5)",drag:!0}),l((e=>({...e,musicOffset:a})))};return n.current&&n.current.addEventListener("click",e),()=>{n.current&&n.current.removeEventListener("click",e)}}),[x,h,t]),(0,o.useEffect)((()=>{x&&x.on("region-updated",(e=>{const t=e.start;h.seekTo(t/h.getDuration())}))}),[x,h]),(0,o.useEffect)((()=>{try{const s=R.Z.create({container:n.current,waveColor:"#4361EE",progressColor:"#002c77"}),a=s.registerPlugin(M.Z.create());return f(a),g(s),s.load(d),s.on("ready",(()=>{e.setIsLoading(!1),a.addRegion({start:b.current,end:b.current+((null===t||void 0===t?void 0:t.duration)||0),resize:!1,color:"rgba(3, 134, 224, 0.5)",drag:!0}),a.on("region-updated",(e=>{const t=e.start;l((e=>({...e,musicOffset:t})))}))})),e.isChooseTrack||s.pause(),i.current=s,()=>{s.destroy()}}catch(s){console.error("Error in WaveSurfer:",s),e.setIsLoading(!1)}}),[d,t]),(0,o.useEffect)((()=>{i.current&&!e.isChooseTrack&&(m(!1),i.current.pause())}),[e.isChooseTrack]),(0,o.useEffect)((()=>{j(c)}),[c]),(0,o.useEffect)((()=>()=>{i.current&&i.current.destroy()}),[]);return(0,a.jsx)("div",{className:"flex items-center w-full gap-2",children:(0,a.jsxs)("div",{className:"music-offset-selector p-3 m-3 w-full border rounded-lg",children:[(0,a.jsx)("div",{className:"wavesurfer-container ".concat(e.isLoading?"hidden":"block"),ref:n}),e.isLoading?(0,a.jsx)("div",{className:"mt-3 flex justify-center items-center",children:(0,a.jsx)(L.Z,{})}):(0,a.jsx)("div",{className:"mt-3",children:(0,a.jsx)("div",{className:"flex flex-col items-center gap-4",children:(0,a.jsx)("div",{className:"flex justify-center items-center gap-3",children:(0,a.jsx)("button",{onClick:()=>{if(!i.current)return;const e=i.current;u?e.pause():(e.seekTo(b.current/e.getDuration()),e.play(),e.on("audioprocess",(s=>{s>=b.current+((null===t||void 0===t?void 0:t.duration)||0)&&(e.pause(),e.seekTo(b.current/e.getDuration()),m(!1))}))),m(!u)},children:u?(0,a.jsx)(O.muf,{className:"w-8 h-8",fill:"#002c77"}):(0,a.jsx)(O.KP$,{className:"w-8 h-8",fill:"#4361EE"})})})})})]})})};(0,j.z)();function J(e){let{setIsUploadModal:t,activeTab:s,setIsLoading:r}=e;const{t:l}=(0,v.$G)();return(0,a.jsx)("div",{className:"w-2/3 bg-[#f4f4f4] rounded-lg mb-6",children:(0,a.jsx)("div",{className:"relative right-0",children:(0,a.jsxs)("ul",{className:"relative flex flex-wrap p-1 list-none rounded-xl bg-blue-gray-50/60","data-tabs":"tabs",role:"list",children:[(0,a.jsx)("li",{className:"z-30 flex-auto mr-6 text-center",children:(0,a.jsx)("a",{className:"".concat("library"===s?"bg-primary text-white":"text-slate-700"," z-30 flex items-center justify-center w-full px-0 py-1 mb-0 transition-all ease-in-out rounded-lg cursor-pointer"),"data-tab-target":"",role:"tab","aria-selected":"library"===s,"aria-controls":"app",onClick:()=>{t(!1),r(!0)},children:(0,a.jsx)("span",{className:"library"===s?"bg-primary text-white ml-1":"text-slate-700 ml-1",children:l("Music library")})})}),(0,a.jsx)("li",{className:"z-30 flex-auto text-center",children:(0,a.jsx)("a",{className:"".concat("upload"===s?"bg-primary text-white":"text-slate-700"," z-30 flex items-center justify-center w-full px-0 py-1 mb-0 transition-all ease-in-out rounded-lg cursor-pointer"),"data-tab-target":"",role:"tab","aria-selected":"upload"===s,"aria-controls":"message",onClick:()=>{t(!0),r(!0)},children:(0,a.jsx)("span",{className:"upload"===s?"text-white ml-1":"text-slate-700 ml-1",children:l("Upload")})})})]})})})}(0,j.z)();var D=e=>{const{t:t}=(0,v.$G)(),{selectedTemplate:s,selectTemplate:r,videoJob:l,setVideoJob:i}=(0,o.useContext)(p),n=((0,I.useDispatch)(),(0,o.useRef)([])),[c,d]=(0,o.useState)(""),[u,m]=(0,o.useState)(""),[x,h]=(0,o.useState)(""),[g,j]=(0,o.useState)(""),[b,N]=(0,o.useState)(""),[y,w]=(0,o.useState)(!1),[C,k]=(0,o.useState)(!1),[E,T]=(0,o.useState)(!1),[R,O]=(0,o.useState)(!1),[L,M]=(0,o.useState)(!1),[D,G]=(0,o.useState)(!0),{data:Z,isLoading:z}=S.r.useGetMusicLibraryQuery(null);(0,o.useEffect)((()=>{D&&n.current.forEach(((e,t)=>{e&&e.pause()}))}),[D]),(0,o.useEffect)((()=>{const e=localStorage.getItem("trackUrl");if(e){const t=JSON.parse(e);N(t),k(!0)}}),[]);const P=null===Z||void 0===Z?void 0:Z.filter((e=>{const t=!c||e.genre===c,s=!u||e.tempo===u,a=!x||e.emotion===x;!g||e.instruments.includes(g);return t&&s&&a})),V=[...new Set(null===Z||void 0===Z?void 0:Z.map((e=>e.genre)))],F=[...new Set(null===Z||void 0===Z?void 0:Z.map((e=>e.tempo)))],U=[...new Set(null===Z||void 0===Z?void 0:Z.map((e=>e.emotion)))],{music:_}=(new Set(null===Z||void 0===Z?void 0:Z.flatMap((e=>e.instruments))),l||{});(0,o.useEffect)((()=>{""!==(null===l||void 0===l?void 0:l.music)&&T(!0)}),[l]);return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:"flex flex-col md:flex-row items-center pt-2 w-full justify-center mt-5",children:(0,a.jsx)("div",{className:"flex flex-col justify-center items-center gap-6"})}
1),!R&&(0,a.jsxs)("div",{className:"flex flex-col items-center p-4",children:[(0,a.jsx)(J,{setIsUploadModal:O,activeTab:"library",setIsLoading:k}),(0,a.jsxs)("div",{className:"flex flex-wrap gap-6 mb-4",children:[(0,a.jsxs)("select",{value:c,onChange:e=>d(e.target.value),className:"px-2 py-1 rounded border border-gray-800 text-gray-800",children:[(0,a.jsx)("option",{value:"",children:t("All Genres")}),null===V||void 0===V?void 0:V.map((e=>(0,a.jsx)("option",{value:e,children:e},e)))]}),(0,a.jsxs)("select",{value:u,onChange:e=>m(e.target.value),className:"px-2 py-1 rounded border border-gray-800 text-gray-800",children:[(0,a.jsx)("option",{value:"",children:t("All Tempos")}),null===F||void 0===F?void 0:F.map((e=>(0,a.jsx)("option",{value:e,children:e},e)))]}),(0,a.jsxs)("select",{value:x,onChange:e=>h(e.target.value),className:"px-2 py-1 rounded border border-gray-800 text-gray-800",children:[(0,a.jsx)("option",{value:"",children:t("All Emotions")}),null===U||void 0===U?void 0:U.map((e=>(0,a.jsx)("option",{value:e,children:e},e)))]})]}),z?(0,a.jsx)("div",{children:t("Loading...")}):(0,a.jsx)("ul",{className:"flex flex-col gap-2 selection w-full max-h-[476px] overflow-auto",children:null===P||void 0===P?void 0:P.filter((e=>"https://dealai-music.s3.us-east-2.amazonaws.com/"!==e.url)).map(((e,s)=>(0,a.jsxs)("div",{className:"flex flex-col",children:[b===e.url&&(0,a.jsx)("div",{className:"offset-setter",children:(0,a.jsx)(A,{setIsChooseTrack:G,isChooseTrack:D,setIsLoading:k,isLoading:C})}),(0,a.jsx)("li",{className:"mb-4 flex justify-between w-full gap-3 items-center",children:(0,a.jsx)("div",{className:"w-full p-2",children:(0,a.jsx)("div",{className:"flex items-center justify-center gap-6 w-full",children:(0,a.jsxs)("div",{className:"flex flex-col w-1/2",children:[(0,a.jsxs)("div",{className:"font-bold text-gray-800",children:[e.tempo," ",e.emotion," ",e.genre]}),(0,a.jsxs)("div",{className:"flex items-center justify-center gap-4 mt-2 w-[111%]",children:[(0,a.jsx)("audio",{ref:e=>n.current[s]=e,controls:!0,src:e.url,className:"mt-2 w-full",onPlay:()=>(e=>{G(!1),n.current.forEach(((t,s)=>{s!==e&&t&&t.pause()}))})(s)}),(0,a.jsx)("button",{onClick:()=>{var t,a,r,o;k(!0),G(!0),t=e.url,a=e.tempo,r=e.emotion,o=e.genre,N(t),localStorage.setItem("trackUrl",JSON.stringify(t)),i({...l,music:t,musicTempo:a,musicEmotion:r,musicGenre:o}),M(!1),n.current.forEach(((e,t)=>{t!==s&&e&&e.pause()}))},className:"border rounded-lg shadow p-2 w-[40%] ".concat(b===e.url?"bg-blue-500 text-white":"bg-white"),children:t("Choose Track")})]})]})})})},e.url)]},s)))})]}),R&&(0,a.jsxs)("div",{className:"flex flex-col items-center gap-2 p-4",children:[(0,a.jsx)(J,{setIsUploadModal:O,activeTab:"upload",setIsLoading:k}),E&&L&&(0,a.jsx)("div",{className:"offset-setter w-full",children:(0,a.jsx)(A,{setIsChooseTrack:G,isChooseTrack:D,setIsLoading:k,isLoading:C})}),(0,a.jsxs)("div",{className:"flex flex-col gap-2 w-full",children:[(0,a.jsxs)("label",{className:"flex justify-center w-full h-[20rem] px-4 transition border-2 border-gray-300 border-dashed rounded-md ".concat(y?"bg-white cursor-pointer hover:border-gray-400":"bg-gray-200 cursor-not-allowed"),onDragOver:y?e=>{e.preventDefault()}:void 0,onDrop:y?t=>{t.preventDefault(),k(!0);const s=t.dataTransfer.files;if(s.length>0){N("");const t=s[0];e.setUploadAudio(t);const a=URL.createObjectURL(t);i({...l,music:a,musicTempo:t.name}),M(!0)}}:void 0,children:[(0,a.jsxs)("span",{className:"flex items-center space-x-2",children:[(0,a.jsx)(f.Qvc,{className:"w-5 h-5"}),(0,a.jsxs)("span",{className:"font-medium text-gray-600",children:[t(y?"Drop audio to Attach, or":"Audio drop disabled until rights are confirmed"),(0,a.jsx)("span",{className:"text-blue-600 underline ".concat(y?"":"hidden"),children:y?"browse":""})]})]}),(0,a.jsx)("input",{type:"file",name:"file_upload",className:"hidden",accept:"audio/*",onChange:t=>{const s=t.target.files&&t.target.files[0];if(s){k(!0),N(""),e.setUploadAudio(s);const t=URL.createObjectURL(s);i({...l,music:t,musicTempo:s.name}),M(!0)}},disabled:!y})]}),(0,a.jsxs)("label",{htmlFor:"rightsConfirmation",className:"flex items-center",children:[(0,a.jsx)("input",{type:"checkbox",id:"rightsConfirmation",checked:y,onChange:e=>{w(e.target.checked)},className:"mr-2"}),t("I confirm that I have the rights to use this music.")]})]})]})]})};const G=e=>
1{if(e){return(.2126*parseInt(e[0],10)+.7152*parseInt(e[1],10)+.0722*parseInt(e[2],10))/255>.5}};(0,j.z)();var Z=e=>{const{t:t}=(0,v.$G)(),{selectedTemplate:s,videoJob:r}=((0,c.useRouter)(),(0,o.useContext)(p)),{text:l}=s||{},{textValues:i,images:n,music:d,musicOffset:m,musicTempo:x,musicEmotion:f,musicGenre:h}=r||{},g=(0,o.useRef)(null),j=(0,o.useRef)(void 0),[b,N]=(0,o.useState)(!1);return(0,o.useEffect)((()=>{const e=g.current;if(e){const t=()=>{b?(e.currentTime=r.musicOffset,N(!1)):0===e.currentTime&&(e.currentTime=r.musicOffset),r.duration&&(j.current=setTimeout((()=>{e&&!e.paused&&e.pause()}),1e3*r.duration))},s=()=>{N(!0),j.current&&clearTimeout(j.current)};return e.addEventListener("play",t),e.addEventListener("pause",s),()=>{e.removeEventListener("play",t),e.removeEventListener("pause",s),j.current&&clearTimeout(j.current)}}}),[r.musicOffset,r.duration,d,b]),(0,o.useEffect)((()=>{const e=g.current;if(e){e.currentTime=r.musicOffset;(()=>{e.paused||e.pause()})()}}),[r.musicOffset]),(0,a.jsxs)("div",{className:"flex flex-col w-full",children:[(0,a.jsxs)("div",{className:"selected-template flex flex-col justify-center items-center border p-3 rounded-lg shadow",children:[(0,a.jsx)("p",{className:"text-center p-5 text-2xl",children:t("Selected Template")}),s&&(0,a.jsx)(u.Z,{preview:null===s||void 0===s?void 0:s.preview,templateName:null===s||void 0===s?void 0:s.templateName}),(0,a.jsx)("div",{className:"mt-4 w-full p-3",children:(0,a.jsxs)("table",{className:"w-full text-left border-collapse",children:[(0,a.jsx)("thead",{children:(0,a.jsxs)("tr",{style:{backgroundColor:"transparent"},children:[(0,a.jsx)("th",{className:"p-2 text-sm font-bold text-gray-700",children:t("Text")}),(0,a.jsx)("th",{className:"p-2 text-sm font-bold text-gray-700",children:t("Content")})]})}),(0,a.jsx)("tbody",{children:null===l||void 0===l?void 0:l.map(((e,s)=>{return(0,a.jsxs)("tr",{children:[(0,a.jsx)("td",{className:"p-2 text-lg text-gray-700",children:e}),(0,a.jsx)("td",{children:(0,a.jsx)("p",{className:"flex items-center justify-center p-1",style:{color:(l=r.colors[s],"rgb(".concat(l.join(", "),")")),fontSize:"20px",backgroundColor:G(r.colors[s])?"rgb(112,112,112)":"white",transition:"background-color 0.5s ease-in-out"},children:i[s]||t("No value provided")})})]},"text-".concat(s));var l}))})]})})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-2 items-center",children:[(0,a.jsxs)("div",{className:"selected-images flex flex-col justify-center items-center border p-3 rounded-lg shadow m-5",children:[(0,a.jsx)("p",{className:"text-center p-3 text-2xl",children:t("Selected Images")}),(0,a.jsx)("div",{className:"flex flex-wrap gap-2 w-full h-full justify-center items-center",children:n.map(((e,t)=>(0,a.jsx)("div",{className:"flex justify-center items-center border rounded-lg shadow mt-2 w-72",children:(0,a.jsx)("img",{src:e,alt:"image ".concat(t),className:" object-cover object-center border shadow-xl"})},t)))})]}),(0,a.jsxs)("div",{className:"flex flex-col justify-center gap-4 items-center border p-3 rounded-lg shadow m-2 h-[250px]",children:[(0,a.jsx)("p",{className:"text-center p-5 text-2xl",children:t("Selected Music")}),d&&(0,a.jsxs)("div",{className:"",children:[(0,a.jsxs)("p",{className:"properties text-center mb-2",children:[x," ",f," ",h]}),(0,a.jsx)("audio",{controls:!0,ref:g,src:d,className:""})]})]})]}),(0,a.jsx)("div",{className:"flex justify-between mt-5"})]})},z=s(97011),P=s(9110),V=s(68372),F=s(84805),U=s(34429),_=s(79495),K=s(14431),$=s(76590);function B(e){return(0,a.jsxs)(z.Z,{sx:{position:"relative",display:"inline-flex"},children:[(0,a.jsx)($.Z,{variant:"determinate",sx:{color:"#4361EE"},...e}),(0,a.jsx)(z.Z,{sx:{top:0,left:0,bottom:0,right:0,position:"absolute",display:"flex",alignItems:"center",justifyContent:"center"},children:(0,a.jsx)(_.Z,{variant:"caption",component:"div",color:"text.secondary",children:"".concat(Math.round(e.value),"%")})})]})}(0,j.z)();function Q(e){let{steps:t,goNextStep:s,videoJob:r,handleSubmit:l,isSubmiting:i,progress:n}=e;const{t:c}=(0,v.$G)(),[d,u]=o.useState(0),[m,x]=(0,o.useState)(!1),[f,h]=(0,o.useState)(!1),[g,j]=(0,o.useState)(!1),{errors:b}=(0,o.useContext)(p);(0,o.useEffect)((()=>{x(!1),h(!1);const e=r.images.length,t=r.textValues.every((e=>""!==e.trim()));null===r||void 0===r||r.textValues.map((a=>{0===d&&0!==s&&e===s&&t&&x(!0)})),""!==(null===r||void 0===r?void 0:r.music)&&h(!0)}),[s,r,d]);const N=()=>{u((e=>e-1))};return(0,a.jsx)(z.Z,{sx:{maxWidth:1e3},children:(0,a.jsx)(P.Z,{activeStep:d,orientation:"vertical",children:t.map(((e,s)=>(0,a.jsxs)(V.Z,{children:[(0,a.jsx)(K.Z,{optional:2===s?(0,a.jsx)(_.Z,{variant:"caption",children:c("Last step")}):null,children:(0,a.jsx)("p",{className:"text-xl",children:e.label})}),(0,a.jsx)(F.Z,{children:(0,a.jsx)(z.Z,{sx:{mb:2},children:(0,a.jsxs)("div",{children:[e.component,(0,a.jsx)(U.Z,{variant:"contained",onClick:()=>(e=>{0===e&&m||1===e&&f?u((e=>e+1)):e===t.length-1&&l()})(s),sx:{mt:3,mr:1},disabled:0===s&&!m||1===s&&!f||b.length>0||i,children:s===t.length-1?i?(0,a.jsx)(B,{value:n}):c("Submit"):c("Continue")}),(0,a.jsx)(U.Z,{disabled:0===s||i,onClick:N,sx:{mt:3,mr:1},children:c("Back")})]})})})]},e.label)))})})}var q=s(38140),W=s(14914),H=s(2310),X=s(89971),Y=s(91157),ee=s(37333),te=s(24736),se=s.n(te);const ae=e=>{const t=3600;if(e>=t){const s=Math.floor(e/t),a=e%t,r=Math.floor(a/60);return r>0?"".concat(s,"h ").concat(r,"m"):"".concat(s,"h")}if(e>=60){const t=Math.floor(e/60),s=e%60;return s>0?"".concat(t,"m ").concat(s,"s"):"".concat(t,"m")}return"".concat(e,"s")};(0,j.z)();function re(e){const{t:t}=(0,v.$G)(),[s,r]=(0,o.useState)(null),[l]=S.r.useLazyGetVideoStatusQuery(),[i]=S.r.useLazyGetJobVaultQuery(),{videos:n,setVideos:c}=e,[d]=S.r.useDeleteFailedVideoMutation(),[u]=S.r.useMarkJobMutation(),[m,x]=(0,o.useState)();(0,o.useEffect)((()=>{(async()=>{const e=await i({});e&&e.data&&(x(e.data._id),se().set("Ai Video",e.data._id))})()}),[]),(0,o.useEffect)((()=>{const e=async()=>{var e;const a=await l({});if(a&&(null===(e=a.data)||void 0===e?void 0:e.length)){c(a.data);const e=a.data.filter((e=>"completed"===e.status&&!e.isShowed&&!e.dismissed));e.forEach((e=>{(0,C.D2)({title:"".concat(t("Video")," ").concat(e.templateName," ").concat(t("is completed and added")," ")})}));const l=e.map((e=>e._id));l.length>0&&await u({jobIds:l}),clearInterval(s),r(null),localStorage.removeItem("completedVideoIds")}};e();const a=setInterval(e,1e4);
1return r(a),()=>{clearInterval(a)}}),[]);const p=(null===n||void 0===n?void 0:n.length)>0&&[...n].sort(((e,t)=>e.createdAt&&t.createdAt?new Date(t.createdAt).getTime()-new Date(e.createdAt).getTime():-1));return(0,a.jsx)("div",{className:"fixed bottom-16 right-[20px] z-50 p-0 m-0 border-none max-w-48 max-h-48 rounded-full bg-blue-600 cursor-pointer shadow-md transition-transform duration-300",children:(0,a.jsx)(Y.J,{className:"relative",children:e=>{let{open:s}=e;var r;return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:"z-[999] absolute right-[68%] top-[-14%] rounded-full bg-red-600",children:(0,a.jsx)("p",{className:"text-sm text-white leading-3 p-[7px]",children:null!==(r=null===n||void 0===n?void 0:n.length)&&void 0!==r?r:0})}),(0,a.jsx)(Y.J.Button,{className:"p-3 bg-primary text-white rounded-full transition-transform duration-200 ease-in-out hover:scale-110",title:"Queue Indicator",children:s?(0,a.jsx)(f.RiI,{className:"h-5 w-5",fill:"white"}):(0,a.jsx)(X.krB,{className:"h-5 w-5",fill:"white"})}),(0,a.jsx)(ee.u,{as:o.Fragment,enter:"transition ease-out duration-200",enterFrom:"opacity-0 scale-95",enterTo:"opacity-100 scale-100",leave:"transition ease-in duration-150",leaveFrom:"opacity-100 scale-100",leaveTo:"opacity-0 scale-95",children:(0,a.jsx)(Y.J.Panel,{className:"absolute bg-white border border-gray-300 rounded-lg shadow-lg w-[300px] md:w-[500px]",style:{bottom:"calc(100% + 8px)",right:0},children:(0,a.jsxs)("div",{className:"flex flex-col justify-between",children:[(0,a.jsxs)("div",{className:"flex justify-center items-center p-2",children:[(0,a.jsx)(X.krB,{className:"w-4 h-4"}),(0,a.jsx)("p",{className:"text-black text-lg p-2",children:t("Queue indicator")})]}),(0,a.jsxs)("div",{className:"z-[999] flex flex-col gap-4 max-h-[500px] overflow-y-auto ".concat((null===n||void 0===n?void 0:n.length)?"":"items-center justify-center min-h-[200px]"),children:[p?p.map(((e,s)=>(0,a.jsxs)("div",{className:"flex flex-col border shadow-sm p-4",children:[(0,a.jsxs)("div",{className:"flex justify-between items-center gap-2",children:[(0,a.jsx)("div",{children:"completed"===e.status?(0,a.jsxs)("p",{children:[(0,a.jsx)("span",{className:"font-bold",children:t("Template:")})," ",(0,a.jsx)("a",{href:"/apps/vault/".concat(m),className:"text-blue-500 underline",children:e.templateName})]}):(0,a.jsxs)("p",{children:[(0,a.jsx)("span",{className:"font-bold",children:t("Template:")})," ",e.templateName]})}),("completed"===e.status||"failed"===e.status)&&(0,a.jsx)("button",{className:"transition-transform duration-200 ease-in-out hover:scale-110",onClick:()=>(async e=>{try{if("data"in await d({id:e})){const t=n.filter((t=>t._id!==e));c(t)}}catch(s){(0,C.Eo)(t("Error while deleting"))}})(e._id),children:(0,a.jsx)(y.FU5,{className:"w-6 h-6"})})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-2 pt-2",children:[(0,a.jsxs)("p",{children:[(0,a.jsx)("span",{className:"font-bold",children:t("Duration:")})," ",ae(e.duration)]}),(0,a.jsxs)("p",{children:[(0,a.jsx)("span",{className:"font-bold",children:t("Music:")})," ",null===e||void 0===e?void 0:e.musicTempo," ",null===e||void 0===e?void 0:e.musicEmotion," ",null===e||void 0===e?void 0:e.musicGenre]}),(0,a.jsxs)("p",{children:[(0,a.jsx)("span",{className:"font-bold",children:t("Job Status:")})," ",null===e||void 0===e?void 0:e.status]}),(null===e||void 0===e?void 0:e.queuePosition)&&"processing"!==e.status&&(0,a.jsxs)("p",{children:[(0,a.jsx)("span",{className:"font-bold",children:t("Position in the queue:")})," ",null===e||void 0===e?void 0:e.queuePosition]})]})]},s))):(0,a.jsxs)("div",{className:"flex gap-2 items-center",children:[(0,a.jsx)("p",{className:"text-xl text-black pt-2 pb-2",children:t("The queue is empty")}),(0,a.jsx)(y.Ley,{className:"w-6 h-6"})]}),n&&(0,a.jsx)("p",{className:"p-2",children:(null===n||void 0===n?void 0:n.length)>0?"".concat(t("Total Jobs:")," ").concat(null===n||void 0===n?void 0:n.length):""})]})]})})})]})}})})}const le="video-template-selection",ie=(0,q.Z)({palette:{primary:{main:"#4361ee"},secondary:{main:"#805dca"}},typography:{fontFamily:"Roboto, sans-serif"}});var ne=!0,oe=(0,i.Z)((e=>{const{t:t}=(0,v.$G)(),{data:s}=(0,H.useSession)(),r=(null===s||void 0===s?void 0:s.token)||"",i=(0,c.useRouter)(),{step:n}=i.query,[d,u]=(0,o.useState)(!0),[m,x]=(0,o.useState)(!1),[f,h]=(0,o.useState)(0),[j,N]=(0,o.useState)(!1),[y,w]=(0,o.useState)(!1),[k,E]=(0,o.useState)(null),[I,R]=(0,o.useState)(0),[O,L]=(0,o.useState)(),{isWhitelabel:M,whitelabelOverride:A}=(0,g.y)();(0,o.useEffect)((()=>{R(0)}),[]);const[J,G]=(0,o.useState)([]),[z,P]=(0,o.useState)({templateName:"",templateDirectory:"",aspectRatio:"",duration:0,textValues:[],colors:[],images:[],music:"",musicTempo:"",musicEmotion:"",musicGenre:"",musicOffset:0}
1),[V,F]=(0,o.useState)(""),[U]=S.r.useRequestVideoJobMutation(),[_,K]=(0,o.useState)({min:0,max:0}),[$,B]=(0,o.useState)(0),[q,X]=(0,o.useState)(0),[Y,ee]=(0,o.useState)(!1),[te,se]=(0,o.useState)([]),[ae,ne]=(0,o.useState)(null),[oe,ce]=(0,o.useState)(""),{data:de,isLoading:ue}=S.r.useGetVideoLibraryQuery(null),me=(0,o.useMemo)((()=>(null===de||void 0===de?void 0:de.map(((e,t)=>({...e,id:e.templateName}))))||[]),[de]),{images:xe}=z||{},pe=["image/jpeg","image/png","image/gif","image/bmp","image/webp"];(0,o.useEffect)((()=>{""===z.templateName&&i.push("/apps/ai-video")}),[]),(0,o.useEffect)((()=>{if(n&&"detail-selector"===n[0]&&n[1]){const e=null===me||void 0===me?void 0:me.find((e=>e.id===n[1]));e&&(E({...e}),P({...z,templateName:e.templateName,templateDirectory:e.templateDirectory,aspectRatio:e.aspectRatio,textValues:e.text.map((e=>"")),duration:e.duration,colors:e.colors,images:e.images}))}}),[n]);const fe=[{label:t("Template Detail"),component:(0,a.jsx)(T,{goNextStep:f,setGoNextStep:h,setAllImages:se,allImages:te})},{label:t("Music Selection"),component:(0,a.jsx)(D,{setUploadAudio:ne})},{label:t("Submit"),component:(0,a.jsx)(Z,{showSubmitSector:w,shouldShowMusicSelector:j,showMusicSelector:N,shouldShowSubmitSector:y})}];return(0,a.jsx)(W.Z,{theme:ie,children:(0,a.jsxs)("div",{className:le,children:[(0,a.jsxs)(l(),{children:[(0,a.jsx)("title",{children:M?A?A.title||t("Motion Maker"):"":t("Motion Maker")}),(0,a.jsx)("style",{children:"\n                body {\n                  background-color: white !important;\n              }\n              .".concat(le,", .").concat(le," * {\n                color: black;\n              }\n              .noUi-connects{\n                background-color: white !important;\n              }\n          ")})]}),(0,a.jsx)("div",{className:"main",children:(0,a.jsxs)(p.Provider,{value:{showTemplateDetailSector:x,showTemplateSelector:u,selectedTemplate:k,selectTemplate:E,videoJob:z,setVideoJob:P,selectedAspectRatio:V,setAspectRatio:F,selectedDurationRange:_,setDurationRange:K,selectedNumOfImages:$,setNumOfImages:B,selectedNumOfTexts:q,setNumOfTexts:X,searchKey:oe,setSearchKey:ce,errors:J,setErrors:G},children:[!n&&(0,a.jsx)(b,{goNextStep:f,originalTemplates:me,isLoading:ue,setGoNextStep:h,setAllImages:se}),n&&"detail-selector"===n[0]&&n[1]&&(0,a.jsx)("div",{className:"video-temp-detail-container m-auto my-3 justify-center px-2 pt-2 md:max-w-[1000px] md:w-10/12",children:(0,a.jsx)(Q,{videos:O,progress:I,isSubmiting:Y,steps:fe,setGoNextStep:h,goNextStep:f,videoJob:z,handleSubmit:async()=>{R((e=>e>=100?0:e+10));const e="https://api.marketing.deal.ai",s={headers:{Authorization:"Bearer ".concat(r)}},a=te.every((e=>{return(t=e)&&pe.includes(t.type);var t}));if(!a)return void(0,C.Eo)(t("One or more uploaded files are not valid image types. Please use JPEG, PNG, GIF, or BMP."));const l=new FormData;te.forEach((e=>{l.append("images",e)}));try{if(ae||z.music){ee(!0),R((e=>e>=100?0:e+10));const a=await fetch("".concat(e,"/video/upload"),{method:"POST",body:l,headers:s.headers});if(!a.ok){const e=await a.text();throw new Error("Error uploading video: ".concat(a.status," - ").concat(e))}R((e=>e>=100?0:e+10));const r=await a.json(),o=[];if(Array.isArray(r.images))r.images.forEach((e=>{e.url&&o.push(e.url)}));else{if(!r.images||!r.images.url)throw ee(!1),new Error("Unexpected response structure");o.push(r.images.url)}let c={...z,images:o};if(setTimeout((()=>{R((e=>e>=100?0:e+20))}),5e3),ae){if(!(n=ae)||!["audio/mpeg"].includes(n.type))return void(0,C.Eo)(t("Invalid audio format. Please upload a valid MP3."));const a=new FormData;a.append("file",ae),R((e=>e>=100?0:e+10));const r=await fetch("".concat(e,"/video/uploadAudio"),{method:"POST",body:a,headers:s.headers});if(!r.ok){const e=await r.text();throw new Error("Error uploading music: ".concat(r.status," - ").concat(e))}R((e=>e>=100?0:e+10));const l=await r.json();c={...z,images:o,music:l.url}}else c={...z,images:o,music:z.music};R((e=>e>=100?0:e+10));const d=await U({job:c});"data"in d?(R((e=>e>=100?0:e+20)),ee(!1),(0,C.NK)({title:d.data.message}),se([]),R(0),ne(null),i.push("/apps/ai-video")):"error"in d&&((0,C.Eo)(d.error.data.error),ee(!1),R(0))}else(0,C.Eo)(t("Please make sure to add a valid MP3 audio."))}catch(o){ee(!1),R(0),(0,C.Eo)(o.message||t("An error occurred during submission."))}var n}})}),(0,a.jsx)(re,{videos:O,setVideos:L})]})})]})})}),n.pR,"ai-platform")}},function(e){e.O(0,[13365,34396,47665,64838,62473,2013,27049,70938,85491,13323,69532,81990,29736,6364,68015,49774,92888,40179],(function(){return t=44760,e(e.s=t);var t}));var t=e.O();_N_E=t}]);

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.