1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[19134],{4337:(e,t,a)=>{a.d(t,{default:()=>d});var r=a(68812),s=a(51456),l=a(92766),i=a(54135);let o=e=>/\.(jpg|jpeg|png|gif|webp|bmp|svg|ico|tiff|tif|avif)$/i.test(e.split("?")[0]),n=e=>{let{effect:t,example:a,onHover:i}=e,[n,d]=(0,s.useState)(!1),[c,u]=(0,s.useState)(!1),m=(0,s.useRef)(null),p=(0,s.useRef)(null);(0,l.useRouter)();let x=!!t.videourl&&!o(t.videourl);(0,s.useEffect)(()=>{if(!p.current||!x)return;let e=new IntersectionObserver(e=>{e.forEach(e=>{u(e.isIntersecting),e.isIntersecting&&m.current?m.current.play().catch(e=>console.log("Auto-play failed:",e)):!e.isIntersecting&&m.current&&m.current.pause()})},{threshold:.5,rootMargin:"50px"});return e.observe(p.current),()=>{e.disconnect()}},[x]);let h=async e=>{try{return(await fetch(e,{method:"HEAD"})).ok}catch(e){return!1}},f=async()=>{let e="/effectsapp/img2videoeffect",a=e;if(t.pageurl)if(t.pageurl===e||"effectsapp/img2videoeffect"===t.pageurl)a=e;else{let r=new URL(t.pageurl,window.location.origin);a=await h(r.pathname)?t.pageurl:e}let r=new URL(a,window.location.origin);r.searchParams.set("effectId",t.id.toString()),window.open(r.pathname+r.search,"_blank")};return(0,r.jsx)("div",{ref:p,className:"relative rounded-lg overflow-hidden shadow-lg cursor-pointer group",style:{backgroundColor:"hsl(var(--card))"},onMouseEnter:()=>{d(!0),null==i||i(!0),m.current&&c&&x&&m.current.play().catch(e=>console.log("Video play failed:",e))},onMouseLeave:()=>{d(!1),null==i||i(!1)},onClick:()=>{f()},children:(0,r.jsxs)("div",{className:"relative w-full",style:{aspectRatio:"9/16"},children:[t.videourl?x?(0,r.jsx)("video",{ref:m,src:t.videourl,className:"absolute inset-0 w-full h-full object-cover",loop:!0,muted:!0,playsInline:!0}):(0,r.jsx)("img",{src:t.videourl,alt:t.name||"Effect",className:"absolute inset-0 w-full h-full object-cover"}):(0,r.jsx)("div",{className:"absolute inset-0 flex items-center justify-center",style:{backgroundColor:"hsl(var(--muted))"},children:(0,r.jsx)("span",{style:{color:"hsl(var(--muted-foreground))"},children:"No video"})}),(0,r.jsxs)("div",{className:"absolute bottom-0 left-0 right-0 p-2 md:p-3 transition-all duration-300",style:{background:"linear-gradient(to top, rgba(0,0,0,0.8), transparent)"},children:[(0,r.jsx)("p",{className:"text-white text-xs md:text-sm font-semibold text-center uppercase tracking-wide mb-2",children:t.name}),(0,r.jsx)("div",{className:"flex justify-center",children:(0,r.jsx)("button",{className:"px-2.5 py-1 sm:px-4 sm:py-1.5 rounded-full font-medium text-[11px] sm:text-sm whitespace-nowrap transition-all duration-300 hover:scale-105 shadow-md",style:{backgroundColor:"hsl(var(--primary))",color:"hsl(var(--primary-foreground))"},onClick:e=>{e.stopPropagation(),f()},children:(()=>{if(!t.type)return"Create Similar";let e=t.type.toLowerCase();return e.includes("video")?(null==a?void 0:a.videoButtonName)||"Create Similar Video":e.includes("image")||e.includes("img")?(null==a?void 0:a.imageButtonName)||"Create Similar Image":(null==a?void 0:a.videoButtonName)||"Create Similar"})()})})]})]})})},d=e=>{let{example:t,type:a,isnoshowclass:l=!1,apptype:o="common",dealyLoad:d=5}=e,[c,u]=(0,s.useState)([]),[m,p]=(0,s.useState)(!0),[x,h]=(0,s.use
1State)(null),f=(0,s.useRef)({}),[v,g]=(0,s.useState)(1),[b,j]=(0,s.useState)({}),y=(0,s.useRef)(null),N=(0,s.useRef)({});(0,s.useEffect)(()=>{if(d>0){let e=setTimeout(()=>{w()},1e3*d);return()=>clearTimeout(e)}w()},[]);let w=async()=>{try{let e=new URLSearchParams;a&&e.set("type",a),e.set("apptype",o||"common");let t="/api/effect?".concat(e.toString()),r=await fetch(t),s=await r.json();if(s.success&&s.data&&(u(s.data),s.data.length>0)){h(s.data[0].id);let e={};s.data.forEach(t=>{e[t.id]=1}),j(e)}}catch(e){console.error("Error fetching effects:",e)}finally{p(!1)}},k=e=>{h(e);let t=f.current[e];t&&t.scrollIntoView({behavior:"smooth",block:"start"})},S=()=>{g(e=>e+1)},C=e=>{j(t=>({...t,[e]:(t[e]||1)+1}))};(0,s.useEffect)(()=>{if(l&&y.current&&!m){let e=6*v<c.flatMap(e=>e.effects).length;if(!e)return;let t=new IntersectionObserver(t=>{t[0].isIntersecting&&e&&S()},{threshold:.1,rootMargin:"100px"});return t.observe(y.current),()=>{t.disconnect()}}},[l,v,c,m]),(0,s.useEffect)(()=>{if(!l&&!m&&c.length>0){let e=[];return c.forEach(t=>{let a=N.current[t.id];if(!a)return;let r=6*(b[t.id]||1)<t.effects.length;if(!r)return;let s=new IntersectionObserver(e=>{e[0].isIntersecting&&r&&C(t.id)},{threshold:.1,rootMargin:"100px"});s.observe(a),e.push(s)}),()=>{e.forEach(e=>e.disconnect())}}},[l,b,c,m]);let R=(null==t?void 0:t.showNumInLine)||6;return(0,r.jsx)("section",{className:"",style:{backgroundColor:"hsl(var(--background))"},children:(0,r.jsxs)("div",{className:"w-full px-[10px]",children:[(null==t?void 0:t.title)&&(0,r.jsx)("h2",{className:"text-3xl sm:text-4xl font-bold text-center mb-3",style:{color:"hsl(var(--foreground))"},children:t.title}),(null==t?void 0:t.description)&&(0,r.jsx)("p",{className:"text-center text-lg sm:text-xl mb-8 md:mb-12",style:{color:"hsl(var(--muted-foreground))"},children:t.description}),m&&(0,r.jsx)("div",{className:"text-center py-20",children:(0,r.jsx)("p",{className:"text-xl",style:{color:"hsl(var(--muted-foreground))"},children:"Loading..."})}),!m&&c.length>0&&(0,r.jsx)(r.Fragment,{children:l?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(i.A,{breakpointCols:{default:R,1024:Math.max(2,R-1),768:2},className:"flex -ml-2 md:-ml-3 w-auto",columnClassName:"pl-2 md:pl-3 bg-clip-padding",children:c.flatMap(e=>e.effects).slice(0,6*v).map(e=>(0,r.jsx)("div",{className:"mb-2 md:mb-3",children:(0,r.jsx)(n,{effect:e,example:t})},e.id))}),6*v<c.flatMap(e=>e.effects).length&&(0,r.jsx)("div",{ref:y,className:"w-full h-10 flex items-center justify-center",children:(0,r.jsx)("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2",style:{borderColor:"hsl(var(--primary))"}})})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"mb-4 md:mb-6",children:(0,r.jsx)("div",{className:"overflow-x-auto -mx-4 px-4",children:(0,r.jsx)("div",{className:"flex gap-0 min-w-max border-b",style:{borderColor:"hsl(var(--border))"},children:c.map(e=>{let t=x===e.id;return(0,r.jsx)("button",{onClick:()=>k(e.id),className:"px-4 md:px-6 py-3 md:py-3.5 font-medium text-sm md:text-base whitespace-nowrap transition-all duration-200 hover:bg-muted/50 relative",style:{backgroundColor:"transparent",color:t?"hsl(var(--foreground))":"hsl(var(--muted-foreground))",borderBottom:t?"2px solid hsl(var(--primary))":"2px solid transparent"},children:e.classname||"Unnamed Group"},e.id)})})})}),c.map(e=>{let a=b[e.id]||1,s=e.effects.slice(0,6*a),l=s.length<e.effects.length;return(0,r.jsxs)("div",{ref:t=>{f.current[e.id]=t},className:"mb-12 md:mb-16",children:[(0,r.jsx)("h3",{className:"text-lg md:text-xl font-semibold mb-4 md:mb-6",style:{color:"hsl(var(--foreground))"},children:e.classname||"Unnamed Group"}),s.length>0?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(i.A,{breakpointCols:{default:R,1024:Math.max(2,R-1),768:2},className:"flex -ml-4 md:-ml-6 w-auto",columnClassName:"pl-4 md:pl-6 bg-clip-padding",children:s.map(e=>(0,r.jsx)("div",{className:"mb-4 md:mb-6",children:(0,r.jsx)(n,{effect:e,example:t})},e.id))}),l&&(0,r.jsx)("div",{ref:t=>{N.current[e.id]=t},className:"w-full h-10 flex items-center justify-center mt-4",children:(0,r.jsx)("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2",style:{borderColor:"hsl(var(--primary))"}})})]}):(0,r.jsx)("p",{style:{color:"hsl(var(--muted-foreground))"},children:"No effects in this group"})]},e.id)})]})}),!m&&0===c.length&&(0,r.jsx)("div",{className:"text-center py-20",children:(0,r.jsx)("p",{className:"text-xl",style:{color:"hsl(var(--muted-foreground))"},children:"No effects available"})})]})})}},25594:(e,t,a)=>{a.d(t,{bq:()=>m,eb:()=>f,gC:()=>h,l6:()=>c,yv:()=>u});var r=a(68812),s=a(51456),l=a(49343),i=a(66281),o=a(67188),n=a(37685),d=a(58981);let c=l.bL;l.YJ;let u=l.WT,m=s.forwardRef((e,t)=>
1{let{className:a,children:s,...o}=e;return(0,r.jsxs)(l.l9,{ref:t,className:(0,d.cn)("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",a),...o,children:[s,(0,r.jsx)(l.In,{asChild:!0,children:(0,r.jsx)(i.A,{className:"h-4 w-4 opacity-50"})})]})});m.displayName=l.l9.displayName;let p=s.forwardRef((e,t)=>{let{className:a,...s}=e;return(0,r.jsx)(l.PP,{ref:t,className:(0,d.cn)("flex cursor-default items-center justify-center py-1",a),...s,children:(0,r.jsx)(o.A,{className:"h-4 w-4"})})});p.displayName=l.PP.displayName;let x=s.forwardRef((e,t)=>{let{className:a,...s}=e;return(0,r.jsx)(l.wn,{ref:t,className:(0,d.cn)("flex cursor-default items-center justify-center py-1",a),...s,children:(0,r.jsx)(i.A,{className:"h-4 w-4"})})});x.displayName=l.wn.displayName;let h=s.forwardRef((e,t)=>{let{className:a,children:s,position:i="popper",...o}=e;return(0,r.jsx)(l.ZL,{children:(0,r.jsxs)(l.UC,{ref:t,className:(0,d.cn)("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2","popper"===i&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",a),position:i,...o,children:[(0,r.jsx)(p,{}),(0,r.jsx)(l.LM,{className:(0,d.cn)("p-1","popper"===i&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:s}),(0,r.jsx)(x,{})]})})});h.displayName=l.UC.displayName,s.forwardRef((e,t)=>{let{className:a,...s}=e;return(0,r.jsx)(l.JU,{ref:t,className:(0,d.cn)("py-1.5 pl-8 pr-2 text-sm font-semibold",a),...s})}).displayName=l.JU.displayName;let f=s.forwardRef((e,t)=>{let{className:a,children:s,...i}=e;return(0,r.jsxs)(l.q7,{ref:t,className:(0,d.cn)("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",a),...i,children:[(0,r.jsx)("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,r.jsx)(l.VF,{children:(0,r.jsx)(n.A,{className:"h-4 w-4"})})}),(0,r.jsx)(l.p4,{children:s})]})});f.displayName=l.q7.displayName,s.forwardRef((e,t)=>{let{className:a,...s}=e;return(0,r.jsx)(l.wv,{ref:t,className:(0,d.cn)("-mx-1 my-1 h-px bg-muted",a),...s})}).displayName=l.wv.displayName},26777:(e,t,a)=>{a.d(t,{A:()=>o});var r=a(68812),s=a(51456),l=a(33493),i=a(65289);function o(e){let{open:t,onOpenChange:a,locale:o,onFailed:n}=e,[d,c]=(0,s.useState)(null);return((0,s.useEffect)(()=>{if(!t)return;c(null);let e=new URLSearchParams;o&&e.set("locale",o);let r=e.toString()?"?".concat(e.toString()):"";fetch("/api/price/data".concat(r)).then(e=>e.json()).then(e=>{e.success&&e.data?c(e.data):(a(!1),null==n||n())}).catch(()=>{a(!1),null==n||n()})},[t]),t)?(0,r.jsxs)("div",{className:"fixed inset-0 z-50 overflow-y-auto bg-background",children:[(0,r.jsx)("button",{onClick:()=>a(!1),className:"fixed right-4 top-4 z-50 w-10 h-10 flex items-center justify-center rounded-full bg-black/60 hover:bg-black/80 text-white transition-colors","aria-label":"Close",children:(0,r.jsx)(l.A,{className:"h-5 w-5"})}),(0,r.jsx)("div",{className:"w-full",children:d&&(0,r.jsx)(i.default,{pricing:d})})]}):null}},45599:(e,t,a)=>{a.d(t,{default:()=>x});var r=a(68812),s=a(51456),l=a(72383),i=a(2313),o=a(25027),n=a(14634),d=a(13910),c=a(71563),u=a(80893),m=a.n(u),p=a(95147);let x=e=>{var t;let{videos:a,example:u}
1=e,[x,h]=(0,s.useState)({}),f=(0,s.useRef)({}),v=(null==u?void 0:null===(t=u.examples)||void 0===t?void 0:t.map((e,t)=>{var r,s,l;return{src:(null==e?void 0:null===(r=e.image)||void 0===r?void 0:r.src)||(null===(s=a[t])||void 0===s?void 0:s.src)||"",prompt:e.description||(null===(l=a[t])||void 0===l?void 0:l.prompt)||""}}))||a,g=()=>{switch(null==u?void 0:u.size){case"16:9":default:return"aspect-video";case"9:16":return"aspect-[9/16] max-h-[60vh] md:max-h-[70vh] lg:max-h-[80vh]";case"1:1":return"aspect-square"}},b=()=>(null==u?void 0:u.size)==="9:16"?"object-contain":"object-cover",j=Math.min(Math.max(Number(null==u?void 0:u.showNumInLine)||2,1),4),y="grid-cols-1 ".concat({1:"md:grid-cols-1",2:"md:grid-cols-2",3:"md:grid-cols-3",4:"md:grid-cols-4"}[String(j)]),N=(e,t)=>{t.paused?(t.play(),h(t=>({...t,[e]:!0}))):(t.pause(),h(t=>({...t,[e]:!1})))},w=(e,t)=>{let a=document.createElement("a");a.href=e,a.download="labubu-wallpaper-".concat(t+1,".mp4"),document.body.appendChild(a),a.click(),document.body.removeChild(a),c.oR.success("Download started!")};(0,s.useEffect)(()=>{if((null==u?void 0:u.videoPlayMode)==="autoplay"){let e=[];Object.values(f.current).forEach((t,a)=>{if(t){let r=t.play();void 0!==r&&(e.push(r),h(e=>({...e,[a]:!0})))}}),Promise.allSettled(e).then(e=>{e.forEach((e,t)=>{"rejected"===e.status&&(console.log("Autoplay blocked for video ".concat(t)),h(e=>({...e,[t]:!1})))})})}},[null==u?void 0:u.videoPlayMode]);let k=e=>{if((null==u?void 0:u.videoPlayMode)==="mouseover"){let t=f.current[e];t&&t.paused&&t.play().then(()=>{h(t=>({...t,[e]:!0}))}).catch(()=>{console.log("Mouseover play blocked for video ".concat(e))})}},S=e=>{if((null==u?void 0:u.videoPlayMode)==="mouseover"){let t=f.current[e];t&&!t.paused&&(t.pause(),h(t=>({...t,[e]:!1})))}},C=()=>{switch(null==u?void 0:u.videoPlayMode){case"autoplay":case"none":default:return"cursor-default";case"mouseover":return"cursor-pointer"}};return(0,r.jsxs)("div",{className:"container mx-auto p-4 max-w-6xl",id:"example-video",children:[(0,r.jsxs)("div",{className:"mb-6 text-center",children:[(0,r.jsx)("h2",{className:"text-4xl font-bold text-foreground mb-1",children:(null==u?void 0:u.title)||"User Cases"}),(0,r.jsx)("p",{className:"text-muted-foreground text-base",children:(null==u?void 0:u.description)||"Try the powerful Veo3 video generator with these cases"})]}),(0,r.jsx)("div",{className:"grid ".concat(y," gap-6"),children:v.map((e,t)=>(0,r.jsxs)("div",{className:"rounded-2xl bg-card p-4 shadow-sm",style:{minWidth:0},children:[e.src&&(0,r.jsxs)("div",{className:"".concat(g()," w-full bg-muted rounded-lg overflow-hidden mb-4 relative group ").concat(C()),onMouseEnter:()=>k(t),onMouseLeave:()=>S(t),children:[(0,r.jsx)("video",{ref:e=>{f.current[t]=e},src:e.src,className:"w-full h-full ".concat(b()),preload:"metadata",style:{background:"black"},onPlay:()=>h(e=>({...e,[t]:!0})),onPause:()=>h(e=>({...e,[t]:!1})),onEnded:()=>h(e=>({...e,[t]:!1})),muted:(null==u?void 0:u.videoPlayMode)==="autoplay"||(null==u?void 0:u.videoPlayMode)==="mouseover",loop:(null==u?void 0:u.videoPlayMode)==="autoplay"||(null==u?void 0:u.videoPlayMode)==="mouseover",controls:null==u?void 0:u.isHavePlayControls}),((null==u?void 0:u.videoPlayMode)==="none"||(null==u?void 0:u.isHavePlayButton))&&(0,r.jsx)("div",{className:"absolute inset-0 flex items-center justify-center bg-black bg-opacity-30 opacity-0 group-hover:opacity-100 transition-opacity duration-200",children:(0,r.jsx)(d.$,{variant:"secondary",size:"icon",className:"w-12 h-12 rounded-full bg-white bg-opacity-90 hover:bg-opacity-100",onClick:e=>{e.preventDefault();let a=f.current[t];a&&N(t,a)},children:x[t]?(0,r.jsx)(l.A,{className:"h-6 w-6 text-black"}):(0,r.jsx)(i.A,{className:"h-6 w-6 text-black ml-1"})})}),(null==u?void 0:u.isHaveDownloadButton)&&(0,r.jsx)("div",{className:"absolute top-2 right-2",children:(0,r.jsx)(d.$,{variant:"secondary",size:"icon",className:"w-8 h-8 rounded-full bg-black bg-opacity-70 hover:bg-opacity-90 text-white",onClick:()=>w(e.src,t),title:"Download video",children:(0,r.jsx)(o.A,{className:"h-4 w-4"})})})]}),e.prompt&&""!==e.prompt.trim()&&(0,r.jsxs)("div",{className:"flex items-center bg-muted rounded-md px-3 py-2 mt-4",children:[(0,r.jsx)("span",{className:"font-semibold text-foreground mr-2",children:(null==u?void 0:u.label)||"Prompt:"}),(0,r.jsx)("span",{className:"text-muted-foreground text-sm truncate flex-1",title:e.prompt,children:e.prompt}),(0,r.jsx)(d.$,{variant:"ghost",size:"icon",onClick:()=>{navigator.clipboard.writeText(e.prompt).then(()=>c.oR.success("Prompt copied!")).catch(()=>c.oR.error("Failed to copy prompt."))},className:"ml-2 text-muted-foreground hover:text-foreground",title:"copy prompt",children:(0,r.jsx)(n.A,{className:"h-4 w-4"})})]})]},t))}),(null==u?void 0:u.buttons)&&(0,r.jsx)("div",{className:"mt-8 flex flex-col justify-center gap-4 sm:flex-row",children:null==u?void 0:u.buttons.map((e,t)=>(0,r.jsx)(d.$,{variant:e.variant||"default",children:(0,r.jsxs)(m(),{href:e.url||"",target:e.target,className:"flex items-center justify-center gap-1",children:[e.title,e.icon&&(0,r.jsx)(p.default,{name:e.icon,className:"size-6"})]})},t))})]})}},65688:(e,t,a)=>{a.d(t,{y:()=>r});let r={label:"Model",description:"Select model",defaultValue:"ai-high-video-free",placeholder:"Select model",is_hide:!1,items:[{value:"ai-high-video-free",name:"MiniMax H3 Basic",description:"One Free per day, No Watermark",resultVideoDemoSrc:"https://static.aiquickdraw.com/tools/example/1785487226469_vOB9N8JQ.mp4",durationStyle:"huadongtiao",durationMin:4,durationMax:10,durationDefault:10,cutSec:2,isImageLibraryNoUse:!0,imageNumberLimit:9,"resolutionSelect-n":{label:"Resolution",description:"Select Video resolution",defaultValue:"768P",is_hide:!1,items:[{value:"2K",name:"2K"},{value:"768P",name:"768P"}]},aspectRatioSelect:{label:"Aspect Ratio",description:"Select Size",defaultValue:"16:9",is_hide:!1,items:[{value:"1:1",name:"1:1"},{value:"16:9",name:"16:9"},{value:"9:16",name:"9:16"},{value:"4:3",name:"4:3"},{value:"3:4",name:"3:4"},{value:"adaptive",name:"adaptive"}]}},{value:"minimax-h3-mt",name:"MiniMax H3 Pro",description:"4-15s, No Watermark",resultVideoDemoSrc:"https://static.aiquickdraw.com/tools/example/1785487226469_vOB9N8JQ.mp4",durationStyle:"huadongtiao",durationMin:4,durationMax:15,durationDefault:15,cutSec:2,isImageLibraryNoUse:!0,imageNumberLimit:9,resolutionSelect:{label:"Resolution",description:"Select Video resolution",defaultValue:"768P",is_hide:!1,items:[{value:"2K",name:"2K"},{value:"768P",name:"768P"}]},aspectRatioSelect:{label:"Aspect Ratio",description:"Select Size",defaultValue:"16:9",is_hide:!1,items:[{value:"1:1",name:"1:1"},{value:"16:9",name:"16:9"},{value:"9:16",name:"9:16"},{value:"4:3",name:"4:3"},{value:"3:4",name:"3:4"},{value:"adaptive",name:"adaptive"}]}}
1,{value:"seedance25",name:"Seedance 2.5",description:"about $0.1/s",resultVideoDemoSrc:"https://videocdn.pollo.ai/web-cdn/pollo/production/cmihen6fj002aejdpr1nfgapd/video/1786085597889-537ca251-08b8-43ab-886d-3787f8147719.mp4",durationStyle:"huadongtiao",durationMin:4,durationMax:30,durationDefault:30,isImageLibraryNoUse:!0,imageNumberLimit:30,videoNumberLimit:10,audioNumberLimit:10,VideoSelectIsShow:!0,audioSelectIsShow:!0,promptPlaceholder:"Eg:Use the character from @Image 1, the first-person POV framing from @Video 1, and @Audio 1 as the background track.","resolutionSelect-n":{label:"Resolution",description:"Select Video resolution",defaultValue:"720P",is_hide:!1,items:[{value:"720P",name:"720P ($0.22/s)"},{value:"480P",name:"480P ($0.1/s)"}]},aspectRatioSelect:{label:"Aspect Ratio",description:"Select Size",defaultValue:"16:9",is_hide:!1,items:[{value:"1:1",name:"1:1"},{value:"16:9",name:"16:9"},{value:"9:16",name:"9:16"},{value:"4:3",name:"4:3"},{value:"3:4",name:"3:4"},{value:"adaptive",name:"adaptive"}]}},{value:"seedance20",name:"Seedance 2.0",resultVideoDemoSrc:"https://resource.cometapi.com/Seedance%202.0.webp",description:"Highest quality, 5-15s, No Watermark",imageNumberLimit:7,durationStyle:"huadongtiao",durationMin:4,durationMax:15,durationDefault:10,resolutionSelect:{label:"Resolution",description:"Select Video resolution",defaultValue:"720p",is_hide:!1,items:[{value:"480p",name:"480p"},{value:"720p",name:"720p"},{value:"1080p",name:"1080p"}]}},{value:"seedance20-fast",name:"Seedance 2.0 Fast",resultVideoDemoSrc:"https://resource.cometapi.com/Seedance%202.0.webp",description:"High quality, 5-15s, No Watermark",imageNumberLimit:7,durationStyle:"huadongtiao",durationMin:4,durationMax:15,durationDefault:10,resolutionSelect:{label:"Resolution",description:"Select Video resolution",defaultValue:"720p",is_hide:!1,items:[{value:"720p",name:"720p"},{value:"480p",name:"480p"}]}},{value:"veo3",name:"veo 3.1",description:"High quality, No Watermark",imageNumberLimit:3},{value:"veo3_lite",name:"veo3.1 lite",description:"normal quality, No Watermark",imageNumberLimit:3,resultVideoDemoSrc:"https://roomai.link/appuse/ai-video/free-ai-video.png"},{value:"kling3",name:"Kling 3.0",description:"High quality, 5-15s, No Watermark",imageNumberLimit:1}]}},71040:(e,t,a)=>{a.d(t,{default:()=>$});var r=a(68812),s=a(51456),l=a(13910),i=a(99678),o=a(82923),n=a(62692),d=a(25594),c=a(87004),u=a(22346),m=a(91987),p=a(44578),x=a(33493),h=a(8871),f=a(70828),v=a(42084),g=a(68708),b=a(54702),j=a(29201),y=a(93822),N=a(37685),w=a(50283),k=a(71563),S=a(93546),C=a(92766),R=a(81254),A=a(45599),P=a(4337),I=a(65688),E=a(88964),L=a(32952);let M="__custom__";function V(e){let{open:t,productImage:a,analysis:o,onSkip:n,onConfirm:d,onClose:c}=e,[u,p]=(0,s.useState)(0),[f,v]=(0,s.useState)(""),[g,b]=(0,s.useState)(""),[j,y]=(0,s.useState)([]),[w,k]=(0,s.useState)([]),[S,C]=(0,s.useState)("");if((0,s.useEffect)(()=>{var e;if(!t||!o)return;p(0);let a=o.audience_vibes.find(e=>e.recommended);v((null==a?void 0:a.label)||(null===(e=o.audience_vibes[0])||void 0===e?void 0:e.label)||""),b(""),y(o.selling_points.map(e=>e.label)),k([]),C("")},[t,o]),!t||!o)return null;let R=f===M?g.trim():f.trim(),A=e=>{y(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},P=()=>{let e=S.trim();""!==e&&(w.includes(e)||o.selling_points.some(t=>t.label===e)||k(t=>[...t,e]),y(t=>t.includes(e)?t:[...t,e]),C(""))},I=0===u?""!==R:j.length>0;return(0,r.jsx)("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm flex items-center justify-center z-50",children:(0,r.jsxs)("div",{className:"bg-white dark:bg-gray-900 rounded-lg shadow-xl w-full max-w-2xl max-h-[85vh] m-4 flex flex-col overflow-hidden",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3 px-5 py-4 border-b",children:[a&&(0,r.jsx)("img",{src:a,alt:"Product",className:"w-10 h-10 rounded-md object-cover border flex-shrink-0"}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1.5 font-semibold text-sm truncate",children:[(0,r.jsx)(E.A,{className:"h-4 w-4 text-primary flex-shrink-0"}),(0,r.jsx)("span",{className:"truncate",children:o.product_name})]}),(0,r.jsxs)("p",{className:"text-xs text-muted-foreground mt-0.5",children:["Step ",u+1," of ",2," â confirm a few facts so the ad stays accurate"]})]}),(0,r.jsx)("button",{type:"button",onClick:n,className:"text-xs text-muted-foreground hover:text-foreground underline underline-offset-2 flex-shrink-0",children:"Skip â let AI decide"}),(0,r.jsx)("button",{type:"button",onClick:c,"aria-label":"Close",title:"Close",className:"p-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-accent flex-shrink-0 transition-colors",children:(0,r.jsx)(x.A,{className:"h-4 w-4"})})]}),(0,r.jsxs)("div",{className:"flex-1 overflow-y-auto px-5 py-4 space-y-4",children:[0===u&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h3",{className:"font-medium text-sm",children:"Who should this ad speak to?"}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:"AI analyzed your product image and suggests these audience directions. Pick one â it guides the casting, scenes and tone."})]}),(0,r.jsxs)("div",{className:"space-y-2",children:[o.audience_vibes.map(e=>{let t=f===e.label;return(0,r.jsxs)("button",{type:"button",onClick:()=>v(e.label),className:"w-full text-left rounded-lg border p-3 transition-colors ".concat(t?"border-primary bg-primary/5 ring-1 ring-primary":"hover:bg-accent"),children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"text-sm font-medium ".concat(t?"text-primary":""),children:e.label}),e.recommended&&(0,r.jsx)("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full bg-primary/10 text-primary font-medium",children:"Recommended"}),t&&(0,r.jsx)(N.A,{className:"h-4 w-4 text-primary ml-auto"})]}),e.description&&(0,r.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:e.description})]},e.label)}),(0,r.jsx)("button",{type:"button",onClick:()=>v(M),className:"w-full text-left rounded-lg border border-dashed p-3 text-xs transition-colors ".concat(f===M?"border-primary bg-primary/5 ring-1 ring-primary":"hover:bg-accent"),children:"Write my own audie
1nce..."}),f===M&&(0,r.jsx)(i.p,{value:g,onChange:e=>b(e.target.value),placeholder:'e.g., "Busy urban millennials who treat their pets as family"',autoFocus:!0,className:"text-xs"})]})]}),1===u&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h3",{className:"font-medium text-sm",children:"What should the ad highlight?"}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:"Select the selling points to feature (at least one). Points from your idea are marked â¦, your own additions are marked â."})]}),(0,r.jsxs)("div",{className:"flex flex-wrap gap-2",children:[o.selling_points.map(e=>{let t=j.includes(e.label);return(0,r.jsxs)("button",{type:"button",onClick:()=>A(e.label),className:"rounded-full border px-3 py-1.5 text-xs transition-colors ".concat(t?"border-primary bg-primary/10 text-primary font-medium":"text-muted-foreground hover:bg-accent"),children:[e.label,e.from_user_idea?" â¦":""]},e.label)}),w.map(e=>{let t=j.includes(e);return(0,r.jsxs)("button",{type:"button",onClick:()=>A(e),className:"rounded-full border px-3 py-1.5 text-xs transition-colors ".concat(t?"border-primary bg-primary/10 text-primary font-medium":"text-muted-foreground hover:bg-accent"),children:[e," â"]},e)})]}),(0,r.jsx)("p",{className:"text-[11px] text-muted-foreground",children:"⦠= extracted from your idea \xb7 â = added by you"}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(i.p,{value:S,onChange:e=>C(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),P())},placeholder:"Add your own selling point...",className:"text-xs"}),(0,r.jsxs)(l.$,{type:"button",variant:"outline",size:"sm",onClick:P,disabled:""===S.trim(),className:"flex-shrink-0",children:[(0,r.jsx)(h.A,{className:"h-3.5 w-3.5 mr-1"}),"Add"]})]})]})]}),(0,r.jsxs)("div",{className:"flex items-center justify-between px-5 py-3 border-t bg-muted/20",children:[(0,r.jsx)("div",{className:"text-xs text-muted-foreground",children:(0,r.jsx)("button",{type:"button",onClick:n,className:"underline underline-offset-2 hover:text-foreground",children:"Skip â let AI decide"})}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[u>0&&(0,r.jsxs)(l.$,{variant:"outline",size:"sm",onClick:()=>p(u-1),children:[(0,r.jsx)(L.A,{className:"h-4 w-4 mr-1"}),"Back"]}),1===u?(0,r.jsxs)(l.$,{size:"sm",disabled:!I,onClick:()=>{d({productName:o.product_name,productType:o.product_type,audienceVibe:R,sellingPoints:j.length>0?j:o.selling_points.map(e=>e.label)})},children:[(0,r.jsx)(N.A,{className:"h-4 w-4 mr-1"}),"Confirm & Create"]}):(0,r.jsxs)(l.$,{size:"sm",disabled:!I,onClick:()=>p(u+1),children:["Continue",(0,r.jsx)(m.A,{className:"h-4 w-4 ml-1"})]})]})]})]})})}var _=a(90627);let z=()=>{let e=window.location.pathname.split("/").filter(Boolean);return e.length>0&&_.IB.includes(e[0])&&e.shift(),e.join("/")||"/"},T=e=>e&&I.y.items.some(t=>t.value===e)?e:I.y.defaultValue,F={ads:{title:"AI Ads Video Generator",description:"Turn your product image into stunning video Ads"},movie:{title:"AI Story Video Creator",description:"Turn your story idea into a cinematic video"},"math-video":{title:"AI Math Video Generator",description:"Turn math problems into engaging video tutorials."},"principle-video":{title:"3D Science Video Generator",description:"Convert scientific principles into engaging three-dimensional animated visualizations."},"product-image":{title:"AI Product Image Generator",description:"Turn your product image into stunning product photos"},"product-show-photo":{title:"AI Product Show Photo Generator",description:"Turn your product image into eye-catching show photos"}},D={ads:"Describe your product information,brand name and creative idea in detail,the more detailed your description, the better the AI-generated script","product-image":"Describe your product information,brand name and creative idea in detail,the more detailed your description, the better the AI-generated product photos","product-show-photo":"Describe your product information,brand name and creative idea in detail,the more detailed your description, the better the AI-generated show photos",movie:"Describe your story idea in detail (characters, setting, plot and tone),the more detailed your description, the better the AI-generated cinematic video","math-video":"Describe the math topic or problem in detail (the concept to explain, grade level and examples),the more detailed your description, the better the AI-generated video","principle-video":"Describe the scientific principle in detail (the concept to explain, key mechanisms and real-world examples),the more detailed your description, the better the AI-generated 3D animation"},U=[{value:"auto",label:"Auto"},...[5,10,15,20,25,30,35,40,45,50].map(e=>({value:"".concat(e,"s"),label:"".concat(e,"s")})),...[1,2,3,4,5,6,7,8,9,10].map(e=>({value:"".concat(60*e,"s"),label:"".concat(e,"min")}))];function $(e){var t,a,E,L;let{texts:M,className:_="",initialUserIdea:$="",initialAspectRatio:B="16:9",initialImage:W="",modelName:J,title:O,description:q,projectype:H,initialLanguage:G="English",onCreated:X,openNewTab:Z=!0,templateProject:K}
1=e,Q=(0,C.useRouter)(),{data:Y}=(0,S.wV)(),[ee,et]=(0,s.useState)("auto"),[ea,er]=(0,s.useState)(!1),es=!!K,el=H&&""!==H.trim()?H:(null==M?void 0:M.projectype)||"ads",ei=null!==(E=F[el])&&void 0!==E?E:F.ads,eo=null!==(L=D[el])&&void 0!==L?L:D.ads,en="ads"===el||"product-image"===el||"product-show-photo"===el,ed=en||"movie"===el,ec="movie"===el,[eu,em]=(0,s.useState)({projectName:"",userIdea:$,aspectRatio:es&&(null==K?void 0:K.aspectratio)||B,language:es&&(null==K?void 0:K.language)||G}),[ep,ex]=(0,s.useState)(es&&(null==K?void 0:K.duration)||"auto"),[eh,ef]=(0,s.useState)(es&&(null==K?void 0:K.resolution)||""),[ev,eg]=(0,s.useState)(()=>T(es&&(null==K?void 0:K.modelname)||J));(0,s.useEffect)(()=>{eg(T(J))},[J]);let[eb,ej]=(0,s.useState)(!1),[ey,eN]=(0,s.useState)(!1),ew=(0,s.useRef)(null),ek=(0,s.useRef)(0),eS=(0,s.useRef)(0),eC=(0,s.useRef)(null),eR=(0,s.useRef)(0),eA=(0,s.useRef)({active:!1,startX:0,startOffset:0,hasMoved:!1}),eP=(0,s.useRef)(!1),eI=(0,s.useRef)(!1),eE=I.y.items.length>2;(0,s.useEffect)(()=>{if(!eE)return;let e=t=>{let a=ew.current;if(eS.current<=0&&a){let e=a.scrollWidth/2;e>0&&(eS.current=e)}if(!a||eS.current<=0||eb||eA.current.active){eC.current=requestAnimationFrame(e);return}let r=eR.current?(t-eR.current)/1e3:0;eR.current=t,ek.current-=65*r;let s=eS.current;for(;ek.current<=-s;)ek.current+=s;for(;ek.current>=0;)ek.current-=s;a.style.transform="translateX(".concat(ek.current,"px)"),eC.current=requestAnimationFrame(e)};return eC.current=requestAnimationFrame(e),()=>{null!=eC.current&&cancelAnimationFrame(eC.current),eC.current=null}},[eE,eb]);let eL=e=>{let t=eA.current;if(!t.active)return;let a=e-t.startX;Math.abs(a)>5&&(t.hasMoved=!0);let r=t.startOffset+a;ek.current=r,ew.current&&(ew.current.style.transform="translateX(".concat(r,"px)"))},eM=()=>{let e=eA.current;if(!e.active)return;e.active=!1,eN(!1),e.hasMoved&&(eP.current=!0);let t=ek.current,a=eS.current;if(a>0){for(;t<-a;)t+=a;for(;t>=0;)t-=a;ek.current=t,ew.current&&(ew.current.style.transform="translateX(".concat(t,"px)"))}},eV=e=>{if(eP.current){eP.current=!1;return}eg(e)},[e_,ez]=(0,s.useState)(!1),eT=(0,s.useRef)(null);(0,s.useEffect)(()=>{if(!e_)return;let e=e=>{var t,a;let r=e.target;!(!r||(null===(t=eT.current)||void 0===t?void 0:t.contains(r)))&&(null!==(a=r.closest)&&void 0!==a&&a.call(r,"[data-radix-popper-content-wrapper]")||ez(!1))};return document.addEventListener("mousedown",e),document.addEventListener("touchstart",e),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("touchstart",e)}},[e_]);let eF=I.y.items.find(e=>e.value===ev),eD=null==eF?void 0:eF.aspectRatioSelect,eU=(null==eD?void 0:null===(t=eD.items)||void 0===t?void 0:t.length)?eD.items:[{value:"16:9",name:"16:9"},{value:"9:16",name:"9:16"}],e$=(null==eF?void 0:eF.resolutionSelect)||(null==eF?void 0:eF["resolutionSelect-n"]),eB=(null===(a=U.find(e=>e.value===ep))||void 0===a?void 0:a.label)||ep;(0,s.useEffect)(()=>{let e=(null==eD?void 0:eD.defaultValue)||"16:9";eU.some(e=>e.value===eu.aspectRatio)||em(t=>({...t,aspectRatio:eU.some(t=>t.value===e)?e:eU[0].value}));let t=(null==e$?void 0:e$.items)||[];if(t.length>0){let e=(null==e$?void 0:e$.defaultValue)||t[0].value;t.some(e=>e.value===eh)||ef(t.some(t=>t.value===e)?e:t[0].value)}else ef("")},[ev]);let[eW,eJ]=(0,s.useState)(W),[eO,eq]=(0,s.useState)(""),[eH,eG]=(0,s.useState)(!1),[eX,eZ]=(0,s.use
1State)(!1),[eK,eQ]=(0,s.useState)(!1),[eY,e0]=(0,s.useState)(""),[e1,e2]=(0,s.useState)(""),[e4,e5]=(0,s.useState)(!1),[e6,e3]=(0,s.useState)(null),[e8,e9]=(0,s.useState)({}),[e7,te]=(0,s.useState)(""),[tt,ta]=(0,s.useState)(null),[tr,ts]=(0,s.useState)(!1),[tl,ti]=(0,s.useState)(!1),to=()=>{let e={};return es||eu.userIdea.trim()||(e.userIdea=(null==M?void 0:M.validationUserIdeaEmpty)||"Your Idea is required"),en&&!eW.trim()&&(e.productImage="Product image is required"),e9(e),0===Object.keys(e).length},tn=async e=>{e5(!0);try{let t=await fetch(es?"/api/ai-ads-video/recreate":"/api/ai-ads-video/create",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(es?{templateProjectId:null==K?void 0:K.id,productImage:eW,idea:eu.userIdea.trim(),avatarImage:eO||null,modelname:ev,aspectratio:eu.aspectRatio,resolution:eh,language:eu.language,pagepath:z()}:{priname:eu.projectName.trim(),useridea:eu.userIdea.trim(),aspectratio:eu.aspectRatio,duration:ep,resolution:eh,language:eu.language,projectype:el,modelname:ev,pagepath:z(),images:JSON.stringify({productImage:en?eW:null,avatarImage:eO||null,...e?{productSetup:e}:{}})})}),a=await t.json();if(401===t.status){k.oR.error((null==M?void 0:M.loginRequired)||"Please login first"),(0,S.Jv)();return}if(es&&402===t.status){k.oR.error(a.error||"Not enough credits, please recharge"),window.open("/price","_blank");return}if(!a.success){k.oR.error(a.error||(null==M?void 0:M.createError)||"Failed to create project");return}let r=a.data;k.oR.success((null==M?void 0:M.createSuccess)||"Project created successfully!"),X&&X(r,ee),Z&&window.open("/ai-ads-video/projectgen?projectId=".concat(r.id).concat("auto"===ee?"&auto=1":""),"_blank")}catch(e){console.error("Error creating project:",e),k.oR.error((null==M?void 0:M.createError)||"Failed to create project")}finally{e5(!1)}},td=async()=>{let e=ev.toLowerCase().includes("free");if(!Y&&(es||!e)){k.oR.error((null==M?void 0:M.loginRequired)||"Please login first"),(0,S.Jv)();return}if(!to()){k.oR.error("Please fix the form errors");return}await tn(null)},tc=e=>{em(t=>({...t,projectName:e.name,userIdea:e.idea})),te(e.name),e9({})},tu=(e,t)=>{e0(e),e2(t),eQ(!0)},tm=()=>{eQ(!1),e0(""),e2("")};if(e6)return(0,r.jsx)("div",{className:"py-6 ".concat(_),children:(0,r.jsx)("div",{className:"w-full max-w-4xl mx-auto",children:(0,r.jsxs)(c.Zp,{className:"border-green-200 bg-green-50 dark:bg-green-900/20",children:[(0,r.jsxs)(c.aR,{className:"text-center",children:[(0,r.jsx)("div",{className:"mx-auto mb-4 flex h-16 w-16 items-center justify-center rounded-full bg-green-100 dark:bg-green-900",children:(0,r.jsx)(u.A,{className:"h-8 w-8 text-green-600"})}),(0,r.jsx)(c.ZB,{className:"text-green-800 dark:text-green-200",children:(null==M?void 0:M.projectCreatedTitle)||"Project Created Successfully!"}),(0,r.jsx)(c.BT,{className:"text-green-600 dark:text-green-300",children:(null==M?void 0:M.projectCreatedDescription)||"AI has generated a complete video script based on your creative idea"})]}),(0,r.jsxs)(c.Wu,{className:"space-y-6",children:[(0,r.jsxs)("div",{className:"rounded-lg border border-green-200 bg-white p-4 dark:bg-green-900/10",children:[(0,r.jsx)("h3",{className:"font-semibold text-green-800 dark:text-green-200 mb-2",children:e6.priname}),(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-4 text-sm text-green-600 dark:text-green-300",children:[(0,r.jsxs)("div",{children:[(0,r.jsxs)("span",{className:"font-medium",children:[null==M?void 0:M.aspectRatioLabel,":"]})," ",e6.aspectratio]}),(0,r.jsxs)("div",{children:[(0,r.jsxs)("span",{className:"font-medium",children:[null==M?void 0:M.durationLabel,":"]}
1)," ",e6.duration]})]})]}),e6.script&&(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(n.J,{className:"text-green-800 dark:text-green-200",children:(null==M?void 0:M.generatedScriptLabel)||"Generated Video Script"}),(0,r.jsx)("div",{className:"rounded-lg border border-green-200 bg-white p-4 dark:bg-green-900/10",children:(0,r.jsx)("pre",{className:"whitespace-pre-wrap text-sm text-green-700 dark:text-green-300",children:e6.script})})]}),(0,r.jsxs)("div",{className:"flex flex-col sm:flex-row gap-3",children:[(0,r.jsxs)(l.$,{onClick:()=>Q.push("/myallcreations"),className:"flex-1",children:[(0,r.jsx)(m.A,{className:"mr-2 h-4 w-4"}),(null==M?void 0:M.viewProjectButton)||"View Project Details"]}),(0,r.jsxs)(l.$,{variant:"outline",onClick:()=>{window.open("/ai-short-video/myprojects","_blank")},className:"flex-1",children:[(0,r.jsx)(p.A,{className:"mr-2 h-4 w-4"}),(null==M?void 0:M.createNewProjectButton)||"Create New Project"]})]})]})]})})});let tp=(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(n.J,{htmlFor:"avatarImage",children:"Avatar Image(Optional)"}),(0,r.jsxs)("div",{className:"flex flex-row flex-wrap gap-2",children:[eO&&(0,r.jsxs)("div",{className:"relative flex-shrink-0 w-[60px] h-[80px] rounded-md border overflow-hidden bg-muted",children:[(0,r.jsx)("img",{src:eO,alt:"Avatar",className:"w-full h-full object-cover cursor-pointer hover:opacity-80 transition-opacity",onClick:()=>tu(eO,"Avatar Image")}),(0,r.jsx)(l.$,{type:"button",variant:"destructive",size:"icon",className:"absolute top-0.5 right-0.5 w-4 h-4",onClick:()=>eq(""),children:(0,r.jsx)(x.A,{className:"h-2.5 w-2.5"})})]}),(0,r.jsxs)(l.$,{type:"button",variant:"outline",className:"w-[60px] h-[80px] flex-shrink-0 border-dashed rounded-md flex flex-col gap-0.5",title:"Select Avatar",onClick:()=>eZ(!0),disabled:e4,children:[(0,r.jsx)(h.A,{className:"h-3.5 w-3.5"}),(0,r.jsx)(f.A,{className:"h-4 w-4 text-muted-foreground"})]}),(0,r.jsxs)(l.$,{type:"button",variant:"outline",className:"w-[60px] h-[80px] flex-shrink-0 border-dashed rounded-md flex flex-col gap-0.5",title:"Generate Avatar",onClick:()=>window.open("/ai-ads-video/ai-avatar-generator","_blank"),disabled:e4,children:[(0,r.jsx)("span",{className:"text-xs",children:"New"}),(0,r.jsx)(v.A,{className:"h-4 w-4 text-muted-foreground"})]})]}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:"Avatar is o
1ptional. If no avatar is selected, the system will automatically generate one"})]});return(0,r.jsxs)("div",{id:"generator",className:"py-6 ".concat(_),children:[(0,r.jsxs)("div",{className:"w-full max-w-3xl mx-auto",children:[(0,r.jsxs)("div",{className:"space-y-6",children:[(0,r.jsxs)(c.Zp,{children:[(0,r.jsxs)(c.aR,{children:[(0,r.jsx)(c.ZB,{children:O||(null==M?void 0:M.formTitle)||(es?"Recreate from Template":ei.title)}),(0,r.jsx)(c.BT,{children:q||(null==M?void 0:M.formDescription)||(es?"Use your own product to recreate this video with the same story and style":ei.description)})]}),(0,r.jsxs)(c.Wu,{className:"space-y-6",children:[(0,r.jsxs)("div",{className:"space-y-2",style:{display:"none"},children:[(0,r.jsxs)(n.J,{htmlFor:"projectName",children:[(null==M?void 0:M.projectNameLabel)||"Project Name"," ",(0,r.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,r.jsx)(i.p,{id:"projectName",value:eu.projectName,onChange:e=>em(t=>({...t,projectName:e.target.value})),placeholder:(null==M?void 0:M.projectNamePlaceholder)||"Give your short video project a name...",disabled:e4,className:e8.projectName?"border-red-500":""}),e8.projectName&&(0,r.jsx)("p",{className:"text-sm text-red-500",children:e8.projectName})]}),(en||ed&&!ec)&&(0,r.jsx)("div",{className:"space-y-4",children:(0,r.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[en&&(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsxs)(n.J,{htmlFor:"productImage",children:["Product Image ",(0,r.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,r.jsxs)("div",{className:"flex flex-row flex-wrap gap-2",children:[eW&&(0,r.jsxs)("div",{className:"relative flex-shrink-0 w-[60px] h-[80px] rounded-md border overflow-hidden bg-muted",children:[(0,r.jsx)("img",{src:eW,alt:"Product",className:"w-full h-full object-cover cursor-pointer hover:opacity-80 transition-opacity",onClick:()=>tu(eW,"Product Image")}),(0,r.jsx)(l.$,{type:"button",variant:"destructive",size:"icon",className:"absolute top-0.5 right-0.5 w-4 h-4",onClick:()=>eJ(""),children:(0,r.jsx)(x.A,{className:"h-2.5 w-2.5"})})]}),(0,r.jsxs)(l.$,{type:"button",variant:"outline",className:"w-[60px] h-[80px] flex-shrink-0 border-dashed rounded-md flex flex-col gap-0.5",title:"Select Product Image",onClick:()=>eG(!0),disabled:e4,children:[(0,r.jsx)(h.A,{className:"h-3.5 w-3.5"}),(0,r.jsx)(f.A,{className:"h-4 w-4 text-muted-foreground"})]})]}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:"Please select a clear product image"}),e8.productImage&&(0,r.jsx)("p",{className:"text-sm text-red-500",children:e8.productImage})]}),ed&&!ec&&tp]})}),(0,r.jsxs)("div",{children:[(0,r.jsxs)(n.J,{htmlFor:"userIdea",className:"mb-2 block",children:[(null==M?void 0:M.userIdeaLabel)||"Your Idea"," ",!es&&(0,r.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,r.jsx)(o.T,{id:"userIdea",value:eu.userIdea,onChange:e=>em(t=>({...t,userIdea:e.target.value})),placeholder:es?"Describe your idea":(null==M?void 0:M.userIdeaPlaceholder)||eo,disabled:e4,rows:6,className:"resize-none ".concat(e8.userIdea?"border-red-500":"")}),e8.userIdea&&(0,r.jsx)("p",{className:"text-sm text-red-500 mt-2",children:e8.userIdea}),(0,r.jsxs)("div",{className:"space-y-2",ref:eT,children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsxs)(d.l6,{value:ev,onValueChange:eg,disabled:e4,children:[(0,r.jsxs)(d.bq,{className:"w-auto h-auto min-h-10 py-1 min-w-[150px] rounded-full bg-muted/30 hover:bg-muted/50 [&>span]:line-clamp-none",children:[(0,r.jsx)(g.A,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),(0,r.jsx)(d.yv,{placeholder:I.y.placeholder})]}),(0,r.jsx)(d.gC,{children:I.y.items.map(e=>(0,r.jsx)(d.eb,{value:e.value,children:(0,r.jsxs)("div",{className:"flex flex-col items-start leading-tight",children:[(0,r.jsx)("span",{className:"text-sm",children:e.name}),e.description&&(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:e.description})]})},e.value))})]}),(0,r.jsx)("div",{className:"relative",children:(0,r.jsxs)("button",{type:"button",className:"flex h-10 items-center gap-1.5 rounded-full bg-muted/30 px-3 text-sm text-muted-foreground transition-colors hover:bg-muted/50 hover:text-foreground disabled:opacity-50",onClick:()=>ez(e=>!e),disabled:e4,children:[(0,r.jsx)(b.A,{className:"h-3.5 w-3.5"}),(0,r.jsx)("span",{children:eu.aspectRatio}),(0,r.jsx)("span",{className:"opacity-40",children:"|"}),(0,r.jsx)("span",{children:eB}
1),e$&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"opacity-40",children:"|"}),(0,r.jsx)("span",{children:eh})]}),(0,r.jsx)("span",{className:"opacity-40",children:"|"}),(0,r.jsx)("span",{children:eu.language})]})})]}),e_&&(0,r.jsxs)("div",{className:"w-full space-y-4 rounded-lg border bg-popover p-4 text-popover-foreground",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsx)("h4",{className:"text-sm font-medium",children:"Video Settings"}),(0,r.jsx)("button",{type:"button",className:"text-muted-foreground hover:text-foreground",onClick:()=>ez(!1),children:(0,r.jsx)(x.A,{className:"h-4 w-4"})})]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(n.J,{className:"text-xs",children:(null==M?void 0:M.aspectRatioLabel)||"Aspect Ratio"}),(0,r.jsx)("div",{className:"flex flex-wrap gap-2",children:eU.map(e=>(0,r.jsx)("button",{type:"button",className:"rounded-md border px-3 py-1.5 text-xs transition-colors ".concat(eu.aspectRatio===e.value?"border shadow-sm bg-background font-medium text-foreground":"bg-transparent text-muted-foreground hover:bg-accent"),onClick:()=>em(t=>({...t,aspectRatio:e.value})),children:e.name},e.value))})]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(n.J,{className:"text-xs",children:(null==M?void 0:M.durationLabel)||"Video Duration"}),es?(0,r.jsxs)("div",{className:"flex h-8 items-center rounded-md border bg-muted/30 px-3 text-xs text-muted-foreground",children:[ep," (from template)"]}):(0,r.jsxs)(d.l6,{value:ep,onValueChange:ex,disabled:e4,children:[(0,r.jsx)(d.bq,{className:"h-8 text-xs",children:(0,r.jsx)(d.yv,{placeholder:"Auto"})}),(0,r.jsx)(d.gC,{children:U.map(e=>(0,r.jsx)(d.eb,{value:e.value,children:e.label},e.value))})]})]}),e$&&(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(n.J,{className:"text-xs",children:e$.label||"Resolution"}),(0,r.jsx)("div",{className:"flex flex-wrap gap-2",children:(e$.items||[]).map(e=>(0,r.jsx)("button",{type:"button",className:"rounded-md border px-3 py-1.5 text-xs transition-colors ".concat(eh===e.value?"border shadow-sm bg-background font-medium text-foreground":"bg-transparent text-muted-foreground hover:bg-accent"),onClick:()=>ef(e.value),children:e.name},e.value))})]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(n.J,{className:"text-xs",children:(null==M?void 0:M.languageLabel)||"Language"}),(0,r.jsxs)(d.l6,{value:eu.language,onValueChange:e=>em(t=>({...t,language:e})),disabled:e4,children:[(0,r.jsx)(d.bq,{className:"h-8 text-xs",children:(0,r.jsx)(d.yv,{placeholder:(null==M?void 0:M.languagePlaceholder)||"Select language"})}),(0,r.jsxs)(d.gC,{children:[(0,r.jsx)(d.eb,{value:"English",children:"English"}),(0,r.jsx)(d.eb,{value:"䏿",children:"䏿"}),(0,r.jsx)(d.eb,{value:"æ¥æ¬èª",children:"æ¥æ¬èª"}),(0,r.jsx)(d.eb,{value:"íêµì´",children:"íêµì´"}),(0,r.jsx)(d.eb,{value:"Espa\xf1ol",children:"Espa\xf1ol"}),(0,r.jsx)(d.eb,{value:"Fran\xe7ais",children:"Fran\xe7ais"}),(0,r.jsx)(d.eb,{value:"Deutsch",children:"Deutsch"}),(0,r.jsx)(d.eb,{value:"Portugu\xeas",children:"Portugu\xeas"}),(0,r.jsx)(d.eb,{value:"Italiano",children:"Italiano"}),(0,r.jsx)(d.eb,{value:"Ð ÑÑÑкий",children:"Ð ÑÑÑкий"}),(0,r.jsx)(d.eb,{value:"Ø§ÙØ¹Ø±Ø¨ÙØ©",children:"Ø§ÙØ¹Ø±Ø¨ÙØ©"}),(0,r.jsx)(d.eb,{value:"हिनà¥à¤¦à¥",children:"हिनà¥à¤¦à¥"}),(0,r.jsx)(d.eb,{value:"à¹à¸à¸¢",children:"à¹à¸à¸¢"}),(0,r.jsx)(d.eb,{value:"Tiếng Viá»t",children:"Tiếng Viá»t"})]})]})]})]}),eE&&(0,r.jsx)("div",{className:"overflow-hidden contain-[inline-size] w-full max-w-full rounded-md bg-muted/30 py-0 select-none touch-none ".concat(ey?"cursor-grabbing":"cursor-grab"),onMouseEnter:()=>ej(!0),onMouseLeave:()=>ej(!1),onMouseDown:e=>{if(eI.current)return;eA.current={active:!0,startX:e.clientX,startOffset:ek.current,hasMoved:!1},eN(!0);let t=e=>eL(e.clientX),a=()=>{eM(),window.removeEventListener("mousemove",t),window.removeEventListener("mouseup",a)};window.addEventListener("mousemove",t),window.addEventListener("mouseup",a)},onTouchStart:e=>{eI.current=!0;let t=e.touches[0];if(!t)return;eA.current={active:!0,startX:t.clientX,startOffset:ek.current,hasMoved:!1},eN(!0);let a=e=>{var t;e.preventDefault();let a=null===(t=e.touches[0])||void 0===t?void 0:t.clientX;null!=a&&eL(a)},r=()=>{eM(),window.removeEventListener("touchmove",a,{capture:!0}),window.removeEventListener("touchend",r,!0),setTimeout(()=>{eI.current=!1},400)};window.addEventListener("touchmove",a,{passive:!1,capture:!0}),window.addEventListener("touchend",r,!0)},children:(0,r.jsx)("div",{ref:ew,className:"flex flex-nowrap gap-6 w-max",children:[...I.y.items,...I.y.items].map((e,t)=>(0,r.jsx)("button",{type:"button",className:"shrink-0 whitespace-nowrap px-2 py-1 text-xs text-muted-foreground rounded transition-colors hover:bg-primary/20 hover:text-foreground cursor-pointer data-[current=true]:text-primary data-[current=true]:font-medium","data-current":e.value===ev?"true":void 0,onClick:()=>eV(e.value),children:e.name},"".concat(e.value,"-").concat(t)))})})]})]}),ec&&tp,(0,r.jsx)("div",{className:"flex flex-col sm:flex-row gap-3 pt-4 border-t",children:(0,r.jsxs)("div",{className:"flex items-center gap-3 flex-1",children:[(0,r.jsxs)("div",{className:"relative shrink-0",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>er(e=>!e),disabled:e4,className:"flex items-center gap-2 rounded-md border border-input bg-background px-3 py-2 text-sm font-medium hover:bg-accent hover:text-accent-foreground disabled:opacity-50",children:["auto"===ee?(0,r.jsx)(j.A,{className:"h-4 w-4"}):(0,r.jsx)(y.A,{className:"h-4 w-4"}),"auto"===ee?"Auto":"Plan"]}),ea&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"fixed inset-0 z-40",onClick:()=>er(!1)}),(0,r.jsxs)("div",{className:"absolute bottom-full left-0 z-50 mb
1-2 w-64 rounded-xl border border-border bg-popover p-1.5 shadow-xl",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>{et("auto"),er(!1)},className:"flex w-full items-start gap-2.5 rounded-lg px-3 py-2.5 text-left text-sm hover:bg-accent ".concat("auto"===ee?"bg-accent":""),children:[(0,r.jsx)(j.A,{className:"mt-0.5 h-4 w-4 shrink-0"}),(0,r.jsxs)("span",{className:"flex-1",children:[(0,r.jsx)("span",{className:"block font-medium",children:"Auto Mode"}),(0,r.jsx)("span",{className:"block text-xs text-muted-foreground",children:"Creates without check-ins"})]}),"auto"===ee&&(0,r.jsx)(N.A,{className:"mt-0.5 h-4 w-4 shrink-0"})]}),(0,r.jsxs)("button",{type:"button",onClick:()=>{et("plan"),er(!1)},className:"flex w-full items-start gap-2.5 rounded-lg px-3 py-2.5 text-left text-sm hover:bg-accent ".concat("plan"===ee?"bg-accent":""),children:[(0,r.jsx)(y.A,{className:"mt-0.5 h-4 w-4 shrink-0"}),(0,r.jsxs)("span",{className:"flex-1",children:[(0,r.jsx)("span",{className:"block font-medium",children:"Plan Mode"}),(0,r.jsx)("span",{className:"block text-xs text-muted-foreground",children:"Waits for your go-ahead"})]}),"plan"===ee&&(0,r.jsx)(N.A,{className:"mt-0.5 h-4 w-4 shrink-0"})]})]})]})]}),(0,r.jsx)(l.$,{onClick:td,disabled:e4||tl,className:"flex-1",children:tl?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(w.A,{className:"mr-2 h-4 w-4 animate-spin"}),"Analyzing your product..."]}):e4?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(w.A,{className:"mr-2 h-4 w-4 animate-spin"}),(null==M?void 0:M.creatingButton)||"AI is generating script..."]}):(null==M?void 0:M.createButton)||"Generate"})]})}),(e4||tl)&&(0,r.jsx)("div",{className:"rounded-lg border border-blue-200 bg-blue-50 p-4 dark:bg-blue-900/20",children:(0,r.jsxs)("div",{className:"flex items-center space-x-3",children:[(0,r.jsx)(w.A,{className:"h-5 w-5 animate-spin text-blue-600"}),(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"font-medium text-blue-800 dark:text-blue-200",children:tl?"\uD83D\uDD0D AI is analyzing your product image":(null==M?void 0:M.generatingScript)||"\uD83E\uDD16 AI is crafting a custom video script for you"}),(0,r.jsx)("p",{className:"text-sm text-blue-600 dark:text-blue-300",children:tl?"Identifying audience, selling points and usage â just a few seconds...":(null==M?void 0:M.generatingScriptTip)||"This may take 10-30 seconds, please be patient..."})]})]})})]})]}),(null==M?void 0:M.examples)&&(null==M?void 0:M.examples.length)>0&&(0,r.jsxs)(c.Zp,{children:[(0,r.jsx)(c.aR,{children:(0,r.jsx)(c.ZB,{className:"text-lg",children:(null==M?void 0:M.exampleTitle)||"Creative Examples"})}),(0,r.jsx)(c.Wu,{className:"space-y-3",children:null==M?void 0:M.examples.map((e,t)=>(0,r.jsxs)("div",{className:"cursor-pointer rounded-lg border p-3 transition-colors hover:bg-accent ".concat(e7===e.name?"border-primary bg-accent":""),onClick:()=>tc(e),children:[(0,r.jsx)("h4",{className:"font-medium text-sm",children:e.name}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground mt-1 line-clamp-3",children:e.idea})]},t))})]}),(null==M?void 0:M.helpItems)&&(null==M?void 0:M.helpItems.length)>0&&(0,r.jsxs)(c.Zp,{children:[(0,r.jsxs)(c.aR,{children:[(0,r.jsx)(c.ZB,{className:"text-lg",children:(null==M?void 0:M.helpTitle)||"How to Create Quality Projects?"}),(0,r.jsx)(c.BT,{children:(null==M?void 0:M.helpDescription)||"Follow these suggestions for better results"})]}),(0,r.jsx)(c.Wu,{className:"space-y-4",children:null==M?void 0:M.helpItems.map((e,t)=>(0,r.jsxs)("div",{className:"flex space-x-3",children:[(0,r.jsx)("div",{className:"flex-shrink-0 w-6 h-6 rounded-full bg-primary/10 flex items-center justify-center",children:(0,r.jsx)("span",{className:"text-xs font-medium text-primary",children:t+1})}),(0,r.jsxs)("div",{children:[(0,r.jsx)("h4",{className:"font-medium text-sm",children:e.title}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:e.description})]})]},t))})]})]}),(null==M?void 0:M.isShowEffects)&&(0,r.jsx)("div",{className:"mt-8",children:(0,r.jsx)(P.default,{type:"video",apptype:(null==M?void 0:M.effectsApptype)||"common",isnoshowclass:!0,example:{showNumInLine
1:4}})}),(null==M?void 0:M.exampleVideoPrompt)&&(0,r.jsx)("div",{className:"mt-8",children:(0,r.jsx)(A.default,{videos:[],example:M.exampleVideoPrompt})})]}),(0,r.jsx)(V,{open:tr,productImage:eW,analysis:tt,onSkip:()=>{ts(!1),tn(null)},onConfirm:e=>{ts(!1),tn(e)},onClose:()=>ts(!1)}),eH&&(0,r.jsx)("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm flex items-center justify-center z-50",children:(0,r.jsx)("div",{className:"bg-white rounded-lg shadow-xl max-w-4xl w-full max-h-[80vh] m-4",children:(0,r.jsx)(R.A,{onSelect:e=>{eJ(e),eG(!1),e8.productImage&&e9(e=>({...e,productImage:""}))},onClose:()=>eG(!1),acceptTypes:"image"})})}),eX&&(0,r.jsx)("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm flex items-center justify-center z-50",children:(0,r.jsx)("div",{className:"bg-white rounded-lg shadow-xl max-w-4xl w-full max-h-[80vh] m-4",children:(0,r.jsx)(R.A,{onSelect:e=>{eq(e),eZ(!1)},onClose:()=>eZ(!1),acceptTypes:"image"})})}),eK&&(0,r.jsx)("div",{className:"fixed inset-0 bg-black/80 backdrop-blur-sm flex items-center justify-center z-50",onClick:tm,children:(0,r.jsxs)("div",{className:"relative max-w-4xl max-h-[90vh] mx-4",onClick:e=>e.stopPropagation(),children:[(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)("img",{src:eY,alt:e1,className:"max-w-full max-h-[90vh] object-contain rounded-lg shadow-2xl"}),(0,r.jsx)(l.$,{variant:"secondary",size:"sm",className:"absolute top-2 right-2 h-8 w-8 p-0 bg-black/50 hover:bg-black/70 text-white border-0",onClick:tm,children:(0,r.jsx)(x.A,{className:"h-4 w-4"})})]}),(0,r.jsx)("div",{className:"absolute bottom-2 left-2 bg-black/50 text-white px-3 py-1 rounded text-sm",children:e1})]})})]})}},81254:(e,t,a)=>{a.d(t,{A:()=>p});var r=a(68812),s=a(51456),l=a(13910),i=a(33493),o=a(50498),n=a(9458),d=a(94106),c=a(70828),u=a(71563),m=a(93546);function p(e){let{onSelect:t,onClose:a,imageLibrary:p,acceptTypes:x="both",videoMaxSizeMB:h=15,modelName:f}=e,[v,g]=(0,s.useState)([]),[b,j]=(0,s.useState)([]),[y,N]=(0,s.useState)("upload"),[w,k]=(0,s.useState)(1),[S]=(0,s.useState)(20),[C,R]=(0,s.useState)(0),[A,P]=(0,s.useState)(!1),[I,E]=(0,s.useState)(!1),[L,M]=(0,s.useState)(!1),V=(0,s.useRef)(null),_=(0,s.useRef)(null),z=async()=>{P(!0),g([]);let e=await fetch("/api/upload-image-todb?page=".concat(w,"&pageSize=").concat(S));if(401===e.status){u.oR.error((null==p?void 0:p.errorNoCredit)||"Please login first"),(0,m.Jv)();return}if(402===e.status){u.oR.error("Not enough credits"),u.oR.error((null==p?void 0:p.errorNoCredit)||"Not enough credits, please recharge"),window.open("/price","_blank");return}let t=await e.json();g(t.data||[]),R(t.total||0),P(!1)},T=async()=>{P(!0),j([]);try{let e=new URL("/api/videos",window.location.origin);e.searchParams.set("page",w.toString()),e.searchParams.set("limit",S.toString()),"image"===x?e.searchParams.set("type","image"):"video"===x?e.searchParams.set("type","video"):"audio"===x&&e.searchParams.set("type","audio");let t=await fetch(e.toString());if(401===t.status){u.oR.error((null==p?void 0:p.errorNoCredit)||"Please login first"),(0,m.Jv)();return}if(402===t.status){u.oR.error("Not enough credits"),u.oR.error((null==p?void 0:p.errorNoCredit)||"Not enough credits, please recharge"),window.open("/price","_blank");return}if(!t.ok){let e=await t.json().catch(()=>({error:"Failed to load generated files"}));u.oR.error(e.error||"Failed to load generated files (status: ".concat(t.status,")")),j([]),P(!1);return}let a=await t.json();if(a.success&&a.data&&a.data.videos){let e=a.data.videos.filter(e=>"success"===e.status&&e.url);j(e),R(a.data.totalCount||0)}else u.oR.error(a.error||"Failed to load generated files"),j([])}catch(e){console.error("Error fetching generated files:",e),j([]),u.oR.error("A network error occurred while fetching generated files")}finally{P(!1)}};(0,s.useEffect)(()=>{"upload"===y?z():T()},[w,y,x]);let F=e=>e.match(/\.(jpg|jpeg|png|gif|bmp|webp|svg|tiff|ico)$/i),D=e=>e.match(/\.(mp4|webm|mov|avi|mkv|m4v|3gp|flv|wmv|ogv)$/i),U=e=>e.match(/\.(mp3|wav|m4a|aac|flac|ogg|opus|wma)$/i),$=()=>{if("upload"!==y)return b.map(e=>({id:e.id,url:e.url||"",user_uuid:e.user_uuid,created_at:e.created_at,assetid:void 0}));switch(x){case"image":return v.filter(e=>F(e.url));case"video":return v.filter(e=>D(e.url));case"audio":return v.filter(e=>U(e.url));default:return v}},B=e=>{N(e),k(1),g([]),j([])},W=e=>{let t=e.type.startsWith("image/"),a=e.type.startsWith("video/"),r=e.type.startsWith("audio/");switch(x){case"image":return t;case"video":return a;case"audio":return r;default:return t||a||r}},J=()=>{switch(x){case"image":return"image";case"video":return"video";case"audio":return"audio";default:return"both"}},O=async e=>{var t;let a=null===(t=e.target.files)||void 0===t?void 0:t[0];a&&(await H(a,!1),V.current&&(V.current.value=""))},q=async e=>{var t;let a=null===(t=e.target.files)||void 0===t?void 0:t[0];a&&(await H(a,!0),_.current&&(_.current.value=""))},H=async(e,t)=>{let a=t?M:E;if(!W(e)){u.oR.error("Please upload a ".concat(J()," file"));return}let r=(e.type.startsWith("video/"),1024*h*1024);if(e.size>r){let t=(e.type.startsWith("video/"),"".concat(h,"MB"));u.oR.error("File size must not exceed ".concat(t));return}a(!0);try{let a=await fetch("/api/upload-presigned",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({fileName:e.name,contentType:e.type,size:e.size})});if(401===a.status){u.oR.error((null==p?void 0:p.errorNoCredit)||"Please login first"),(0,m.Jv)();return}if(402===a.status){u.oR.error((null==p?void 0:p.errorNoCredit)||"Not enough credits, please recharge"),window.open("/price","_blank");return}let r=await a.json().catch(()=>({}));if(!a.ok||!(null==r?void 0:r.presignedUrl)||!(null==r?void 0:r.key)){u.oR.error((null==r?void 0:r.message)||(null==p?void 0:p.uploadFail)||"Upload failed");return}let s=await fetch(r.presignedUrl,{method:"PUT",body:e,headers:{"Content-Type":e.type||"application/octet-stream"}});if(!s.ok){u.oR.error("Upload to storage failed (".concat(s.status,")"));return}let l=await fetch("/api/upload-confirm",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:r.key,fileName:e.name,contentType:e.type,size:e.size,isSeedanceAsset:t})}),i=await l.json().catch(()=>({}));if(!l.ok||!(null==i?void 0:i.url)){u.oR.error((null==i?void 0:i.message)||(null==p?void 0:p.uploadFail)||"Upload failed");return}await z(),u.oR.success("Upload successful!")}catch(e){u.oR.error((null==p?void 0:p.uploadFail)||"Upload failed")}finally{a(!1)}},G=async e=>{if(confirm((null==p?void 0:p.deleteConfirm)||"Are you sure to delete this file?"))try{let t;t="upload"===y?await fetch("/api/upload-image-todb?id=".concat(e),{method:"DELETE"}):await fetch("/api/videos?id=".concat(e),{method:"DELETE"});let a=await t.json();t.ok&&a.success?u.oR.success((null==p?void 0:p.deleteSuccess)||"Delete Success!"):u.oR.error((null==p?void 0:p.deleteFail)||"Delete failed"),"upload"===y?z():T()}catch(e){u.oR.error((null==p?void 0:p.deleteFail)||"Delete failed")}};return(0,r.jsx)("div",{className:"fixed inset-0 bg-black/60 z-50 flex items-center justify-center",children:(0,r.jsxs)("div",{className:"bg-card p-0 rounded-lg w-full max-w-3xl max-h-[80vh] overflow-auto relative shadow-2xl border border-border",children:[(0,r.jsxs)("div",{className:"sticky top-0 left-0 right-0 z-10 bg-card rounded-t-lg border-b border-border",children:[(0,r.jsxs)("div",{className:"flex justify-between items-center px-6 py-4",children:[(0,r.jsx)("h2",{className:"text-lg font-bold",children:null==p?void 0:p.title}),(0,r.jsx)(l.$,{onClick:a,size:"icon",variant:"ghost",children:(0,r.jsx)(i.A,{className:"w-5 h-5"})})]}),(0,r.jsx)("div",{className:"px-6 pb-0",children:(0,r.jsxs)("div",{className:"flex border-b",children:[(0,r.jsx)("button",{className:"px-4 py-2 text-sm font-medium border-b-2 transition-colors ".concat("upload"===y?"border-primary text-primary":"border-transparent text-muted-foreground hover:text-foreground hover:border-muted-foreground"),onClick:()=>B("upload"),children:"My Upload"}),(0,r.jsx)("button",{className:"px-4 py-2 text-sm font-medium border-b-2 transition-colors ".concat("generation"===y?"border-primary text-primary":"border-transparent text-muted-foreground hover:text-foreground hover:border-muted-foreground"),onClick:()=>B("generation"),children:"My Generation"})]})})]}),(0,r.jsxs)("div",{className:"px-6 pb-6 pt-2",children:["upload"===y&&(0,r.jsxs)("div",{className:"mb-4",children:[(0,r.jsx)(l.$,{onClick:()=>{var e;return null===(e=V.current)||void 0===e?void 0:e.click()},disabled:I||L,children:I?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"w-4 h-4 mr-2 animate-spin rounded-full border-2 border-white border-r-transparent"}),"Uploading..."]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(o.A,{className:"w-4 h-4 mr-2"}),null==p?void 0:p.uploadButton]})}),("seedance20"===f||"seedance20-fast"===f)&&(0,r.jsx)(l.$,{variant:"outline",className:"ml-2",onClick:()=>{var e;return null===(e=_.current)||void 0===e?void 0:e.click()},disabled:I||L,children:L?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"w-4 h-4 mr-2 animate-spin rounded-full border-2 border-current border-r-transparent"}),"Uploading..."]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(o.A,{className:"w-4 h-4 mr-2"}),"Upload Person Asset"]})}),(0,r.jsx)("input",{ref:V,type:"file",accept:(()=>{switch(x){case"image":return"image/*";case"video":return"video/*";case"audio":return"audio/*";default:return"image/*,video/*,audio/*"}})(),className:"hidden",onChange:O}),(0,r.jsx)("input",{ref:_,type:"file",accept:"image/*",className:"hidden",onChange:q})]}),(0,r.jsxs)("div",{className:"mb-2 flex justify-between items-center text-sm text-muted-foreground",children:[(0,r.jsxs)("span",{children:["upload"===y?"My Uploaded Files":"My Generated Files","both"!==x&&" (".concat(x," only)")]}),$().length>0&&(0,r.jsxs)("span",{children:[$().length," files found"]}
1)]}),(0,r.jsx)("div",{className:"grid grid-cols-4 gap-4 mt-4",children:0===$().length?(0,r.jsx)("div",{className:"col-span-4 text-center py-8 text-muted-foreground",children:A?"Loading...":"upload"===y?"No ".concat("both"===x?"uploaded files":"uploaded ".concat(x," files")," found"):"No ".concat("both"===x?"generated files":"generated ".concat(x," files")," found")}):$().map(e=>(0,r.jsxs)("div",{className:"relative group border rounded",children:[D(e.url)?(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)("video",{src:e.url,className:"w-full h-32 object-cover rounded cursor-pointer",onClick:()=>{console.log("Video clicked in image-library:",e.url),t(e.url,e.assetid)},preload:"metadata",muted:!0}),(0,r.jsx)("div",{className:"absolute inset-0 flex items-center justify-center bg-black bg-opacity-30 rounded cursor-pointer",onClick:()=>{console.log("Video overlay clicked in image-library:",e.url),t(e.url,e.assetid)},children:(0,r.jsx)(n.A,{className:"w-8 h-8 text-white"})})]}):U(e.url)?(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsxs)("div",{className:"w-full h-32 flex flex-col items-center justify-center bg-muted rounded cursor-pointer gap-2",onClick:()=>t(e.url,e.assetid),children:[(0,r.jsx)(d.A,{className:"w-8 h-8 text-muted-foreground flex-shrink-0"}),(0,r.jsx)("span",{className:"text-xs text-muted-foreground truncate max-w-[90%] px-1",children:e.url.split("/").pop()})]}),(0,r.jsx)("div",{className:"absolute bottom-1 left-1 right-1",children:(0,r.jsx)("audio",{src:e.url,controls:!0,className:"w-full h-8",preload:"metadata",onClick:e=>e.stopPropagation()})})]}):(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)("img",{src:e.url,alt:"",className:"w-full h-32 object-cover rounded cursor-pointer",onClick:()=>t(e.url,e.assetid)}),(0,r.jsx)("div",{className:"absolute top-1 left-1 bg-black bg-opacity-50 rounded p-1",children:(0,r.jsx)(c.A,{className:"w-3 h-3 text-white"})}),e.assetid&&(0,r.jsx)("div",{className:"absolute bottom-1 right-1 bg-primary text-primary-foreground text-[10px] font-semibold px-1.5 py-0.5 rounded leading-none",children:"asset"})]}),(0,r.jsx)(l.$,{size:"icon",variant:"destructive",className:"absolute top-1 right-1 opacity-80",onClick:()=>void 0!==e.id&&G(e.id),disabled:void 0===e.id,children:"\xd7"})]},e.url))}),(0,r.jsxs)("div",{className:"flex justify-center items-center mt-4 space-x-4",children:[(0,r.jsxs)("div",{className:"text-sm text-muted-foreground",children:["Showing ",$().length," of ",C," files from ","upload"===y?"uploads":"generations","both"!==x&&" (".concat(x," only)")]}),(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,r.jsx)(l.$,{disabled:1===w,onClick:()=>k(w-1),children:(null==p?void 0:p.prevPage)||"pre"}),(0,r.jsxs)("span",{className:"mx-2",children:[w," / ",Math.ceil(C/S)||1]}),(0,r.jsx)(l.$,{disabled:w*S>=C,onClick:()=>k(w+1),children:(null==p?void 0:p.nextPage)||"next"})]})]})]})]})})}},82923:(e,t,a)=>{a.d(t,{T:()=>i});var r=a(68812),s=a(51456),l=a(58981);let i=s.forwardRef((e,t)=>{let{className:a,autoResize:i=!1,...o}=e,n=s.useRef(null);s.useImperativeHandle(t,()=>n.current,[]);let d=s.useCallback(()=>{if(i&&n.current){let e=n.current;e.style.height="auto",e.style.height="".concat(e.scrollHeight,"px")}},[i]);return s.useEffect(()=>{d()},[d,o.value]),(0,r.jsx)("textarea",{className:(0,l.cn)("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",a),ref:n,onChange:e=>{i&&d(),o.onChange&&o.onChange(e)},...o})});i.displayName="Textarea"},87004:(e,t,a)=>{a.d(t,{BT:()=>d,Wu:()=>c,ZB:()=>n,Zp:()=>i,aR:()=>o,wL:()=>u});var r=a(68812),s=a(51456),l=a(58981);let i=s.forwardRef((e,t)=>{let{className:a,...s}=e;return(0,r.jsx)("div",{ref:t,className:(0,l.cn)("rounded-lg border bg-card text-card-foreground shadow-sm",a),...s})});i.displayName="Card";let o=s.forwardRef((e,t)=>{let{className:a,...s}=e;return(0,r.jsx)("div",{ref:t,className:(0,l.cn)("flex flex-col space-y-1.5 p-6",a),...s})});
1o.displayName="CardHeader";let n=s.forwardRef((e,t)=>{let{className:a,...s}=e;return(0,r.jsx)("div",{ref:t,className:(0,l.cn)("text-2xl font-semibold leading-none tracking-tight",a),...s})});n.displayName="CardTitle";let d=s.forwardRef((e,t)=>{let{className:a,...s}=e;return(0,r.jsx)("div",{ref:t,className:(0,l.cn)("text-sm text-muted-foreground",a),...s})});d.displayName="CardDescription";let c=s.forwardRef((e,t)=>{let{className:a,...s}=e;return(0,r.jsx)("div",{ref:t,className:(0,l.cn)("p-6 pt-0",a),...s})});c.displayName="CardContent";let u=s.forwardRef((e,t)=>{let{className:a,...s}=e;return(0,r.jsx)("div",{ref:t,className:(0,l.cn)("flex items-center p-6 pt-0",a),...s})});u.displayName="CardFooter"},90627:(e,t,a)=>{a.d(t,{IB:()=>s,L$:()=>l});var r=a(55036);let s=["en","zh","es","de","fr","it","ja","ko","ru","pt"],l={en:"English",es:"Espa\xf1ol",de:"Deutsch",ja:"æ¥æ¬èª",zh:"䏿"};r.env.NEXT_PUBLIC_DEFAULT_LOCALE},99678:(e,t,a)=>{a.d(t,{p:()=>i});var r=a(68812),s=a(51456),l=a(58981);let i=s.forwardRef((e,t)=>{let{className:a,type:s,...i}=e;return(0,r.jsx)("input",{type:s,className:(0,l.cn)("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",a),ref:t,...i})});i.displayName="Input"}}]);
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.