1import{o as dn}from"./rolldown-runtime-ChpBd9eV.js";import{a as ro,o as ao}from"./framer-D6rFZViT.js";import{Cr as un,Er as so,Ji as ve,Ki as no,Kn as mn,S as As,Wn as pn,Yi as pe,Yt as oo,b as io,ea as lo,k as co,mr as st,pr as ds,qr as xe,v as uo,vi as mo,w as Rs,x as Er,y as fr,zn as po}from"./landing-bottom-BIxvSgA_.js";import{t as $s}from"./arrow-right-CPaKH5-d.js";import{t as da}from"./MediaSourcePicker-BMNzdwRi.js";import{t as ho}from"./minimize-2-DkdGXfqP.js";import{t as us}from"./package-B6rnr8j3.js";import{t as fo}from"./pencil-yoyrsiY0.js";import{t as go}from"./refresh-cw-Q4wKUrok.js";import{t as yo}from"./user-round-DfLn3uHn.js";import{I as bo,Jn as hn,Jr as Wr,Kr as Jr,Pi as xo,Qn as je,Qr as Ms,Ri as Gr,Ti as Zr,Vi as vo,Xn as ja,_n as ko,bn as wo,gn as _o,gr as Ve,hr as Io,qn as fn,qr as Fa,si as So,ui as jo,vn as No,xn as Co,yn as Po}from"./index-Cj5sqahA.js";import{n as To}from"./useVideoPlayBudget-CmTUTdkg.js";import{a as Eo,n as Tr}from"./invokeProviderRouter-EMfp98Qx.js";import{t as Ao}from"./creditRounding-B6m0fPdg.js";import{F as Ro}from"./modelPromptLimitStore-B9Wn0w86.js";import{L as $o,N as Mo,P as Ga,S as Uo,b as os,f as Do,i as Va,m as Xr,r as na,v as Oo,x as Lo,y as gn,z as Fo}from"./Seedance2Module-BMRq3jXv.js";import{r as yn}from"./creditCost-DvoVJGm-.js";import{r as Ha,t as za}from"./useProviderPolling-O16yAYEi.js";import{_ as Go,g as Us,i as Vo,m as Ho,o as sr,p as Ds,r as zo,s as qo,t as bn,u as Bo,x as Ko,y as Wo}from"./marketing-studio-DSrGrSys.js";import{a as Jo,i as Yo,n as Xo,r as Qo}from"./seedance2ModelSelect-BLbJ4NN-.js";/* empty css */import{o as Zo,r as ei}from"./sanitizeErrorMessage-B8sLtBHk.js";import{n as xn}from"./BbananaCreditContext-DVHuDxCt.js";import{t as ti}from"./CreditInsufficientModal-BRlgi437.js";import{o as ri}from"./fashionFilmTutorialFixture-CQMvMl-d.js";import{t as ai}from"./pollingConfig-B6Jhza1P.js";import{t as si}from"./useBbananaTaskPolling-Drr3H_mU.js";import{n as ni,r as oi,t as Fr}from"./absoluteAssetUrl-DOTg39dG.js";import{r as Os}from"./ensureRealPhotoAssets-pbYFLeLN.js";import{t as Ls}from"./dist-D3WKI0zm.js";import{a as Fs,c as ii,o as Gs,s as qa}from"./settings-DfRBgoyn.js";import{t as li}from"./DirectorOrb-BpOAbBik.js";import{i as ci,n as Vs,r as di,t as Hs}from"./AgentChat-46xPZkKx.js";import{a as ui,i as mi,n as Ba,o as pi,r as zs}from"./shortsHeroCleanFrame-B8T4XF95.js";import{t as ms}from"./MentionInput-D2DoYwJb.js";import{i as hi,n as fi,o as gi,s as yi,t as bi}from"./select-BKfCmozG.js";import{n as qs,r as xi}from"./studioFreeGrant-DpDesLc9.js";import{t as vi}from"./seedance2Credit-TsDH99Ls.js";import{n as ki,t as va}from"./templateOmniMedia-B6ZQQs-Q.js";import{a as oa,i as Ka,n as wi,r as Bs,t as Yr}from"./shortsAgentTutorialFixture-DBt9ENLB.js";var _i=ds("CupSoda",[["path",{d:"m6 8 1.75 12.28a2 2 0 0 0 2 1.72h4.54a2 2 0 0 0 2-1.72L18 8",key:"8166m8"}],["path",{d:"M5 8h14",key:"pcz4l3"}],["path",{d:"M7 15a6.47 6.47 0 0 1 5 0 6.47 6.47 0 0 0 5 0",key:"yjz344"}],["path",{d:"m12 8 1-6h2",key:"3ybfa4"}]]),vn=ds("Mountain",[["path",{d:"m8 3 4 8 5-5 5 15H2L8 3z",key:"otkl63"}]]),Ii=ds("PawPrint",[["circle",{cx:"11",cy:"4",r:"2",key:"vol9p0"}],["circle",{cx:"18",cy:"8",r:"2",key:"17gozi"}],["circle",{cx:"20",cy:"16",r:"2",key:"1v9bxh"}],["path",{d:"M9 10a5 5 0 0 1 5 5v3.5a3.5 3.5 0 0 1-6.84 1.045Q6.52 17.48 4.46 16.84A3.5 3.5 0 0 1 5.5 10Z",key:"1ydw1z"}]]),s=dn(ao(),1);var kn=t=>!0,Si=(t,r)=>kn(r)?"2.5":"2.0",ji=(t,r)=>t==="2.5"?Xo:Jo(r),wn=(t,r)=>t==="2.5"?["480p","720p","1080p"]:r>15?["720p"]:["720p","1080p"],Ks=(t,r,n)=>t==="2.5"?n==="4k"?"720p":n:r>15&&n!=="480p"?"720p":n,Ws=(t,r,n)=>t==="2.5"||r>15?n.seedance25:n.seedance2,Lr=t=>t==="2.5"?{seedanceEngine:"2.5"}:{},Ni=(t,r,n)=>t!==null?t!==r:r!=="2.5"?!1:!/\b\d+-\d+ seconds:/.test(n||""),Ci=["Seedance 2.5","Seedance 2.0","Seedance 2"],Ia=dn(lo(),1),e=ro(),Wa=`${no}/functions/v1`,Js=3,ia=1,ot="shorts",ka="Preserve authentic product packaging text and label typography. Do not add unrelated overlay captions, subtitles, or watermarks.",Pi=`TEXT RENDERING POLICY â mandatory (ABSOLUTE NO ON-SCREEN TEXT rule). 2 3PRESERVE (render accurately, DO NOT blur, DO NOT erase, DO NOT replace with placeholder shapes): authentic product packaging text, brand marks, label typography, printed logos, ingredient lists, barcodes, serial numbers, regulatory marks, and any typography that is physically printed, embossed, etched, screen-printed, or stickered on the actual product body as visible in the hero reference image. These ARE part of the product identity and MUST be rendered faithfully. 4 5FORBIDDEN (never render, under no circumstances): burned-in subtitles, lower-third captions, closed captions, karaoke lyrics, bottom-aligned text, title cards, chapter titles, credits, date/time stamps, watermarks, UI overlays, caption bars, floating words, typed-out narration, speech-bubbles, or any typography added by the video model that is NOT physically present on the product in the reference image. 6 7AUDIO-ONLY: all narration, dialogue, and VO are spoken on the audio track â never transcribed or rendered as on-screen text. 8 9DECISION RULE for the model: "Is this text visible on the physical product in the reference image?" â if YES, preserve it faithfully. If NO (it would have to be invented, transcribed from speech, or added as a caption/overlay), do not render it. 10 11This policy is non-negotiable.`,_n=t=>t?t.replace(/\bno\s*text\s*,?\s*no\s*watermarks?\b/gi,ka).replace(/\bno\s*text\b/gi,"Preserve authentic product packaging text and label typography").replace(/\bnever\s+include(?:\s+any)?\s+text(?:\/typography)?[^.]*\./gi,`${ka}.`).replace(/\bdo\s+not\s+include(?:\s+any)?\s+text(?:\/typography)?[^.]*\./gi,`${ka}.`).replace(/\bdo\s+not\s+render(?:\s+any)?\s+text[^.]*\./gi,`${ka}.`).replace(/\s{2,}/g," ").replace(/\s+([,.;:!?])/g,"$1").trim():"",In=t=>t?t.includes("ABSOLUTE NO ON-SCREEN TEXT")||t.includes("íë©´ í ì¤í¸ ì ì± ")||t.includes("SEEDANCE 2.5 TEXT RENDERING POLICY")?t:`${t.trimEnd()} 12 13${Pi}`.trim():"",Ys=t=>({...t,finalPrompt:t.finalPrompt?In(_n(t.finalPrompt)):""}),jt=t=>{if(!t)return null;if(typeof t=="string"){const r=t.trim();if(r.startsWith("http"))return r;if(r.startsWith("[")&&r.endsWith("]")||r.startsWith("{")&&r.endsWith("}"))try{return jt(JSON.parse(r))}catch{return r}return r}if(Array.isArray(t)){for(const r of t){if(typeof r=="string"&&r.startsWith("http"))return r;const n=jt(r);if(n)return n}return null}if(typeof t=="object"){const r=t;return jt(r.url)||jt(r.resultUrl)||jt(r.result_url)||jt(r.videoUrl)||jt(r.video_url)||jt(r.imageUrl)||jt(r.image_url)||jt(r.editedImageUrl)||jt(r.output)||jt(r.images)||jt(r.allResultUrls)||jt(r.resultUrls)||jt(r.data)||null}return null},ar=t=>typeof t=="string"&&t.startsWith("http")?t.trim():Array.isArray(t)&&t.length>0&&typeof t[0]=="string"&&t[0].startsWith("http")?t[0].trim():jt(t),J=(t,r,n)=>({id:`${t}-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,role:t,content:r,suggestions:n?.suggestions?.filter(Boolean),moodPresets:n?.moodPresets,imageUrl:n?.imageUrl,videoUrl:n?.videoUrl,sourceTaskId:n?.sourceTaskId,showStoryboard:n?.showStoryboard,...n?.storyboardFollowUp?{storyboardFollowUp:!0}:{},timestamp:Date.now()}),Xs=t=>t==="ko"?`í¹ì ë¶ë¶ë§ ì½ ì§ì´ ê³ ì¹ ìë ìê³ , ìì í ë¤ë¥¸ 컨ì ì 주ìë©´ 거기ì ë§ê²
13 ì¤í 리보ë를 ìë¡ ì§ ëë ¤ì âï¸ 14ë§ìì ëìë©´ ìëìì ë°ë¡ ììì ë§ë¤ë©´ ë¼ì. 15í¹ì ë°ê¾¸ê³ ì¶ì ë¶ë¶ì´ ììê¹ì?`:t==="ja"?`ä¸é¨ã ããã³ãã¤ã³ãã§ç´ããã¨ããã¾ã£ããå¥ã®ã³ã³ã»ããã«åããã¦æ¸ãç´ããã¨ãã§ãã¾ãã âï¸ 16æ°ã«å ¥ã£ããä¸ããããåç»ãä½ãã¾ãã 17å¤ãããã¨ããã¯ããã¾ããï¼`:`I can tweak just one part, or rewrite the whole storyboard for a completely different concept âï¸ 18If you like it, you can make the video right below. 19Anything you want to change?`,pr=[{id:"hold_explain",label:"ë¤ê³ ì¤ëª ",emoji:"ð¤³",description:'ìì 모ë¸ì´ ì íì ë¤ê³ ì¹´ë©ë¼ì ì§ì ì¤ëª â 첫 ë§ëê° "ëë°!" ê°ì íí¹ íë§ëë¡ ììíë í´ëì ì¼ì¸ '},{id:"pov_review",label:"POV 리뷰",emoji:"ð¥",description:"ì§ì§ ì¸í루ì¸ì ì¼ì¸ ë¬¸ë² â ì 2ì´ ì¼êµ´+ì í íí¹ â ê°ì´ë°ë íµì§¸ë¡ 1ì¸ì¹ POV ì¬ì© ì¥ë©´ì ëë¹ë§ â ë§ì§ë§ 2ì´ ê°ì ì리ìì ì¼êµ´ë¡ ë§ë¬´ë¦¬ (30ì´ ê¶ì¥, 15ì´ë¶í°)"},{id:"ugc",label:"UGC ê·¹í",emoji:"ðª",description:"ì¤ì¹´ì´ë¤ì´ë¹Â·ìì¤Â·ì°ì£¼Â·íì¬ ê°ì ê·¹í íê²½ìì íìê° ì¹¨ì°©íê² ì í ì¤ëª â íê²½ì ìí vs ì°¨ë¶í¨ì ê°ì´ íí¬"},{id:"drama",label:"K-ëë¼ë§ PPL",emoji:"ð",description:'ë§ì¥/ë¡ë§¨ì¤ ëë¼ë§ì²ë¼ ì§íëë¤ê° ë¬ê¸ìì´ ë°°ì°ë¤ì´ ë©ì¶ê³ ì¹´ë©ë¼ ë³´ë©° ì í ë¤ì´ë°ê³ ì¶ì²íë "ê°ì기 ê´ê³ " í¸ë¡í'},{id:"fooh",label:"FOOH (ëì¬ í©ì±)",emoji:"ðï¸",description:"ê±°ë ì íì´ ëìì ìí¸ìì©íë í¹ì´íê³ ê°ê°ì ì¸ ê°ì§ OOH ì¤íí°í´ â ë ¹ìë´ë¦¬ê³ ê°ííê³ ìë©´ ì를 ë ë¤ëë í©ì± 룩"},{id:"cgi",label:"CGI 3D ì í",emoji:"ð¬",description:"í 3D ë ë â ì¡ì²´ ì¤íëì·ë¶í´Â·ìë£ íê°ê¸°Â·360 íì ë± sim FXê° ì í 주ë³ìì í°ì§ë í리미ì íì´ë¡ì·"},{id:"vfx",label:"VFX íí¹",emoji:"â¨",description:'ë§í경·ê¸ë¦¬ì¹Â·ì ì·차ì문 ë± ì¶ì ë¹ì£¼ì¼ í¸ë¦ â ìì²ìê° "ì´ë»ê² ì°ìê±°ì§?" ì¶ì í¨ê³¼ ì¤ì¬'}],hr=[{id:"hold_explain",label:"Hold & Explain",emoji:"ð¤³",description:"A beautiful model holds the product up and explains it to camera â opening with a Korean hook one-liner, the classic shorts format"},{id:"pov_review",label:"POV Review",emoji:"ð¥",description:"How real influencer shorts are cut â 2s of face + product hook, then the whole middle in first-person POV with voice-over only, back to the same frame for a 2s sign-off (best at 30s, 15s floor)"},{id:"ugc",label:"UGC Extreme",emoji:"ðª",description:"A presenter calmly explains the product in an extreme setting â skydiving, underwater, space, fire â the danger-vs-calm gap is the hook"},{id:"drama",label:"K-Drama PPL",emoji:"ð",description:'Plays like a makjang/romance K-drama then suddenly the actors freeze, turn to camera and pitch the product â the "sudden ad" trope'},{id:"fooh",label:"FOOH (Fake OOH)",emoji:"ðï¸",description:"A giant product interacts with a real city in a unique, sensory spectacle â melting, blooming, floating on water â faked out-of-home composite look"},{id:"cgi",label:"CGI 3D Product",emoji:"ð¬",description:"Full 3D render â liquid splash, exploded view, ingredient swirl, 360 rotate sim-FX erupting around the product, premium hero shot"},{id:"vfx",label:"VFX Hook",emoji:"â¨",description:'Kaleidoscope, glitch, particles, portals â abstract visual tricks that make viewers go "how did they shoot that?"'}],Ti={hold_explain:{emoji:"ð¤³",labelKo:"ë¤ê³ ì¤ëª ",labelEn:"Hold & Explain"},pov_review:{emoji:"ð¥",labelKo:"POV 리뷰",labelEn:"POV Review"},ugc:{emoji:"ðª",labelKo:"UGC ê·¹í",labelEn:"UGC Extreme"},fooh:{emoji:"ðï¸",labelKo:"FOOH ëì¬ í©ì±",labelEn:"FOOH City"},cgi:{emoji:"ð¬",labelKo:"CGI 3D ì í",labelEn:"CGI 3D Product"},vfx:{emoji:"â¨",labelKo:"VFX íí¹",labelEn:"VFX Hook"},drama:{emoji:"ð",labelKo:"K-ëë¼ë§ PPL",labelEn:"K-Drama PPL"},motion_graphic:{emoji:"ð¨",labelKo:"모ì ê·¸ëí½",labelEn:"Motion Graphics"},free_concept:{emoji:"â¨",labelKo:"AI ìë 컨ì ",labelEn:"AI Auto Concept"}},is="bbanana-shorts-agent-session",Ei="bbanana-shorts-agent-session-input",Na="shorts-agent-session:",ps="mcp_",hs=t=>t.startsWith(ps),ea=t=>`bbanana-shorts-agent-session:${t}`,fs=t=>`bbanana-shorts-agent-session-input:${t}`,Ca=t=>`${Na}${t}`,Sn=(t,r)=>({...r,sessionPresetId:t.sessionId,savedAt:Date.now()}),jn=(t,r)=>
19({sessionInput:t,state:r}),Nn=t=>{switch(t){case"hero":return 15;case"mood_select":return 35;case"drafting":return 50;case"discussion":return 70;case"generating":return 90;case"result":return 100;case"error":return 60;default:return 0}},Ai=(t,r)=>{if(!r)return null;const n=r.clientTaskId,l=r.apiTaskId;return t.find(p=>{const h=p.generationOptions||{},o=h.client_task_id||h.clientTaskId,S=h.api_task_id||h.apiTaskId;return p.id===n||p.id===l||p.apiTaskId===n||p.apiTaskId===l||o===n||o===l||S===l||S===n})||null};async function Cn(t){if(t.state.phase==="result"&&t.state.finalVideoUrl){const r=t.state.finalVideoUrl;if(!(r.includes("supabase.co/storage/")||r.includes("supabase.in/storage/"))&&t.state.activeGeneration?.apiTaskId)try{const n=t.state.activeGeneration.apiTaskId,{data:l}=await ve.from("user_tasks").select("result_url").eq("task_id",n).maybeSingle(),p=ar(l?.result_url);if(p&&p!==r)return{...t,state:{...t.state,finalVideoUrl:p,savedAt:Date.now()}}}catch{}return t}if(t.state.phase!=="generating"||!t.state.activeGeneration?.apiTaskId)return t;try{const{data:r,error:n}=await ve.from("user_tasks").select("status, result_url").eq("task_id",t.state.activeGeneration.apiTaskId).maybeSingle();if(n||!r)return t;const l=ar(r.result_url)||t.state.finalVideoUrl;return l?{...t,state:{...t.state,phase:"result",finalVideoUrl:l,activeGeneration:null,savedAt:Date.now()}}:t}catch{return t}}async function gs(t,r,n){if(ja()||hs(r))return;const l=Ca(r),p=new Date().toISOString(),h=n.state.draft?.title||n.sessionInput.highlights?.trim()||n.sessionInput.preset.name,o=n.state.phase==="result"||!!n.state.finalVideoUrl,S={task_id:l,user_id:t,status:n.state.phase==="error"?"failed":o?"completed":"processing",progress:o?100:Nn(n.state.phase),prompt:h,model:"AD Video Agent",service_name:"ad",preset_name:n.sessionInput.preset.name,error_message:n.state.phase==="error"?"AD video agent session paused with an error.":null,terminal_reason:n.state.phase==="error"?"agent_session_error":null,terminated_at:n.state.phase==="error"?p:null,result_url:n.state.finalVideoUrl||null,generation_options:{provider:"internal",mode:"video",task_type:"ad",preset_name:n.sessionInput.preset.name,client_task_id:l,ad_workflow:"video_agent_session",shorts_agent_session:n},updated_at:p,created_at:p};await Eo();let{error:v}=await ve.from("user_tasks").upsert(S,{onConflict:"task_id"});v&&(await ve.auth.refreshSession()).data.session?.access_token&&({error:v}=await ve.from("user_tasks").upsert(S,{onConflict:"task_id"})),v&&pe.error("[useShortsVideoAgent] Failed to sync session task after retry:",v)}async function Ri(t,r,n){if(ja())return;const l=n||Ca(r);l.startsWith(`${Na}${ps}`)||await ve.from("user_tasks").delete().eq("user_id",t).eq("task_id",l)}async function $i(t,r){if(hs(r))return null;const n=Ca(r),{data:l,error:p}=await ve.from("user_tasks").select("generation_options").eq("user_id",t).eq("task_id",n).maybeSingle();if(p||!l)return null;const h=l?.generation_options?.shorts_agent_session;return!h?.state||!h?.sessionInput?null:h}var Pn=t=>Sn(t,{phase:"hero",messages:[],draft:null,heroImageUrl:t.presetHeroImageUrl||null,sourceProductImageUrls:(t.productImages||[]).filter(r=>typeof r=="string"&&!!r),sourceFaceImageUrl:t.faceImage||void 0,selectedMood:null,dynamicMoods:null,finalVideoUrl:null,activeGeneration:null,brandPronunciation:null,brandPronunciationSkipped:!1,productFingerprint:null,interactionCount:0});function Ja(t){const r=Pn(t);return{sessionId:t.sessionId,taskId:Ca(t.sessionId),sessionInput:t,phase:r.phase,heroImageUrl:r.heroImageUrl,finalVideoUrl:r.finalVideoUrl,draftTitle:null,presetName:t.preset?.name||"",error:null,savedAt:r.savedAt,progress:Nn(r.phase)}}async function Ya(t,r){if(!t)return;const n=Pn(r);await gs(t,r.sessionId,jn(r,n))}async function Qs(t){if(!t)return[];try{const{data:r,error:n}=await ve.from("user_tasks").select("task_id, generation_options, error_message, progress").eq("user_id",t).like("task_id",`${Na}%`).not("task_id","like",`${Na}${ps}%`).in("status",["processing","failed"]).order("created_at",{ascending:!1}).limit(50);if(n||!r)return[];const l=[];for(const p of r){const h=p?.generation_options?.shorts_agent_session;!h?.state||!h?.sessionInput||hs(h.sessionInput.sessionId)||h?.orchestrator?.mcp_managed||l.push({sessionId:h.sessionInput.sessionId,taskId:p.task_id,sessionInput
19:h.sessionInput,phase:h.state.phase,heroImageUrl:h.state.heroImageUrl,finalVideoUrl:h.state.finalVideoUrl,draftTitle:h.state.draft?.title||null,presetName:h.sessionInput.preset?.name||"",error:p.error_message||null,savedAt:h.state.savedAt||0,progress:p.progress||0})}return l}catch{return[]}}function Mi(t,r,n){if(!t)return;const l=Sn(t,r);try{localStorage.setItem(ea(t.sessionId),JSON.stringify(l))}catch{}if(n){const p=jn(t,l);gs(n,t.sessionId,p)}}function Ui(t){try{const r=t?ea(t):is,n=localStorage.getItem(r);if(!n){if(t){const l=localStorage.getItem(is);if(l){const p=JSON.parse(l);if(p.sessionPresetId===t)return p}}return null}return JSON.parse(n)}catch{return null}}function Zs(t,r,n){if(r){try{localStorage.removeItem(ea(r))}catch{}try{localStorage.removeItem(fs(r))}catch{}try{localStorage.removeItem(`shorts-agent-input:${r}`)}catch{}}try{localStorage.removeItem(is)}catch{}try{localStorage.removeItem(Ei)}catch{}t&&r&&Ri(t,r,n)}async function Di(t,r){if(!t||!r)return null;try{const n=await $i(t,r);if(!n?.state||!n?.sessionInput)return null;const l=await Cn(n);let p=l;try{const h=localStorage.getItem(ea(r));if(h){const o=JSON.parse(h);(o?.savedAt||0)>(l.state.savedAt||0)&&o.sessionPresetId===r&&o.phase!=="idle"&&l.state.phase!=="result"&&(p={sessionInput:l.sessionInput,state:o})}}catch{}return localStorage.setItem(fs(r),JSON.stringify(p.sessionInput)),localStorage.setItem(ea(r),JSON.stringify(p.state)),p}catch{return null}}async function Oi(t){if(!t)return!1;try{const{data:r}=await ve.from("user_preferences").select("ad_video_agent_state").eq("user_id",t).maybeSingle(),n=r?.ad_video_agent_state;if(n?.state&&n?.sessionInput){const l=await Cn(n),p=l.sessionInput.sessionId;return localStorage.setItem(fs(p),JSON.stringify(l.sessionInput)),localStorage.setItem(ea(p),JSON.stringify(l.state)),await ve.from("user_preferences").update({ad_video_agent_state:null}).eq("user_id",t),gs(t,p,l),!0}}catch{}return!1}function Li({open:t,session:r,language:n,pollingHistory:l,generationTasks:p,createRepresentativeImage:h,uploadImages:o,startSeedanceGeneration:S,onTaskComplete:v,onSessionCompleted:U,demoFixture:D,userId:I}){const f=(i,m,g)=>n==="ko"?i:n==="ja"?m:g,H=()=>f(`ììì´ ìì±ëì´ì ð 20ìëìì íì¸í´ ë³´ì¸ì.`,`åç»ãã§ãã¾ãã ð 21ä¸ã§ãã§ãã¯ãã¦ã¿ã¦ãã ããã`,`Your video is ready ð 22Check it out below.`),ee=()=>f(`ë¶ì기를 ê³¨ë¼ ì£¼ìë©´ ë°ë¡ ì¤í 리보ë를 ì§ ë³¼ê²ì âï¸ 23ì´ë¤ ë¶ìê¸°ë¡ ë§ë¤ì´ ë³¼ê¹ì?`,`é°å²æ°ãé¸ãã§ããããããããã¹ãã¼ãªã¼ãã¼ããä½ãã¾ãã âï¸ 24ã©ããªé°å²æ°ã§ä½ãã¾ããããï¼`,`Pick a mood and I'll write the storyboard right away âï¸ 25Which mood shall we go with?`),Ee=()=>f(`ì´ë¯¸ì§ì ì´ì¸ë¦¬ë ë¶ì기를 ì°¾ê³ ìì´ì ð 26ì ê¹ë§ 기ë¤ë ¤ 주ì¸ì!`,`ç»åã«åãé°å²æ°ãæ¢ãã¦ãã¾ã ð 27å°ãå¾ ã£ã¦ã¦ãã ãããï¼`,`Looking for moods that fit the image ð
28Just a moment!`),[N,F]=(0,s.useState)("idle"),[se,_]=(0,s.useState)([]),[B,ie]=(0,s.useState)(null),[K,x]=(0,s.useState)(null),[te,ue]=(0,s.useState)([]),[R,$]=(0,s.useState)(void 0),[O,G]=(0,s.useState)(null),[Oe,fe]=(0,s.useState)(null),[_e,Ne]=(0,s.useState)(!1),[P,Ce]=(0,s.useState)(!1),[Re,We]=(0,s.useState)(null),[Ie,q]=(0,s.useState)(!1),[V,X]=(0,s.useState)(!1),ge=(0,s.useRef)(null),[Qe,ht]=(0,s.useState)(""),[$t,ft]=(0,s.useState)(0),[W,Le]=(0,s.useState)(null),[kt,De]=(0,s.useState)(null),[yt,rt]=(0,s.useState)(null),[A,ye]=(0,s.useState)(null),[Ze,Lt]=(0,s.useState)(null),[ut,at]=(0,s.useState)(null),[qt,re]=(0,s.useState)(!1),[Me,ce]=(0,s.useState)(null),[gt,Ae]=(0,s.useState)(0),[bt,Ue]=(0,s.useState)(null),Nt=(0,s.useRef)(null),{checkCredit:Mt,deductCredit:wt,showCreditRequiredModal:nr}=xn(),Bt=(0,s.useRef)(!1),Je=(0,s.useRef)(!1),me=(0,s.useRef)(0),Fe=(0,s.useRef)(N);Fe.current=N;const Qt=(0,s.useRef)(_e);Qt.current=_e;const vr=(0,s.useRef)(r);vr.current=r;const et=(0,s.useCallback)(async i=>{const m=D?.respond(i);return m?(await new Promise(g=>{setTimeout(g,m.delayMs)}),m.data):null},[D]),xt=(0,s.useCallback)(async i=>{const m=await et(i.body?.action);return m?{data:m,error:null}:ve.functions.invoke("shorts-video-agent",i)},[et]),kr=(0,s.useMemo)(()=>A||(n==="en"?hr:pr),[A,n]),mt=(0,s.useMemo)(()=>{const i=Ai(p,W);return i?{progress:Math.min(Math.round(i.progress),100),status:i.status,error:i.error||i.errorMessage,message:i.message,resultUrl:ar(i.resultUrl||i.imageUrl)}:null},[W,p]),gr=(0,s.useMemo)(()=>n==="en"?["Make the overall tone more emotional","Make the product stand out more","Make the first 3 seconds more impactful","Give the ending more resonance"]:["ì ì²´ì ì¼ë¡ ë ê°ì±ì ì¸ í¤ì¼ë¡ ë°ê¿ì¤","ì íì´ ë ë¶ê°ëê² ìì í´ì¤","첫 3ì´ë¥¼ ë ìí©í¸ ìê² ë°ê¿ì¤","ìë©ì ë ì¬ì´ì´ ë¨ê² ë°ê¿ì¤"],[n]),Ye=(0,s.useCallback)((i,m)=>{if(!i||Je.current)return;if(Fe.current!=="generating"){pe.log("[shorts-agent] Stale completion ignored â phase is",Fe.current);return}Je.current=!0;const g=W?.clientTaskId;g&&v&&v(g,i),G(i),De(null),Le(null),fe(null),F("result"),_(b=>[...b,J("agent",m,{videoUrl:i,sourceTaskId:g||void 0})]),r?.sessionId&&U&&U(r.sessionId,i)},[W?.clientTaskId,v,U,r?.sessionId]),_t=(0,s.useCallback)(i=>{fe(i),De(null),Le(null),F("discussion");const m=ei(i),g=!m&&/InputImageSensitiveContentDetected|PolicyViolation|sensitive.?content|content.?policy|copyright.?restrictions|ìì \s*ì ì± |ì½í ì¸ \s*ì ì± |ì½í ì¸ \s*ê²ì´|ê²ì´|(?:ì°¨ë¨|ê±°ë¶)ëììµëë¤|ì í´\s*ì½í ì¸ |ë¶ì ì /i.test(i),b=Zo(i,n)||f("ìì ìì±ì ì¤í¨íìµëë¤.","åç»çæã«å¤±æãã¾ããã","Video generation failed."),C=m?b:g?f(["ð« ì½í ì¸ ê²ì´ë¡ ìì±ì´ ì°¨ë¨ëììµëë¤.","","ì ì¤í¸ë¦¼ AI 모ë¸ì ìì ì ì± ì ìë ì¤ íëê° ê°ì§ëë©´ ìëì¼ë¡ ê±°ë¶ë©ëë¤:","⢠ð¶ 미ì±ë ì·ì기","⢠ð ì ëª ì¸Â·ì´ìê¶ ëì ì¸ë¬¼","⢠ð·ï¸ ë¸ëë ë¡ê³ ·ìºë¦í°Â·ì ì물","⢠â ï¸ ì±ì /íë ¥ì Â·ë¯¼ê° ì´ë¯¸ì§","","ð¡ í´ê²° ë°©ë²","⢠ì í ì´ë¯¸ì§ìì ì ììê° ë³´ì´ë©´ ë¤ë¥¸ ê°ë·컷ì¼ë¡ êµì²´","⢠ì¼êµ´ 참조 ì´ë¯¸ì§ë¥¼ ì ê±°íê±°ë ì±ì¸ ì¼ë°ì¸ ì¬ì§ì¼ë¡ êµì²´","⢠배경ì ì¸ë¬¼/ë¡ê³ ê° ë³´ì´ë©´ í¬ë¡í´ì ë¤ì ì ë¡ë","","ìì í ë¤ì ìëí´ ì£¼ì¸ì. ìì± ì¤í¨ë¶ì í¬ë ë§ì´ ìë íë¶ë©ëë¤."].join(` 29`),["ð« ã³ã³ãã³ãããªã·ã¼ã«ããçæããããã¯ããã¾ããã","","䏿µAIã¢ãã«ã®å®å ¨ããªã·ã¼ã«ããã以ä¸ã®ãããããæ¤åºãããã¨èªåæå¦ããã¾ã:","â¢ ð¶ æªæå¹´è ã»èµ¤ã¡ãã","⢠ð æå人ã»è忍©å¯¾è±¡è ","⢠ð·ï¸ ãã©ã³ããã´ã»ãã£ã©ã¯ã¿ã¼ã»èä½ç©","⢠â ï¸ æ§çã»æ´åçã»ã»ã³ã·ãã£ããªç»å","","ð¡ è§£æ±ºæ¹æ³","⢠製åç»åã«ä¸è¨è¦ç´ ãå«ã¾ãã¦ããã°å¥ã®ã¢ã³ã°ã«ã»ã«ããã«å¤æ´","⢠é¡åç §ç»åãåé¤ãããä¸è¬æäººã®åçã«äº¤æ","â¢ èæ¯ã«äººç©ã»ãã´ãè¦ããå ´åã¯ã¯ããããã¦åã¢ãããã¼ã","","ä¿®æ£å¾ã«å試è¡ãã¦ãã ãããçæå¤±æåã¯ã¯ã¬ã¸ãããèªåè¿éããã¾ãã"].join(` 30`),["ð« Generation blocked by content policy.","","The upstream AI model auto-rejects requests when it detects any of:","⢠ð¶ Minors / infants","⢠ð Celebrities / identifiable public figures","⢠ð·ï¸ Brand logos, characters, or copyrighted material","⢠â ï¸ Sexual / violent / sensitive imagery","","ð¡ How to fix","⢠Replace the product image if it contains any of the above","⢠Remove or swap the face-reference image for a generic adult","⢠Crop out background peo
30ple/logos and re-upload","","Please revise and retry. Credits for failed generations are auto-refunded."].join(` 31`)):f(`${b} 32ì¤í 리보ë를 ìì íê±°ë ë¤ì ìëí´ ì£¼ì¸ì.`,`${b} 33ã¹ãã¼ãªã¼ãã¼ããä¿®æ£ãããå試è¡ãã¦ãã ããã`,`${b} 34Please revise the storyboard or try again.`);_(T=>[...T,J("system",C)])},[n]),wr=(0,s.useCallback)(async()=>{const i=W?.apiTaskId,m=W?.clientTaskId,g=!!(i||m);if(me.current+=1,Ne(!1),Le(null),De(null),F("discussion"),fe(null),_(b=>[...b,J("system",g?f("ð ìì ìì±ì ì·¨ìíìµëë¤. íë¶ì ì§íëì§ ììµëë¤. ì¤í 리보ë를 ìì íê±°ë ë¤ì ìì±í´ 주ì¸ì.","ð åç»çæããã£ã³ã»ã«ãã¾ãããè¿éã¯è¡ããã¾ãããã¹ãã¼ãªã¼ãã¼ããä¿®æ£ãããåçæãã¦ãã ããã","ð Video generation cancelled. Credits are not refunded. Edit the storyboard or generate again."):f("ð ìì ìì±ì ì·¨ìíìµëë¤. ì§í ì¤ì´ë ìì ì´ ìì´ ì°¨ê°ë í¬ë ë§ë ììµëë¤. ì¤í 리보ë를 ìì íê±°ë ë¤ì ìì±í´ 주ì¸ì.","ð åç»çæããã£ã³ã»ã«ãã¾ãããé²è¡ä¸ã®ä½æ¥ããªãã£ããããå·®ãå¼ãããã¯ã¬ã¸ãããããã¾ãããã¹ãã¼ãªã¼ãã¼ããä¿®æ£ãããåçæãã¦ãã ããã","ð Video generation cancelled. No job was actually running, so no credits were charged. Edit the storyboard or generate again."))]),!g)return{ok:!0};try{const{data:{session:b}}=await ve.auth.getSession(),C=b?.access_token;if(!C)return{ok:!1,error:"not_authenticated"};const T=[i,m].filter(y=>typeof y=="string"&&y.length>0),E=await fetch(`${Wa}/cancel-task`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${C}`},body:JSON.stringify({task_ids:T})}),z=await E.json().catch(()=>({}));return!E.ok||!z?.success?{ok:!1,error:z?.error||`http_${E.status}`}:{ok:!0}}catch(b){return{ok:!1,error:b?.message??"unknown"}}},[W?.apiTaskId,W?.clientTaskId,n]),Vr=(0,s.useCallback)(()=>{me.current+=1,F("idle"),_([]),ie(null),Zt.current=null,x(null),ue([]),$(void 0),G(null),fe(null),Ne(!1),ht(""),ft(0),Le(null),De(null),rt(null),ye(null),at(null),re(!1),ce(null),Ae(0),X(!1),We(null),Ce(!1),Ue(null),Nt.current=null,Bt.current=!1,Je.current=!1,pt.current=!1},[]);(0,s.useEffect)(()=>{if(!t||!r)return;const i=r.sessionId;if(Nt.current===i)return;me.current+=1,Bt.current=!1,Je.current=!1,pt.current=!1,X(!1);const m=Ui(i);if(!m||m.sessionPresetId!==i){F("idle"),_([]),ie(null),Zt.current=null,x(null),ue([]),$(void 0),G(null),fe(null),Ne(!1),ht(""),ft(0),Le(null),De(null),rt(null),ye(null),at(null),re(!1),ce(null),Ae(0),Ue(i),Nt.current=i;return}pe.log("[shorts-video-agent] Restoring session from localStorage, phase:",m.phase);let g=m.phase,b=null,C=!1;if(g==="drafting"?(g="mood_select",m.selectedMood=null,b=f("ì¤í 리보ë ìì±ì´ ì¤ë¨ëììµëë¤. ë¶ì기를 ë¤ì ì íí´ ì£¼ì¸ì.","ã¹ãã¼ãªã¼ãã¼ãçæã䏿ããã¾ãããé°å²æ°ãååº¦é¸æãã¦ãã ããã","Storyboard generation was interrupted. Please pick a mood again."),pe.log('[shorts-video-agent] Rolled back "drafting" â "mood_select" (API call cannot resume, selectedMood cleared)')):g==="hero"&&(m.heroImageUrl?(g="mood_select",m.dynamicMoods&&m.dynamicMoods.length?(b=f("ë¶ì기 ë¶ìì´ ì¤ë¨ëììµëë¤. ë¶ì기 ì¤ íë를 ì ííê±°ë ì´ë¯¸ì§ë¥¼ ì¬ìì±í´ 주ì¸ì.","é°å²æ°åæã䏿ããã¾ãããé°å²æ°ã鏿ãããç»åãåçæãã¦ãã ããã","Mood analysis was interrupted. Please select a mood or regenerate the image."),pe.log('[shorts-video-agent] Rolled back "hero" â "mood_select" (hero image exists)')):(C=!0,pe.log('[shorts-video-agent] Rolled back "hero" â "mood_select" (hero exists, re-running mood analysis)'))):(g="idle",m.messages=[],m.heroImageUrl=null,m.dynamicMoods=null,m.selectedMood=null,pe.log('[shorts-video-agent] Rolled back "hero" â "idle" (will auto-restart)'))),b&&(m.messages=[...m.messages||[],J("system",b)]),Bt.current=g!=="idle",F(g),_(m.messages||[]),ie(m.draft),x(m.heroImageUrl),ue(m.sourceProductImageUrls||[]),$(m.sourceFaceImageUrl),rt(m.selectedMood),ye(m.dynamicMoods),G(m.finalVideoUrl),Le(m.activeGeneration),fe(null),Ne(!1),ht(""),ft(0),m.brandPronunciation!==void 0?at(m.brandPronunciation):at(null),m.brandPronunciationSkipped!==void 0?re(m.brandPronunciationSkipped):re(!1),m.productFingerprint!==void 0?ce(m.productFingerprint):ce(null),typeof m.interactionCount=="number"?Ae(m.interactionCount):Ae(0),De(null),Ue(i),Nt.current=i,C&&m.heroImageUrl&&r){const T=m.heroImageUrl;Ir(T,r).catch(E=>{})}if(g==="generating"&&m.activeGeneration?.apiTaskId){const T=m.activeGeneration.apiTaskId,E=m.activeGeneration.clientTaskId,z=i;(async()=>{try{const{data:y}=await ve.from("user_tasks").select("status, result_url").eq("task_id",T).eq("user_id",I).maybeSingle();if(r?.sessionId!==z){pe.log("[shorts-video-agent] Session changed during restore, aborting");return}const j=ar(y?.result_url);if(j){pe.log("[shorts-video-agent] Restored generating â result (from user_tasks):",j.substring(0,80)),G(j),Le(null),De(null),F("result"),_(Pe=>[...Pe,J("agent",H(),{videoUrl:j,sourceTaskId:T})]);return}const M=[T,E].filter(Pe=>typeof Pe=="string"&&Pe.length>0);let Q=null;if(M.length>0){const{data:Pe}=await ve.from("user_image_library").select("image_url, task_id").eq("user_id",I).eq("task_type","shorts").in("task_id",M).is("deleted_at",null).order("created_at",{ascending:!1}).limit(1);Q=Pe}const ke=Q?.[0],ae=ar(ke?.image_url);if(ae){pe.log("[shorts-video-agent] Restored generating â result (from user_image_library):",ae.substring(0,80)),G(ae),Le(null),De(null),F("result"),_(Pe=>
34[...Pe,J("agent",H(),{videoUrl:ae,sourceTaskId:ke?.task_id||T})]);return}if(I){const{data:Pe}=await ve.from("user_image_library").select("image_url, task_id, created_at").eq("user_id",I).eq("task_type","shorts").eq("media_type","video").is("deleted_at",null).order("created_at",{ascending:!1}).limit(1),Te=Pe?.[0],St=ar(Te?.image_url);if(St){const Tt=Te?.created_at?new Date(Te.created_at).getTime():0;if(Date.now()-Tt<3600*1e3){pe.log("[shorts-video-agent] Restored generating â result (from agent lib fallback):",St.substring(0,80)),G(St),Le(null),De(null),F("result"),_(Ht=>[...Ht,J("agent",H(),{videoUrl:St})]);return}}}if(y?.status==="failed"){pe.log("[shorts-video-agent] Restored generating â discussion (task failed)"),Le(null),De(null),F("discussion");return}pe.log("[shorts-video-agent] Restored generating â waiting for polling/realtime to complete"),De({progress:10,status:"generating",message:f("ìì ìì± ì¤...","åç»çæä¸...","Generating video..."),resultUrl:null})}catch{}})()}},[t,r,I]),(0,s.useEffect)(()=>{N==="idle"||!r||bt===r.sessionId&&Mi(r,{phase:N,messages:se,draft:B,heroImageUrl:K,sourceProductImageUrls:te,sourceFaceImageUrl:R,selectedMood:yt,dynamicMoods:A,finalVideoUrl:O,activeGeneration:W,brandPronunciation:ut,productFingerprint:Me,brandPronunciationSkipped:qt,interactionCount:gt},I)},[N,se,B,K,te,R,yt,A,O,W,ut,Me,qt,gt,r,I,bt]);const _r=(0,s.useCallback)(async i=>{const m=await et(i.action);if(m)return m;const g=me.current,b=i.session.sessionId,C=()=>{if(me.current!==g)throw new Error("INVOKE_AGENT_CANCELLED_BY_RESET");if(vr.current?.sessionId!==b)throw new Error("INVOKE_AGENT_CANCELLED_BY_SESSION_CHANGE")},T=(i.messages||[]).filter(Te=>Te.role==="agent"||Te.role==="user").slice(-12).map(({role:Te,content:St})=>({role:Te,content:St.substring(0,800)})),{data:{session:E}}=await ve.auth.getSession();let z=E?.access_token;if(!z){const{data:Te}=await ve.auth.refreshSession();z=Te.session?.access_token}if(!z)throw new Error("Not authenticated");const y={action:i.action,stream:!0,language:n,...Lr(i.session.seedanceEngine??"2.0"),targetDuration:i.session.videoDuration||15,heroImageUrl:i.heroImageUrl,productImageUrls:i.productImageUrls,faceImageUrl:i.faceImageUrl,template:{id:i.session.preset.id,name:i.session.preset.name,description:i.session.preset.description,category:i.session.preset.category,promptTemplate:i.session.preset.promptTemplate},highlights:i.session.highlights,currentDraft:i.draft,messages:T,userMessage:i.userMessage,mood:i.mood?{id:i.mood.id,label:i.mood.label,description:i.mood.description,...i.mood.recipe?{recipe:i.mood.recipe}:{}}:void 0,autoConcept:i.session.autoConcept?{hook:i.session.autoConcept.hook,cta:i.session.autoConcept.cta,sellingPoints:i.session.autoConcept.sellingPoints,casting:i.session.autoConcept.casting,location:i.session.autoConcept.location,visualStyle:i.session.autoConcept.visualStyle,hookAction:i.session.autoConcept.hookAction,productPitch:i.session.autoConcept.productPitch,benefit:i.session.autoConcept.benefit,speechStyle:i.session.autoConcept.speechStyle,narrationStyle:i.session.autoConcept.narrationStyle,cgModuleLabel:i.session.autoConcept.cgModuleLabel,cgIntensity:i.session.autoConcept.cgIntensity,cgDirection:i.session.autoConcept.cgDirection}:void 0,revisionMode:i.revisionMode,brandPronunciation:i.brandPronunciation&&i.brandPronunciation.koreanReading?.trim()?{displayName:i.brandPronunciation.displayName||"",koreanReading:i.brandPronunciation.koreanReading.trim(),confidence:i.brandPronunciation.confidence||"medium",alternatives:i.brandPronunciation.alternatives||[]}:void 0,productFingerprint:i.productFingerprint&&i.productFingerprint.categoryLabel?.trim()?{categoryLabel:i.productFingerprint.categoryLabel.trim(),shape:i.productFingerprint.shape||"",material:i.productFingerprint.material||"",distinctive:i.productFingerprint.distinctive||"",motionHint:i.productFingerprint.motionHint||"",highlightsSummary:i.productFingerprint.highlightsSummary||""}:void 0},j=new AbortController,M=setTimeout(()=>j.abort(),155e3);let Q;try{Q=await fetch(`${Wa}/shorts-video-agent`,{method:"POST",headers:{Authorization:`Bearer ${z}`,"Content-Type":"application/json"},body:JSON.stringify(y),signal:j.signal})}
34catch(Te){throw clearTimeout(M),Te.name==="AbortError"?new Error(f("AI ìëµ ë기 ìê°ì´ ì´ê³¼ëììµëë¤. ë¤ì ìëí´ ì£¼ì¸ì.","AIå¿çå¾ ã¡æéãè¶ éãã¾ãããå試è¡ãã¦ãã ããã","AI response timed out. Please try again.")):Te}if(clearTimeout(M),!Q.ok){const Te=await Q.text().catch(()=>"Unknown error"),St=Q.status===401||Q.status===403?f("ì¸ì¦ì´ ë§ë£ëììµëë¤. ë¤ì ë¡ê·¸ì¸í´ 주ì¸ì.","èªè¨¼ã®æå¹æéãåãã¾ãããå度ãã°ã¤ã³ãã¦ãã ããã","Authentication expired. Please log in again."):Q.status===429?f("ìì²ì´ ë무 ë§ìì. ì ì í ë¤ì ìëí´ ì£¼ì¸ì.","ãªã¯ã¨ã¹ããå¤ããã¾ãããã°ããå¾ã«å試è¡ãã¦ãã ããã","Too many requests. Please try again in a moment."):Q.status>=500?f("ìë² ì¤ë¥ê° ë°ìíìµëë¤. ì ì í ë¤ì ìëí´ ì£¼ì¸ì.","ãµã¼ãã¼ã¨ã©ã¼ãçºçãã¾ããããã°ããå¾ã«å試è¡ãã¦ãã ããã","Server error. Please try again shortly."):f(`ìì²ì´ ì¤í¨íìµëë¤ (${Q.status}).`,`ãªã¯ã¨ã¹ãã失æãã¾ãã (${Q.status}).`,`Request failed (${Q.status}).`);throw new Error(St)}if(C(),!(Q.headers.get("content-type")||"").includes("text/event-stream")){const Te=await Q.json();if(C(),Te.error)throw new Error(Te.error);if(!Te.success||!Te.draft||!Te.assistantMessage)throw new Error(Te.error||"Agent response was incomplete.");return Te}const ke=Q.body.getReader(),ae=new TextDecoder;let Pe="";for(ht("start"),ft(0);;){const{done:Te,value:St}=await ke.read();if(Te)break;Pe+=ae.decode(St,{stream:!0});const Tt=Pe.split(` 35`);Pe=Tt.pop()??"";for(const Ht of Tt){if(!Ht.startsWith("data: "))continue;const er=Ht.slice(6).trim();if(er)try{const Et=JSON.parse(er);if(Et.phase&&(ht(Et.phase),Et.phase==="cut"&&Et.cutNumber&&ft(Et.cutNumber)),Et.error)throw new Error(Et.error);if(Et.done&&Et.result){ht(""),ft(0);const $r=Et.result;if(!$r.success||!$r.draft||!$r.assistantMessage)throw new Error($r.error||"Agent response was incomplete.");return $r}}catch(Et){if(Et.message!=="Unexpected token")throw Et}}}if(Pe.trim()){const Te=Pe.trim();if(Te.startsWith("data: ")){const St=Te.slice(6).trim();if(St)try{const Tt=JSON.parse(St);if(Tt.done&&Tt.result){ht(""),ft(0);const Ht=Tt.result;if(!Ht.success||!Ht.draft||!Ht.assistantMessage)throw new Error(Ht.error||"Agent response was incomplete.");return C(),Ht}if(Tt.error)throw new Error(Tt.error)}catch(Tt){if(Tt.message!=="Unexpected token")throw Tt}}}throw new Error("Stream ended without a result.")},[n,et]),Ct=(0,s.useCallback)(i=>{const m=i?.brandPronunciation;m&&typeof m=="object"&&typeof m.koreanReading=="string"&&m.koreanReading.trim()?(at({displayName:typeof m.displayName=="string"?m.displayName:"",koreanReading:m.koreanReading.trim(),confidence:["high","medium","low"].includes(m.confidence)?m.confidence:"medium",alternatives:Array.isArray(m.alternatives)?m.alternatives.filter(C=>typeof C=="string"&&C.trim()).slice(0,3):[]}),re(!1)):at(null);const g=i?.productFingerprint,b=C=>typeof C=="string"?C.trim():"";g&&typeof g=="object"&&b(g.categoryLabel)?ce({categoryLabel:b(g.categoryLabel),shape:b(g.shape),material:b(g.material),distinctive:b(g.distinctive),motionHint:b(g.motionHint),highlightsSummary:b(g.highlightsSummary)}):ce(null)},[]),Ir=(0,s.useCallback)(async(i,m)=>{_(g=>[...g,J("agent",Ee(),{imageUrl:i})]),q(!0);try{const{data:g}=await xt({body:{action:"analyze",language:n,...Lr(m.seedanceEngine??"2.0"),heroImageUrl:i,template:{name:m.preset.name,description:m.preset.description,category:m.preset.category,previewImage:Fr(m.preset.previewImage)},highlights:m.highlights}});Ct(g);const b=m.preset.tone,C=b?Ti[b]:void 0;if(C){const T={id:b,label:n==="en"?C.labelEn:C.labelKo,emoji:C.emoji,description:m.preset.description||"",...m.autoConcept?.recipe?{recipe:m.autoConcept.recipe}:{}},E=b==="free_concept";_(z=>[...z,J("agent",E?f(`ê³ ë¥´ì 컨ì ê·¸ëë¡ ì¤í 리보ë를 ì§ ë³¼ê²ì âï¸ 36íí¹ â ì í ì¤ëª â ì¥ì â ë§ë¬´ë¦¬ ììë¡ ê°ê²ì.`,`é¸ãã ã³ã³ã»ããã®ã¾ã¾ã¹ãã¼ãªã¼ãã¼ããä½ãã¾ãã âï¸ 37ãã㯠â 製å説æ â ã¡ãªãã â ç· ãã®é ã§é²ãã¾ãã`,`I'll write the storyboard straight from your concept âï¸
38Hook, product, benefit, then the close.`):f(`${C.labelKo} í í릿 í¤ì¼ë¡ ë°ë¡ ì¤í 리보ë를 ì§ ë³¼ê²ì ${C.emoji}`,`${C.labelKo} ãã³ãã¬ã¼ãã®ãã¼ã³ã§ãããã¹ãã¼ãªã¼ãã¼ããä½ãã¾ãã ${C.emoji}`,`I'll write the storyboard right away in the ${C.labelEn} template tone ${C.emoji}`))]),Lt(T);return}if(g?.success&&g.moods?.length){const T=g.moods.map(E=>({id:E.id||`mood_${Date.now()}`,label:E.label,emoji:E.emoji||"ð¬",description:E.description}));ye(T),_(E=>[...E,J("agent",g.assistantMessage||ee(),{moodPresets:T})])}else{const T=n==="en"?hr:pr;_(E=>[...E,J("agent",ee(),{moodPresets:T})])}}catch{const g=n==="en"?hr:pr;_(b=>[...b,J("agent",ee(),{moodPresets:g})])}finally{q(!1)}},[n,xt]),Ft=(0,s.useCallback)(async i=>{const m=me.current;if(fe(null),G(null),ie(null),Zt.current=null,x(null),ue([]),$(void 0),Le(null),rt(null),i.presetHeroImageUrl){const g=i.presetHeroImageUrl;x(g),ue(i.productImages||[]),_([J("agent",f(`ìë íì¸ì, ë¹ ë¥ì´ìì ð± 39ê³ ë¥´ì ì´ë¯¸ì§ë¥¼ ë³´ê³ ì´ì¸ë¦¬ë ë¶ì기를 ì¶ì²í´ ë릴ê²ì!`,`ããã«ã¡ã¯ãããã£ã³ã§ã ð± 40é¸ãã ç»åã«åãé°å²æ°ããããããã¾ããï¼`,`Hi, I'm Bbanyang ð± 41I'll suggest moods that fit the image you picked!`))]),F("mood_select");try{await Ir(g,i)}catch(b){if(m!==me.current)return;fe(b?.message||"Analysis failed"),F("error")}return}_([J("agent",i.productImages?.length>0?f(`ìë íì¸ì, ë¹ ë¥ì´ìì ð± 42ì¬ë ¤ 주ì ì íì¼ë¡ ëí ì´ë¯¸ì§ë¥¼ 먼ì í ì¥ ê·¸ë ¤ ë³¼ê²ì ð¨`,`ããã«ã¡ã¯ãããã£ã³ã§ã ð± 43ã¢ãããã¼ãããååã§ãã¾ã代表ç»åã1ææãã¾ãã ð¨`,`Hi, I'm Bbanyang ð± 44First I'll draw one hero image with your product ð¨`):f(`ìë íì¸ì, ë¹ ë¥ì´ìì ð± 45"${i.highlights||i.preset.name}" ë´ì©ì¼ë¡ ê´ê³ 컨ì ì´ë¯¸ì§ë¥¼ 먼ì ê·¸ë ¤ ë³¼ê²ì ð¨`,`ããã«ã¡ã¯ãããã£ã³ã§ã ð± 46ã${i.highlights||i.preset.name}ãã®å 容ã§ãã¾ãåºåã³ã³ã»ããç»åãæãã¾ãã ð¨`,`Hi, I'm Bbanyang ð± 47First I'll draw a concept image for your ad based on "${i.highlights||i.preset.name}" ð¨`))]),F("hero");try{const g=await h(i);if(m!==me.current||(x(g.heroImageUrl),ue(g.productImageUrls),$(g.faceImageUrl),await Ir(g.heroImageUrl,i),m!==me.current))return;F("mood_select")}catch(g){if(m!==me.current)return;const b=g?.message||"Failed to initialize the video agent.";fe(b),F("error"),_(C=>[...C,J("system",f(`ìì´ì í¸ë¥¼ ì¤ë¹íì§ ëª»íìµëë¤. ${b}`,`ã¨ã¼ã¸ã§ã³ããæºåã§ãã¾ããã§ããã${b}`,`I couldn't prepare the agent. ${b}`))])}},[Ir,h,o,n]),ua=(0,s.useCallback)(async()=>{if(!r||N!=="mood_select")return;const i=me.current;F("hero"),x(null),ye(null),_(m=>[...m,J("user",f("ì´ë¯¸ì§ ì¬ìì± ìì²","ç»ååçæãªã¯ã¨ã¹ã","Regenerate image")),J("agent",f(`ë¤, ëí ì´ë¯¸ì§ë¥¼ ìë¡ ê·¸ë ¤ ë³¼ê²ì ð¨ 48ë¤ ëë©´ ë°ë¡ ë³´ì¬ ë릴ê²ì!`,`ã¯ãã代表ç»åãæãç´ãã¾ãã ð¨ 49ã§ããããããè¦ããã¾ãï¼`,`Sure, I'll redraw the hero image ð¨ 50I'll show you as soon as it's done!`))]);try{const m=K||r.presetHeroImageUrl,g=await h(r.productImages.length>0?r:{...r,productImages:m?[m]:[],presetHeroImageUrl:void 0});if(i!==me.current)return;x(g.heroImageUrl),ue(g.productImageUrls),$(g.faceImageUrl),_(b=>[...b,J("agent",f(`ì§ì, ì ëí ì´ë¯¸ì§ê° ëìì´ì ð¨ 51ì´ì¸ë¦¬ë ë¶ì기를 ê³¨ë¼ ë³´ê³ ìì´ì ð`,`ã¸ã£ã¼ã³ãæ°ãã代表ç»åãã§ãã¾ãã ð¨ 52åãé°å²æ°ãé¸ãã§ãã¾ã ð`,`Ta-da, here's the new hero image ð¨ 53Picking moods that fit it ð`),{imageUrl:g.heroImageUrl})]),q(!0);try{const{data:b}=await xt({body:{action:"analyze",language:n,...Lr(r.seedanceEngine??"2.0"),heroImageUrl:g.heroImageUrl,template:{name:r.preset.name,description:r.preset.description,category:r.preset.category,previewImage:Fr(r.preset.previewImage)},highlights:r.highlights}});if(i!==me.current)return;if(Ct(b),b?.success&&b.moods?.length){const C=b.moods.map(T=>({id:T.id||`mood_${Date.now()}`,label:T.label,emoji:T.emoji||"ð¬",description:T.description}));ye(C),_(T=>[...T,J("agent",b.assistantMessage||ee(),{moodPresets:C})])}else{const C=n==="en"?hr:pr;_(T=>[...T,J("agent",ee(),{moodPresets:C})])}}catch{if(i!==me.current)return;const b=n==="en"?hr:pr;_(C=>[...C,J("agent",ee(),{moodPresets:b})])}finally{q(!1)}F("mood_select")}catch(m){if(i!==me.current)return;fe(m?.message||"Regeneration failed"),F("mood_select"),_(g=>[...g,J("system",f(`ì¬ìì±ì ì¤í¨íìµëë¤: ${m?.message}`,`åçæã«å¤±æãã¾ãã: ${m?.message}`,`Regeneration failed: ${m?.message}`))])}},[r,N,h,n,xt]),Gt=(0,s.useCallback)(async(i,m={})=>
53{if(!r||N!=="mood_select"||_e)return;const g=me.current;F("hero"),Ne(!0),x(null),ye(null),_(E=>[...E,...m.userBubbleShown?[]:[J("user",i)],J("agent",f(`ë¤, ë§ìíì ëë¡ ì´ë¯¸ì§ë¥¼ ë¤ì ê·¸ë ¤ ë³¼ê²ì ð¨ 54ë¤ ëë©´ ë°ë¡ ë³´ì¬ ë릴ê²ì!`,`ã¯ãããè¦æã©ããç»åãæãç´ãã¾ãã ð¨ 55ã§ããããããè¦ããã¾ãï¼`,`Sure, I'll redraw the image the way you asked ð¨ 56I'll show you as soon as it's done!`))]);const b=K||r.presetHeroImageUrl,C=r.productImages.length>0?r.productImages:b?[b]:[],T={...r,productImages:C,presetHeroImageUrl:void 0,highlights:r.highlights?`${r.highlights} 57 58User feedback for image regeneration: ${i}`:`User feedback for image regeneration: ${i}`};try{const E=await h(T);if(g!==me.current)return;x(E.heroImageUrl),ue(E.productImageUrls),$(E.faceImageUrl),_(z=>[...z,J("agent",f(`ì§ì, ì ì´ë¯¸ì§ê° ëìì´ì ð¨ 59ì´ì¸ë¦¬ë ë¶ì기를 ê³¨ë¼ ë³´ê³ ìì´ì ð`,`ã¸ã£ã¼ã³ãæ°ããç»åãã§ãã¾ãã ð¨ 60åãé°å²æ°ãé¸ãã§ãã¾ã ð`,`Ta-da, here's the new image ð¨ 61Picking moods that fit it ð`),{imageUrl:E.heroImageUrl})]),q(!0);try{const{data:z}=await xt({body:{action:"analyze",language:n,...Lr(r.seedanceEngine??"2.0"),heroImageUrl:E.heroImageUrl,template:{name:r.preset.name,description:r.preset.description,category:r.preset.category,previewImage:Fr(r.preset.previewImage)},highlights:r.highlights}});if(g!==me.current)return;if(Ct(z),z?.success&&z.moods?.length){const y=z.moods.map(j=>({id:j.id||`mood_${Date.now()}`,label:j.label,emoji:j.emoji||"ð¬",description:j.description}));ye(y),_(j=>[...j,J("agent",z.assistantMessage||ee(),{moodPresets:y})])}else{const y=n==="en"?hr:pr;_(j=>[...j,J("agent",ee(),{moodPresets:y})])}}catch{if(g!==me.current)return;const z=n==="en"?hr:pr;_(y=>[...y,J("agent",ee(),{moodPresets:z})])}finally{q(!1)}F("mood_select")}catch(E){if(g!==me.current)return;fe(E?.message||"Regeneration failed"),F("mood_select"),_(z=>[...z,J("system",f(`ì¬ìì±ì ì¤í¨íìµëë¤: ${E?.message}`,`åçæã«å¤±æãã¾ãã: ${E?.message}`,`Regeneration failed: ${E?.message}`))])}finally{g===me.current&&Ne(!1)}},[r,N,_e,h,n,xt]),ma=(0,s.useCallback)(async()=>{if(!r||!K||_e)return;const i=me.current;ie(null),Zt.current=null,rt(null),ye(null),Ne(!0),q(!0),F("mood_select"),_(m=>[...m,J("user",f("ë¤ë¥¸ 컨ì ìë","ä»ã®ã³ã³ã»ããã試ã","Try a different concept")),J("agent",f(`ì¢ìì, ë¤ë¥¸ 컨ì ì ì°¾ìë³¼ê²ì ð 62ì ê¹ë§ 기ë¤ë ¤ 주ì¸ì!`,`ããã§ãããå¥ã®ã³ã³ã»ãããæ¢ãã¾ãã ð 63å°ãå¾ ã£ã¦ã¦ãã ããï¼`,`Sure, let me find a different concept ð 64Just a moment!`))]);try{const{data:m}=await xt({body:{action:"analyze",language:n,...Lr(r.seedanceEngine??"2.0"),heroImageUrl:K,template:{name:r.preset.name,description:r.preset.description,category:r.preset.category,previewImage:Fr(r.preset.previewImage)},highlights:r.highlights}});if(i!==me.current)return;if(m?.success&&m.moods?.length){const g=m.moods.map(b=>({id:`mood_${Date.now()}_${Math.random().toString(36).slice(2)}`,label:b.label,emoji:b.emoji||"ð¬",description:b.description}));ye(g),_(b=>[...b,J("agent",m.assistantMessage||ee(),{moodPresets:g})])}else{const g=n==="en"?hr:pr;_(b=>[...b,J("agent",ee(),{moodPresets:g})])}}catch{if(i!==me.current)return;const m=n==="en"?hr:pr;_(g=>[...g,J("agent",ee(),{moodPresets:m})])}finally{Ne(!1),q(!1)}},[r,K,_e,n,xt]),or=(0,s.useCallback)(async(i,m)=>{if(!(!r||!K||_e)){rt(i),m?.auto||_(g=>[...g,J("user",i.label),J("agent",f(`ì¢ìì, "${i.label}" ë¶ìê¸°ë¡ ê° ë³¼ê²ì ð 65${r.videoDuration||15}ì´ ì¼ì¸ ì¤í 리보ë를 ë°ë¡ ì§ ë³¼ê²ì âï¸`,`ããã§ãããã${i.label}ãã®é°å²æ°ã§ããã¾ããã ð 66${r.videoDuration||15}ç§ã·ã§ã¼ãã®ã¹ãã¼ãªã¼ãã¼ããããä½ãã¾ãã âï¸`,`Great, let's go with the "${i.label}" vibe ð 67I'll write the ${r.videoDuration||15}-second shorts storyboard right away âï¸`))]),F("drafting"),Ne(!0);try{const g=await _r({action:"draft",session:r,heroImageUrl:K,productImageUrls:te,faceImageUrl:R,mood:i,brandPronunciation:ut,productFingerprint:Me});if(!g.draft?.title&&!g.draft?.cuts?.length)throw new Error(f("AIê° ì¤í 리보ë를 ìì±íì§ ëª»íìµëë¤. ë¤ì ìëí´ ì£¼ì¸ì.","AIãã¹ãã¼ãªã¼ãã¼ããçæã§ãã¾ããã§ãããå試è¡ãã¦ãã ããã","AI failed to generate storyboard. Please try again."));
67ie(Ys(g.draft)),_(b=>[...b,J("agent",g.assistantMessage||f("ì¤í 리보ë를 ë¤ ì¼ì´ì ð","ã¹ãã¼ãªã¼ãã¼ããã§ãã¾ãã ð","Your storyboard is ready ð"),{suggestions:g.suggestions?.length?g.suggestions:gr,showStoryboard:!0}),J("agent",Xs(n),{storyboardFollowUp:!0})]),F("discussion")}catch(g){const b=g?.message||"Failed to create storyboard draft.";if(b.startsWith("INVOKE_AGENT_CANCELLED")){pe.log("[shorts-video-agent] selectMood cancelled (session/reset):",b);return}fe(b),F("mood_select"),_(C=>[...C,J("system",`â ï¸ ${b}`),J("agent",f(`ì, ì´ë²ì ì¤í 리보ë를 못 ì¼ì´ì ð¿ 68ë¤ë¥¸ ë¶ì기를 ê³ ë¥´ê±°ë í ë² ë ìëí´ ë³¼ê¹ì?`,`ãã£ãä»åã¯ã¹ãã¼ãªã¼ãã¼ããä½ãã¾ããã§ãã ð¿ 69å¥ã®é°å²æ°ãé¸ã¶ããããä¸åº¦è©¦ãã¦ã¿ã¾ããããï¼`,`Oops, I couldn't write the storyboard this time ð¿ 70Want to pick another mood or try again?`),{moodPresets:n==="en"?hr:pr})])}finally{Ne(!1)}}},[ut,gr,K,_r,_e,n,Me,r,R,te]);(0,s.useEffect)(()=>{if(!Ze||!r||!K||_e||N!=="mood_select"&&N!=="hero")return;const i=Ze;Lt(null),or(i,{auto:!0})},[Ze,r,K,_e,N,or]);const Ar=(0,s.useCallback)(async(i,m,g)=>{try{const{data:b,error:C}=await xt({body:{action:"chat",language:n,phase:N,revisionAvailable:m,userMessage:i,targetDuration:r?.videoDuration||15,currentDraft:B,messages:g.slice(-10).map(T=>({role:T.role,content:String(T.content||"")}))}});if(C||!b?.success)throw new Error(C?.message||b?.error||"chat failed");return{received:!0,intent:b.intent,reply:typeof b.reply=="string"?b.reply.trim():"",quality:typeof b.quality=="string"?b.quality:null,suggestions:Array.isArray(b.suggestions)?b.suggestions.filter(T=>typeof T=="string"):[]}}catch(b){return pe.warn("[shorts-agent] chat judge failed",b?.message),{received:!1,intent:void 0,reply:"",quality:null,suggestions:[]}}},[xt,n,N,r?.videoDuration,B]),it=(0,s.useCallback)(async(i,m)=>{if(!r||_e)return;const g=me.current;Ne(!0),_(T=>[...T,J("agent",m)]);const b=K||r.presetHeroImageUrl,C={...r,productImages:r.productImages.length>0?r.productImages:b?[b]:[],presetHeroImageUrl:void 0,highlights:r.highlights?`${r.highlights} 71 72User feedback for image regeneration: ${i}`:`User feedback for image regeneration: ${i}`};try{const T=await h(C);if(g!==me.current)return;x(T.heroImageUrl),ue(T.productImageUrls),$(T.faceImageUrl),ie(E=>E&&{...E,finalPrompt:""}),_(E=>[...E,J("agent",f(`ì§ì, ì ëí ì´ë¯¸ì§ê° ëìì´ì ð¨ 73ì¤í 리보ëë ê·¸ëë¡ ëê³ , ììì ì´ ì´ë¯¸ì§ë¡ ë§ë¤ê²ì.`,`ã¸ã£ã¼ã³ãæ°ãã代表ç»åãã§ãã¾ãã ð¨ 74ã¹ãã¼ãªã¼ãã¼ãã¯ãã®ã¾ã¾ã§ãåç»ã¯ãã®ç»åã§ä½ãã¾ããã`,`Here is the new representative image ð¨ 75The storyboard stays as it is â the video will use this image.`),{imageUrl:T.heroImageUrl})])}catch(T){if(g!==me.current)return;_(E=>[...E,J("system",f(`ëí ì´ë¯¸ì§ë¥¼ ë¤ì ê·¸ë¦¬ì§ ëª»íì´ì: ${T?.message||""}`.trim(),`代表ç»åãæãç´ãã¾ããã§ãã: ${T?.message||""}`.trim(),`Could not redraw the representative image: ${T?.message||""}`.trim()))])}finally{g===me.current&&Ne(!1)}},[r,_e,K,h,n]),ir=(0,s.useCallback)(async i=>{const m=i.trim();if(!m||!r||P)return;const g=V&&N==="result"&&!!B&&!_e,b=[...se,J("user",m)];_(M=>[...M,J("user",m)]);const C=async(M,Q)=>{if(!(!K||!B)){if(!D&>>=Js){if(!await Mt(ia)){nr(ia),_(ke=>[...ke,J("system",f("4í째 ìì ë¶í°ë 1í¬ë ë§ì´ íìí©ëë¤. í¬ë ë§ì´ ë¶ì¡±í´ ìì²ì ì²ë¦¬í ì ìì´ì.","4åç®ä»¥éã®ä¿®æ£ã¯1ã¯ã¬ã¸ããå¿ è¦ã§ããã¯ã¬ã¸ãããä¸è¶³ãã¦ãããããªã¯ã¨ã¹ããå¦çã§ãã¾ããã","Revisions beyond the free count require 1 credit. Insufficient credits to process this request."))]);return}if(!await wt(ia,"ì¼ì¸ ìì´ì í¸ ì¤í 리보ë ìì ")){nr(ia),_(ke=>[...ke,J("system",f("í¬ë ë§ ì°¨ê°ì ì¤í¨íìµëë¤. ì ì í ë¤ì ìëí´ ì£¼ì¸ì.","ã¯ã¬ã¸ããæ§é¤ã«å¤±æãã¾ããããã°ããå¾ã«å試è¡ãã¦ãã ããã","Credit deduction failed. Please try again in a moment."))]);return}}Ae(ke=>ke+1),Ne(!0),Q&&_(ke=>[...ke,J("agent",Q)]);try{const ke=await _r({action:"revise",session:r,heroImageUrl:K,productImageUrls:te,faceImageUrl:R,draft:M==="reconstruct"?null:B,messages:b,userMessage:m,mood:M==="reconstruct"?null:yt,revisionMode:M,brandPronunciation:ut,productFingerprint:Me});ke.draft&&ie(Ys(ke.draft)),_(ae=>[...ae,J("agent",ke.assistantMessage||f("ë§ìíì ëë¡ ê³ ì³¤ì´ì â¨","ãè¦æã©ããç´ãã¾ãã â¨","Done â updated as you asked â¨"),{suggestions:ke.suggestions?.length?ke.suggestions:gr,showStoryboard:!!ke.draft}),...ke.draft?[J("agent",Xs(n),{storyboardFollowUp:!0})]:[]]),fe(null),F("discussion")}catch(ke){const ae=ke?.message||"Failed to update the storyboard.";if(ae.startsWith("INVOKE_AGENT_CANCELLED")){pe.log("[shorts-video-agent] sendMessage cancelled (session/reset):",ae);return}fe(ae),_(Pe=>[...Pe,J("system",f(`ìì ë°ì ì¤ ë¬¸ì ê° ìê²¼ìµëë¤. ${ae}`,`ä¿®æ£åæ ä¸ã«åé¡ãçºçãã¾ããã${ae}`,`There was a problem applying the revision. ${ae}`))])}finally{Ne(!1)}}};if(g){X(!1),ge.current?.({silent:!0}),await C("revise",f(`ìê² ì´ì! 76기존 ì¤í 리보ëìì ë§ìíì ë¶ë¶ì ê³ ì³ ë¤ì ì¨ ë³¼ê²ì âï¸`,`ãããã¾ããï¼ 77ä»ã®ã¹ãã¼ãªã¼ãã¼ãã§ãè¨ãããã¨ãããç´ãã¦æ¸ãç´ãã¾ãã âï¸`,`Got it! 78I'll rewrite the current storyboard with your changes âï¸`));return}const T=pi({phase:N,hasDraft:!!B&&!!K,isBusy:_e||Ie});Ce(!0);let E;try{E=await Ar(m,T!=="answer_only",b)}finally{Ce(!1)}const z=mi({intent:E.intent,received:E.received,route:T}),y=E.reply,j=(M,Q,ke)=>{_(ae=>[...ae,y?J("agent",y,E.suggestions.length?{suggestions:E.suggestions}:void 0):J("system",f(M,Q,ke))])};
78if(z==="answer"||T==="answer_only"){j("ëµì ê°ì ¸ì¤ì§ 못íì´ì. ì ì í ë¤ì ë§ìí´ ì£¼ì¸ì.","åçãåå¾ã§ãã¾ããã§ãããå°ãå¾ã«ããä¸åº¦ã話ããã ããã","I could not get an answer. Please try again in a moment.");return}if(T==="mood_select"){if(z==="redraw_hero"&&K){await Gt(m,{userBubbleShown:!0});return}await or({id:`custom_${Date.now()}`,label:m.length>20?m.substring(0,20)+"...":m,description:m,emoji:"âï¸"});return}if(T==="gate_then_act"&&ge.current?.({silent:!0}),z==="redraw_hero"){await it(m,y||f(`ë¤, ëí ì´ë¯¸ì§ë¥¼ ë¤ì ê·¸ë ¤ ë³¼ê²ì ð¨ 79ì¤í 리보ëë ê·¸ëë¡ ëê²ì.`,`ã¯ãã代表ç»åãæãç´ãã¾ãã ð¨ 80ã¹ãã¼ãªã¼ãã¼ãã¯ãã®ã¾ã¾ã«ãã¾ãã`,`Sure, I'll redraw the representative image ð¨ 81The storyboard stays as it is.`));return}if(z==="generate_video"){const M=wn(r.seedanceEngine??"2.0",r.videoDuration??15),Q=ui(E.quality,M);We({quality:Q,nonce:Date.now()}),_(ke=>[...ke,J("agent",f(`ì¢ìì, ì§ê¸ ì¤í 리보ëë¡ ${Q} ììì ë§ë¤ê²ì ð¬ 82íì¸ì°½ìì ììì ëë¬ ì£¼ì¸ì!`,`ããã§ãããä»ã®ã¹ãã¼ãªã¼ãã¼ãã§${Q}ã®åç»ãä½ãã¾ãã ð¬ 83確èªç»é¢ã§éå§ãæ¼ãã¦ãã ããï¼`,`Great â I'll make the ${Q} video from this storyboard ð¬ 84Press start in the confirmation.`))]);return}await C(z==="reconstruct"?"reconstruct":"revise",y||(z==="reconstruct"?f("ì¢ìì, ë§ìíì ë°©í¥ì¼ë¡ ì¤í 리보ë를 ì²ìë¶í° ìë¡ ì§ ë³¼ê²ì âï¸","ããã§ãããè¨ãããæ¹åã§ã¹ãã¼ãªã¼ãã¼ããæåããä½ãç´ãã¾ãã âï¸","Sure, I'll rebuild the storyboard from scratch in your new direction âï¸"):f("ë§ìíì ë¶ë¶ì ê³ ì³ì ë¤ì ì 리í ê²ì âï¸","è¨ãããã¨ãããç´ãã¦æ´ãç´ãã¾ãã âï¸","I'll rework that part and tidy up the storyboard âï¸")))},[Ar,ut,gr,B,K,_r,Ie,P,_e,n,se,N,Me,it,yt,or,r,R,te,Gt,gt,Mt,wt,nr,V,D]),Vt=(0,s.useCallback)(async i=>{if(!r||!K)return i.finalPrompt;const m=await et("rebuild-prompt");if(m)return m.finalPrompt||i.finalPrompt;const g=new AbortController,b=setTimeout(()=>g.abort(),155e3);try{const C=(await ve.auth.getSession()).data.session?.access_token,T=await fetch(`${Wa}/shorts-video-agent`,{method:"POST",headers:{"Content-Type":"application/json",...C?{Authorization:`Bearer ${C}`}:{}},body:JSON.stringify({action:"rebuild-prompt",targetDuration:r.videoDuration||15,heroImageUrl:K,currentDraft:i,language:n,highlights:r.highlights,template:{name:r.preset.name,description:r.preset.description},mood:yt,autoConcept:r.autoConcept?{hook:r.autoConcept.hook,cta:r.autoConcept.cta,sellingPoints:r.autoConcept.sellingPoints,casting:r.autoConcept.casting,location:r.autoConcept.location,hookAction:r.autoConcept.hookAction,benefit:r.autoConcept.benefit,speechStyle:r.autoConcept.speechStyle,narrationStyle:r.autoConcept.narrationStyle,cgModuleLabel:r.autoConcept.cgModuleLabel,cgIntensity:r.autoConcept.cgIntensity,cgDirection:r.autoConcept.cgDirection}:void 0,brandPronunciation:ut,productFingerprint:Me,...Lr(r.seedanceEngine??"2.0"),...r.seedanceEngine==="2.5"?{productImageUrls:te,faceImageUrl:R??null}:{}}),signal:g.signal});if((T.headers.get("content-type")||"").includes("text/event-stream")){const E=(await T.text()).split(` 85`).filter(z=>z.startsWith("data: "));for(let z=E.length-1;z>=0;z--)try{const y=JSON.parse(E[z].slice(6));if(y.finalPrompt)return y.finalPrompt;if(y.draft?.finalPrompt)return y.draft.finalPrompt}catch{}}else{const E=await T.json(),z=E.finalPrompt||E.draft?.finalPrompt;if(z&&z.trim())return z}}catch{}finally{clearTimeout(b)}throw new Error(f("í롬íí¸ ìì±ì ì¤í¨íìµëë¤. ì ì í ë¤ì ìëí´ ì£¼ì¸ì.","ããã³ããçæã«å¤±æãã¾ããããã°ããå¾ã«å試è¡ãã¦ãã ããã","Prompt generation failed. Please try again in a moment."))},[ut,K,n,Me,yt,r,te,R]),Kt=(0,s.useCallback)((i,m)=>{ie(g=>!g||!g.cuts?g:{...g,cuts:g.cuts.map(b=>b.cutNumber===i?m:b)})},[]),pt=(0,s.useRef)(!1),Pt=(0,s.useRef)([]),Zt=(0,s.useRef)(null),Sr=(0,s.useRef)(0),lr=(0,s.useCallback)(async(i="720p")=>{if(!(!r||!K||!B||_e||pt.current)){pt.current=!0,W&&(pe.log("[shorts-video-agent] Clearing previous activeGeneration before new generation"),Le(null),De(null)),Ne(!0),F("generating"),Sr.current=Date.now(),Je.current=!1,De({progress:5,status:"generating",message:f("í¸ì§ë ì»· 기ë°ì¼ë¡ ìµì¢ í롬íí¸ ìì± ì¤...","ç·¨éãããã«ããããã¨ã«æçµããã³ãããçæä¸...","Rebuilding final prompt from edited cuts...")}),_(m=>
85[...m,J("agent",f(`ì¤í 리보ëëë¡ ìì ë§ë¤ê¸° ììí ê²ì ð¬ 86ë³´íµ 1~2ë¶ì´ë©´ ìì±ë¼ì.`,`ã¹ãã¼ãªã¼ãã¼ãã©ããã«åç»ãä½ãå§ãã¾ãã ð¬ 87ã ããã1ã2åã§ã§ããããã¾ãã`,`Starting the video from your storyboard ð¬ 88It usually takes 1â2 minutes.`))]);try{const m=In(_n(await Vt(B))),g={...B,finalPrompt:m};ie(g),Zt.current=r.seedanceEngine??"2.0",De({progress:10,status:"generating",message:f("ìì í롬íí¸ ì ì¡ ì¤...","åç»ããã³ããéä¿¡ä¸...","Sending the video prompt...")});const b=await S({session:r,heroImageUrl:K,productImageUrls:te,faceImageUrl:R,finalPrompt:m,storyboardDraft:g,quality:i,excludeProviders:Pt.current});b.resultUrl?Ye(b.resultUrl,H()):Le(b)}catch(m){if(Os(m)){De(null),F("discussion");return}const g=m?.message||"Failed to start video generation.";De(null),fe(g),F("discussion"),_(b=>[...b,J("system",f(`ìì ìì± ìì²ì ì¤í¨íìµëë¤: ${g} 89ì¤í 리보ë를 ìì íê±°ë ë¤ì ìëí´ ì£¼ì¸ì.`,`åç»çæãªã¯ã¨ã¹ãã«å¤±æãã¾ãã: ${g} 90ã¹ãã¼ãªã¼ãã¼ããä¿®æ£ãããå試è¡ãã¦ãã ããã`,`Video generation request failed: ${g} 91Please revise the storyboard or try again.`))])}finally{Ne(!1),pt.current=!1}}},[B,K,_e,n,Ye,Vt,r,S]),It=(0,s.useCallback)(()=>{const i=D?.finalVideoUrl;if(!i||Fe.current==="result")return;const m=H();if(Fe.current==="generating"){Ye(i,m);return}const g=D?.respond("draft")?.data?.draft??null;ie(b=>b??g),Ne(!1),fe(null),Le(null),De(null),pt.current=!1,G(i),F("result"),_(b=>b.some(C=>C.videoUrl===i)?b:[...b,J("agent",m,{videoUrl:i})])},[D,n,Ye]),pa=(0,s.useCallback)(()=>{!D||Fe.current!=="result"||(me.current+=1,Je.current=!1,pt.current=!1,Le(null),De(null),G(null),Ne(!1),fe(null),F("generating"))},[D]),Ut=(0,s.useCallback)(()=>{if(!D||Fe.current!=="generating"&&Fe.current!=="result")return;me.current+=1,Je.current=!1,pt.current=!1,Le(null),De(null),G(null),Ne(!1),fe(null);const i=D.respond("draft")?.data?.draft??null;ie(m=>m??i),F("discussion")},[D]);(0,s.useEffect)(()=>{if(!t){Fe.current!=="generating"&&Fe.current!=="result"&&Vr();return}if(t&&r&&N==="idle"){if(Bt.current){Bt.current=!1;return}if(bt!==r.sessionId)return;Ft(r)}},[Ft,t,N,Vr,r,bt]),(0,s.useEffect)(()=>{if(!W||N!=="generating")return;const i=l.find(m=>{const g=m.generationOptions||{},b=g.client_task_id||g.clientTaskId,C=g.ad_workflow==="video_agent";return m.taskId===W.apiTaskId||b===W.clientTaskId?m.mediaType==="video"||C||/\.(mp4|webm|mov)/i.test(m.editedImageUrl||""):!1});i?.editedImageUrl&&Ye(i.editedImageUrl,H())},[W,n,Ye,N,l]),(0,s.useEffect)(()=>{if(!(!mt||N!=="generating")){if(mt.status==="completed"&&mt.resultUrl){Ye(mt.resultUrl,H());return}De(i=>({progress:Math.max(i?.progress??0,mt.progress??0),status:mt.status,error:mt.error,message:mt.message,resultUrl:mt.resultUrl??i?.resultUrl??null}))}},[mt,n,Ye,N]);const{markObserved:cr}=ni({active:N==="generating",suspended:()=>Qt.current,label:"shorts-video-agent",onZombie:()=>{Je.current||(Le(null),De(null),F("discussion"),Ne(!1),pt.current=!1,_(i=>[...i,J("system",f("ì§í ì¤ì´ë ìì ìì ì ì°¾ì§ ëª»í´ ìì±ì ì¤ë¨íìµëë¤. ì°¨ê°ë í¬ë ë§ì ììµëë¤. ì¤í 리보ë를 íì¸íê³ ë¤ì ìì±í´ 주ì¸ì.","é²è¡ä¸ã®åç»ä½æ¥ãè¦ã¤ãããªãã£ãããçæã䏿ãã¾ãããå·®ãå¼ãããã¯ã¬ã¸ããã¯ããã¾ãããã¹ãã¼ãªã¼ãã¼ãã確èªãã¦åçæãã¦ãã ããã","We could not find the video job in progress, so generation was stopped. No credits were charged. Please review the storyboard and generate again."))]))}});(0,s.useEffect)(()=>{if(N!=="generating")return;const i=W?.apiTaskId;let m=!1;const g=async()=>{if(m||Je.current)return;let j=null,M=null;if(i){let ae=ve.from("user_tasks").select("status, progress, result_url, error_message").eq("task_id",i);I&&(ae=ae.eq("user_id",I));const Pe=await ae.maybeSingle();j=Pe.data,M=Pe.error}else if(I){const ae=new Date(Date.now()-3e5).toISOString(),Pe=await ve.from("user_tasks").select("status, progress, result_url, error_message").eq("user_id",I).in("model",Ci).filter("generation_options->>ad_workflow","eq","video_agent").filter("generation_options->>task_type","eq",ot).gt("created_at",ae).order("created_at",{ascending:!1}).limit(1).maybeSingle();j=Pe.data,M=Pe.error}if(m||M||!j)return;cr();const Q=ar(j.result_url);if(Q){Pt.current=[],Ye(Q,H());return}if(j.status==="failed"){const ae=j.error_message||f("ìì ìì±ì ì¤í¨íìµëë¤.","åç»çæã«å¤±æãã¾ããã","Video generation failed."),Pe=j?.generation_options?.provider;
91typeof Pe=="string"&&Pe.trim()&&!Pt.current.includes(Pe)&&(Pt.current=[...Pt.current,Pe],pe.warn("[shorts-video-agent] provider failed â ë¤ì ì¬ìëìì ì ì¸:",Pe,Pt.current)),_t(ae);return}const ke=typeof j.progress=="number"?Math.max(10,Math.min(Math.round(j.progress),99)):10;De(ae=>({progress:Math.max(ae?.progress??0,ke),status:"generating",error:void 0,message:ae?.message||f("ìì ìì± ì¤","åç»çæä¸","Generating video"),resultUrl:ae?.resultUrl??null}))};g();const b=window.setInterval(()=>{g()},3e3),C=97,T=8,E=4.5,z=Date.now(),y=window.setInterval(()=>{if(m||Je.current)return;const j=(Date.now()-z)/6e4,M=Math.floor(C-(C-T)*Math.exp(-j/E));De(Q=>{if(!Q||Q.status!=="generating")return Q;const ke=Math.max(Q.progress??0,M);return ke===(Q.progress??0)?Q:{...Q,progress:ke}})},3e3);return()=>{m=!0,window.clearInterval(b),window.clearInterval(y)}},[W,n,Ye,_t,N,I]),(0,s.useEffect)(()=>{if(!W?.apiTaskId||N!=="generating")return;const i=W.apiTaskId,m=async()=>{try{const{data:E}=await ve.from("user_tasks").select("generation_options").eq("task_id",i).single(),z=E?.generation_options?.provider;return z&&{segmind:"segmind-task-status",evolink:"evolink-task-status",kie:"kie-task-status"}[z]||null}catch{return null}};let g=null;const b=async()=>{if(g)try{const{data:E}=await ve.functions.invoke(g,{body:{taskId:i}});E?.status==="completed"&&E?.result_url?Ye(E.result_url,H()):E?.status==="failed"&&_t(E.error||f("ìì ìì±ì ì¤í¨íìµëë¤.","åç»çæã«å¤±æãã¾ããã","Video generation failed."))}catch{}};m().then(E=>{g=E});const C=setTimeout(b,1e4),T=setInterval(b,15e3);return()=>{clearTimeout(C),clearInterval(T)}},[W?.apiTaskId,n,Ye,_t,N]),(0,s.useEffect)(()=>{if(!W?.apiTaskId||N!=="generating")return;const i=ve.channel(`shorts-agent-task-watch-${W.apiTaskId}`).on("postgres_changes",{event:"UPDATE",schema:"public",table:"user_tasks",filter:`task_id=eq.${W.apiTaskId}`},m=>{const g=m.new;if(I&&g?.user_id&&g.user_id!==I){pe.log("[shorts-agent] Ignoring realtime update from another user:",g.user_id);return}const b=ar(g?.result_url);b?Ye(b,H()):g?.status==="failed"&&_t(g.error_message||f("ìì ìì±ì ì¤í¨íìµëë¤.","åç»çæã«å¤±æãã¾ããã","Video generation failed."))}).subscribe();return()=>{ve.removeChannel(i)}},[W?.apiTaskId,n,Ye,_t,N]),(0,s.useEffect)(()=>{const i=mt||kt;if(!(!i||N!=="generating")){if(i.resultUrl){Ye(i.resultUrl,H());return}if(i.status==="failed"){_t(i.error||f("ìì ìì±ì ì¤í¨íìµëë¤.","åç»çæã«å¤±æãã¾ããã","Video generation failed."));return}}},[mt,kt,n,Ye,_t,N]),(0,s.useEffect)(()=>{if(N!=="generating"||!W?.apiTaskId||!I)return;const i=W.apiTaskId,m=W.clientTaskId,g=async()=>{try{const{data:T}=await ve.from("user_tasks").select("status, result_url").eq("task_id",i).eq("user_id",I).maybeSingle(),E=ar(T?.result_url);if(E){Ye(E,H());return}const z=[i,m].filter(M=>typeof M=="string"&&M.length>0);let y=null;if(z.length>0){const{data:M}=await ve.from("user_image_library").select("image_url").eq("user_id",I).in("task_id",z).is("deleted_at",null).order("created_at",{ascending:!1}).limit(1);y=M}const j=ar(y?.[0]?.image_url);if(j){Ye(j,H());return}if(I){const{data:M}=await ve.from("user_image_library").select("image_url, created_at").eq("user_id",I).eq("task_type","shorts").eq("media_type","video").is("deleted_at",null).order("created_at",{ascending:!1}).limit(1),Q=M?.[0],ke=ar(Q?.image_url);if(ke){const ae=Q?.created_at?new Date(Q.created_at).getTime():0,Pe=Sr.current;Pe>0&&ae>=Pe-60*1e3&&Ye(ke,H())}}}catch{}},b=window.setTimeout(()=>{g()},3e3),C=window.setInterval(()=>{g()},2e4);return()=>{window.clearTimeout(b),window.clearInterval(C)}},[N,W?.apiTaskId,W?.clientTaskId,I,n,Ye]);const vt=(0,s.useCallback)((i={})=>{N!=="result"||!B||(G(null),F("discussion"),Le(null),De(null),Je.current=!1,pt.current=!1,ie(m=>m&&{...m,finalPrompt:""}),i.silent||_(m=>
91[...m,J("agent",f(`ì¤í 리보ë를 ë¤ì ê³ ì¹ ì ìì´ì âï¸ 92ë¤ ê³ ì¹ë©´ ìëìì ìì ë§ë¤ê¸°ë¥¼ ëë¬ ì£¼ì¸ì!`,`ã¹ãã¼ãªã¼ãã¼ããããä¸åº¦ç´ãã¾ãã âï¸ 93ç´ãçµãã£ããä¸ã§åç»ãä½ããã¿ã³ãæ¼ãã¦ãã ãããï¼`,`You can edit the storyboard again âï¸ 94When you are done, press Generate below!`))]))},[N,B,n]);ge.current=vt;const Rr=(0,s.useCallback)(()=>{N!=="result"||!B||V||(X(!0),_(i=>[...i,J("agent",f(`ì¢ìì, ê°ì´ ê³ ì³ ë´ì âï¸ 95ììì ì´ë»ê² ìì í ê¹ì?`,`ããã§ãããä¸ç·ã«ç´ãã¾ããã âï¸ 96åç»ãã©ãä¿®æ£ãã¾ããããï¼`,`Sure, let's fix it together âï¸ 97How would you like to change the video?`))]))},[N,B,V,n]);(0,s.useEffect)(()=>{N!=="result"&&X(!1)},[N]);const dr=(0,s.useCallback)(async(i="720p")=>{if(!r||!K||!B||_e||pt.current)return;pt.current=!0;const m=B.finalPrompt,g=r.seedanceEngine??"2.0",b=Ni(Zt.current,g,m);if(!m||b){pt.current=!1,await lr(i);return}Ne(!0),F("generating"),Sr.current=Date.now(),Je.current=!1,G(null),Le(null),De({progress:10,status:"generating",message:f("ëì¼í í롬íí¸ë¡ ìì ì¬ìì± ì¤...","åãããã³ããã§åç»ãåçæä¸...","Regenerating video with same prompt...")}),_(C=>[...C,J("agent",f("ê°ì ì¤í 리보ëë¡ ììì í ë² ë ë§ë¤ì´ ë³¼ê²ì ð¬","åãã¹ãã¼ãªã¼ãã¼ãã§åç»ãããä¸åº¦ä½ãã¾ãã ð¬","I'll make one more video from the same storyboard ð¬"))]);try{const C=await S({session:r,heroImageUrl:K,productImageUrls:te,faceImageUrl:R,finalPrompt:m,storyboardDraft:B,quality:i,excludeProviders:Pt.current});Le({clientTaskId:C.clientTaskId,apiTaskId:C.apiTaskId||null}),C.resultUrl&&Ye(C.resultUrl,H())}catch(C){if(Os(C)){F("discussion");return}_t(C?.message||"Regeneration failed")}finally{Ne(!1),pt.current=!1}},[r,K,B,_e,n,S,te,R,Ye,_t,lr]),ur=(0,s.useCallback)(i=>{const m=i.trim();m&&(at(g=>({displayName:g?.displayName||"",koreanReading:m,confidence:"high",alternatives:g?.alternatives||[]})),re(!1))},[]),Hr=(0,s.useCallback)((i,m)=>{const g=m.trim();g&&(at({displayName:i.trim(),koreanReading:g,confidence:"high",alternatives:[]}),re(!1))},[]),Wt=(0,s.useCallback)(i=>{re(i),i&&at(null)},[]);return{phase:N,messages:se,draft:B,heroImageUrl:K,finalVideoUrl:O,error:Oe,isThinking:_e,isAnalyzing:Ie,streamingPhase:Qe,streamingCutNumber:$t,selectedMood:yt,moodPresets:kr,brandPronunciation:ut,productFingerprint:Me,activeTaskProgress:Math.max(mt?.progress??0,kt?.progress??0)||(N==="generating"?10:null),activeTaskStatus:mt?.status??kt?.status??null,activeTaskMessage:mt?.message??kt?.message??null,canSendMessage:!!r&&N!=="idle"&&!P,isAnswering:P,generateRequest:Re,clearGenerateRequest:()=>We(null),canGenerateVideo:N==="discussion"&&!_e&&!!B&&!!K,brandPronunciationSkipped:qt,nextMessageCost:(N==="discussion"||N==="result")&>>=Js?ia:0,canSelectMood:N==="mood_select"&&!_e,canRegenerateHero:N==="mood_select"&&!_e&&!!K,sendMessage:ir,selectMood:or,updateBrandPronunciation:ur,confirmBrandPronunciation:Hr,markBrandPronunciationSkipped:Wt,generateVideo:lr,regenerateVideo:dr,editStoryboard:vt,askVideoRevision:Rr,videoRevisionAsked:V,updateCut:Kt,regenerateHero:ua,restartConcept:ma,cancelGeneration:wr,jumpToResultForTutorial:It,showProgressForTutorial:pa,rewindToDiscussionForTutorial:Ut,reset:Vr}}var Fi={analyzing:"searching",start:"searching",concept:"solving",cuts_start:"composing",cut:"shaping",narration:"composing",final:"working"},Gi=yn({quality:"medium",resolution:"1K"}),ta=t=>(r,n,l)=>t==="ko"?r:t==="ja"?n:l,Vi=({cut:t,language:r,index:n,editable:l=!1,onSave:p,onEditingChange:h})=>{const o=ta(r),[S,v]=(0,s.useState)(!1),[U,D]=(0,s.useState)(t),I=(0,s.useRef)(!1),f=te=>{I.current!==te&&(I.current=te,h?.(te?1:-1))};(0,s.useEffect)(()=>()=>{I.current&&h?.(-1)},[]);const H=t.narration&&t.narration!=="ìì"&&t.narration!=="None",ee=t.dialogue&&t.dialogue!=="ìì"&&t.dialogue!=="None",Ee="bg-white/[0.03]",N="border-border",F="text-brand-ink",se="border-border",_="shrink-0 w-[46px] md:w-[52px] pt-px text-[10px] md:text-[10.5px] font-bold text-muted-foreground",B=()=>{D({...t}),v(!0),f(!0)},ie=()=>{p?.(U),v(!1),f(!1)},K=()=>{D({...t}),v(!1),f(!1)},x=(te,ue)=>{D(R=>({...R,[te]:ue}))};if(S){const te="mb-1 block text-[10.5px] font-bold text-muted-foreground",ue="w-full rounded-xl border border-white/[0.14] bg-white/[0.02] px-3 py-1.5 text-[12.5px] text-foreground placeholder:text-muted-foreground
97/70 outline-none transition-colors focus:border-brand/55 dark:bg-black/25";return(0,e.jsxs)("div",{className:st("overflow-hidden rounded-2xl border border-brand/50",Ee),children:[(0,e.jsxs)("div",{className:st("flex items-center justify-between border-b px-4 py-2",se),children:[(0,e.jsxs)("span",{className:st("font-geo text-[10.5px] font-bold uppercase tracking-[0.16em]",F),children:["Cut ",t.cutNumber]}),(0,e.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,e.jsx)("button",{type:"button",onClick:K,className:"rn-btn rn-btn-g is-xs",children:o("ì·¨ì","ãã£ã³ã»ã«","Cancel")}),(0,e.jsx)("button",{type:"button",onClick:ie,className:"rn-btn rn-btn-y is-xs",children:o("ì ì¥","ä¿å","Save")})]})]}),(0,e.jsxs)("div",{className:"space-y-2.5 px-4 py-3",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:te,children:o("ì¥ë©´ ì¤ëª
","ã·ã¼ã³èª¬æ","Scene Description")}),(0,e.jsx)("textarea",{value:U.description,onChange:R=>x("description",R.target.value),rows:3,className:st(ue,"py-2 leading-5 resize-none")})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:te,children:o("ì¹´ë©ë¼ìí¬","ã«ã¡ã©ã¯ã¼ã¯","Camera Work")}),(0,e.jsx)("input",{value:U.cameraWork,onChange:R=>x("cameraWork",R.target.value),className:ue})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:te,children:o("ë´ë ì´ì
","ãã¬ã¼ã·ã§ã³","Narration")}),(0,e.jsx)("input",{value:U.narration,onChange:R=>x("narration",R.target.value),className:ue})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:te,children:o("ëì¬","ã»ãªã","Dialogue")}),(0,e.jsx)("input",{value:U.dialogue,onChange:R=>x("dialogue",R.target.value),placeholder:o("ìì","ãªã","None"),className:ue})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:te,children:"BGM / SFX"}),(0,e.jsx)("input",{value:U.bgm,onChange:R=>x("bgm",R.target.value),className:ue})]})]})]})}return(0,e.jsxs)("div",{...n===0?Ve(je.shortsAgentStoryboardCut):{},className:st("group overflow-hidden rounded-xl md:rounded-2xl border transition-colors",Ee,N,l&&"cursor-pointer hover:border-brand/55"),onClick:l?B:void 0,children:[(0,e.jsxs)("div",{className:st("flex items-center justify-between border-b px-3 md:px-4 py-2 md:py-2.5",se),children:[(0,e.jsxs)("span",{className:st("font-geo text-[10px] md:text-[10.5px] font-bold uppercase tracking-[0.16em]",F),children:["Cut ",t.cutNumber]}),(0,e.jsxs)("div",{className:"flex items-center gap-1.5 md:gap-2",children:[l&&(0,e.jsx)(fo,{className:"h-3 w-3 text-muted-foreground md:opacity-0 md:transition-opacity md:group-hover:opacity-100","aria-hidden":!0}),(0,e.jsx)("span",{className:"rounded-full bg-white/[0.08] px-2 md:px-2.5 py-0.5 font-geo text-[10px] md:text-[11px] font-semibold text-foreground/80",children:t.timeRange})]})]}),(0,e.jsxs)("div",{className:"space-y-2 md:space-y-2.5 px-3 md:px-4 py-2.5 md:py-3",children:[t.description&&(0,e.jsx)("p",{className:"text-[12px] md:text-[13px] leading-5 text-foreground",children:t.description}),(0,e.jsxs)("div",{className:"space-y-1 md:space-y-1.5 pt-0.5",children:[t.cameraWork&&(0,e.jsxs)("div",{className:"flex items-start gap-2",children:[(0,e.jsx)("small",{className:_,children:o("ì¹´ë©ë¼","ã«ã¡ã©","Camera")}),(0,e.jsx)("span",{className:"text-[11px] md:text-[12px] leading-5 text-muted-foreground",children:t.cameraWork})]}),H&&(0,e.jsxs)("div",{className:"flex items-start gap-2",children:[(0,e.jsx)("small",{className:_,children:o("ë´ë ì´ì
","ãã¬","VO")}),(0,e.jsxs)("span",{className:"text-[11px] md:text-[12px] leading-5 text-foreground/85 italic",children:['"',t.narration,'"']})]}),ee&&(0,e.jsxs)("div",{className:"flex items-start gap-2",children:[(0,e.jsx)("small",{className:_,children:o("ëì¬","ã»ãªã","Line")}),(0,e.jsxs)("span",{className:"text-[11px] md:text-[12px] leading-5 text-foreground/85 italic",children:['"',t.dialogue,'"']})]}),t.bgm&&(0,e.jsxs)("div",{className:"flex items-start gap-2",children:[(0,e.jsx)("small",{className:_,children:o("ì리","ãµã¦ã³ã","Sound")}),(0,e.jsx)("span",{className:"text-[11px] md:text-[12px] leading-5 text-muted-foreground",children:t.bgm})]})]})]})]})},Hi=({draft:t,language:r,videoDuration:n=15,editable:l=!1,onCutSave:p,onCutEditingChange:h})=>{const o=ta(r);return(0,e.jsxs)("div",{...Ve(je.shortsAgentStoryboard),className:"mka-card mt-4 md:mt-5 mb-2 !rounded-2xl md:!rounded-[22px]",children:[(0,e.jsxs)("div",{className:"border-b border-border px-3 md:px-5 py-3 md:py-4",children:[(0,e.jsx)("p",{className:"rn-eyebrow is-y !text-[10px] md:!text-[10.5px]",children:o("ì¤í 리보ë","ã¹ãã¼ãªã¼ãã¼ã","Storyboard")}),(0,e.jsx)("h4",{className:"mt-1.5 truncate font-title text-[16px] md:text-[19px] font-black leading-tight text-foreground",children:t.title})]}),(0,e.jsxs)("div",{className:"space-y-3 md:space-y-4 p-3 md:p-5",children:[t.conceptSummary?.trim()&&(0,e.jsxs)("div",{className:"mka-box px-3 md:px-4 py-2.5 md:py-3",children:[(0,e.jsx)("p",{className:"mka-lab mb-1 md:mb-1.5",children:o("컨ì
","ã³ã³ã»ãã","Concept")}),(0,e.jsx)("p",{className:"text-[12px] md:text-[13px] leading-5 text-foreground
97/85",children:t.conceptSummary})]}),t.cuts&&t.cuts.length>0&&(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsx)("p",{className:"mka-lab",children:o(`${n}ì´ ì¤í 리보ë`,`${n}ç§ã¹ãã¼ãªã¼ãã¼ã`,`${n}s Storyboard`)}),(0,e.jsx)("div",{className:"space-y-2",children:t.cuts.map((S,v)=>(0,e.jsx)(Vi,{cut:S,language:r,index:v,editable:l,onSave:U=>p?.(S.cutNumber,U),onEditingChange:h},S.cutNumber))})]}),!t.cuts?.length&&t.storyboard?.trim()&&(0,e.jsxs)("div",{className:"mka-box px-4 py-3",children:[(0,e.jsx)("p",{className:"mka-lab mb-1.5",children:o(`${n}ì´ ì¤í 리보ë`,`${n}ç§ã¹ãã¼ãªã¼ãã¼ã`,`${n}s Storyboard`)}),(0,e.jsx)("p",{className:"whitespace-pre-wrap text-[13px] leading-5 text-foreground/85",children:t.storyboard})]}),(t.narration?.trim()||t.dialogue?.trim()||t.directorNote?.trim())&&(0,e.jsxs)("div",{className:"grid gap-2 sm:grid-cols-2",children:[t.narration?.trim()&&(0,e.jsxs)("div",{className:"mka-box px-3 md:px-4 py-2.5 md:py-3",children:[(0,e.jsx)("p",{className:"mka-lab mb-1 md:mb-1.5",children:o("ë´ë ì´ì
","ãã¬ã¼ã·ã§ã³","Narration")}),(0,e.jsxs)("p",{className:"text-[11px] md:text-[12px] leading-5 text-foreground/85 italic",children:['"',t.narration,'"']})]}),t.dialogue?.trim()&&(0,e.jsxs)("div",{className:"mka-box px-3 md:px-4 py-2.5 md:py-3",children:[(0,e.jsx)("p",{className:"mka-lab mb-1 md:mb-1.5",children:o("ë°°ì° ëì¬","俳åªã»ãªã","Actor Dialogue")}),(0,e.jsxs)("p",{className:"text-[11px] md:text-[12px] leading-5 text-foreground/85 italic",children:['"',t.dialogue,'"']})]})]})]})]})},zi=(t,r)=>t==="hero"?r==="ko"?{title:"ëí ì´ë¯¸ì§ ìì± ì¤",description:"í
í릿 ì´ë¯¸ì§ì ì í ì´ë¯¸ì§ë¥¼ ë¬¶ì´ ëí ì»·ì ë§ë¤ê³ ììµëë¤."}:r==="ja"?{title:"ãã¼ãã¼ç»åãçæä¸",description:"ãã³ãã¬ã¼ãã¨è£½åç»åãçµã¿åããã¦ãã¼ãã¼ãã¬ã¼ã ã使ãã¦ãã¾ãã"}:{title:"Creating Hero Image",description:"Combining the template and product images into a representative hero frame."}:t==="mood_select"?r==="ko"?{title:"ë¶ì기/컨ì
ì í",description:"ëí ì´ë¯¸ì§ê° ìì±ëììµëë¤. ì´ë¤ ë¶ì기ì ì¼ì¸ 를 ë§ë¤ì§ ì íí´ ì£¼ì¸ì."}:r==="ja"?{title:"ã ã¼ã/ã³ã³ã»ãã鏿",description:"ãã¼ãã¼ç»åã宿ãã¾ãããã©ããªé°å²æ°ã®ã·ã§ã¼ããä½ããé¸ãã§ãã ããã"}:{title:"Select Mood & Concept",description:"The hero image is ready. Choose what mood and concept for the ì¼ì¸ ."}:t==="drafting"?r==="ko"?{title:"ì¤í 리보ë 구ì ì¤",description:"ì íí ë¶ì기를 ë°íì¼ë¡ ì¼ì¸ ì´
97ìì ì¡ê³ ììµëë¤."}:r==="ja"?{title:"ã¹ãã¼ãªã¼ãã¼ãæ§æ³ä¸",description:"鏿ããã ã¼ãããã¨ã«ã·ã§ã¼ãã®èæ¡ã使ãã¦ãã¾ãã"}:{title:"Drafting Storyboard",description:"Building a 15-second ì¼ì¸ concept based on the selected mood."}:t==="generating"?r==="ko"?{title:"ìì ìì± ì¤",description:"íì ë ì¤í 리보ë를 기ë°ì¼ë¡ ììì ìì±íê³ ììµëë¤."}:r==="ja"?{title:"åç»ãçæä¸",description:"確å®ããã¹ãã¼ãªã¼ãã¼ãããã¨ã«åç»ãçæãã¦ãã¾ãã"}:{title:"Generating Video",description:"The approved storyboard is being used to generate your video."}:t==="result"?r==="ko"?{title:"ìµì¢
ìì ìë£",description:"ìì±ë ììì ë°ë¡ íì¸í ì ììµëë¤."}:r==="ja"?{title:"æçµåç»å®äº",description:"宿ããåç»ããã確èªã§ãã¾ãã"}:{title:"Video Ready",description:"Your final video is ready to preview."}:t==="error"?r==="ko"?{title:"ì¤ë¹ ì¤ ë¬¸ì ê° ìê²¼ìµëë¤",description:"ìë ë©ìì§ë¥¼ íì¸í ë¤ ë¤ì ìëí´ ì£¼ì¸ì."}:r==="ja"?{title:"æºåä¸ã«åé¡ãçºçãã¾ãã",description:"ä¸ã®ã¡ãã»ã¼ã¸ã確èªãã¦ããããä¸åº¦ã試ããã ããã"}:{title:"Something Went Wrong",description:"Check the message below and try again."}:r==="ko"?{title:"ì¤í 리보ë íì ì¤",description:"ìì´ì í¸ì ëííë©´ì ì¼ì¸ ì¤í 리보ë를 ë¤ë¬ê³ ììµëë¤."}:r==="ja"?{title:"ã¹ãã¼ãªã¼ãã¼ãåè°ä¸",description:"ã¨ã¼ã¸ã§ã³ãã¨ä¼è©±ããªããã·ã§ã¼ãã¹ãã¼ãªã¼ãã¼ããç·´ã£ã¦ãã¾ãã"}:{title:"Refining Storyboard",description:"Refining the ì¼ì¸ storyboard with the agent through chat."},qi=({language:t,aspectRatio:r="9:16"})=>{const n=ta(t),[l,p]=(0,s.useState)(0);(0,s.useEffect)(()=>{const D=Date.now(),I=setInterval(()=>p(Math.floor((Date.now()-D)/1e3)),500);return()=>clearInterval(I)},[]);const h=l<25?Math.min(75,Math.round(l/25*75)):Math.min(99,75+Math.round((l-25)/60*24)),o=l>60,S=l>90,v=125.66,U=v*(1-h/100);return(0,e.jsxs)("div",{className:"mka-card w-full md:max-w-[240px]",children:[(0,e.jsxs)("div",{className:"relative w-full overflow-hidden bg-zinc-900 md:aspect-[var(--hero-ar)]",style:{"--hero-ar":String(r).replace(":"," / ")},children:[(0,e.jsx)("div",{className:"absolute inset-0 -translate-x-full animate-[shimmer_1.6s_infinite] bg-gradient-to-r from-transparent via-white/[0.06] to-transparent"}),(0,e.jsxs)("div",{className:"flex items-center gap-3 px-4 py-4 md:absolute md:inset-0 md:flex-col md:justify-center md:p-0",children:[(0,e.jsxs)("div",{className:"relative flex h-12 w-12 md:h-16 md:w-16 shrink-0 items-center justify-center",children:[(0,e.jsxs)("svg",{className:"absolute inset-0 -rotate-90",viewBox:"0 0 48 48",children:[(0,e.jsx)("circle",{cx:"24",cy:"24",r:"20",fill:"none",style:{stroke:"rgb(var(--c-white) / 0.1)"},strokeWidth:"3"}),(0,e.jsx)("circle",{cx:"24",cy:"24",r:"20",fill:"none",stroke:"#FFE600",strokeWidth:"3",strokeLinecap:"round",strokeDasharray:v,strokeDashoffset:U,style:{transition:"stroke-dashoffset 0.5s ease-out"}})]}),(0,e.jsxs)("span",{className:"font-geo text-[12px] md:text-[13px] font-bold tabular-nums text-foreground",children:[h,"%"]})]}),(0,e.jsxs)("div",{className:"min-w-0 flex-1 space-y-1 text-left md:flex-none md:space-y-3 md:text-center",children:[(0,e.jsx)("p",{className:"text-[13px] font-semibold text-foreground",children:n("ëí ì´ë¯¸ì§ ìì± ì¤...","ãã¼ãã¼ç»åãçæä¸...","Generating hero image...")}),(0,e.jsx)("p",{className:"text-[11px] text-muted-foreground",children:S?n(`${l}ì´ ê²½ê³¼ â íìë³´ë¤ ë§ì´ ê±¸ë¦¬ê³ ìì´ì. ì¡°ê¸ë§ ë 기ë¤ë ¤ 주ì¸ì.`,`${l}ç§çµé â é常ããæéãããã£ã¦ãã¾ããããå°ããå¾
ã¡ãã ããã`,`${l}s elapsed â taking longer than usual. Hang in there.`):o?n(`${l}ì´ ê²½ê³¼ â ì¡°ê¸ ë 걸리ë ì¤...`,`${l}ç§çµé â ããå°ãããã£ã¦ãã¾ã...`,`${l}s elapsed â taking a bit longer...`):n("í
í릿 + ì í ì´ë¯¸ì§ë¥¼ í©ì±íê³ ììµëë¤","ãã³ãã¬ã¼ãã¨è£½åç»åãåæãã¦ãã¾ã","Compositing template and product images")})]})]})]}),(0,e.jsxs)("div",{className:"space-y-2 px-4 py-3",children:[(0,e.jsx)("div",{className:"mka-track h-1.5 w-full",children:(0,e.jsx)("div",{className:"mka-fill",style:{width:`${h}%`}})}),(0,e.jsxs)("div",{className:"flex items-center justify-between text-[10.5px] text-muted-foreground",children:[(0,e.jsx)("span",{children:h<100?n("ì§í ì¤","é²è¡ä¸","In progress"):n("ìë£","å®äº","Done")}),(0,e.jsxs)("span",{className:"font-geo tabular-nums",children:[l,"s"]}
97)]})]})]})},en=t=>t&&t.replace(/\s*\(?\d{1,3}\s*%\)?\s*$/,"").trim()||null,Bi=({progress:t,message:r,language:n,onCancel:l})=>{const p=ta(n),h=Math.min(Math.max(t,0),99),o=2*Math.PI*20,S=o-h/100*o;return(0,e.jsxs)("div",{className:"mka-card w-full !rounded-xl md:!rounded-2xl",children:[(0,e.jsxs)("div",{className:"flex items-center gap-3 md:gap-4 px-3 md:px-5 py-3 md:py-4",children:[(0,e.jsxs)("div",{className:"relative flex h-12 w-12 md:h-14 md:w-14 shrink-0 items-center justify-center",children:[(0,e.jsxs)("svg",{className:"absolute inset-0 -rotate-90",viewBox:"0 0 48 48",children:[(0,e.jsx)("circle",{cx:"24",cy:"24",r:"20",fill:"none",style:{stroke:"rgb(var(--c-white) / 0.1)"},strokeWidth:"3"}),(0,e.jsx)("circle",{cx:"24",cy:"24",r:"20",fill:"none",stroke:"#FFE600",strokeWidth:"3",strokeLinecap:"round",strokeDasharray:o,strokeDashoffset:S,className:"transition-all duration-700"})]}),(0,e.jsxs)("span",{className:"font-geo text-xs font-bold text-foreground",children:[h,"%"]})]}),(0,e.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,e.jsx)("p",{className:"mb-1 text-[10.5px] font-bold uppercase tracking-[0.16em] text-brand-ink",children:p("ìì ìì± ì¤","åç»ãçæä¸","Generating Video")}),(0,e.jsx)("p",{className:"truncate text-sm text-foreground/85",children:r}),(0,e.jsx)("p",{className:"mt-0.5 text-[11px] text-muted-foreground",children:p("ë³´íµ 1~2ë¶ì´ë©´ ìì±ë©ëë¤","é常1ã2åã§å®æãã¾ã","Usually done in 1-2 minutes")})]}),l&&(0,e.jsx)("button",{type:"button",onClick:l,className:"rn-btn rn-btn-g is-sm shrink-0",children:p("ì·¨ì","ãã£ã³ã»ã«","Cancel")})]}),(0,e.jsx)("div",{className:"h-1 w-full bg-white/[0.06]",children:(0,e.jsx)("div",{className:"h-full bg-brand transition-all duration-700",style:{width:`${h}%`}})})]})},Ki=async(t,r)=>{try{const n=await(await fetch(t)).blob(),l=URL.createObjectURL(n),p=document.createElement("a");p.href=l,p.download=r,document.body.appendChild(p),p.click(),document.body.removeChild(p),URL.revokeObjectURL(l)}catch{window.open(t,"_blank","noopener,noreferrer")}},Wi=({videoUrl:t,language:r,userId:n,sourceTaskId:l,onReviseVideo:p,onGenerateOnceMore:h,onSetShowcaseShare:o,onDone:S})=>{const v=ta(r),U=()=>Ki(t,`ad-video-${Date.now()}.mp4`),[D,I]=s.useState(!1),[f,H]=s.useState(!1);s.useEffect(()=>{H(!1)},[t]);const ee=s.useCallback(async()=>{if(!t||D)return;const Ee=!f;I(!0),H(Ee);try{await o?.(t,Ee)}catch{H(!Ee)}finally{I(!1)}},[t,f,D,o]);return(0,e.jsxs)("div",{...Ve(je.shortsAgentResult),className:"mka-card w-full",children:[(0,e.jsx)("div",{className:"relative aspect-video w-full overflow-hidden bg-black",children:(0,e.jsx)("video",{src:t,controls:!0,autoPlay:!0,loop:!0,muted:!0,playsInline:!0,className:"h-full w-full object-contain"})}),(0,e.jsxs)("div",{className:"px-4 py-3 space-y-3",children:[(0,e.jsx)("p",{className:"text-xs font-bold text-brand-ink",children:v("ììì´ ìì±ëììµëë¤","åç»ã宿ãã¾ãã","Video is ready")}),(0,e.jsxs)("div",{className:"flex flex-wrap gap-2",children:[p&&(0,e.jsx)("button",{type:"button",...Ve(je.shortsAgentEditStoryboard),onClick:p,className:"rn-btn rn-btn-g is-sm",children:v("ìì ìì ","åç»ãä¿®æ£","Revise video")}),h&&(0,e.jsx)("button",{type:"button",onClick:h,title:v("ê°ì ì´ë¯¸ì§Â·ê°ì í롬íí¸ë¡ ììë§ í ë² ë ìì±í©ëë¤. ì´ì ê²°ê³¼ë ìì ê·¸ëë¡ ë¨ìì.","åãç»åã»åãããã³ããã§åç»ã ãããä¸åº¦çæãã¾ãã以åã®çµæã¯ä¸ã«ãã®ã¾ã¾æ®ãã¾ãã","Generate one more video from the same image and prompt. Previous results stay above."),className:"rn-btn rn-btn-g is-sm",children:v("í ë² ë ìì±","ããä¸åº¦çæ","Generate one more")}),o&&(0,e.jsx)("button",{type:"button",onClick:ee,disabled:D,title:v("ì¸í루ì¸ì ê°¤ë¬ë¦¬ì ê³µì íë©´ 5í¬ë ë§ì ëë ¤ì. ê³µì í ììì í
í릿 ì¹´ëìì ì¬ìë©ëë¤.","ã¤ã³ãã«ã¨ã³ãµã¼ã®ã£ã©ãªã¼ã«å
±æããã¨5ã¯ã¬ã¸ããä»ä¸ãå
±æããåç»ã¯ãã³ãã¬ã¼ãã«ã¼ãã§åçããã¾ãã","Share to the influencer gallery and get 5 credits. Shared videos play on the template card."),className:st("rn-btn is-sm",f?"rn-btn-o":"rn-btn-y"),children:D?v("ì²ë¦¬ ì¤...","å¦çä¸...","Working..."):f?v("ê³µì ë¨ Â· ê³µì ì·¨ì","å
±ææ¸ã¿ · åãæ¶ã","Shared · Undo"):v("ê³µì íê³ 5í¬ë ë§ ë°ê¸°","å
±æãã¦5ã¯ã¬ã¸ãã","Share & get 5 credits")}),(0,e.jsx)("button",{type:"button",onClick:U,className:"rn-btn rn-btn-g is-sm",children:v("ë¤ì´ë¡ë","ãã¦ã³ãã¼ã","Download")}),S&&(0,e.jsx)("button",{type:"button",onClick:S,className:"rn-btn rn-btn-g is-sm",children:v("ìë£","å®äº","Done")})]})]})]})},Ji=({onSetShowcaseShare:t,open:r,visible:n,onClose:l,onEndSession:p,onStateChange:h,onGenerateStart:o,session:S,language:v,pollingHistory:U,generationTasks:D,createRepresentativeImage:I,uploadImages:f,startSeedanceGeneration:H,userId:ee,onTaskComplete:Ee,onSessionCompleted:N,videoCreditCost480p:F,videoCreditCost720p:se=75.6,videoCreditCost1080p:_=187.2,videoCreditCost4k:B=388.8,onCheckCredit:ie,demoFixture:K})=>{const x=ta(v),te=S?.sessionId?`shorts-agent-input:${S.sessionId}
97`:null,[ue,R]=(0,s.useState)(()=>{if(!te)return"";try{return localStorage.getItem(te)||""}catch{return""}}),[$,O]=(0,s.useState)(!1),[G,Oe]=(0,s.useState)(""),[fe,_e]=(0,s.useState)(""),[Ne,P]=(0,s.useState)(""),[Ce,Re]=(0,s.useState)(!1),[We,Ie]=(0,s.useState)(!1),[q,V]=(0,s.useState)(!1),[X,ge]=(0,s.useState)(!1),[Qe,ht]=(0,s.useState)(null),[$t,ft]=(0,s.useState)(null),[W,Le]=(0,s.useState)(null),[kt,De]=(0,s.useState)(!1),yt=(0,s.useRef)("720p"),[rt,A]=(0,s.useState)(!1),[ye,Ze]=(0,s.useState)(!1);(0,s.useEffect)(()=>{if(te)try{ue?localStorage.setItem(te,ue):localStorage.removeItem(te)}catch{}},[ue,te]);const Lt=(0,s.useRef)(null),ut=(0,s.useRef)(null),at=(0,s.useCallback)(()=>{const y=ut.current;return y&&y.scrollHeight>y.clientHeight+1?y:qt.current??y},[]),qt=(0,s.useRef)(null),{phase:re,messages:Me,draft:ce,heroImageUrl:gt,finalVideoUrl:Ae,error:bt,isThinking:Ue,isAnalyzing:Nt,streamingPhase:Mt,streamingCutNumber:wt,selectedMood:nr,canSendMessage:Bt,canGenerateVideo:Je,canSelectMood:me,canRegenerateHero:Fe,nextMessageCost:Qt,moodPresets:vr,brandPronunciation:et,brandPronunciationSkipped:xt,activeTaskProgress:kr,activeTaskStatus:mt,activeTaskMessage:gr,sendMessage:Ye,selectMood:_t,updateBrandPronunciation:wr,confirmBrandPronunciation:Vr,markBrandPronunciationSkipped:_r,generateVideo:Ct,regenerateVideo:Ir,editStoryboard:Ft,askVideoRevision:ua,videoRevisionAsked:Gt,isAnswering:ma,generateRequest:or,clearGenerateRequest:Ar,updateCut:it,regenerateHero:ir,restartConcept:Vt,cancelGeneration:Kt,jumpToResultForTutorial:pt,showProgressForTutorial:Pt,rewindToDiscussionForTutorial:Zt}=Li({open:r,session:S,language:v,pollingHistory:U,generationTasks:D,createRepresentativeImage:I,uploadImages:f,startSeedanceGeneration:H,onTaskComplete:Ee,onSessionCompleted:N,demoFixture:K,userId:ee}),Sr=(0,s.useMemo)(()=>Me.reduce((y,j,M)=>j.role==="agent"?M:y,-1),[Me]),lr=(0,s.useMemo)(()=>Me.reduce((y,j,M)=>j.videoUrl?M:y,-1),[Me]),It=(0,s.useMemo)(()=>{const y=Me[Me.length-1];return y?.role==="agent"&&y.storyboardFollowUp?y:null},[Me]),[pa,Ut]=(0,s.useState)(0),cr=(0,s.useCallback)(y=>{Ut(j=>Math.max(0,j+y))},[]),vt=pa>0,Rr=(0,s.useRef)(Me.length),dr=(0,s.useCallback)(y=>{const j=at();j&&(typeof j.scrollTo=="function"?j.scrollTo({top:j.scrollHeight,behavior:y?"smooth":"auto"}):j.scrollTop=j.scrollHeight)},[at]);(0,s.useEffect)(()=>{const y=Me.length>Rr.current;if(Rr.current=Me.length,vt)return;if(y){dr(!Mt);return}const j=at();j&&j.scrollHeight-j.scrollTop-j.clientHeight<200&&dr(!1)},[Me,ce,Ae,Ue,Nt,Mt,wt,bt,vt,dr]),(0,s.useEffect)(()=>{const y=ut.current?.firstElementChild;if(!y||typeof ResizeObserver>"u")return;const j=new ResizeObserver(()=>{if(vt)return;const M=at();M&&M.scrollHeight-M.scrollTop-M.clientHeight<200&&dr(!1)});return j.observe(y),()=>j.disconnect()},[vt,r,re,dr,at]);const ur=(0,s.useMemo)(()=>zi(re,v),[v,re]);(0,s.useEffect)(()=>{!r||!S||!h||h({phase:re,title:ur.title,description:ur.description,draftTitle:ce?.title,heroImageUrl:gt,finalVideoUrl:Ae,error:bt,isThinking:Ue,canGenerateVideo:Je})},[Je,ce?.title,bt,Ae,gt,Ue,h,r,re,ur.description,ur.title,S]),(0,s.useEffect)(()=>{const y=qt.current;if(!y)return;const j=Array.from(y.querySelectorAll("video, audio"));n?j.forEach(M=>{if(M.loop)try{M.muted=!0,M.play().catch(()=>{})}catch{}}):j.forEach(M=>{try{M.pause()}catch{}})},[n,Ae,Me.length]);const Hr=(0,s.useCallback)(y=>{Ue||!me||ht(y)},[me,Ue]),Wt=(0,s.useCallback)(()=>{const y=Qe;!y||Ue||!me||(ht(null),_t(y))},[me,Ue,Qe,_t]);if(fn((0,s.useCallback)(()=>{r&&l()},[r,l])),hn((0,s.useCallback)(y=>{if(ja()){if(y.includes(je.shortsAgentMoodConfirm)||ht(null),y.includes(je.shortsAgentGenerateConfirm)||(ft(null),Le(null),A(!1),Ze(!1)),[je.shortsAgentStoryboard,je.shortsAgentStoryboardCut,je.shortsAgentChat,je.shortsAgentNewConcept,je.shortsAgentGenerate,je.shortsAgentGenerateConfirm].some(j=>y.includes(j))){Zt();return}if(y.includes(je.shortsAgentProgress)&&re==="result"){Pt();return}y.includes(je.shortsAgentResult)&&pt()}},[re,Zt,pt,Pt])),(0,s.useEffect)(()=>{!or||re!=="discussion"||!Je||(Le(or.quality),Ar())},[or,re,Je,Ar]),!r||!S)return null;const i=async y=>{const j=(y??ue).trim();if(j){if(!y&&re==="mood_select"&>){ft(j);return}R(""),await Ye(j)}},m=y=>y==="4k"?B:y==="1080p"?_:y==="480p"?F??se:se,g=async(y="720p")=>{Je&&(ie&&!await ie(m(y))||(yt.current=y,o?.(),await Ct(y)))},b=async y=>{ie&&!await ie(m(y))||(yt.current=y,o?.(),await Ir(y))},C=W==="4k"?B:W==="1080p"?_:W==="480p"?F:se,T=$t||W||rt||ye,E=()=>{ft(null),Le(null),De(!1),A(!1),Ze(!1)},z=()=>{if($t){const y=$t;E(),R(""),Ye(y);return}if(W){const y=W,j=kt;E(),j?b(y):g(y);return}if(rt){E(),ir();return}ye&&(E(),Vt())};return(0,e.jsxs)("div",{ref:qt,"aria-hidden":!n,className:st("mka-scrim fixed inset-0 z-[70] flex items-start md:items-center justify-center md:p-6 transition-opacity duration-200 max-md:overflow-y-auto",n?"opacity-100":"pointer-events-none opacity-0"),children:[(0,e.jsxs)("div",{className:"mka-shell relative flex flex-col md:flex-row max-md:h-auto max-md:min-h-full md:h-[88vh] w-full max-w-[1440px] md:overflow-hidden md:rounded-[28px]",children:[(0,e.jsx)("div",{className:"max-md:sticky max-md:top-0 max-md:h-0 max-md:overflow-visible max-md:z-20 md:absolute md:right-4 md:top-4 md:z-10",children:(0,e.jsxs)("div",{className:"absolute right-3 top-3 md:static flex items-center gap-1.5",children:[(0,e.jsx)("button",{type:"button",onClick:l,title:x("ìµìí","æå°å","Minim
97ize"),"aria-label":x("ìì´ì í¸ ìµìí","ã¨ã¼ã¸ã§ã³ããæå°å","Minimize agent"),className:"mka-x",children:(0,e.jsx)(ho,{"aria-hidden":!0})}),p&&(0,e.jsx)("button",{type:"button",onClick:()=>V(!0),title:x("ì¸ì
ì¢
ë£","ã»ãã·ã§ã³çµäº","End Session"),"aria-label":x("ì¸ì
ì¢
ë£","ã»ãã·ã§ã³çµäº","End session"),className:"mka-x",children:(0,e.jsx)(Zr,{"aria-hidden":!0})})]})}),(0,e.jsxs)("div",{className:"mka-side flex w-full md:w-[34%] md:min-w-[320px] shrink-0 md:shrink flex-col max-md:overflow-visible md:overflow-y-auto border-b md:border-b-0 md:border-r",children:[(0,e.jsxs)("div",{className:"px-4 md:px-6 pt-3 md:pt-6 pb-3 md:pb-5 pr-24 md:pr-6",children:[(0,e.jsx)("p",{className:"rn-eyebrow is-y max-md:!text-[10px] max-md:!tracking-[0.16em]",children:(0,e.jsx)("span",{className:"truncate",children:x("ì¼ì¸ ìì´ì í¸","ã·ã§ã¼ãã¨ã¼ã¸ã§ã³ã","Shorts Agent")})}),(0,e.jsx)("h2",{className:"mka-title",children:ur.title}),(0,e.jsx)("p",{className:"mka-desc line-clamp-2 md:line-clamp-none",children:ur.description})]}),(0,e.jsx)("div",{className:"px-4 md:px-6",children:(0,e.jsxs)("div",{className:"mka-card !rounded-2xl",children:[(0,e.jsx)("div",{className:"flex justify-center p-2.5 md:p-3",children:(0,e.jsxs)("div",{...Ve(je.shortsAgentHero),className:"relative aspect-[9/16] w-full max-w-[180px] md:max-w-[240px] overflow-hidden rounded-xl bg-zinc-900",children:[Ae?(0,e.jsx)("video",{src:Ae,controls:!0,autoPlay:!0,loop:!0,muted:!0,playsInline:!0,className:"h-full w-full object-cover"}):gt?(0,e.jsx)("img",{src:gt,alt:S.preset.name,className:"h-full w-full object-cover"}):S.preset.previewImage?(0,e.jsx)("img",{src:S.preset.previewImage,alt:S.preset.name,className:"h-full w-full object-cover opacity-80"}):(0,e.jsx)("div",{className:"h-full w-full",style:{background:S.preset.previewGradient}}),!Ae&&re==="hero"&&!gt&&(0,e.jsxs)("div",{className:"absolute inset-0 flex flex-col items-center justify-center bg-black/50 backdrop-blur-sm",children:[(0,e.jsx)("span",{className:"mka-spin",style:{"--sz":"28px"}}),(0,e.jsx)("p",{className:"mt-4 text-sm font-semibold text-[#fff]",children:x("ëí ì´ë¯¸ì§ ì¤ë¹ ì¤","ãã¼ãã¼ç»åãæºåä¸","Preparing hero image")})]}),!Ae&&Nt&&!!gt&&(0,e.jsxs)("div",{className:"absolute bottom-3 left-3 flex items-center gap-1.5 rounded-full bg-black/60 px-3 py-1.5 text-xs font-semibold text-[#fff] backdrop-blur-sm",children:[(0,e.jsx)("span",{className:"mka-spin",style:{"--sz":"12px"}}),x("ì´ë¯¸ì§ ë¶ì ì¤","ç»åãåæä¸","Analyzing image")]}),Fe&&!Ae&&re==="mood_select"&&(0,e.jsx)("button",{type:"button",onClick:()=>A(!0),className:"rn-glass absolute bottom-3 right-3 inline-flex h-8 items-center rounded-full px-3.5 text-xs font-bold transition-colors hover:bg-black/75",children:x("ì´ë¯¸ì§ ì¬ìì±","åçæ","Regenerate")}),re==="generating"&&(0,e.jsxs)("div",{className:"absolute inset-0 flex flex-col items-center justify-center bg-black/65 backdrop-blur-sm",children:[(0,e.jsxs)("div",{className:"relative flex h-24 w-24 items-center justify-center",children:[(0,e.jsxs)("svg",{className:"-rotate-90",width:"96",height:"96",viewBox:"0 0 96 96",children:[(0,e.jsx)("circle",{cx:"48",cy:"48",r:"42",fill:"none",stroke:"rgba(255,255,255,0.14)",strokeWidth:"5"}),(0,e.jsx)("circle",{cx:"48",cy:"48",r:"42",fill:"none",stroke:"#FFE600",strokeWidth:"5",strokeLinecap:"round",strokeDasharray:2*Math.PI*42,strokeDashoffset:2*Math.PI*42-(kr??0)/100*2*Math.PI*42,className:"transition-all duration-500"})]}),(0,e.jsxs)("span",{className:"absolute font-geo text-2xl font-bold text-[#fff]",children:[kr!=null?Math.min(kr,99):0,(0,e.jsx)("span",{className:"text-sm text-[#fff]/70",children:"%"})]})]}),(0,e.jsx)("p",{className:"mt-4 text-sm font-semibold text-[#fff]",children:en(gr)||x("ìì ìì± ì¤","åç»ãçæä¸","Generating video")}),(0,e.jsx)("p",{className:"mt-1 text-xs text-[#fff]/70",children:x("ë³´íµ 1~2ë¶ì´ë©´ ìì±ë©ëë¤","é常1ã2åã§å®æãã¾ã","Usually done in 1-2 minutes")})]})]})}),(0,e.jsxs)("div",{className:"hidden md:block space-y-3.5 p-4",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("p",{className:"mka-lab",children:x("í
í릿","ãã³ãã¬ã¼ã","Template")}),(0,e.jsx)("div",{className:"mt-1 text-sm font-bold text-foreground",children:S.preset.name}),S.preset.description&&(0,e.jsx)("p",{className:"mt-0.5 text-xs leading-5 text-muted-foreground",children:S.preset.description})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("p",{className:"mka-lab",children:x("ì í í¹ì¥ì ","製åã®ç¹é·","Product Highlights")}),(0,e.jsx)("p",{className:"mt-1 whitespace-pre-wrap text-sm leading-6 text-foreground
97/85",children:S.highlights.trim()||x("ì¶ê° ì
ë ¥ ìì","追å å
¥åãªã","No extra highlights provided")})]})]})]})}),(0,e.jsx)("div",{className:"mt-2 md:mt-5 px-4 md:px-6 pb-3 md:pb-6",children:(0,e.jsxs)("div",{...Ve(je.shortsAgentPhasePanel),className:"mka-box !rounded-xl md:!rounded-2xl p-2.5 md:p-4",children:[(0,e.jsx)("p",{className:"mka-lab",children:x("íì¬ ì§í","ç¾å¨ã®é²æ","Current Progress")}),(0,e.jsx)("div",{className:"mka-track mt-2 md:mt-3 h-1.5",children:(0,e.jsx)("div",{className:st("mka-fill",re==="hero"&&"w-[18%]",re==="mood_select"&&"w-[33%]",re==="drafting"&&"w-[50%]",re==="discussion"&&"w-[72%]",re==="generating"&&"w-[88%]",re==="result"&&"w-full",re==="error"&&"w-[58%]",re==="idle"&&"w-0")})})]})})]}),(0,e.jsxs)("div",{className:"mka-main flex min-h-0 max-md:shrink-0 min-w-0 flex-1 flex-col",children:[(0,e.jsxs)("div",{...Ve(je.shortsAgentPanelHeader),className:"border-b border-border px-4 md:px-6 py-2.5 md:py-5 md:pr-28",children:[(0,e.jsx)("p",{className:"rn-eyebrow max-md:!text-[10px] max-md:!tracking-[0.16em]",children:x("ì¤í 리보ë íì","ã¹ãã¼ãªã¼ãã¼ãåè°","Storyboard Discussion")}),(0,e.jsx)("p",{className:"hidden md:block mt-2 text-[13.5px] leading-6 text-muted-foreground",children:re==="mood_select"?x("ìë ë¶ì기/컨ì
ì¤ íë를 ì ííë©´, ìì´ì í¸ê° í´ë¹ ë¶ìê¸°ë¡ ì¼ì¸ ì¤í 리보ë를 구ì±í©ëë¤.","以ä¸ã®ã ã¼ã/ã³ã³ã»ããããä¸ã¤é¸ã¶ã¨ãã¨ã¼ã¸ã§ã³ãããã®ã ã¼ãã§ã·ã§ã¼ãã¹ãã¼ãªã¼ãã¼ããæ§æãã¾ãã","Select a mood/concept below, and the agent will craft a ì¼ì¸ storyboard in that style."):x("ëì¬, ë´ë ì´ì
, ì ê°, ìë© CTAê¹ì§ ìì°ì¤ë½ê² ìì ìì²íë©´ ìì´ì í¸ê° ì¼ì¸ ì´ìì ë°ë¡ ë°ìí©ëë¤.","ã»ãªãããã¬ã¼ã·ã§ã³ãå±éãã¨ã³ãã£ã³ã°CTAã¾ã§èªç¶ã«ä¿®æ£ä¾é ¼ããã¨ã¨ã¼ã¸ã§ã³ããã·ã§ã¼ãèæ¡ã«ããåæ ãã¾ãã","Ask for changes to the dialogue, narration, pacing, or CTA, and the agent will update the ì¼ì¸ draft.")})]}),(0,e.jsx)("div",{ref:ut,className:"min-h-0 max-md:shrink-0 flex-1 max-md:overflow-visible md:overflow-y-auto px-4 md:px-6 py-3 md:py-5",children:(0,e.jsxs)("div",{className:"space-y-3",children:[Me.map((y,j)=>y.storyboardFollowUp?null:(0,e.jsxs)(s.Fragment,{children:[y.content?.trim()&&y.role==="agent"&&(0,e.jsx)(Hs,{text:y.content,language:v,typewriter:j===Sr}),y.content?.trim()&&y.role==="user"&&(0,e.jsx)(ci,{children:y.content}),y.content?.trim()&&y.role==="system"&&(0,e.jsx)("div",{className:"mka-msg is-sys w-fit max-w-[90%]",children:(0,e.jsx)("p",{className:"whitespace-pre-wrap",children:y.content})}),y.imageUrl&&(0,e.jsx)("div",{className:"mka-card w-fit max-w-full",children:(0,e.jsx)("img",{src:y.imageUrl,alt:x("ëí ì´ë¯¸ì§","ãã¼ãã¼ç»å","Hero image"),className:"block max-h-[clamp(280px,48vh,460px)] w-auto max-w-full object-contain"})}),y.videoUrl&&(0,e.jsx)(Wi,{videoUrl:y.videoUrl,language:v,userId:ee,sourceTaskId:y.sourceTaskId,onReviseVideo:re==="result"&&j===lr?()=>ja()?Ft():ua():void 0,onDone:re==="result"?()=>p?V(!0):l():void 0,onSetShowcaseShare:re==="result"?t:void 0,onGenerateOnceMore:re==="result"&&j===lr&&ce?.finalPrompt?()=>{De(!0),Le(yt.current)}:void 0}),y.role==="agent"&&y.moodPresets&&y.moodPresets.length>0&&me&&et&&et.koreanReading&&(0,e.jsx)("div",{className:"mka-box px-3 py-2.5",children:$?(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)("span",{className:"mka-lab",children:x("ë´ë ì´ì
ë°ì","ãã¬ã¼ã·ã§ã³çºé³","Narration reading")}),et.displayName&&(0,e.jsxs)("span",{className:"text-xs text-muted-foreground",children:[(0,e.jsx)("span",{className:"font-geo",children:et.displayName}),(0,e.jsx)("span",{className:"mx-1.5",children:"â"})]}),(0,e.jsx)("input",{type:"text",value:G,onChange:M=>Oe(M.target.value),onKeyDown:M=>{if(M.key==="Enter")M.preventDefault(),G.trim()&&(wr(G),O(!1));else if(M.key==="Escape"){if(G.trim()&&G.trim()!==et?.koreanReading?.trim()&&!window.confirm(x("ë³ê²½ ì¬íì ì ì¥íì§ ìê³ ë«ìê¹ì?","夿´å
容ãä¿åããã«éãã¾ããï¼","Discard unsaved changes?")))return;O(!1)}},placeholder:x("ì: ì¨ë§ì§ ìíììì¤","ä¾: ãµã¼ãã¸FLX","e.g. Thermage FLX"),autoFocus:!0,className:"mka-ta !py-1.5 !text-sm w-full sm:flex-1 sm:min-w-[160px] sm:w-auto"}),(0,e.jsx)("button",{type:"button",onClick:()=>{G.trim()&&(wr(G),O(!1))},disabled:!G.trim(),className:"rn-btn rn-btn-y is-xs",children:x("íì ","確å®","Save")}),(0,e.jsx)("button",{type:"button",onClick:()=>O(!1),className:"rn-btn rn-btn-g is-xs",children:x("ì·¨ì","ãã£ã³ã»ã«","Cancel")})]}):(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)("span",{className:"mka-lab",children:x("ë´ë ì´ì
ë°ì","ãã¬ã¼ã·ã§ã³çºé³","Narration reading")}),et.displayName&&(0,e.jsxs)("span",{className:"text-xs text-muted-foreground",children:[(0,e.jsx)("span",{className:"font-geo",children:et.displayName}),(0,e.jsx)("span",{className:"mx-1.5",children:"â"})]}),(0,e.jsx)("span",{className:"rounded-lg bg-brand/[0.14] px-2.5 py-0.5 text-sm font-bold text-brand-ink",children:et.koreanReading}),(0,e.jsx)("button",{type:"button",onClick:()=>{Oe(et.koreanReading),O(!0)},className:"rn-btn rn-btn-g is-xs ml-auto",children:x("ìì ","ä¿®æ£","Edit")}),et.alternatives&&et.alternatives.length>0&&(0,e.jsxs)("div",{className:"mt-1.5 flex w-full flex-wrap items-center gap-1.5",children:[(0,e.jsx)("span",{className:"text-[10.5px] text-muted-foreground",children:x("ë¤ë¥¸ ë°ì:","ä»ã®çºé³:","Alternatives:")}),et.alternatives.map(M=>(0,e.jsx)("button",{type:"button",onClick:()=>wr(M),className:"rn-btn rn-btn-g is-xs",children:M},M))]}),et.confidence==="low"&&(0,e.jsx)("p",{className:"mka-warn mt-1 w-full px-2.5 py-1.5 text-[11px] font-semibold",children:x("ë°ìì´ ë¶íì¤í´ì. íì¸í´ 주ì¸ì.","çºé³ãä¸ç¢ºãã§ãã確èªãã¦ãã ããã","Pronunciation uncertain â please confirm.")})]})}),y.role==="agent"&&y.moodPresets&&y.moodPresets.length>0&&me&&(0,e.jsxs)("div",{...Ve(je.shortsAgentMoodGrid),className:"ac-chips",children:[(0,e.jsx)("small",{children:x("ë¶ì기 ê³ ë¥´ê¸°","é°å²æ°ãé¸ã¶","Pick a mood")}),y.moodPresets.map(M=>(0,e.jsx)("button",{type:"button",onClick:()=>
97Hr(M),disabled:Ue,title:M.description,className:st(Ue&&"cursor-not-allowed opacity-50"),children:M.label},M.id))]})]},y.id)),ce&&(0,e.jsx)(Hi,{draft:ce,language:v,videoDuration:S.videoDuration||15,editable:re==="discussion",onCutSave:it,onCutEditingChange:cr}),ce&&It&&(0,e.jsx)(Hs,{text:It.content,language:v,typewriter:Me.length-1===Sr}),re==="hero"&&!gt&&(0,e.jsx)(qi,{language:v,aspectRatio:S?.aspectRatio}),re==="generating"&&(0,e.jsx)("div",{...Ve(je.shortsAgentProgress),children:(0,e.jsx)(Bi,{progress:kr??5,message:en(gr)||x("ììì ì ìíê³ ììµëë¤...","åç»ãå¶ä½ãã¦ãã¾ã...","Generating your video..."),language:v,onCancel:()=>Ie(!0)})}),Nt&&re!=="generating"&&(0,e.jsxs)("div",{className:"grid w-full gap-1.5",children:[(0,e.jsx)(Vs,{language:v}),(0,e.jsxs)("div",{className:"mka-box w-full px-4 py-3",children:[(0,e.jsxs)("div",{className:"mb-2.5 flex items-center gap-2 text-[10.5px] font-bold uppercase tracking-[0.16em] text-brand-ink",children:[(0,e.jsx)("span",{className:"inline-block h-1.5 w-1.5 animate-pulse rounded-full bg-brand"}),x("AI ì´ë¯¸ì§ ë¶ì ì¤","AIãç»åãåæä¸","AI Analyzing Image")]}),(0,e.jsxs)("div",{className:"flex items-center gap-2.5",children:[(0,e.jsx)("span",{className:"mka-spin",style:{"--sz":"14px"}}),(0,e.jsx)("span",{className:"text-sm text-foreground/85",children:x("ì´ì¸ë¦¬ë ë¶ì기ì ë¸ëë ë°ìì ì¶ì¶íê³ ììµëë¤...","åãé°å²æ°ã¨ãã©ã³ãã®èªã¿æ¹ãæ½åºãã¦ãã¾ã...","Extracting fitting moods & brand pronunciation...")})]})]})]}),Ue&&!Nt&&re!=="hero"&&re!=="generating"&&(()=>{const y={start:{label:"ì¤í 리보ë ë¶ì ì¤...",labelJa:"ã¹ãã¼ãªã¼ãã¼ããåæä¸...",labelEn:"Analyzing storyboard..."},concept:{label:"ì¼ì¸ 컨ì
êµ¬ì± ì¤...",labelJa:"ã·ã§ã¼ãã³ã³ã»ãããæ§æä¸...",labelEn:"Building shorts concept..."},cuts_start:{label:"ì»· ì¤í 리보ë ìì± ìì...",labelJa:"ã«ããã¹ãã¼ãªã¼ãã¼ãã®ä½æéå§...",labelEn:"Starting cut storyboard..."},cut:{label:`Cut ${wt} ìì± ì¤...`,labelJa:`ã«ãã ${wt} ã使ä¸...`,labelEn:`Writing Cut ${wt}...`},narration:{label:"ë´ë ì´ì
& ëë í° ë
¸í¸ ìì± ì¤...",labelJa:"ãã¬ã¼ã·ã§ã³ï¼ãã£ã¬ã¯ã¿ã¼ãã¼ãã使ä¸...",labelEn:"Writing narration & director note..."},final:{label:"ìµì¢
ìì í롬íí¸ ìì± ì¤...",labelJa:"æçµåç»ããã³ãããä»ä¸ãä¸...",labelEn:"Finalizing video prompt..."}},j=y[Mt]??y.start,M=v==="ko"?j.label:v==="ja"?j.labelJa:j.labelEn,Q=Mt==="cut"||Mt==="cuts_start";return(0,e.jsxs)("div",{className:"grid w-full gap-1.5",children:[(0,e.jsx)(Vs,{language:v}),(0,e.jsxs)("div",{className:"mka-box w-full px-4 py-3",children:[(0,e.jsxs)("div",{className:"mb-2.5 flex items-center gap-2 text-[10.5px] font-bold uppercase tracking-[0.16em] text-brand-ink",children:[(0,e.jsx)("span",{className:"inline-block h-1.5 w-1.5 animate-pulse rounded-full bg-brand"}),x("AI ì¤í 리보ë ìì± ì¤","AIãã¹ãã¼ãªã¼ãã¼ãã使ä¸","AI Writing Storyboard")]}),(0,e.jsxs)("div",{className:"flex items-center gap-2.5",children:[(0,e.jsx)(li,{state:Fi[Mt]??"composing",size:20,className:"flex h-5 w-5 shrink-0 items-center justify-center"}),(0,e.jsx)("span",{className:"text-sm text-foreground/85",children:M})]}),Q&&wt>0&&(0,e.jsxs)("div",{className:"mt-2.5 flex items-center gap-1.5",children:[Array.from({length:Math.max(wt,6)}).map((ke,ae)=>(0,e.jsx)("div",{className:st("h-1 flex-1 rounded-full transition-all duration-300",ae<wt?"bg-brand":"bg-white/10")},ae)),(0,e.jsx)("span",{className:"ml-1 font-geo text-[10.5px] font-bold text-brand-ink",children:wt})]})]})]})})(),ce&&!Ue&&re!=="generating"&&re!=="result"&&(0,e.jsx)(e.Fragment,{children:(Je||!Ue&&ce)&&(0,e.jsx)("div",{className:"flex flex-col gap-3",children:(0,e.jsxs)("div",{className:"flex flex-col gap-2 lg:flex-row lg:flex-nowrap lg:items-center lg:justify-end",children:[(0,e.jsx)("button",{type:"button",onClick:()=>Ze(!0),disabled:Ue,...Ve(je.shortsAgentNewConcept),className:"rn-btn rn-btn-g w-full lg:w-auto
97shrink-0",children:x("ë¤ë¥¸ 컨ì
ì ì","å¥ã®ã³ã³ã»ããææ¡","New Concept")}),re==="discussion"&&(()=>{const y=Je?"":v==="ko"?et?.koreanReading?.trim()||xt?"ì ì í ë¤ì ìëí´ ì£¼ì¸ì":'ë¸ëë ë°ìì ì
ë ¥íê±°ë "ê±´ëë°ê¸°"를 ì ííë©´ íì±íë©ëë¤':v==="ja"?et?.koreanReading?.trim()||xt?"ãã°ãããã¦ããããä¸åº¦ã試ããã ãã":"ãã©ã³ãçºé³ãå
¥åããããã¹ããããã鏿ããã¨æå¹åããã¾ã":et?.koreanReading?.trim()||xt?"Please wait a moment":"Enter brand pronunciation or skip to enable";return(0,e.jsx)("div",{className:"flex flex-col gap-2",children:(0,e.jsx)("div",{className:"flex flex-col gap-2 sm:flex-row sm:flex-wrap lg:flex-nowrap",children:(()=>{const j=wn(S?.seedanceEngine??"2.0",S?.videoDuration??15),M=!j.includes("1080p"),Q={"480p":F,"720p":se,"1080p":_},ke=j.map(ae=>({res:ae,onClick:()=>Le(ae),cost:Q[ae],primary:ae==="720p"}));return(0,e.jsxs)(e.Fragment,{children:[M&&(0,e.jsx)("span",{className:"self-center whitespace-nowrap text-[11px] text-muted-foreground",children:x("30ì´ ììì 720pë¡ ì ê³µë©ëë¤","30ç§åç»ã¯720pã®ã¿å¯¾å¿ã§ã","30-second videos are available in 720p")}),ke.map(ae=>(0,e.jsxs)("button",{type:"button",onClick:ae.onClick,disabled:!Je,title:y,...ae.res==="720p"?Ve(je.shortsAgentGenerate):ae.res==="1080p"?Ve(je.shortsAgentGenerateAlt):{},className:st("rn-btn",ae.primary?"rn-btn-y":"rn-btn-o"),children:[x(`${ae.res} ìì±`,`${ae.res} çæ`,`Generate ${ae.res}`),(0,e.jsx)(fr,{value:ae.cost??"â",variant:ae.primary?"ink":"soft"})]},ae.res))]})})()})})})()]})})}),ma&&(0,e.jsx)(di,{language:v,label:x("ëµë³ì ì°ë ì¤...","åçã使ä¸...","Writing a reply...")}),(0,e.jsx)("div",{ref:Lt})]})}),(0,e.jsx)("div",{className:"mka-in px-3 md:px-6 py-3 md:py-4",children:(0,e.jsxs)("div",{...Ve(je.shortsAgentChat),children:[(0,e.jsx)("textarea",{value:ue,onChange:y=>R(y.target.value),onKeyDown:y=>{y.key==="Enter"&&!y.shiftKey&&(y.preventDefault(),i())},placeholder:Bt?re==="generating"||re==="hero"||re==="drafting"||Ue?x("ë§ëë ì¤ìë ê¶ê¸í ê±´ í¸íê² ë¬¼ì´ë³´ì¸ì ð","使ä¸ã§ãæ°ã«ãªããã¨ã¯æ°è»½ã«èãã¦ãã ããã ð","Ask me anything while I work ð"):Gt?x("ì: ë§ì§ë§ ì»·ì ì í í´ë¡ì¦ì
ì¼ë¡ ë°ê¿ì¤ / ëì¬ë¥¼ ë ì§§ê² í´ì¤","ä¾: æå¾ã®ã«ãããååã®ã¯ãã¼ãºã¢ããã« / ã»ãªãããã£ã¨çã","Example: End on a product close-up / Shorten the dialogue"):re==="mood_select"?x("ì: ë°ë»í ë´ ëëì¼ë¡ í´ì¤ / ì´ë¯¸ì§ë¥¼ ë ë°ê² í´ì¤","ä¾: æããæ¥ã®é°å²æ°ã§ / ç»åããã£ã¨æãããã¦","Example: Make it feel like warm spring / Make the image brighter"):x("ì: ëì¬ë¥¼ ë ì§§ê² í´ì¤ / ìì ì 컨ì
ì¼ë¡ ë¤ì ì§ì¤","ä¾: ã»ãªãããã£ã¨çãã㦠/ å®å
¨ã«æ°ããã³ã³ã»ããã§ä½ãç´ãã¦","Example: Shorten the dialogue / Rebuild with a completely new concept"):x("ìì´ì í¸ê° ëµíë ì¤ì´ìì. ì ìë§ ê¸°ë¤ë ¤ 주ì¸ìâ¦","ã¨ã¼ã¸ã§ã³ããåçä¸ã§ããå°ã
ãå¾
ã¡ãã ããâ¦","The agent is answering. One momentâ¦"),className:"mka-ta h-16 md:h-24",disabled:!Bt}),(0,e.jsxs)("div",{className:"mt-2.5 md:mt-3 flex items-center justify-between gap-2 md:gap-3",children:[(0,e.jsx)("div",{className:"hidden md:block text-xs text-muted-foreground",children:re==="mood_select"?x("ë¶ì기를 ì ííê±°ë, ìíë ë¶ì기를 ì§ì ì
ë ¥í ì ììµëë¤.","ã ã¼ãããªã»ãããé¸ã¶ãã叿ã®ã ã¼ããç´æ¥å
¥åã§ãã¾ãã","Select a mood preset, or describe your own mood."):x("ë¶ë¶ ìì ë, ìì í ìë¡ì´ 컨ì
ì¼ë¡ ë¤ì ì§ë¬ë¼ë ìì²ë ìì ë¡ê² ë³´ë¼ ì ììµëë¤.","é¨åä¿®æ£ããå®å
¨ã«æ°ããã³ã³ã»ããã§ä½ãç´ãä¾é ¼ãèªç±ã«éããã¨ãã§ãã¾ãã","Request partial tweaks, or ask to rebuild the whole concept from scratch.")}),(0,e.jsxs)("button",{type:"button",onClick:()=>{i()},disabled:!Bt||!ue.trim(),className:"rn-btn rn-btn-y ml-auto shrink-0",children:[x("ë³´ë´ê¸°","éã","Send"),Qt>0&&(0,e.jsx)(fr,{value:Qt,variant:"ink"})]})]})]})})]})]}),T&&(0,Ia.createPortal)((0,e.jsx)("div",{className:"mka-scrim fixed inset-0 z-[80] flex items-center justify-center px-4",onClick:()=>{Ue||E()},children:(0,e.jsxs)("div",{className:"mka-dlg max-w-[560px]",onClick:y=>y.stopPropagation(),children:[(0,e.jsx)("p",{className:"rn-eyebrow is-y",children:x("ìì ì íì¸","éå§åã®ç¢ºèª","Confirm start")}),(0,e.jsx)("h3",{children:W?kt?x("ê°ì ì¤ì ì¼ë¡ í ë² ë ë§ë¤ê¹ì?","åãè¨å®ã§ããä¸åº¦ä½ãã¾ããï¼","Generate one more with the same settings?"):x("ìì ìì±ì ììí ê¹ì?","åç»çæãéå§ãã¾ããï¼","Start video generation?"):rt?x("ì´ë¯¸ì§ë¥¼ ì¬ìì±í ê¹ì?","ç»åãåçæãã¾ããï¼","Regenerate the image?"):ye?x("ì 컨ì
ìì±ì ììí ê¹ì?","æ°ããã³ã³ã»ããçæãéå§ãã¾ããï¼","Start a new concept?"):x("ì
ë ¥í ë´ì©ì¼ë¡ ì§íí ê¹ì?","å
¥åå
容ã§é²è¡ãã¾ããï¼","Continue with this input?")}),(0,e.jsx)("p",{children:W?kt?x("ê°ì ëí ì´ë¯¸ì§ì ê°ì í롬íí¸ë¡ ììë§ ë¤ì ë§ëëë¤. ì¤í 리보ëë ê·¸ëë¡ì´ê³ , ì´ì ê²°ê³¼ë ìì ê·¸ëë¡ ë¨ìì. í¬ë ë§ì ìë¡ ì°¨ê°ë©ëë¤.","åãã¡ã¤ã³ãã¸ã¥ã¢ã«ã¨åãããã³ããã§åç»ã ãä½ãç´ãã¾ããã¹ãã¼ãªã¼ãã¼ãã¯ãã®ã¾ã¾ã§ã以åã®çµæãä¸ã«æ®ãã¾ããã¯ã¬ã¸ããã¯æ°ãã«æ¶è²»ããã¾ãã","Generates another video from the same hero image and prompt. The storyboard stays as-is and previous results remain above. Credits are charged again."):x("íì ë ì¤í 리보ëë¡ ì¼ì¸ ìì ìì±ì ììíë©´ AI ìì
ì´ ë°ë¡ ì§íë©ëë¤. ìì íìë ì¤ê° ì¤ì§ë ë¹ì© ì·¨ìê° ì´ë ¤ì¸ ì ìì´ì.","確å®ããã¹ãã¼ãªã¼ãã¼ãã§ã·ã§ã¼ãåç»çæãéå§ããã¨ãAIå¦çãããã«é²è¡ãã¾ããéå§å¾ã¯éä¸åæ¢ãè²»ç¨ã®åãæ¶ããé£ããå ´åãããã¾ãã","Once Shorts video generation starts from the approved storyboard, the AI job begins right away. After it starts, stopping midway or cancelling the cost may not be possible."):rt?x("íì¬ ëí ì´ë¯¸ì§ë¥¼ ìë¡ ë§ë¤ë©° AI ìì
ì´ ë°ë¡ ì§íë©ëë¤. ìì íìë ì¤ê° ì¤ì§ë ë¹ì© ì·¨ìê° ì´ë ¤ì¸ ì ìì´ì.","ç¾å¨ã®ã¡ã¤ã³ãã¸ã¥ã¢ã«ãä½ãç´ããAIå¦çãããã«é²è¡ãã¾ããéå§å¾ã¯éä¸åæ¢ãè²»ç¨ã®åãæ¶ããé£ããå ´åãããã¾ãã","This will recreate the current hero image and start the AI job right away. After it starts, stopping midway or cancelling the cost may not be possible."):ye?x("ì ì¼ì¸ 컨ì
ì´ìì ë¤ì ë§ë¤ë©° AI ìì
ì´ ë°ë¡ ì§íë©ëë¤. ìì íìë ì¤ê° ì¤ì§ë ë¹ì© ì·¨ìê° ì´ë ¤ì¸ ì ìì´ì.","æ°ããã·ã§ã¼ãåç»ã³ã³ã»ããæ¡ãä½ãç´ããAIå¦çãããã«é²è¡ãã¾ããéå§å¾ã¯éä¸åæ¢ãè²»ç¨ã®åãæ¶ããé£ããå ´åãããã¾ãã","This will create a new Shorts concept draft and start the AI job right away. After it starts, stopping midway or cancelling the cost may not be possible."):x("ì´ ë´ì©ì ë³´ë´ë©´ ëí ì´ë¯¸ì§ ìì ëë ì¼ì¸ ì¤í 리보ë ìì±ì´ ë°ë¡ ì§íë ì ììµëë¤. ìì íìë ì¤ê° ì¤ì§ë ë¹ì© ì·¨ìê° ì´ë ¤ì¸ ì ìì´ì.","ãã®å
容ãéä¿¡ããã¨ãã¡ã¤ã³ãã¸ã¥ã¢ã«ã®ä¿®æ£ã¾ãã¯ã·ã§ã¼ãåç»ã®ã¹ãã¼ãªã¼ãã¼ãçæãããã«é²è¡ããå ´åãããã¾ããéå§å¾ã¯éä¸åæ¢ãè²»ç¨ã®åãæ¶ããé£ããå ´åãããã¾ãã","Sending this may immediately start hero image revision or Shorts storyboard generation. After it starts, stopping midway or cancelling the cost may not be possible.")}),(0,e.jsxs)("div",{className:"mka-box mt-5 p-4",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-x-3 gap-y-1",children:[(0,e.jsx)("span",{className:"text-[15px] font-bold text-foreground",children:W?x(`${W.toUpperCase()}
97 ìì ìì±`,`${W.toUpperCase()} åç»çæ`,`${W.toUpperCase()} video generation`):rt?x("ëí ì´ë¯¸ì§ ì¬ìì±","ã¡ã¤ã³ãã¸ã¥ã¢ã«åçæ","Hero image regeneration"):ye?x("ë¤ë¥¸ 컨ì ì ì","å¥ã³ã³ã»ããææ¡","New concept"):x("ì§ì ì ë ¥í ìì²","ç´æ¥å ¥åãããªã¯ã¨ã¹ã","Custom request")}),W&&(0,e.jsx)("span",{className:"text-[12.5px] font-medium text-muted-foreground",children:x("ë³´íµ 1~2ë¶ì´ë©´ ìì±ë©ëë¤","é常1ã2åã§å®æãã¾ã","Usually done in 1-2 minutes")})]}),W&&(0,e.jsx)("p",{className:"mka-warn mt-3 whitespace-pre-line p-3 text-[12.5px] font-semibold leading-5",children:x(`AI ìì±ì ì문·ì«ìÂ·ê³ ì ëª ì¬ë¥¼ ì´ìíê² ë°ìí ì ììµëë¤. í´ì¸ 모ë¸ì íê³ë¼ íë¶ ì¬ì ê° ìëëë¤. 98ì´ ê²½ì° ìì± íë©´ì âí ë² ë ìì±âì¼ë¡ ë¤ì ë§ëìê±°ë, ìì±ë§ ë°ë¡ ë°ì í´ë¹ ë¶ë¶ì êµì²´í´ ì¬ì©íìë©´ ë©ëë¤.`,`AIé³å£°ã¯è±æ°åã»åºæåè©ãä¸èªç¶ã«çºé³ãããã¨ãããã¾ããæµ·å¤ã¢ãã«ã®éçã®ããè¿é対象å¤ã§ãã 99ãã®å ´åã¯å®æç»é¢ã®ãããä¸åº¦çæãã§ä½ãç´ãããé³å£°ã®ã¿åå¾ãã¦è©²å½é¨åãå·®ãæ¿ãã¦ãå©ç¨ãã ããã`,'AI voice may mispronounce English words, numbers or proper nouns. This is a limitation of the overseas model and is not grounds for a refund â use "Generate one more" on the result screen, or download the voice track and swap that part.')}),!W&&(0,e.jsx)("p",{className:"mt-2 text-sm leading-6 text-foreground/85",children:$t||x("ìì± ìì ì´ ììë©ëë¤.","çæå¦çãéå§ããã¾ãã","The generation job will start.")})]}),(0,e.jsxs)("div",{className:"mka-dlg-f",children:[(0,e.jsx)("button",{type:"button",disabled:Ue,onClick:E,className:"rn-btn rn-btn-g",children:x("ìëì¤","ããã","No")}),(0,e.jsxs)("button",{type:"button",disabled:Ue,onClick:z,...Ve(je.shortsAgentGenerateConfirm),className:"rn-btn rn-btn-y",children:[x("ëìíê³ ìì","åæãã¦éå§","Agree and start"),(W||rt)&&(0,e.jsx)(fr,{value:W?C:Gi,variant:"ink"})]})]})]})}),document.body),Qe&&(0,Ia.createPortal)((0,e.jsx)("div",{className:"mka-scrim fixed inset-0 z-[80] flex items-center justify-center px-4",onClick:()=>{Ue||ht(null)},children:(0,e.jsxs)("div",{className:"mka-dlg max-w-md",onClick:y=>y.stopPropagation(),children:[(0,e.jsx)("p",{className:"rn-eyebrow is-y",children:x("ìì ì íì¸","éå§åã®ç¢ºèª","Confirm start")}),(0,e.jsx)("h3",{children:x("ì¼ì¸ ì¤í 리보ë ìì±ì ììí ê¹ì?","ã·ã§ã¼ãåç»ã®ã¹ãã¼ãªã¼ãã¼ãçæãéå§ãã¾ããï¼","Start Shorts storyboard generation?")}),(0,e.jsx)("p",{children:x("ì´ ë¶ìê¸°ë¡ ì¼ì¸ ì¤í 리보ë ìì±ì ììíë©´ AI ìì ì´ ë°ë¡ ì§íë©ëë¤. ìì íìë ì¤ê° ì¤ì§ë ë¹ì© ì·¨ìê° ì´ë ¤ì¸ ì ìì´ì.","ãã®é°å²æ°ã§ã·ã§ã¼ãåç»ã®ã¹ãã¼ãªã¼ãã¼ã使ãéå§ããã¨ãAIå¦çãããã«é²è¡ãã¾ããéå§å¾ã¯éä¸åæ¢ãè²»ç¨ã®åãæ¶ããé£ããå ´åãããã¾ãã","Once Shorts storyboard drafting starts with this mood, the AI job begins right away. After it starts, stopping midway or cancelling the cost may not be possible.")}),(0,e.jsxs)("div",{className:"mka-box mt-4 p-3",children:[(0,e.jsx)("p",{className:"text-sm font-bold text-foreground",children:Qe.label}),(0,e.jsx)("p",{className:"mt-1 text-xs leading-5 text-muted-foreground",children:Qe.description})]}),(0,e.jsxs)("div",{className:"mka-dlg-f",children:[(0,e.jsx)("button",{type:"button",disabled:Ue,onClick:()=>ht(null),className:"rn-btn rn-btn-g",children:x("ìëì¤","ããã","No")}),(0,e.jsx)("button",{type:"button",disabled:Ue||!me,onClick:Wt,...Ve(je.shortsAgentMoodConfirm),className:"rn-btn rn-btn-y",children:x("ë¤, ìì","ã¯ããéå§","Yes, start")})]})]})}),document.body),q&&(0,Ia.createPortal)((0,e.jsx)("div",{className:"mka-scrim fixed inset-0 z-[85] flex items-center justify-center px-4",onClick:()=>V(!1),children:(0,e.jsxs)("div",{className:"mka-dlg max-w-[520px]",onClick:y=>y.stopPropagation(),children:[(0,e.jsx)("p",{className:"rn-eyebrow is-y",children:x("ë«ê¸° ì íì¸","éããåã®ç¢ºèª","Confirm close")}),(0,e.jsx)("h3",{children:x("ì¸ì ì ì¢ ë£í ê¹ì?","ã»ãã·ã§ã³ãçµäºãã¾ããï¼","End the session?")}),(0,e.jsx)("p",{children:re==="generating"?x(`ìì ìì±ì´ ì§í ì¤ì ëë¤. ì¢ ë£íë©´ ì´ ì°½ììë ë ì´ì ì§íì ì¶ì í ì ìê³ , ì¤í 리보ëì ëí 기ë¡ì´ ìì ë©ëë¤. 100ì´ë¯¸ ììë ììì ìë²ìì ê³ì ë§ë¤ì´ì ¸ ìì±ëë©´ ë³´ê´í¨ì ì ì¥ë©ëë¤.`,`åç»çæãé²è¡ä¸ã§ããçµäºããã¨ãã®ã¦ã£ã³ãã¦ã§ã¯é²è¡ã追跡ã§ããªããªããã¹ãã¼ãªã¼ãã¼ãã¨ä¼è©±å
100±¥æ´ãåé¤ããã¾ãã 101ãã§ã«å§ã¾ã£ãåç»ã¯ãµã¼ãã¼ã§çæãç¶ãã宿ããã¨ã©ã¤ãã©ãªã«ä¿åããã¾ãã`,`A video is being generated. Ending stops this window from tracking it, and deletes the storyboard and chat history. 102The video already started keeps rendering on the server and lands in your library when done.`):re==="hero"||re==="drafting"||Ue?x(`ì§í ì¤ì¸ ìì ì´ ììµëë¤. ì¢ ë£íë©´ ê·¸ 결과를 ë°ì ì ìê³ , ì¤í 리보ëì ëí 기ë¡ì´ ìì ë©ëë¤. 103ëë릴 ì ìì¼ë ì ì ì ì´ëë ¤ë©´ ìµìí를 ëë¬ ì£¼ì¸ì.`,`é²è¡ä¸ã®ä½æ¥ãããã¾ããçµäºããã¨ãã®çµæãåãåãããã¹ãã¼ãªã¼ãã¼ãã¨ä¼è©±å±¥æ´ãåé¤ããã¾ãã 104å ã«æ»ããªãããã䏿çã«é ãã ããªãæå°åãæ¼ãã¦ãã ããã`,`A task is still running. Ending discards its result and deletes the storyboard and chat history. 105This cannot be undone â use Minimize if you just want it out of the way.`):re==="result"?x(`ìì±ë ììì ë³´ê´í¨ì ì ì¥ëì´ ìì´ ì¸ì ë ë¤ì ë³¼ ì ììµëë¤. 106ì¢ ë£íë©´ ì´ ì¸ì ì ì¤í 리보ëì ëí 기ë¡ë§ ìì ë©ëë¤.`,`宿ããåç»ã¯ã©ã¤ãã©ãªã«ä¿åããã¦ããããã¤ã§ãè¦ããã¾ãã 107çµäºããã¨ãã®ã»ãã·ã§ã³ã®ã¹ãã¼ãªã¼ãã¼ãã¨ä¼è©±å±¥æ´ã®ã¿åé¤ããã¾ãã`,`Your finished video is saved in the library and stays available. 108Ending only deletes this session's storyboard and chat history.`):x(`ì¢ ë£íë©´ ì´ ì¸ì ì ì¤í 리보ëì ëí 기ë¡ì´ ìì ëê³ ë¤ì ì´ ì ììµëë¤. 109ì ì ì ì´ëë ¤ë©´ ìµìí를 ëë¬ ì£¼ì¸ì.`,`çµäºããã¨ãã®ã»ãã·ã§ã³ã®ã¹ãã¼ãªã¼ãã¼ãã¨ä¼è©±å±¥æ´ãåé¤ãããå度éãã¾ããã 110䏿çã«é ãã ããªãæå°åãæ¼ãã¦ãã ããã`,`Ending deletes this session's storyboard and chat history for good. 111Use Minimize if you just want it out of the way.`)}),(0,e.jsxs)("div",{className:"mka-dlg-f",children:[(0,e.jsx)("button",{type:"button",onClick:()=>V(!1),className:"rn-btn rn-btn-g",children:x("ìëì¤","ããã","No")}),(0,e.jsx)("button",{type:"button",onClick:()=>{V(!1),p?.()},className:"rn-btn rn-btn-danger",children:x("ì¸ì ì¢ ë£","ã»ãã·ã§ã³çµäº","End session")})]})]})}),document.body),We&&(0,e.jsx)("div",{className:"mka-scrim fixed inset-0 z-[80] flex items-center justify-center px-4",onClick:()=>{X||Ie(!1)},children:(0,e.jsxs)("div",{className:"mka-dlg max-w-[440px]",onClick:y=>y.stopPropagation(),children:[(0,e.jsx)("h3",{className:"!mt-0",children:x("ì ë§ ì·¨ìíìê² ìµëê¹?","æ¬å½ã«ãã£ã³ã»ã«ãã¾ããï¼","Cancel generation?")}),(0,e.jsx)("p",{children:x("ìì ìì±ì ì¤ë¨í©ëë¤. íë¶ì ì§íëì§ ìì¼ë©°, ë¦ê² ëì°©í 결과물ë ì ì¥ëì§ ììµëë¤.","åç»çæã䏿ãã¾ããè¿éã¯è¡ããããé ãã¦å±ããçµæç©ãä¿åããã¾ããã","Stop video generation now. No refund will be issued, and any late-arriving result will be discarded.")}),(0,e.jsxs)("div",{className:"mka-dlg-f",children:[(0,e.jsx)("button",{type:"button",disabled:X,onClick:()=>Ie(!1),className:"rn-btn rn-btn-g",children:x("ìëì¤","ããã","No")}),(0,e.jsx)("button",{type:"button",disabled:X,onClick:async()=>{ge(!0),await Kt(),ge(!1),Ie(!1)},className:"rn-btn rn-btn-danger",children:X?x("ì·¨ì ì¤...","ãã£ã³ã»ã«ä¸...","Cancelling..."):x("ì, ì·¨ì","ã¯ãããã£ã³ã»ã«","Yes, cancel")})]})]})})]})},Xa=({children:t})=>(0,e.jsxs)("div",{className:"flex items-start gap-2.5",children:[(0,e.jsx)("span",{className:"mt-0.5 flex h-7 w-7 shrink-0 items-center justify-center rounded-lg bg-gradient-to-br from-rose-500 to-violet-500",children:(0,e.jsx)(pn,{size:14,className:"text-white"})}),(0,e.jsx)("div",{className:"max-w-[46rem] rounded-2xl rounded-tl-sm border border-white/10 bg-white/[0.05] px-4 py-2.5 text-[13px] leading-relaxed text-zinc-200",children:t})]}),ca=4,ys="shorts_auto_concept_progress_v1",Tn=t=>typeof t=="string"&&/^https?:\/\//i.test(t),Yi=()=>{try{const t=localStorage.getItem(ys);if(!t)return null;const r=JSON.parse(t);return!r?.savedAt||Date.now()-r.savedAt>1440*60*1e3?null:(r.phase==="loading"&&(r.phase="input"),!r.images?.length&&r.uploadedUrls?.length&&(r.images=r.uploadedUrls.filter(Tn).slice(0,ca)),r)}catch{return null}},Xi=t=>{try{localStorage.setItem(ys,JSON.stringify({...t,images:t.images.filter(Tn),savedAt:Date.now()}))}catch{}},Qi=({open:t,onClose:r,uploadImages:n,onStart:l,initialImages:p,initialHighlights:h,inline:o=!1,lockedCasting:S,lockedLocation:v,lockedPresetName:U,seedanceEngine:D="2.0"})=>{const{language:I}=un(),f=(0,s.useCallback)((P,Ce,Re)=>I==="ko"?P:I==="ja"?Ce:Re,[I]),H=(0,s.useRef)(Yi()),[ee,Ee]=(0,s.use
111State)(H.current?.phase||"input"),[N,F]=(0,s.useState)(H.current?.images||[]),[se,_]=(0,s.useState)(H.current?.productName||""),[B,ie]=(0,s.useState)(H.current?.highlights||""),[K,x]=(0,s.useState)(H.current?.concepts||[]),[te,ue]=(0,s.useState)(H.current?.sellingPoints||[]),[R,$]=(0,s.useState)(H.current?.uploadedUrls||[]),O=(0,s.useRef)(null);(0,s.useEffect)(()=>{ee!=="loading"&&Xi({phase:ee,productName:se,images:N,highlights:B,concepts:K,sellingPoints:te,uploadedUrls:R})},[ee,se,N,B,K,te,R]),(0,s.useEffect)(()=>{t&&(p?.length&&F(P=>P.length===0?p.slice(0,ca):P),h?.trim()&&ie(P=>P.trim()?P:h.trim()))},[t,p,h]);const G=(0,s.useCallback)(P=>P.vibe||(I==="ja"?P.labelJa:I==="en"?P.labelEn:P.labelKo),[I]),Oe=(0,s.useCallback)(P=>{if(!P?.length)return;const Ce=ca-N.length;Array.from(P).slice(0,Ce).forEach(Re=>{if(!Re.type.startsWith("image/"))return;const We=new FileReader;We.onload=()=>{typeof We.result=="string"&&F(Ie=>Ie.length<ca?[...Ie,We.result]:Ie)},We.readAsDataURL(Re)})},[N.length]),fe=(0,s.useCallback)(async()=>{if(N.length===0&&!B.trim()&&!se.trim()){xe.error(f("ì
ë ¥ íì","å
¥åãå¿
è¦","Input Required"),{description:f("ì í ì¬ì§ì ì¬ë¦¬ê±°ë ì í ì¤ëª
ì ì
ë ¥í´ ì£¼ì¸ì.","製ååçãã¢ãããã¼ããããã製å説æãå
¥åãã¦ãã ããã","Upload a product photo or enter a product description.")});return}Ee("loading");try{const P=N.length>0?await n(N,null):[];$(P);const{data:Ce,error:Re}=await ve.functions.invoke("shorts-auto-concept",{body:{productImageUrls:P,productName:se.trim(),highlights:B.trim(),language:I,conceptCount:4,lockedCasting:S||void 0,lockedLocation:v||void 0,...Lr(D)}});if(Re)throw new Error(Re.message||"shorts-auto-concept failed");if(!Ce?.success||!Array.isArray(Ce.concepts)||Ce.concepts.length===0)throw new Error(Ce?.error||"No concepts generated");x(Ce.concepts),ue(Array.isArray(Ce.sellingPoints)?Ce.sellingPoints:[]),Ee("concepts")}catch(P){pe.warn("[ShortsAutoConceptModal] concept generation failed:",P),xe.error(f("컨ì
ìì± ì¤í¨","ã³ã³ã»ããçæå¤±æ","Concept Generation Failed"),{description:f("ì ì í ë¤ì ìëí´ ì£¼ì¸ì.","ãã°ãããã¦ããå試è¡ãã¦ãã ããã","Please try again in a moment.")}),Ee("input")}},[N,se,B,I,f,n,S,v,D]),_e=(0,s.useCallback)(()=>{r()},[r]);if(!t)return null;const Ne=(0,e.jsxs)("div",{className:st(o?"w-full rounded-2xl border border-white/10 bg-white/[0.02]":"relative w-full max-w-5xl max-h-[90vh] overflow-y-auto rounded-2xl border border-white/10 bg-zinc-950 shadow-2xl"),children:[(0,e.jsxs)("div",{className:st("flex items-center justify-between px-5 sm:px-7 py-4 border-b border-white/10",!o&&"sticky top-0 z-10 bg-zinc-950/95 backdrop-blur"),children:[(0,e.jsxs)("div",{className:"flex items-center gap-2.5",children:[(0,e.jsx)("span",{className:"flex h-8 w-8 items-center justify-center rounded-lg bg-gradient-to-br from-rose-500 to-violet-500",children:(0,e.jsx)(pn,{size:16,className:"text-white"})}),(0,e.jsxs)("div",{children:[(0,e.jsx)("h2",{className:"text-base sm:text-lg font-black text-white leading-tight",children:f("AI ìë ì¼ì¸ ","AIèªåã·ã§ã¼ã","AI Auto Shorts")}),(0,e.jsx)("p",{className:"text-[11px] text-zinc-500",children:f("ì íë§ ì£¼ë©´ 컨ì
·íí¹Â·CTAê¹ì§ ììì","製åãæ¸¡ãã ãã§ã³ã³ã»ããã»ããã¯ã»CTAã¾ã§èªå","Product in â concept, hook & CTA out")})]})]}),!o&&ee!=="loading"&&(0,e.jsx)("button",{onClick:_e,className:"p-2 rounded-lg text-zinc-500 hover:text-white hover:bg-white/10 transition-colors",children:(0,e.jsx)(Zr,{size:18})})]}),ee==="input"&&(0,e.jsxs)("div",{className:"p-5 sm:p-7 space-y-5",children:[o&&(0,e.jsx)(Xa,{children:f("ìë
íì¸ì. ì í ì¬ì§ë§ ì¬ë ¤ì£¼ìë©´ ì ê° ì»¨ì
·íí¹Â·ëª¨ë¸Â·ì¥ìê¹ì§ ì§ì 10ì´ ì¼ì¸ ë¡ ë§ë¤ì´ ë릴ê²ì.","ããã«ã¡ã¯ãåååçãã¢ãããã¦ããã ããã°ãã³ã³ã»ããã»ããã¯ã»ã¢ãã«ã»ãã±ã¾ã§çµã¿ç«ã¦ã¦10ç§ã·ã§ã¼ãã«ãã¾ãã","Hi â just drop a product photo and I'll work out the concept, hook, cast and location, then build a 10-second short.")}),(0,e.jsxs)("div",{children:[(0,e.jsxs)("p",{className:"text-sm font-bold text-white mb-2",children:[f("ì í ì´ë¦","製åå","Product Name"),(0,e.jsx)("span",{className:"ml-1.5 text-[11px] font-normal text-zinc-500",children:f("ëì¬ì ì´ ì´ë¦ ê·¸ëë¡ ë¤ì´ê°ëë¤","ã»ãªãã«ãã®ååããã®ã¾ã¾å
¥ãã¾ã","used verbatim in the spoken lines")})]}),(0,e.jsx)("input",{value:se,onChange:P=>_(P.target.value),maxLength:80,placeholder:f("ì) ë¹ ëë ìì´ìì´","ä¾ï¼ppabanana AI","e.g. BBANANA AI"),className:"w-full rounded-xl border border-white/10 bg-white/5 px-4 py-3 text-sm text-white placeholder:text-zinc-600 focus:outline-none focus:border-rose-400/50"})]}),(0,e.jsxs)("div",{children:[(0,e.jsxs)("p",{className:"text-sm font-bold text-white mb-2",children:[f("ì í ì¬ì§","製ååç","Product Photos"),(0,e.jsx)("span",{className:"ml-1.5 text-[11px] font-normal text-zinc-500",children:f("ìµë 4ì¥","æå¤§4æ","up to 4")})]}),(0,e.jsxs)("div",{className:"grid grid-cols-4 gap-2",children:[N.map((P,Ce)=>(0,e.jsxs)("div",{className:"relative aspect-square rounded-xl overflow-hidden border border-white/10 bg-white/5 group",children:[(0,e.jsx)("img",{src:P,alt:"",className:"w-full h-full object-cover"}),(0,e.jsx)("button",{onClick:()=>F(Re=>Re.filter((We,Ie)=>Ie!==Ce)),className:"absolute top-1 right-1 p-1 rounded-md bg-black/70 text-white opacity-0 group-hover:opacity-100 transition-opacity",children:(0,e.jsx)(Zr,{size:12})})]},Ce)),N.length<ca&&(0,e.jsxs)("button",{onClick:()=>O.current?.click(),className:"aspect-square rounded-xl border border-white/15 bg-white/5 hover:bg-white/10 hover:border-white/25 transition-colors flex flex-col items-center justify-center gap-1.5 text-zinc-500 hover:text-zinc-300",children:[(0,e.jsx)(vo,{size:20}),(0,e.jsx)("span",{className:"text-[10px] font-medium",children:f("ì¶ê°","追å ","Add")})]})]}),(0,e.jsx)("input",{ref:O,type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:P=>{Oe(P.target.files),P.target.value=""}})]}),(0,e.jsxs)("div",{children:[(0,e.jsxs)("p",{className:"text-sm font-bold text-white mb-2",children:[f("ì í ì¤ëª
","製å説æ","Product Notes"),(0,e.jsx)("span",{className:"ml-1.5 text-[11px] font-normal text-zinc-500",children:f("ì í â ë¸ëëëª
·í¹ì¥ì ·íê¹","ä»»æ â ãã©ã³ãåã»ç¹å¾´ã»ã¿ã¼ã²ãã","optional â brand, features, target")})]}),(0,e.jsx)("textarea",{value:B,onChange:P=>ie(P.target.value),rows:3,maxLength:1e3,placeholder:f("ì) ë¹ê±´ ì ìê·¹ ìë¶ ì¸ë¼, 20-30ë 민ê°ì± í¼ë¶ íê¹","ä¾ï¼ã´ã£ã¼ã¬ã³ä½åºæ¿ã»ã©ã ã20-30代ææèåã","e.g. vegan hydrating serum for sensitive skin, 20-30s"),className:"w-full rounded-xl border border-white/10 bg-white/5 px-4 py-3 text-sm text-white placeholder:text-zinc-600 focus:outline-none focus:border-rose-400/50 resize-none"})]}),(0,e.jsxs)("button",{onClick:fe,className:"w-full flex items-center justify-center gap-2 rounded-xl bg-gradient-to-r from-rose-500 to-violet-500 hover:from-rose-400 hover:to-violet-400 px-5 py-3.5 text-sm font-black text-white transition-all shadow-lg shadow-rose-500/20",children:[f("컨ì
4ê° ë½ê¸°","ã³ã³ã»ããã4ã¤çæ","Generate 4 Concepts"),(0,e.jsx)($s,{size:16})]}),(0,e.jsx)("p",{className:"text-center text-[11px] text-zinc-600",children:f("AIê° ì íì ë³´ê³ ì»¨ì
·모ë¸Â·ì¥ì를 ì§ì ì íê³ , íí¹ ì¡ì
ì 모ë ë¼ì´ë¸ë¬ë¦¬ìì 골ë¼ìµëë¤ Â· 컨ì
ìì±ì 무ë£","AIã製åãè¦ã¦ã³ã³ã»ããã»ã¢ãã«ã»ãã±ã決ããããã¯ã¯ã¢ã¸ã¥ã¼ã«ã©ã¤ãã©ãªããé¸ã³ã¾ã · ã³ã³ã»ããçæã¯ç¡æ","The AI reads your product and decides the concept, cast and location â hook actions come from the module library · free")})]}),ee==="loading"&&o&&(0,e.jsx)("div",{className:"p-5 sm:p-7 pb-0",children:(0,e.jsx)(Xa,{children:f("ì í ë³´ê³ ì´ì¸ë¦¬ë 컨ì
ì ì§ê³ ìì´ì. 30ì´ì¯¤ ê±¸ë ¤ì.","ååãè¦ã¦åãã³ã³ã»ãããèãã¦ãã¾ãã30ç§ã»ã©ãããã¾ãã","Reading your product and working out concepts â about 30 seconds.")})}),ee==="loading"&&(0,e.jsxs)("div",{className:"p-16 flex flex-col items-center justify-center gap-4",children:[(0,e.jsx)(Gr,{size:32,className:"text-rose-400 animate-spin"}),(0,e.jsxs)("div",{className:"text-center",children:[(0,e.jsx)("p",{className:"text-sm font-bold text-white",children:f("ì íì ë¶ìíê³ ì»¨ì
ì ì¡°í©íê³ ììµëë¤...","製åãåæãã¦ã³ã³ã»ãããçµã¿åããã¦ãã¾ã...","Analyzing your product and mixing concepts...")}),(0,e.jsx)("p",{className:"text-[11px] text-zinc-500 mt-1.5",children:f("ì
ë§í¬ì¸í¸ ì¶ì¶ â 컨ì
ë°ì â ìºì¤í
·ì¥ì·íí¹ ì¡ì
íì (ì½ 40ì´)","ã»ã¼ã«ã¹ãã¤ã³ãæ½åº â ã³ã³ã»ããçºæ³ â ãã£ã¹ãã»ãã±ã»ããã¯ç¢ºå®ï¼ç´40ç§ï¼","Extracting selling points â inventing concepts â
111 locking cast, location & hook action (~40s)")})]})]}),ee==="concepts"&&(0,e.jsxs)("div",{className:"p-5 sm:p-7 space-y-4",children:[o&&(0,e.jsx)(Xa,{children:f("ì´ ì íì ì´ë° 컨ì
ë¤ì´ ì´ì¸ë ¤ì. ë§ìì ëë 걸 ê³ ë¥´ìë©´ ë°ë¡ ì¤í 리보ë를 ì§ê¸° ììí ê²ì.","ãã®ååã«ã¯ãããªã³ã³ã»ãããåãããã§ããæ°ã«å
¥ã£ããã®ãé¸ãã§ããã ããã°ãããã¹ãã¼ãªã¼ãã¼ããä½ãå§ãã¾ãã","These concepts fit your product. Pick one and I'll start building the storyboard.")}),te.length>0&&(0,e.jsxs)("div",{className:"rounded-xl border border-white/10 bg-white/[0.03] px-4 py-3",children:[(0,e.jsx)("p",{className:"text-[11px] font-bold text-zinc-400 mb-1.5",children:f("AIê° ì°ì ì
ë§í¬ì¸í¸","AIãæ´ãã ã»ã¼ã«ã¹ãã¤ã³ã","Selling points AI picked")}),(0,e.jsx)("div",{className:"flex flex-wrap gap-1.5",children:te.map((P,Ce)=>(0,e.jsx)("span",{className:"rounded-full bg-rose-500/10 border border-rose-400/20 px-2.5 py-1 text-[11px] text-rose-200",children:P},Ce))})]}),(0,e.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:K.map((P,Ce)=>(0,e.jsxs)("button",{onClick:()=>{try{localStorage.removeItem(ys)}catch{}l({concept:P,productImageUrls:R,productName:se.trim(),highlights:B.trim(),sellingPoints:te})},className:"group text-left rounded-2xl border border-white/10 bg-white/[0.03] hover:bg-white/[0.07] hover:border-rose-400/40 transition-all p-4 flex flex-col gap-2.5",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsxs)("span",{className:"inline-flex items-center gap-1.5 rounded-full bg-white/5 border border-white/10 px-2.5 py-1 text-[11px] font-bold text-zinc-300",children:[(0,e.jsx)("span",{children:P.emoji}),(0,e.jsx)("span",{children:G(P)})]}),(0,e.jsx)($s,{size:14,className:"shrink-0 text-zinc-600 group-hover:text-rose-300 transition-colors"})]}),(0,e.jsx)("p",{className:"text-sm font-black text-white leading-snug",children:P.title}),(0,e.jsxs)("p",{className:"text-[13px] text-rose-200/90 leading-snug",children:["â",P.hook,"â"]}),P.hookModuleLabel&&(0,e.jsxs)("span",{className:"w-max rounded-md bg-violet-500/10 border border-violet-400/25 px-2 py-0.5 text-[10px] font-bold text-violet-200",children:[f("íí¹","ããã¯","Hook")," · ",P.hookModuleLabel]}),P.hookAction&&(0,e.jsx)("p",{className:"text-[11px] text-zinc-400 leading-relaxed line-clamp-2",children:P.hookAction}),(P.casting||P.location)&&(0,e.jsxs)("div",{className:"space-y-1 rounded-lg bg-black/30 px-2.5 py-2",children:[P.casting&&(0,e.jsxs)("p",{className:"text-[10.5px] text-zinc-400 leading-relaxed line-clamp-2",children:[(0,e.jsx)("span",{className:"font-bold text-zinc-500",children:f("ìºì¤í
","ãã£ã¹ã","Cast")})," ",P.casting]}),P.location&&(0,e.jsxs)("p",{className:"text-[10.5px] text-zinc-400 leading-relaxed line-clamp-2",children:[(0,e.jsx)("span",{className:"font-bold text-zinc-500",children:f("ì¥ì","ãã±","Location")})," ",P.location]})]}),P.microStoryboard&&(0,e.jsx)("p",{className:"text-[11px] text-zinc-500 leading-relaxed whitespace-pre-line line-clamp-4",children:P.microStoryboard}),P.fitReason&&(0,e.jsx)("p",{className:"text-[11px] text-zinc-400 leading-snug mt-auto pt-1 border-t border-white/5",children:P.fitReason})]},Ce))}),(0,e.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,e.jsx)("button",{onClick:()=>Ee("input"),className:"text-[12px] text-zinc-500 hover:text-zinc-300 transition-colors",children:f("ì
ë ¥ ìì í기","å
¥åãä¿®æ£","Edit inputs")}),(0,e.jsxs)("button",{onClick:fe,className:"inline-flex items-center gap-1.5 rounded-lg border border-white/10 bg-white/5 hover:bg-white/10 px-3.5 py-2 text-[12px] font-bold text-zinc-300 hover:text-white transition-colors",children:[f("ë¤ë¥¸ 컨ì
4ê° ë¤ì ë½ê¸°","å¥ã®ã³ã³ã»ãããåçæ","Reroll 4 new concepts"),(0,e.jsx)(go,{size:13})]})]})]})]});return o?Ne:(0,Ia.createPortal)((0,e.jsxs)("div",{className:"fixed inset-0 z-[80] flex items-center justify-center p-3 sm:p-6",children:[(0,e.jsx)("div",{className:"absolute inset-0 bg-black/80 backdrop-blur-sm",onClick:ee==="loading"?void 0:_e}),Ne]}),document.body)},bs="!min-h-[120px] !rounded-[14px] !border-white/[0.14] !bg-zinc-950/[0.35] focus-within:!ring-0 focus-within:!border-[rgba(255,230,0,0.55)]",tn=(t,r,n,l)=>t==="ko"?r:t==="ja"?n:l,Zi="mk-modal is-narrow-pv bg-card text-foreground 2xl:!w-[min(92vw,1760px)] 2xl:!h-[min(88vh,1100px)] 2xl:!grid-cols-[minmax(0,1fr)_440px] data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95",Pa=({language:t,onClose:r,title:n,description:l,adminBadge:p,videoUrl:h,posterUrl:o,overlayUrl:S,onCloseAutoFocus:v,onInteractOutside:U,children:D,footer:I,extra:f})=>(0,e.jsx)(wo,{modal:!0,open:!0,onOpenChange:H=>{H||r()},children:(0,e.jsx)(Po,{children:(0,e.jsx)(No,{className:"mk-scrim data-[state=open]:animate-in data-[state=open]:fade-in-0",children:(0,e.jsxs)(_o,{onCloseAutoFocus:v,onInteractOutside:U,...l?{}:{"aria-describedby":void 0},className:Zi,children:[(0,e.jsx)(bn,{onClick:r,label:tn(t,"ë«ê¸°","éãã","Close")}),(0,e.jsx)("div",{className:"mk-pv",children:(0,e.jsx)("div",{className:"mk-pv-media",children:(0,e.jsxs)("div",{className:"absolute inset-0 bg-[#000] flex items-center justify-center overflow-hidden",children:[o&&(0,e.jsx)("img",{src:o,alt:"","aria-hidden":"true",className:"absolute inset-0 w-full h-full object-cover scale-110 blur-2xl opacity-40 pointer-events-none select-none"}),h?(0,e.jsx)("video",{src:h,poster:o||void 0,controls:!0,autoPlay:!0,loop:!0,muted:!0,playsInl
111ine:!0,className:"relative w-full h-full object-contain"},h):o?(0,e.jsx)("img",{src:o,alt:n,className:"relative w-full h-full object-contain"}):null,S&&(h||o)&&(0,e.jsx)("img",{src:S,alt:"","aria-hidden":"true","data-testid":"shift-preview-overlay",className:"absolute inset-0 w-full h-full object-contain pointer-events-none select-none"})]})})}),(0,e.jsxs)("div",{className:"mk-mform",children:[(0,e.jsxs)("header",{className:"mk-mhead",children:[(0,e.jsx)("p",{className:"rn-eyebrow is-y",children:tn(t,"릴ì¤","ãªã¼ã«","Reels")}),(0,e.jsxs)("div",{className:"flex items-center gap-2 min-w-0 mt-1.5",children:[(0,e.jsx)(Co,{asChild:!0,children:(0,e.jsx)("h3",{className:"!m-0 min-w-0 truncate",children:n})}),p&&(0,e.jsx)("span",{className:"shrink-0 px-1 py-px text-[9px] font-bold leading-none bg-brand/15 text-brand rounded ring-1 ring-brand/30",children:"ê´"})]}),l&&(0,e.jsx)(ko,{className:"line-clamp-2",children:l})]}),(0,e.jsx)("div",{className:"mk-mbody",children:D}),(0,e.jsx)("div",{className:"mk-mfoot",children:I})]}),f]})})})}),xs=({label:t,Icon:r,src:n,ariaLabel:l,need:p,onPick:h,onRemove:o,removeLabel:S,corner:v,language:U,muted:D})=>(0,e.jsxs)("div",{className:"mk-slot shrink-0",children:[(0,e.jsxs)("button",{type:"button",onClick:I=>{I.currentTarget.blur(),h()},"aria-label":l,className:st("mk-slot-box",n&&"is-filled"),children:[n?(0,e.jsx)("img",{src:n,alt:"",draggable:!1}):(0,e.jsx)(r,{"aria-hidden":"true",strokeWidth:1.6}),p&&!n&&(0,e.jsx)("em",{className:"mk-slot-need","aria-hidden":"true",children:p})]}),n&&o&&(0,e.jsx)("button",{type:"button",className:"mk-slot-x",onClick:o,"aria-label":S,title:S,children:(0,e.jsx)(Zr,{size:11,strokeWidth:2.6,"aria-hidden":"true"})}),!n&&v,(0,e.jsx)("small",{className:st("max-w-[4.5rem] text-center !whitespace-normal leading-tight",U==="ja"?"break-words":"break-keep",D&&"opacity-80"),children:t})]}),En=()=>(0,e.jsx)("span",{className:"mk-sep","aria-hidden":"true"});function vs({value:t,options:r,onChange:n,ariaLabel:l}){return(0,e.jsxs)(bi,{value:t,onValueChange:p=>n(p),children:[(0,e.jsx)(gi,{"aria-label":l,className:"w-full h-12 rounded-[14px] border border-border bg-white/[0.03] px-4 text-[14.5px] font-bold text-foreground shadow-none transition-colors hover:border-[rgba(255,230,0,0.35)] focus:ring-0 focus:ring-offset-0 focus:border-[rgba(255,230,0,0.55)] data-[state=open]:border-[rgba(255,230,0,0.55)]",children:(0,e.jsx)(yi,{})}),(0,e.jsx)(fi,{className:"z-[60]",children:r.map(p=>(0,e.jsx)(hi,{value:p,className:"text-sm font-semibold cursor-pointer focus:bg-[rgba(255,230,0,0.13)] focus:text-[rgb(var(--c-brand-ink))]",children:p},p))})]})}var Qr=[{key:"lead",label:{ko:"ì£¼ì° êµì²´",ja:"主役ãå·®ãæ¿ã",en:"Swap lead"},Icon:yo},{key:"support",label:{ko:"ì¡°ì° êµì²´",ja:"èå½¹ãå·®ãæ¿ã",en:"Swap supporting"},Icon:po},{key:"background",label:{ko:"ë°°ê²½ êµì²´",ja:"èæ¯ãå·®ãæ¿ã",en:"Swap background"},Icon:vn}],el=[1,2,3,4].map(t=>({key:`product${t}`,label:{ko:`ì í ${t}`,ja:`åå ${t}`,en:`Product ${t}`},Icon:mn})),tl={key:"finished",label:{ko:"ëì¤ë ì í",ja:"åºã¦ããåå",en:"Product that comes out"},Icon:us},rl=[Qr[0],Qr[1],tl,Qr[2],...el];function An(t){const r=t.shiftSlots;if(!r||r.length===0)return Qr;const n=[];for(const l of rl){const p=r.find(v=>v.role===l.key);if(!p)continue;const h=l.key==="lead"&&p.subject==="pet",o=l.key.startsWith("product")&&p.anchor==="product",S=l.key==="support"&&p.anchor==="product"||o?us:h?Ii:l.Icon;n.push({...l,Icon:S,...p.label?{label:p.label}:{},...p.required?{required:!0}:{},...p.atLeastOne?{atLeastOne:!0}:{},...l.key==="support"&&p.anchor==="product"?{productAnchor:!0}:{},...h?{pet:!0}:{},...o?{productObject:!0}:{}})}return n.length>0?n:Qr}function al(t){return t.some(r=>r.key==="lead"&&r.pet)?{hint:{ko:"ë°ë ¤ë물 ì¬ì§ í ì¥ì´ë©´ ë©ëë¤. ì¬ì§ ì í¸Â·ë¬´ë¬Â·ì· ê·¸ëë¡ ê±°ëí´ì ¸ ëì¤ê³ , 거리·íì·í¬ê¸°ë ì본 ê·¸ëë¡ ë¡ëë¤.",ja:"ãããã®åç1æã§å¤§ä¸å¤«ã§ã
111ãåçã®æ¯ä¸¦ã¿ã»æ¨¡æ§ã»æã®ã¾ã¾å·¨å¤§ã«ãªããè¡ã»ã¿ã¯ã¼ã»ããªã¯å
ã®ã¾ã¾ã§ãã",en:"One pet photo is all it takes. Your pet appears giant with the same fur, markings and outfit; the street, tower and helicopters stay as in the original."},placeholder:{ko:"ì) ë°ë ¤ë물 ì¬ì§ë§ ë£ê³ í롬íí¸ë ë¹ì ëì´ë ë©ëë¤.",ja:"ä¾) ãããã®åçã ãå
¥ãã¦ãããã³ããã¯ç©ºã®ã¾ã¾ã§ã大ä¸å¤«ã§ãã",en:"e.g. Just add a pet photo â you can leave the prompt empty."}}:t.some(r=>r.key==="finished")?{hint:{ko:"ëì§ë ì íê³¼ ëì¤ë ì í ì¬ì§ì ê·¸ ëª¨ìµ ê·¸ëë¡ ëìµëë¤. íìª½ë§ ë£ì¼ë©´ ë머ì§ë í롬íí¸ë¡ ì íì¸ì.",ja:"æãå
¥ããååã¨åºã¦ããååã®åçã¯ããã®è¦ãç®ã©ããã«åºã¾ããçæ¹ã ããªããããçæ¹ã¯ããã³ããã§æå®ãã¦ãã ããã",en:"Photos of what is thrown in and what comes out appear exactly as shown. With only one, describe the other in the prompt."},placeholder:{ko:"ì) @ëì§ëì í ìë를 ëì§ë©´ @ëì¤ëì í ìºì»¤í¼ê° ììì§ê³ , ë§ì§ë§ì @ì¸ë¬¼ì´ ìºì»¤í¼ë¥¼ ë§ìê².",ja:"ä¾) æãå
¥ããã³ã¼ãã¼è±ããç¼¶ã³ã¼ãã¼ãå´ãåºããæå¾ã«äººç©ãç¼¶ã³ã¼ãã¼ã飲ãã",en:"e.g. Throw in coffee beans and canned coffee erupts out; at the end the person drinks one."}}:t.some(r=>r.key==="support"&&r.productAnchor)&&t.some(r=>r.atLeastOne)?{hint:{ko:'ì¸ë¬¼Â·ì í ì¬ì§ ì¤ í ì¥ ì´ì ë£ì´ 주ì¸ì. ë£ì ì¬ì§ì ê·¸ ëª¨ìµ ê·¸ëë¡ ë°ëê³ , ë£ì§ ìì 쪽ì ì본 ê·¸ëë¡ ë¡ëë¤. ì본 ì·ì ì ì§íë ¤ë©´ í롬íí¸ì "ì¼êµ´ë§"ì´ë¼ê³ ì ì´ ì£¼ì¸ì.',ja:"人ç©ã»è£½åã®åçã1æä»¥ä¸å
¥ãã¦ãã ãããå
¥ããåçã¯ãã®è¦ãç®ã©ããã«å·®ãæ¿ãããå
¥ããªãã£ãæ¹ã¯å
ã®ã¾ã¾ã§ããå
ã®æã®ã¾ã¾ã«ããã«ã¯ããã³ããã«ãé¡ã ããã¨æ¸ãã¦ãã ããã",en:'Add at least one photo, a person or a product. Photos are swapped in exactly as shown, and anything you leave out stays as in the original. To keep the original outfit, write "face only" in the prompt.'},placeholder:{ko:"ì) ì í ì¬ì§ë§ ë£ê³ í롬íí¸ë ë¹ì ëì´ë ë©ëë¤.",ja:"ä¾) 製ååçã ãå
¥ãã¦ãããã³ããã¯ç©ºã®ã¾ã¾ã§ã大ä¸å¤«ã§ã
111ã",en:"e.g. Just add a product photo â you can leave the prompt empty."}}:t.length===1&&t[0].key==="support"&&t[0].productAnchor&&t[0].required?{hint:{ko:"ì¬ì§ í ì¥ì íìì
ëë¤. ë£ì ì¬ì§ ëª¨ìµ ê·¸ëë¡ ìì ì ëìì´ ë°ëê³ , ëë¨¸ì§ ì¥ë©´ì ì본 ê·¸ëë¡ì
ëë¤.",ja:"åç1æã¯å¿
é ã§ããå
¥ããåçã®è¦ãç®ã©ããã«åç»ã®å¯¾è±¡ãå·®ãæ¿ãããã»ãã®å ´é¢ã¯å
ã®ã¾ã¾ã§ãã",en:"One photo is required. It replaces the subject in the video exactly as shown; the rest of the scene stays as in the original."},placeholder:{ko:"ì) ì¬ì§ë§ ë£ê³ í롬íí¸ë ë¹ì ëì´ë ë©ëë¤.",ja:"ä¾) åçã ãå
¥ãã¦ãããã³ããã¯ç©ºã®ã¾ã¾ã§ã大ä¸å¤«ã§ãã",en:"e.g. Just add the photo â you can leave the prompt empty."}}:t.some(r=>r.key==="support"&&r.productAnchor)?{hint:{ko:"ì¸ë¬¼Â·ì í ì¬ì§ì ê·¸ ëª¨ìµ ê·¸ëë¡ ë°ëê³ , ë£ì§ ìì 쪽ì ì본 ê·¸ëë¡ ë¡ëë¤. ì íì ë°ê¾¸ë ¤ë©´ ì í ì¬ì§ì ë£ì´ 주ì¸ì.",ja:"人ç©ã»è£½åã®åçã¯ãã®è¦ãç®ã©ããã«å·®ãæ¿ãããå
¥ããªãã£ãæ¹ã¯å
ã®ã¾ã¾ã§ãã製åãæ¿ããã¨ãã¯è£½ååçãå
¥ãã¦ãã ããã",en:"Person and product photos are swapped in exactly as shown, and anything you leave out stays as in the original. To change the product, add a product photo."},placeholder:{ko:"ì) ì í ì¬ì§ë§ ë£ê³ í롬íí¸ë ë¹ì ëì´ë ë©ëë¤.",ja:"ä¾) 製ååçã ãå
¥ãã¦ãããã³ããã¯ç©ºã®ã¾ã¾ã§ã大ä¸å¤«ã§ã
111ã",en:"e.g. Just add a product photo â you can leave the prompt empty."}}:t.some(r=>r.productObject)?{hint:{ko:"ì í ì¬ì§ 3ì¥ì íìì
ëë¤. ì í 1·2·3ì´ ê³µì¤ì ë¬ ë¬¼ê±´ì ììëë¡ ë°ê¾¸ê³ , ì¬ì§ ëª¨ìµ ê·¸ëë¡ ëìµëë¤. ì¸ë¬¼ ì¬ì§ì ì íì
ëë¤.",ja:"åååç3æã¯å¿
é ã§ããåå1ã»2ã»3ã空ä¸ã«æµ®ãã¶ç©ãé ã«å·®ãæ¿ããåçã®è¦ãç®ã©ããã«åºã¾ãã人ç©åçã¯ä»»æã§ãã",en:"Three product photos are required. Products 1, 2 and 3 replace the flying items in order, exactly as shown. The person photo is optional."},placeholder:{ko:"ì) ì í ì¬ì§ë§ ë£ê³ í롬íí¸ë ë¹ì ëì´ë ë©ëë¤.",ja:"ä¾) åååçã ãå
¥ãã¦ãããã³ããã¯ç©ºã®ã¾ã¾ã§ã大ä¸å¤«ã§ãã",en:"e.g. Just add product photos â you can leave the prompt empty."}}:t.some(r=>r.key.startsWith("product"))?{hint:{ko:"ì í ì¬ì§ì íìì
ëë¤. ì í 1~4ë ìììì ì·ì´ ë°ëë ììëë¡ ì
íì§ëë¤. ì¸ë¬¼ ì¬ì§ì ì íì
ëë¤.",ja:"åååçã¯å¿
é ã§ããåå1ã4ã¯åç»ã§æãæ¿ããé ã«çãæ¿ãã¾ãã人ç©åçã¯ä»»æã§ãã",en:"Product photos are required. Products 1â4 are worn in the order the outfits change in the video. The person photo is optional."},placeholder:{ko:"ì) ì í 2 ìí¼ì¤ë ë¬´ë¦ ì 길ì´ë¡. ë§ì§ë§ì ì¹´ë©ë¼ë¥¼ ë³´ë©° ìë íì ì ê·¸ëë¡.",ja:"ä¾) åå2ã®ã¯ã³ãã¼ã¹ã¯èä¸ä¸ã«ãæå¾ã®ã«ã¡ã©ç®ç·ã®ç¬é¡ã¯ãã®ã¾ã¾ã",en:"e.g. Make the product 2 dress above the knee. Keep the final smile to the camera."}}:null}var sl=new Set(["image/jpeg","image/jpg","image/pjpeg","image/png","image/webp","image/gif","image/bmp","image/x-ms-bmp","image/avif","image/svg+xml"]),nl=/\.(jpe?g|png|webp|gif|bmp|avif|svg)$/i;function Ta(t){const r=String(t?.type||"").trim().toLowerCase();return r?sl.has(r):nl.test(String(t?.name||""))}var ks="480p",rn=["480p","720p","1080p"];function ol(t,r,n=Qr){const l=n.map(p=>p.key).filter(p=>!!t[p]);return{prompt:_s(r,n).trim(),mode:t.lead?"recast":"restyle",imageOrder:l}}var il=/^[a-zA-Z0-9_\-ê°-í£]+$/;function ls(t,r){const n=String(t.label?.[r]||"").trim();return(r==="ko"?n.replace(/\s*êµì²´$/,""):n.replace(/^swap\s+/i,"").toLowerCase()).trim()}function ws(t,r){const n=r==="ko"?["ko","en"]:["en"];for(const l of n){const p=ls(t,l).replace(/\s+/g,"");if(p&&il.test(p))return p}return t.key}function _s(t,r){if(!t||!t.includes("@"))return t;const n=new Map;for(const p of r){for(const h of["ko","en"]){const o=ls(p,h);o&&n.set(o.replace(/\s+/g,"").toLowerCase(),o)}n.set(p.key.toLowerCase(),ls(p,"en")||p.key)}const l=[...n.keys()].sort((p,h)=>h.length-p.length);return t.replace(/@([a-zA-Z0-9_\-ê°-í£]+)/g,(p,h)=>{const o=h.toLowerCase(),S=n.get(o);if(S!==void 0)return S;const v=l.find(U=>o.startsWith(U)&&/^[ê°-í£]+$/.test(o.slice(U.length)));return v?`${n.get(v)}${h.slice(v.length)}`:p})}var ll=({preset:t,sourceVideoUrl:r,variant:n=null,onVariantChange:l,language:p,sourceSeconds:h,estimateCredit:o,freeGrant:S=null,isSubmitting:v,onClose:U,onSubmit:D})=>{const I=(A,ye,Ze)=>p==="ko"?A:p==="ja"?ye:Ze,f=p!=="ko"&&t.i18n?.name?.[p]||t.name,H=p!=="ko"&&t.i18n?.description?.[p]||t.description,[ee,Ee]=(0,s.useState)({}
111),[N,F]=(0,s.useState)(null),se=(0,s.useMemo)(()=>An(t),[t]),[_,B]=(0,s.useState)(""),ie=S?.maxDurationSec!=null,K=rn.find(A=>A===S?.maxQuality)??null,[x,te]=(0,s.useState)(ks),[ue,R]=(0,s.useState)(null),$=(0,s.useRef)(typeof document<"u"&&document.activeElement instanceof HTMLElement&&document.activeElement!==document.body?document.activeElement:null),O=A=>{const ye=$.current;!ye||!ye.isConnected||(A.preventDefault(),ye.focus({preventScroll:!0}))},G=r,Oe=n?.poster||t.previewImage||"",fe=(t.shiftVariants||[]).map(A=>A.key),_e=!!l&&fe.includes("day")&&fe.includes("night"),Ne=(n?.key??t.shiftVariants?.[0]?.key)==="night",P=(0,s.useMemo)(()=>ol(ee,_,se),[ee,_,se]),Ce=Object.prototype.hasOwnProperty.call(os,t.id)&&!gn.includes(t.id),Re=se.filter(A=>!!ee[A.key]||A.required).map(A=>A.key),We=Ce&&Oo[t.id]?.promptOnly===!0&&Re.length===0&&!P.prompt.trim(),Ie=Ce?We?se.filter(A=>A.key!=="lead").slice(0,1).map(A=>A.key):Re:P.imageOrder,q=o(Ce?Ie.includes("lead")?"recast":"restyle":P.mode,x,Ie,P.prompt),V=!!S&&q===0,X=P.imageOrder.length>0||_.trim().length>0,ge=se.filter(A=>A.required&&!ee[A.key]),Qe=se.filter(A=>A.atLeastOne),ht=Qe.length>0&&!Qe.some(A=>ee[A.key]),$t=!v&&h>0&&X&&ge.length===0&&!ht&&q!==null,ft=al(se),W=se.length>4,Le=(A,ye)=>{if(!ye)return;if(!Ta(ye)){F(I("ì´ íìì ì¬ì©í ì ììµëë¤. JPG·PNG·WebP ë¡ ì ì¥í´ ì¬ë ¤ 주ì¸ì. (ìì´í° ì¬ì§ì HEIC íìì¼ ì ììµëë¤)","ãã®å½¢å¼ã¯ä½¿ç¨ã§ãã¾ãããJPGã»PNGã»WebP ã§ä¿åãã¦ã¢ãããã¼ããã¦ãã ãããï¼iPhone ã®åç㯠HEIC å½¢å¼ã®å ´åãããã¾ãï¼","This file type canât be used. Please upload a JPG, PNG or WebP. (iPhone photos may be in HEIC format.)"));return}const Ze=new FileReader;Ze.onerror=()=>F(I("ì¬ì§ì ì½ì§ 못íìµëë¤. ë¤ì ì íí´ ì£¼ì¸ì.","åçãèªã¿è¾¼ãã¾ããã§ãããããä¸åº¦é¸ãã§ãã ããã","Could not read the photo. Please pick it again.")),Ze.onload=()=>{typeof Ze.result=="string"&&(F(null),Ee(Lt=>({...Lt,[A]:Ze.result})))},Ze.readAsDataURL(ye)},kt=(A,ye)=>{ye&&(F(null),Ee(Ze=>({...Ze,[A]:ye})))},De=(0,s.useMemo)(()=>se.map(A=>({tag:`@${ws(A,p)}`,type:"image",previewUrl:ee[A.key]||void 0})),[se,p,ee]),yt=A=>Ee(ye=>{const Ze={...ye};return delete Ze[A],Ze}),rt=r?h>0?I(`ì본 ${Math.round(h)}ì´ Â· ê°ì 길ì´Â·ë¹ì¨`,`å
åç» ${Math.round(h)}ç§ã»åãé·ãã»æ¯ç`,`${Math.round(h)}s · same length and ratio`):I("ìì ì 보를 ì½ë ì¤â¦","åç»æ
å ±ãèªã¿è¾¼ã¿ä¸â¦","Reading video detailsâ¦"):I("ì´ í
í릿ì ì본 ììì ì¤ë¹ ì¤ì
ëë¤.","ãã®ãã³ãã¬ã¼ãã¯å
åç»ãæºåä¸ã§ãã","This templateâs source video is not ready yet.");return(0,e.jsxs)(Pa,{language:p,onClose:U,title:f,description:H,adminBadge:!!t.adminOnly,videoUrl:G,posterUrl:Oe,overlayUrl:Uo[t.id]||null,onCloseAutoFocus:O,onInteractOutside:A=>{A.target?.closest?.("[data-mention-dropdown]")&&A.preventDefault()},footer:(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"mk-foot-note",children:rt}),(0,e.jsxs)(Er,{variant:"y",disabled:!$t,onClick:()=>D({mode:P.mode,userPrompt:P.prompt,referenceImages:P.imageOrder.map(A=>ee[A]),referenceRoles:P.imageOrder,quality:x}),children:[v&&(0,e.jsx)(Gr,{className:"w-4 h-4 animate-spin","aria-hidden":"true"}),I("ë°ê¾¸ê¸° ìì","夿ãéå§","Start"),q!==null&&(0,e.jsxs)(e.Fragment,{children:[" ",(0,e.jsx)(fr,{value:V?I("ë¬´ë£ 1í","ç¡æ1å","Free run"):q,variant:"ink"})]})]})]}),extra:(0,e.jsx)(da,{open:ue!==null,accept:"image",onOpenChange:A=>{A||R(null)},onSelectFile:A=>{ue&&Le(ue,A)},onSelectLibrary:A=>{ue&&kt(ue,A)}}),children:[(0,e.jsx)("section",{className:"mk-slots","aria-label":I("êµì²´ ì¬ì§","å·®ãæ¿ãåç","Replacement photos"),children:se.map(({key:A,label:ye,Icon:Ze,required:Lt},ut)=>{const at=ee[A];return(0,e.jsxs)(s.Fragment,{children:[ut>0&&!W&&(se.length<=3||ut===1&&se[0].key==="lead")&&(0,e.jsx)(En,{}),W&&ut===1&&(0,e.jsx)("div",{className:"basis-full h-0","aria-hidden":"true"}),(0,e.jsx)(xs,{language:p,label:ye[p],Icon:Ze,src:at,ariaLabel:Lt?`${ye[p]} (${I("íì","å¿
é ","Required")})`:ye[p],need:Lt?I("íì","å¿
é ","Required"):void 0,onPick:()=>R(A),onRemove:()=>yt(A),removeLabel:`${I("ì ê±°","åé¤","Remove")}: ${ye[p]}`})]},A)})}),N&&(0,e.jsx)("p",{role:"alert",className:"mk-hint !text-destructive",children:N}),(0,e.jsx)(sr,{title:I("í롬íí¸","ããã³ãã","Prompt")}),(0,e.jsx)(ms,{ariaLabel:I("í롬íí¸","ããã³ãã","Prompt"),value:_,onCh
111ange:B,omniSlots:De,disableCharacterMentions:!0,disableLibraryMentions:!0,constrainHeight:!0,placeholder:ft?ft.placeholder[p]:I("ì) ì£¼ì° ìì ë°ëë를 ìì´ì¤ ìë©ë¦¬ì¹´ë
¸ë¡. ì¡°ì°ì í° ì
ì¸ ì ì²ë°ì§, ë°°ê²½ì ëì¿ ì¼ê²½ì¼ë¡.","ä¾) ä¸»å½¹ã®æã®ããããã¢ã¤ã¹ã³ã¼ãã¼ã«ãèå½¹ã¯ç½ã·ã£ãã«ã¸ã¼ã³ãºãèæ¯ã¯æ±äº¬ã®å¤æ¯ã«ã","e.g. Banana in the leadâs hand â iced coffee. Supporting cast in white shirts and jeans, background a Tokyo night skyline."),className:bs}),(0,e.jsx)("p",{className:"mk-hint",children:ft?ft.hint[p]:I("주ì°Â·ì¡°ì°Â·ë°°ê²½ì´ë¼ë ë§ë§ì¼ë¡ ì¶©ë¶í©ëë¤. ì¸ê¸íì§ ìì ììë ì본 ê·¸ëë¡ ë¡ëë¤.","ã主役ã»èå½¹ã»èæ¯ãã¨æ¸ãã ãã§éãã¾ãã触ããªãã£ãè¦ç´ ã¯å
ã®ã¾ã¾ã§ãã","Just say âleadâ, âsupportingâ or âbackgroundâ. Anything unmentioned stays as in the original.")}),_e&&(0,e.jsxs)("div",{className:"mk-toggle",children:[(0,e.jsxs)("b",{children:[I("ë® Â· ë°¤","æ¼ Â· å¤","Day · Night"),(0,e.jsx)("span",{className:"ml-2 text-xs font-medium text-muted-foreground","data-testid":"shift-daynight-state",children:Ne?I("ë°¤","å¤","Night"):I("ë®","æ¼","Day")})]}),(0,e.jsx)(bo,{dark:Ne,onToggle:()=>{v||l?.(Ne?"day":"night")},ariaLabel:I("ë°¤ì¼ë¡ 보기","å¤ã§è¡¨ç¤º","Night version"),className:v?"opacity-50 cursor-not-allowed":""})]}),(0,e.jsx)(sr,{title:I("í´ìë","è§£å度","Resolution")}),(0,e.jsx)(vs,{value:x,onChange:te,ariaLabel:I("í´ìë","è§£å度","Resolution"),options:rn}),S&&(0,e.jsx)("p",{className:"mk-hint","data-testid":"shift-free-note",children:V?I(`${ie?"ê°ì
기ë
":"ì¤í 기ë
"} ë¬´ë£ 1íê° ì ì©ë©ëë¤${K?` (${K} íì )`:""}.`,`${ie?"æ°è¦ç»é²è¨å¿µ":"ãªã¼ãã³è¨å¿µ"}ã®ç¡æ1åãé©ç¨ããã¾ã${K?`ï¼${K}éå®ï¼`:""}ã`,`Your ${ie?"sign-up":"launch"}-gift free run applies${K?` (${K} only)`:""}.`):I(`ë¬´ë£ 1íë ${K??"480p"} ììë§ ì ì©ë©ëë¤. ì´ í´ìëë ì ê°ë¡ ì°¨ê°ë©ëë¤.`,`ç¡æ1åã¯${K??"480p"}ã®ã¿å¯¾è±¡ã§ãããã®è§£å度ã¯é常æéã§ãã`,`The free run applies only at ${K??"480p"}. This resolution is charged at the normal rate.`)})]})};function cl(t){return[...t].sort((r,n)=>(n.popularityCount??0)-(r.popularityCount??0))}var dl=["shift_menu_lights","shift_drink_player","shift_crayon_hanger"];function ul(t){return typeof t=="string"&&dl.includes(t.trim())}var an={ko:16,en:32};function Qa(t){const r=.335+(Math.min(6,Math.max(2,Math.floor(t)))-1)*2.14+.875;return Math.round((r+1.345+2.1)*1e3)/1e3}var Za=()=>({image:null,ko:"",en:""});function ml(t){const r=[];for(const n of t){const l=n.ko.trim(),p=n.en.trim();if(!n.image){if(l||p)return{items:[],problem:"photo"};continue}if(!l)return{items:[],problem:"name"};r.push({image:n.image,ko:l,en:p})}return r.length<2||r.length>6?{items:r,problem:"count"}:{items:r,problem:null}}var pl=({preset:t,sourceVideoUrl:r,language:n,credit:l,isFree:p,isSubmitting:h,onClose:o,onSubmit:S})=>{const v=($,O,G)=>n==="ko"?$:n==="ja"?O:G,U=n!=="ko"&&t.i18n?.name?.[n]||t.name,D=n!=="ko"&&t.i18n?.description?.[n]||t.description,[I,f]=(0,s.useState)(()=>Array.from({length:2},Za)),[H,ee]=(0,s.useState)(null),[Ee,N]=(0,s.useState)(null),F=(0,s.useRef)(typeof document<"u"&&document.activeElement instanceof HTMLElement&&document.activeElement!==document.body?document.activeElement:null),se=$=>{const O=F.current;!O||!O.isConnected||($.preventDefault(),O.focus({preventScroll:!0}))},_=ml(I),B=I.filter($=>$.image).length,ie=!h&&_.problem===null&&l!==null,K=t.previewImage||"",x=($,O)=>f(G=>G.map((Oe,fe)=>fe===$?{...Oe,...O}:Oe)),te=$=>f(O=>{const G=O.filter((Oe,fe)=>fe!==$);for(;G.length<2;)G.push(Za());return G}),ue=($,O)=>{if(!O)return;if(!Ta(O)){N(v("ì´ íìì ì¬ì©í ì ììµëë¤. JPG·PNG·WebP ë¡ ì ì¥í´ ì¬ë ¤ 주ì¸ì. (ìì´í° ì¬ì§ì HEIC íìì¼ ì ììµëë¤)","ãã®å½¢å¼ã¯ä½¿ç¨ã§ãã¾ãããJPGã»PNGã»WebP ã§ä¿åãã¦ã¢ãããã¼ããã¦ãã ãããï¼iPhone ã®åç㯠HEIC å½¢å¼ã®å ´åãããã¾ãï¼","This file type canât be used. Please upload a JPG, PNG or WebP. (iPhone photos may be in HEIC format.)"));return}const G=new FileReader;G.onerror=()=>N(v("ì¬ì§ì ì½ì§ 못íìµëë¤. ë¤ì ì íí´ ì£¼ì¸ì.","åçãèªã¿è¾¼ãã¾ããã§ãããããä¸åº¦é¸ãã§ãã ããã","Could not read the photo. Please pick it again.")),G.onload=()=>{typeof G.result=="string"&&(N(null),x($,{image:G.result}))}
111,G.readAsDataURL(O)},R=_.problem==="name"?v("ì¬ì§ì ë£ì ì íë§ë¤ ì´ë¦ì ì ì´ ì£¼ì¸ì.","åçãå
¥ããååãã¨ã«ååãå
¥åãã¦ãã ããã","Add a name for every product with a photo."):_.problem==="photo"?v("ì´ë¦ì ì ì 칸ì ì í ì¬ì§ì ë£ì´ 주ì¸ì.","ååãå
¥åããæ¬ã«åååçãå
¥ãã¦ãã ããã","Add a product photo to every row with a name."):_.problem==="count"?v("ì íì 2~6ê° ë£ì´ 주ì¸ì.","ååã2ã6åå
¥ãã¦ãã ããã","Add 2â6 products."):null;return(0,e.jsxs)(Pa,{language:n,onClose:o,title:U,description:D,adminBadge:!!t.adminOnly,videoUrl:r,posterUrl:K,onCloseAutoFocus:se,footer:(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"mk-foot-note",children:v(`${Math.round(Qa(Math.max(B,2)))}ì´ Â· 1080Ã1920`,`${Math.round(Qa(Math.max(B,2)))}ç§ã»1080Ã1920`,`${Math.round(Qa(Math.max(B,2)))}s · 1080Ã1920`)}),(0,e.jsxs)(Er,{variant:"y",disabled:!ie,onClick:()=>S({items:_.items}),children:[h&&(0,e.jsx)(Gr,{className:"w-4 h-4 animate-spin","aria-hidden":"true"}),v("ë§ë¤ê¸° ìì","使ãéå§","Start"),l!==null&&(0,e.jsxs)(e.Fragment,{children:[" ",(0,e.jsx)(fr,{value:p?v("ë¬´ë£ 1í","ç¡æ1å","Free run"):l,variant:"ink"})]})]})]}),extra:(0,e.jsx)(da,{open:H!==null,accept:"image",onOpenChange:$=>{$||ee(null)},onSelectFile:$=>{H!==null&&ue(H,$)},onSelectLibrary:$=>{H!==null&&$&&(N(null),x(H,{image:$}))}}),children:[(0,e.jsxs)("section",{className:"rounded-[14px] bg-muted/40 ring-1 ring-border px-3.5 py-3",children:[(0,e.jsx)("p",{className:"text-[11px] font-bold tracking-[0.15em] text-muted-foreground uppercase",children:v("ì¼ì§ë ìì","ç¹ç¯ã®é çª","Lighting order")}),(0,e.jsxs)("div",{className:"mt-2 flex flex-wrap items-center gap-1.5","aria-hidden":"true",children:[I.map(($,O)=>(0,e.jsxs)(s.Fragment,{children:[(0,e.jsx)("span",{className:st("inline-flex items-center justify-center w-6 h-6 rounded-full text-[11px] font-bold",$.image?"bg-[#D0B692] text-[#1d140f]":"bg-muted text-muted-foreground ring-1 ring-border"),children:O+1}),(0,e.jsx)("span",{className:"text-muted-foreground text-[11px]",children:"â"})]},O)),(0,e.jsx)("span",{className:"inline-flex items-center h-6 rounded-full px-2.5 text-[11px] font-bold bg-[#D0B692] text-[#1d140f]",children:v("ì ì²´","å
¨ä½","All")})]}),(0,e.jsx)("p",{className:"mt-2 text-[11px] leading-4 text-muted-foreground",children:v("ì íì´ íëì© ì¼ì§ë©° ì´ë¦ì´ ë¨ê³ , ë§ì§ë§ì ì ë¶ ì¼ì§ëë¤.","ååã1ã¤ãã¤ç¹ç¯ãã¦ååãåºã¦ãæå¾ã«å
¨é¨ç¹ç¯ãã¾ãã","Each product lights up with its name, then everything lights up.")})]}),(0,e.jsx)("ol",{className:"flex flex-col gap-2.5 mt-2","aria-label":v("ì í 목ë¡","ååãªã¹ã","Products"),children:I.map(($,O)=>(0,e.jsxs)("li",{className:"relative flex items-stretch gap-3 rounded-2xl bg-muted/30 ring-1 ring-border p-2.5",children:[(0,e.jsx)("span",{className:"absolute -top-2 -left-2 w-5 h-5 rounded-full bg-[#D0B692] text-[#1d140f] text-[10px] font-bold flex items-center justify-center ring-2 ring-card","aria-hidden":"true",children:O+1}),(0,e.jsxs)("div",{className:"relative shrink-0",children:[(0,e.jsx)("button",{type:"button",onClick:G=>{G.currentTarget.blur(),ee(O)},"aria-label":v(`ì í ${O+1} ì¬ì§`,`åå ${O+1} ã®åç`,`Product ${O+1} photo`),className:st("w-[76px] h-[76px] rounded-[14px] border overflow-hidden flex flex-col items-center justify-center gap-1 transition-colors","outline-none focus:outline-none focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[rgba(255,230,0,0.7)]",$.image?"border-border":"border-border bg-muted/40 text-muted-foreground hover:border-[rgba(255,230,0,0.5)] hover:text-[rgb(var(--c-brand-ink))]"),children:$.image?(0,e.jsx)("img",{src:$.image,alt:"",className:"w-full h-full object-cover"}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(us,{className:"w-5 h-5",strokeWidth:1.6}),(0,e.jsx)("span",{className:"text-[10px] font-semibold",children:v("ì¬ì§","åç","Photo")})]})}),$.image&&(0,e.jsx)("button",{type:"button",onClick:()=>x(O,{image:null}),"aria-label":`${v("ì¬ì§ 빼기","åçãå¤ã","Remove photo")}: ${v(`ì í ${O+1}`,`åå ${O+1}`,`Product ${O+1}`)}`,className:"absolute -top-1.5 -right-1.5 w-4 h-4 rounded-full bg-[rgba(10,10,11,0.82)
111] ring-1 ring-[rgba(255,255,255,0.25)] text-[#fff] flex items-center justify-center hover:bg-[#ef4444]",children:(0,e.jsx)(Zr,{className:"w-2.5 h-2.5"})})]}),(0,e.jsxs)("div",{className:"flex-1 min-w-0 rounded-xl bg-[#1d140f] ring-1 ring-[#3a2a1f] px-3 py-2.5 flex flex-col items-center justify-center gap-1 focus-within:ring-[#D0B692]/60",children:[(0,e.jsx)("input",{value:$.ko,maxLength:an.ko,onChange:G=>x(O,{ko:G.target.value}),"aria-label":v(`ì í ${O+1} ì´ë¦(첫 ì¤)`,`åå ${O+1} ã®ååï¼1è¡ç®ï¼`,`Product ${O+1} name (first line)`),placeholder:v("ì í ì´ë¦","ååå","Product name"),className:"w-full bg-transparent border-0 outline-none text-center text-[15px] font-bold text-[#D0B692] placeholder:text-[#D0B692]/35"}),(0,e.jsx)("input",{value:$.en,maxLength:an.en,onChange:G=>x(O,{en:G.target.value}),"aria-label":v(`ì í ${O+1} ë째 ì¤(ì í)`,`åå ${O+1} ã®2è¡ç®ï¼ä»»æï¼`,`Product ${O+1} second line (optional)`),placeholder:v("ë째 ì¤ (ì í)","2è¡ç®ï¼ä»»æï¼","Second line (optional)"),className:"w-full bg-transparent border-0 outline-none text-center text-[11px] font-serif text-[#D0B692]/90 placeholder:text-[#D0B692]/30"})]}),I.length>2&&(0,e.jsx)("button",{type:"button",onClick:()=>te(O),"aria-label":`${v("ì í ìì ","ååãåé¤","Delete product")}: ${v(`ì í ${O+1}`,`åå ${O+1}`,`Product ${O+1}`)}`,className:"shrink-0 self-start p-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted",children:(0,e.jsx)(Zr,{className:"w-3.5 h-3.5"})})]},O))}),I.length<6&&(0,e.jsx)("button",{type:"button",onClick:()=>f($=>[...$,Za()]),className:"mk-chipb",children:v(`ì í ì¶ê° (${I.length}/6)`,`ååã追å ï¼${I.length}/6ï¼`,`Add product (${I.length}/6)`)}),(0,e.jsx)("p",{className:"mk-hint",children:v("ë¼ë²¨ì ì ì ê·¸ëë¡ ë¤ì´ê°ëë¤. í ì¤ë§ ì°ë©´ í ì¤ ë¼ë²¨, ìì´ë§ ìíìë©´ 첫 ì¤ì ìì´ë¥¼ ì°ì¸ì.","ã©ãã«ã¯å
¥åã©ããã«å
¥ãã¾ãã1è¡ã ããªã1è¡ã®ã©ãã«ãè±èªã ããªã1è¡ç®ã«è±èªãå
¥åãã¦ãã ããã","Labels appear exactly as typed. Fill only the first line for a one-line label.")}),Ee&&(0,e.jsx)("p",{role:"alert",className:"mk-hint !text-destructive",children:Ee}),!Ee&&B>0&&R&&(0,e.jsx)("p",{className:"mk-hint !text-destructive",children:R})]})};function hl(t){return typeof t=="string"&&t.trim()==="shift_drink_player"}var fl={10:20},sn=["480p","720p","1080p"],gl={"480p":0,"720p":18,"1080p":63};function yl(t){const r=fl[10];return t.background?r+gl[t.resolution]:r}var bl=({preset:t,sourceVideoUrl:r,language:n,ready:l,freeGrant:p,isQualityFree:h,estimateCredit:o,isSubmitting:S,onClose:v,onSubmit:U})=>{const D=(q,V,X)=>n==="ko"?q:n==="ja"?V:X,I=n!=="ko"&&t.i18n?.name?.[n]||t.name,f=n!=="ko"&&t.i18n?.description?.[n]||t.description,[H,ee]=(0,s.useState)({}
111),Ee=H.product??null,[N,F]=(0,s.useState)(null),[se,_]=(0,s.useState)(null),[B,ie]=(0,s.useState)(""),K=(0,s.useRef)(typeof document<"u"&&document.activeElement instanceof HTMLElement&&document.activeElement!==document.body?document.activeElement:null),x=q=>{const V=K.current;!V||!V.isConnected||(q.preventDefault(),V.focus({preventScroll:!0}))},te=10,ue=p?.maxDurationSec!=null,R=sn.includes(String(p?.maxQuality))?p.maxQuality:null,[$,O]=(0,s.useState)(ks),G=!!H.background,Oe=!!p&&h($),fe=Oe?0:o($,G),_e=!S&&l&&!!Ee&&(Oe||fe!==null),Ne=t.previewImage||"",P=(0,s.useMemo)(()=>{const q=(V,X)=>t.shiftSlots?.find(ge=>ge.role===V)?.label??X;return[{key:"product",label:q("support",{ko:"ì í êµì²´",ja:"製åãå·®ãæ¿ã",en:"Swap product"}),Icon:_i,required:!0},{key:"background",label:q("background",{ko:"ë°°ê²½ êµì²´",ja:"èæ¯ãå·®ãæ¿ã",en:"Swap background"}),Icon:vn}]},[t.shiftSlots]),Ce=(0,s.useMemo)(()=>P.map(q=>({tag:`@${ws(q,n)}`,type:"image",previewUrl:H[q.key]||void 0})),[P,n,H]),Re=_s(B,P).trim(),We=(q,V)=>ee(X=>{const ge={...X};return V?ge[q]=V:delete ge[q],ge}),Ie=(q,V)=>{if(!V)return;if(!Ta(V)){_(D("ì´ íìì ì¬ì©í ì ììµëë¤. JPG·PNG·WebP ë¡ ì ì¥í´ ì¬ë ¤ 주ì¸ì. (ìì´í° ì¬ì§ì HEIC íìì¼ ì ììµëë¤)","ãã®å½¢å¼ã¯ä½¿ç¨ã§ãã¾ãããJPGã»PNGã»WebP ã§ä¿åãã¦ã¢ãããã¼ããã¦ãã ãããï¼iPhone ã®åç㯠HEIC å½¢å¼ã®å ´åãããã¾ãï¼","This file type canât be used. Please upload a JPG, PNG or WebP. (iPhone photos may be in HEIC format.)"));return}const X=new FileReader;X.onerror=()=>_(D("ì¬ì§ì ì½ì§ 못íìµëë¤. ë¤ì ì íí´ ì£¼ì¸ì.","åçãèªã¿è¾¼ãã¾ããã§ãããããä¸åº¦é¸ãã§ãã ããã","Could not read the photo. Please pick it again.")),X.onload=()=>{typeof X.result=="string"&&(_(null),We(q,X.result))},X.readAsDataURL(V)};return(0,e.jsxs)(Pa,{language:n,onClose:v,title:I,description:f,adminBadge:!!t.adminOnly,videoUrl:r,posterUrl:Ne,onCloseAutoFocus:x,onInteractOutside:q=>{q.target?.closest?.("[data-mention-dropdown]")&&q.preventDefault()},footer:(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"mk-foot-note",children:D(`${te}ì´ Â· ${$}`,`${te}ç§ã»${$}`,`${te}s · ${$}`)}),(0,e.jsxs)(Er,{variant:"y",disabled:!_e,onClick:()=>{Ee&&U({image:Ee,resolution:$,...H.background?{background:H.background}:{},...Re?{prompt:Re}:{}})},children:[S&&(0,e.jsx)(Gr,{className:"w-4 h-4 animate-spin","aria-hidden":"true"}),D("ë°ê¾¸ê¸° ìì","夿ãéå§","Start"),l&&(Oe||fe!==null)&&(0,e.jsxs)(e.Fragment,{children:[" ",(0,e.jsx)(fr,{value:Oe?D("ë¬´ë£ 1í","ç¡æ1å","Free run"):fe,variant:"ink"})]})]})]}),extra:(0,e.jsx)(da,{open:N!==null,accept:"image",onOpenChange:q=>{q||F(null)},onSelectFile:q=>{N&&Ie(N,q)},onSelectLibrary:q=>{N&&q&&(_(null),We(N,q))}}),children:[(0,e.jsx)("section",{className:"mk-slots","aria-label":D("êµì²´ ì¬ì§","å·®ãæ¿ãåç","Replacement photos"),children:P.map(({key:q,label:V,Icon:X,required:ge},Qe)=>(0,e.jsxs)(s.Fragment,{children:[Qe>0&&(0,e.jsx)(En,{}),(0,e.jsx)(xs,{language:n,label:V[n],Icon:X,src:H[q],ariaLabel:ge?`${V[n]} (${D("íì","å¿
é ","Required")})`:V[n],need:ge?D("íì","å¿
é ","Required"):void 0,onPick:()=>F(q),onRemove:()=>We(q,null),removeLabel:`${D("ì ê±°","åé¤","Remove")}: ${V[n]}`})]},q))}),se&&(0,e.jsx)("p",{role:"alert",className:"mk-hint !text-destructive",children:se}),(0,e.jsx)(sr,{title:D("í롬íí¸","ããã³ãã","Prompt")}),(0,e.jsx)(ms,{ariaLabel:D("í롬íí¸","ããã³ãã","Prompt"),value:B,onChange:ie,omniSlots:Ce,disableCharacterMentions:!0,disableLibraryMentions:!0,constrainHeight:!0,placeholder:D("ì) 곡 ì 목ì 'ì°ë² ë¼ë¼', ê°ìë 'ì¹´í ë¹ ëë'ë¡.","ä¾) æ²åã¯ãã¦ãã©ãããã¢ã¼ãã£ã¹ãã¯ãã«ãã§ ãããããã«ã","e.g. Song title 'Ube Latte', artist 'Cafe Bbanana'."),className:bs}),(0,e.jsx)("p",{className:"mk-hint",children:D("ìë£ ì¬ì§ì ì 리ìì ë´ê¸´, ì¸µì´ ìë ìë£ê° ì ì´ì¸ë¦½ëë¤. í롬íí¸ë¡ íë ì´ì´ì 곡 ì 목·ê°ì ì´ë¦ê³¼ ìë£ ëª¨ìµì ë°ê¿ ì ììµëë¤. ë°°ê²½ ì¬ì§ì ë£ì¼ë©´ ê·¸ ë°ë¥ ììì ì ì¥ë©´ì ë¤ì ì°ê³ , ë°ë¥ì´ ë°ì¼ë©´ íë ì´ì´ ê¸ì¨ë ê²ììì´ ë©ëë¤. ìë£ê° ìë ì¬ì§ì ë§ë¤ ì ìê³ í¬ë ë§ì íë¶ë©ëë¤.","ã°ã©ã¹ã«å
¥ã£ã層ã®ããããªã³ã¯ãæ ãã¾ããããã³ããã§ãã¬ã¼ã¤ã¼ã®æ²åã»ã¢ã¼ãã£ã¹ãåã¨ããªã³ã¯ã®è¦ãç®ãå¤ãããã¾ããèæ¯åçãå
¥ããã¨ãã®åºã®ä¸ã§æã®ã·ã¼ã³ãæ®ãç´ããæããåºã§ã¯ãã¬ã¼ã¤ã¼ã®æåãé»ã«ãªãã¾ããããªã³ã¯ä»¥å¤ã®åçã¯ä½æã§ãããã¯ã¬ã¸ããã¯è¿éããã¾ãã","Layered drinks in a clear glass work best. Use the prompt to change the playerâs song title and artist or how the drink looks. Add a background photo to reshoot the hand scene on that surface; on light surfaces the player text turns black. Photos without a drink canât be made and are refunded.")}),(0,e.jsx)(sr,{title:D("í´ìë","è§£å度","Resolution")}),(0,e.jsx)(vs,{value:$,onChange:O,ariaLabel:D("í´ìë","è§£å度","Resolution"),options:sn}),p&&(0,e.jsx)("p",{className:"mk-hint","data-testid":"shift-free-note",children:Oe?D(`${ue?"ê°ì
기ë
":"ì¤í 기ë
"} ë¬´ë£ 1íê° ì ì©ë©ëë¤${R?` (${R} íì )`:""}.`,`${ue?"æ°è¦ç»é²è¨å¿µ":"ãªã¼ãã³è¨å¿µ"}ã®ç¡æ1åãé©ç¨ããã¾ã${R?`ï¼${R}éå®ï¼`:""}
111ã`,`Your ${ue?"sign-up":"launch"}-gift free run applies${R?` (${R} only)`:""}.`):D(`ë¬´ë£ 1íë ${R??"480p"} ììë§ ì ì©ë©ëë¤. ì´ í´ìëë ì ê°ë¡ ì°¨ê°ë©ëë¤.`,`ç¡æ1åã¯${R??"480p"}ã®ã¿å¯¾è±¡ã§ãããã®è§£å度ã¯é常æéã§ãã`,`The free run applies only at ${R??"480p"}. This resolution is charged at the normal rate.`)})]})};function xl(t){return typeof t=="string"&&t.trim()==="shift_crayon_hanger"}var nn=["480p","720p","1080p"],vl=2.5;var kl=2.6,wl={"480p":{perOutfit:28,base:12},"720p":{perOutfit:57,base:27},"1080p":{perOutfit:133,base:65}};function Sa(t){return t*kl+(t-1)*2+vl}function _l(t,r){const n=Math.min(5,Math.max(2,Math.floor(t))),l=wl[r];return n*l.perOutfit+l.base}function Il(t){return _l(t.outfits,t.resolution)}function Sl(t){const r=t.filter(n=>typeof n=="string"&&n.length>0);return r.length<2||r.length>5?{outfits:r,problem:"count"}:{outfits:r,problem:null}}function jl(t){const r=t.filter(Boolean).length;let n=-1;return t.forEach((l,p)=>{l&&(n=p)}),Math.min(5,Math.max(2,r+1,n+1))}function Nl(t){return{key:`outfit${t+1}`,label:{ko:`ìì ${t+1}`,ja:`è¡£è£
${t+1}`,en:`Outfit ${t+1}`}}}var Cl=({preset:t,sourceVideoUrl:r,language:n,estimateCredit:l,freeGrant:p=null,isQualityFree:h,isSubmitting:o,onClose:S,onSubmit:v})=>{const U=(V,X,ge)=>n==="ko"?V:n==="ja"?X:ge,D=n!=="ko"&&t.i18n?.name?.[n]||t.name,I=n!=="ko"&&t.i18n?.description?.[n]||t.description,[f,H]=(0,s.useState)(()=>Array.from({length:5},()=>
111null)),[ee,Ee]=(0,s.useState)(ks),[N,F]=(0,s.useState)(""),[se,_]=(0,s.useState)(null),[B,ie]=(0,s.useState)(null),K=(0,s.useRef)(typeof document<"u"&&document.activeElement instanceof HTMLElement&&document.activeElement!==document.body?document.activeElement:null),x=V=>{const X=K.current;!X||!X.isConnected||(V.preventDefault(),X.focus({preventScroll:!0}))},te=Sl(f),ue=te.outfits.length,R=jl(f),$=Math.max(ue,2),O=p?.maxDurationSec!=null,G=nn.includes(String(p?.maxQuality))?p.maxQuality:null,Oe=h(ee),fe=Oe?0:l($,ee),_e=!o&&te.problem===null&&fe!==null,Ne=t.previewImage||"",P=f.slice(0,R),Ce=(0,s.useMemo)(()=>Array.from({length:R},(V,X)=>Nl(X)),[R]),Re=(0,s.useMemo)(()=>Ce.map((V,X)=>({tag:`@${ws(V,n)}`,type:"image",previewUrl:P[X]||void 0})),[Ce,P,n]),We=_s(N,Ce).trim(),Ie=(V,X)=>H(ge=>ge.map((Qe,ht)=>ht===V?X:Qe)),q=(V,X)=>{if(!X)return;if(!Ta(X)){ie(U("ì´ íìì ì¬ì©í ì ììµëë¤. JPG·PNG·WebP ë¡ ì ì¥í´ ì¬ë ¤ 주ì¸ì. (ìì´í° ì¬ì§ì HEIC íìì¼ ì ììµëë¤)","ãã®å½¢å¼ã¯ä½¿ç¨ã§ãã¾ãããJPGã»PNGã»WebP ã§ä¿åãã¦ã¢ãããã¼ããã¦ãã ãããï¼iPhone ã®åç㯠HEIC å½¢å¼ã®å ´åãããã¾ãï¼","This file type canât be used. Please upload a JPG, PNG or WebP. (iPhone photos may be in HEIC format.)"));return}const ge=new FileReader;ge.onerror=()=>ie(U("ì¬ì§ì ì½ì§ 못íìµëë¤. ë¤ì ì íí´ ì£¼ì¸ì.","åçãèªã¿è¾¼ãã¾ããã§ãããããä¸åº¦é¸ãã§ãã ããã","Could not read the photo. Please pick it again.")),ge.onload=()=>{typeof ge.result=="string"&&(ie(null),Ie(V,ge.result))},ge.readAsDataURL(X)};return(0,e.jsxs)(Pa,{language:n,onClose:S,title:D,description:I,adminBadge:!!t.adminOnly,videoUrl:r,posterUrl:Ne,onCloseAutoFocus:x,onInteractOutside:V=>{V.target?.closest?.("[data-mention-dropdown]")&&V.preventDefault()},footer:(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"mk-foot-note",children:U(`${$}ë² Â· ì½ ${Math.round(Sa($))}ì´ Â· ${ee}`,`${$}çã»ç´${Math.round(Sa($))}ç§ã»${ee}`,`${$} outfits · ~${Math.round(Sa($))}s · ${ee}`)}),(0,e.jsxs)(Er,{variant:"y",disabled:!_e,onClick:()=>v({outfits:te.outfits,resolution:ee,...We?{prompt:We}:{}}),children:[o&&(0,e.jsx)(Gr,{className:"w-4 h-4 animate-spin","aria-hidden":"true"}),U("ë°ê¾¸ê¸° ìì","夿ãéå§","Start"),fe!==null&&(0,e.jsxs)(e.Fragment,{children:[" ",(0,e.jsx)(fr,{value:Oe?U("ë¬´ë£ 1í","ç¡æ1å","Free run"):fe,variant:"ink"})]})]})]}),extra:(0,e.jsx)(da,{open:se!==null,accept:"image",onOpenChange:V=>{V||_(null)},onSelectFile:V=>{se!==null&&q(se,V)},onSelectLibrary:V=>{se!==null&&V&&(ie(null),Ie(se,V))}}),children:[(0,e.jsx)("section",{className:"mk-slots","aria-label":U("ìì ì¬ì§","è¡£è£
ã®åç","Outfit photos"),children:P.map((V,X)=>{const ge=Ce[X].label[n],Qe=X<2;return(0,e.jsx)(xs,{language:n,label:ge,Icon:mn,src:V,ariaLabel:Qe?`${ge} (${U("íì","å¿
é ","Required")})`:ge,need:Qe?U("íì","å¿
é ","Required"):void 0,onPick:()=>_(X),onRemove:()=>Ie(X,null),removeLabel:`${U("ì ê±°","åé¤","Remove")}: ${ge}`},X)})}),B&&(0,e.jsx)("p",{role:"alert",className:"mk-hint !text-destructive",children:B}),(0,e.jsx)(sr,{title:U("í롬íí¸","ããã³ãã","Prompt")}),(0,e.jsx)(ms,{ariaLabel:U("í롬íí¸","ããã³ãã","Prompt"),value:N,onChange:F,omniSlots:Re,disableCharacterMentions:!0,disableLibraryMentions:!0,constrainHeight:!0,placeholder:U("ì) @ìì2 ë ììë§ ê±¸ì´ ì£¼ì¸ì. ë¹ì ëì´ë ë©ëë¤.","ä¾) è¡£è£
2ã¯ãããã¹ã ãæãã¦ãã ããã空æ¬ã§ã大ä¸å¤«ã§ã
111ã","e.g. Hang only the top for @outfit2. You can leave this empty."),className:bs}),(0,e.jsx)("p",{className:"mk-hint",children:U("ìì ì¬ì§ì 2ì¥ ì´ì íìíê³ , 칸 ììëë¡ í¬ë íì¤ë¡ ê·¸ë ¤ì§ ë¤ ì¤ë¬¼ë¡ ë°ëëë¤. ìì·íìê° í ì¬ì§ì ìì¼ë©´ í ì·ê±¸ì´ì ê°ì´ 걸립ëë¤. í롬íí¸ë¡ë 걸리ë ì·ì 모ì(ììë§ ê±¸ê¸°, ì매 걷기 ë±)ì ì í ì ììµëë¤.","è¡£è£ åçã¯2æä»¥ä¸å¿ è¦ã§ãæ ã®é ã«ã¯ã¬ã¨ã³ã§æããã¦ããå®ç©ã«å¤ããã¾ããä¸ä¸ã1æã®åçã«ããã°åããã³ã¬ã¼ã«æããã¾ããããã³ããã§ã¯æããæã®è¦ãç®ï¼ãããã¹ã ããè¢ãã¾ãã ãªã©ï¼ãæå®ã§ãã¾ãã","At least two outfit photos are needed; they are drawn in crayon in slot order and then turn real. A top and bottom in one photo hang together. Use the prompt to shape how the clothes hang (top only, sleeves rolled up, etc.).")}),(0,e.jsx)(sr,{title:U("í´ìë","è§£å度","Resolution")}),(0,e.jsx)(vs,{value:ee,onChange:Ee,ariaLabel:U("í´ìë","è§£å度","Resolution"),options:nn}),p&&(0,e.jsx)("p",{className:"mk-hint","data-testid":"shift-free-note",children:Oe?U(`${O?"ê°ì 기ë ":"ì¤í 기ë "} ë¬´ë£ 1íê° ì ì©ë©ëë¤${G?` (${G} íì )`:""}.`,`${O?"æ°è¦ç»é²è¨å¿µ":"ãªã¼ãã³è¨å¿µ"}ã®ç¡æ1åãé©ç¨ããã¾ã${G?`ï¼${G}éå®ï¼`:""}ã`,`Your ${O?"sign-up":"launch"}-gift free run applies${G?` (${G} only)`:""}.`):U(`ë¬´ë£ 1íë ${G??"480p"} ììë§ ì ì©ë©ëë¤. ì´ í´ìëë ì ê°ë¡ ì°¨ê°ë©ëë¤.`,`ç¡æ1åã¯${G??"480p"}ã®ã¿å¯¾è±¡ã§ãããã®è§£å度ã¯é常æéã§ãã`,`The free run applies only at ${G??"480p"}. This resolution is charged at the normal rate.`)})]})};function Pl(t){if(!(t.sourceSeconds>0))return null;const r=Fo({templateKey:t.templateKey,mode:t.mode,roles:t.roles,sourceSeconds:t.sourceSeconds,isAdmin:t.isAdmin,hasPrompt:t.hasPrompt}),n=(t.templateKey||"").trim(),l=Math.min(30,Math.max(4,Math.round(t.sourceSeconds)));if((r.total>0||gn.includes(n))&&Object.prototype.hasOwnProperty.call(os,n)&&l<=Lo[n]+1)return os[n][t.quality];const p=vi({serviceName:Xr,variants:t.variants||[],tier:"pro",quality:t.quality,duration:t.sourceSeconds,inputVideoDuration:t.sourceSeconds,useOmni:!1});if(p===null)return null;const{total:h}=r,o=$o(t.templateKey,t.sourceSeconds);return Ao(p+(h>0?Mo(h):0)+o)}var wa="Preserve authentic product packaging text and label typography. Do not add unrelated overlay captions, subtitles, or watermarks.",Tl="no subtitles, no captions, no on-screen text, no burned-in text, no Hangul text overlay. audio only.",Ke="shorts",El=9,Al={10:{"720p":50.4,"1080p":124.8,"4k":259.2},15:{"720p":75.6,"1080p":187.2,"4k":388.8}},Rl={"480p":3,"720p":6.4,"1080p":19.3};function $l(t){if(!t)return"";const r=[[/\b(gym\s+)?locker[\s-]?room\b/gi,"gym lounge area"],[/\b(shower|changing)[\s-]?room\b/gi,"lounge area"],[/\bíìì¤\b/g,"í¬ì¤ì¥ ë¼ì´ì§"],[/\bë½ì»¤\s*룸\b/g,"í¬ì¤ì¥ ë¼ì´ì§"],[/\bì¤ìì¤\b/g,"í¬ì¤ì¥ ë¼ì´ì§"],[/\b(a\s+)?(white\s+)?towel\s+(draped|wrapped)[^.,]*/gi,"a sports jacket over the shoulders"],[/\btowel\s+over\s+(her|his|their)\s+shoulder/gi,"a sports jacket over the shoulders"],[/\bbare\s+(skin|thigh|thighs|underarm|underarms|armpit|armpits)\b/gi,"the clothed area"],[/맨ì´/g,"í¼ë¶"],[/\b(inner\s+)?(thigh|thighs|underarm|underarms|armpit|armpits)\b/gi,"the application area"],[/겨ëëì´\s*ì쪽/g,"ì¬ì© ë¶ì"],[/íë² ì§\s*ì쪽/g,"ì¬ì© ë¶ì"],[/\b(sports\s+bra|underwear|lingerie|swimsuit|bikini)\b/gi,"athletic top"],[/\bsweaty\b/gi,"freshly active"]];let n=t;for(const[l,p]of r)n=n.replace(l,p);return n}function es(t){const r=String(t||"").toLowerCase();return r?/inappropriate content|suggestive or explicit|content[_\s-]?policy|safety system|moderation|flagged|nsfw|ì ì |ì í´|ì ì± ìë°/.test(r):!1}function Ml(t){if(!t)return"";const r=[[/\b(a|the)\s+(strikingly\s+)?(pretty|beautiful|gorgeous|attractive|sexy)\s+/gi,"a "],[/\bin (her|his|their) (early|mid|late)[\s-]?(twenties|thirties|forties|fifties|\d{2}s)\b/gi,""],[/\b(dewy|damp|glowing|flushed)\s+(skin|hair)\b/gi,"natural $2"],[/\bpost[\s-]?workout\b/gi,"after a light activity"],[/\b(skin texture|pores|collarbone|shoulder line|waist|hips|legs|thigh[s]?|underarm[s]?|armpit[s]?|chest|cleavage)\b/gi,"the scene"],[/\b(bare|exposed)\s+\w+/gi,"covered"],[/\b(selfie|front[\s-]?camera)\b/gi,"handheld camera"],[/\bface (and|,) upper chest fill the frame\b/gi,"the product fills the frame"],[/\bnext to (her|his|their) face\b/gi,"in front of the camera"]];let n=t;for(const[l,p]of r)n=n.replace(l,p);return`${n} Framing note: keep the composition centered on the product in its setting, fully clothed people only, modest everyday wardrobe, no close-up of skin. Safe-for-all-ages commercial photography.`}function Xt(t){if(!t)return"";const r=[[/\bno\s*text\s*,?\s*no\s*watermarks?\b/gi,wa],[/\bno\s*text\b/gi,"Preserve authentic product packaging text and label typography"],[/\bnever\s+include(?:\s+any)?\s+text(?:\/typography)?[^.]*\./gi,`${wa}.`],[/\bdo\s+not\s+include(?:\s+any)?\s+text(?:\/typography)?[^.]*\./gi,`${wa}.`],[/\bdo\s+not\s+render(?:\s+any)?\s+text[^.]*\./gi,`${wa}.`],[/\bno\s+typography\b/gi,"preserve authentic product packaging text and label typography"]];let n=t;for(const[l,p]of r)n=n.replace(l,p);return n.replace(/\s{2,}/g," ").replace(/\s+([,.;:!?])/g,"$1").trim()}function Ul(t){const r=Xt(t||"");if(!r)return"";const n=r.replace(/(".*?[\uac00-\ud7a3].*?")\s*\([A-Za-z][^)]*\)/g,"$1").replace(/\s*FULL NARRATION SCRIPT:[\s\S]*?(?=(?:ACTOR DIALOGUE:|STYLE:|$))/i,` 112`).replace(/\n{3,}/g,` 113 114`).trim();return n.includes("ABSOLUTE NO ON-SCREEN TEXT")||n.includes("íë©´ í ì¤í¸ ì ì± ")||n.includes("SEEDANCE 2.5 TEXT RENDERING POLICY")?n:`${Tl} 115 116${n}`.trim()}function on(t,r){if(!t)return t;try{const n=new URL(t,typeof window<"u"?window.location.origin:"http://localhost");return n.searchParams.set("_thumb_retry",r),n.toString()}catch{return`${t}${t.includes("?")?"&":"?"}_thumb_retry=${encodeURIComponent(r)}`}}function cs(t,r){if(!t)return"";const{width:n=420,height:l,quality:p=55}=r||{};try{const h=new URL(t,typeof window<"u"?window.location.origin:"http://localhost"),o="/storage/v1/object/public/";if(!h.pathname.includes(o))return t;if(h.pathname.includes("/storage/v1/render/image/"))return h.searchParams.has("width")||h.searchParams.set("width",String(n)),l&&!h.searchParams.has("height")&&h.searchParams.set("height",String(l)),h.searchParams.has("quality")||h.searchParams.set("qual
116ity",String(p)),h.searchParams.has("resize")||h.searchParams.set("resize","cover"),h.toString();const[S,...v]=h.pathname.split(o)[1].split("/");return!S||v.length===0?t:(h.pathname=`/storage/v1/render/image/public/${S}/${v.join("/")}`,h.searchParams.set("width",String(n)),l&&h.searchParams.set("height",String(l)),h.searchParams.set("quality",String(p)),h.searchParams.set("resize","cover"),h.toString())}catch{return t}}var Dl=t=>{if(!Array.isArray(t))return;const r=t.map(n=>{if(typeof n=="string")return n.trim()?{url:n.trim()}:null;const l=typeof n?.url=="string"?n.url.trim():"";return l?{url:l,poster:typeof n?.poster=="string"&&n.poster.trim()?n.poster.trim():void 0}:null}).filter(Boolean);return r.length>0?r:void 0},Ol=t=>{if(!Array.isArray(t))return;const r=["lead","support","finished","background","product1","product2","product3","product4"],n=[];for(const l of r){const p=t.find(f=>f&&typeof f=="object"&&f.role===l);if(!p)continue;const h=p.label,o=h&&typeof h.ko=="string"&&typeof h.ja=="string"&&typeof h.en=="string"?{ko:h.ko,ja:h.ja,en:h.en}:void 0,S=l==="lead"&&p.wardrobe==="replace"?"replace":void 0,v=(l==="support"||l.startsWith("product"))&&p.anchor==="product"?"product":void 0,U=p.required===!0,D=l==="lead"&&p.subject==="pet"?"pet":void 0,I=p.atLeastOne===!0;n.push({role:l,...o?{label:o}:{},...S?{wardrobe:S}:{},...v?{anchor:v}:{},...U?{required:U}:{},...D?{subject:D}:{},...I?{atLeastOne:I}:{}})}return n.length>0?n:void 0},Ll=t=>{if(!Array.isArray(t))return;const r=[];for(const n of t){if(!n||typeof n!="object")continue;const l=n,p=l.key==="day"||l.key==="night"?l.key:null,h=typeof l.templateKey=="string"?l.templateKey.trim():"",o=typeof l.sourceUrl=="string"?l.sourceUrl.trim():"";if(!p||!/^shift_[a-z0-9_]+$/.test(h)||!/^https:\/\//.test(o)||r.some(v=>v.key===p))continue;const S=typeof l.poster=="string"&&/^https:\/\//.test(l.poster.trim())?l.poster.trim():void 0;r.push({key:p,templateKey:h,sourceUrl:o,...S?{poster:S}:{}})}return r.length>=2?r:void 0},Fl=t=>{if(!t||typeof t!="object")return;const r=p=>{if(!p||typeof p!="object")return;const h={};for(const o of["ja","en"]){const S=p[o];typeof S=="string"&&S.trim()&&(h[o]=S.trim())}return Object.keys(h).length>0?h:void 0},n=r(t.name),l=r(t.description);return n||l?{name:n,description:l}:void 0},Gl=t=>({id:t.preset_key,name:t.name,description:t.description||"",category:t.category,industry:t.industry||null,colorSwatch:t.color_swatch||"#FFFFFF",previewGradient:t.preview_gradient||"linear-gradient(135deg,#333,#555)",previewImage:t.preview_image_url||void 0,promptTemplate:Xt(t.prompt_template||""),createdAt:t.created_at,displayOrder:t.display_order,popularityCount:typeof t.popularity_count=="number"?t.popularity_count:void 0,tone:t.tone||void 0,casting:t.casting||void 0,ethnicity:t.ethnicity||void 0,theme:t.theme==="shift"?"shift":"influencer",location:t.location||void 0,showcaseVideos:Dl(t.showcase_videos),shiftSourceVideoUrl:typeof t.shift_source_video_url=="string"&&t.shift_source_video_url.trim()?t.shift_source_video_url.trim():void 0,i18n:Fl(t.i18n),adminOnly:t.admin_only===!0,shiftSlots:Ol(t.shift_slots),shiftVariants:Ll(t.shift_variants)}),Vl=["hold_explain"],ts=yn({quality:"medium",resolution:"1K"}),ln=[{key:"hold_explain",emoji:"ð¤³",labelKo:"ë¤ê³ ì¤ëª
",labelJa:"æã£ã¦èª¬æ",labelEn:"Hold & Explain"},{key:"fooh",emoji:"ðï¸",labelKo:"FOOH ëì",labelJa:"FOOH ã·ãã£",labelEn:"FOOH City"},{key:"ugc",emoji:"ðª",labelKo:"UGC ê·¹í",labelJa:"UGC ã¨ã¯ã¹ããªã¼ã ",labelEn:"UGC Extreme"},{key:"cgi",emoji:"ð¬",labelKo:"CGI 3D",labelJa:"CGI 3D",labelEn:"CGI 3D"},{key:"vfx",emoji:"â¨",labelKo:"VFX í¨ê³¼",labelJa:"VFX ã¨ãã§ã¯ã",labelEn:"VFX Effects"},{key:"drama",emoji:"ð",labelKo:"K-ëë¼ë§",labelJa:"K-ãã©ã",labelEn:"K-Drama"},{key:"legacy",emoji:"ðï¸",labelKo:"í´ëì",labelJa:"ã¯ã©ã·ãã¯",labelEn:"Classic"}],Hl=[{key:"influencer",labelKo:"ì¸í루ì¸ì",labelJa:"ã¤ã³ãã«ã¨ã³ãµã¼",labelEn:"Influencer"},{key:"shift",labelKo:"ë¨ë릴ì¤",labelJa:"æ¥ä¸æãªã¼ã«",labelEn:"Trending Reels",comingSoon:!0}],rs=48,as=2e3,zl=["image/jpeg","image/png","image/webp","image/gif"],_a=10*1024*1024,ss=()=>ai("image"),ns=t=>new Promise(r=>{window.setTimeout(r,t)}),$e=t=>{if(!t)return null;if(typeof t=="string"){const r=t.trim();return r||null}if(Array.isArray(t)){for(const r of t){const n=$e(r);if(n)return n}return null}if(typeof t=="object"){const r=t;return $e(r.url)||$e(r.resultUrl)||$e(r.result_url)||$e(r.imageUrl)||$e(r.image_url)||$e(r.videoUrl)||$e(r.video_url)||$e(r.output)||$e(r.images)||$e(r.data)}return null},cn=t=>$e(t?.taskId??t?.task_id??t?.data?.taskId??t?.data?.task_id??t?.data?.data?.taskId??t?.data?.data?.task_id),la=t=>typeof t=="string"&&t.startsWith("http")?t:Array.isArray(t)&&t.length>0&&typeof t[0]=="string"&&t[0].startsWith("http")?t[0]:$e(t?.imageUrl)||$e(t?.image_url)||$e(t?.resultUrl)||$e(t?.result_url)||$e(t?.videoUrl)||$e(t?.video_url)||$e(t?.images)||$e(t?.allResultUrls)||$e(t?.resultUrls)||$e(t?.output)||$e(t?.data?.imageUrl)||$e(t?.data?.image_url)||$e(t?.data?.resultUrl)||$e(t?.data?.result_url)||$e(t?.data?.videoUrl)||$e(t?.data?.video_url)||$e(t?.data?.images)||$e(t?.data?.allResultUrls)||$e(t?.data?.resultUrls)||$e(t?.data?.response?.resultUrls)||$e(t?.data?.resultInfoJson?.resultUrls)||$e(t?.data?.resultJson)||null,ql=(t,r)=>{const n=(l,p,h)=>r==="ko"?l:r==="ja"?p:h;return t==="hero"?{label:n("ëí ì´ë¯¸ì§","ãã¼ãã¼ç»å","Hero Image"),description:n("ëí ì´ë¯¸ì§ë¥¼ ë§ë¤ê³ ììµëë¤.","ãã¼ãã¼ç»åã使ãã¦ãã¾ãã","Creating the representative image.")}:t==="drafting"?{label:n("ì´ì ìì±","ãã©ãã使","Drafting"),description:n("ì¼ì¸ ì´
116ìì 구ì±íê³ ììµëë¤.","ã·ã§ã¼ãåç»ã®èæ¡ãæ§æãã¦ãã¾ãã","Building the shorts draft.")}:t==="discussion"?{label:n("íì ì¤","åè°ä¸","Discussing"),description:n("ì¬ì©ì ìì ìì²ì 기ë¤ë¦¬ê±°ë ë°ìí ì ììµëë¤.","ã¦ã¼ã¶ã¼ã®ä¿®æ£ãªã¯ã¨ã¹ããå¾
ã¤ãåæ ã§ãã¾ãã","Ready for user edits and approval.")}:t==="generating"?{label:n("ìì ìì± ì¤","åç»ãçæä¸","Generating"),description:n("Seedance 2.0 결과를 기ë¤ë¦¬ê³ ììµëë¤.","Seedance 2.0ã®çµæãå¾
ã£ã¦ãã¾ãã","Waiting for the Seedance 2.0 result.")}:t==="result"?{label:n("ê²°ê³¼ ëì°©","çµæå°ç","Ready"),description:n("ìì±ë 결과를 ë¤ì ì´ì´ íì¸í ì ììµëë¤.","宿ããçµæãå度éãã¦ç¢ºèªã§ãã¾ãã","The finished result is ready to reopen.")}:t==="error"?{label:n("íì¸ íì","確èªãå¿
è¦","Needs Attention"),description:n("ì¤ë¥ ë´ì©ì íì¸íê³ ì´ì´ì ì§íí ì ììµëë¤.","ã¨ã©ã¼å
容ã確èªãã¦ç¶ãã¦é²ãããã¾ãã","Review the error and continue from the agent.")}:{label:n("ì¤ë¹ ì¤","æºåä¸","Preparing"),description:n("ìì´ì í¸ ì¸ì
ì ì¤ë¹íê³ ììµëë¤.","ã¨ã¼ã¸ã§ã³ãã»ãã·ã§ã³ãæºåãã¦ãã¾ãã","Preparing the agent session.")}},Rn=s.memo(({preset:t,onClick:r,priority:n=!1,tutorialAnchor:l,badge:p=null})=>{const h=t.category==="fashion_film",[o,S]=s.useState(!1),[v,U]=s.useState(!1),[D,I]=s.useState(!1),f=t.previewImage||"",H=s.useMemo(()=>cs(f,{width:360,height:640,quality:55}),[f]),[ee,Ee]=s.useState(H||f),N=s.useRef(0),{ref:F,inView:se}=Ls({triggerOnce:!0,rootMargin:"320px 0px",initialInView:n}),_=s.useMemo(()=>(t.showcaseVideos||[]).filter(ge=>ge&&typeof ge.url=="string"&&ge.url),[t.showcaseVideos]),[B,ie]=s.useState(0),[K,x]=s.useState(!1),[te,ue]=s.useState(!1),[R,$]=s.useState(!1),[O,G]=s.useState(!1);s.useEffect(()=>{ie(0),x(!1),ue(!1),$(!1)},[_.length]);const Oe=_.length>0?_[B%_.length]:null;s.useEffect(()=>{ue(!1),$(!1)},[Oe?.url]);const{ref:fe,inView:_e,entry:Ne}=Ls({rootMargin:"120px 0px",threshold:[0,.25,.5,.75,1],initialInView:n}),P=Ne?.intersectionRatio??0,Ce=P>0?P:n?.001:0,Re=To(`shorts-preset-${t.id}`,!!Oe&&!K&&(!R||O),Ce,O),We=!!Oe&&!K,Ie=We&&(n||_e)&&Re,q=Oe?.poster||H||f||void 0;s.useEffect(()=>{N.current=0,S(!1),U(!1),I(!1),Ee(H||f)},[H,f]);const V=s.useCallback(()=>{if(f&&!D&&H&&H!==f){U(!1),I(!0),Ee(on(f,"full"));return}N.current<1&&f?(N.current+=1,U(!1),I(!0),Ee(on(f,String(N.current)))):S(!0)},[f,H,D]),X=!!f&&(n||se);return(0,e.jsxs)("button",{ref:F,type:"button",onClick:r,...l?Ve(l):{},"aria-label":t.name,className:"mk-tcard",style:{aspectRatio:h?"3 / 4":"9 / 16"},children:[(0,e.jsxs)("div",{ref:fe,onMouseEnter:()=>G(!0),onMouseLeave:()=>G(!1),className:"mk-media overflow-hidden",children:[(0,e.jsx)("div",{className:"absolute inset-0 w-full h-full",style:{background:t.previewGradient}}),We?(0,e.jsxs)(e.Fragment,{children:[Ie?(0,e.jsx)("video",{src:Oe.url,poster:q,muted:!0,autoPlay:!0,playsInline:!0,preload:"metadata",loop:_.length<=1,onEnded:()=>{_.length>1&&ie(ge=>(ge+1)%_.length)},onLoadedData:()=>ue(!0),onLoadedMetadata:ge=>{const Qe=ge.currentTarget;(Qe.videoWidth>1920||Qe.videoHeight>1920)&&$(!0)},onError:()=>x(!0),className:st("absolute inset-0 w-full h-full object-cover transition-opacity duration-300",te?"opacity-100":"opacity-0")},Oe.url):null,(!Ie||!te)&&q&&(0,e.jsx)("img",{src:q,alt:t.name,className:"absolute inset-0 w-full h-full object-cover",loading:n?"eager":"lazy",decoding:"async",draggable:!1})]}):X&&!o?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("img",{src:ee,alt:t.name,className:st("absolute inset-0 w-full h-full object-cover transition-opacity duration-300",v?"opacity-100":"opacity-0"),loading:n?"eager":"lazy",decoding:"async",sizes:h?"(max-width: 1024px) 50vw, 20vw":"(max-width: 1024px) 50vw, 25vw",draggable:!1,onLoad:()=>U(!0),onError:V,fetchpriority:n?"high":"low"}),!v&&(0,e.jsx)("div",{className:"absolute inset-0 animate-pulse bg-white/[0.05]"})]}):null]}),t.adminOnly&&(0,e.jsx)("span",{className:"mk-vb",style:{color:"#ffe600"},children:"ê´"}),p&&(0,e.jsx)("span",{className:"mk-vb is-round",style:{left:"auto",right:10},children:p})]})});Rn.displayName="AdTemplateCard";var Bl=({summary:t,language:r,onOpen:n,onDismiss:l})=>{const p=(I,f,H)=>r==="ko"?I:r==="ja"?f:H,h=ql(t.phase||"idle",r),o=t.heroImageUrl||t.sessionInput?.preset?.previewImage||null,S=t.draftTitle||t.presetName,v=t.error||h.description,U=t.phase==="error"||!!t.error,D=!U&&(t.phase==="result"||!!t.finalVideoUrl);return(0,e.jsx)(Ho,{video:t.finalVideoUrl,image:o,background:t.sessionInput?.preset?.previewGradient,title:S,sub:v,status:U?"error":D?"done":"active",statusLabel:h.label,progress:t.progress?`${t.progress}%`:void 0,onClick:n,onDelete:l,deleteLabel:p("ì¢
ë£","ã»ãã·ã§ã³çµäº","End"),deleteIcon:"close"})},$c=({user:t,onClose:r,onOpenStorage:n,sandbox:l=!1})=>{const{t:p,language:h}=un(),o=(0,s.useCallback)((a,c,d)=>
116h==="ko"?a:h==="ja"?c:d,[h]),{signInWithGoogle:S}=so(),{isAdmin:v,canUseAdminFeatures:U}=uo(),{currentModel:D}=Ro(),{checkCredit:I,showCreditRequiredModal:f,showCreditModal:H,setShowCreditModal:ee,requiredCredit:Ee}=xn(),{settings:N}=ii(),F=(0,s.useMemo)(()=>qa(N.type_specific_settings),[N.type_specific_settings]),se=oo(),[_,B]=(0,s.useState)(()=>{if(l)return"templates";try{const a=localStorage.getItem("ad-active-tab");if(a==="templates"||a==="history")return a}catch{}return"templates"});(0,s.useEffect)(()=>{if(!l)try{localStorage.setItem("ad-active-tab",_)}catch{}},[_,l]);const ie=Ko("mk-lib-shorts"),[K,x]=(0,s.useState)("all"),[te,ue]=(0,s.useState)(0),[R,$]=(0,s.useState)([]),[O,G]=(0,s.useState)(!0);(0,s.useEffect)(()=>{(async()=>{G(!0);try{const{data:a,error:c}=await ve.from("shorts_preset_templates").select("*").eq("is_active",!0).or(`tone.in.(${Vl.join(",")}),theme.eq.shift`).not("preview_image_url","is",null).order("display_order",{ascending:!0});if(c)throw c;$((a||[]).map(Gl))}catch{$([])}finally{G(!1)}})()},[]);const[Oe,fe]=(0,s.useState)(void 0);(0,s.useEffect)(()=>{(async()=>{try{const{data:a,error:c}=await ve.from("bbanana_models").select("model_variants").eq("id","a8785abe-d139-479a-9202-d69119078e4b").single();!c&&a?.model_variants&&(fe(a.model_variants),pe.log("[ShortsAgentView] NB2 variants loaded from DB, credit_map:",a.model_variants?.[0]?.params?.find(d=>d.key==="resolution")?.credit_map))}catch{}})()},[]);const[_e,Ne]=(0,s.useState)(null),[P,Ce]=(0,s.useState)(null);(0,s.useEffect)(()=>{(async()=>{try{const{data:a,error:c}=await ve.from("bbanana_models").select("id, service_name, model_variants, credit_cost").in("id",[Yo,Qo]);!c&&Array.isArray(a)&&(Ne(a.find(d=>d.id==="2fd1c0c1-2e5c-435d-bf31-ee4b00830f49")??null),Ce(a.find(d=>d.id==="6db87733-d7dd-410c-b9e8-6650d0f5fbea")??null))}catch{}})()},[]);const[Re,We]=(0,s.useState)(15),Ie=!l&&kn(U)?"2.5":"2.0",q=(0,s.useCallback)((a,c,d)=>{const u=d??Ie,k=Ws(u,a,{seedance2:_e,seedance25:P}),w=Ks(u,a,c);if(u==="2.5"||a>15){if(k)return Va(a,w,!0,k,"pro");const ne=Rl[w==="4k"?"720p":w];return Math.ceil(ne*a*10)/10}const L=w==="480p"?"720p":w;return k?Va(a,L,!0,k,"pro"):Al[a][L]},[_e,P,Ie]),V=(0,s.useMemo)(()=>["service","product"],[]),[X,ge]=(0,s.useState)("all"),[Qe,ht]=(0,s.useState)("all"),[$t,ft]=(0,s.useState)("all"),[W,Le]=(0,s.useState)("all"),kt=(0,s.useMemo)(()=>{const a={};for(const c of R){if((c.theme||"influencer")==="shift")continue;const d=c.tone||"legacy";a[d]=(a[d]||0)+1}return a},[R]),De=(0,s.useMemo)(()=>ln.filter(a=>(kt[a.key]||0)>0).length>1,[kt]),yt=(0,s.useMemo)(()=>{const a={};for(const c of R){if(c.adminOnly&&!v)continue;const d=c.theme||"influencer";a[d]=(a[d]||0)+1}return a},[R,v]),rt=!1;(0,s.useMemo)(()=>{const a={},c=X==="all"?R.filter(d=>V.includes(d.category)):R.filter(d=>d.category===X);for(const d of c)d.industry&&(a[d.industry]=(a[d.industry]||0)+1);return a},[X,R,V]);const A=(0,s.useMemo)(()=>{let a=R;return X==="all"?a=[...R].sort((c,d)=>{const u=c.displayOrder??0,k=d.displayOrder??0;if(u!==k)return u-k;const w=c.createdAt?new Date(c.createdAt).getTime():0;return(d.createdAt?new Date(d.createdAt).getTime():0)-w}).filter(c=>V.includes(c.category)):a=R.filter(c=>c.category===X),Qe!=="all"&&(a=a.filter(c=>c.industry===Qe)),$t!=="all"&&(a=a.filter(c=>(c.tone||"legacy")===$t)),W!=="all"?a=a.filter(c=>(c.theme||"influencer")===W):rt&&(a=a.filter(c=>(c.theme||"influencer")!=="shift")),W==="shift"&&rt&&(a=[]),W==="shift"&&(a=cl(a)),v||(a=a.filter(c=>!c.adminOnly)),l&&(a=a.filter(c=>(c.theme||"influencer")!=="shift")),a},[X,Qe,$t,W,rt,v,l,R,V]),[ye,Ze]=(0,s.useState)(rs),Lt=(0,s.useRef)(null),ut=(0,s.useMemo)(()=>{const a=A.slice(0,ye);if(!l)return a;const c=A.find(d=>d.id===Bs);return c?[c,...a.filter(d=>d.id!==c.id)]:a},[A,ye,l]),at=ye<A.length,qt=(0,s.useCallback)(()=>{Ze(a=>a>=A.length?a:Math.min(a+rs,A.length))},[A.length]),re=(0,s.useCallback)(a=>{if(!at)return;const{scrollTop:c,scrollHeight:d,clientHeight:u}=a.currentTarget;d-c-u<=420&&qt()},[at,qt]);(0,s.useEffect)(()=>{Ze(rs)},[X,Qe,$t,W]),(0,s.useEffect)(()=>{if(_!=="templates"||!at)return;const a=Lt.current;a&&a.scrollHeight<=a.clientHeight+320&&qt()},[_,at,qt,ye]);
116const Me=6,[ce,gt]=(0,s.useState)(null);(0,s.useEffect)(()=>{if(!ce)return;const a=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=a}},[ce]);const[Ae,bt]=(0,s.useState)([]),[Ue,Nt]=(0,s.useState)(null),[Mt,wt]=(0,s.useState)(null),[nr,Bt]=(0,s.useState)(null),[Je,me]=(0,s.useState)(null),[Fe,Qt]=(0,s.useState)(""),[vr,et]=(0,s.useState)(""),[xt,kr]=(0,s.useState)(!1),[mt,gr]=(0,s.useState)([]),[Ye,_t]=(0,s.useState)(!1),wr=(0,s.useRef)(null),{unregisterPortraitAsset:Vr}=So(),_r=(0,s.useRef)(new Set);(0,s.useEffect)(()=>{if(!ce)return;if(l){const c=Yr.productImages.map(oa).filter(d=>!!d);bt(d=>d.length===0?c:d),et(d=>d||Ka.productName),We(Ka.videoDuration);return}const a=qa(N.type_specific_settings);Ae.length===0&&a.productImages.length>0&&bt(a.productImages.slice(0,Me)),!Fe.trim()&&a.highlights.trim()&&Qt(a.highlights.trim())},[ce,N.type_specific_settings,l]),(0,s.useCallback)(async()=>{if(!(mt.length>0)){_t(!0);try{const{data:a,error:c}=await ve.from("model_presets").select("id, name, preview_image, category").eq("is_active",!0).order("sort_order");!c&&a&&gr(a)}catch{}finally{_t(!1)}}},[mt.length]),(0,s.useEffect)(()=>{if(!xt)return;const a=c=>{wr.current&&!wr.current.contains(c.target)&&kr(!1)};return document.addEventListener("mousedown",a),()=>document.removeEventListener("mousedown",a)},[xt]);const[Ct,Ir]=(0,s.useState)("9:16"),[Ft,ua]=(0,s.useState)("1K"),[Gt,ma]=(0,s.useState)("jpg"),[or,Ar]=(0,s.useState)(!1),[it,ir]=(0,s.useState)(null),Vt=it?.seedanceEngine??Ie,Kt=it?.videoDuration??Re,pt=(0,s.useMemo)(()=>q(Kt,"480p",Vt),[q,Kt,Vt]),Pt=(0,s.useMemo)(()=>q(Kt,"720p",Vt),[q,Kt,Vt]),Zt=(0,s.useMemo)(()=>q(Kt,"1080p",Vt),[q,Kt,Vt]),Sr=(0,s.useMemo)(()=>q(Kt,"4k",Vt),[q,Kt,Vt]),[lr,It]=(0,s.useState)(!1),[pa,Ut]=(0,s.useState)(null),[cr,vt]=(0,s.useState)([]);(0,s.useRef)(null),(0,s.useEffect)(()=>{if(!t?.id)return;let a=!1;return(async()=>{if(await Oi(t.id),a)return;const d=await Qs(t.id);a||vt(d)})(),()=>{a=!0}},[t?.id]);const Rr=(0,s.useRef)(null);(0,s.useEffect)(()=>{Rr.current=it?.sessionId??null},[it?.sessionId]);const dr=(0,s.useRef)(!1);(0,s.useEffect)(()=>{dr.current=lr},[lr]);const ur=(0,s.useCallback)((a,c)=>{vt(d=>d.filter(u=>u.sessionId!==a)),dr.current||xe.success(o("ìì ìì±","åç»å®æ","Video Ready"),{description:o("ìì´ì í¸ ììì´ ìì±ëììµëë¤. ë´ ìì íìì íì¸íì¸ì.","ã¨ã¼ã¸ã§ã³ãåç»ã宿ãã¾ããããã¤åç»ã¿ãã§ç¢ºèªãã¦ãã ããã","Your agent video is ready. Check the history tab.")})},[o]);(0,s.useEffect)(()=>{if(!t?.id)return;const a=setInterval(async()=>{const c=await Qs(t.id);vt(d=>{const u=Rr.current;if(!u)return c;const k=d.find(w=>w.sessionId===u);return k?c.map(w=>w.sessionId===u?k:w):c})},1e4);return()=>clearInterval(a)},[t?.id]);const Hr=(0,s.useRef)(null),Wt=(0,s.useRef)(new Set),i=(0,s.useCallback)(async a=>{if(!t?.id||Wt.current.has(a))return;Hr.current=a;const c=await Di(t.id,a);if(Hr.current===a&&!Wt.current.has(a))if(c?.sessionInput){const d={...c.sessionInput};c.state?.heroImageUrl&&!d.presetHeroImageUrl&&(d.presetHeroImageUrl=c.state.heroImageUrl),d.seedanceEngine=Si(d.seedanceEngine,U),ir(d),Ut(null),It(!0)}else vt(d=>d.filter(u=>u.sessionId!==a)),Wt.current.add(a),setTimeout(()=>Wt.current.delete(a),3e4),xe.error(o("ì¸ì
ì ë¶ë¬ì¬ ì ìì´ì","ã»ãã·ã§ã³ãèªã¿è¾¼ãã¾ãã","Session unavailable"),{description:o("ì´ ìì´ì í¸ ì¸ì
ì ë³µìì íìí ë°ì´í°ê° ëë½ëìê±°ë ë§ë£ëì´ì. ì ì¸ì
ì¼ë¡ ë¤ì ììí´ ì£¼ì¸ì.","ãã®ã¨ã¼ã¸ã§ã³ãã»ãã·ã§ã³ã¯å¾©å
ã«å¿
è¦ãªãã¼ã¿ãæ¬ æãã¦ãããæéåãã§ããæ°ããã»ãã·ã§ã³ã§åéãã¦ãã ããã","This agent session cannot be restored (missing or expired data). Please start a new session.")})},[t?.id,o,U]),m=(0,s.useCallback)(async a=>{if(!t?.id)return;const c=a?.image_url;if(c)try{const{data:d,error:u}=await ve.from("user_tasks").select("task_id").eq("user_id",t.id).eq("result_url",c).like("task_id","shorts-agent-session:%").order("created_at",{ascending:!1}).limit(1).maybeSingle();if(u)throw u;
116const k=d?.task_id,w=k?.startsWith("shorts-agent-session:")?k.slice(21):null;if(!w){xe.error(o("ìì ì ììí ì ìì´ì","ç·¨éãéå§ã§ãã¾ãã","Can't start editing"),{description:o("ì´ ììì ì본 ìì´ì í¸ ì¸ì
ì ì°¾ì§ ëª»íì´ì. ë³´ê´ ê¸°ê°ì´ ì§ë¬ê±°ë ë¤ë¥¸ ê²½ë¡ë¡ ë§ë ììì¼ ì ìì´ì.","ãã®åç»ã®å
ã®ã¨ã¼ã¸ã§ã³ãã»ãã·ã§ã³ãè¦ã¤ããã¾ããã§ãããä¿åæéãéããããå¥ã®çµè·¯ã§ä½æãããå¯è½æ§ãããã¾ãã","We couldn't find the original agent session for this video. It may have expired or been created through a different flow.")});return}B("templates"),await i(w)}catch(d){pe.error("[shorts] remake lookup failed",d),xe.error(o("ìì ì ììí ì ìì´ì","ç·¨éãéå§ã§ãã¾ãã","Can't start editing"),{description:o("ì ì í ë¤ì ìëí´ ì£¼ì¸ì.","ãã°ãããã¦ããå試è¡ãã¦ãã ããã","Please try again in a moment.")})}},[t?.id,o,i]),[g,b]=(0,s.useState)([]),{addTask:C,updateTaskProgress:T,updateTaskStatus:E,updateTaskApiId:z,completeTask:y,failTask:j,tasks:M}=jo(),{startPolling:Q}=si(ot,()=>Ke,()=>Ke,b,()=>{pe.log("ð¨ [ShortsAgentView] Task completed via shared hook")}),ke=(0,s.useMemo)(()=>M.filter(a=>(a.status==="generating"||a.status==="waiting")&&a.generationOptions?.task_type==="shorts"&&a.generationOptions?.ad_workflow!=="video_agent_session"),[M]),ae=(0,s.useCallback)(a=>{},[]),Pe=(0,s.useCallback)(a=>{const c=new Image;c.onload=()=>me({width:c.naturalWidth,height:c.naturalHeight}),c.src=a},[]),Te=(0,s.useCallback)(a=>{if(!a)return"1:1";const c=a.width/a.height,d=[["1:1",1],["16:9",16/9],["9:16",9/16],["4:3",4/3],["3:4",3/4],["3:2",3/2],["2:3",2/3],["21:9",21/9]];let u="1:1",k=1/0;for(const[w,L]of d){const ne=Math.abs(c-L);ne<k&&(k=ne,u=w)}return u},[]),St=(0,s.useCallback)(a=>a&&["16:9","9:16","1:1","4:3","3:4","21:9","adaptive"].includes(a)?a:a==="3:2"?"16:9":a==="2:3"?"9:16":"16:9",[]),Tt=(0,s.useCallback)(a=>new Promise(c=>{try{const d=new Image;d.crossOrigin="anonymous",d.onload=()=>{if(!d.naturalWidth||!d.naturalHeight)return c(null);c(Te({width:d.naturalWidth,height:d.naturalHeight}))},d.onerror=()=>c(null),d.src=a}catch{c(null)}}),[Te]),Ht=(0,s.useCallback)(async a=>{const u=URL.createObjectURL(a);let k;try{k=await new Promise((le,he)=>{const Be=new Image;Be.onload=()=>le(Be),Be.onerror=()=>he(new Error("image load failed")),Be.src=u})}catch{return URL.revokeObjectURL(u),a}const w=k.naturalWidth,L=k.naturalHeight;if(!(w>2048||L>2048||a.size>4194304))return URL.revokeObjectURL(u),a;const ne=Math.min(2048/w,2048/L,1),Z=Math.round(w*ne),we=Math.round(L*ne),de=document.createElement("canvas");de.width=Z,de.height=we;const be=de.getContext("2d");if(!be)return URL.revokeObjectURL(u),a;be.drawImage(k,0,0,Z,we),URL.revokeObjectURL(u);const oe=a.type==="image/png";let Y=await new Promise(le=>de.toBlob(le,oe?"image/png":"image/jpeg",oe?void 0:.85));if(!Y||Y.size>4194304){const le=await new Promise(he=>de.toBlob(he,"image/jpeg",.85));le&&(!Y||le.size<Y.size)&&(Y=le)}if(Y&&Y.size>4194304&&Y.type==="image/jpeg"){const le=await new Promise(he=>de.toBlob(he,"image/jpeg",.7));le&&le.size<Y.size&&(Y=le)}if(!Y)return a;const He=Y.type==="image/png"?".png":".jpg",ze=a.name.replace(/\.[^.]+$/,"")+He;return pe.log("ðï¸ [AD-UPLOAD] ìë 리ì¬ì´ì¦:",{ì본:`${w}x${L}, ${(a.size/1024/1024).toFixed(2)}MB, ${a.type}`,ê²°ê³¼:`${Z}x${we}, ${(Y.size/1024/1024).toFixed(2)}MB, ${Y.type}`}),new File([Y],ze,{type:Y.type})},[]),er=(0,s.useCallback)(async(a,c)=>{if(!t){xe.warning(o("ë¡ê·¸ì¸ íì","ãã°ã¤ã³å¿
è¦","Login Required"),{description:o("ì´ë¯¸ì§ë¥¼ ì
ë¡ëíë ¤ë©´ ë¡ê·¸ì¸ì´ íìí©ëë¤.","ç»åãã¢ãããã¼ãããã«ã¯ãã°ã¤ã³ãå¿
è¦ã§ãã","Please log in to upload images.")}),S();return}if(!zl.includes(a.type)){xe.error(o("ì§ìíì§ ìë íì¼ íì","ãµãã¼ãããã¦ããªããã¡ã¤ã«å½¢å¼","Unsupported file type"),{description:o("JPEG, PNG, WebP, GIF ì´ë¯¸ì§ë§ ì
ë¡ëí ì ìì´ì. (SVGë ë³´ìì ì ì¸)","JPEGãPNGãWebPãGIFç»åã
116®ã¿ã¢ãããã¼ãã§ãã¾ããï¼SVGã¯ã»ãã¥ãªãã£ä¸é¤å¤ï¼","Only JPEG, PNG, WebP, and GIF images are supported. (SVG is blocked for security.)")});return}if(a.size>_a){xe.error(o("íì¼ì´ ë무 커ì","ãã¡ã¤ã«ã大ãããã¾ã","File too large"),{description:o(`ìµë ${_a/1024/1024}MBê¹ì§ ì
ë¡ë ê°ë¥í´ì. íì¬ íì¼: ${(a.size/1024/1024).toFixed(1)}MB`,`æå¤§${_a/1024/1024}MBã¾ã§ã¢ãããã¼ãå¯è½ã§ããç¾å¨ã®ãã¡ã¤ã«: ${(a.size/1024/1024).toFixed(1)}MB`,`Maximum size is ${_a/1024/1024}MB. Your file: ${(a.size/1024/1024).toFixed(1)}MB`)});return}if(a.size<1024){xe.error(o("íì¼ì´ ë무 ììì","ãã¡ã¤ã«ãå°ãããã¾ã","File too small"),{description:o("1KB ì´ìì ì´ë¯¸ì§ë¥¼ ì¬ë ¤ì£¼ì¸ì.","1KB以ä¸ã®ç»åãã¢ãããã¼ããã¦ãã ããã","Please upload an image larger than 1KB.")});return}try{const u=await Ms(a);if(!u.valid){let k,w;const L=u.ratio.toFixed(2);u.reason==="too_small"?(k=o("ì´ë¯¸ì§ í´ìëê° ë무 ììµëë¤","ç»åè§£å度ãå°ãããã¾ã","Image resolution too small"),w=o(`${u.width}Ã${u.height}px â ê°ë¡Â·ì¸ë¡ 모ë 300px ì´ìì´ì´ì¼ í©ëë¤.`,`${u.width}Ã${u.height}px â 縦横ã¨ãã«300px以ä¸å¿
è¦ã§ãã`,`${u.width}Ã${u.height}px â both width and height must be at least 300px.`)):u.reason==="too_large"?(k=o("ì´ë¯¸ì§ í´ìëê° ë무 í½ëë¤","ç»åè§£å度ã大ãããã¾ã","Image resolution too large"),w=o(`${u.width}Ã${u.height}px â ê°ë¡Â·ì¸ë¡ 모ë ${Fa}px ì´íì¬ì¼ í©ëë¤.`,`${u.width}Ã${u.height}px â 縦横ã¨ãã«${Fa}px以ä¸å¿
è¦ã§ãã`,`${u.width}Ã${u.height}px â both width and height must be at most ${Fa}px.`)):(k=o("ì´ë¯¸ì§ ë¹ì¨ì´ íì© ë²ì를 ë²ì´ë¬ìµëë¤","ç»åæ¯çã許容ç¯å²å¤ã§ã","Image aspect ratio out of range"),w=o(`${u.width}Ã${u.height}, ë¹ì¨ ${L} â íì© ë¹ì¨ ${Wr} ~ ${Jr}.`,`${u.width}Ã${u.height}ãæ¯ç${L} â 許容æ¯ç${Wr}ï½${Jr}.`,`${u.width}Ã${u.height}, ratio ${L} â allowed ${Wr} ~ ${Jr}.`)),xe.error(k,{description:w});return}}catch{}try{a=await Ht(a)}catch{}const d=new FileReader;d.onload=u=>{const k=u.target?.result;c==="product"?(bt(w=>w.length<Me?[...w,k]:w),Pe(k)):c==="face"?Nt(k):wt(k)},d.readAsDataURL(a)},[S,t,Pe,Ht,o]),Et=(0,s.useCallback)(a=>{a.preventDefault(),Array.from(a.dataTransfer.files).slice(0,Me).forEach(c=>er(c,"product"))},[er]);(0,s.useCallback)(a=>{a.preventDefault();const c=a.dataTransfer.files[0];c&&er(c,"face")},[er]),(0,s.useCallback)(a=>{a.preventDefault();const c=a.dataTransfer.files[0];c&&er(c,"logo")},[er]);const $r=(0,s.useCallback)(async(a,c)=>{try{const d=await Ms(a);if(d.reason==="too_small"||d.reason==="too_wide"||d.reason==="too_tall"){const u=d.ratio.toFixed(2);d.reason==="too_small"?xe.error(o("ì´ë¯¸ì§ í´ìëê° ë무 ììµëë¤","ç»åè§£å度ãå°ãããã¾ã","Image resolution too small"),{description:o(`${d.width}Ã${d.height}px â ê°ë¡Â·ì¸ë¡ 모ë 300px ì´ìì´ì´ì¼ í©ëë¤.`,`${d.width}Ã${d.height}px â 縦横ã¨ãã«300px以ä¸å¿
è¦ã§ãã`,`${d.width}Ã${d.height}px â both width and height must be at least 300px.`)}):xe.error(o("ì´ë¯¸ì§ ë¹ì¨ì´ íì© ë²ì를 ë²ì´ë¬ìµëë¤","ç»åæ¯çã許容ç¯å²å¤ã§ã","Image aspect ratio out of range"),{description:o(`${d.width}Ã${d.height}, ë¹ì¨ ${u} â íì© ë¹ì¨ ${Wr} ~ ${Jr}.`,`${d.width}Ã${d.height}ãæ¯ç${u} â 許容æ¯ç${Wr}ï½${Jr}.`,`${d.width}Ã${d.height}, ratio ${u} â allowed ${Wr} ~ ${Jr}.`)});return}}catch{}c==="product"?(bt(d=>d.length<Me?[...d,a]:d),Pe(a)):c==="face"?Nt(a):wt(a)},[o,Pe]),ra=(0,s.useCallback)((a,c)=>{if(!a)return"";let d=Xt(a.promptTemplate);return a.category==="fashion_film"&&(d+=" The model must be Korean, with hair, makeup, and overall styling that naturally match the mood and atmosphere of the scene. Shot on a mirrorless camera with a prime lens ??shallow depth of field, professional bokeh, sharp micro-textures on fabric and skin. Professional color depth and dynamic range. Do NOT look like a phone camera photo."),a.tone==="hold_explain"&&(d+=" CAPTURE STYLE (mandatory): authentic iPhone handheld look â KEEP the framing shown in the reference image (a selfie close-up, a full-body standing shot, or the product placed in the scene â do not force it into an arm-extended selfie), available ambient light only, realistic smartphone HDR, natural visible skin texture, deep phone-camera depth of field with the background in focus. NOT studio lighting, NOT a professional photoshoot, NOT DSLR bokeh, NOT retouched commercial polish."),c.trim()?Xt(`${d} Additionally: ${c.trim()}`):d},[]),Dt=(0,s.useCallback)(async(a,c)=>{if(a.length===0)throw new Error("No product image");if(!t?.id)throw new Error("User not authenticated");const d=576,u=1408,k=async(L,ne,Z)=>
116{if(L.startsWith("http")&&!L.startsWith("data:"))return L;const we=await new Promise((He,ze)=>{const le=new Image;le.crossOrigin="anonymous",le.onload=()=>{let he=le.width,Be=le.height;if(he>u||Be>u){const qe=Math.min(u/he,u/Be);he=Math.round(he*qe),Be=Math.round(Be*qe)}if(he<d||Be<d){const qe=Math.max(d/he,d/Be);he=Math.round(he*qe),Be=Math.round(Be*qe),he>u&&(he=u),Be>u&&(Be=u)}const tt=document.createElement("canvas");tt.width=he,tt.height=Be,tt.getContext("2d").drawImage(le,0,0,he,Be),tt.toBlob(qe=>qe?He(qe):ze(new Error("Canvas toBlob failed")),"image/png")},le.onerror=()=>ze(new Error("Image load failed")),le.src=L}),de=new File([we],`ad-${Z}-${Date.now()}-${ne}.png`,{type:"image/png"}),be=`user-${t.id}/bbanana/${de.name}`,{error:oe}=await ve.storage.from("public-assets").upload(be,de,{upsert:!0});if(oe)throw new Error(`Upload failed: ${oe.message}`);const{data:Y}=ve.storage.from("public-assets").getPublicUrl(be);return Z==="face"&&_r.current.add(Y.publicUrl),Y.publicUrl},w=[];for(let L=0;L<a.length;L++)w.push(await k(a[L],L,"product"));return c&&w.push(await k(c,a.length,"face")),w},[t]);(0,s.useCallback)(()=>{if(!ce)return"";let a=Xt(ce.promptTemplate);return ce.category==="fashion_film"&&(a+=" The model must be Korean, with hair, makeup, and overall styling that naturally match the mood and atmosphere of the scene. Shot on a mirrorless camera with a prime lens â shallow depth of field, professional bokeh, sharp micro-textures on fabric and skin. Professional color depth and dynamic range. Do NOT look like a phone camera photo."),Fe.trim()?Xt(`${a} Additionally: ${Fe.trim()}`):a},[ce,Fe]);const Is=(0,s.useCallback)(()=>Dt(Ae,Ue),[Dt,Ae,Ue]),Ss=(0,s.useCallback)(()=>ra(ce,Fe),[ra,ce,Fe]),[js,$n]=(0,s.useState)(!1),Mn=(0,s.useCallback)(async()=>{if(l){Mr(null),xe.info(o("ì°ìµì© íë©´ì
ëë¤","ç·´ç¿ç¨ã®ç»é¢ã§ã","This is a practice screen"),{description:o("ì´ í¸ììë ì¤í ë²í¼ì¼ë¡ ì¼ì¸ ë§ëë ê³¼ì ë§ ë°ë¼ê° ë´
ëë¤.","ããã§ã¯å®è¡ãã¿ã³ã§ã·ã§ã¼ãå¶ä½ã®æµãã ããä½é¨ãã¾ãã","Here you only walk through making shorts with the run button.")});return}if(Ae.length===0&&!Fe.trim()||!ce){xe.error(o("ì
ë ¥ ì¤ë¥","å
¥åã¨ã©ã¼","Input Error"),{description:o("ì í ì´ë¯¸ì§ ëë ìë¹ì¤ ì¤ëª
ì ì
ë ¥í´ ì£¼ì¸ì.","製åç»åã¾ãã¯ãµã¼ãã¹èª¬æãå
¥åãã¦ãã ããã","Please upload a product image or enter a service description.")});return}if(!t?.id){xe.warning(o("ë¡ê·¸ì¸ íì","ãã°ã¤ã³å¿
è¦","Login Required"),{description:o("ìì±íë ¤ë©´ ë¡ê·¸ì¸ì´ íìí©ëë¤.","çæããã«ã¯ãã°ã¤ã³ãå¿
è¦ã§ãã","Please log in to generate.")}),S();return}const a=ce,c=[...Ae],d=Ue,u=Fe.trim(),k=Ct,w=Ft,L=Gt,ne=Je;gt(null),B("history"),$n(!1),bt([]),Nt(null),wt(null),me(null),Qt("");const Z=`local_${Date.now()}`,we="evolink";C(Z,Z,"GPT Image 2","GPT Image 2",Xt(a.promptTemplate),"image",void 0,k==="auto"?Te(ne):k,"waiting",5,{provider:we,task_type:ot,preset_name:a.name,client_task_id:Z}),(async()=>{try{T(Z,5,o("ì´ë¯¸ì§ ì
ë¡ë ì¤...","ç»åãã¢ãããã¼ãä¸...","Uploading images..."));const de=await Is(),be=de[0],oe=d&&de.length>c.length?de[de.length-1]:void 0,Y=Fr(a.previewImage),He=[];Y&&(He.push(Y),pe.log("ð¸ [ShortsAgentView] Template reference image:",Y)),He.push(...de),T(Z,15,o("AI í롬íí¸ ìµì í ì¤...","AIããã³ãããæé©åä¸...","Optimizing prompt..."));let ze=Ss();try{pe.log("ð§ [ShortsAgentView] Adapting prompt via Claude...");const{data:qe,error:Ot}=await ve.functions.invoke("adapt-ad-prompt",{body:{productImageUrl:be,presetPromptTemplate:a.promptTemplate,presetName:a.name,category:a.category,faceImageUrl:oe,customPrompt:u||void 0,templateReferenceImageUrl:Y}});!Ot&&qe?.success&&qe?.adaptedPrompt&&(ze=Xt(qe.adaptedPrompt),pe.log("â
[ShortsAgentView] Adapted prompt:",ze.substring(0,120)+"..."))}catch{}E(Z,"generating"),T(Z,25,o("ì´ë¯¸ì§ ìì± ìì² ì¤...","ç»åçæããªã¯ã¨ã¹ãä¸...","Requesting generation..."));const le={model_id:"8fb8755a-f16a-4240-ad9c-0699be359700",model_key:"gpt-image-2",provider_name:we,service_name:"GPT Image 2",mode:"editing",prompt:ze,image_urls:He,has_image:!0,size:k==="auto"?Te(ne):k,resolution:w,quality:"medium",excludeProviders:["atlas"],output_format:L,preset_name:a.name,task_type:ot,generationOptions:{provider:we,task_type:ot,preset_name:a.name,client_task_id:Z}};pe.log("ð¨ [ShortsAgentView] Payload:",JSON.stringify(le));const{data:he,error:Be}=await Tr(le);if(Be||!he?.success)throw new Error(he?.error||Be?.message||"Generation failed");const tt=he?.imageUrl||(Array.isArray(he?.images)&&he.images.length>0?he.images[0]:null)||he?.data?.imageUrl;if(tt&&typeof tt=="string"&&tt.startsWith("http"))y(Z,tt),xe.success("⨠"+o("AD ìì± ìë£!","ADçæå®äº!","AD Generation Complete!"),{description:a.name}),t?.id&&ve.from("user_image_library").update({task_type:ot,preset_name:a.name,service_name:Ke}).eq("user_id",t.id).eq("image_url",tt).is("deleted_at",null).then(()=>{});else{const qe=he?.taskId||he?.data?.data?.taskId,Ot=he?.provider||we;if(qe){z(Z,qe);const Xe={provider:Ot,task_type:ot,preset_name:a.name,client_task_id:Z};Q(Z,qe,ze,5,Ke,Ke,void 0,a.name,Xe)}}}catch(de){j(Z,de.message),xe.error(o("ìì± ì¤í¨","çæå¤±æ","Generation Failed"),{description:de.message})}})()},[l,Ae,Ue,ce,t,Is,Ss,Je,Te,Ct,Ft,Gt,C,T,E,z,y,j,Q,S,Fe,o]),tr=(0,s.useCallback)(async(a,c)=>{try{const d=a?.context;if(d&&typeof d.clone=="function"&&typeof d.json=="function"){const u=await d.clone().json();if(u?.insufficientCredits){const k=typeof u.available=="number"?u.available:0,w=typeof u.required=="number"?u.required:0;return f(w),o(`í¬ë ë§ì´ ë¶ì¡±í©ëë¤. (ë³´ì ${k} / íì ${w})`,`ã¯ã¬ã¸ãããä¸è¶³ãã¦ãã¾ããï¼ä¿æ${k} / å¿
è¦${w}ï¼`,`Insufficient credits. (available ${k} / required ${w})`)}if(typeof u?.error=="string"&&u.error.trim())return u.error}}catch{}return a?.message||c},[h,f]),Ea=(0,s.useRef)(new Map),Un=(0,s.useCallback)(async a=>{if(l){const u=oa(Yr.heroImage),k=Yr.productImages.map(oa).filter(w=>!!w);if(u)return await new Promise(w=>{setTimeout(w,2400)}),{heroImageUrl:u,productImageUrls:k}}if(!t?.id)throw new Error(o("ë¡ê·¸ì¸ì´ íìí©ëë¤.","ãã°ã¤ã³ãå¿
è¦ã§ãã","Login is required."));const c=Ea.current.get(a.sessionId);if(c)return pe.log("ð [createRepImage] In-flight hero gen detected for session",a.sessionId,"â reusing existing promise"),c;const d=(async()=>{const u=`ad-hero-lock-${a.sessionId}`,k=(()=>{try{return JSON.parse(localStorage.getItem(u)||"null")}catch{return null}})();if(k?.taskId){pe.log("ð [createRepImage] 기존 hero task 복구 ìë:",k.taskId);try{const{data:Xe}=await ve.from("user_tasks").select("status, result_url").eq("task_id",k.taskId).maybeSingle();if(Xe?.status==="completed"&&Xe?.result_url)return pe.log("â
[createRepImage] 기존 hero task ìë£ â 복구:",Xe.result_url),localStorage.removeItem(u),{heroImageUrl:Xe.result_url,productImageUrls:k.productImageUrls||[],faceImageUrl:k.faceImageUrl};
116if(Xe?.status==="processing"){pe.log("â³ [createRepImage] 기존 hero task ì§í ì¤ â í´ë§ ì¬ê°:",k.taskId);const At=k.provider||await Ha(k.taskId),zt=Date.now();let Ge=null;for(;!Ge&&Date.now()-zt<ss();){const Yt=await za(k.taskId,At,"GPT Image 2","GPT Image 2");if(Yt.status==="completed"){Ge=la(Yt.result);break}if(Yt.status==="failed")throw localStorage.removeItem(u),new Error(Yt.error||"Hero image generation failed.");await ns(as)}if(Ge)return localStorage.removeItem(u),{heroImageUrl:Ge,productImageUrls:k.productImageUrls||[],faceImageUrl:k.faceImageUrl}}localStorage.removeItem(u)}catch{localStorage.removeItem(u)}}if(pe.log("ð¼ï¸ [createRepImage] agentSession images:",{productImages:a.productImages,productImagesCount:a.productImages?.length??0,faceImage:a.faceImage}),!((a.productImages?.length??0)>0)){pe.log("ð¼ï¸ [createRepImage] No product images â text-only service mode");const Xe=ra(a.preset,""),At=a.preset.category||"service",zt=Fr(a.preset.previewImage),Ge=a.highlights?`This is a service advertisement (no physical product). The service/brand being advertised: ${a.highlights}. If the template reference image shows a model holding or displaying a physical product, REMOVE the product entirely and instead have the model pose or gesture in a way that naturally represents this service concept (e.g. using a phone, pointing at something, confident lifestyle pose). Create a hero image that visually represents this service concept.`:"This is a service advertisement (no physical product). If the template reference image shows a model holding or displaying a physical product, REMOVE the product entirely and instead have the model in a natural, service-appropriate pose or lifestyle gesture. Create an evocative conceptual hero image based purely on the template's visual direction.",Yt=zt?[zt]:[];let Pr=Xt(`Professional ì¼ì¸ ${At} advertisement photograph. Use this registered template prompt as the primary creative direction: ${Xe}. Keep the template's camera composition, framing, lens feel, focal length, background, set dressing, props, mise-en-scene, lighting, texture, grain, color grading, and overall atmosphere. `+(zt?"The reference image is the template scene guide â use it only for atmosphere and composition, do NOT keep any product or person from it. ":"")+`Do NOT integrate any product object into the scene. ${Ge} Cinematic 8K quality, premium commercial photography. ${Ba} No watermarks, no product packaging.`);try{const{data:rr,error:Kr}=await ve.functions.invoke("adapt-ad-prompt",{body:{presetPromptTemplate:Xe,presetName:a.preset.name,category:a.preset.category,customPrompt:a.highlights||void 0,templateReferenceImageUrl:zt,serviceOnlyMode:!0}});!Kr&&rr?.success&&rr?.adaptedPrompt&&(Pr=Xt(`${rr.adaptedPrompt} ${Ge} Do NOT include any physical product object.`.trim()))}catch{}const Br=a.aspectRatio==="auto"?Te(a.imageDimensions):a.aspectRatio,{data:Rt,error:Dr}=await Tr({model_id:"8fb8755a-f16a-4240-ad9c-0699be359700",model_key:"gpt-image-2",provider_name:"evolink",service_name:"GPT Image 2",mode:Yt.length>0?"editing":"generation",prompt:Pr,image_urls:Yt,has_image:Yt.length>0,size:Br,resolution:a.resolution,quality:"medium",excludeProviders:["atlas"],output_format:a.outputFormat,preset_name:a.preset.name,task_type:ot,generationOptions:{provider:"evolink",task_type:ot,preset_name:a.preset.name,ad_workflow:"video_agent_hero"}});if(Dr||!Rt?.success){const rr="Hero image generation failed (text-only mode)",Kr=Dr?await tr(Dr,rr):Rt?.error||rr;throw new Error(Kr)}let Or=la(Rt);if(!Or){const rr=cn(Rt);if(!rr)throw new Error(o("ëí ì´ë¯¸ì§ task ID를 ë°ì§ 못íìµëë¤.","ãã¼ãã¼ç»åã®ã¿ã¹ã¯IDãè¿ããã¾ããã§ããã","Hero image task ID was not returned."));const Kr=typeof Rt?.provider=="string"&&Rt.provider.trim()?Rt.provider:await Ha(rr);localStorage.setItem(u,JSON.stringify({taskId:rr,provider:Kr,productImageUrls:[],faceImageUrl:void 0}));const to=Date.now();for(;!Or&&Date.now()-to<ss();){const xa=await za(rr,Kr,"GPT Image 2","GPT Image 2");if(xa.status==="completed"){Or=la(xa.result);break}if(xa.status==="failed")throw localStorage.removeItem(u),new Error(xa.error||"Hero image generation failed.");await ns(as)}}if(!Or)throw new Error(o("ëí ì´ë¯¸ì§ ìì±ì´ ì§ì°ëê³ ììµëë¤.","ãã¼ãã¼ç»åã®çæãé
ãã¦ãã¾ãã","Hero image generation timed out."));return localStorage.removeItem(u),{heroImageUrl:Or,productImageUrls:[],faceImageUrl:void 0}}const w=await Dt(a.productImages,a.faceImage);pe.log("ð¼ï¸ [createRepImage] uploadedUrls:",w),w[0];const L=w.slice(0,a.productImages.length),ne=a.faceImage&&w.length>a.productImages.length?w[w.length-1]:void 0,Z=Fr(a.preset.previewImage),we=[...L,...ne?[ne]:[],...Z?[Z]:[]];pe.log("ð¼ï¸ [createRepImage] final referenceImages:",we);const de=ra(a.preset,"");a.preset.category;const be=L.length>1?`The first ${L.length}
116 reference images are user-provided product photos from multiple angles. Use them as the actual product source and preserve the exact packaging, labels, logo, colors, and structure.`:"The first reference image is the user-provided product photo. Use it as the actual hero product and preserve the exact packaging, labels, logo, colors, and structure.",oe=ne?L.length>1?"The next reference image is the user-provided model face. Use this exact person if a human appears, matching facial features, skin tone, and likeness closely.":"The second reference image is the user-provided model face. Use this exact person if a human appears, matching facial features, skin tone, and likeness closely.":"",Y=Z?"The last reference image is THE INFLUENCER. Keep ONLY that person â the same face, hair character, age feel and overall look, so viewers recognise the same creator. Everything else MUST change to suit this product: choose a different location, different wardrobe, different props and time of day. Do NOT reuse that image's setting or outfit, and do not keep its original product.":"",He=a.highlights?`Additional user guidance to weave in naturally: ${a.highlights}.`:"",ze="The product must appear exactly as photographed in its reference: same closure and cap state, nothing attached or inserted that the photo does not show â no straw, spoon, ribbon, sticker or accessory added to it.",le="If the product reference reveals a clear brand or accent color, echo that point color naturally through selected props, wardrobe accents, background accents, styling details, or lighting cues so the hero image feels tonally aligned to the product. Keep it tasteful and template-appropriate rather than flooding the whole frame with that color.";let he="";he=Xt(`Vertical 9:16 product advertising photograph for a short-form video. ${be} ${zs} ${oe} ${Y} Build a scene that genuinely suits THIS product â pick the location, wardrobe and props a real person would naturally have around them when using it. Only the influencer's face and identity carry over from the reference; the place and the outfit are chosen fresh for this product. The person is Korean, fully clothed in ordinary everyday wear appropriate to that setting, holding or using the product naturally. ${le} ${He} Clean modern commercial quality. ${Ba} ${ze}`),a.preset.id?.startsWith("auto_")&&(he=Xt(`${de} ${be} ${zs} ${oe} ${le} ${He} ${ze} ${Ba}`.trim()),pe.log("ðï¸ [createRepImage] Auto-concept preset â using recipe-driven hero scene prompt as-is")),he=$l(he);const Be=a.aspectRatio==="auto"?Te(a.imageDimensions):a.aspectRatio,tt={model_id:"8fb8755a-f16a-4240-ad9c-0699be359700",model_key:"gpt-image-2",provider_name:"evolink",service_name:"GPT Image 2",mode:"editing",prompt:he,image_urls:we,has_image:!0,size:Be,resolution:a.resolution,quality:"medium",excludeProviders:["atlas"],output_format:a.outputFormat,preset_name:a.preset.name,task_type:ot,generationOptions:{provider:"evolink",task_type:ot,preset_name:a.preset.name,ad_workflow:"video_agent_hero"}};let qe=null;for(let Xe=0;Xe<2;Xe++){const At=await Tr(tt);if(!At.error&&At.data?.success){qe=At.data;break}const zt="Representative image generation failed",Ge=At.error?await tr(At.error,zt):At.data?.error||zt;if(Xe===0&&es(Ge)){pe.warn("ð¡ï¸ [createRepImage] 모ëë ì´ì
ê±°ë¶ â í롬íí¸ ê°í í ì¬ìë"),tt.prompt=Ml(tt.prompt);continue}throw new Error(es(Ge)?o("ì´ë¯¸ì§ê° ìì ì ì±
ì ê±¸ë ¤ ìì±ëì§ ìììµëë¤. í롬íí¸ë¥¼ ìëì¼ë¡ ìíí´ í ë² ë ìëíì§ë§ íµê³¼íì§ ëª»íì´ì. ë¤ë¥¸ ì¸í루ì¸ì를 ê³¨ë¼ ë¤ì ìëí´ ì£¼ì¸ì.","ç»åãå®å
¨ããªã·ã¼ã«æµè§¦ãã¦çæã§ãã¾ããã§ãããããã³ãããèªåã§èª¿æ´ãã¦å試è¡ãã¾ãããéãã¾ããã§ãããå¥ã®ã¤ã³ãã«ã¨ã³ãµã¼ãé¸ãã§ã試ããã ããã","The image was blocked by the safety policy. We softened the prompt and retried once, but it still did not pass. Please pick a different influencer and try again."):Ge)}let Ot=la(qe);if(!Ot){const Xe=cn(qe);if(!Xe)throw new Error(o("ëí ì´ë¯¸ì§ task ID를 ë°ì§ 못íìµëë¤.","ãã¼ãã¼ç»åã®ã¿ã¹ã¯IDãè¿ããã¾ããã§ããã","Representative image task ID w
116as not returned."));const At=typeof qe?.provider=="string"&&qe.provider.trim()?qe.provider:await Ha(Xe);localStorage.setItem(u,JSON.stringify({taskId:Xe,provider:At,productImageUrls:L,faceImageUrl:ne}));const zt=Date.now();for(;!Ot&&Date.now()-zt<ss();){const Ge=await za(Xe,At,"GPT Image 2","GPT Image 2");if(Ge.status==="completed"){if(Ot=la(Ge.result),!Ot)throw new Error(o("ëí ì´ë¯¸ì§ ìì±ì ìë£ëì§ë§ ê²°ê³¼ URLì ì°¾ì§ ëª»íìµëë¤.","代表ç»åã®çæã¯å®äºãã¾ããããçµæURLãè¦ã¤ããã¾ããã§ããã","Representative image generation completed, but no result URL was found."));break}if(Ge.status==="failed")throw localStorage.removeItem(u),new Error(es(Ge.error)?o("ì´ë¯¸ì§ê° ìì ì ì±
ì ê±¸ë ¤ ìì±ëì§ ìììµëë¤. ë¤ë¥¸ ì¸í루ì¸ì를 ê³¨ë¼ ë¤ì ìëí´ ì£¼ì¸ì.","ç»åãå®å
¨ããªã·ã¼ã«æµè§¦ãã¦çæã§ãã¾ããã§ãããå¥ã®ã¤ã³ãã«ã¨ã³ãµã¼ãé¸ãã§ã試ããã ããã","The image was blocked by the safety policy. Please pick a different influencer and try again."):Ge.error||o("ëí ì´ë¯¸ì§ ìì±ì ì¤í¨íìµëë¤.","代表ç»åã®çæã«å¤±æãã¾ããã","Representative image generation failed."));await ns(as)}}if(!Ot||typeof Ot!="string")throw new Error(o("ëí ì´ë¯¸ì§ ìì±ì´ ì§ì°ëê³ ììµëë¤. ì ì í ë¤ì ìëí´ ì£¼ì¸ì.","代表ç»åã®çæãé
ãã¦ãã¾ãããã°ãããã¦ããå試è¡ãã¦ãã ããã","Representative image generation is taking longer than expected. Please try again shortly."));return localStorage.removeItem(u),{heroImageUrl:Ot,productImageUrls:L,faceImageUrl:ne}})();Ea.current.set(a.sessionId,d);try{return await d}finally{Ea.current.delete(a.sessionId)}},[ra,Te,h,tr,Dt,t?.id]),aa=(0,s.useRef)(null),Dn=(0,s.useCallback)(async({session:a,heroImageUrl:c,productImageUrls:d,faceImageUrl:u,finalPrompt:k,storyboardDraft:w,quality:L="720p"})=>{if(l){const oe=oa(Yr.finalVideo);if(oe)return await new Promise(Y=>{setTimeout(Y,3400)}),{clientTaskId:`tutorial-shorts-${a.sessionId}`,resultUrl:oe}}const ne=a.videoDuration||Re,Z=a.seedanceEngine??"2.0",we=q(ne,L,Z),de=a.sessionId;if(aa.current===de)throw new Error("Video generation already in progress for this session");aa.current=de;let be;try{const oe=Ul(k),Y=`local_${Date.now()}`,He=Z==="2.5"?St(a.aspectRatio):a.aspectRatio==="16:9"?"16:9":"9:16";pe.log("ð¬ [startShortsVideoGeneration] aspect_ratio =",He);const ze=[c,...d,...u?[u]:[]].filter((Rt,Dr,Or)=>!!Rt&&Or.indexOf(Rt)===Dr),le=El,he=ze.slice(0,le),Be=ze.length-he.length;Be>0&&xe.warning(o(`참조 ì´ë¯¸ì§ë ìµë ${le}ì¥ê¹ì§ë§ ì¬ì©ë©ëë¤`,`åç
§ç»åã¯æå¤§${le}æã¾ã§ä½¿ç¨ããã¾ã`,`Only up to ${le} reference images are used`),{description:o(`ì í ì¬ì§ ${Be}ì¥ì ì ì¸íê³ ìì±í©ëë¤. ì¤ìí ì¬ì§ì ì쪽ì ëë ¤ë©´ ì í ì¬ì§ ì를 ì¤ì¬ 주ì¸ì.`,`åååç${Be}æãé¤ãã¦çæãã¾ããéè¦ãªåçãåªå
ããã«ã¯åååçã®ææ°ãæ¸ããã¦ãã ããã`,`Generating without ${Be} product photo(s). Reduce the number of product photos to prioritize the ones you need.`)});const tt={provider:"segmind",task_type:ot,preset_name:a.preset.name,client_task_id:Y,ad_workflow:"video_agent",image_urls:he,_sourceImageUrl:c,_sourceProductImageUrls:d};tt.video_engine="seedance-2",tt.duration=ne,tt.quality=L,tt.tier="pro",w&&(tt.ad_title=w.title||"",tt.ad_storyboard={title:w.title,conceptSummary:w.conceptSummary,cuts:w.cuts,narration:w.narration,dialogue:w.dialogue,directorNote:w.directorNote}),C(Y,Y,Ke,Ke,oe,"video",void 0,He,"waiting",we,tt),T(Y,10,o("ìì ìì± ìì ì¤...","åç»çæãéå§ä¸...","Starting video generation..."));const qe=ji(Z,ne),Ot={model_id:qe.model_id,model_key:qe.model_key,provider_name:"byteplus",force_provider:"byteplus",ad_channel:!0,service_name:qe.service_name,mode:"video",prompt:oe,has_image:!0},Xe=na(Ot,{aspect_ratio:He,duration:ne,quality:Ks(Z,ne,L),tier:"pro",generate_audio:!0,web_search:!1,use_omni:!0,seedance2_mode:"omni"},he);Xe.generationOptions=tt,Xe.task_type=ot,Xe.preset_name=a.preset.name,w?.title&&(Xe.display_name=w.title);const At=Tr(Xe),zt=new Promise((Rt,Dr)=>{be=setTimeout(()=>
116Dr(new Error(o("ìì 주문 ìê°ì´ ì´ê³¼ëììµëë¤. ë¤ì ìëí´ ì£¼ì¸ì.","åç»ãªã¯ã¨ã¹ããã¿ã¤ã ã¢ã¦ããã¾ãããããä¸åº¦ã試ããã ããã","Video request timed out. Please try again."))),12e4)}),{data:Ge,error:Yt}=await Promise.race([At,zt]);if(Yt||!Ge?.success){(Ge??Yt?.context?.data??null)?.insufficientCredits===!0&&f(we);const Rt=Ge?.error||Yt?.message||"Video generation failed";throw j(Y,Rt),new Error(Rt)}const Pr=Ge?.resultUrl||Ge?.videoUrl||Ge?.imageUrl||Ge?.data?.result_url||Ge?.data?.video_url;if(Pr&&typeof Pr=="string")return t?.id&&(async()=>{try{await ve.functions.invoke("download-bbanana-image",{body:{imageUrl:Pr,userId:t.id,mediaType:"video",modelName:Ot.service_name,mode:"video",taskId:Y,prompt:oe,presetName:a.preset.name,task_type:ot,generationOptions:tt}})}catch{}})(),y(Y,Pr),{clientTaskId:Y,resultUrl:Pr};const Br=Ge?.taskId||Ge?.data?.task_id||Ge?.data?.data?.taskId;if(!Br)throw j(Y,o("ìì task ID를 ìì íì§ ëª»íìµëë¤.","åç»ã¿ã¹ã¯IDãåä¿¡ã§ãã¾ããã§ããã","Video task ID was not returned.")),new Error(o("ìì task ID를 ìì íì§ ëª»íìµëë¤.","åç»ã¿ã¹ã¯IDãåä¿¡ã§ãã¾ããã§ããã","Video task ID was not returned."));return z(Y,Br),Q(Y,Br,oe,we,Ke,Ke,10,a.preset.name,tt),{clientTaskId:Y,apiTaskId:Br}}finally{clearTimeout(be),aa.current=null}},[C,y,j,Te,q,h,Tt,St,f,Q,z,T,Re,t?.id]),[Se,yr]=(0,s.useState)(null),[sa,Aa]=(0,s.useState)(null),[jr,Nr]=(0,s.useState)(!1),{row:lt}=xi(v),[On,Ns]=(0,s.useState)(null);(0,s.useEffect)(()=>{Ns(null)},[Se?.id]);const ha=Se?.shiftVariants?Se.shiftVariants.find(a=>a.key===On)??Se.shiftVariants[0]:null,ct=ha?.sourceUrl||Se?.shiftSourceVideoUrl||"";(0,s.useEffect)(()=>{if(!ct){Aa(null);return}let a=!0;return Aa(null),ki(ct).then(c=>{a&&Aa({url:ct,...c})}),()=>{a=!1}},[ct]);const nt=sa?.url===ct&&sa?.durationSec||0,br=Do(l?null:Xr),fa=mo(),mr=(0,s.useMemo)(()=>!br.hasGrant||br.dailyLimit!=null&&br.remainingToday<=0||Array.isArray(br.allowedSources)&&br.allowedSources.length>0?null:{maxQuality:br.maxQuality,eventName:br.eventName,maxDurationSec:br.maxDurationSec},[br]),Ra=ha?.templateKey||Se?.id,xr=(0,s.useCallback)(a=>!!mr&&(!mr.maxQuality||qs(a)<=qs(mr.maxQuality))&&Ga(mr.maxDurationSec,Ra,nt||null),[mr,Ra,nt]),ga=mr&&Ga(mr.maxDurationSec,Ra,nt||null)?mr:null,dt=ha?.templateKey||Se?.id,$a=(0,s.useCallback)((a,c,d,u)=>!lt||!(nt>0)?null:xr(c)?0:Pl({variants:lt.model_variants||[],quality:c,sourceSeconds:nt,templateKey:dt,mode:a,roles:d,isAdmin:v,hasPrompt:!!String(u??"").trim()}),[lt,nt,v,xr,dt]),Jt=(0,s.useRef)(!1),Ln=(0,s.useCallback)(async a=>{if(!Se||!lt||!t?.id)return;if(l){xe.info(o("ì°ìµ íë©´ììë ì¤ì ìì í¸ì§ì ììíì§ ììµëë¤.","ç·´ç¿ç»é¢ã§ã¯å®éã®åç»ç·¨éã¯éå§ãã¾ããã","Video edits are not started on the practice screen."));return}if(Jt.current)return;if(!(nt>0)){xe.error(o("ìì ì 보를 ì½ì§ 못íìµëë¤. ì ì í ë¤ì ìëí´ ì£¼ì¸ì.","åç»æ
å ±ãèªã¿åãã¾ããã§ããããã°ãããã¦ããããä¸åº¦ã試ããã ããã","Could not read the video details. Please try again shortly."));return}const c=$a(a.mode,a.quality,a.referenceRoles,a.userPrompt);if(c===null)return;Jt.current=!0,Nr(!0);const d=`local_${Date.now()}`;try{if(!await I(c)){f(c);return}const u=a.referenceImages.length>0?await Dt(a.referenceImages,null):[],k=Se.shiftSlots?.find(le=>le.role==="lead")?.wardrobe!=="replace",w=Object.fromEntries(An(Se).map(le=>[le.key,o(le.label.ko,le.label.ja,le.label.en)])),L=a.userPrompt||a.referenceRoles.map(le=>w[le]).join(" · "),ne=sa?.width||0,Z=sa?.height||0,we=ne>0&&Z>0?ne>Z?"16:9":ne<Z?"9:16":"1:1":"16:9",de=Math.min(30,Math.max(4,Math.round(nt))),be={provider:"byteplus",task_type:ot,preset_name:Se.name,client_task_id:d,ad_workflow:"shift_template",shift_template_key:dt,shift_template_roles:a.referenceRoles,shift_template_user_prompt:a.userPrompt,shift_mode:a.mode,shift_preserve_wardrobe:k,seedance25_mode:"edit",quality:a.quality,duration:de,input_video_duration:nt,aspect_ratio:we,generate_audio:!1,image_urls:u,_sourceVideoUrl:ct};C(d,d,Ke,Ke,L,"video",void 0,we,"waiting",c,be),T(d,10,o("ìì í¸ì§ ìì ì¤...","åç»ç·¨éãéå§ä¸...","Starting video edit..."));const oe=na({model_id:lt.id,provider_name:"byteplus",service_name:Xr,mode:"video",prompt:a.userPrompt,has_image:u.length>0,shift_template_key:dt,client_task_id:d},{aspect_ratio:we,duration:de,quality:a.quality,tier:"pro",generate_audio:!1,web_search:!1,use_omni:!1,seedance2_mode:"edit",shift_mode:a.mode,shift_preserve_wardrobe:k,input_video_duration:nt},u);va(oe,ct,null,nt),oe.generationOptions=be,oe.task_type=ot,oe.preset_name=Se.name,oe.shift_template_key=dt,oe.shift_template_roles=a.referenceRoles;const{data:Y,error:He}=await Tr(oe);if(He||!Y?.success){Y?.insufficientCredits===!0&&f(c);const le=o("ìì í¸ì§ì ììíì§ ëª»íìµëë¤.","åç»ç·¨éãéå§ã§ãã¾ããã§ããã","Could not start the video edit."),he=Y?.error||(He?await tr(He,le):le);throw j(d,he),new Error(he)}const ze=Y?.taskId||Y?.data?.task_id||Y?.data?.data?.taskId;if(!ze){const le=o("ìì task ID를 ìì íì§ ëª»íìµëë¤.","åç»ã¿ã¹ã¯IDãåä¿¡ã§ãã¾ããã§ããã","Video task ID w
116as not returned.");throw j(d,le),new Error(le)}z(d,ze),Q(d,ze,L,c,Ke,Ke,10,Se.name,be),xe.success(o("ìì í¸ì§ì ììíìµëë¤. ìë£ëë©´ ë´ ìì
ì ëíë©ëë¤.","åç»ç·¨éãéå§ãã¾ãããå®äºããã¨ããã¤ä½åãã«è¡¨ç¤ºããã¾ãã","Video edit started. It will appear in My Works when done.")),c===0&&fa.invalidateQueries({queryKey:["unlimited-grant-status"]}),yr(null),B("history")}catch(u){const k=String(u?.message||""),w=/image load failed/i.test(k)?o("ì¬ì§ì ì´ì§ 못íìµëë¤. JPG·PNG·WebP ë¡ ì ì¥í´ ë¤ì ì¬ë ¤ 주ì¸ì. (ìì´í° ì¬ì§ì HEIC íìì¼ ì ììµëë¤)","åçãéãã¾ããã§ãããJPGã»PNGã»WebP ã§ä¿åãã¦å度ã¢ãããã¼ããã¦ãã ãããï¼iPhone ã®åç㯠HEIC å½¢å¼ã®å ´åãããã¾ãï¼","Could not open the photo. Please save it as JPG, PNG or WebP and upload again. (iPhone photos may be in HEIC format.)"):k||o("ìì í¸ì§ 주문ì ì¤í¨íìµëë¤.","åç»ç·¨éã®ä¾é ¼ã«å¤±æãã¾ããã","Could not start the video edit.");xe.error(w)}finally{Jt.current=!1,Nr(!1)}},[Se,lt,t?.id,l,nt,sa,ct,dt,$a,I,f,tr,Dt,C,T,z,j,Q]),Cs=ul(dt),ya=lt?xr("480p")?0:10:null,Fn=(0,s.useCallback)(async a=>{if(!Se||!lt||!t?.id)return;if(l){xe.info(o("ì°ìµ íë©´ììë ì¤ì ìì í¸ì§ì ììíì§ ììµëë¤.","ç·´ç¿ç»é¢ã§ã¯å®éã®åç»ç·¨éã¯éå§ãã¾ããã","Video edits are not started on the practice screen."));return}if(Jt.current)return;const c=ya;if(c===null)return;Jt.current=!0,Nr(!0);const d=`local_${Date.now()}`;try{if(!await I(c)){f(c);return}const u=await Dt(a.items.map(oe=>oe.image),null),k=a.items.map(oe=>({ko:oe.ko,en:oe.en})),w=k.map(oe=>oe.ko).join(" · "),L=nt>0?nt:10,ne={provider:"byteplus",task_type:ot,preset_name:Se.name,client_task_id:d,ad_workflow:"shift_template",shift_template_key:dt,shift_template_user_prompt:w,shift_composite_labels:k,quality:"480p",aspect_ratio:"9:16",generate_audio:!1,image_urls:u,_sourceVideoUrl:ct};C(d,d,Ke,Ke,w,"video",void 0,"9:16","waiting",c,ne),T(d,10,o("ìì ë§ëë ì¤...","åç»ã使ä¸...","Creating video..."));const Z=na({model_id:lt.id,provider_name:"byteplus",service_name:Xr,mode:"video",prompt:w,has_image:!0,shift_template_key:dt,client_task_id:d},{aspect_ratio:"9:16",duration:Math.min(30,Math.max(4,Math.round(L))),quality:"480p",tier:"pro",generate_audio:!1,web_search:!1,use_omni:!1,seedance2_mode:"edit",shift_mode:"restyle",input_video_duration:L},u);va(Z,ct,null,L),Z.generationOptions=ne,Z.task_type=ot,Z.preset_name=Se.name,Z.shift_template_key=dt,Z.shift_composite_labels=k;const{data:we,error:de}=await Tr(Z);if(de||!we?.success){we?.insufficientCredits===!0&&f(c);const oe=o("ìì ë§ë¤ê¸°ë¥¼ ììíì§ ëª»íìµëë¤.","åç»ä½æãéå§ã§ãã¾ããã§ããã","Could not start the video."),Y=we?.error||(de?await tr(de,oe):oe);throw j(d,Y),new Error(Y)}const be=we?.taskId||we?.data?.task_id||we?.data?.data?.taskId;if(!be){const oe=o("ìì task ID를 ìì íì§ ëª»íìµëë¤.","åç»ã¿ã¹ã¯IDãåä¿¡ã§ãã¾ããã§ããã","Video task ID was not returned.");throw j(d,oe),new Error(oe)}z(d,be),Q(d,be,w,c,Ke,Ke,10,Se.name,ne),xe.success(o("ìì ë§ë¤ê¸°ë¥¼ ììíìµëë¤. ìë£ëë©´ ë´ ìì
ì ëíë©ëë¤.","åç»ä½æãéå§ãã¾ãããå®äºããã¨ããã¤ä½åãã«è¡¨ç¤ºããã¾ãã","Video started. It will appear in My Works when done.")),c===0&&fa.invalidateQueries({queryKey:["unlimited-grant-status"]}),yr(null),B("history")}catch(u){const k=String(u?.message||""),w=/image load failed/i.test(k)?o("ì¬ì§ì ì´ì§ 못íìµëë¤. JPG·PNG·WebP ë¡ ì ì¥í´ ë¤ì ì¬ë ¤ 주ì¸ì. (ìì´í° ì¬ì§ì HEIC íìì¼ ì ììµëë¤)","åçãéãã¾ããã§ãããJPGã»PNGã»WebP ã§ä¿åãã¦å度ã¢ãããã¼ããã¦ãã ãããï¼iPhone ã®åç㯠HEIC å½¢å¼ã®å ´åãããã¾ãï¼","Could not open the photo. Please save it as JPG, PNG or WebP and upload again. (iPhone photos may be in HEIC format.)"):k||o("ìì ë§ë¤ê¸° 주문ì ì¤í¨íìµëë¤.","åç»ä½æã®ä¾é ¼ã«å¤±æãã¾ããã","Could not start the video.");xe.error(w)}finally{Jt.current=!1,Nr(!1)}},[Se,lt,t?.id,l,nt,ct,dt,ya,I,f,tr,Dt,C,T,z,j,Q]),Ps=xl(dt),Ma=(0,s.useCallback)((a,c)=>lt?Il({outfits:a,resolution:c}):null,[lt]),Gn=(0,s.useCallback)(async a=>{if(!Se||!lt||!t?.id)return;if(l){xe.info(o("ì°ìµ íë©´ììë ì¤ì ìì í¸ì§ì ììíì§ ììµëë¤.","ç·´ç¿ç»é¢ã§ã¯å®éã®åç»ç·¨éã¯éå§ãã¾ããã","Video edits are not started on the practice screen."));return}if(Jt.current)return;const c=a.resolution,d=Ma(a.outfits.length,c);if(d===null)return;const u=xr(c)?0:d;Jt.current=!0,Nr(!0);const k=`local_${Date.now()}`;try{if(!await I(u)){f(u);return}const w=await Dt(a.outfits,null),L=Math.round(Sa(w.length)),ne=`${Se.name} · ${o(`${w.length}ë²`,`${w.length}ç`,`${w.length} outfits`)}`,Z=nt>0?nt:10,we={provider:"byteplus",task_type:ot,preset_name:Se.name,client_task_id:k,ad_workflow:"shift_template",shift_template_key:dt,shift_template_user_prompt:ne,shift_crayon_resolution:c,...a.prompt?{shift_crayon_prompt:a.prompt}:{}
116,quality:c,aspect_ratio:"9:16",generate_audio:!1,image_urls:w,_sourceVideoUrl:ct};C(k,k,Ke,Ke,ne,"video",void 0,"9:16","waiting",u,we),T(k,10,o("ìì ë§ëë ì¤...","åç»ã使ä¸...","Creating video..."));const de=na({model_id:lt.id,provider_name:"byteplus",service_name:Xr,mode:"video",prompt:ne,has_image:!0,shift_template_key:dt,client_task_id:k},{aspect_ratio:"9:16",duration:Math.min(30,Math.max(4,Math.round(Z))),quality:c,tier:"pro",generate_audio:!1,web_search:!1,use_omni:!1,seedance2_mode:"edit",shift_mode:"restyle",input_video_duration:Z},w);va(de,ct,null,Z),de.generationOptions=we,de.task_type=ot,de.preset_name=Se.name,de.shift_template_key=dt,de.shift_crayon_resolution=c,a.prompt&&(de.shift_crayon_prompt=a.prompt);const{data:be,error:oe}=await Tr(de);if(oe||!be?.success){be?.insufficientCredits===!0&&f(u);const He=o("ìì ë§ë¤ê¸°ë¥¼ ììíì§ ëª»íìµëë¤.","åç»ä½æãéå§ã§ãã¾ããã§ããã","Could not start the video."),ze=be?.error||(oe?await tr(oe,He):He);throw j(k,ze),new Error(ze)}const Y=be?.taskId||be?.data?.task_id||be?.data?.data?.taskId;if(!Y){const He=o("ìì task ID를 ìì íì§ ëª»íìµëë¤.","åç»ã¿ã¹ã¯IDãåä¿¡ã§ãã¾ããã§ããã","Video task ID was not returned.");throw j(k,He),new Error(He)}z(k,Y),Q(k,Y,ne,u,Ke,Ke,L,Se.name,we),xe.success(o("ìì ë§ë¤ê¸°ë¥¼ ììíìµëë¤. ìë£ëë©´ ë´ ìì
ì ëíë©ëë¤.","åç»ä½æãéå§ãã¾ãããå®äºããã¨ããã¤ä½åãã«è¡¨ç¤ºããã¾ãã","Video started. It will appear in My Works when done.")),u===0&&fa.invalidateQueries({queryKey:["unlimited-grant-status"]}),yr(null),B("history")}catch(w){const L=String(w?.message||""),ne=/image load failed/i.test(L)?o("ì¬ì§ì ì´ì§ 못íìµëë¤. JPG·PNG·WebP ë¡ ì ì¥í´ ë¤ì ì¬ë ¤ 주ì¸ì. (ìì´í° ì¬ì§ì HEIC íìì¼ ì ììµëë¤)","åçãéãã¾ããã§ãããJPGã»PNGã»WebP ã§ä¿åãã¦å度ã¢ãããã¼ããã¦ãã ãããï¼iPhone ã®åç㯠HEIC å½¢å¼ã®å ´åãããã¾ãï¼","Could not open the photo. Please save it as JPG, PNG or WebP and upload again. (iPhone photos may be in HEIC format.)"):L||o("ìì ë§ë¤ê¸° 주문ì ì¤í¨íìµëë¤.","åç»ä½æã®ä¾é ¼ã«å¤±æãã¾ããã","Could not start the video.");xe.error(ne)}finally{Jt.current=!1,Nr(!1)}},[Se,lt,t?.id,l,nt,ct,dt,Ma,xr,I,f,tr,Dt,C,T,z,j,Q]),Ts=hl(dt),Ua=(0,s.useCallback)((a,c)=>lt?yl({resolution:a,background:c}):null,[lt]),Vn=(0,s.useCallback)(async a=>{if(!Se||!lt||!t?.id)return;if(l){xe.info(o("ì°ìµ íë©´ììë ì¤ì ìì í¸ì§ì ììíì§ ììµëë¤.","ç·´ç¿ç»é¢ã§ã¯å®éã®åç»ç·¨éã¯éå§ãã¾ããã","Video edits are not started on the practice screen."));return}if(Jt.current)return;const c=10,d=a.resolution,u=!!a.background,k=Ua(d,u);if(k===null)return;const w=xr(d)?0:k;Jt.current=!0,Nr(!0);const L=`local_${Date.now()}`;try{if(!await I(w)){f(w);return}const ne=await Dt(u?[a.image,a.background]:[a.image],null),Z=`${Se.name} · ${o(`${c}ì´`,`${c}ç§`,`${c}s`)}`,we=nt>0?nt:10,de={provider:"byteplus",task_type:ot,preset_name:Se.name,client_task_id:L,ad_workflow:"shift_template",shift_template_key:dt,shift_template_user_prompt:Z,shift_drink_duration:c,shift_drink_background:u,shift_drink_resolution:d,...a.prompt?{shift_drink_prompt:a.prompt}:{},quality:d,aspect_ratio:"16:9",generate_audio:!1,image_urls:ne,_sourceVideoUrl:ct};C(L,L,Ke,Ke,Z,"video",void 0,"16:9","waiting",w,de),T(L,10,o("ìì ë§ëë ì¤...","åç»ã使ä¸...","Creating video..."));const be=na({model_id:lt.id,provider_name:"byteplus",service_name:Xr,mode:"video",prompt:Z,has_image:!0,shift_template_key:dt,client_task_id:L},{aspect_ratio:"16:9",duration:Math.min(30,Math.max(4,Math.round(we))),quality:d,tier:"pro",generate_audio:!1,web_search:!1,use_omni:!1,seedance2_mode:"edit",shift_mode:"restyle",input_video_duration:we},ne);va(be,ct,null,we),be.generationOptions=de,be.task_type=ot,be.preset_name=Se.name,be.shift_template_key=dt,be.shift_drink_duration=c,be.shift_drink_background=u,be.shift_drink_resolution=d,a.prompt&&(be.shift_drink_prompt=a.prompt);const{data:oe,error:Y}=await Tr(be);if(Y||!oe?.success){oe?.insufficientCredits===!0&&f(w);const ze=o("ìì ë§ë¤ê¸°ë¥¼ ììíì§ ëª»íìµëë¤.","åç»ä½æãéå§ã§ãã¾ããã§ããã","Could not start the video."),le=oe?.error||(Y?await tr(Y,ze):ze);throw j(L,le),new Error(le)}const He=oe?.taskId||oe?.data?.task_id||oe?.data?.data?.taskId;if(!He){const ze=o("ìì task ID를 ìì íì§ ëª»íìµëë¤.","åç»ã¿ã¹ã¯IDãåä¿¡ã§ãã¾ããã§ããã","Video task ID w
116as not returned.");throw j(L,ze),new Error(ze)}z(L,He),Q(L,He,Z,w,Ke,Ke,10,Se.name,de),xe.success(o("ìì ë§ë¤ê¸°ë¥¼ ììíìµëë¤. ìë£ëë©´ ë´ ìì ì ëíë©ëë¤.","åç»ä½æãéå§ãã¾ãããå®äºããã¨ããã¤ä½åãã«è¡¨ç¤ºããã¾ãã","Video started. It will appear in My Works when done.")),w===0&&fa.invalidateQueries({queryKey:["unlimited-grant-status"]}),yr(null),B("history")}catch(ne){const Z=String(ne?.message||""),we=/image load failed/i.test(Z)?o("ì¬ì§ì ì´ì§ 못íìµëë¤. JPG·PNG·WebP ë¡ ì ì¥í´ ë¤ì ì¬ë ¤ 주ì¸ì. (ìì´í° ì¬ì§ì HEIC íìì¼ ì ììµëë¤)","åçãéãã¾ããã§ãããJPGã»PNGã»WebP ã§ä¿åãã¦å度ã¢ãããã¼ããã¦ãã ãããï¼iPhone ã®åç㯠HEIC å½¢å¼ã®å ´åãããã¾ãï¼","Could not open the photo. Please save it as JPG, PNG or WebP and upload again. (iPhone photos may be in HEIC format.)"):Z||o("ìì ë§ë¤ê¸° 주문ì ì¤í¨íìµëë¤.","åç»ä½æã®ä¾é ¼ã«å¤±æãã¾ããã","Could not start the video.");xe.error(we)}finally{Jt.current=!1,Nr(!1)}},[Se,lt,t?.id,l,nt,ct,dt,Ua,xr,I,f,tr,Dt,C,T,z,j,Q]),Cr=(0,s.useCallback)(()=>{gt(null),ba(null),bt([]),Nt(null),wt(null),me(null),Qt(""),Ar(!1)},[]);(0,s.useEffect)(()=>{const a=()=>Cr();return window.addEventListener(Fs,a),window.addEventListener(Gs,a),()=>{window.removeEventListener(Fs,a),window.removeEventListener(Gs,a)}},[Cr]);const Hn=(0,s.useCallback)(()=>{It(!1),l||B("history")},[l]),zn=(0,s.useCallback)(()=>{const a=it?.sessionId;if(It(!1),ir(null),Ut(null),a){Wt.current.add(a),setTimeout(()=>Wt.current.delete(a),3e4);const c=cr.find(d=>d.sessionId===a);Zs(t?.id,a,c?.taskId),vt(d=>d.filter(u=>u.sessionId!==a))}},[t?.id,it,cr]),qn=(0,s.useCallback)(a=>{Wt.current.add(a),setTimeout(()=>Wt.current.delete(a),3e4);const c=cr.find(d=>d.sessionId===a);Zs(t?.id,a,c?.taskId),vt(d=>d.filter(u=>u.sessionId!==a)),it?.sessionId===a&&(ir(null),Ut(null),It(!1))},[t?.id,it?.sessionId,cr]);(0,s.useCallback)(()=>{xe.info(o("ì¤ë¹ ì¤","æºåä¸","Coming Soon"),{description:o("Seedance 2.0 ëìì ìì± ê¸°ë¥ì´ ê³§ ì¶ê°ë©ëë¤.","Seedance 2.0åç»çææ©è½ãã¾ããªã追å ããã¾ãã","Seedance 2.0 video generation is coming soon.")})},[o]);const Bn=(0,s.useCallback)(()=>{const a=Ae.length>0,c=Fe.trim().length>0;if(!a&&!c){xe.error(o("ì ë ¥ ì¤ë¥","å ¥åã¨ã©ã¼","Input Error"),{description:o("ì í ì´ë¯¸ì§ ëë ìë¹ì¤ ì¤ëª ì ì ë ¥í´ ì£¼ì¸ì.","製åç»åã¾ãã¯ãµã¼ãã¹èª¬æãå ¥åãã¦ãã ããã","Please upload a product image or enter a service description.")});return}if(!ce){xe.error(o("ì ë ¥ ì¤ë¥","å ¥åã¨ã©ã¼","Input Error"),{description:o("í í릿ì ì íí´ ì£¼ì¸ì.","ãã³ãã¬ã¼ãã鏿ãã¦ãã ããã","Please select a template.")});return}if(!l&&!t?.id){xe.warning(o("ë¡ê·¸ì¸ íì","ãã°ã¤ã³å¿ è¦","Login Required"),{description:o("ëìì ìì± ì ì ë¡ê·¸ì¸í´ 주ì¸ì.","åç»çæåã«ãã°ã¤ã³ãã¦ãã ããã","Please log in before creating a video.")}),S();return}it&&(Ut(null),It(!1)),aa.current=null;const d=Mt?[...Ae,Mt]:[...Ae];pe.log("ð¬ [handleMakeVideo] Creating agent session with:",{productImages:Ae,productImagesCount:Ae.length,faceImage:Ue,logoImage:!!Mt,totalReferenceImages:d.length});const u=ce.tone==="hold_explain"?{...ce,tone:"pov_review"}:ce,k={sessionId:`agent_${Date.now()}_${Math.random().toString(36).slice(2,8)}`,preset:u,productImages:d,faceImage:Ue,highlights:[vr.trim()&&`ì íëª : ${vr.trim()}`,Fe.trim()].filter(Boolean).join(` 117`),aspectRatio:Ct,resolution:Ft,outputFormat:Gt,imageDimensions:Je,videoDuration:Re,seedanceEngine:Ie},w=Ja(k);vt(L=>[w,...L.filter(ne=>ne.sessionId!==k.sessionId)]),Ya(t.id,k).catch(L=>{pe.warn("[ShortsAgentView] Failed to persist initial agent session:",L)}),ir(k),It(!0),Ut(null),Cr()},[Cr,Fe,Ue,Mt,Je,ce,Ae,Ct,Re,Gt,Ft,Ie,S,t?.id,it,o]),[zr,Mr]=(0,s.useState)(null);fn((0,s.useCallback)(()=>{l&&Cr()},[l,Cr])),hn((0,s.useCallback)(a=>{l&&(a.includes(je.shortsStartConfirm)||Mr(null),It(a.includes("shorts-agent-")))},[l]));
117const[Ur,ba]=(0,s.useState)(null),[Kn,Es]=(0,s.useState)(!1),[Da,Kl]=(0,s.useState)(null),Wn=(0,s.useCallback)(a=>{if(!t?.id){xe.warning(o("ë¡ê·¸ì¸ íì","ãã°ã¤ã³å¿ è¦","Login Required"),{description:o("ëìì ìì± ì ì ë¡ê·¸ì¸í´ 주ì¸ì.","åç»çæåã«ãã°ã¤ã³ãã¦ãã ããã","Please log in before creating a video.")}),S();return}const{concept:c,productImageUrls:d,productName:u,highlights:k,sellingPoints:w}=a,L=u?[`ì íëª : ${u}`,k].filter(Boolean).join(` 118`):k;it&&(Ut(null),It(!1)),aa.current=null;const ne={id:`auto_${Date.now()}`,name:c.title||c.vibe||(h==="ja"?c.labelJa:h==="en"?c.labelEn:c.labelKo),description:c.logline||c.microStoryboard||c.hook,category:"product",colorSwatch:"#F43F5E",previewGradient:"linear-gradient(135deg, #F43F5E, #8B5CF6)",previewImage:"",promptTemplate:c.heroScenePrompt,tone:c.tone},Z={sessionId:`agent_${Date.now()}_${Math.random().toString(36).slice(2,8)}`,preset:ne,productImages:d,faceImage:null,highlights:L,aspectRatio:Ct,resolution:Ft,outputFormat:Gt,imageDimensions:null,videoDuration:Re,seedanceEngine:Ie,autoConcept:{hook:c.hook,cta:c.cta,sellingPoints:w,recipe:c.recipe,casting:c.casting,location:c.location,visualStyle:c.visualStyle,hookAction:c.hookAction,productPitch:c.productPitch,benefit:c.benefit,speechStyle:c.speechStyle,narrationStyle:c.narrationStyle,cgModuleLabel:c.cgModuleLabel,cgIntensity:c.cgIntensity,cgDirection:c.cgDirection}},we=Ja(Z);vt(de=>[we,...de.filter(be=>be.sessionId!==Z.sessionId)]),Ya(t.id,Z).catch(de=>{pe.warn("[ShortsAgentView] Failed to persist initial auto-concept agent session:",de)}),ir(Z),It(!0),Ut(null),Es(!1)},[t?.id,it,h,Ct,Re,Gt,Ft,Ie,S,o]),Jn=(0,s.useCallback)(a=>{if(!t?.id){xe.warning(o("ë¡ê·¸ì¸ íì","ãã°ã¤ã³å¿ è¦","Login Required"),{description:o("ëìì ìì± ì ì ë¡ê·¸ì¸í´ 주ì¸ì.","åç»çæåã«ãã°ã¤ã³ãã¦ãã ããã","Please log in before creating a video.")}),S();return}it&&(Ut(null),It(!1));const c={id:`library_${Date.now()}`,name:o("ë´ ì´ë¯¸ì§","ãã¤ç»å","My Image"),description:o("ë¼ì´ë¸ë¬ë¦¬ ì´ë¯¸ì§ë¡ ìì ìì±","ã©ã¤ãã©ãªç»åããåç»ãçæ","Create video from library image"),category:"service",colorSwatch:"#4F46E5",previewGradient:"linear-gradient(135deg, #4F46E5, #7C3AED)",previewImage:a,promptTemplate:""},d={sessionId:`agent_${Date.now()}_${Math.random().toString(36).slice(2,8)}`,preset:c,productImages:[],faceImage:null,highlights:"",aspectRatio:Ct,resolution:Ft,outputFormat:Gt,imageDimensions:null,videoDuration:Re,seedanceEngine:Ie,presetHeroImageUrl:a},u=Ja(d);vt(k=>[u,...k.filter(w=>w.sessionId!==d.sessionId)]),Ya(t.id,d).catch(k=>{pe.warn("[ShortsAgentView] Failed to persist initial library agent session:",k)}),ir(d),It(!0),Ut(null)},[t?.id,it,Ct,Re,Ft,Gt,Ie,S,o]),Yn=ke.length+cr.length,Xn=(0,s.useMemo)(()=>A.slice(0,3).map(a=>cs(a.previewImage||"",{width:360,height:640,quality:55})||a.previewImage||null),[A]),Qn=(0,s.useMemo)(()=>{const a=R.find(c=>c.id===Bs);return a?.previewImage?cs(a.previewImage,{width:360,height:640,quality:55})||a.previewImage:null},[R]);if((0,s.useEffect)(()=>{const a=Lt.current;a&&(a.scrollTop=0)},[_]),O)return(0,e.jsx)(ri,{preset:"shorts"});const Zn=h==="ko"?"ko":h==="ja"?"ja":"en",qr=yt.influencer||0,Oa=yt.shift||0,eo=W==="shift"&&rt?o("ìë¡ì´ ë¨ëë¦´ì¤ í ë§ë¥¼ ì¤ë¹íê³ ìì´ì. ì§ê¸ì ì¸í루ì¸ì í ë§ìì ê³¨ë¼ ì£¼ì¸ì.","æ°ããæ¥ä¸æãªã¼ã«ãã¼ããæºåä¸ã§ããä»ã¯ã¤ã³ãã«ã¨ã³ãµã¼ãã¼ããããé¸ã³ãã ããã","The Trending Reels theme is coming soon â pick from the Influencer theme for now."):rt?o(`${qr}ëª ì¤ ë§ìì ëë ì¬ëì ê³ ë¥´ì¸ì. ì¥ìì ìí©ì ì¬ë¦¬ì ì íì ë§ì¶° AIê° ë¤ì ì í©ëë¤.`,`${qr}人ãã好ããªäººãé¸ãã§ãã ããããã±ãç¶æ³ã¯ã¢ããããååã«åããã¦AIãæ±ºãç´ãã¾ãã`,`Pick someone from ${qr} â the location and situation are re-chosen to fit the product you upload.`):o(`ì¸í루ì¸ì ${qr}ëª Â· ë¨ëë¦´ì¤ ${Oa}ê° ì¤ ë§ìì ëë 걸 ê³ ë¥´ì¸ì. ì¥ìì ìí©ì ì¬ë¦¬ì ì íì ë§ì¶° AIê° ë¤ì ì í©ëë¤.`,`ã¤ã³ãã«ã¨ã³ãµã¼${qr}äººã»æ¥ä¸æãªã¼ã«${Oa}æ¬ããã好ã¿ãé¸ãã§ãã ããããã±ãç¶æ³ã¯ã¢ããããååã«åããã¦AIãæ±ºãç´ãã¾ãã`,`Pick from ${qr} influencers and ${Oa} trending reels. The location and situation are re-chosen by AI to fit the product you upload.`),La=cr.map(a=>(0,e.jsx)(Bl,{summary:a,language:Zn,onOpen:()=>i(a.sessionId),onDismiss:()=>qn(a.sessionId)},a.sessionId));return(0,e.jsxs)("div",{className:"flex flex-col h-full min-h-0 overflow-hidden",children:[(0,e.jsx)("div",{ref:Lt,className:"flex-1 min-h-0 overflow-y-auto custom-scrollbar",onScroll:_==="templates"?re:void 0,children:(0,e.jsxs)(co,{children:[(0,e.jsx)(Wo,{value:_,onCh
118ange:B,ariaLabel:o("ë¦´ì¤ ë³´ê¸°","ãªã¼ã«ã®è¡¨ç¤º","Reels view"),options:[{value:"templates",label:o("í
í릿","ãã³ãã¬ã¼ã","Templates"),attrs:Ve(je.shortsInfluencerTab)},{value:"history",label:o("ë´ ìì
","ãã¤ããã¸ã§ã¯ã","My Projects"),count:Yn||void 0,attrs:Ve(je.shortsHistoryTab)}]}),_==="templates"&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(Rs,{eyebrow:"AI MARKETING · REELS",line1:o("ìì¦ ì ííë 릴ì¤ë¥¼","æµè¡ãã®ãªã¼ã«ã","Make the reels everyone's watching"),line2:o("ììê°ì ë§ë¤ì´ë³´ì¸ì","ä¸ç¬ã§ä½ã£ã¦ã¿ã¾ããã","in no time"),sub:eo,aside:(0,e.jsx)(Vo,{ratio:"9 / 16",images:Xn,pick:Qn,product:"/marketing-howto/reels-product.jpg",done:"/marketing-howto/reels-result.jpg",doneVideo:Yr.finalVideo,video:!0,loc3:o}),asideClassName:"mk-aside is-howto"}),(0,e.jsx)("div",{className:"mk-chiprow",children:(0,e.jsx)(As,{value:W,onChange:a=>Le(a),ariaLabel:o("ë¶ë¥","åé¡","Category"),options:[{value:"all",label:o("ì ì²´","ãã¹ã¦","All")},...Hl.map(a=>{const c=!!a.comingSoon&&rt,d=h==="ja"?a.labelJa:h==="en"?a.labelEn:a.labelKo;return{value:a.key,label:c?`${d} ${o("ì¤ë¹ì¤","æºåä¸","Soon")}`:d,count:c?void 0:yt[a.key]||0}})]})}),De&&(0,e.jsx)("div",{...Ve(je.shortsToneFilter),className:"mk-chiprow",children:(0,e.jsx)(As,{value:$t,onChange:a=>ft(a),ariaLabel:o("í¤","ãã¼ã³","Tone"),options:[{value:"all",label:o("모ë í¤","å
¨ãã¼ã³","All Tones")},...ln.filter(a=>(kt[a.key]||0)>0).map(a=>({value:a.key,label:h==="ja"?a.labelJa:h==="en"?a.labelEn:a.labelKo,count:kt[a.key]||0}))]})}),W==="shift"&&rt&&(0,e.jsxs)("div",{className:"mk-empty",children:[(0,e.jsx)("b",{children:o("ë¨ëë¦´ì¤ í
ë§ë¥¼ ì¤ë¹íê³ ìì´ì","æ¥ä¸æãªã¼ã«ãã¼ããæºåä¸ã§ã","The Trending Reels theme is on its way")}),(0,e.jsx)("span",{children:o("ê³§ ìë¡ì´ ì¸í루ì¸ì ì¤íì¼ë¡ ì°¾ìëµê² ìµëë¤.","ã¾ããªãæ°ããã¹ã¿ã¤ã«ã§ãå±ããã¾ãã","New influencer styles are coming soon.")})]}),!(W==="shift"&&rt)&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{...Ve(je.shortsTemplateGrid),className:"mk-grid mk-g-shorts",children:[ut.map((a,c)=>(0,e.jsx)(Rn,{preset:a,priority:c<6,tutorialAnchor:Io(a.id),badge:a.theme==="shift"&&mr&&Ga(mr.maxDurationSec,a.id)?o("ë¬´ë£ 1í","ç¡æ1å","Free run"):null,onClick:()=>{if(a.theme==="shift"){yr(a);return}const d=qa(N.type_specific_settings);gt(a),ba(null),l||(bt(d.productImages.slice(0,Me)),Qt(d.highlights.trim())),Nt(null),me(null)}},a.id)),A.length===0&&(0,e.jsx)("p",{className:"mk-lempty",children:o("í
íë¦¿ì´ ììµëë¤","ãã³ãã¬ã¼ããããã¾ãã","No templates")})]}),at&&(0,e.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,e.jsx)(Gr,{size:16,className:"text-muted-foreground animate-spin"})})]})]}),_==="history"&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(Rs,{eyebrow:"MY WORKS",line1:o("ë´ê° ë§ë ","ä½ã£ã","Your"),line2:o("ë¦´ì¤ ìì","ãªã¼ã«åç»","reels"),sub:te>0?o(`ì§ê¸ê¹ì§ ë§ë ${te}ê°ì 릴ì¤. í´ë¦íë©´ í¬ê² ë³´ê³ ë°ë¡ ë¤ì´ë¡ëí ì ìì´ì.`,`ããã¾ã§ã«ä½æãã${te}æ¬ã®ãªã¼ã«ãã¯ãªãã¯ã§æ¡å¤§è¡¨ç¤ºã»ãã¦ã³ãã¼ãã§ãã¾ãã`,`${te} reels you've made so far. Click any to view large and download.`):o("í
í릿ì¼ë¡ 릴ì¤ë¥¼ ë§ë¤ë©´ ì¬ê¸°ì 모ì
ëë¤.","ãã³ãã¬ã¼ããããªã¼ã«ãä½ãã¨ããã«éã¾ãã¾ãã","Reels you generate from templates will land here.")}),(0,e.jsx)(qo,{media:K,onMedia:x,view:ie.view,onView:ie.setView,zoom:ie.zoom,onZoom:ie.setZoom,cols:ie.cols,onCols:ie.setCols,loc3:o}),l?(0,e.jsxs)("div",{...Ve(je.shortsHistoryGrid),className:"mk-grid mk-g-shorts",children:[La.map(a=>(0,e.jsx)("div",{className:"relative overflow-hidden rounded-[14px]",style:{aspectRatio:"9 / 16"},children:a},a.key)),(0,e.jsx)("div",{className:"relative overflow-hidden rounded-[14px]",style:{aspectRatio:"9 / 16"},children:(0,e.jsxs)("div",{className:"mk-rc",style:{cursor:"default"},children:[(0,e.jsx)("video",{src:oa(Yr.finalVideo)||void 0,muted:!0,loop:!0,autoPlay:!0,playsInl
118ine:!0}),(0,e.jsxs)(io,{className:"mk-rc-cap",children:[(0,e.jsx)("b",{children:Ka.productName}),(0,e.jsx)("span",{children:o("ë°©ê¸ ë§ë ì¼ì¸ ","ä»ä½ã£ãã·ã§ã¼ã","Just created")})]})]})})]}):(0,e.jsx)("div",{...Ve(je.shortsHistoryGrid),children:(0,e.jsx)(oi,{serviceName:Ke,serviceNames:[Ke],taskType:"shorts",pollingTasks:ke,onRemoveTask:ae,emptyTitle:o("ìì§ ìì±ì íì§ ìì¼ì
¨ë¤ì","ã¾ã çæãã¦ãã¾ãã","No creations yet"),emptySubtitle:o("í
í릿ì¼ë¡ ê°ì ìíìë ì¼ì¸ í
í릿ì 골ë¼ì ì¼ì¸ ì ìì ììí´ ë³´ì¸ì!","ãã³ãã¬ã¼ãã«è¡ããã好ã¿ã®ã·ã§ã¼ããã³ãã¬ã¼ããé¸ãã§ã·ã§ã¼ãå¶ä½ãå§ãã¾ãããï¼","Go to Templates and pick a template to start creating your shorts!"),onEmptyAction:()=>B("templates"),emptyActionLabel:o("í
í릿 ëë¬ë³´ê¸°","ãã³ãã¬ã¼ããè¦ã","Browse Templates"),cardAspect:"auto",extraGridCards:La.length>0?La:void 0,viewType:ie.view,rowZoom:ie.zoom,gridColumns:ie.cols,placeholderAspect:9/16,mediaTypeFilter:K,onMakeVideo:Jn,onCountChange:ue,showNarrationReplace:!1,showDirectorNote:!1,onRemakeAdVideo:m})})]})]})}),ce&&(()=>{const a=ce.showcaseVideos||[],c=[10,15,20,30],d=["9:16","16:9","1:1","4:3","3:4","21:9"];return(0,e.jsx)("div",{className:"mk-scrim",onMouseDown:u=>{u.target===u.currentTarget&&(u.currentTarget.dataset.bd="true")},onClick:u=>{u.target===u.currentTarget&&u.currentTarget.dataset.bd==="true"&&Cr(),delete u.currentTarget.dataset.bd},children:(0,e.jsxs)("div",{className:"mk-modal is-narrow-pv",role:"dialog","aria-modal":"true","aria-label":ce.name,onMouseDown:u=>u.stopPropagation(),children:[(0,e.jsx)(bn,{onClick:Cr,label:o("ë«ê¸°","éãã","Close")}),(0,e.jsxs)("div",{...Ve(je.shortsDetailPreview),className:"mk-pv",children:[(0,e.jsx)("div",{className:"mk-pv-media",children:Ur?(0,e.jsx)("video",{src:Ur.url,poster:Ur.poster,controls:!0,autoPlay:!0,playsInline:!0},Ur.url):ce.previewImage?(0,e.jsx)("img",{src:ce.previewImage,alt:ce.name}):(0,e.jsx)("div",{className:"mk-fill",style:{background:ce.previewGradient}})}),a.length>0&&(0,e.jsxs)("div",{className:"mk-pv-strip",children:[(0,e.jsx)("p",{children:o("ì´ í
í릿ì¼ë¡ ë§ë ìì","ãã®ãã³ãã¬ã¼ãã§ä½ã£ãåç»","Videos made with this template")}),(0,e.jsxs)("div",{className:"mk-strip",children:[(0,e.jsx)("button",{type:"button",onClick:()=>ba(null),className:st("mk-strip-i",!Ur&&"is-on"),title:o("í
í릿 ì´ë¯¸ì§","ãã³ãã¬ã¼ãç»å","Template image"),"aria-label":o("í
í릿 ì´ë¯¸ì§","ãã³ãã¬ã¼ãç»å","Template image"),"aria-pressed":!Ur,children:ce.previewImage?(0,e.jsx)("img",{src:ce.previewImage,alt:""}):(0,e.jsx)("div",{className:"w-full h-full",style:{background:ce.previewGradient}})}),a.map((u,k)=>{const w=Ur?.url===u.url;return(0,e.jsxs)("button",{type:"button",onClick:()=>ba(u),className:st("mk-strip-i",w&&"is-on"),title:o("ìì ì¬ì","åç»ãåç","Play video"),"aria-label":`${o("ìì ì¬ì","åç»ãåç","Play video")} ${k+1}`,"aria-pressed":w,children:[u.poster?(0,e.jsx)("img",{src:u.poster,alt:""}):(0,e.jsx)("video",{src:u.url,muted:!0,playsInline:!0,preload:"metadata"}),(0,e.jsx)("span",{className:"mk-strip-play",children:(0,e.jsx)(xo,{size:14,fill:"currentColor","aria-hidden":!0})})]},`${u.url}-${k}`)})]})]})]}),(0,e.jsxs)("div",{className:"mk-mform",children:[(0,e.jsx)(Bo,{eyebrow:o("릴ì¤","ãªã¼ã«","Reels"),title:ce.name,desc:ce.description||void 0}),(0,e.jsxs)("div",{className:"mk-mbody",children:[(0,e.jsxs)("div",{...Ve(je.shortsDetailName),className:"grid gap-2",children:[(0,e.jsx)(sr,{title:o("ì í ì´ë¦","製åå","Product Name"),extra:o("ëì¬ì ì´ ì´ë¦ ê·¸ëë¡ ë¤ì´ê°ëë¤","ã»ãªãã«ãã®ååããã®ã¾ã¾å
¥ãã¾ã","used verbatim in the spoken lines"),count:`${vr.length}/80`}),(0,e.jsx)("input",{value:vr,onChange:u=>et(u.target.value),maxLength:80,placeholder:o("ì) ë¹ ëë ìì´ìì´","ä¾ï¼ppabanana AI","e.g. BBANANA AI"),"aria-label":o("ì í ì´ë¦","製åå","Product Name"),className:"mk-field"})]}),(0,e.jsxs)("div",{...Ve(je.shortsDetailProducts),className:"grid gap-2",children:[(0,e.jsx)(sr,{title:o("ì í ì´ë¯¸ì§","製åç»å","Product Image"),count:`${Ae.length}/${Me}`}),(0,e.jsx)("input",{id:"product-upload",type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:u=>{const k=u.target.files;
118k&&Array.from(k).slice(0,Me-Ae.length).forEach(w=>er(w,"product")),u.target.value=""}}),(0,e.jsxs)(Go,{children:[Ae.map((u,k)=>(0,e.jsx)(Us,{src:u,label:`Image ${k+1}`,removeLabel:o("ì´ë¯¸ì§ ìì ","ç»åãåé¤","Remove image"),onRemove:()=>{u&&_r.current.has(u)&&Vr(u),bt(w=>w.filter((L,ne)=>ne!==k)),k===0&&me(null)}},k)),Ae.length<Me&&(0,e.jsx)(Us,{label:`Image ${Ae.length+1}`,ariaLabel:o("ì í ì´ë¯¸ì§ ì¶ê°","製åç»åã追å ","Add product image"),onClick:()=>Bt("product"),onDrop:Et,onDragOver:u=>u.preventDefault()})]}),(0,e.jsx)("p",{className:"mk-tip",children:o("íê¸ì´ ìë ì íì ê²½ì° ê°ê¸ì í° ì¬ì´ì¦ì ì´ë¯¸ì§ë¥¼ ì
ë¡ëíìë©´ íê¸ì´ ë 깨ì§ëë¤.","éå½èªããã¹ãã®ãã製åã®å ´åãã§ããã ã大ããªãµã¤ãºã®ç»åãã¢ãããã¼ãããã¨éå½èªãå´©ãã«ãããªãã¾ãã","For products with Korean text, uploading a larger image helps preserve the Korean characters more accurately.")})]}),(0,e.jsxs)("div",{...Ve(je.shortsDetailHighlights),className:"grid gap-2",children:[(0,e.jsx)(sr,{title:o("ì í í¹ì¥ì ","製åã®ç¹é·","Product Highlights"),count:Fe.length>1800?`${Fe.length}/2000`:void 0}),(0,e.jsx)("textarea",{value:Fe,onChange:u=>Qt(u.target.value.slice(0,2e3)),maxLength:2e3,rows:3,"aria-label":o("ì í í¹ì¥ì ","製åã®ç¹é·","Product Highlights"),placeholder:Ae.length===0?o('ì´ë¯¸ì§ ìì´ ìë¹ì¤ ì¼ì¸ 를 ë§ë¤ ì ììµëë¤. ì: "ì¬í ìì½ ì±, ê°í¸íê³ ë¹ ë¥¸ ìì½", "í리미ì í¬ì¤ì¼ì´ 구ë
ìë¹ì¤"','ç»åãªãã§ãµã¼ãã¹ã·ã§ã¼ããä½ãã¾ããä¾: "æ
è¡äºç´ã¢ããªãç°¡åã§ç´ æ©ãäºç´"ã"ãã¬ãã¢ã ãã«ã¹ã±ã¢å®æè³¼èªãµã¼ãã¹"','No image? Describe your service here. e.g. "Travel booking app, fast & easy reservations" or "Premium skincare subscription"'):o("ì¶ê° ì§ìì¬íì ì
ë ¥íì¸ì...","追å ã®æç¤ºãå
¥åãã¦ãã ãã...","Add extra instructions..."),className:"mk-field"})]}),(0,e.jsxs)(zo,{title:o("ì¶ë ¥ ìµì
","åºåãªãã·ã§ã³","Output Options"),attrs:Ve(je.shortsDetailOptions),children:[(0,e.jsx)(sr,{title:o("ë¹ì¨","æ¯ç","Aspect Ratio")}),(0,e.jsx)(Ds,{value:Ct,onChange:u=>Ir(u),ariaLabel:o("ë¹ì¨","æ¯ç","Aspect Ratio"),options:d.map(u=>({value:u,label:u}))}),(0,e.jsx)(sr,{title:o("ìì 길ì´","åç»ã®é·ã","Video Length")}),(0,e.jsx)(Ds,{value:String(Re),onChange:u=>We(Number(u)),ariaLabel:o("ìì 길ì´","åç»ã®é·ã","Video Length"),options:c.map(u=>{const k=Ws(Ie,u,{seedance2:_e,seedance25:P}),w=k?Va(u,"720p",!0,k,"pro"):0;return{value:String(u),label:`${u}${o("ì´","ç§","s")}`,sub:w>0?`${w}${o("í¬ë ë§~","ã¯ã¬ã¸ãã~"," credits~")}`:void 0}})}),(0,e.jsx)("p",{className:"mk-foot-note",children:Ie==="2.5"?o("* 모ë 길ì´ê° Seedance 2.5 ë¡ ìì±ë©ëë¤ â 720p/1080p 모ë ì íí ì ìê³ , í´ìëì ë°ë¼ í¬ë ë§ì´ ë³ëë©ëë¤.","* ãã¹ã¦ã®é·ããSeedance 2.5ã§çæããã¾ã â 720p/1080pã鏿ã§ããè§£å度ã«ããã¯ã¬ã¸ãããå¤åãã¾ãã","* Every length is generated
118with Seedance 2.5 â both 720p and 1080p are available; credits scale with resolution."):Re>15?o("* 30ì´ ììì Seedance 2.5ë¡ ìì±ëë©° 720pë¡ ì ê³µë©ëë¤.","* 30ç§åç»ã¯Seedance 2.5ã§çæããã720pã®ã¿å¯¾å¿ã§ãã","* 30-second videos are generated with Seedance 2.5 and available in 720p."):o("* í´ìë(720p/1080p)ì ë°ë¼ í¬ë ë§ì´ ì¶ê°ë¡ ë³ëë©ëë¤.","* è§£å度 (720p/1080p) ã«ããã¯ã¬ã¸ããã追å å¤åãã¾ãã","* Credits scale with resolution (720p/1080p).")})]})]}),(0,e.jsxs)("div",{className:"mk-mfoot is-two",children:[(0,e.jsx)(Er,{variant:"o",onClick:()=>Mr("image"),disabled:Ae.length===0&&!Fe.trim()||js,children:js?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(Gr,{size:16,className:"animate-spin shrink-0","aria-hidden":!0}),o("ìì± ì¤...","çæä¸...","Generating...")]}):(0,e.jsxs)(e.Fragment,{children:[o("ì´ë¯¸ì§ë§ ìì±","ç»åã®ã¿çæ","Generate Image Only")," ",(0,e.jsx)(fr,{value:ts})]})}),(0,e.jsxs)(Er,{variant:"y",onClick:()=>Mr("agent"),...Ve(je.shortsRunAgent),title:o("ì¼ì¸ ë¹ëì¤ ìì´ì í¸ ìì","ã·ã§ã¼ããããªã¨ã¼ã¸ã§ã³ãéå§","Start shorts video agent"),children:[o("ìì´ì í¸ ì¤í","ã¨ã¼ã¸ã§ã³ãå®è¡","Run Agent")," ",!l&&(0,e.jsx)(fr,{value:ts,variant:"ink"})]})]})]})]})})})(),Se&&Ts&&(0,e.jsx)(bl,{preset:Se,sourceVideoUrl:ct,language:h==="ko"?"ko":h==="ja"?"ja":"en",ready:!!lt,freeGrant:ga,isQualityFree:xr,estimateCredit:Ua,isSubmitting:jr,onClose:()=>{jr||yr(null)},onSubmit:Vn}),Se&&Ps&&(0,e.jsx)(Cl,{preset:Se,sourceVideoUrl:ct,language:h==="ko"?"ko":h==="ja"?"ja":"en",estimateCredit:Ma,freeGrant:ga,isQualityFree:xr,isSubmitting:jr,onClose:()=>{jr||yr(null)},onSubmit:Gn}),Se&&Cs&&!Ts&&!Ps&&(0,e.jsx)(pl,{preset:Se,sourceVideoUrl:ct,language:h==="ko"?"ko":h==="ja"?"ja":"en",credit:ya,isFree:!!ga&&ya===0,isSubmitting:jr,onClose:()=>{jr||yr(null)},onSubmit:Fn}),Se&&!Cs&&(0,e.jsx)(ll,{preset:Se,sourceVideoUrl:ct,variant:ha,onVariantChange:Ns,language:h==="ko"?"ko":h==="ja"?"ja":"en",sourceSeconds:nt,estimateCredit:$a,freeGrant:ga,isSubmitting:jr,onClose:()=>{jr||yr(null)},onSubmit:Ln}),(0,e.jsx)(Ji,{open:!!it,visible:lr,onClose:Hn,onEndSession:zn,onStateChange:Ut,onGenerateStart:void 0,session:it,language:h==="ko"?"ko":h==="ja"?"ja":"en",pollingHistory:g,generationTasks:M,createRepresentativeImage:Un,uploadImages:Dt,startSeedanceGeneration:Dn,userId:t?.id,onTaskComplete:y,onSessionCompleted:ur,videoCreditCost480p:pt,videoCreditCost720p:Pt,videoCreditCost1080p:Zt,videoCreditCost4k:Sr,demoFixture:l?wi:void 0,onCheckCredit:async a=>{if(l||!t?.id)return!0;const c=await I(a);return c||f(a),c},onSetShowcaseShare:async(a,c)=>{try{const{data:d,error:u}=await ve.rpc("set_my_shorts_video_public",{p_url:a,p_public:c});if(u)throw u;if(!d?.ok)throw new Error(d?.reason||"share_failed");c?xe.success(d.rewarded?o("ê³µì ìë£ Â· 5í¬ë ë§ ì 립!","å
±æå®äº · 5ã¯ã¬ã¸ããä»ä¸ï¼","Shared · +5 credits!"):o("ê°¤ë¬ë¦¬ì ê³µì íì´ì","ã®ã£ã©ãªã¼ã«å
±æãã¾ãã","Shared to the gallery"),{description:d.rewarded?o("ì¸í루ì¸ì í
í릿 ì¹´ëìì ì´ ììì´ ì¬ìë©ëë¤.","ã¤ã³ãã«ã¨ã³ãµã¼ãã³ãã¬ã¼ãã«ã¼ãã§ãã®åç»ãåçããã¾ãã","Your video now plays on the influencer template card."):d.reward_reason==="already_rewarded"?o("ì´ë¯¸ ë³´ìì ë°ì ììì´ë¼ í¬ë ë§ì ì¶ê°ë¡ ì 립ëì§ ììì.","ãã§ã«å ±é
¬ãåãåã£ãåç»ã®ããã追å ã®ã¯ã¬ã¸ããã¯ããã¾ããã","This video was already rewarded, so no additional credits were granted."):o("ì´ ììì í¬ë ë§ ì 립 ëìì´ ìëìì.","ãã®åç»ã¯ã¯ã¬ã¸ããä»ä¸ã®å¯¾è±¡å¤ã§ãã","This video is not eligible for a credit reward.")}):xe.success(o("ê³µì 를 ì·¨ìíì´ì","å
±æãåãæ¶ãã¾ãã","Sharing turned off"),d.reclaimed?{description:o("ì 립ëë 5í¬ë ë§ì´ íìëììµëë¤.","ä»ä¸ããã5ã¯ã¬ã¸ãããååããã¾ããã","The 5 credits granted earlier were reclaimed.")}:void 0)}catch(d){throw xe.error(o("ê³µì ì ì¤í¨íì´ì","å
±æã«å¤±æãã¾ãã","Sharing failed"),{description:o("ì ì í ë¤ì ìëí´ ì£¼ì¸ì.","ãã°ãããã¦ããå試è¡ãã¦ãã ããã","Please try again in a moment.")}),d}}}),(0,e.jsx)(ti,{open:H,onOpenChange:ee,requiredCredit:Ee,onPurchase:()=>{ee(!1),se("/credit-purchase")}}),zr&&(0,e.jsx)("div",{className:"mka-scrim fixed inset-0 z-[85] flex items-center justify-center px-4",onClick:()=>Mr(null),children:(0,e.jsxs)("div",{className:"mka-dlg max-w-[560px]",onClick:a=>a.stopPropagation(),children:[(0,e.jsx)("p",{className:"rn-eyebrow is-y",children:o("ìì ì íì¸","éå§åã®ç¢ºèª","Confirm start")}),(0,e.jsx)("h3",{children:zr==="image"?o("ì´ë¯¸ì§ ìì±ì ììí ê¹ì?","ç»åçæãéå§ãã¾ããï¼","Start image generation?"):o("ì¼ì¸ ìì
118 ìì´ì í¸ë¥¼ ììí ê¹ì?","ã·ã§ã¼ãåç»ã¨ã¼ã¸ã§ã³ããéå§ãã¾ããï¼","Start the shorts video agent?")}),(0,e.jsx)("p",{children:zr==="image"?o(`ì ë¡ëí ì íì¼ë¡ í©ì± ì´ë¯¸ì§ë¥¼ ë§ëëë¤. 119ìì íìë ì¤ê° ì¤ì§ë ë¹ì© ì·¨ìê° ì´ë ¤ì¸ ì ìì´ì.`,`ã¢ãããã¼ãããååã§åæç»åã使ãã¾ãã 120éå§å¾ã¯éä¸åæ¢ãè²»ç¨ã®åãæ¶ããé£ããå ´åãããã¾ãã`,`Creates a composite image from your product. 121After it starts, stopping midway or cancelling the cost may not be possible.`):o(`먼ì í©ì± ì´ë¯¸ì§ë¥¼ ë§ë ë¤ ì»¨ì ·ì¤í 리보ëë¡ ì´ì´ì§ëë¤. 122ìì ìì± ë¹ì©ì ê·¸ ë¤ì ë¨ê³ìì ë°ë¡ íì¸í©ëë¤.`,`ã¾ãåæç»åã使ããã³ã³ã»ããã»ã¹ãã¼ãªã¼ãã¼ãã¸é²ã¿ã¾ãã 123åç»çæã®è²»ç¨ã¯æ¬¡ã®æ®µéã§å¥é確èªãã¾ãã`,`It first creates the composite image, then moves on to concept and storyboard. 124The video generation cost is confirmed separately at that step.`)}),(0,e.jsxs)("div",{className:"mka-box mt-5 p-4",children:[(0,e.jsx)("span",{className:"text-[15px] font-bold text-foreground",children:zr==="image"?o("í©ì± ì´ë¯¸ì§ ìì±","åæç»åã®çæ","Composite image generation"):o("ì¼ì¸ ìì ìì´ì í¸ ì¤í","ã·ã§ã¼ãåç»ã¨ã¼ã¸ã§ã³ãå®è¡","Run shorts video agent")}),zr==="agent"&&(0,e.jsx)("p",{className:"mt-3 border-t border-border pt-3 text-[12px] leading-5 text-muted-foreground",children:o(`ììê¹ì§ ë§ë¤ë©´ 720p ê¸°ì¤ ${Pt} í¬ë ë§ì´ ì¶ê°ë¡ ì°¨ê°ë©ëë¤(1080p ë ë ëëë¤). ì¤í 리보ë를 íì¸í ë¤ ê²°ì íìë©´ ë©ëë¤.`,`åç»ã¾ã§ä½æããã¨720påºæºã§ ${Pt} ã¯ã¬ã¸ããã追å ã§æ¶è²»ããã¾ãï¼1080pã¯ããã«å¿ è¦ã§ãï¼ãã¹ãã¼ãªã¼ãã¼ãã確èªãã¦ããæ±ºãããã¾ãã`,`Generating the video costs another ${Pt} credits at 720p (1080p costs more). You can decide after reviewing the storyboard.`)})]}),(0,e.jsxs)("div",{className:"mka-dlg-f",children:[(0,e.jsx)(Er,{variant:"g",onClick:()=>Mr(null),children:o("ìëì¤","ããã","No")}),(0,e.jsxs)(Er,{variant:"y",onClick:()=>{const a=zr;Mr(null),a==="image"?Mn():Bn()},...Ve(je.shortsStartConfirm),children:[o("ëìíê³ ìì","åæãã¦éå§","Agree and start"),(0,e.jsx)(fr,{value:ts,variant:"ink"})]})]})]})}),(0,e.jsx)(Qi,{open:Kn,onClose:()=>Es(!1),uploadImages:Dt,onStart:Wn,initialImages:F.productImages,initialHighlights:F.highlights,lockedCasting:Da?.casting,lockedLocation:Da?.location,lockedPresetName:Da?.presetName,seedanceEngine:Ie}),(0,e.jsx)(da,{open:nr!==null,accept:"image",onOpenChange:a=>{a||Bt(null)},onSelectFile:a=>{nr&&er(a,nr)},onSelectLibrary:a=>{nr&&$r(a,nr)}})]})};export{$c as ShortsAgentView};
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.