1(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,524629,e=>{"use strict";var t=e.i(413274),a=e.i(578938);let r={"seedance-2.0-beta":{"480p":{noVideo:.07125,withVideo:.043125},"720p":{noVideo:.15375,withVideo:.09375},"1080p":{noVideo:.3825,withVideo:.2325},"4k":{noVideo:.78,withVideo:.48}},"seedance-2.0-fast-beta":{"480p":{noVideo:.058125,withVideo:.03375},"720p":{noVideo:.12375,withVideo:.075}},"seedance-2.0-mini":{"480p":{noVideo:.030875,withVideo:.0195},"720p":{noVideo:.066625,withVideo:.040625}},"doubao-seedance-2.5-face":{"480p":{noVideo:.118589,withVideo:.071153},"720p":{noVideo:.266824,withVideo:.160094}}},i={"seedance-2.0-beta":["480p","720p","1080p","4k"],"seedance-2.0-fast-beta":["480p","720p"],"seedance-2.0-mini":["480p","720p"],"doubao-seedance-2.5-face":["480p","720p"]},s={"seedance-2.0-beta":{min:4,max:15},"seedance-2.0-fast-beta":{min:4,max:15},"seedance-2.0-mini":{min:4,max:15},"doubao-seedance-2.5-face":{min:4,max:30}},n={xchatv1:{full:"Wan 2.7 Spicy",short:"Wan 2.7"},xchatv2:{full:"Wan 2.2 Spicy",short:"Wan 2.2"},xchati1:{full:"Qwen Image Edit Spicy",short:"Qwen Edit"},"face-swap":{full:"Face Swap",short:"Face Swap"},"chat-v0":{full:"Wan 2.7 Spicy",short:"Wan 2.7"},"chat-i0":{full:"Qwen Image Edit Spicy",short:"Qwen Edit"},"chat-i1":{full:"Z-Image Spicy",short:"Z-Image"}};var l=e.i(243658),o=e.i(754219),d=e.i(975157),c=e.i(667784);let m=(0,c.default)("audio-lines",[["path",{d:"M2 10v3",key:"1fnikh"}],["path",{d:"M6 6v11",key:"11sgs0"}],["path",{d:"M10 3v18",key:"yhl04a"}],["path",{d:"M14 8v7",key:"3a1oy3"}],["path",{d:"M18 5v13",key:"123xd1"}],["path",{d:"M22 10v3",key:"154ddg"}]]);var u=e.i(550545),h=e.i(515246),p=e.i(519426);let x=(0,c.default)("undo-2",[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]]),g=(0,c.default)("video",[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]]);var f=e.i(450549),b=e.i(862667),w=e.i(794030);let v={image:"Image",video:"Video",audio:"Audio"},j=/@(Image|Video|Audio)\s+\d+/g;function y(e,t){if(!e||0===t.length)return e;let a=new Map;for(let e of t){let t=v[e.kind],r=a.get(t)||[];r.push(e.mentionIndex),a.set(t,r)}for(let[e,t]of a)t.sort((e,t)=>e-t),a.set(e,t);return e.replace(j,(e,t,r)=>{let i=a.get(t);if(!i||0===i.length)return e;let s=Number.parseInt(r,10);if(!Number.isFinite(s))return e;if(i.includes(s))return`${t} ${s}`;let n=0;for(let e of i)e<s&&(n+=1);return 0===n?e:`@${t} ${s-n}`})}let N={xchatv1:"video",xchatv2:"video",xchati1:"image","z-image":"image","z-image-lora":"image","flux-lora":"image","chat-v0":"video","chat-i0":"image","chat-i1":"image"};function k({prompt:e,onPromptChange:a,mediaGroups:r,placeholder:i="Enter your idea to generate",disabled:s,className:n,rows:l=5,modelFamily:o,referenceImageUrl:c,videoDuration:y,bottomBarLeftSlot:k,optimizeBarTarget:C}){let z=(0,f.useTranslations)("PromptOptimizer"),[I,_]=b.useState({phase:"idle"}),[S,M]=b.useState(null),[$,R]=b.useState(Date.now()),P=b.useRef(null),A=b.useRef(""),L=b.useRef(!1),[E,F]=b.useState(!e.trim()),[V,T]=b.useState(null),[U,D]=b.useState(0),G=b.useMemo(()=>[...r.image.map(e=>`image:${e.mentionIndex}:${e.url}`),...r.video.map(e=>`video:${e.mentionIndex}:${e.url}`),...r.audio.map(e=>`audio:${e.mentionIndex}:${e.url}`)].join("|"),[r]),B=b.useRef(G),O=b.useCallback((e,t)=>r[e.toLowerCase()][t-1]??null,[r]),W=b.useMemo(()=>{let e=(V?.search??"").trim().toLowerCase(),t=t=>t.filter(t=>!e||`${v[t.kind]} ${t.mentionIndex}`.toLowerCase().includes(e)||t.kind.includes(e)||v[t.kind].toLowerCase().includes(e)).map(e=>({id:`${e.kind}-${e.mentionIndex}`,title:`${v[e.kind]} ${e.mentionIndex}`,kind:e.kind,url:e.url}));return{image:t(r.image),video:t(r.video),audio:t(r.audio)}},[r,V?.search]),q=b.useMemo(()=>[...W.image,...W.video,...W.audio],[W]);b.useEffect(()=>{D(0)},[V?.search,q.length]);let H=b.useCallback(e=>{if(!e)return"";let t=e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");return(t=t.replace(/@(Image|Video|Audio)\s+(\d+)/g,(e,t,a)=>{let r=O(t,Number.parseInt(a,10)),i=`<span style="color:oklch(0.65 0.2 38);">${e}</span>`;return r?"audio"===r.kind?`<span contenteditable="false" style="display:inline-flex;align-items:center;justify-content:center;width:18px;height:18px;border-radius:3px;background:rgba(255,140,40,0.18);vertical-align:middle;margin-right:2px;"><svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 16 16" fill="rgba(255,140,40,0.9)"><path d="M8 1a3 3 0 0 0-3 3v4a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3M4 7a1 1 0 0 0-2 0 6 6 0 0 0 5 5.91V14H5.5a.5.5 0 0 0 0 1h5a.5.5 0 0 0 0-1H9v-1.09A6 6 0 0 0 14 7a1 1 0 0 0-2 0 4 4 0 0 1-8 0"/></svg></span>${i}`:"video"===r.kind?`<video src="${r.url}#t=0.001" contenteditable="false" preload="metadata" muted playsinline style="display:inline-block;width:18px;height:18px;border-radius:3px;object-fit:cover;vertical-align:middle;margin-right:2px;"></video>${i}`:`<img src="${r.url}" contenteditable="false" alt="" style="display:inline-block;width:18px;height:18px;border-radius:3px;object-fit:cover;vertical-align:middle;margin-right:2px;" onerror="this.style.display='none'" />${i}`:i})).replace(/\n/g,"<br>")},[O]),X=b.useCallback(e=>{let t="";for(let a of Array.from(e.childNodes)){if(a.nodeType===Node.TEXT_NODE){t+=a.textContent||"";continue}if("BR"===a.nodeName){t+="\n";continue}if("IMG"!==a.nodeName&&"VIDEO"!==a.nodeName&&a.nodeType===Node.ELEMENT_NODE&&"false"!==a.getAttribute("contenteditable")){if("DIV"===a.nodeName||"P"===a.nodeName){t&&!t.endsWith("\n")&&(t+="\n"),t+=X(a);continue}t+=X(a)}}return t},[]),Z=b.useRef(H);Z.current=H,b.useEffect(()=>{if(!P.current)return;let t=e!==A.current,a=G!==B.current;if(B.current=G,!t&&!a)return;let r=t?e:A.current;P.current.innerHTML=Z.current(r),t&&(A.current=e,F(!e.trim()),T(null))},[G,e]);let K=()=>{let e=window.getSelection();if(!e||!e.rangeCount||!P.current)return 0;let{startContainer:t,startOffset:a}=e.getRangeAt(0),r=0,i=!1,s=e=>{if(!i){if(e===t){e.nodeType===Node.TEXT_NODE&&(r+=a),i=!0;return}if(e.nodeType===Node.TEXT_NODE){r+=(e.textContent||"").length;return}if("BR"===e.nodeName){r+=1;return}if("IMG"!==e.nodeName&&"VIDEO"!==e.nodeName){if(e.nodeType===Node.ELEMENT_NODE){if("false"===e.getAttribute("contenteditable"))return;
1("DIV"===e.nodeName||"P"===e.nodeName)&&r>0&&(r+=1)}for(let t of Array.from(e.childNodes)){if(i)return;s(t)}}}};return s(P.current),r},Q=e=>{if(!P.current)return;let t=document.createTreeWalker(P.current,NodeFilter.SHOW_TEXT,null),a=0,r=null;for(;t.nextNode();){r=t.currentNode;let i=r.textContent?.length||0;if(a+i>e){let t=window.getSelection();if(!t)return;let i=document.createRange();i.setStart(r,e-a),i.collapse(!0),t.removeAllRanges(),t.addRange(i);return}a+=i}if(r){let e=window.getSelection();if(!e)return;let t=document.createRange();t.setStartAfter(r),t.collapse(!0),e.removeAllRanges(),e.addRange(t)}},J=b.useCallback(e=>{let t=K(),a=e.slice(0,t),r=a.match(/(^|[\s\n])@([A-Za-z]*)$/);if(!r)return void T(null);let i=r[2]||"";T({start:a.length-i.length-1,end:t,search:i})},[]),Y=()=>{if(!P.current)return;let e=X(P.current);A.current=e,F(!e.trim()),a(e),L.current||J(e)},ee=b.useCallback(e=>{if(!P.current||!V)return;let t=A.current,r=t.slice(0,V.start),i=t.slice(V.end),s=`@${e.title}`,n=i.startsWith(" ")||i.startsWith("\n")?"":" ",l=`${r}${s}${n}${i}`,o=`${r}${s}${n}`.length;A.current=l,F(!l.trim()),T(null),a(l),P.current.innerHTML=H(l),Q(o),P.current.focus()},[H,V,a]),et=Math.max(72,22*l),ea="optimizing"===I.phase,er=s||ea,ei=o?N[o]:void 0,es=void 0!==ei,en=e.trim().length;b.useEffect(()=>{if("undoable"!==I.phase&&"error"!==I.phase)return;let e=window.setInterval(()=>R(Date.now()),500);return()=>window.clearInterval(e)},[I.phase]),b.useEffect(()=>{"undoable"===I.phase&&$>=I.undoExpiresAt&&_({phase:"idle"})},[$,I]),b.useEffect(()=>()=>{"optimizing"===I.phase&&I.abortController.abort()},[]);let el=b.useCallback(async()=>{if(!ei||!o||0===en||ea)return;let t=new AbortController;_({phase:"optimizing",abortController:t});try{let r=await fetch("/api/optimize-prompt",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({draft:e,modelFamily:o,...c?{referenceImageUrl:c}:{},..."video"===ei&&"number"==typeof y?{videoDuration:y}:{}}),signal:t.signal});if(!r.ok){let e="errorGeneric";try{let t=await r.json();"unauthorized"===t.error?e="errorUnauthorized":"draft_too_long"===t.error?e="errorDraftTooLong":"invalid_image_url"===t.error?e="errorInvalidImageUrl":"insufficient_credits"===t.error&&(e="errorInsufficientCredits",M(e=>e?{...e,freeRemaining:0}:e))}catch{}throw Error(z(e))}let i=r.headers.get("x-optimize-free-remaining"),s=r.headers.get("x-optimize-free-per-day"),n=r.headers.get("x-optimize-credits-per-block"),l=r.headers.get("x-optimize-block-size"),d=r.headers.get("x-optimize-balance");if(null!==i&&s&&n&&l){let e=d?Number.parseInt(d,10):NaN;M({freeRemaining:Number.parseInt(i,10)||0,freePerDay:Number.parseInt(s,10)||0,creditsPerBlock:Number.parseInt(n,10)||1,blockSize:Number.parseInt(l,10)||10,balance:Number.isFinite(e)?e:null})}let m=r.body?.getReader();if(!m)throw Error(z("errorGeneric"));let u=new TextDecoder,h="";for(a("");;){let{done:e,value:t}=await m.read();if(e)break;h+=u.decode(t,{stream:!0}),a(h)}_({phase:"undoable",previousDraft:e,undoExpiresAt:Date.now()+3e4})}catch(t){if("AbortError"===t.name){a(e),_({phase:"idle"});return}_({phase:"error",message:t instanceof Error?t.message:z("errorGeneric")}),window.setTimeout(()=>_({phase:"idle"}),5e3)}},[ei,o,en,ea,e,c,y,a,z]),eo=b.useCallback(()=>{"undoable"===I.phase&&(a(I.previousDraft),_({phase:"idle"}))},[I,a]),ed=es?0===en?z("enterPromptFirst"):null:z("unsupportedModel"),ec="undoable"===I.phase?Math.max(0,Math.ceil((I.undoExpiresAt-$)/1e3)):0,em=(0,t.jsxs)(t.Fragment,{children:[es&&"idle"===I.phase&&(0,t.jsxs)("span",{className:"pointer-events-none mr-1 hidden flex-1 truncate text-right text-[11px] text-white/40 sm:inline",children:[(0,t.jsx)(p.SparklesIcon,{className:"mr-1 inline-block size-3 align-[-2px] text-primary/70"}),z("hintCta")]}),es&&S&&!ea&&"error"!==I.phase&&(0,t.jsx)("span",{className:"pointer-events-none text-[10px] text-white/40",children:S.freeRemaining>0?z("quotaFreeRemaining",{remaining:S.freeRemaining,total:S.freePerDay}):1===S.creditsPerBlock?z("quotaPaid",{credits:S.creditsPerBlock,calls:S.blockSize}):z("quotaPaidPlural",{credits:S.creditsPerBlock,calls:S.blockSize})}),"undoable"===I.phase&&(0,t.jsxs)("button",{type:"button",onClick:eo,className:"pointer-events-auto inline-flex items-center gap-1 rounded-md border border-white/10 bg-white/[0.04] px-2 py-1 text-xs text-white/70 transition-colors hover:bg-white/[0.08] hover:text-white",title:z("undo",{sec:ec}),children:[(0,t.jsx)(x,{className:"size-3"}),z("undo",{sec:ec})]}),"error"===I.phase&&(0,t.jsx)("span",{className:"pointer-events-auto inline-flex items-center rounded-md border border-red-500/30 bg-red-500/10 px-2 py-1 text-xs text-red-300",title:I.message,children:I.message}),(0,t.jsx)("button",{type:"button",onClick:el,disabled:!!ed||ea||s,title:ed??(ea?z("optimizing"):z("optimize")),className:(0,d.cn)("pointer-events-auto inline-flex items-center gap-1 rounded-md border px-2 py-1 text-xs font-medium transition-colors",ea?"border-white/10 bg-white/[0.04] text-white/70":ed||s?"cursor-not-allowed border-white/5 bg-white/[0.02] text-white/30":"border-white/15 bg-white/[0.06] text-white/90 hover:bg-white/[0.12] hover:text-white"),children:ea?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(h.Loader2Icon,{className:"size-3 animate-spin"}),z("optimizing")]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(p.SparklesIcon,{className:"size-3"}),z("optimize")]})})]});return(0,t.jsxs)("div",{className:(0,d.cn)("relative flex min-h-[72px] flex-col sm:min-h-[140px]",n),children:[E&&i&&(0,t.jsx)("div",{className:"pointer-events-none absolute inset-0 select-none text-base leading-relaxed text-white/40 sm:text-sm",children:i}),(0,t.jsx)("div",{ref:P,contentEditable:!er,suppressContentEditableWarning:!0,tabIndex:er?-1:0,onInput:Y,onCompositionStart:()=>{L.current=!0,T(null)},onCompositionEnd:()=>
1{if(L.current=!1,!P.current)return;let e=X(P.current);A.current=e,F(!e.trim()),a(e),J(e)},onKeyDown:e=>{if(("Backspace"===e.key||"Delete"===e.key)&&P.current){let t=window.getSelection();if(t?.rangeCount&&t.isCollapsed){let t=K(),r=X(P.current),i=function(e,t,a){for(let r of e.matchAll(j)){let e=r[0],i=r.index??0,s=i+e.length,n=t>i&&t<=s,l=t>=i&&t<s;if("backward"===a&&n||"forward"===a&&l)return{start:i,end:s,text:e}}return null}(r,t,"Backspace"===e.key?"backward":"forward");if(i){let t,s;e.preventDefault();let n=(t=r.slice(0,i.start),s=r.slice(i.end),t.endsWith(" ")&&s.startsWith(" ")?`${t}${s.slice(1)}`:`${t}${s}`);A.current=n,F(!n.trim()),T(null),a(n),P.current.innerHTML=H(n),Q(i.start);return}}}if(V&&0!==q.length){if("ArrowDown"===e.key){e.preventDefault(),D(e=>(e+1)%q.length);return}if("ArrowUp"===e.key){e.preventDefault(),D(e=>(e-1+q.length)%q.length);return}if("Enter"===e.key||"Tab"===e.key){e.preventDefault(),ee(q[U]);return}"Escape"===e.key&&(e.preventDefault(),T(null))}},onBlur:()=>{window.setTimeout(()=>{if(!P.current)return;let e=X(P.current);P.current.innerHTML=H(e),A.current=e,F(!e.trim()),T(null)},0)},onPaste:e=>{e.preventDefault();let t=e.clipboardData.getData("text/plain"),a=window.getSelection();if(!a||!a.rangeCount)return;let r=a.getRangeAt(0);r.deleteContents();let i=document.createTextNode(t);
1r.insertNode(i),r.setStartAfter(i),r.setEndAfter(i),a.removeAllRanges(),a.addRange(r),Y()},style:{"--rich-prompt-min-h":`${et}px`},className:(0,d.cn)("w-full min-h-[72px] whitespace-pre-wrap break-words bg-transparent text-base leading-relaxed text-white focus:outline-none sm:min-h-[var(--rich-prompt-min-h)] sm:text-sm",s&&"cursor-not-allowed opacity-50",ea&&"opacity-80")}),(void 0!==o||k)&&(0,t.jsxs)("div",{className:"pointer-events-none mt-auto flex flex-nowrap items-center justify-end gap-1.5 pt-1.5",children:[k&&(0,t.jsx)("div",{className:"thin-scrollbar pointer-events-auto mr-auto flex min-w-0 flex-1 flex-nowrap items-center gap-2 overflow-x-auto",children:k}),C?null:em]}),C&&(void 0!==o||k)&&(0,w.createPortal)((0,t.jsx)("div",{className:"flex min-w-0 flex-1 items-center justify-end gap-1.5",children:em}),C),V&&q.length>0&&(0,t.jsx)("div",{className:"thin-scrollbar absolute left-0 top-8 z-20 max-h-56 w-full max-w-sm overflow-y-auto rounded-xl border border-white/10 bg-[#0c0c10]/95 shadow-2xl backdrop-blur",children:["image","video","audio"].map(e=>{let a=W[e];return 0===a.length?null:(0,t.jsxs)("div",{className:"border-b border-white/[0.06] last:border-b-0",children:[(0,t.jsx)("div",{className:"px-3 py-2 text-xs font-medium text-white/35",children:e}),(0,t.jsx)("div",{className:"p-1.5 pt-0",children:a.map(e=>{let a=q.findIndex(t=>t.id===e.id);return(0,t.jsxs)("button",{type:"button",onMouseDown:t=>{t.preventDefault(),ee(e)},className:(0,d.cn)("flex w-full items-center gap-2 rounded-lg px-2 py-2 text-left transition-colors",a===U?"bg-white/[0.08] text-white":"text-white/75 hover:bg-white/[0.05] hover:text-white"),children:["audio"===e.kind?(0,t.jsx)("span",{className:"flex size-7 shrink-0 items-center justify-center rounded-md bg-primary/15 text-primary",children:(0,t.jsx)(m,{className:"size-3.5"})}):"video"===e.kind?(0,t.jsxs)("div",{className:"relative size-7 shrink-0 overflow-hidden rounded-md bg-black/50",children:[(0,t.jsx)("video",{src:`${e.url}#t=0.001`,className:"h-full w-full object-cover",muted:!0,playsInline:!0}),(0,t.jsx)("span",{className:"absolute inset-0 flex items-center justify-center bg-black/25 text-white",children:(0,t.jsx)(g,{className:"size-3"})})]}):(0,t.jsxs)("div",{className:"relative size-7 shrink-0 overflow-hidden rounded-md bg-white/[0.05]",children:[(0,t.jsx)("img",{src:e.url,alt:"",className:"h-full w-full object-cover"}),(0,t.jsx)("span",{className:"absolute inset-0 flex items-center justify-center bg-black/20 text-white",children:(0,t.jsx)(u.ImageIcon,{className:"size-3"})})]}),(0,t.jsx)("div",{className:"min-w-0 flex-1",children:(0,t.jsx)("div",{className:"truncate text-sm font-medium",children:e.title})})]},e.id)})})]},e)})})]})}var C=e.i(519455),z=e.i(776639),I=e.i(337822),_=e.i(699375),S=e.i(520133),M=e.i(778497),$=e.i(7681),R=e.i(628997),P=e.i(704299);let A=(0,c.default)("columns-2",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]]);var L=e.i(21342);let E=(0,c.default)("layers",[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]]);var F=e.i(953826),V=e.i(890239),T=e.i(701123),U=e.i(872630),D=e.i(532409),G=e.i(965034);let B=(0,c.default)("users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]]);var O=e.i(63274),W=e.i(53005),q=e.i(323726),H=e.i(676993),X=e.i(77607);let Z=[{id:"text-image-to-video",name:"Text to Video",icon:P.ClapperboardIcon},{id:"reference-to-video",name:"Reference to Video",icon:E},{id:"frames-to-video",name:"Frames to Video",icon:A}],K="/imgs/model-icons/seedance.png";function Q(e){return"xchatv1"===e||"xchatv2"===e}let J=[{id:"v2-5",family:"seedance",modelName:"seedance-v2.5",name:"Seedance 2.5 Spicy",desc:"Up to 30s with native audio, 30 reference images",icon:K,apiModel:"doubao-seedance-2.5-face"},{id:"high",family:"seedance",modelName:"seedance-v2.0",name:"Seedance 2.0 Spicy",desc:"Fluid, cohesive multi-shot video outputs â up to 4k",icon:K,apiModel:"seedance-2.0-beta"},{id:"basic",family:"seedance",modelName:"seedance-v2.0",name:"Seedance 2.0 Fast Spicy",desc:"Fast, high-quality videos with rich visuals",icon:K,apiModel:"seedance-2.0-fast-beta"},{id:"mini",family:"seedance",modelName:"seedance-v2.0",name:"Seedance 2.0 Mini Spicy",desc:"Lowest-cost tier â great for quick drafts",icon:K,apiModel:"seedance-2.0-mini"},{id:"xchatv2",family:"xchatv2",modelName:"xchatv2",name:n.xchatv2.full,desc:"Image-to-vi
1deo, 480p/720p, 5s or 8s â cheapest option",icon:"/imgs/model-icons/chat-v0.svg"},{id:"xchatv1",family:"xchatv1",modelName:"xchatv1",name:n.xchatv1.full,desc:"Image-to-video, 720p/1080p, 2â15s, optional audio",icon:"/imgs/model-icons/chat-v0.svg"},{id:"xchati1",family:"xchati1",modelName:"xchati1",name:n.xchati1.full,desc:"Image generation; upload an image to edit it instead",icon:"/imgs/model-icons/chat-i0.svg"},{id:"face-swap",family:"face-swap",modelName:"face-swap",name:n["face-swap"].full,desc:"Swap a face onto a target image",icon:"/imgs/model-icons/face-swap.svg"},{id:"z-image",family:"z-image",modelName:"z-image-turbo",name:"Z-Image",desc:"Tongyi-MAI 6B · 8-step text-to-image",icon:"/imgs/model-icons/seedance.png"},{id:"z-image-lora",family:"z-image-lora",modelName:"z-image-turbo",name:"Z-Image LoRA",desc:"Z-Image with up to 3 LoRA weights",icon:"/imgs/model-icons/seedance.png"},{id:"flux-dev-lora",family:"flux-lora",modelName:"flux-dev-lora",name:"FLUX Dev LoRA",desc:"High-detail FLUX LoRA image generation",icon:"/imgs/model-icons/seedance.png"},{id:"flux-lora-ultra",family:"flux-lora",modelName:"flux-lora-ultra",name:"FLUX LoRA Ultra",desc:"Ultra-fast FLUX LoRA image generation",icon:"/imgs/model-icons/seedance.png"}];function Y(e){return"z-image"===e.family||"z-image-lora"===e.family||"flux-lora"===e.family}function ee(e,t=[]){return!Y(e)||t.includes(e.id)}function et(e,t=[]){return J.find(a=>a.id===e&&ee(a,t))}function ea(e,t,a,r,i){let s=Number(e?.get(t));return Number.isFinite(s)?Math.min(i,Math.max(r,s)):a}function er(e){let t=Number(e);return Number.isFinite(t)?Math.min(2,Math.max(-2,t)):1}function ei(e){return e.map(e=>({path:e.path.trim(),scale:er(e.scale)})).filter(e=>e.path.length>0).slice(0,3)}let es=[{id:"text-to-image",name:"Text to Image",icon:W.WandSparklesIcon},{id:"image-to-image",name:"Image to Image",icon:P.ClapperboardIcon},{id:"controlnet",name:"ControlNet",icon:E}],en=[{value:"square_hd",label:"1024 à 1024",ratio:"1:1",w:1024,h:1024},{value:"square",label:"512 à 512",ratio:"1:1",w:512,h:512},{value:"portrait_4_3",label:"768 à 1024",ratio:"3:4",w:768,h:1024},{value:"portrait_16_9",label:"720 à 1280",ratio:"9:16",w:720,h:1280},{value:"landscape_4_3",label:"1024 à 768",ratio:"4:3",w:1024,h:768},{value:"landscape_16_9",label:"1280 à 720",ratio:"16:9",w:1280,h:720}],el={"text-to-image":.005,"text-to-image-lora":.0085,"image-to-image":.005,"image-to-image-lora":.0085,controlnet:.0065,"controlnet-lora":.01},eo={"flux-dev-lora":.015,"flux-lora-ultra":.006},ed=[{value:"16:9",w:16,h:9},{value:"4:3",w:4,h:3},{value:"1:1",w:1,h:1},{value:"3:4",w:3,h:4},{value:"9:16",w:9,h:16},{value:"21:9",w:21,h:9},{value:"adaptive",w:16,h:12}],ec=[2,3,4,5,6,7,8,9,10,11,12,13,14,15],em=[5,8],eu=Object.fromEntries(Object.keys(s).map(e=>{let{min:t,max:a}=s[e];return[e,Array.from({length:a-t+1},(e,a)=>t+a)]})),eh=["720p","1080p"],ep=["480p","720p"],ex=".jpg,.jpeg,.png,.webp,.bmp,.tiff,.gif",eg={"720p":.13,"1080p":.2},ef={"480p":.04,"720p":.08};function eb(e,t,a){let r=e?.get(t);return r?Array.from(new Set(r.split(",").map(e=>e.trim()).filter(Boolean))).slice(0,a):[]}function ew(e){let t=new Date,a=t.getFullYear(),r=String(t.getMonth()+1).padStart(2,"0"),i=String(t.getDate()).padStart(2,"0"),s=String(t.getHours()).padStart(2,"0"),n=String(t.getMinutes()).padStart(2,"0");return`generate/${e}/${a}${r}${i}-${s}${n}`}function ev({w:e,h:a,active:r}){let i=Math.max(e,a),s=Math.round(e/i*14),n=Math.round(a/i*14);return(0,t.jsx)("span",{className:`inline-block rounded-[2px] border-[1.5px] ${r?"border-primary-foreground":"border-white/40"}`,style:{width:s,height:n}})}function ej({defaultQuality:e,defaultModel:s,containerClassName:d,promptStarters:c=[],enabledImageModelIds:m=[],hideTabs:x=!1,lockedMode:g}){var f,w,v;let j,N,A,{data:K}=a.authClient.useSession(),ej=!!K?.user,ey=(0,H.useSearchParams)(),eN=(0,H.useRouter)(),[ek,eC]=(0,b.useState)(()=>ey?.get("prompt")??""),[ez,eI]=(0,b.useState)(null),[e_,eS]=(0,b.useState)(()=>{let e;return g??("text-image-to-video"===(e=ey?.get("mode"))||"reference-to-video"===e||"frames-to-video"===e?e:ey?.get("reference_image_urls")||ey?.get("reference_video_urls")||ey?.get("reference_audio_urls")||ey?.get("input_images")?"reference-to-video":ey?.get("first_frame_url")||ey?.get("last_frame_url")||ey?.get("input_image_end")?"frames-to-video":"text-image-to-vi
1deo")}),[eM,e$]=(0,b.useState)(()=>{var t;let a=(t=ey?.get("model"))?"doubao-seedance-2.5-face"===t?"v2-5":"seedance-2.0-beta"===t?"high":"seedance-2.0-fast-beta"===t?"basic":"seedance-2.0-mini"===t?"mini":"bytedance/seedance-2"===t?"high":"bytedance/seedance-2-fast"===t?"basic":"chat-v0"===t?"xchatv1":"chat-i0"===t?"xchati1":t:null;if(a&&et(a,m))return a;if(s&&et(s,m))return s;let r=ey?.get("quality");return"basic"===r?"basic":"high"===r?"high":"basic"===e?"basic":"high"===e?"high":"basic"}),[eR,eP]=(0,b.useState)(()=>{let e=ey?.get("aspect_ratio");return e&&["16:9","4:3","1:1","3:4","9:16","21:9","adaptive"].includes(e)?e:"16:9"}),[eA,eL]=(0,b.useState)(()=>{let e=Number(ey?.get("duration"));return Number.isFinite(e)&&e>=2&&e<=30?e:5}),[eE,eF]=(0,b.useState)(()=>{let e=ey?.get("resolution");return"480p"===e||"720p"===e||"1080p"===e||"4k"===e?e:"720p"}),[eV,eT]=(0,b.useState)(()=>ey?.get("negative_prompt")??""),[eU,eD]=(0,b.useState)(()=>"0"!==ey?.get("prompt_extend")),[eG,eB]=(0,b.useState)(()=>"0"!==(ey?.get("generate_audio")??ey?.get("enable_audio"))),[eO,eW]=(0,b.useState)(()=>{let e=ey?.get("web_search");return"0"!==e&&"1"===e}),[eq,eH]=(0,b.useState)(()=>ey?.get("seed")??""),[eX,eZ]=(0,b.useState)(()=>(function(e){let t=[],a=e?.get("first_frame_url")??e?.get("input_image");a&&t.push(a);let r=e?.get("last_frame_url");r&&t.push(r);let i=e?.get("reference_image_urls")??e?.get("input_images");if(i)for(let e of i.split(",")){let a=e.trim();a&&t.push(a)}return Array.from(new Set(t)).slice(0,9)})(ey)),[eK,eQ]=(0,b.useState)(()=>eb(ey,"reference_video_urls",3)),[eJ,eY]=(0,b.useState)([]),[e0,e1]=(0,b.useState)(()=>eb(ey,"reference_audio_urls",3)),[e2,e5]=(0,b.useState)([]),[e3,e4]=(0,b.useState)(null),e8=null!==e3,[e6,e7]=(0,b.useState)("idle"),[e9,te]=(0,b.useState)(null),[tt,ta]=(0,b.useState)(null),[tr,ti]=(0,b.useState)(0),[ts,tn]=(0,b.useState)(null),[tl,to]=(0,b.useState)(!1),[td,tc]=(0,b.useState)(!1),[tm,tu]=(0,b.useState)(!1),[th,tp]=(0,b.useState)(!1),[tx,tg]=(0,b.useState)(!1),[tf,tb]=(0,b.useState)(!1),[tw,tv]=(0,b.useState)(()=>{let e;return"text-to-image"===(e=ey?.get("image_mode")??ey?.get("type"))||"image-to-image"===e||"controlnet"===e?e:"text-to-image"}),[tj,ty]=(0,b.useState)(()=>{let e;return"square_hd"===(e=ey?.get("image_size"))||"square"===e||"portrait_4_3"===e||"portrait_16_9"===e||"landscape_4_3"===e||"landscape_16_9"===e?e:"landscape_4_3"}),[tN,tk]=(0,b.useState)(()=>Math.round(ea(ey,"num_images",1,1,4))),[tC,tz]=(0,b.useState)(()=>Math.round(ea(ey,"num_inference_steps",8,1,50))),[tI,t_]=(0,b.useState)(()=>{let e;return"jpeg"===(e=ey?.get("output_format"))||"png"===e||"webp"===e?e:"png"}),[tS,tM]=(0,b.useState)(()=>{let e;return"none"===(e=ey?.get("acceleration"))||"regular"===e||"high"===e?e:"regular"}),[t$,tR]=(0,b.useState)(()=>"1"===ey?.get("enable_prompt_expansion")),[tP,tA]=(0,b.useState)(()=>ea(ey,"strength",.6,.05,1)),[tL,tE]=(0,b.useState)(()=>ea(ey,"control_scale",.75,0,1)),[tF,tV]=(0,b.useState)(()=>ea(ey,"control_start",0,0,1)),[tT,tU]=(0,b.useState)(()=>ea(ey,"control_end",.8,0,1)),[tD,tG]=(0,b.useState)(()=>{let e;return"none"===(e=ey?.get("preprocess"))||"canny"===e||"depth"===e||"pose"===e?e:"none"}),[tB,tO]=(0,b.useState)(()=>{let e=function(e){let t=e?.get("loras");if(t)try{let e=JSON.parse(t);if(Array.isArray(e))return ei(e.map(e=>
1({path:"string"==typeof e.path?e.path:"",scale:er(e.scale)})))}catch{}let a=eb(e,"lora_paths",3),r=(e?.get("lora_scales")??"").split(",").map(e=>e.trim()).filter(Boolean);return ei(a.map((e,t)=>({path:e,scale:er(r[t])})))}(ey);return e.length>0?e:[{path:"",scale:1}]}),[tW,tq]=(0,b.useState)(null),[tH,tX]=(0,b.useState)(null),[tZ,tK]=(0,b.useState)(!1),tQ=(0,b.useRef)(null),[tJ,tY]=(0,b.useState)(1024),[t0,t1]=(0,b.useState)(1536),t2=(0,b.useRef)(null),t5=(0,b.useRef)(0),t3=(0,b.useRef)(null),t4=(0,b.useRef)(!1),t8=(0,b.useRef)(null),t6=(0,b.useRef)(null),t7=(0,b.useRef)(null),t9=et(eM,m)??et("basic",m)??et("xchatv1",m)??et("high",m)??J[0],ae="seedance"===t9.family,at="xchatv1"===t9.family,aa="xchatv2"===t9.family,ar=at||aa,ai="xchati1"===t9.family,as="chat-i1"===t9.family,an="face-swap"===t9.family,al=ai||as||an,ao=an?"face-swap":ai||as||Y(t9)?"image":"video",ad=c.length>0&&!an&&!ek.trim(),ac="flux-lora"===t9.family,am="z-image"===t9.family||"z-image-lora"===t9.family||ac,au="z-image-lora"===t9.family,ah=am&&"image-to-image"===tw,ap=am&&"controlnet"===tw,ax=am&&(ah||ap),ag=au?`${tw}-lora`:tw,af=ei(tB),ab=en.find(e=>e.value===tj)??en[0],aw=es.find(e=>e.id===tw)??es[0],av=ac?es.filter(e=>"controlnet"!==e.id):es,aj=aw.icon;(0,b.useEffect)(()=>{ac&&"controlnet"===tw&&tv("text-to-image")},[ac,tw]);let ay=(0,b.useCallback)(()=>{tO(e=>e.length>=3?e:[...e,{path:"",scale:1}])},[]),aN=(0,b.useCallback)((e,t)=>{tO(a=>a.map((a,r)=>r===e?{...a,...t,scale:void 0===t.scale?a.scale:er(t.scale)}:a))},[]),ak=(0,b.useCallback)(e=>{tO(t=>t.length<=1?t:t.filter((t,a)=>a!==e))},[]);(0,b.useEffect)(()=>{let e=t4.current;ac&&!e&&tz(28),!ac&&e&&tz(e=>Math.min(e,8)),t4.current=ac},[ac]);let aC=ae?t9.apiModel:null,az=at?eh:aa?ep:aC?i[aC]:ep,aI=at?ec:aa?em:aC?eu[aC]:em;(0,b.useEffect)(()=>{az.includes(eE)||eF(az[0])},[eE,az]),(0,b.useEffect)(()=>{aI.includes(eA)||eL(aI[Math.min(3,aI.length-1)])},[eA,aI]),(0,b.useEffect)(()=>{(ar||al)&&"text-image-to-video"!==e_&&eS("text-image-to-video")},[ar,al,e_]);let a_=ar||al;(0,b.useEffect)(()=>{a_&&eX.length>1&&eZ(e=>e.slice(0,1))},[a_,eX.length]),(0,b.useEffect)(()=>{ae&&("text-image-to-video"===e_?(eZ([]),eQ([]),eY([]),e1([]),e5([])):"frames-to-video"===e_&&(eZ(e=>e.slice(0,2)),eQ([]),eY([]),e1([]),e5([])))},[ae,e_]);let aS=0;if("reference-to-video"===e_&&(aS=eJ.reduce((e,t)=>e+t,0)),al)j=ai?eX.length>0?2:1:1;else if(ac){let e;f=t9.modelName,e=Math.max(1,Math.min(4,Math.round(tN))),j=Math.max(1,Math.ceil(eo[f]*e/.02))}else if(am)w={w:ab.w,h:ab.h},j=Math.max(1,Math.ceil(w.w*w.h/1e6*el[ag]*tN/.03));else if(at){let e;v="1080p"===eE?"1080p":"720p",e=Math.max(2,Math.min(15,Math.round(eA))),j=Math.ceil(Math.round(100*eg[v])*e*Math.round(1e4)/(1e4*Math.round(3)))}else if(aa)j=Math.ceil(Math.round(100*ef["720p"===eE?"720p":"480p"])*(eA>=7?8:5)*Math.round(11e3)/(1e4*Math.round(3)));else j=function(e){let t=r[e.model][e.resolution];if(!t)throw Error(`No Seedance pricing configured for ${e.model}/${e.resolution}`);let a=e.inputVideoTotalDuration??0;if(a<=0)return Math.ceil(t.noVideo*e.duration/.02);let i=e.duration+Math.ceil(a),s="doubao-seedance-2.5-face"===e.model?Math.min(Math.max(i,Math.ceil(5*e.duration/3)),60):i;return Math.ceil(t.withVideo*s/.02)}({model:t9.apiModel,resolution:i[t9.apiModel].includes(eE)?eE:"720p",duration:eA,inputVideoTotalDuration:aS});let aM=Z.find(e=>e.id===e_)??Z[0],a$=aM.icon;(0,b.useEffect)(()=>()=>{t2.current&&clearInterval(t2.current)},[]);let aR=(0,b.useCallback)((e,t)=>!ae||(e.length>t?(ta(`You can add ${t} more image(s).`),!1):e.find(e=>{let t=e.name.toLowerCase();return!/\.(jpe?g|png|webp|bmp|tiff?|gif)$/.test(t)})?(ta("Images must be JPG, PNG, WebP, BMP, TIFF, or GIF files."),!1):!e.find(e=>e.size>0x1e00000)||(ta("Each image must be 30 MB or smaller."),!1)),[ae]),aP=(0,b.useCallback)(async e=>{let t=e.target.files;if(!t||0===t.length)return;let a=Array.from(t);if(!aR(a,ae&&"reference-to-video"===e_?Math.max(0,9-eX.length):1)){t8.current&&(t8.current.value="");return}e4("image");try{let e=await Promise.all(a.map(e=>(0,l.uploadFileFromBrowser)(e,ew("input"))));eZ(t=>{let a=a_?1:9;return 1===a?[e[0].url]:[...t,...e.map(e=>e.url)].slice(0,a)})}catch(e){M.logger.error("[VideoGenerator] Upload failed",e),ta("Image upload failed")}finally{e4(null),t8.current&&(t8.current.value="")}},[a_,ae,e_,eX.length,aR]),aA=(0,b.useCallback)(async e=>{let t=e.target.files;if(t&&0!==t.length){tK(!0);try{let e=await (0,l.uploadFileFromBrowser)(t[0],ew("input"));tX(e.url)}catch(e){M.logger.error("[VideoGenerator] face upload failed",e),ta("Face image upload failed")}finally{tK(!1),tQ.current&&(tQ.current.value="")}}},[]),aL=(0,b.useCallback)(e=>{eZ(t=>t.filter((t,a)=>a!==e)),eC(t=>y(t,[{kind:"image",mentionIndex:e+1,url:""}]))},[]),aE=(0,b.useCallback)(e=>{eQ(t=>t.filter((t,a)=>a!==e)),eY(t=>t.filter((t,a)=>a!==e)),eC(t=>y(t,[{kind:"video",mentionIndex:e+1,url:""}]))},[]),aF=(0,b.useCallback)(e=>{e1(t=>t.filter((t,a)=>a!==e)),e5(t=>t.filter((t,a)=>a!==e)),eC(t=>y(t,[{kind:"audio",mentionIndex:e+1,url:""}]))},[]),aV=(0,b.useCallback)((e,t="video")=>{t2.current&&(clearInterval(t2.current),t2.current=null),t5.current=0;let a=async()=>
1{if(t5.current+=1,t5.current>17280){t2.current&&clearInterval(t2.current),e7("failed"),ta("Generation timed out. Please try again.");return}try{let a=await fetch(`/api/tasks/${e}`),r=await a.json();if(!a.ok){t2.current&&clearInterval(t2.current),e7("failed"),ta(r.error||"Failed to check status");return}if("string"==typeof r.providerStatus&&tn(r.providerStatus),r.progress&&ti(r.progress),"pending"===r.status&&e7("pending"),"processing"===r.status&&e7("processing"),"completed"===r.status){if(t2.current&&clearInterval(t2.current),"image"===t){let e=Array.isArray(r.result?.image_urls)?r.result.image_urls.filter(Boolean):[];if(0===e.length){e7("failed"),ta("Generation completed but no images were returned.");return}te({taskId:t3.current,imageUrls:e,imageSeed:"number"==typeof r.result?.seed?r.result.seed:null}),e7("completed");return}e7("completed");let e=function(e){if(!e||"object"!=typeof e)return null;let t=e.video_url;if("string"==typeof t&&t)return t;let a=e.videos;if(Array.isArray(a)&&a.length>0){let e=a[0];if("string"==typeof e?.url&&e.url)return e.url}let r=e.video_urls;return Array.isArray(r)&&"string"==typeof r[0]&&r[0]?r[0]:null}(r.result);e&&te({taskId:t3.current,videoUrl:e,thumbnailUrl:r.result?.thumbnail_url}),e||(e7("failed"),ta("Generation completed but no video was returned."))}"failed"===r.status&&(t2.current&&clearInterval(t2.current),e7("failed"),ta(r.error?.message||"Generation failed"))}catch(e){M.logger.warn("[VideoGenerator] poll tick failed, retrying",e)}};a(),t2.current=setInterval(a,5e3)},[]),aT=(0,b.useCallback)(async()=>{let e;if(!an&&!ek.trim()||"submitting"===e6||"pending"===e6||"processing"===e6)return;if(ar&&0===eX.length){let e=n[t9.id]?.short??t9.modelName;ta(`${e} requires a reference image.`);return}if(an&&(0===eX.length||!tH))return void ta("face-swap requires both a target image and a face image.");if(am&&ax&&!eX[0])return void ta("controlnet"===tw?"ControlNet requires a guidance image.":"Image-to-image requires a reference image.");let t=ei(tB);if(!am&&!al&&!ar){let e=ek.trim();if(e.length<3)return void ta("Prompt must be at least 3 characters.");if(e.length>2e4)return void ta("Prompt must be 20,000 characters or fewer.");if("frames-to-video"===e_&&!eX[0])return void ta("First frame is required for Frames to Video.");if("reference-to-video"===e_&&0===eX.length&&0===eK.length)return void ta("Reference to Video requires images or videos.");if("reference-to-video"===e_&&e0.length>0&&0===eX.length&&0===eK.length)return void ta("Reference audio requires reference images or videos.")}if(ta(null),te(null),ti(0),tn(null),e7("submitting"),am)if(ac){if(e={model:t9.modelName,type:"image-to-image"===tw?"image-to-image":"text-to-image",prompt:ek.trim(),image_size:tj,width:ab.w,height:ab.h,num_images:tN,num_inference_steps:tC,guidance_scale:3.5,output_format:tI},eq.trim()){let t=Number.parseInt(eq.trim(),10);Number.isInteger(t)&&t>=0&&(e.seed=t)}ax&&(e.image_url=eX[0],e.image=eX[0]),ah&&(e.strength=tP),e.loras=t.map(e=>({path:e.path,scale:e.scale}))}else{if(e={model:"z-image-turbo",type:tw,use_lora:au&&t.length>0,prompt:ek.trim(),image_size:tj,num_images:tN,num_inference_steps:tC,output_format:tI,acceleration:tS,enable_safety_checker:!1,enable_prompt_expansion:t$},eq.trim()){let t=Number.parseInt(eq.trim(),10);Number.isInteger(t)&&t>=0&&(e.seed=t)}ax&&(e.image_url=eX[0]),ah&&(e.strength=tP),ap&&(e.control_scale=tL,e.control_start=tF,e.control_end=tT,e.preprocess=tD),au&&(e.loras=t.map(e=>({path:e.path,scale:e.scale})))}else if(al){let t=()=>{if(!eq.trim())return;let e=Number.parseInt(eq.trim(),10);if(!Number.isNaN(e)&&Number.isInteger(e)&&e>=0&&e<=0x7fffffff)return e};if(ai){if(eX.length>0)e={model:"xchati1",type:"image-to-image",prompt:ek.trim(),image_url:eX[0]};else{let t=e=>Math.max(256,Math.min(1536,Math.round(e)));e={model:"chat-i1",type:"text-to-image",prompt:ek.trim(),width:t(tJ),height:t(t0),prompt_extend:eU}}let a=t();void 0!==a&&(e.seed=a)}else{e={model:"face-swap",type:"image-to-image",image_url:eX[0],face_image:tH};let a=t();void 0!==a&&(e.seed=a)}}
1else if(at){if(e={model:"xchatv1",type:"image-to-video",prompt:ek.trim(),input_image:eX[0],resolution:"1080p"===eE?"1080p":"720p",duration:eA,prompt_extend:eU},eV.trim()&&(e.negative_prompt=eV.trim()),e0[0]&&(e.audio_url=e0[0]),eq.trim()){let t=Number.parseInt(eq.trim(),10);!Number.isNaN(t)&&Number.isInteger(t)&&t>=0&&t<=0x7fffffff&&(e.seed=t)}}else if(aa){let t="720p"===eE?"720p":"480p",a=eA>=7?8:5;if(e={model:"xchatv2",type:"image-to-video",prompt:ek.trim(),input_image:eX[0],resolution:t,duration:a,prompt_extend:eU},eq.trim()){let t=Number.parseInt(eq.trim(),10);!Number.isNaN(t)&&Number.isInteger(t)&&t>=0&&t<=0x7fffffff&&(e.seed=t)}}else e={model:t9.apiModel,prompt:ek.trim(),aspect_ratio:eR,duration:eA,resolution:eE,generate_audio:eG,web_search:eO},"frames-to-video"===e_&&(eX[0]&&(e.first_frame_url=eX[0]),eX[1]&&(e.last_frame_url=eX[1])),"reference-to-video"===e_&&(eX.length>0&&(e.reference_image_urls=eX),eK.length>0&&(e.reference_video_urls=eK),e0.length>0&&(e.reference_audio_urls=e0));try{let t=await fetch("/api/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),a=await t.json();if(!t.ok){e7("failed"),ta(a.error||"Submission failed");return}t3.current=a.id??null,e7("pending"),aV(a.task_id,am||al?"image":"video"),eN.push(X.Routes.MyCreations)}catch(e){M.logger.error("[VideoGenerator] submit failed",e),e7("failed"),ta("Network error. Please try again.")}},[ek,e_,at,aa,ar,ai,as,an,al,am,ac,tH,tJ,t0,au,ah,ap,ax,tw,tj,ab,tN,tC,tI,tS,t$,tP,tL,tF,tT,tD,tB,t9,eR,eA,eE,eG,eO,eq,eV,eU,eX,eK,e0,e2,e6,aV,eN]),aU=(0,b.useCallback)(()=>{t2.current&&clearInterval(t2.current),e7("idle"),te(null),ta(null),ti(0),tn(null)},[]),aD=(0,b.useCallback)(()=>{eC(""),ta(null)},[]),aG="submitting"===e6||"pending"===e6||"processing"===e6,aB=ek.trim().length>0,aO=function(e,t,a){if("submitting"===e)return"Submitting job...";if("pending"===e){let e=a?a.replaceAll("_"," ").replaceAll("-"," "):null;return e?`Queued by provider: ${e}`:"Queued by provider..."}return"processing"===e?t>0?`Generating ${t}%`:"Generating videoâ¦":""}(e6,tr,ts),aW=(N=new URLSearchParams,((A=(e,t)=>{if(null==t)return;let a=String(t);a&&N.set(e,a)})("prompt",ek.trim()),am)?(A("seed",eq.trim()),A("model",eM),A("image_mode",tw),A("image_size",tj),A("num_images",tN),A("num_inference_steps",tC),A("output_format",tI),ac||(A("acceleration",tS),A("enable_prompt_expansion",t$?"1":"0")),ah&&A("strength",tP),ap&&(A("control_scale",tL),A("control_start",tF),A("control_end",tT),A("preprocess",tD)),(au||ac)&&af.length>0&&A("loras",JSON.stringify(af)),`/z-image-turbo?${N.toString()}`):al?(A("model",eM),A("seed",eq.trim()),as&&(A("width",tJ),A("height",t0),A("prompt_extend",eU?"1":"0")),ai&&eX[0]&&A("input_image",eX[0]),`/?${N.toString()}`):(A("duration",eA),A("resolution",eE),ar)?(A("model",t9.id),A("seed",eq.trim()),A("input_image",eX[0]),A("prompt_extend",eU?"1":"0"),at&&A("negative_prompt",eV.trim()),`/?${N.toString()}`):(A("aspect_ratio",eR),A("model",t9.apiModel),A("generate_audio",eG?"1":"0"),A("web_search",eO?"1":"0"),"frames-to-video"===e_&&(A("first_frame_url",eX[0]),A("last_frame_url",eX[1])),"reference-to-video"===e_&&(eX.length>0&&A("reference_image_urls",eX.join(",")),eK.length>0&&A("reference_video_urls",eK.join(",")),e0.length>0&&A("reference_audio_urls",e0.join(","))),`/seedance-2-0?${N.toString()}`)),aq=ej&&(an||ek.trim().length>0)&&!aG&&(!ar||eX.length>0)&&(!an||eX.length>0&&!!tH)&&(!ax||eX.length>0)&&(!ap||tF<tT)&&(!ae||ek.trim().length>=3&&("frames-to-video"!==e_||eX.length>0)&&("reference-to-video"!==e_||eX.length>0||eK.length>0)),aH=aq||!ej||aG?null:an||0!==ek.trim().length?ar&&0===eX.length?"Upload a reference image â this model turns an image into a video.":an&&0===eX.length?"Upload a target image (the photo to swap onto).":an&&!tH?"Upload a face image (the face to paste in).":ax&&!eX[0]?"controlnet"===tw?"Upload a guidance image for ControlNet.":"Upload a reference image for image-to-image.":ap&&tF>=tT?"Control Start must be less than Control End.":ae&&ek.trim().length<3?"Prompt must be at least 3 characters.":ae&&"frames-to-video"===e_&&0===eX.length?"Upload a first-frame image for Frames to Video.":ae&&"reference-to-video"===e_&&0===eX.length&&0===eK.length?"Upload at least one reference image or video.":null:"Enter a prompt to generate.",aX=(0,b.useCallback)(()=>
1{if(!aG){if(aH)return void o.toast.warning(aH);aT()}},[aG,aH,aT]);return am?(0,t.jsxs)("div",{className:d??"relative mx-auto w-full max-w-[1080px]",children:[(0,t.jsxs)("div",{className:"relative rounded-2xl border border-white/[0.08] bg-card p-2.5 pb-2 shadow-(--shadow-card) sm:p-3 sm:pb-2 md:rounded-3xl md:p-4 md:pb-2",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:gap-1",children:[ax&&(0,t.jsx)("div",{className:"flex shrink-0 items-start gap-1.5",children:(0,t.jsxs)("div",{className:"relative flex h-[52px] w-[48px] shrink-0 sm:h-[60px] sm:w-[56px]",children:[(0,t.jsxs)("button",{type:"button",onClick:()=>t8.current?.click(),disabled:e8||aG,className:`absolute left-0 top-0 flex h-[52px] w-[40px] sm:h-[60px] sm:w-[45px] cursor-pointer items-center justify-center rounded border border-dashed transition-colors disabled:cursor-not-allowed disabled:opacity-40 ${eX[0]?"border-primary/30 bg-primary/10 hover:bg-primary/15":"border-white/[0.12] bg-white/[0.04] hover:bg-white/[0.08]"}`,style:{transform:"rotate(-5deg)"},"aria-label":eX[0]?"Replace image":"Upload image",children:["image"===e3&&(0,t.jsx)(h.Loader2Icon,{className:"size-4 animate-spin text-white/30"}),"image"!==e3&&(eX[0]?(0,t.jsx)("img",{src:eX[0],alt:"",className:"size-full rounded object-cover"}):(0,t.jsx)(T.PlusIcon,{className:"size-4 text-white/30"}))]}),eX[0]&&"image"!==e3&&(0,t.jsx)("button",{type:"button",onClick:()=>eZ([]),className:"absolute -right-1 -top-1 z-10 grid size-5 place-items-center rounded-full bg-black/80 text-white/85 hover:bg-black","aria-label":"Remove image",children:(0,t.jsx)(q.XIcon,{className:"size-3"})}),(0,t.jsx)("input",{ref:t8,type:"file",accept:"image/*",onChange:async e=>{let t=e.target.files?.[0];if(e.target.value="",t){e4("image"),ta(null);try{let e=await (0,l.uploadFileFromBrowser)(t,ew("input"));eZ([e.url])}catch(e){M.logger.error("[VideoGenerator] z-image upload failed",e),ta(e instanceof Error?e.message:"Upload failed")}finally{e4(null)}}},className:"hidden"})]})}),(0,t.jsxs)("div",{className:"relative min-h-[72px] flex-1 sm:min-h-[140px]",children:[(0,t.jsx)("textarea",{value:ek,onChange:e=>eC(e.target.value),placeholder:"Enter your idea to generate.",disabled:aG,rows:5,onKeyDown:e=>{(e.metaKey||e.ctrlKey)&&"Enter"===e.key&&(e.preventDefault(),aT())},className:"size-full min-h-[72px] w-full resize-none border-0 bg-transparent px-2 py-1 text-sm leading-[1.55] text-white outline-none placeholder:text-white/40 sm:min-h-[140px] sm:text-[15px]"}),ax&&!eX[0]&&!aG&&(0,t.jsxs)("div",{className:"mt-1 flex items-center gap-1.5 text-xs text-white/50",children:[(0,t.jsx)(u.ImageIcon,{className:"size-3"}),(0,t.jsx)("span",{children:"controlnet"===tw?"ControlNet requires a guidance image to enable Generate.":"Image-to-image requires a reference image to enable Generate."})]}),aG&&(0,t.jsxs)("div",{className:"mt-1 flex items-center gap-2",children:[(0,t.jsxs)("span",{className:"relative size-3.5 shrink-0",children:[(0,t.jsx)("span",{className:"absolute inset-0 rounded-full border border-primary/20"}),(0,t.jsx)("span",{className:"absolute inset-0 animate-spin rounded-full border border-transparent border-r-primary/60 border-t-primary",style:{animationDuration:"850ms"}})]}),(0,t.jsxs)("span",{className:"text-xs text-white/50",children:[aO||"Generatingâ¦",(0,t.jsx)("span",{className:"ml-1.5 text-white/40",children:"· ~30 sec to 2 min"})]})]}),tt&&(0,t.jsxs)("div",{className:"mt-1 flex items-center gap-1.5",children:[(0,t.jsx)(q.XIcon,{className:"size-3 text-red-400"}),(0,t.jsx)("span",{className:"text-xs text-red-400",children:tt})]})]})]}),(0,t.jsxs)("div",{className:"-mx-1 mt-0 flex items-center gap-1 overflow-x-auto border-t border-white/[0.06] px-1 pt-2 sm:gap-1.5 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:[(0,t.jsxs)(I.Popover,{open:th,onOpenChange:tp,children:[(0,t.jsx)(I.PopoverTrigger,{asChild:!0,children:(0,t.jsxs)("button",{type:"button",className:"flex h-8 shrink-0 items-center gap-1.5 rounded-lg bg-white/[0.06] px-1.5 text-sm transition-colors hover:bg-white/[0.1] sm:px-3",children:[(0,t.jsx)(u.ImageIcon,{className:"size-4 text-[#FF8F34]"}),(0,t.jsx)("span",{className:"hidden font-medium text-[oklch(0.8_0.11_55)] sm:inline",children:"Image"}),(0,t.jsx)(R.ChevronDownIcon,{className:"size-3.5 text-white/40"})]})}),(0,t.jsxs)(I.PopoverContent,{align:"start",className:"w-[calc(100vw-2rem)] max-w-[180px] p-1.5",children:[(0,t.jsxs)("button",{type:"button",className:"flex w-full items-center gap-2 rounded-md bg-white/[0.08] px-3 py-2 text-left text-sm font-medium",children:[(0,t.jsx)(u.ImageIcon,{className:"size-4"})," Image"]}),(0,t.jsxs)("button",{type:"button",onClick:()=>{e$("high"),tp(!1)},className:"flex w-full items-center gap-2 rounded-md px-3 py-2 text-left text-sm text-white/70 transition-colors hover:bg-white/[0.06]",children:[(0,t.jsx)(W.WandSparklesIcon,{className:"size-4"})," Video"]})]})]}),(0,t.jsxs)(I.Popover,{open:tl,onOpenChange:to,children:[(0,t.jsx)(I.PopoverTrigger,{asChild:!0,children:(0,t.jsxs)("button",{type:"button",className:"flex h-8 shrink-0 items-center gap-1.5 rounded-lg bg-white/[0.06] px-1.5 text-sm text-white/80 transition-colors hover:bg-white/[0.1] sm:px-3",children:[(0,t.jsx)(p.SparklesIcon,{className:"size-3.5 text-primary/85"}),(0,t.jsx)("span",{className:"hidden sm:inline",children:t9.name}),(0,t.jsx)("span",{className:"sm:hidden",children:"z-image"===t9.id?"Z":ac?"FLUX":"Z·L"}),(0,t.jsx)(R.ChevronDownIcon,{className:"size-3.5 text-white/40"})]})}),(0,t.jsx)(I.PopoverContent,{align:"start",className:"w-[calc(100vw-2rem)] max-w-[300px] p-1.5",children:J.filter(e=>ee(e,m)&&("z-image"===e.family||"z-image-lora"===e.family||"flux-lora"===e.family)).map(e=>(0,t.jsxs)("button",{type:"button",onClick:()=>{e$(e.id),to(!1)},className:`flex w-full flex-col gap-0.5 rounded-md px-3 py-2.5 text-left transition-colors hover:bg-white/[0.06] ${eM===e.id?"bg-white/[0.08]":""}`,children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(p.SparklesIcon,{className:"size-3.5 text-primary/85"}),(0,t.jsx)("span",{className:"text-sm font-medium",children:e.name})]}),(0,t.jsx)("p",{className:"ml-[22px] text-xs text-muted-foreground",children:e.desc})]},e.id))})]}),(0,t.jsxs)(I.Popover,{open:td,onOpenChange:tc,children:[(0,t.jsx)(I.PopoverTrigger,{asChild:!0,children:(0,t.jsxs)("button",{type:"button",className:"flex h-8 shrink-0 items-center gap-1.5 rounded-lg bg-white/[0.06] px-1.5 text-sm text-white/80 transition-colors hover:bg-white/[0.1] sm:px-3",children:[(0,t.jsx)(aj,{className:"size-4"}),(0,t.jsx)("span",{className:"hidden sm:inline",children:aw.name}),(0,t.jsx)(R.ChevronDownIcon,{className:"size-3.5 text-white/40"})]})}),(0,t.jsxs)(I.PopoverContent,{align:"start",className:"w-[calc(100vw-2rem)] max-w-[300px] p-1.5",children:[av.map(e=>{let a=e.icon;return(0,t.jsxs)("button",{type:"button",onClick:()=>{tv(e.id),tc(!1)},className:`flex w-full items-center gap-2 rounded-md px-3 py-2 text-left text-sm transition-colors hover:bg-white/[0.06] ${tw===e.id?"bg-white/[0.08] font-medium":"text-white/70"}`,children:[(0,t.jsx)(a,{className:"size-4"})," ",e.name]},e.id)}),ah&&(0,t.jsxs)("div",{className:"mt-1.5 border-t border-white/[0.06] px-1.5 pt-3 pb-1.5",children:[(0,t.jsxs)("div",{className:"mb-1 flex items-baseline justify-between text-xs",children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:"Strength"}),(0,t.jsx)("span",{className:"tabular-nums text-white/70",children:tP.toFixed(2)})]}
1),(0,t.jsx)("input",{type:"range",min:.05,max:1,step:.05,value:tP,onChange:e=>tA(Math.max(.05,Number(e.target.value))),className:"h-1 w-full cursor-pointer appearance-none rounded-full bg-white/10 accent-primary outline-none"}),(0,t.jsx)("p",{className:"mt-1 text-[10.5px] text-muted-foreground",children:"Lower values keep more of the input; 1 fully repaints."})]}),ap&&(0,t.jsxs)("div",{className:"mt-1.5 border-t border-white/[0.06] px-1.5 pt-3 pb-1.5",children:[(0,t.jsx)("p",{className:"mb-1.5 text-xs text-muted-foreground",children:"Preprocess"}),(0,t.jsx)("div",{className:"mb-3 grid grid-cols-4 gap-1",children:["none","canny","depth","pose"].map(e=>{let a=e===tD;return(0,t.jsx)("button",{type:"button",onClick:()=>tG(e),className:`rounded-md py-1 text-xs capitalize transition ${a?"bg-white/[0.08] text-white":"bg-white/[0.02] text-white/60 hover:bg-white/[0.06]"}`,children:e},e)})}),(0,t.jsx)("div",{className:"grid grid-cols-3 gap-2",children:[{label:"Scale",value:tL,min:0,max:1,set:tE},{label:"Start",value:tF,min:0,max:Math.max(0,tT-.05),set
1:tV},{label:"End",value:tT,min:Math.min(1,tF+.05),max:1,set:tU}].map(({label:e,value:a,min:r,max:i,set:s})=>(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"mb-1 flex items-baseline justify-between text-xs",children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:e}),(0,t.jsx)("span",{className:"tabular-nums text-white/70",children:a.toFixed(2)})]}),(0,t.jsx)("input",{type:"range",min:r,max:i,step:.05,value:a,onChange:e=>{s(Math.min(i,Math.max(r,Number(e.target.value))))},className:"h-1 w-full cursor-pointer appearance-none rounded-full bg-white/10 accent-primary outline-none"})]},e))})]})]})]}),au&&(0,t.jsxs)(I.Popover,{open:tf,onOpenChange:tb,children:[(0,t.jsx)(I.PopoverTrigger,{asChild:!0,children:(0,t.jsxs)("button",{type:"button",className:"flex h-8 shrink-0 items-center gap-1.5 rounded-lg bg-white/[0.06] px-1.5 text-sm text-white/80 transition-colors hover:bg-white/[0.1] sm:px-3",children:[(0,t.jsx)(E,{className:"size-3.5"}),(0,t.jsx)("span",{className:"hidden sm:inline",children:"LoRA"}),(0,t.jsxs)("span",{className:"tabular-nums",children:[af.length,"/3"]}),(0,t.jsx)(R.ChevronDownIcon,{className:"size-3.5 text-white/40"})]})}),(0,t.jsxs)(I.PopoverContent,{align:"start",className:"w-[420px] max-w-[calc(100vw-2rem)] space-y-3 p-3",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-sm font-medium text-white",children:"LoRA weights"}),(0,t.jsx)("p",{className:"mt-0.5 text-xs text-muted-foreground",children:"Add 1â3 LoRA URLs for this model."})]}),(0,t.jsxs)("button",{type:"button",onClick:ay,disabled:tB.length>=3,className:"inline-flex h-8 items-center gap-1.5 rounded-md bg-white/[0.06] px-2.5 text-xs text-white/80 transition-colors hover:bg-white/[0.1] disabled:cursor-not-allowed disabled:text-white/30",children:[(0,t.jsx)(T.PlusIcon,{className:"size-3.5"}),"Add"]})]}),(0,t.jsx)("div",{className:"space-y-2",children:tB.slice(0,3).map((e,a)=>(0,t.jsxs)("div",{className:"rounded-lg border border-white/[0.06] bg-white/[0.03] p-2.5",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("input",{type:"text",value:e.path,onChange:e=>aN(a,{path:e.target.value}),placeholder:"https://.../model.safetensors",className:"min-w-0 flex-1 rounded-md border border-white/[0.06] bg-black/20 px-2 py-1.5 text-xs outline-none placeholder:text-muted-foreground focus:border-primary/40"}),tB.length>1&&(0,t.jsx)("button",{type:"button",onClick:()=>ak(a),"aria-label":"Remove LoRA",className:"flex size-8 shrink-0 items-center justify-center rounded-md text-white/45 transition-colors hover:bg-white/[0.08] hover:text-white",children:(0,t.jsx)(G.Trash2Icon,{className:"size-3.5"})})]}),(0,t.jsxs)("div",{className:"mt-2 flex items-center gap-3",children:[(0,t.jsx)("span",{className:"w-10 text-xs text-muted-foreground",children:"Scale"}),(0,t.jsx)("input",{type:"range",min:-2,max:2,step:.05,value:er(e.scale),onChange:e=>aN(a,{scale:Number(e.target.value)}),className:"h-1 flex-1 cursor-pointer appearance-none rounded-full bg-white/10 accent-primary outline-none"}),(0,t.jsx)("span",{className:"w-10 text-right text-xs tabular-nums text-white/70",children:er(e.scale).toFixed(2)})]})]},a))})]})]}),(0,t.jsxs)(I.Popover,{open:tm,onOpenChange:tu,children:[(0,t.jsx)(I.PopoverTrigger,{asChild:!0,children:(0,t.jsxs)("button",{type:"button",className:"flex h-8 shrink-0 items-center gap-1.5 rounded-lg bg-white/[0.06] px-1.5 text-sm text-white/80 transition-colors hover:bg-white/[0.1] sm:px-3",children:[(0,t.jsx)("span",{className:"hidden tabular-nums sm:inline",children:ab.label}),(0,t.jsx)("span",{className:"hidden text-white/30 sm:inline",children:"|"}),(0,t.jsxs)("span",{className:"tabular-nums",children:["Ã",tN]}),(0,t.jsx)(R.ChevronDownIcon,{className:"size-3.5 text-white/40"})]})}),(0,t.jsxs)(I.PopoverContent,{align:"start",className:"w-[calc(100vw-2rem)] max-w-[300px] p-3",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"mb-2 text-xs text-muted-foreground",children:"Image Size"}),(0,t.jsx)("div",{className:"grid grid-cols-2 gap-1.5",children:en.map(e=>{let a=tj===e.value;return(0,t.jsxs)("button",{type:"button",onClick:()=>ty(e.value),className:`rounded-md px-2 py-2 text-center text-xs font-medium transition-colors ${a?"bg-primary text-primary-foreground":"bg-white/[0.06] text-white/70 hover:bg-white/[0.1]"}`,children:[(0,t.jsx)("div",{children:e.ratio}),(0,t.jsx)("div",{className:"mt-0.5 text-[10.5px] tabular-nums opacity-80",children:e.label})]},e.value)})})]}),(0,t.jsxs)("div",{className:"mt-4",children:[(0,t.jsx)("p",{className:"mb-2 text-xs text-muted-foreground",children:"Number of Images"}),(0,t.jsx)("div",{className:"grid grid-cols-4 gap-1.5",children:[1,2,3,4].map(e=>{let a=e===tN;return(0,t.jsxs)("button",{type:"button",onClick:()=>tk(e),className:`rounded-md py-1.5 text-center text-xs font-medium transition-colors ${a?"bg-primary text-primary-foreground":"bg-white/[0.06] text-white/70 hover:bg-white/[0.1]"}`,children:["Ã",e]},e)})})]}),(0,t.jsxs)("div",{className:"mt-4",children:[(0,t.jsx)("p",{className:"mb-2 text-xs text-muted-foreground",children:"Format"}),(0,t.jsx)("div",{className:"flex gap-1.5",children:["png","jpeg","webp"].map(e=>{let a=e===tI;return(0,t.jsx)("button",{type:"button",onClick:()=>t_(e),className:`flex-1 rounded-md py-1.5 text-xs uppercase transition-colors ${a?"bg-primary text-primary-foreground":"bg-white/[0.06] text-white/70 hover:bg-white/[0.1]"}`,children:e},e)})})]})]})]}),(0,t.jsxs)(I.Popover,{open:tx,onOpenChange:tg,children:[(0,t.jsx)(I.PopoverTrigger,{asChild:!0,children:(0,t.jsxs)("button",{type:"button",className:"flex h-8 shrink-0 items-center gap-1.5 rounded-lg bg-white/[0.06] px-1.5 text-sm text-white/80 transition-colors hover:bg-white/[0.1] sm:px-3","aria-label":"Advanced settings",children:[(0,t.jsx)("span",{className:"hidden sm:inline",children:"Advanced"}),(0,t.jsx)(R.ChevronDownIcon,{className:"size-3.5 text-white/40"})]})}),(0,t.jsxs)(I.PopoverContent,{align:"end",className:"w-[calc(100vw-2rem)] max-w-[340px] space-y-3 p-3",children:[(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"mb-1.5 flex items-baseline justify-between text-xs",children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:"Inference steps"}),(0,t.jsx)("span",{className:"tabular-nums text-white/70",children:tC})]}),(0,t.jsx)("input",{type:"range",min:1,max:ac?50:8,step:1,value:tC,onChange:e=>tz(Number(e.target.value)),className:"h-1 w-full cursor-pointer appearance-none rounded-full bg-white/10 accent-primary outline-none"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"mb-1.5 block text-xs text-muted-foreground",children:"Speed"}),(0,t.jsx)("div",{className:"flex gap-1.5",children:["none","regular","high"].map(e=>{let a=e===tS;return(0,t.jsx)("button",{type:"button",onClick:()=>tM(e),className:`flex-1 rounded-md py-1.5 text-xs capitalize transition-colors ${a?"bg-primary text-primary-foreground":"bg-white/[0.06] text-white/70 hover:bg-white/[0.1]"}`,children:e},e)})})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"mb-1.5 block text-xs text-muted-foreground",children:"Seed"}),(0,t.jsx)("input",{type:"text",value:eq,onChange:e=>eH(e.target.value),placeholder:"random",className:"w-full rounded-md border border-white/[0.06] bg-white/[0.04] px-2 py-1 text-xs tabular-nums outline-none placeholder:text-muted-foreground focus:border-primary/40"})]}),(0,t.jsxs)("label",{className:"flex items-center gap-2.5 text-xs",children:[(0,t.jsx)("input",{type:"checkbox",checked:t$,onChange:e=>tR(e.target.checked),className:"size-3.5 accent-primary"}),(0,t.jsx)("span",{className:"text-white/70",children:"Prompt expansion"})]})]})]}),(0,t.jsx)("span",{className:"flex-1"}),aB&&(0,t.jsx)("button",{type:"button",onClick:aD,disabled:aG,"aria-label":"Clear prompt",title:"Clear prompt",className:"flex size-8 shrink-0 items-center justify-center rounded-full border border-white/[0.08] bg-white/[0.04] text-white/55 transition-colors hover:border-white/[0.16] hover:bg-white/[0.08] hover:text-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/45 disabled:pointer-events-none disabled:opacity-40",children:(0,t.jsx)(U.RefreshCwIcon,{className:"size-3.5"})}),ej&&(0,t.jsxs)("button",{type:"button",onClick:aX,disabled:aG,"aria-disabled":!aq,title:aH??void 0,className:"flex h-8 shrink-0 items-center gap-1.5 rounded-full bg-primary px-3 text-sm font-medium text-primary-foreground transition-colors hover:bg-primary/90 disabled:cursor-not-allowed disabled:bg-white/[0.06] disabled:text-white/30 aria-disabled:cursor-not-allowed aria-disabled:bg-white/[0.06] aria-disabled:text-white/30 aria-disabled:hover:bg-white/[0.06] sm:px-4",children:[aG?(0,t.jsx)(h.Loader2Icon,{className:"size-4 animate-spin"}):(0,t.jsx)(V.PlayIcon,{className:"size-3.5 fill-current"}),(0,t.jsx)("span",{children:"Generate"}),(0,t.jsx)(D.CoinsIcon,{className:"size-3"}),(0,t.jsx)("span",{className:"tabular-nums",children:j})]}),!ej&&(0,t.jsx)(C.Button,{asChild:!0,className:"flex h-8 shrink-0 items-center gap-1.5 rounded-full bg-primary px-3 text-sm font-medium text-primary-foreground hover:bg-primary/90 sm:px-4",children:(0,t.jsxs)(S.LocaleLink,{href:"/auth/register",children:[(0,t.jsx)(V.PlayIcon,{className:"size-3.5 fill-current"}),(0,t.jsx)("span",{children:"Generate"}),(0,t.jsx)(D.CoinsIcon,{className:"size-3"}),(0,t.jsx)("span",{className:"tabular-nums",children:j})]})})]})]}),e9?.imageUrls&&e9.imageUrls.length>0&&(0,t.jsxs)("section",{className:"mt-6",children:[(0,t.jsxs)("div",{className:"mb-3 flex items-center justify-end gap-4",children:[(0,t.jsxs)(S.LocaleLink,{href:"/my-creations",className:"inline-flex items-center gap-1.5 text-xs font-semibold text-white/60 transition-colors hover:text-white",children:["Archive",(0,t.jsx)($.ArrowRightIcon,{className:"size-3"})]}),(0,t.jsxs)(S.LocaleLink,{href:aW,className:"inline-flex items-center gap-1.5 text-xs font-semibold text-primary/85 transition-colors hover:text-primary",children:[(0,t.jsx)(U.RefreshCwIcon,{className:"size-3"}),"Remix"]}),(0,t.jsx)("button",{type:"button",onClick:aU,"aria-label":"Close result",className:"flex size-6 items-center justify-center rounded-md text-white/50 transition-colors hover:bg-white/[0.06] hover:text-white",children:(0,t.jsx)(q.XIcon,{className:"size-3.5"})})]}),(0,t.jsx)("div",{className:`mx-auto grid max-w-[720px] gap-3 ${1===e9.imageUrls.length?"grid-cols-1":"grid-cols-2"}`,children:e9.imageUrls.map((e,a)=>(0,t.jsxs)("button",{type:"button",onClick:()=>tq(e),className:"group relative block cursor-zoom-in overflow-hidden rounded-xl border border-white/[0.06] bg-black/40",children:[e9.imageUrls.length>1&&(0,t.jsxs)("span",{"aria-hidden":"true",className:"pointer-events-none absolute left-2 top-2 z-10 rounded-sm bg-black/65 px-1.5 py-0.5 text-[10px] tabular-nums text-white/85 backdrop-blur-sm",children:[a+1," / ",e9.imageUrls.length]}),(0,t.jsx)("img",{src:e,alt:`generated ${a+1}
1`,className:"mx-auto block max-h-[500px] w-auto max-w-full object-contain transition-transform duration-300 group-hover:scale-[1.015]"})]},a))}),null!=e9.imageSeed&&(0,t.jsxs)("div",{className:"mt-2 text-xs tabular-nums text-muted-foreground",children:["seed · ",e9.imageSeed]})]}),(0,t.jsx)(z.Dialog,{open:!!tW,onOpenChange:e=>!e&&tq(null),children:(0,t.jsxs)(z.DialogContent,{className:"!sm:max-w-none max-h-[92vh] w-auto !max-w-[92vw] bg-transparent p-0 ring-0",showCloseButton:!1,children:[(0,t.jsx)(z.DialogTitle,{className:"sr-only",children:"Generated image preview"}),tW&&(0,t.jsx)("img",{src:tW,alt:"generated",className:"block max-h-[92vh] max-w-[92vw] rounded-lg object-contain"})]})})]}):(0,t.jsxs)("div",{className:d??"relative mx-auto w-full max-w-[1080px]",children:[(0,t.jsxs)("div",{className:"relative rounded-2xl border border-white/[0.08] bg-card p-2.5 pb-2 shadow-(--shadow-card) sm:p-3 sm:pb-2 md:rounded-3xl md:p-4 md:pb-2",children:[(0,t.jsx)("div",{role:"tablist","aria-label":"Generation mode",className:`-mx-0.5 mb-3 items-center gap-1 overflow-x-auto px-0.5 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden ${x?"hidden":"flex"}`,children:[{key:"video",label:"Video",icon:W.WandSparklesIcon,onSelect:()=>{if("video"!==ao){let e=s?J.find(e=>e.id===s):void 0;e$(e?.family==="seedance"||Q(e?.family??"seedance")?s:"basic")}}},{key:"image",label:"Image",icon:u.ImageIcon,onSelect:()=>{"image"!==ao&&e$("xchati1")}},{key:"face-swap",label:"Face Swap",icon:B,onSelect:()=>{"face-swap"!==ao&&e$("face-swap")}}].map(e=>{let a=e.icon,r=ao===e.key;return(0,t.jsxs)("button",{type:"button",role:"tab","aria-selected":r,onClick:e.onSelect,className:`flex h-8 shrink-0 items-center gap-1.5 rounded-lg px-3 text-sm transition-colors ${r?"bg-white/[0.1] text-white":"text-white/55 hover:bg-white/[0.04] hover:text-white/80"}`,children:[(0,t.jsx)(a,{className:`size-4 ${r?"text-[#FF8F34]":""}`}),(0,t.jsx)("span",{className:r?"font-medium text-[oklch(0.8_0.11_55)]":"",children:e.label})]},e.key)})}),(0,t.jsxs)("div",{className:"flex flex-col gap-3 sm:block sm:after:block sm:after:clear-both sm:after:content-['']",children:["text-image-to-video"===e_&&!as&&!ae&&(0,t.jsxs)("div",{className:"relative z-10 flex shrink-0 items-start gap-1.5 sm:float-left sm:mr-2.5 sm:mb-2",children:[(0,t.jsxs)("div",{className:"relative flex h-[52px] w-[48px] shrink-0 sm:h-[60px] sm:w-[56px]",children:[(0,t.jsxs)("button",{type:"button",onClick:()=>t8.current?.click(),disabled:e8||aG,className:"absolute left-0 top-0 flex h-[52px] w-[40px] sm:h-[60px] sm:w-[45px] cursor-pointer items-center justify-center rounded border border-dashed border-white/[0.12] bg-white/[0.04] transition-colors hover:bg-white/[0.08] disabled:cursor-not-allowed disabled:opacity-40",style:{transform:"rotate(-5deg)"},children:[e8&&(0,t.jsx)(h.Loader2Icon,{className:"size-4 animate-spin text-white/30"}),!e8&&(0,t.jsx)(T.PlusIcon,{className:"size-4 text-white/30"})]}),(0,t.jsx)("input",{ref:t8,type:"file",accept:ae?ex:ar?".jpg,.jpeg,.png,.webp,.bmp":".jpg,.jpeg,.png,.webp",multiple:!ae&&!ar&&!al,onChange:aP,className:"hidden"})]}),an&&(0,t.jsxs)("div",{className:"relative flex h-[52px] w-[48px] shrink-0 sm:h-[60px] sm:w-[56px]",children:[(0,t.jsxs)("button",{type:"button",onClick:()=>tQ.current?.click(),disabled:tZ||aG,title:tH?"Replace face image":"Upload source face","aria-label":tH?"Replace face image":"Upload source face",className:`absolute left-0 top-0 flex h-[52px] w-[40px] sm:h-[60px] sm:w-[45px] cursor-pointer items-center justify-center rounded border border-dashed transition-colors disabled:cursor-not-allowed disabled:opacity-40 ${tH?"border-primary/30 bg-primary/10 hover:bg-primary/15":"border-white/[0.12] bg-white/[0.04] hover:bg-white/[0.08]"}`,style:{transform:"rotate(5deg)"},children:[tZ&&(0,t.jsx)(h.Loader2Icon,{className:"size-4 animate-spin text-white/30"}),!tZ&&(tH?(0,t.jsx)("img",{src:tH,alt:"source face",className:"size-full rounded object-cover"}):(0,t.jsx)(T.PlusIcon,{className:"size-4 text-white/30"}))]}),(0,t.jsx)("input",{ref:tQ,type:"file",accept:".jpg,.jpeg,.png,.webp",onChange:aA,className:"hidden"})]}),at&&(0,t.jsxs)("div",{className:"relative flex h-[52px] w-[40px] shrink-0 sm:h-[60px] sm:w-[45px]",children:[(0,t.jsxs)("button",{type:"button",onClick:()=>t7.current?.click(),disabled:e8||aG,title:e0[0]?"Replace audio":"Add audio (optional)",className:`absolute left-0 top-0 flex h-[52px] w-[40px] sm:h-[60px] sm:w-[45px] cursor-pointer items-center justify-center rounded border border-dashed transition-colors disabled:cursor-not-allowed disabled:opacity-40 ${e0[0]?"border-primary/30 bg-primary/10 hover:bg-primary/15":"border-white/[0.12] bg-white/[0.04] hover:bg-white/[0.08]"}`,style:{transform:"rotate(-5deg)"},children:["audio"===e3&&(0,t.jsx)(h.Loader2Icon,{className:"size-4 animate-spin text-white/30"}),"audio"!==e3&&(0,t.jsx)(O.Volume2Icon,{className:`size-4 ${e0[0]?"text-primary":"text-white/30"}`})]}),(0,t.jsx)("input",{ref:t7,type:"file",accept:".mp3,.wav",onChange:async e=>{let t=e.target.files?.[0];if(t){e4("audio");try{let e=await (0,l.uploadFileFromBrowser)(t,ew("audio"));e1([e.url])}catch(e){M.logger.error("[VideoGenerator] wan audio upload failed",e),ta("Audio upload failed")}finally{e4(null),t7.current&&(t7.current.value="")}}},className:"hidden"})]})]}),"frames-to-video"===e_&&(0,t.jsxs)("div",{className:"relative z-10 flex shrink-0 gap-2 sm:float-left sm:mr-2.5 sm:mb-2",children:[(0,t.jsxs)("div",{className:"flex flex-col items-center gap-1",children:[(0,t.jsxs)("button",{type:"button",onClick:()=>t8.current?.click(),disabled:e8||aG,className:"flex h-[52px] w-[40px] sm:h-[60px] sm:w-[45px] cursor-pointer items-center justify-center rounded border border-dashed border-white/[0.12] bg-white/[0.04] transition-colors hover:bg-white/[0.08] disabled:cursor-not-allowed disabled:opacity-40",style:{transform:"rotate(-5deg)"},children:[eX[0]&&(0,t.jsx)("img",{src:eX[0],alt:"Start",className:"size-full rounded object-cover"}),!eX[0]&&(0,t.jsx)(T.PlusIcon,{className:"size-4 text-white/30"})]}),(0,t.jsx)("span",{className:"text-[10px] text-white/40",children:"Start"}),(0,t.jsx)("input",{ref:t8,type:"file",accept:ex,onChange:e=>{let t=e.target.files?.[0];if(t){if(!aR([t],1)){t8.current&&(t8.current.value="");return}e4("image"),(0,l.uploadFileFromBrowser)(t,ew("input")).then(e=>{eZ(t=>
1[e.url,t[1]||""].filter(Boolean))}).catch(e=>{M.logger.error("[VideoGenerator] frame upload failed",e),ta("Upload failed")}).finally(()=>{e4(null),t8.current&&(t8.current.value="")})}},className:"hidden"})]}),(0,t.jsxs)("div",{className:"flex flex-col items-center gap-1",children:[(0,t.jsxs)("button",{type:"button",onClick:()=>{let e=document.createElement("input");e.type="file",e.accept=ex,e.onchange=e=>{let t=e.target.files?.[0];!t||aR([t],1)&&(e4("image"),(0,l.uploadFileFromBrowser)(t,ew("input")).then(e=>{eZ(t=>[t[0]||"",e.url].filter(Boolean))}).catch(e=>{M.logger.error("[VideoGenerator] frame upload failed",e),ta("Upload failed")}).finally(()=>e4(null)))},e.click()},disabled:e8||aG,className:"flex h-[52px] w-[40px] sm:h-[60px] sm:w-[45px] cursor-pointer items-center justify-center rounded border border-dashed border-white/[0.12] bg-white/[0.04] transition-colors hover:bg-white/[0.08] disabled:cursor-not-allowed disabled:opacity-40",style:{transform:"rotate(-5deg)"},children:[eX[1]&&(0,t.jsx)("img",{src:eX[1],alt:"End",className:"size-full rounded object-cover"}),!eX[1]&&(0,t.jsx)(T.PlusIcon,{className:"size-4 text-white/30"})]}),(0,t.jsx)("span",{className:"text-[10px] text-white/40",children:"End"})]})]}),"reference-to-video"===e_&&(0,t.jsxs)("div",{className:"relative z-10 flex shrink-0 gap-1.5 sm:float-left sm:mr-2.5 sm:mb-2",children:[(0,t.jsxs)("button",{type:"button",onClick:()=>t8.current?.click(),disabled:e8||aG||eX.length>=9,title:eX.length>=9?"Image limit reached (9)":"Add image",className:`relative flex h-[66px] w-[64px] shrink-0 cursor-pointer flex-col items-center justify-center gap-1 rounded-lg border border-dashed transition-colors disabled:cursor-not-allowed disabled:opacity-40 ${eX.length>0?"border-primary/30 bg-primary/10 hover:bg-primary/15":"border-white/[0.12] bg-white/[0.04] hover:bg-white/[0.08]"}`,children:["image"===e3&&(0,t.jsx)(h.Loader2Icon,{className:"size-4 animate-spin text-white/30"}),"image"!==e3&&(0,t.jsx)(u.ImageIcon,{className:`size-[18px] ${eX.length>0?"text-primary":"text-white/35"}`}),(0,t.jsx)("span",{className:`text-[10px] font-medium leading-none ${eX.length>0?"text-primary/90":"text-white/40"}`,children:"Image"}),eX.length>0&&(0,t.jsx)("span",{className:"absolute -right-1 -top-1 flex size-4 items-center justify-center rounded-full bg-primary font-mono text-[8px] font-bold text-primary-foreground",children:eX.length})]}),(0,t.jsx)("input",{ref:t8,type:"file",accept:ex,multiple:!0,onChange:aP,className:"hidden"}),(0,t.jsxs)("button",{type:"button",onClick:()=>t6.current?.click(),disabled:e8||aG||eK.length>=3,title:eK.length>=3?"Video limit reached (3)":"Add video",className:`relative flex h-[66px] w-[64px] shrink-0 cursor-pointer flex-col items-center justify-center gap-1 rounded-lg border border-dashed transition-colors disabled:cursor-not-allowed disabled:opacity-40 ${eK.length>0?"border-primary/30 bg-primary/10 hover:bg-primary/15":"border-white/[0.12] bg-white/[0.04] hover:bg-white/[0.08]"}`,children:["video"===e3&&(0,t.jsx)(h.Loader2Icon,{className:"size-4 animate-spin text-white/30"}),"video"!==e3&&(0,t.jsx)(V.PlayIcon,{className:`size-[18px] ${eK.length>0?"text-primary":"text-white/35"}`}),(0,t.jsx)("span",{className:`text-[10px] font-medium leading-none ${eK.length>0?"text-primary/90":"text-white/40"}`,children:"Video"}),eK.length>0&&(0,t.jsx)("span",{className:"absolute -right-1 -top-1 flex size-4 items-center justify-center rounded-full bg-primary font-mono text-[8px] font-bold text-primary-foreground",children:eK.length})]}),(0,t.jsx)("input",{ref:t6,type:"file",accept:".mp4,.mov",multiple:!0,onChange:async e=>{let t=e.target.files;if(!t||0===t.length)return;let a=Array.from(t);if(eK.length+a.length>3){ta("Reference videos are limited to 3 files."),t6.current&&(t6.current.value="");return}if(a.find(e=>!/\.(mp4|mov)$/i.test(e.name))){ta("Reference videos must be MP4 or MOV files."),t6.current&&(t6.current.value="");return}if(a.find(e=>e.size>0x3200000)){ta("Each reference video must be 50 MB or smaller."),t6.current&&(t6.current.value="");return}let r=await Promise.all(a.map(e=>new Promise(t=>{let a=URL.createObjectURL(e),r=document.createElement("video");r.preload="metadata",r.src=a,r.onloadedmetadata=()=>{let e=Number.isFinite(r.duration)?r.duration:0,i=r.videoWidth||0,s=r.videoHeight||0;URL.revokeObjectURL(a),t({duration:e,pixels:i*s,w:i,h:s})},r.onerror=()=>{URL.revokeObjectURL(a),t({duration:0,pixels:0,w:0,h:0})}})));if(r.find(e=>e.duration<2||e.duration>15)){ta("Each reference video must be 2 to 15 seconds."),t6.current&&(t6.current.value="");return}if(r.find(e=>{if(e.w<300||e.h<300||e.w>6e3||e.h>6e3)return!0;let t=e.w/e.h;return t<.4||t>2.5})){ta("Reference video dimensions must be 300-6000 px with aspect ratio 0.4-2.5."),t6.current&&(t6.current.value="");return}let i=r.find(e=>
1e.pixels<409600||e.pixels>927408);if(i){ta(`Reference video size ${i.w}\xd7${i.h} is outside the supported pixel range.`),t6.current&&(t6.current.value="");return}let s=r.map(e=>e.duration),n=eJ.reduce((e,t)=>e+t,0)+s.reduce((e,t)=>e+t,0);if(n>15){ta(`Reference videos total ${n.toFixed(1)}s â must be ⤠15s.`),t6.current&&(t6.current.value="");return}e4("video");try{let e=await Promise.all(a.map(e=>(0,l.uploadFileFromBrowser)(e,ew("video"))));eQ(t=>[...t,...e.map(e=>e.url)].slice(0,3)),eY(e=>[...e,...s].slice(0,3))}catch(e){M.logger.error("[VideoGenerator] video upload failed",e),ta("Video upload failed")}finally{e4(null),t6.current&&(t6.current.value="")}},className:"hidden"}),(0,t.jsxs)("button",{type:"button",onClick:()=>t7.current?.click(),disabled:e8||aG||e0.length>=3,title:e0.length>=3?"Audio limit reached (3)":"Add audio",className:`relative flex h-[66px] w-[64px] shrink-0 cursor-pointer flex-col items-center justify-center gap-1 rounded-lg border border-dashed transition-colors disabled:cursor-not-allowed disabled:opacity-40 ${e0.length>0?"border-primary/30 bg-primary/10 hover:bg-primary/15":"border-white/[0.12] bg-white/[0.04] hover:bg-white/[0.08]"}`,children:["audio"===e3&&(0,t.jsx)(h.Loader2Icon,{className:"size-4 animate-spin text-white/30"}),"audio"!==e3&&(0,t.jsx)(O.Volume2Icon,{className:`size-[18px] ${e0.length>0?"text-primary":"text-white/35"}`}),(0,t.jsx)("span",{className:`text-[10px] font-medium leading-none ${e0.length>0?"text-primary/90":"text-white/40"}`,children:"Audio"}),e0.length>0&&(0,t.jsx)("span",{className:"absolute -right-1 -top-1 flex size-4 items-center justify-center rounded-full bg-primary font-mono text-[8px] font-bold text-primary-foreground",children:e0.length})]}),(0,t.jsx)("input",{ref:t7,type:"file",accept:".mp3,.wav",multiple:!0,onChange:async e=>{let t=e.target.files;if(!t||0===t.length)return;let a=Array.from(t);if(e0.length+a.length>3){ta("Reference audios are limited to 3 files."),t7.current&&(t7.current.value="");return}if(a.find(e=>!/\.(mp3|wav)$/i.test(e.name))){ta("Reference audios must be MP3 or WAV files."),t7.current&&(t7.current.value="");return}if(a.find(e=>e.size>0xf00000)){ta("Each reference audio must be 15 MB or smaller."),t7.current&&(t7.current.value="");return}let r=await Promise.all(a.map(e=>new Promise(t=>{let a=URL.createObjectURL(e),r=document.createElement("audio");r.preload="metadata",r.src=a,r.onloadedmetadata=()=>{let e=Number.isFinite(r.duration)?r.duration:0;URL.revokeObjectURL(a),t(e)},r.onerror=()=>{URL.revokeObjectURL(a),t(0)}})));if(r.some(e=>e<2||e>15)){ta("Each reference audio must be 2 to 15 seconds."),t7.current&&(t7.current.value="");return}if(e2.reduce((e,t)=>e+t,0)+r.reduce((e,t)=>e+t,0)>15){ta("Reference audios total duration must be <= 15s."),t7.current&&(t7.current.value="");return}e4("audio");try{let e=await Promise.all(a.map(e=>(0,l.uploadFileFromBrowser)(e,ew("audio"))));e1(t=>[...t,...e.map(e=>e.url)].slice(0,3)),e5(e=>[...e,...r].slice(0,3))}catch(e){M.logger.error("[VideoGenerator] audio upload failed",e),ta("Audio upload failed")}finally{e4(null),t7.current&&(t7.current.value="")}},className:"hidden"})]}),(0,t.jsxs)("div",{className:"relative min-h-[72px] flex-1 sm:min-h-[140px]",children:[(eX.length>0||eK.length>0||e0.length>0)&&(0,t.jsxs)("div",{className:"mb-2 hidden items-center gap-2 overflow-x-auto sm:flex",children:[eX.length>0&&"frames-to-video"!==e_&&(0,t.jsx)("div",{className:"flex shrink-0 items-center gap-1.5",children:eX.map((e,a)=>(0,t.jsxs)("div",{className:"group relative size-12 shrink-0 overflow-hidden rounded-md",children:[(0,t.jsx)("img",{src:e,alt:`Reference ${a+1}`,className:"size-full object-cover"}),(0,t.jsxs)("span",{className:"pointer-events-none absolute left-0 top-0 rounded-br bg-black/70 px-1 text-[8px] font-semibold tracking-wider text-white/85",children:["I",a+1]}),(0,t.jsx)("button",{type:"button",onClick:()=>aL(a),className:"absolute inset-0 flex items-center justify-center bg-black/60 opacity-0 transition-opacity group-hover:opacity-100 [@media(hover:none)]:opacity-100 [@media(hover:none)]:bg-black/40",children:(0,t.jsx)(G.Trash2Icon,{className:"size-3 text-white"})})]},e))}),eX.length>0&&(eK.length>0||e0.length>0)&&(0,t.jsx)("span",{className:"h-8 w-px shrink-0 bg-white/[0.08]"}),eK.length>0&&(0,t.jsx)("div",{className:"flex shrink-0 items-center gap-1.5",children:eK.map((e,a)=>(0,t.jsxs)("div",{className:"group relative size-12 shrink-0 overflow-hidden rounded-md bg-black",children:[(0,t.jsx)("video",{src:`${e}
1#t=0.001`,muted:!0,playsInline:!0,preload:"metadata",className:"size-full object-cover"}),(0,t.jsxs)("span",{className:"pointer-events-none absolute left-0 top-0 rounded-br bg-black/70 px-1 text-[8px] font-semibold tracking-wider text-white/85",children:["V",a+1]}),(0,t.jsx)("span",{className:"pointer-events-none absolute bottom-0 right-0 rounded-tl bg-black/70 px-1 font-mono text-[8px] tabular-nums text-white/80",children:eJ[a]?`${eJ[a].toFixed(1)}s`:""}),(0,t.jsx)(V.PlayIcon,{className:"pointer-events-none absolute left-1/2 top-1/2 size-3.5 -translate-x-1/2 -translate-y-1/2 text-white/90 drop-shadow"}),(0,t.jsx)("button",{type:"button",onClick:()=>aE(a),className:"absolute inset-0 flex items-center justify-center bg-black/60 opacity-0 transition-opacity group-hover:opacity-100 [@media(hover:none)]:opacity-100 [@media(hover:none)]:bg-black/40",children:(0,t.jsx)(G.Trash2Icon,{className:"size-3 text-white"})})]},e))}),eK.length>0&&e0.length>0&&(0,t.jsx)("span",{className:"h-8 w-px shrink-0 bg-white/[0.08]"}),e0.length>0&&(0,t.jsx)("div",{className:"flex shrink-0 items-center gap-1.5",children:e0.map((e,a)=>(0,t.jsxs)("div",{className:"group relative flex size-12 shrink-0 items-center justify-center overflow-hidden rounded-md bg-primary/10",children:[(0,t.jsx)(O.Volume2Icon,{className:"size-4 text-primary/80"}),(0,t.jsxs)("span",{className:"pointer-events-none absolute left-0 top-0 rounded-br bg-black/70 px-1 text-[8px] font-semibold tracking-wider text-white/85",children:["A",a+1]}),(0,t.jsx)("button",{type:"button",onClick:()=>aF(a),className:"absolute inset-0 flex items-center justify-center bg-black/60 opacity-0 transition-opacity group-hover:opacity-100 [@media(hover:none)]:opacity-100 [@media(hover:none)]:bg-black/40",children:(0,t.jsx)(G.Trash2Icon,{className:"size-3 text-white"})})]},e))})]}),an&&(0,t.jsx)("div",{"aria-hidden":!0,className:"pointer-events-none absolute inset-y-0 right-0 hidden items-center justify-end sm:flex",children:(0,t.jsx)("img",{src:"https://cdn.xchatai.io/assets/images/faceswap.webp",alt:"",className:"h-full max-h-[220px] w-auto rounded-md object-contain opacity-90"})}),(0,t.jsx)(k,{prompt:ek,onPromptChange:eC,mediaGroups:{image:eX.map((e,t)=>({kind:"image",mentionIndex:t+1,url:e})),video:eK.map((e,t)=>({kind:"video",mentionIndex:t+1,url:e})),audio:e0.map((e,t)=>({kind:"audio",mentionIndex:t+1,url:e}))},placeholder:"",disabled:aG||an,rows:5,modelFamily:t9.family,referenceImageUrl:eX[0],videoDuration:eA,optimizeBarTarget:ez,bottomBarLeftSlot:ad?c.map(e=>(0,t.jsxs)("button",{type:"button",onClick:()=>{eC(e.prompt),ta(null)},disabled:aG,className:"inline-flex max-w-full shrink-0 items-center gap-1.5 rounded-full border border-white/[0.08] bg-white/[0.04] px-2.5 py-1.5 text-left text-[11px] font-medium text-white/60 transition-colors hover:border-white/[0.16] hover:bg-white/[0.08] hover:text-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/45 disabled:pointer-events-none disabled:opacity-40 sm:text-xs",children:[(0,t.jsx)(W.WandSparklesIcon,{className:"size-3 shrink-0 text-primary/75"}),(0,t.jsx)("span",{className:"truncate",children:e.label})]},e.label)):null}),aG&&(0,t.jsxs)("div",{className:"mt-1 flex flex-wrap items-center gap-x-2 gap-y-1",children:[(0,t.jsxs)("span",{className:"relative size-3.5 shrink-0",children:[(0,t.jsx)("span",{className:"absolute inset-0 rounded-full border border-primary/20"}),(0,t.jsx)("span",{className:"absolute inset-0 animate-spin rounded-full border border-transparent border-r-primary/60 border-t-primary",style:{animationDuration:"850ms"}})]}),(0,t.jsxs)("span",{className:"text-xs text-white/50",children:[aO,(ar||ae)&&(0,t.jsx)("span",{className:"ml-1.5 text-white/40",children:"· ~2â5 min"}),(ai||as)&&(0,t.jsx)("span",{className:"ml-1.5 text-white/40",children:"· ~30 sec to 2 min"})]}),(0,t.jsx)("span",{className:"text-xs text-white/35",children:"You can close this tab â it'll show up in My Creations."})]}),tt&&(0,t.jsxs)("div",{className:"mt-1 flex items-center gap-1.5",children:[(0,t.jsx)(q.XIcon,{className:"size-3 text-red-400"}),(0,t.jsx)("span",{className:"text-xs text-red-400",children:tt})]})]})]}),(0,t.jsxs)("div",{className:"-mx-1 mt-0 flex items-center gap-0.5 overflow-x-auto border-t border-white/[0.06] px-1 pt-2 sm:gap-1.5 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:[(0,t.jsxs)(I.Popover,{open:tl,onOpenChange:to,children:[(0,t.jsx)(I.PopoverTrigger,{asChild:!0,children:(0,t.jsxs)("button",{type:"button",className:"flex h-8 shrink-0 items-center gap-1.5 rounded-lg bg-white/[0.06] px-1.5 text-sm text-white/80 transition-colors hover:bg-white/[0.1] sm:px-3",children:[(0,t.jsx)("img",{src:t9.icon,alt:"",className:"size-4 rounded-sm"}),(0,t.jsx)("span",{className:"hidden sm:inline",children:t9.name}),(0,t.jsxs)("span",{className:"sm:hidden",children:["high"===t9.id&&"2.0","basic"===t9.id&&"2.0F",("xchatv1"===t9.id||"xchatv2"===t9.id||"xchati1"===t9.id||"chat-i1"===t9.id||"face-swap"===t9.id)&&n[t9.id]?.short]}),(0,t.jsx)(R.ChevronDownIcon,{className:"size-3.5 text-white/40"})]})}),(0,t.jsx)(I.PopoverContent,{align:"start",className:"w-[calc(100vw-2rem)] max-w-[320px] p-1",children:J.filter(e=>"video"===ao?Q(e.family)||"seedance"===e.family:"image"===ao?"xchati1"===e.family||Y(e):"face-swap"===e.family).sort((e,t)=>
1"video"!==ao?0:"xchatv2"===e.family?-1:"xchatv2"===t.family?1:"xchatv1"===e.family?-1:+("xchatv1"===t.family)).map(e=>(0,t.jsxs)("button",{type:"button",onClick:()=>{e$(e.id),to(!1)},className:`flex w-full flex-col gap-px rounded-md px-2.5 py-2 text-left transition-colors hover:bg-white/[0.06] ${eM===e.id?"bg-white/[0.08]":""}`,children:[(0,t.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,t.jsx)("img",{src:e.icon,alt:"",className:"size-4 shrink-0 rounded-sm"}),(0,t.jsx)("span",{className:"truncate text-sm font-medium",children:e.name})]}),(0,t.jsx)("p",{className:"ml-6 truncate text-[11px] leading-4 text-muted-foreground",children:e.desc})]},e.id))})]}),!ar&&!al&&!g&&(0,t.jsxs)(I.Popover,{open:td,onOpenChange:tc,children:[(0,t.jsx)(I.PopoverTrigger,{asChild:!0,children:(0,t.jsxs)("button",{type:"button",className:"flex h-8 shrink-0 items-center gap-1.5 rounded-lg bg-white/[0.06] px-1.5 text-sm text-white/80 transition-colors hover:bg-white/[0.1] sm:px-3",children:[(0,t.jsx)(a$,{className:"size-4"}),(0,t.jsx)("span",{className:"hidden sm:inline",children:aM.name}),(0,t.jsx)(R.ChevronDownIcon,{className:"size-3.5 text-white/40"})]})}),(0,t.jsxs)(I.PopoverContent,{align:"start",className:"w-[calc(100vw-2rem)] max-w-[240px] p-1.5",children:[(0,t.jsx)("p",{className:"px-3 py-1.5 text-xs text-muted-foreground",children:"Features"}),Z.map(e=>{let a=e.icon;return(0,t.jsxs)("button",{type:"button",onClick:()=>{eS(e.id),tc(!1),eZ([]),eQ([]),e1([]),eY([])},className:`flex w-full items-center gap-2 rounded-md px-3 py-2 text-left text-sm transition-colors hover:bg-white/[0.06] ${e_===e.id?"bg-white/[0.08] font-medium":"text-white/70"}`,children:[(0,t.jsx)(a,{className:"size-4"})," ",e.name]},e.id)})]})]}),(as||ai&&0===eX.length)&&(0,t.jsxs)("div",{title:"Image size (width à height)",className:"flex h-8 shrink-0 items-center gap-1 rounded-lg bg-white/[0.06] px-1.5 text-xs text-white/75 sm:px-3",children:[(0,t.jsx)("span",{className:"hidden text-white/45 sm:inline",children:"W"}),(0,t.jsx)("input",{type:"number",min:256,max:1536,step:64,"aria-label":"Width",value:tJ,onChange:e=>tY(Math.max(256,Math.min(1536,Number(e.target.value)||1024))),className:"h-6 w-10 rounded bg-white/[0.04] px-1 text-right tabular-nums outline-none focus:bg-white/[0.08] sm:w-12 [appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none"}),(0,t.jsx)("span",{className:"text-white/45",children:"Ã"}),(0,t.jsx)("span",{className:"hidden text-white/45 sm:inline",children:"H"}),(0,t.jsx)("input",{type:"number",min:256,max:1536,step:64,"aria-label":"Height",value:t0,onChange:e=>t1(Math.max(256,Math.min(1536,Number(e.target.value)||1536))),className:"h-6 w-10 rounded bg-white/[0.04] px-1 text-right tabular-nums outline-none focus:bg-white/[0.08] sm:w-12 [appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none"})]}),!al&&(0,t.jsxs)(I.Popover,{children:[(0,t.jsx)(I.PopoverTrigger,{asChild:!0,children:(0,t.jsxs)("button",{type:"button",className:"flex h-8 shrink-0 items-center gap-1.5 rounded-lg bg-white/[0.06] px-1.5 text-sm text-white/80 transition-colors hover:bg-white/[0.1] sm:gap-2 sm:px-3",children:[ar?(0,t.jsx)(P.ClapperboardIcon,{className:"size-4 text-white/55"}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(ev,{w:ed.find(e=>e.value===eR).w,h:ed.find(e=>e.value===eR).h,active:!1}),(0,t.jsx)("span",{children:eR}),(0,t.jsx)("span",{className:"inline-block h-3 w-px bg-white/20"})]}),(0,t.jsxs)("span",{children:[eA,"s"]}),(0,t.jsx)("span",{className:"inline-block h-3 w-px bg-white/20"}),(0,t.jsx)("span",{children:eE})]})}),(0,t.jsxs)(I.PopoverContent,{align:"start",className:"w-[calc(100vw-2rem)] max-w-[340px] p-4",children:[!ar&&(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"mb-2 text-xs text-muted-foreground",children:"Aspect Ratio"}),(0,t.jsx)("div",{className:"flex flex-wrap gap-1.5",children:ed.map(e=>(0,t.jsxs)("button",{type:"button",onClick:()=>eP(e.value),className:`flex flex-col items-center gap-1 rounded-lg px-3 py-2 text-xs font-medium transition-colors ${eR===e.value?"bg-primary text-primary-foreground":"bg-white/[0.06] text-white/70 hover:bg-white/[0.1]"}`,children:[(0,t.jsx)(ev,{w:e.w,h:e.h,active:eR===e.value}),e.value]},e.value))})]}),(0,t.jsxs)("div",{className:ar?"":"mt-4",children:[(0,t.jsx)("p",{className:"mb-2 text-xs text-muted-foreground",children:"Video Length"}),(0,t.jsx)("div",{className:"grid grid-cols-6 gap-1.5",children:aI.map(e=>(0,t.jsxs)("button",{type:"button",onClick:()=>eL(e),className:`rounded-md py-1.5 text-center text-xs font-medium transition-colors ${eA===e?"bg-primary text-primary-foreground":"bg-white/[0.06] text-white/70 hover:bg-white/[0.1]"}`,children:[e,"s"]},e))})]}),(0,t.jsxs)("div",{className:"mt-4",children:[(0,t.jsx)("p",{className:"mb-2 text-xs text-muted-foreground",children:"Resolution"}),(0,t.jsx)("div",{className:"flex gap-1.5",children:az.map(e=>(0,t.jsx)("button",{type:"button",onClick:()=>eF(e),className:`flex-1 rounded-md py-2 text-xs font-medium transition-colors ${eE===e?"bg-primary text-primary-foreground":"bg-white/[0.06] text-white/70 hover:bg-white/[0.1]"}`,children:e},e))})]})]})]}),al&&(0,t.jsxs)("div",{className:"flex h-8 shrink-0 items-center gap-1.5 rounded-lg bg-white/[0.06] px-1.5 text-xs text-white/75 sm:px-3",children:[(0,t.jsx)("span",{className:"hidden text-white/45 sm:inline",children:"Seed"}),(0,t.jsx)("input",{type:"text",inputMode:"numeric",placeholder:"Seed","aria-label":"Seed (leave empty for random)",value:eq,onChange:e=>
1eH(e.target.value),className:"h-6 w-14 rounded bg-white/[0.04] px-1 tabular-nums outline-none focus:bg-white/[0.08] sm:w-20"})]}),!al&&(0,t.jsxs)(I.Popover,{open:tm,onOpenChange:tu,children:[(0,t.jsx)(I.PopoverTrigger,{asChild:!0,children:(0,t.jsx)("button",{type:"button",className:"flex size-9 shrink-0 items-center justify-center rounded-lg bg-white/[0.06] transition-colors hover:bg-white/[0.1]",children:(0,t.jsx)(F.MoreHorizontalIcon,{className:"size-4 text-white/60"})})}),(0,t.jsxs)(I.PopoverContent,{align:"end",className:"w-[calc(100vw-2rem)] max-w-[320px] p-4",children:[at&&(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"mb-1.5 text-sm font-medium",children:"Negative Prompt"}),(0,t.jsx)("input",{type:"text",value:eV,onChange:e=>eT(e.target.value),placeholder:"blurry, distorted, extra limbs",className:"h-9 w-full rounded-md border border-white/[0.08] bg-white/[0.04] px-3 text-sm text-white placeholder:text-white/30 focus:border-primary focus:outline-none"})]}),!ar&&(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-sm font-medium",children:"Generate Audio"}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:"Generate natural-sounding, fitting audio for the video"})]}),(0,t.jsx)(_.Switch,{checked:eG,onCheckedChange:eB})]}),!ar&&(0,t.jsxs)("div",{className:"mt-4 flex items-center justify-between",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-sm font-medium",children:"Web Search"}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:"Search the web for up-to-date context before generating"})]}),(0,t.jsx)(_.Switch,{checked:eO,onCheckedChange:eW})]})]})]}),(0,t.jsx)("div",{className:"flex min-w-0 flex-1 items-center justify-end px-2",ref:eI}),(0,t.jsxs)("div",{className:"ml-auto hidden items-center gap-2 sm:flex",children:[aB&&(0,t.jsx)("button",{type:"button",onClick:aD,disabled:aG,"aria-label":"Clear prompt",title:"Clear prompt",className:"flex size-8 shrink-0 items-center justify-center rounded-full border border-white/[0.08] bg-white/[0.04] text-white/55 transition-colors hover:border-white/[0.16] hover:bg-white/[0.08] hover:text-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/45 disabled:pointer-events-none disabled:opacity-40",children:(0,t.jsx)(U.RefreshCwIcon,{className:"size-3.5"})}),ej&&(0,t.jsxs)(C.Button,{size:"sm",disabled:aG,"aria-disabled":!aq,onClick:aX,title:aH??void 0,"aria-label":aH??"Generate",className:"h-8 rounded-full bg-primary px-4 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:bg-white/[0.06] disabled:text-white/30 aria-disabled:cursor-not-allowed aria-disabled:bg-white/[0.06] aria-disabled:text-white/30 aria-disabled:hover:bg-white/[0.06]",children:[aG&&(0,t.jsx)(h.Loader2Icon,{className:"mr-1 size-3.5 animate-spin"}),!aG&&(0,t.jsx)(V.PlayIcon,{className:"mr-1 size-3.5"}),"Generate",(0,t.jsxs)("span",{className:"ml-1.5 flex items-center gap-0.5 text-xs font-semibold",children:[(0,t.jsx)(D.CoinsIcon,{className:"size-3"})," ",j]})]}),!ej&&(0,t.jsx)(C.Button,{asChild:!0,size:"sm",className:"h-8 rounded-full bg-primary px-4 text-xs font-medium text-primary-foreground hover:bg-primary/90",children:(0,t.jsxs)(S.LocaleLink,{href:"/auth/register",children:["Generate",(0,t.jsxs)("span",{className:"ml-1.5 flex items-center gap-0.5 text-xs font-semibold",children:[(0,t.jsx)(D.CoinsIcon,{className:"size-3"})," ",j]}),(0,t.jsx)($.ArrowRightIcon,{className:"ml-1 size-3.5"})]})})]})]}),(0,t.jsxs)("div",{className:"mt-3 flex gap-2 sm:hidden",children:[aB&&(0,t.jsx)("button",{type:"button",onClick:aD,disabled:aG,"aria-label":"Clear prompt",title:"Clear prompt",className:"flex size-11 shrink-0 items-center justify-center rounded-full border border-white/[0.08] bg-white/[0.04] text-white/55 transition-colors hover:border-white/[0.16] hover:bg-white/[0.08] hover:text-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/45 disabled:pointer-events-none disabled:opacity-40",children:(0,t.jsx)(U.RefreshCwIcon,{className:"size-4"})}),ej&&(0,t.jsxs)(C.Button,{disabled:aG,"aria-disabled":!aq,onClick:aX,title:aH??void 0,"aria-label":aH??"Generate",className:"h-11 flex-1 rounded-full bg-primary text-sm font-semibold text-primary-foreground hover:bg-primary/90 disabled:bg-white/[0.06] disabled:text-white/30 aria-disabled:cursor-not-allowed aria-disabled:bg-white/[0.06] aria-disabled:text-white/30 aria-disabled:hover:bg-white/[0.06]",children:[aG&&(0,t.jsx)(h.Loader2Icon,{className:"mr-1.5 size-4 animate-spin"}),!aG&&(0,t.jsx)(V.PlayIcon,{className:"mr-1.5 size-4"}),"Generate",(0,t.jsxs)("span",{className:"ml-2 flex items-center gap-0.5 text-sm font-bold",children:[(0,t.jsx)(D.CoinsIcon,{className:"size-3.5"})," ",j]})]}),!ej&&(0,t.jsx)(C.Button,{asChild:!0,className:"h-11 flex-1 rounded-full bg-primary text-sm font-semibold text-primary-foreground hover:bg-primary/90",children:(0,t.jsxs)(S.LocaleLink,{href:"/auth/register",children:["Generate",(0,t.jsxs)("span",{className:"ml-2 flex items-center gap-0.5 text-sm font-bold",children:[(0,t.jsx)(D.CoinsIcon,{className:"size-3.5"})," ",j]}),(0,t.jsx)($.ArrowRightIcon,{className:"ml-1.5 size-4"})]})})]})]}),e9?.imageUrls&&e9.imageUrls.length>0&&(0,t.jsxs)("section",{className:"mt-6 overflow-hidden rounded-2xl border border-white/[0.06] bg-background",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3 border-b border-white/[0.04] bg-white/[0.02] px-4 py-2.5",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:"size-1.5 rounded-full bg-emerald-400"}),(0,t.jsx)("span",{className:"text-xs font-semibold text-white/70",children:"Ready"})]}),(0,t.jsxs)("div",{className:"flex items-center gap-4",children:[(0,t.jsxs)(S.LocaleLink,{href:"/my-creations",className:"inline-flex items-center gap-1.5 text-xs font-semibold text-white/60 transition-colors hover:text-white",children:["Archive",(0,t.jsx)($.ArrowRightIcon,{className:"size-3"})]}),(0,t.jsx)("button",{type:"button",onClick:aU,"aria-label":"Close result",className:"flex size-6 items-center justify-center rounded-md text-white/50 transition-colors hover:bg-white/[0.06] hover:text-white",children:(0,t.jsx)(q.XIcon,{className:"size-3.5"})})]})]}),(0,t.jsx)("div",{className:`mx-auto grid max-w-[720px] gap-3 p-3 ${1===e9.imageUrls.length?"grid-cols-1":"grid-cols-2"}`,children:e9.imageUrls.map((e,a)=>(0,t.jsx)("button",{type:"button",onClick:()=>tq(e),className:"group relative block cursor-zoom-in overflow-hidden rounded-xl border border-white/[0.06] bg-black/40",children:(0,t.jsx)("img",{src:e,alt:`generated ${a+1}
1`,className:"mx-auto block max-h-[500px] w-auto max-w-full object-contain transition-transform duration-300 group-hover:scale-[1.015]"})},a))})]}),e9?.videoUrl&&(0,t.jsxs)("section",{className:"mt-6 overflow-hidden rounded-2xl border border-white/[0.06] bg-background",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3 border-b border-white/[0.04] bg-white/[0.02] px-4 py-2.5",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:"size-1.5 rounded-full bg-emerald-400"}),(0,t.jsx)("span",{className:"text-xs font-semibold text-white/70",children:"Ready"})]}),(0,t.jsxs)("div",{className:"flex items-center gap-4",children:[e9.taskId&&(0,t.jsxs)("a",{href:`/api/my-creations/${e9.taskId}/download`,className:"inline-flex items-center gap-1.5 text-xs font-semibold text-white/60 transition-colors hover:text-white",children:[(0,t.jsx)(L.DownloadIcon,{className:"size-3"}),"Download"]}),(0,t.jsxs)(S.LocaleLink,{href:"/my-creations",className:"inline-flex items-center gap-1.5 text-xs font-semibold text-white/60 transition-colors hover:text-white",children:["Archive",(0,t.jsx)($.ArrowRightIcon,{className:"size-3"})]}),(0,t.jsxs)(S.LocaleLink,{href:aW,className:"inline-flex items-center gap-1.5 text-xs font-semibold text-primary/85 transition-colors hover:text-primary",children:[(0,t.jsx)(U.RefreshCwIcon,{className:"size-3"}),"Remix"]}),(0,t.jsx)("button",{type:"button",onClick:aU,"aria-label":"Close result",className:"flex size-6 items-center justify-center rounded-md text-white/50 transition-colors hover:bg-white/[0.06] hover:text-white",children:(0,t.jsx)(q.XIcon,{className:"size-3.5"})})]})]}),(0,t.jsx)("div",{className:"relative mx-auto max-w-[720px] bg-black",children:(0,t.jsx)("video",{src:e9.videoUrl,poster:e9.thumbnailUrl,controls:!0,playsInline:!0,preload:"none",className:"block w-full"})})]}),(0,t.jsx)(z.Dialog,{open:!!tW,onOpenChange:e=>!e&&tq(null),children:(0,t.jsxs)(z.DialogContent,{className:"!sm:max-w-none max-h-[92vh] w-auto !max-w-[92vw] bg-transparent p-0 ring-0",showCloseButton:!1,children:[(0,t.jsx)(z.DialogTitle,{className:"sr-only",children:"Generated image preview"}),tW&&(0,t.jsx)("img",{src:tW,alt:"generated",className:"block max-h-[92vh] max-w-[92vw] rounded-lg object-contain"})]})})]})}e.s(["VideoGenerator",()=>ej],524629)}]);
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.