PageSourceSearch

https://www.studioe.ai/assets/FlatLayBatch-D5jrx4bV.js

js studioe.ai collected 2026-10-05 14:28:46 UTC 115,763 bytes, 21 lines download raw bytes

1import{j as e}from"./jsx-runtime-CqrCmrYQ.js";import{r as i,a as jt,b as Ir}from"./vendor-react-DWiRq_5Q.js";import{toast as v}from"./react-toastify.esm-dODcvvAN.js";import{u as Wr,p as Kr,o as Gr,i as Yr,d as Hr}from"./AuthContext-D_aQViLm.js";import{u as qr}from"./AuthModalContext-Dn1r-5W7.js";import{u as Xr}from"./referenceSelection-D8MVjsOF.js";import{g as Qr}from"./subscription-BI2A8kyt.js";import{a as ve,e as Zr,p as re,q as Jr,k as el,r as tl,s as sl,t as Ze,h as me,u as lr,v as rl,w as ll,o as gt,i as Nt,x as ar,y as al}from"./index-COyPRzeT.js";import{P as nl}from"./index-DpHmcKyI.js";import{L as bt}from"./index-D4pxbIbR.js";import{S as il}from"./ScrollReveal-Dknkigl8.js";import{B as ol}from"./beforeAfterFlatLayExamples-Dwz3IAyz.js";import{D as fe}from"./DropdownMenu-Jz4QorZx.js";import{T as cl}from"./TabSelector-CyOkNz0p.js";import{C as dl}from"./fitPresets-C321BtcG.js";import{G as ul,a as ml,R as fl}from"./GarmentSearch-BbIVY6pS.js";import{C as xl}from"./ColorPickerModal-lP8VnRQC.js";import{L as Je}from"./LockedButton-5TXcm2L2.js";import{u as hl}from"./useLeaveGuard-D9VZ19qO.js";import{readFlatLayBatchSession as pl,writeFlatLayBatchSession as gl,clearFlatLayBatchSession as nr}from"./flatLayBatchLastSession-Dn5flvI7.js";import{S as bl}from"./SessionResumeDialog-BwAtYG6W.js";import{p as wl,c as vl,f as ir,m as yl}from"./moreLikeThis-mCri96A2.js";import{W as or}from"./WorkflowFeedbackModal-Bgb8w4Lv.js";import{a as cs,A as cr}from"./aspectRatios-BcXvHWfU.js";import{F as dr,a as Te,r as ds,d as jl}from"./featureTokens-CK05Y9US.js";import{s as xe,r as us}from"./secureTransport-BT8gXiVx.js";import{i as ur,H as mr,m as et,p as tt,s as st,f as ms}from"./uploadPrep-LCedjOzL.js";import{garmentAssets as H}from"./garmentAssets-Ba_iJWNr.js";import"./vendor-redux-BFhIuSuA.js";import"./TokenCostPill-DyxFPAvf.js";import"./time-C6oRCTH3.js";import"./workflowFeedbackApi-Cifx_jjm.js";import"./metaPixel-Dqi1DP_N.js";import"./errorReporter-D_obZs0p.js";function wt({label:p,value:o,highlight:f=!1,open:Y=!1}){return e.jsxs("div",{className:"flex flex-col gap-[2px] min-w-0",children:[e.jsx("span",{className:`text-[9px] font-medium ${f?"text-purple-300":"text-gray-300"}`,children:p}),e.jsxs("div",{className:`w-full bg-[#16181A] border rounded-md px-2 py-1.5 text-[10px] flex items-center justify-between transition-colors ${f?"border-purple-500/60 ring-1 ring-purple-500/30":"border-[#27272A]"}`,children:[e.jsx("span",{className:"truncate text-gray-100",children:o}),e.jsx(re,{className:`h-3 w-3 ml-1.5 text-gray-400 transition-transform ${Y?"rotate-180":""}`})]})]})}function Nl(){return e.jsxs("div",{className:"flex flex-col gap-[2px] min-w-0",children:[e.jsx("span",{className:"text-[9px] font-medium text-gray-300",children:"Backgroun
1d"}),e.jsxs("div",{className:"flex items-center gap-1.5 px-1.5 py-1 rounded-md bg-[#16181A] border border-[#252629]",children:[e.jsx("div",{className:"w-4 h-4 rounded-sm border border-white/15",style:{backgroundColor:"#f5f5f0"}}),e.jsx("span",{className:"text-[10px] font-mono text-white truncate",children:"#f5f5f0"})]})]})}const _e=[{title:"New: Cast Shadow Toggle",description:"You can now choose if you'd like to include cast shadows or not.",Mock:()=>e.jsxs("div",{className:"w-full rounded-xl border border-[#27272A] bg-[#0f1113] p-3",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("span",{className:"text-[10px] font-semibold text-gray-300 uppercase tracking-wide",children:"Settings"}),e.jsx("span",{className:"text-[7px] font-bold text-purple-300 bg-purple-500/15 border border-purple-500/30 px-1.5 py-[1px] rounded-full",children:"NEW"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2.5",children:[e.jsx(wt,{label:"View",value:"Front"}),e.jsx(Nl,{}),e.jsx(wt,{label:"Aspect Ratio",value:"Auto"}),e.jsx(wt,{label:"Resolution",value:"1K"}),e.jsxs("div",{className:"relative",children:[e.jsx(wt,{label:"Cast Shadow",value:"Don't Show",highlight:!0,open:!1}),!1]})]})]})}],fr="flatLayBatchWhatsNew_v1_castShadow_dismissed";function kl(){const[p,o]=i.useState(()=>localStorage.getItem(fr)==="1"),[f,Y]=i.useState(0),[y,S]=i.useState(!1),[j,P]=i.useState("right"),[F,K]=i.useState(!1),[U,h]=i.useState(!1),L=i.useRef(0),B=i.useRef(!1);i.useEffect(()=>{const N=setTimeout(()=>h(!0),500);return()=>clearTimeout(N)},[]);const O=i.useCallback(()=>{y||(S(!0),setTimeout(()=>{o(!0),localStorage.setItem(fr,"1")},220))},[y]),le=i.useCallback(N=>{F||N===f||(P(N>f?"right":"left"),K(!0),B.current=!0,L.current+=1,setTimeout(()=>{Y(N),K(!1)},10))},[f,F]),pe=()=>{f<_e.length-1?le(f+1):O()},ge=()=>{f>0&&le(f-1)};if(p||!U)return null;const G=_e[f],x=f===_e.length-1,T=G.Mock;return jt.createPortal(e.jsxs("div",{className:"fixed inset-0 z-[10000] flex items-center justify-center px-4",children:[e.jsx("div",{className:`absolute inset-0 bg-black/70 backdrop-blur-sm transition-opacity duration-200 ${y?"opacity-0":"opacity-100"}`}),e.jsxs("div",{onClick:N=>N.stopPropagation(),className:`relative w-full max-w-md rounded-2xl border border-[#252629] bg-[#16181A] shadow-2xl overflow-hidden ${y?"animate-[whatsNewOut_220ms_ease-out_forwards]":"animate-[whatsNewIn_300ms_ease-out]"}`,children:[e.jsx("button",{type:"button",onClick:O,className:"absolute top-3 right-3 z-10 w-7 h-7 rounded-full bg-white/5 hover:bg-white/10 flex items-center justify-center text-gray-400 hover:text-white transition-colors","aria-label":"Close",children:e.jsx(ve,{className:"w-3.5 h-3.5"})}),e.jsxs("div",{className:"px-5 pt-5 flex items-center justify-between",children:[e.jsx("h2",{className:"text-[15px] font-semibold text-white",children:"What's New"}),e.jsxs("span",{className:"text-[11px] text-gray-500 font-medium tabular-nums mr-8",children:[f+1," / ",_e.length]})]}),e.jsx("div",{className:"overflow-hidden",children:e.jsxs("div",{className:`px-5 pt-4 pb-2 ${B.current?j==="right"?"animate-[slideInRight_280ms_ease-out]":"animate-[slideInLeft_280ms_ease-out]":""}`,children:[e.jsx("h3",{className:"text-base font-semibold text-white leading-snug mb-1.5",children:G.title}),e.jsx("p",{className:"text-[13px] leading-relaxed text-gray-400 mb-4",children:G.description}),e.jsx("div",{className:"pb-3",children:e.jsx(T,{})})]},L.current)}),_e.length>1&&e.jsx("div",{className:"flex justify-center gap-1.5 pb-3 pt-1",children:_e.map((N,k)=>e.jsx("button",{type:"button",onClick:()=>le(k),"aria-label":`Go to step ${k+1}`,className:`rounded-full transition-all duration-300 ${k===f?"w-5 h-2 bg-white":"w-2 h-2 bg-white/15 hover:bg-white/25"}`},k))}),e.jsxs("div",{className:"px-5 pb-5 pt-2 flex items-center gap-3",children:[f>0&&e.jsx("button",{type:"button",onClick:ge,className:"px-4 py-2.5 rounded-full bg-white/5 text-gray-400 text-sm font-medium hover:bg-white/10 active:scale-[0.98] transition-all",children:"Back"}),e.jsx("button",{type:"button",onClick:pe,className:"flex-1 py-2.5 rounded-full bg-white text-gray-900 text-sm font-semibold hover:bg-gray-100 active:scale-[0.98] transition-all flex items-center justify-center gap-2",children:x?"Got it!":e.jsxs(e.Fragment,{children:["Next",e.jsx(Zr,{className:"w-4 h-4"})]})})]})]}),e.jsx("style",{children:`
2        @keyframes slideInRight {
3          from { opacity: 0; transform: translateX(40px); }
4          to   { opacity: 1; transform: translateX(0); }
5        }
6        @keyframes slideInLeft {
7          from { opacity: 0; transform: translateX(-40px); }
8          to   { opacity: 1; transform: translateX(0); }
9        }
10        @keyframes whatsNewIn {
11          from { opacity: 0; transform: scale(0.92) translateY(12px); }
12          to   { opacity: 1; transform: scale(1) translateY(0); }
13        }
14        @keyframes whatsNewOut {
15          from { opacity: 1; transform: scale(1) translateY(0); }
16          to   { opacity: 0; transform: scale(0.92) translateY(12px); }
17        }
18      `})]}),document.body)}const se="https://api.studioe.ai",W=6,vt=100,Cl=450,Sl=[{value:"#ffffff",label:"White"},{value:"#f5f5f0",label:"Ivory"},{value:"#e8e8e8",label:"Light Gray"},{value:"#d3d3d3",label:"Gray"},{value:"#c4b5a0",label:"Beige"},{value:"#2c2c2c",label:"Charcoal"},{value:"#000000",label:"Black"},{value:"#f5e6d3",label:"Sand"},{value:"#d4c5b2",label:"Taupe"},{value:"#b8cce0",label:"Soft Blue"},{value:"#c8d5c8",label:"Sage"},{value:"#e8d5e0",label:"Blush"}];function Rl(p){const o=Sl.find(f=>f.value.toLowerCase()===(p||"").toLowerCase());return o?o.label:p||"#f5f5f0"}const xr=[{value:"1K",label:"1K – Standard Quality"},{value:"2K",label:"2K – High Definition"},{value:"4K",label:"4K – DSLR Print Quality"}],hr=[{value:"as-is",label:"Use Original"},{value:"front",label:"Front"},{value:"back",label:"Back"},{value:"side",label:"Side"}],Al=new Set(["front","back","side"]);function Ee(p){return Al.has(String(p||"").toLowerCase())}function yt(p){const o=String(p||"").toLowerCase();return o==="front"?"Front":o==="back"?"Back":o==="side"?"Side":"Original"}function he(p,o=p==null?void 0:p.garmentView){return!p||!Ee(o)?null:p.viewReferenceView===o&&p.viewReferencePreview?p.viewReferencePreview:null}function pr(){return{viewReferenceFile:null,viewReferencePreview:null,viewReferenceView:null}}function fs(p,o=400){return new Promise((f,Y)=>{const y=URL.createObjectURL(p),S=new Image;S.onload=()=>{URL.revokeObjectURL(y);
18let{naturalWidth:j,naturalHeight:P}=S;if(j>o||P>o){const U=o/Math.max(j,P);j=Math.round(j*U),P=Math.round(P*U)}const F=document.createElement("canvas");F.width=j,F.height=P;const K=F.getContext("2d");K.imageSmoothingEnabled=!0,K.imageSmoothingQuality="high",K.drawImage(S,0,0,j,P),f(F.toDataURL("image/jpeg",.7))},S.onerror=()=>{URL.revokeObjectURL(y),Y(new Error("Thumbnail generation failed"))},S.src=y})}function gr(){return{file:null,preview:null,garmentView:null,bgColor:"#f5f5f0",aspectRatio:"auto",resolution:"1K",customPrompt:"",showShadow:!0,wizardCategory:null,wizardSubtype:null,wizardVariantIndex:0,wizardVariantTitle:null,maskUrl:null,maskPreview:null,viewReferenceFile:null,viewReferencePreview:null,viewReferenceView:null,useMyReference:!1,selectedMyReference:null}}const Pl=()=>e.jsx(dl,{modalTitle:"Reference Upload Explained",modalIcon:e.jsx(Nt,{className:"w-5 h-5"}),contentClassName:"max-w-full",content:()=>e.jsxs("div",{className:"text-white",children:[e.jsx("p",{className:"text-sm text-gray-300 mb-3",children:"Upload any image and our AI will create your custom reference style. No editing required."}),e.jsx("img",{src:`/flat-lay.GIF?t=${Date.now()}`,alt:"Flat-lay example",className:"w-full rounded-lg border border-[#27272A]"})]}),children:e.jsxs("span",{role:"button",tabIndex:0,className:"inline-flex items-center gap-1 px-1.5 sm:px-2.5 py-1 rounded-full bg-[#16181A] border border-[#27272A] text-[10px] sm:text-xs font-medium text-white hover:bg-[#1d2023] shadow-sm transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-500/60 cursor-pointer","aria-label":"Show pro upload tips",children:[e.jsx(Nt,{className:"w-3 h-3 sm:w-4 sm:h-4"}),"How It Works"]})}),br=ol;function wr({compact:p=!1}){const o=br.length,[f,Y]=i.useState(0),[y,S]=i.useState("before"),j=(f-1+o)%o,P=(f+1)%o;i.useEffect(()=>{const x=setTimeout(()=>S("flipping"),1e3),T=setTimeout(()=>S("after"),1700),N=setTimeout(()=>{S("advancing"),setTimeout(()=>{Y(k=>(k+1)%o),S("before")},650)},2700);return()=>{clearTimeout(x),clearTimeout(T),clearTimeout(N)}},[f,o]);const F=p?120:180,K=p?155:230,U=p?60:90,h=p?110:165,L={left:{x:-U,rY:-25,rZ:-6,scale:.85,opacity:.55,z:2},center:{x:0,rY:0,rZ:0,scale:1,opacity:1,z:10},right:{x:U,rY:25,rZ:6,scale:.85,opacity:.55,z:2},offRight:{x:h,rY:40,rZ:10,scale:.75,opacity:0,z:0},offLeft:{x:-h,rY:-40,rZ:-10,scale:.75,opacity:0,z:0}},B=x=>x===f?"center":x===j?"left":x===P?"right":x===(f+2)%o?"incoming":null,O=x=>x===f?"left":x===j?"offLeft":x===P?"center":x===(f+2)%o?"right":null,le=x=>{const T=y==="advancing",N=T?O(x):B(x);if(!N){const ae=L.offRight;return{transform:`translateX(${ae.x}px) rotateY(${ae.rY}deg) rotateZ(${ae.rZ}deg) scale(${ae.scale})`,opacity:0,zIndex:0,pointerEvents:"none",transition:"none"}}const k=N==="incoming"?L.offRight:L[N],ye=T||B(x)!=="incoming";return{transform:`translateX(${k.x}px) rotateY(${k.rY}deg) rotateZ(${k.rZ}deg) scale(${k.scale})`,opacity:k.opacity,zIndex:k.z,pointerEvents:N==="center"?"auto":"none",transition:ye?"transform 0.65s cubic-bezier(.4,.0,.2,1), opacity 0.55s cubic-bezier(.4,.0,.2,1)":"none"}},pe=x=>y==="advancing"?x===f||x===j:x===j?!0:x===f?y==="flipping"||y==="after":!1,ge=x=>{const T=br[x],N=pe(x),ye=(y==="advancing"?O(x):B(x))==="center";return e.jsxs("div",{className:"w-full h-full",style:{transformStyle:"preserve-3d",transition:"transform 0.7s cubic-bezier(.4,.0,.2,1)",transform:N?"rotateY(180deg)":"rotateY(0deg)"},children:[e.jsxs("div",{className:"absolute inset-0 rounded-xl overflow-hidden border border-white/[0.12] shadow-lg",style:{backfaceVisibility:"hidden"},children:[e.jsx("img",{src:T.before,alt:"Before",className:"w-full h-full object-cover",loading:x<4?"eager":"lazy",draggable:!1}),e.jsx("div",{className:"absolute inset-x-0 bottom-0 h-1/3 bg-gradient-to-t from-black/40 to-transparent pointer-events-none"}),ye&&e.jsx("span",{className:"absolute bottom-2 left-1/2 -translate-x-1/2 text-[9px] font-semibold text-white/70 bg-black/40 px-2 py-0.5 rounded-full backdrop-blur-sm",children:"Before"})]}),e.jsxs("div",{className:"absolute inset-0 rounded-xl overflow-hidden border border-purple-400/20 shadow-lg",style:{backfaceVisibility:"hidden",transform:"rotateY(180deg)"},children:[e.jsx("img",{src:T.after,alt:"After",className:"w-full h-full object-cover",loading:x<4?"eager":"lazy",draggable:!1}),e.jsx("div",{className:"absolute inset-x-0 bottom-0 h-1/3 bg-gradient-to-t from-black/40 to-transparent pointer-events-none"}),ye&&e.jsx("span",{className:"absolute bottom-2 left-1/2 -translate-x-1/2 text-[9px] font-semibold text-purple-200/90 bg-purple-900/50 px-2 py-0.5 rounded-full backdrop-blur-sm",children:"After ✨"}),e.jsx("div",{className:"absolute inset-0 bg-purple-500/[0.04] pointer-events-none"})]})]})},G=[...new Set([j,f,P,(f+2)%o])];return e.jsx("div",{className:"flex-1 flex flex-col items-center justify-center px-4 py-3",children:e.jsx("div",{className:"relative flex items-center justify-center",style:{width:"100%",height:`${K+20}px`,perspective:"800px"},children:G.map(x=>e.jsx("div",{className:"absolute will-change-transform",style:{width:`${F}px`,height:`${K}px`,transformStyle:"preserve-3d",transformOrigin:"center center",...le(x)},children:ge(x)},x))})})}function da(){var Xs,Qs,Zs,Js,er,tr,sr,rr;const p=Ir(),{user:o,setCreditBalance:f,isLoading:Y}=Wr(),{openAuthModal:y}=qr(),{myRefs:S,setMyRefs:j,myRefsLoading:P,setMyRefsLoading:F,myRefsError:K,setMyRefsError:U,maskProcessing:h,setMaskProcessing:L,maskProcessingStage:B,setMaskProcessingStage:O,maskOriginalCloudinaryUrl:le,setMaskOriginalCloudinaryUrl:pe,isReferenceNamingOpen:ge,setReferenceNamingOpen:G,pen
18dingReferenceFile:x,setPendingReferenceFile:T,referenceName:N,setReferenceName:k,maskDragActive:ye,setMaskDragActive:ae}=Xr(),rt=String((o==null?void 0:o.subscriptionStatus)||"").toLowerCase(),kt=String((o==null?void 0:o.subscriptionTier)||"").toLowerCase(),xs=rt==="active"||rt==="active-cancelled"||rt==="paused"||rt==="past_due",je=xs&&(kt==="pro"||kt==="elite"),ne=xs&&kt==="elite",$=Qr(o),$e=dr[Te.CUSTOM_REFERENCE_UPLOAD],Ct=o&&Number(o.creditBalance??0)>=$e,[C,hs]=i.useState("reference"),q=i.useMemo(()=>{const t=[{key:"garments",label:"Add Products",desc:"Upload your products",icon:Jr}];return C==="reference"&&t.push({key:"style",label:"Style",desc:"Choose reference styles",icon:el}),t.push({key:"settings",label:"Settings",desc:"Configure each flat lay",icon:tl},{key:"generate",label:"Summary",desc:"Review & generate",icon:sl}),t},[C]),[X,Me]=i.useState(0),_=((Xs=q[X])==null?void 0:Xs.key)||"garments";i.useEffect(()=>{X>=q.length&&Me(q.length-1)},[q.length,X]);const[b,M]=i.useState([]),St=i.useRef(null),vr=i.useRef(null),[Rt,At]=i.useState(null),[Pt,Tt]=i.useState(null),[_t,Et]=i.useState(null),[$t,Mt]=i.useState(null),zt=i.useRef({}),Ft=i.useRef({}),Lt=i.useRef({}),Ut=i.useRef({}),[w,Ne]=i.useState(0),[Q,ps]=i.useState(0),[R,be]=i.useState(1),[yr,Bt]=i.useState(!1),[gs,bs]=i.useState(null),lt=i.useRef(null),[A,ie]=i.useState("default"),[Ot,ws]=i.useState(!0),vs=i.useRef(null),[ze,Fe]=i.useState(""),[at,ke]=i.useState(!1),ys=i.useRef(null),js=i.useRef(null),[Le,Ns]=i.useState(!1),[Ce,Z]=i.useState(null),[we,Vt]=i.useState(null),[Dt,jr]=i.useState("#f5f5f0"),[ks,It]=i.useState(!1),[Cs,Wt]=i.useState(!1),[Ss,Kt]=i.useState(!1),[Rs,Gt]=i.useState(!1),As=i.useRef(null),Ps=i.useRef(null),Ts=i.useRef(null),_s=i.useRef(null),[Se,oe]=i.useState(null),nt=i.useCallback(()=>oe(null),[]);i.useEffect(()=>{if(!Ce)return;const t=s=>{s.key==="Escape"&&Z(null)};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[Ce]),i.useEffect(()=>{if(!Se)return;const t=s=>{s.key==="Escape"&&(Ce||nt())};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[Se,Ce,nt]);const[it,Es]=i.useState(!1),[ot,Ue]=i.useState(!1),[Nr,Yt]=i.useState(null),[Be,Oe]=i.useState([]),[kr,Ve]=i.useState(""),[Re,$s]=i.useState(!1),[J,ct]=i.useState(null),Ht="flatlay:pendingMaskCandidates",Ms=1,Cr=30*60*1e3,Sr=i.useCallback(({candidates:t,originalUrl:s,name:r,slotIndex:a})=>{try{if(!(o!=null&&o.id)||!s||!(t!=null&&t.length))return;const l=t.map(c=>({maskUrl:c.maskUrl})),n={version:Ms,userId:String(o.id),candidates:l,originalUrl:s,name:r||"",slotIndex:typeof a=="number"?a:null,debitedAt:Date.now()};sessionStorage.setItem(Ht,JSON.stringify(n))}catch{}},[o==null?void 0:o.id]),De=i.useCallback(()=>{try{sessionStorage.removeItem(Ht)}catch{}},[]),zs=i.useRef(!1);i.useEffect(()=>{if(!zs.current&&o!=null&&o.id&&!(Be.length>0)){zs.current=!0;try{const t=sessionStorage.getItem(Ht);if(!t)return;const s=JSON.parse(t),r=Date.now()-((s==null?void 0:s.debitedAt)||0);if(!s||s.version!==Ms||s.userId!==String(o.id)||!Array.isArray(s.candidates)||s.candidates.length===0||!s.originalUrl||r<0||r>Cr){De();return}pe(s.originalUrl),Ve(s.name||""),Oe(s.candidates),typeof s.slotIndex=="number"&&s.slotIndex>=0&&Ne(a=>{const l=Math.max(0,((b==null?void 0:b.length)||1)-1);return Math.min(s.slotIndex,l)})}catch{De()}}},[o==null?void 0:o.id]);const u=i.useMemo(()=>b.filter(t=>t.preview&&(t.file||/^https?:\/\//i.test(t.preview))),[b]),ce=u.length,Rr=dr[Te.FLAT_LAY_GENERATE]||1,qt=t=>Rr,E=u.reduce((t,s)=>t+qt(),0),V=Number((o==null?void 0:o.creditBalance)??0),D=V>=E,Fs=(o==null?void 0:o.role)==="admin",Ie=i.useCallback(t=>Fs||t==="1K"?!0:t==="2K"?je:t==="4K"?ne:!0,[Fs,je,ne]),We=i.useMemo(()=>u.some(t=>!Ie(t.resolution||"1K")),[u,Ie]),Ke=i.useMemo(()=>{const t=u.some(r=>
18r.resolution==="4K"),s=u.some(r=>r.resolution==="2K");return t&&!Ie("4K")?"Upgrade to ELITE for 4K":s&&!Ie("2K")?"Upgrade to PRO for 2K":""},[u,Ie]),de=i.useMemo(()=>{if(!u.length)return null;const t=u[0].garmentView;return u.every(s=>s.garmentView===t)?t:void 0},[u]),Xt=i.useMemo(()=>{if(!u.length)return null;const t=u[0].bgColor;return u.every(s=>s.bgColor===t)?t:void 0},[u]),Ge=i.useMemo(()=>{if(!u.length)return null;const t=u[0].aspectRatio;return u.every(s=>s.aspectRatio===t)?t:void 0},[u]),Ae=i.useMemo(()=>{if(!u.length)return null;const t=u[0].resolution;return u.every(s=>s.resolution===t)?t:void 0},[u]),Ye=i.useMemo(()=>{if(!u.length)return null;const t=u[0].showShadow!==!1;return u.every(s=>s.showShadow!==!1===t)?t:void 0},[u]),He=i.useCallback(async t=>{if(!(t!=null&&t.length))return;const s=Array.from(t).filter(c=>!(!ur(c)||c.size>mr));if(!s.length){v.error("No valid image files found. Please use JPG, PNG, or WebP.");return}const r=b.filter(c=>c.preview&&(c.file||/^https?:\/\//i.test(c.preview))).length,a=W-r;if(a<=0){v.info(`Maximum ${W} products per batch.`);return}const l=s.slice(0,a);s.length>l.length&&v.info(`Only ${l.length} of ${s.length} images added (max ${W} products).`);const n=[];for(const c of l)try{const m=await et(c),d=await tt(m),g=await fs(d);n.push({file:d,preview:g})}catch(m){st(m)}n.length&&M(c=>{const m=[...c];let d=0;for(const g of n){if(d>=n.length)break;const I=m.findIndex(os=>!os.file&&!os.preview);I>=0?(m[I]={...m[I],file:g.file,preview:g.preview},d++):m.length<W&&(m.push({...gr(),file:g.file,preview:g.preview}),d++)}return m})},[b]),Ls=i.useCallback(t=>{var r;t.preventDefault(),t.stopPropagation(),Ue(!1);const s=(r=t.dataTransfer)==null?void 0:r.files;s!=null&&s.length&&He(s)},[He]),Ar=i.useCallback(t=>{M(s=>s.filter((r,a)=>a!==t)),be(1),Bt(!1),bs(null)},[]),ue=i.useCallback((t,s,r)=>{M(a=>{const l=[...a];return l[t]={...l[t],[s]:r},l})},[]),dt=i.useCallback((t,s)=>{M(r=>r.map(a=>a.preview?{...a,[t]:s}:a))},[]),Pr=i.useCallback((t,s)=>{const r=Ee(s)?s:null;M(a=>{const l=a[t];if(!l)return a;const n=r&&l.viewReferenceView===r,c=[...a];return c[t]={...l,garmentView:r,...r&&n?{}:pr()},c}),r&&oe({view:r,slotIndexes:[t],warning:!1})},[]),Tr=i.useCallback(t=>{const s=Ee(t)?t:null;let r=[];M(a=>(r=[],a.map((l,n)=>{if(!l.preview)return l;s&&r.push(n);const c=s&&l.viewReferenceView===s;return{...l,garmentView:s,...s&&c?{}:pr()}}))),s&&r.length&&oe({view:s,slotIndexes:r,warning:!1})},[]),ee=i.useCallback(t=>{const s=R;if(t!==s){const r=t>s?"forward":"backward";bs(r),Bt(!0),lt.current&&clearTimeout(lt.current),lt.current=setTimeout(()=>{Bt(!1),lt.current=null},Cl)}be(t)},[R]),Us=i.useCallback((t,s)=>{M(r=>{const a=[...r];return a[t]={...a[t],wizardCategory:s,wizardSubtype:null,wizardVariantIndex:0},a}),ee(2)},[ee]),Bs=i.useCallback((t,s)=>{M(r=>{const a=[...r];return a[t]={...a[t],wizardSubtype:s,wizardVariantIndex:0},a}),ee(3)},[ee]),ut=i.useCallback((t,s,r)=>{M(a=>{const l=[...a];l[t]={...l[t],wizardVariantIndex:s,wizardVariantTitle:r.title||null,maskUrl:r.mask||null,maskPreview:r.img||null,useMyReference:!1,selectedMyReference:null};const n=l.findIndex((c,m)=>m>t&&c.preview&&(c.file||/^https?:\/\//i.test(c.preview))&&!c.maskPreview);return n!==-1&&setTimeout(()=>{Ne(n),be(1),ie("default")},350),l})},[]),mt=i.useCallback((t,s)=>{M(r=>{const a=[...r],l=s.processedMaskUrl||s.originalUrl||null;a[t]={...a[t],maskUrl:s.processedMaskUrl||null,maskPreview:l,useMyReference:!0,selectedMyReference:s,wizardCategory:null,wizardSubtype:null,wizardVariantIndex:0,wizardVariantTitle:null};const n=a.findIndex((c,m)=>m>t&&c.preview&&(c.file||/^https?:\/\//i.test(c.preview))&&!c.maskPreview);return n!==-1&&setTimeout(()=>{Ne(n),be(1),ie("default")},350),a})},[]),Os=i.useCallback(t=>{M(s=>{const r=[...s];return r[t]={...r[t],wizardCategory:null,wizardSubtype:null,wizardVariantIndex:0,wizardVariantTitle:null,maskUrl:null,maskPreview:null,useMyReference:!1,selectedMyReference:null},r})},[]),_r=((Qs=b[w])==null?void 0:Qs.preview)??null,Er=((Zs=b[w])==null?void 0:Zs.wizardCategory)??null;i.useEffect(()=>{const t=b[w];t&&(t.useMyReference&&t.selectedMyReference?ie("my"):ie("default"),t!=null&&t.wizardSubtype?be(3):t!=null&&t.wizardCategory?be(2):be(1),Fe(""),ke(!1))},[w,_r,Er]),i.useEffect(()=>{const t=ys.current;if(!t)return;const s=t.querySelector(`[data-thumb-idx="${w}"]`);if(!s)return;const r=s.offsetLeft-t.offsetWidth/2+s.offsetWidth/2;t.scrollTo({left:r,behavior:"smooth"})},[w]),i.useEffect(()=>{const t=js.current;if(!t)return;const s=t.querySelector(`[data-settings-thumb-idx="${Q}"]`);if(!s)return;const r=s.offsetLeft-t.offsetWidth/2+s.offsetWidth/2;t.scrollTo({left:r,behavior:"smooth"})},[Q]);const Vs=i.useMemo(()=>{try{if(h)return 0;if(Number(R)===1&&A==="default")return Object.keys(H||{}).length}catch{}return 0},[h,R,A]);i.useEffect(()=>{const t=vs.current;if(!t)return;const s=()=>{Ot&&t.scrollTop>10&&(ws(!1),t.removeEventListener("scroll",s))};return t.addEventListener("scroll",s,{passive:!0}),()=>t.removeEventListener("scroll",s)},[R,Ot,_]),i.useEffect(()=>{_==="style"&&ws(Vs>1)},[R,Vs,_]);const Qt=i.useCallback(async()=>
18{if(o)try{F(!0),U("");const t=await xe(`${se}/api/custom-references/list`,{page:1,limit:100},{method:"POST"});j(Array.isArray(t==null?void 0:t.items)?t.items:[])}catch(t){U(t.message||"Failed to load user references"),j([])}finally{F(!1)}},[o,j,F,U]);i.useEffect(()=>{A==="my"&&o&&Qt()},[A,o,Qt]);const Ds=async t=>{const s=await ms(t);return(await xe(`${se}/api/upload`,{file:s},{method:"POST"})).upload},Zt=i.useCallback(async t=>{var s;if(!t||typeof t!="string")return null;if(/^https?:\/\//i.test(t))return t;if(!t.startsWith("data:"))return null;try{const r=await xe(`${se}/api/upload`,{file:t});return((s=r==null?void 0:r.upload)==null?void 0:s.secure_url)||null}catch{return null}},[]),$r=i.useCallback(async(t,s,r)=>{if(!s)return;if(!ur(s)||s.size>mr){v.error("No valid image files found. Please use JPG, PNG, or WebP.");return}let a,l;try{const c=await et(s);a=await tt(c),l=await fs(a)}catch(c){st(c);return}let n=null;M(c=>{const m=c[t];if(!m)return c;const d=m.garmentView||r||null;if(!Ee(d))return c;n=d;const g=[...c];return g[t]={...m,viewReferenceFile:a,viewReferencePreview:l,viewReferenceView:d},g}),n&&(v.success(`${yt(n)} view image added.`),oe(c=>c&&(c.slotIndexes||[]).length<=1?null:c))},[]),Mr=async t=>{L(!0);let s=null,r=!1;const a=async l=>{if(r){r=!1;try{const n=await ds(Te.CUSTOM_REFERENCE_UPLOAD,$e,{reason:l||"custom_reference_failed"});typeof(n==null?void 0:n.creditBalance)=="number"&&f(n.creditBalance)}catch(n){console.warn("Custom reference refund failed:",n)}}};try{try{if(!(await fetch(`${se}/api/health`,{method:"GET",signal:AbortSignal.timeout(5e3)})).ok)throw new Error("Server unavailable")}catch{return v.error("Server is temporarily unavailable. Please try again later."),L(!1),{candidates:[],originalUrl:null}}try{const d=await jl(Te.CUSTOM_REFERENCE_UPLOAD,{beforeBalance:o==null?void 0:o.creditBalance,user:o});typeof(d==null?void 0:d.creditBalance)=="number"&&f(d.creditBalance),r=!0}catch(d){return(d==null?void 0:d.code)==="SERVER_OFFLINE"||(d==null?void 0:d.code)==="INSUFFICIENT_TOKENS"?(L(!1),{candidates:[],originalUrl:null}):(v.error("Something went wrong while processing credits."),L(!1),{candidates:[],originalUrl:null})}const l=await Ds(t);if(s=(l==null?void 0:l.secure_url)||(l==null?void 0:l.url)||null,!s)return await a("upload_failed"),v.error("Failed to upload your image. Please try again."),L(!1),{candidates:[],originalUrl:null};pe(s);const n=await xe(`${se}/api/custom-references/generate-mask`,{imageUrl:s,numCandidates:2},{method:"POST"}),c=Array.isArray(n==null?void 0:n.candidates)?n.candidates:n!=null&&n.maskUrl?[{maskUrl:n.maskUrl,maskData:n.maskData,mimeType:n.mimeType}]:[];if(!(n!=null&&n.ok)||c.length===0)throw new Error((n==null?void 0:n.error)||"Mask generation failed");return{candidates:await Promise.all(c.map(async(d,g)=>{const I=await fetch(`data:${d.mimeType||"image/png"};base64,${d.maskData}`).then(Dr=>Dr.blob());return{maskFile:new File([I],`custom-mask-${g+1}.png`,{type:d.mimeType||"image/png"}),maskUrl:d.maskUrl}})),originalUrl:s}}catch(l){return console.warn("Custom mask pipeline failed",l),await a("pipeline_failed"),v.error("Reference processing failed. Please try again."),{candidates:[],originalUrl:null}}finally{L(!1)}};i.useEffect(()=>{if(h){O("initial");const t=setTimeout(()=>O(a=>a==="initial"?"bgRemoval":a),5e3),s=setTimeout(()=>O(a=>a==="bgRemoval"||a==="initial"?"silhouette":a),1e4),r=setTimeout(()=>O(a=>a==="silhouette"?"silhouetteWaiting":a),15e3);return()=>{clearTimeout(t),clearTimeout(s),clearTimeout(r)}}else O(null)},[h,O]),hl({when:h,message:"A custom reference is being processed. Leaving now will cancel the upload. Are you sure?"});const ft=i.useRef(new WeakMap),Jt=i.useRef(new WeakSet),Is=i.useCallback(t=>{for(const s of t)for(const r of[s.file,s.viewReferenceFile])!r||ft.current.has(r)||Jt.current.has(r)||(Jt.current.add(r),Kr(r).then(a=>{var l;Jt.current.delete(r),a&&(ft.current.set(r,a),(l=qe.current)==null||l.call(qe))}))},[]),zr=i.useCallback(async()=>{var a;const t=await pl();if(!((a=t==null?void 0:t.slots)!=null&&a.length))return t;const s=async l=>{if(!Yr(l))return{file:null,thumb:null};const n=await Hr(l);return n?(ft.current.set(n,l),{file:n,thumb:await fs(n).catch(()=>null)}):{file:null,thumb:null}},r=[];for(const l of t.slots){const n=await s(l.fileRef),c=await s(l.viewReferenceFileRef),m=l.preview||n.thumb;m&&r.push({...l,preview:m,file:l.preview?null:n.file,viewReferencePreview:l.viewReferencePreview||c.thumb,viewReferenceFile:l.viewReferencePreview?null:c.file})}return{...t,slots:r}},[]),xt=o?String(o._id||o.id||""):"",ht=i.useCallback((t={})=>{try{const s=t.slots??b;if(!s.some(n=>n.preview||n.file))return;const r=n=>n&&ft.current.get(n)||null,a=s.map(n=>
18{const c=n.preview,m=c&&typeof c=="string"&&/^https?:\/\//i.test(c),d=m?null:r(n.file);return!m&&!d?null:{preview:m?c:null,fileRef:d,viewReferenceFileRef:r(n.viewReferenceFile),bgColor:n.bgColor||"#f5f5f0",aspectRatio:n.aspectRatio||"auto",resolution:n.resolution||"1K",customPrompt:n.customPrompt||"",garmentView:n.garmentView||null,viewReferencePreview:n.viewReferencePreview&&typeof n.viewReferencePreview=="string"&&/^https?:\/\//i.test(n.viewReferencePreview)?n.viewReferencePreview:null,viewReferenceView:n.viewReferenceView||null,showShadow:n.showShadow!==!1,wizardCategory:n.wizardCategory||null,wizardSubtype:n.wizardSubtype||null,wizardVariantIndex:n.wizardVariantIndex||0,wizardVariantTitle:n.wizardVariantTitle||null,maskUrl:n.maskUrl||null,maskPreview:n.maskPreview||null,useMyReference:!!n.useMyReference,selectedMyReference:n.selectedMyReference?{_id:n.selectedMyReference._id||null,name:n.selectedMyReference.name||"",originalUrl:n.selectedMyReference.originalUrl||null,processedMaskUrl:n.selectedMyReference.processedMaskUrl||null}:null}}),l={ts:Date.now(),owner:Gr(xt?{_id:xt}:null),currentStep:t.currentStep??X,generationPath:t.generationPath??C,activeStyleSlot:t.activeStyleSlot??w,wizardTab:t.wizardTab??A,slots:a.filter(Boolean)};gl(l)&&!xt&&Is(s)}catch{}},[xt,X,C,w,A,b,Is]),[es,Ws]=i.useState(!1),te=i.useRef(null),qe=i.useRef(ht);qe.current=ht,i.useEffect(()=>{if(es)return te.current&&clearTimeout(te.current),te.current=setTimeout(()=>{te.current=null,ht()},400),()=>{te.current&&clearTimeout(te.current)}},[ht,es]),i.useEffect(()=>{const t=()=>{te.current&&(clearTimeout(te.current),te.current=null,qe.current())};return window.addEventListener("beforeunload",t),()=>window.removeEventListener("beforeunload",t)},[]);const ts=i.useCallback(t=>{var s,r;if(Ws(!0),!!t){if(t.generationPath&&hs(t.generationPath),t.wizardTab&&ie(t.wizardTab),(s=t.slots)!=null&&s.length){const a=t.slots.map(l=>({...gr(),file:l.file||null,viewReferenceFile:l.viewReferenceFile||null,preview:l.preview,bgColor:l.bgColor||"#f5f5f0",aspectRatio:l.aspectRatio||"auto",resolution:l.resolution||"1K",customPrompt:l.customPrompt||"",garmentView:l.garmentView||null,viewReferencePreview:l.viewReferencePreview||null,viewReferenceView:l.viewReferenceView||null,showShadow:l.showShadow!==!1,wizardCategory:l.wizardCategory||null,wizardSubtype:l.wizardSubtype||null,wizardVariantIndex:l.wizardVariantIndex||0,wizardVariantTitle:l.wizardVariantTitle||null,maskUrl:l.maskUrl||null,maskPreview:l.maskPreview||null,useMyReference:!!l.useMyReference,selectedMyReference:l.selectedMyReference||null}));M(a)}typeof t.activeStyleSlot=="number"&&t.activeStyleSlot>=0&&Ne(Math.min(t.activeStyleSlot,(((r=t.slots)==null?void 0:r.length)||1)-1)),typeof t.currentStep=="number"&&t.currentStep>=0&&setTimeout(()=>{Me(Math.min(t.currentStep,10))},50)}},[]),ss=i.useCallback(()=>{Ws(!0)},[]),[Xe]=i.useState(()=>wl("flat-lay")),Ks=i.useRef(!1);i.useEffect(()=>{!Xe||Ks.current||Y||(Ks.current=!0,vl(),(async()=>{var s;let t=ir(Xe,H,[]);if((s=t.session.slots[0])!=null&&s.useMyReference&&o)try{const r=await xe(`${se}/api/custom-references/list`,{page:1,limit:100},{method:"POST"});Array.isArray(r==null?void 0:r.items)&&(t=ir(Xe,H,r.items))}catch{}ts(t.session),v.info(yl(t.missing)||"Opened with this result's setup. Change anything you like, then generate.",{toastId:"more-like-this",autoClose:7e3})})())},[Xe,Y,o,ts]);const pt=i.useRef([]),rs=i.useRef(0),Qe=i.useRef(new Set),Fr=2,ls=i.useCallback(async()=>{for(;pt.current.length>0&&rs.current<Fr;){const t=pt.current.shift();if(!t)break;rs.current+=1,(async()=>{const{idx:s,file:r,thumbUrl:a,kind:l}=t;try{const n=await ms(r),c=await Zt(n);c&&M(m=>{const d=[...m];if(!d[s])return m;if(l==="view"){const g=d[s];if(g.viewReferencePreview!==a&&!/^data:/.test(g.viewReferencePreview||""))return m;d[s]={...g,viewReferencePreview:c,viewReferenceFile:null}}else{if(d[s].preview!==a&&!/^data:/.test(d[s].preview||""))return m;d[s]={...d[s],preview:c}}return d})}catch{}finally{Qe.current.delete(`${l}:${s}`),rs.current-=1,ls()}})()}},[Zt]),Gs=o?String(o._id||o.id||""):"";i.useEffect(()=>{if(!Gs)return;let t=!1;b.forEach((s,r)=>{if(s.file&&typeof s.preview=="string"&&s.preview.startsWith("data:")){const a=`slot:${r}`;Qe.current.has(a)||(Qe.current.add(a),pt.current.push({kind:"slot",idx:r,file:s.file,thumbUrl:s.preview}),t=!0)}if(s.viewReferenceFile&&typeof s.viewReferencePreview=="string"&&s.viewReferencePreview.startsWith("data:")){const a=`view:${r}`;Qe.current.has(a)||(Qe.current.add(a),pt.current.push({kind:"view",idx:r,file:s.viewReferenceFile,thumbUrl:s.viewReferencePreview}),t=!0)}}),t&&ls()},[b,ls,Gs]);const Lr=t=>Fe(t.target.value),Ur=()=>{Fe(""),ke(!1)},as=i.useMemo(()=>
18{if(!ze.trim())return[];const t=ze.toLowerCase().trim(),s=[];return Object.keys(H).forEach(r=>{const a=H[r];Object.keys(a.subtypes||{}).forEach(l=>{const n=a.subtypes[l],c=(n.title||"").toLowerCase(),m=(a.title||"").toLowerCase();(n.variants||[]).forEach((d,g)=>{((d.title||"").toLowerCase().includes(t)||c.includes(t)||m.includes(t))&&s.push({category:r,categoryTitle:a.title,subtype:l,subtypeTitle:n.title,variant:d,variantIndex:g,source:"default"})})})}),(S||[]).forEach(r=>{if(!(r!=null&&r.originalUrl)||!(r!=null&&r.processedMaskUrl))return;(r.name||"").toLowerCase().includes(t)&&s.push({category:null,categoryTitle:"My Styles",subtype:null,subtypeTitle:r.name||"Custom Reference",variant:{img:r.originalUrl,mask:r.processedMaskUrl,title:r.name||"Custom Reference"},variantIndex:0,source:"my",myRef:r})}),s.sort((r,a)=>(r.variant.title||"").localeCompare(a.variant.title||"")),s},[ze,S]),Pe=ze.trim().length>0,Br=i.useCallback(t=>{const s=w;t.source==="my"&&t.myRef?mt(s,t.myRef):(ue(s,"wizardCategory",t.category),ue(s,"wizardSubtype",t.subtype),ut(s,t.variantIndex,t.variant)),Fe(""),ke(!1)},[w,mt,ue,ut]),Or=i.useCallback(t=>{var r;if(t===0)return!0;if(u.length===0)return!1;const s=(r=q[t])==null?void 0:r.key;return!((s==="settings"||s==="generate")&&C==="reference"&&!u.every(a=>a.maskPreview))},[u,C]),ns=()=>Me(t=>Math.min(t+1,q.length-1)),Ys=()=>Me(t=>Math.max(t-1,0)),Hs=i.useMemo(()=>u.length>0&&u.every(t=>t.maskPreview),[u]),is=i.useMemo(()=>_==="garments"?u.length>0:_==="style"&&C==="reference"?Hs:!0,[_,u.length,C,Hs]);i.useEffect(()=>{w>=b.length&&Ne(Math.max(0,b.length-1)),Q>=b.length&&ps(Math.max(0,b.length-1))},[b.length,w,Q]);const qs=async()=>{var s;if(!o){v.info("You must be signed in to continue."),y("login",{mode:"login"});return}if($){p($.ctaHref);return}if(!u.length){v.error("Upload at least one product image to generate.");return}if(We){us({reason:"plan",message:Ke});return}if(E>0&&!D){v.error(`Not enough credits. You need ${E} but only have ${V}.`,{autoClose:6e3});return}Ns(!0);let t=!1;try{const r=[];for(const l of b){if(!l.preview||!l.file&&!/^https?:\/\//i.test(l.preview))continue;const n=[];if(C==="reference"){const g=l.maskPreview||l.maskUrl;g&&n.push(g)}const c=he(l);let m=c||l.preview;const d=c?l.viewReferenceFile:l.file;if(/^data:/i.test(m)&&d)try{const g=await ms(d),I=await Zt(g);I&&(m=I)}catch{}n.push(m),r.push({imageUrls:n,bgColor:l.bgColor||"#f5f5f0",garmentView:l.garmentView||null,aspectRatio:l.aspectRatio||"auto",resolution:l.resolution||"1K",generationPath:C,customPrompt:((s=l.customPrompt)==null?void 0:s.trim())||null,showShadow:l.showShadow!==!1,wizardCategory:l.wizardCategory||null,wizardSubtype:l.wizardSubtype||null,wizardVariantTitle:l.wizardVariantTitle||null,useMyReference:!!l.useMyReference})}if(!r.length){v.error("No valid products to generate.");return}v.info(`Queuing ${r.length} flat lay generation${r.length>1?"s":""}…`,{autoClose:4e3});const a=await xe(`${se}/api/flat-lay/queue-batch`,{combos:r});a!=null&&a.ok&&Array.isArray(a.jobs)?(typeof a.creditBalance=="number"&&f(a.creditBalance),v.success(`${r.length} flat lay${r.length>1?"s":""} queued (${a.debited||E} credit${(a.debited||E)>1?"s":""} used).`,{autoClose:6e3}),t=!0):(a==null?void 0:a.code)==="INSUFFICIENT_TOKENS"?(typeof a.currentBalance=="number"&&f(a.currentBalance),v.error(`Not enough credits. Need ${a.required||E} but have ${a.currentBalance??V}.`,{autoClose:6e3})):v.error((a==null?void 0:a.error)||"Failed to queue batch. Please try again.")}catch(r){if(console.error("Flat lay batch error:",r),(r==null?void 0:r.code)==="INSUFFICIENT_TOKENS"){const a=r.data||{};typeof a.currentBalance=="number"&&f(a.currentBalance),v.error(`Not enough credits. Need ${a.required||E} but have ${a.currentBalance??V}.`,{autoClose:6e3})}else(r==null?void 0:r.code)!=="SERVER_OFFLINE"&&v.error((r==null?void 0:r.message)||"Generation failed. Please try again.")}finally{Ns(!1),t&&(nr(),p("/projects?tab=allProjects"))}},z=(Js=b[w])!=null&&Js.preview?b[w]:null,Vr=()=>!yr||!gs?"":gs==="forward"?"wizard-slide-in-forward":"wizard-slide-in-backward";return e.jsxs("div",{className:"fixed inset-0 text-white z-[10]",children:[e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{className:"absolute inset-0 pointer-events-none overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 bg-gray-900"}),e.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(900px_circle_at_15%_10%,rgba(160,200,230,0.20),transparent_55%),radial-gradient(900px_circle_at_85%_20%,rgba(180,200,220,0.14),transparent_55%),radial-gradient(1000px_circle_at_50%_90%,rgba(160,190,210,0.10),transparent_60%)]"}),e.jsx("div",{className:"absolute inset-0 opacity-[0.10] [background-image:linear-gradient(to_right,rgba(255,255,255,0.12)_1px,transparent_1px),linear-gradient(to_bottom,rgba(255,255,255,0.12)_1px,transparent_1px)] [background-size:88px_88px]"})]}),e.jsxs(il,{className:"flex-1 min-h-0 h-full",children:[e.jsxs("div",{className:"relative pt-20 lg:pt-24 pb-32 lg:pb-4 max-w-[1440px] mx-auto px-4 flex flex-col h-full overflow-y-auto overflow-x-hidden touch-pan-y",children:[e.jsx("div",{className:`mb-0 bg-[#111318]/80 backdrop-blur-md rounded-2xl px-1.5 py-1.5 border border-white/[0.06] shadow-lg shadow-black/20 transition-opacity ${h?"opacity-50 pointer-events-none":""}`,children:e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("div",{className:"flex items-center gap-1 flex-1 min-w-0 overflow-x-auto scrollbar-none",children:q.map((t,s)=>{const r=s===X,a=Or(s)&&!h,l=t.icon;return e.jsxs("button",{disabled:h,onClick:()=>a&&Me(s),className:`group relative flex items-center gap-1.5 whitespace-nowrap px-3.5 py-2 rounded-full text-[14px] font-medium transition-colors duration-200 outline-none focus:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-white/30 ${r?"bg-blue-500/15 text-white ring-1 ring-inset ring-blue-400/30":a?"text-white hover:bg-white/[0.05]":"text-gray-600 cursor-default"}`,children:[e.jsx(l,{className:`w-3.5 h-3.5 shrink-0 ${r?"text-blue-400":""}`}),t.label]},t.key)})}),X<q.length-1&&e.jsxs("button",{onClick:ns,disabled:!is||h,className:"hidden sm:flex shrink-0 items-center gap-2 px-5 py-2 bg-[#326CB4] hover:bg-[#3A78C6] active:bg-[#285789] rounded-full text-sm font-semibold text-white transition-all disabled:opacity-30 disabled:cursor-not-allowed",children:["Next ",e.jsx(Ze,{className:"w-4 h-4"})]})]})}),e.jsx("div",{className:"flex gap-6 mt-2 lg:mt-6 flex-1 min-h-0",children:e.jsxs("div",{className:"flex-1 min-w-0 min-h-0 flex flex-col overflow-y-auto scrollbar-thin scrollbar-thumb-white/10 scrollbar-track-transparent",children:[_==="garments"&&e.jsxs("div",{className:"flex flex-col md:flex-row gap-6 md:items-stretch",children:[e.jsx("div",{className:"flex-1 min-w-0 flex flex-col",children:u.length===0?e.jsxs("div",{className:"flex-1 flex flex-col",children:[e.jsxs("div",{ref:vr,className:`flex-1 flex flex-col items-center justify-center py-8 sm:py-14 px-6 rounded-2xl transition-colors duration-200 ${ot?"border-2 border-dashed border-blue-500 bg-blue-500/[0.06] ring-2 ring-blue-500/30":"border-2 border-transparent"}`,onDragOver:t=>{t.preventDefault(),Ue(!0)},onDragLeave:t=>{t.currentTarget.contains(t.relatedTarget)||Ue(!1)},onDrop:Ls,children:[e.jsx("div",{className:"md:hidden w-full mb-4",children:e.jsx("div",{className:"h-[180px] w-full",children:e.jsx(wr,{compact:!0})})}),e.jsx("div",{className:"hidden md:block relative w-52 h-40 sm:w-72 sm:h-56 mb-6",children:[{src:"/try-on/product_shot2.webp",rotate:-12,x:-40},{src:"/try-on/product_shot1.webp",rotate:0,x:0},{src:"/try-on/product_shot3.webp",rotate:12,x:40}].map((t,s)=>e.jsx("div",{className:"absolute top-0 left-1/2 w-28 h-36 sm:w-40 sm:h-52 rounded-2xl overflow-hidden bg-white shadow-xl border border-gray-200",style:{transform:`translateX(calc(-50% + ${t.x}px)) rotate(${t.rotate}deg)`,zIndex:s===1?3:1},children:e.jsx("img",{src:t.src,alt:"",className:"w-full h-full object-cover"})},s))}),e.jsx("h2",{className:"text-base lg:text-xl font-bold text-white mb-3 lg:mb-1 text-center",children:"Upload your products to begin"}),e.jsxs("p",{className:"hidden lg:block text-center text-sm text-gray-400 mb-5",children:["Click or drag and drop your images here",e.jsx("br",{}),e.jsxs("span",{className:"text-gray-500 text-xs",children:["You can upload multiple images — max ",W]})]}),e.jsxs("label",{className:`relative flex items-center justify-center gap-2.5 px-10 py-3.5 rounded-full text-sm font-semibold text-white whitespace-nowrap transition-all cursor-pointer ${ot?"bg-blue-600 ring-2 ring-blue-400 scale-105":"bg-[#1a1d23] hover:bg-[#22262e] border border-white/10"}`,children:[e.jsx("input",{ref:St,type:"file",accept:"image/jpeg,image/png,image/webp,image/heic,image/heif",multiple:!0,className:"hidden",onChange:t=>{var s;(s=t.target.files)!=null&&s.length&&He(t.target.files),t.target.value=""}}),"Upload your images",e.jsx("span",{className:"text-lg",children:"+"})]})]}),e.jsx("div",{className:"md:hidden w-full mt-1.5 rounded-2xl border border-white/10 bg-[#14161a] overflow-hidden",children:e.jsxs("div",{className:"flex flex-col divide-y min-[501px]:grid min-[501px]:grid-cols-2 min-[501px]:divide-y-0 min-[501px]:divide-x divide-white/5",children:[e.jsxs("div",{className:"px-3 py-3",children:[e.jsxs("h4",{className:"text-[10px] font-bold text-white flex items-center gap-1.5 mb-0.5",children:[e.jsx("span",{className:"flex h-3.5 w-3.5 items-center justify-center rounded-full bg-emerald-500/15",children:e.jsx(me,{className:"w-2 h-2 text-emerald-400"})}),"What Works Best"]}),e.jsx("div",{className:"grid grid-cols-3 gap-1.5",children:[{src:"good_bad_uploads/good1.webp",alt:"Plain background"},{src:"good_bad_uploads/good2.webp",alt:"Even lighting"},{src:"good_bad_uploads/good3.webp",alt:"Fills frame"}].map((t,s)=>e.jsxs("div",{className:"relative rounded-md overflow-hidden border border-emerald-500/15 bg-[#121416]",children:[e.jsx("img",{src:t.src,alt:t.alt,className:"w-full aspect-square object-cover",loading:"lazy"}),e.jsx("div",{className:"absolute bottom-0.5 left-1/2 -translate-x-1/2",children:e.jsx("span",{className:"flex h-3.5 w-3.5 items-center justify-center rounded-full bg-emerald-500 shadow-lg",children:e.jsx(me,{className:"w-2 h-2 text-white"})})})]},s))})]}),e.jsxs("div",{className:"px-3 py-3",children:[e.jsxs("h4",{className:"text-[10px] font-bold text-white flex items-center gap-1.5 mb-0.5",children:[e.jsx("span",{className:"flex h-3.5 w-3.5 items-center justify-center rounded-full bg-rose-500/15",children:e.jsx(ve,{className:"w-2 h-2 text-rose-400"})}),"What to Avoid"]}),e.jsx("div",{className:"grid grid-cols-3 gap-1.5",children:[{src:"good_bad_uploads/bad1.webp",alt:"Cluttered background"},{src:"good_bad_uploads/bad2.webp",alt:"Harsh lighting"},{src:"good_bad_uploads/bad3.webp",alt:"Tight crop"}].map((t,s)=>e.jsxs("div",{className:"relative rounded-md overflow-hidden border border-rose-500/15 bg-[#121416]",children:[e.jsx("img",{src:t.src,alt:t.alt,className:"w-full aspect-square object-cover",loading:"lazy"}),e.jsx("div",{className:"absolute bottom-0.5 left-1/2 -translate-x-1/2",children:e.jsx("span",{className:"flex h-3.5 w-3.5 items-center justify-center rounded-full bg-rose-500 shadow-lg",children:e.jsx(ve,{className:"w-2 h-2 text-white"})})})]},s))})]})]})})]}):e.jsxs("div",{className:"relative",onDragOver:t=>{t.preventDefault(),Ue(!0)},onDragLeave:t=>{t.currentTarget.contains(t.relatedTarget)||Ue(!1)},onDrop:Ls,children:[e.jsx("div",{className:`absolute inset-0 z-30 rounded-2xl pointer-events-none transition-opacity duration-150 ${ot?"opacity-100":"opacity-0"}`,style:{willChange:"opacity"},children:e.jsx("div",{className:`absolute inset-0 rounded-2xl border-2 border-dashed bg-black/20 flex items-center justify-center ${u.length>=W?"border-amber-500/40":"border-blue-500/40"}`,children:u.length>=W?e.jsxs("p",{className:"text-sm font-semibold text-white/90",children:["Maximum ",W," products reached — remove one first"]}):e.jsxs("p",{className:"text-sm font-semibold text-white/90",children:["Drop to add (",u.length,"/",W,")"]})})}),e.jsxs("div",{className:"space-y-3 sm:space-y-5",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-bold",children:"Add Products"}),e.jsxs("p",{className:"text-sm text-gray-400 mt-0.5",children:["Add up to ",W," product images. Each becomes a separate flat lay."]})]}),e.jsxs("div",{className:"rounded-xl border border-white/10 bg-[#14161a] p-4",children:[e.jsx("label",{className:"text-[11px] font-semibold text-gray-400 uppercase tracking-wider block mb-3",children:"Generation Mode"}),e.jsx("div",{className:"flex flex-col sm:flex-row gap-3",children:[{id:"reference",label:"Reference Based",badge:"Recommended",badgeCls:"bg-emerald-500/20 text-emerald-300 border-emerald-500/30",activeCls:"border-emerald-500/50 bg-emerald-500/10 shadow-emerald-500/10",radioCls:"border-emerald-400",dotCls:"bg-emerald-400",desc:"Choose a reference style from our library. Best accuracy."},{id:"guess",label:"Let AI Guess",badge:"Fast",badgeCls:"bg-blue-500/15 text-blue-300 border-blue-500/30",activeCls:"border-blue-500/50 bg-blue-500/10 shadow-blue-500/10",radioCls:"border-blue-400",dotCls:"bg-blue-400",desc:"No reference needed — AI guesses the best flat lay arrangement."}].map(t=>e.jsxs("button",{onClick:()=>hs(t.id),className:`flex-1 text-left rounded-xl border p-3 transition-all ${C===t.id?`${t.activeCls} shadow-sm`:"border-white/10 bg-white/[0.02] hover:border-white/20"}`,children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("div",{className:`w-4 h-4 rounded-full border-2 flex items-center justify-center ${C===t.id?t.radioCls:"border-gray-600"}`,children:C===t.id&&e.jsx("div",{className:`w-2 h-2 rounded-full ${t.dotCls}`})}),e.jsx("span",{className:"text-sm font-semibold text-white",children:t.label}),e.jsx("span",{className:`text-[9px] font-bold uppercase tracking-wide px-1.5 py-0.5 rounded-full border ${t.badgeCls}`,children:t.badge})]}),e.jsx("p",{className:"text-[11px] text-gray-400 ml-6",children:t.desc})]},t.id))})]}),e.jsxs("div",{className:"grid grid-cols-1 min-[420px]:grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6 gap-3",children:[b.map((t,s)=>{var r;return t.preview?e.jsxs("div",{className:"rounded-xl border border-white/10 bg-[#14161a] overflow-hidden group relative transition-all",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-white/5",children:[e.jsxs("span",{className:"text-[10px] font-semibold text-gray-400 uppercase tracking-wider",children:["Product ",s+1]}),e.jsx("button",{onClick:()=>Ar(s),className:"p-1 rounded-lg hover:bg-red-500/15 text-gray-500 hover:text-red-400 transition-colors",children:e.jsx(lr,{className:"w-3 h-3"})})]}),e.jsxs("div",{className:"relative aspect-[3/2] sm:aspect-[3/4] bg-black/20",children:[e.jsx("img",{src:t.preview,alt:`Product ${s+1}`,className:"w-full h-full object-contain"}),C==="reference"&&t.maskPreview&&e.jsxs("div",{className:"absolute bottom-2 left-2 right-2 flex items-center gap-2 bg-black/70 backdrop-blur-sm rounded-lg px-2 py-1.5",children:[e.jsx("img",{src:t.maskPreview,alt:"Ref",className:"w-6 h-6 rounded object-contain"}),e.jsx("span",{className:"text-[9px] text-gray-300 truncate flex-1",children:t.useMyReference?((r=t.selectedMyReference)==null?void 0:r.name)||"My Style":(()=>{var n,c,m,d;const a=(n=H)==null?void 0:n[t.wizardCategory],l=(c=a==null?void 0:a.subtypes)==null?void 0:c[t.wizardSubtype];return((d=(m=l==null?void 0:l.variants)==null?void 0:m[t.wizardVariantIndex])==null?void 0:d.title)||"Reference"})()}),e.jsx("button",{onClick:a=>{a.stopPropagation(),Os(s)},className:"p-0.5 rounded hover:bg-white/10 text-gray-400 hover:text-white",children:e.jsx(ve,{className:"w-3 h-3"})})]})]})]},s):null}),u.length<W&&e.jsxs("div",{onClick:()=>{var t;return(t=St.current)==null?void 0:t.click()},className:`rounded-xl border-2 border-dashed transition-all overflow-hidden cursor-pointer group ${ot?"border-blue-500 ring-2 ring-blue-500/40 bg-blue-500/10":"border-white/40 bg-[#1a1a1f] hover:border-white/60"}`,children:[e.jsx("div",{className:"px-3 py-2 border-b border-transparent",children:e.jsx("span",{className:"text-[10px] font-semibold text-transparent uppercase tracking-wider select-none",children
18:" "})}),e.jsxs("div",{className:"aspect-[3/2] sm:aspect-[3/4]  flex flex-col items-center justify-center gap-1.5",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-white/[0.05] flex items-center justify-center mb-1",children:e.jsx(rl,{strokeWidth:2,className:"w-6 h-6 text-gray-300 group-hover:text-white transition-colors"})}),e.jsx("p",{className:"text-[13px] text-gray-200 group-hover:text-white font-semibold transition-colors",children:"Add Product"}),e.jsx("p",{className:"text-[11px] text-gray-400 group-hover:text-gray-300 transition-colors",children:"or drag & drop"}),e.jsxs("p",{className:"text-[11px] text-gray-500 mt-0.5",children:[u.length,"/",W]})]})]}),e.jsx("input",{ref:St,type:"file",accept:"image/jpeg,image/png,image/webp,image/heic,image/heif",multiple:!0,className:"hidden",onChange:t=>{var s,r;(((s=t.target.files)==null?void 0:s.length)>1||(r=t.target.files)!=null&&r[0])&&He(t.target.files),t.target.value=""}})]})]})]})}),u.length===0&&e.jsxs("div",{className:"hidden md:flex flex-col md:w-[320px] lg:w-[460px] shrink-0 self-start sticky top-0 rounded-2xl border border-white/10 bg-[#14161a] overflow-hidden",children:[e.jsxs("div",{className:"shrink-0 border-b border-white/5",children:[e.jsx("p",{className:"text-[11px] font-semibold text-gray-400 uppercase tracking-wider text-center pt-3 lg:pt-4",children:"Quality you can expect"}),e.jsx("div",{className:"h-[200px] lg:h-[270px] flex items-center justify-center overflow-hidden",children:e.jsx("div",{className:"scale-[0.72] lg:scale-100 origin-center",children:e.jsx(wr,{})})})]}),e.jsxs("div",{className:"px-3 lg:px-4 pt-3 lg:pt-3.5 pb-2 lg:pb-2.5",children:[e.jsxs("h4",{className:"text-xs font-bold text-white flex items-center gap-1.5 mb-0.5",children:[e.jsx("span",{className:"flex h-4 w-4 items-center justify-center rounded-full bg-emerald-500/15",children:e.jsx(me,{className:"w-2.5 h-2.5 text-emerald-400"})}),"What Works Best"]}),e.jsx("p",{className:"text-[10px] text-gray-400 mb-2 leading-relaxed",children:"Front-facing, flat surface, good lighting, no wrinkles"}),e.jsx("div",{className:"grid grid-cols-3 gap-1.5 lg:gap-2",children:[{src:"good_bad_uploads/good1.webp",alt:"Plain background"},{src:"good_bad_uploads/good2.webp",alt:"Even lighting"},{src:"good_bad_uploads/good3.webp",alt:"Fills frame"}].map((t,s)=>e.jsxs("div",{className:"relative rounded-lg overflow-hidden border border-emerald-500/15 bg-[#121416]",children:[e.jsx("img",{src:t.src,alt:t.alt,className:"w-full aspect-[4/3] object-cover",loading:"lazy"}),e.jsx("div",{className:"absolute bottom-1 left-1/2 -translate-x-1/2",children:e.jsx("span",{className:"flex h-5 w-5 items-center justify-center rounded-full bg-emerald-500 shadow-lg",children:e.jsx(me,{className:"w-3 h-3 text-white"})})})]},s))})]}),e.jsxs("div",{className:"px-3 lg:px-4 pt-1.5 lg:pt-2 pb-3 lg:pb-3.5",children:[e.jsxs("h4",{className:"text-xs font-bold text-white flex items-center gap-1.5 mb-0.5",children:[e.jsx("span",{className:"flex h-4 w-4 items-center justify-center rounded-full bg-rose-500/15",children:e.jsx(ve,{className:"w-2.5 h-2.5 text-rose-400"})}),"What to Avoid"]}),e.jsx("p",{className:"text-[10px] text-gray-400 mb-2 leading-relaxed",children:"Bad lighting, folded sleeves, angled shots, cluttered backgrounds"}),e.jsx("div",{className:"grid grid-cols-3 gap-1.5 lg:gap-2",children:[{src:"good_bad_uploads/bad1.webp",alt:"Cluttered background"},{src:"good_bad_uploads/bad2.webp",alt:"Harsh lighting"},{src:"good_bad_uploads/bad3.webp",alt:"Tight crop"}].map((t,s)=>e.jsxs("div",{className:"relative rounded-lg overflow-hidden border border-rose-500/15 bg-[#121416]",children:[e.jsx("img",{src:t.src,alt:t.alt,className:"w-full aspect-[4/3] object-cover",loading:"lazy"}),e.jsx("div",{className:"absolute bottom-1 left-1/2 -translate-x-1/2",children:e.jsx("span",{className:"flex h-5 w-5 items-center justify-center rounded-full bg-rose-500 shadow-lg",children:e.jsx(ve,{className:"w-3 h-3 text-white"})})})]},s))})]})]})]}),_==="style"&&e.jsxs("div",{className:"space-y-1 sm:space-y-5 flex-1 min-h-0 flex flex-col",children:[e.jsx("h2",{className:"text-lg font-bold",children:"Choose how each product should look like"}),e.jsxs("div",{className:"flex flex-col md:flex-row gap-3 md:gap-4 flex-1 min-h-0",children:[e.jsx("div",{className:"md:w-[280px] lg:w-[340px] xl:w-[400px] shrink-0 flex flex-col gap-1.5 min-h-0",children:z?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"hidden sm:flex flex-1 min-h-0 rounded-2xl border border-white/10 bg-[#14161a] overflow-hidden",children:e.jsx("div",{className:"relative w-full h-full bg-black/30",children:e.jsx("img",{src:z.preview,alt:`Product ${w+1}`,className:"absolute inset-0 w-full h-full object-contain p-6"})})}),u.length>1&&e.jsx("div",{ref:ys,className:"shrink-0 flex items-center gap-2.5 overflow-x-auto scrollbar-none px-2 py-2",children:b.map((t,s)=>{if(!t.preview)return null;const r=w===s,a=!!t.maskPreview;return e.jsx("button",{"data-thumb-idx":s,onClick:()=>Ne(s),className:`relative shrink-0 rounded-xl transition-all ${r?"ring-[3px] ring-blue-500 ring-offset-2 ring-offset-[#0d0f12]":"hover:opacity-80"}`,children:e.jsxs("div",{className:"w-[90px] h-[90px] sm:w-24 sm:h-24 rounded-xl overflow-hidden border border-white/15 bg-[#14161a] relative",children:[e.jsx("img",{src:t.preview,alt:"",className:"w-full h-full object-contain p-0.5"}),a&&e.jsx("div",{className:"absolute top-1.5 right-1.5 w-6 h-6 sm:w-5 sm:h-5 rounded-full bg-emerald-500 flex items-center justify-center shadow-lg",children:e.jsx(me,{className:"w-4 h-4 text-white",strokeWidth:3})})]})},s)})})]}):e.jsx("div",{className:"flex-1 rounded-2xl border border-white/10 bg-[#14161a] flex items-center justify-center",children:e.jsx("p",{className:"text-sm text-gray-500",children:"No garment uploaded for this slot."})})}),e.jsxs("div",{className:"flex-1 min-w-0 flex flex-col min-h-0",children:[e.jsx("div",{className:"shrink-0 rounded-t-xl border-t border-l border-r border-t-white/10 border-l-white/10 border-r-white/10 bg-[#14161a] overflow-hidden",children:z&&!h&&e.jsxs("div",{className:"px-2.5 pt-1.5 pb-1.5 sm:px-3 sm:pt-2 sm:pb-2 lg:px-4 lg:pt-3 lg:pb-3 border-b border-white/5",children:[e.jsxs("div",{className:"flex flex-row items-center gap-1.5 lg:gap-2",children:[e.jsx("button",{onClick:()=>{A==="my"?(ie("default"),ee(1),ke(!0)):ke(!at)},className:"p-1.5 sm:p-2.5 hover:bg-gray-700/10 border border-gray-700 rounded-full transition-all group flex-shrink-0 aspect-square",title:at?"Close search":"Search products",children:e.jsx(ll,{className:`w-4 h-4 sm:w-5 sm:h-5 transition-colors ${at&&A==="default"?"text-[#326CB4]":"text-gray-400 group-hover:text-[#326CB4]"}`})}),e.jsx("div",{className:"flex-1 flex justify-end",children:e.jsx("div",{className:"w-full md:w-auto md:min-w-[300px] lg:min-w-[400px]",children:e.jsx(cl,{fullWidth:!0,value:A,onChange:t=>{if(t!==A){if(t==="my"&&!o){v.info("Sign in to access your styles."),y("login",{mode:"login"});return}ie(t),t==="default"&&ee(1),Fe(""),ke(!1)}},tabs:[{id:"default",label:"Studioe Styles"},{id:"my",label:"My Styles"}]})})})]}),A==="default"&&at&&e.jsx("div",{className:"mt-3 animate-[slideIn_0.2s_ease-out]",children:e.jsx(ul,{searchQuery:ze,onSearchChange:Lr,onClearSearch:Ur,placeholder:"Search all products (e.g., 'button down', 'oversize', 'hat')...",searchResults:as,isActive:Pe,autoFocus:!0})})]})}),e.jsxs("div",{className:"relative flex-1 min-h-0 flex flex-col",children:[Ot&&R===1&&!h&&A==="default"&&!Pe&&e.jsx("div",{className:"absolute bottom-4 left-0 right-0 pointer-events-none z-50 flex justify-center",children:e.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-[#326CB4]/85 backdrop-blur-md rounded-lg shadow-lg border border-[#326CB4]/85",style:{animation:"slideDown 1.5s ease-in-out infinite"}
18,children:[e.jsx("svg",{className:"w-4 h-4 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:2.5,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})}),e.jsxs("span",{className:"text-sm text-white font-medium",children:[e.jsx("span",{className:"hidden lg:inline",children:"Scroll for more"}),e.jsx("span",{className:"lg:hidden",children:"Drag for more"})]})]})}),e.jsx("div",{ref:vs,className:`flex-1 min-h-0 overflow-y-auto scrollbar-thin scrollbar-thumb-white/10 scrollbar-track-transparent border-x border-b border-white/10 bg-[#14161a] ${R>1&&z&&!h&&A==="default"&&!Pe?"":"rounded-b-xl"}`,children:z?e.jsxs("div",{className:"p-2.5 sm:p-4 lg:p-5",children:[!h&&A==="default"&&Pe&&as.length>0&&e.jsx("div",{className:"mb-4",children:e.jsx(ml,{results:as,onResultClick:Br,onZoomClick:t=>Z(t)})}),h&&e.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 w-full",style:{minHeight:"60vh"},children:[e.jsx("div",{className:"animate-spin h-6 w-6 rounded-full border-2 border-gray-500 border-t-transparent"}),e.jsxs("div",{className:"text-sm text-gray-300 text-center px-4",children:[B==="initial"&&"Preparing custom reference…",B==="bgRemoval"&&"Removing background from subject...",B==="silhouette"&&"Preparing background...",B==="silhouetteWaiting"&&"Still processing, please hang tight...",!B&&"Processing reference..."]})]}),!h&&A==="default"&&!Pe&&e.jsxs("div",{className:Vr(),children:[R>=2&&e.jsxs("div",{className:"hidden sm:flex items-center gap-2 mb-1.5 sm:mb-2 lg:mb-4 text-xs",children:[e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>ee(1),className:`transition-colors ${R===1?"text-white font-semibold":"text-blue-400 hover:text-blue-300 cursor-pointer"}`,children:"Category"}),e.jsx(Ze,{className:"w-3 h-3 text-gray-600"}),e.jsx("button",{onClick:()=>ee(2),className:`transition-colors ${R===2?"text-white font-semibold":"text-blue-400 hover:text-blue-300 cursor-pointer"}`,children:((tr=(er=H)==null?void 0:er[z.wizardCategory])==null?void 0:tr.title)||"Subtype"})]}),R>=3&&e.jsxs(e.Fragment,{children:[e.jsx(Ze,{className:"w-3 h-3 text-gray-600"}),e.jsx("span",{className:"text-white font-semibold",children:"Variant"})]})]}),R===1&&e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 gap-2 sm:gap-3",children:[e.jsxs("div",{className:"flex flex-col gap-1 sm:gap-1.5",children:[e.jsx("span",{className:"text-xs font-medium px-1 truncate text-[#5A9BF0]",children:"Your Style"}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute top-2 left-2 z-20",onClick:t=>{t.preventDefault(),t.stopPropagation()},children:e.jsx(Pl,{})}),e.jsxs("label",{className:`group relative flex flex-col rounded-xl border-2 border-dashed text-sm transition-all min-h-[190px] overflow-hidden cursor-pointer ${ye?"bg-[#326CB4]/20 border-[#326CB4] ring-2 ring-[#326CB4]/40":"bg-gray-900/50 border-[#326CB4]/40 hover:border-[#326CB4] hover:bg-[#326CB4]/10"} ${o&&!Ct?"pointer-events-none opacity-50":""}`,onClick:t=>{if(!o){t.preventDefault(),v.info("Sign in to upload your own style."),y("login",{mode:"login"});return}Ct||t.preventDefault()},onDragOver:t=>{t.preventDefault(),ae(!0)},onDragLeave:t=>{t.preventDefault(),ae(!1)},onDrop:t=>{var r,a;if(t.preventDefault(),ae(!1),!o)return;const s=(a=(r=t.dataTransfer)==null?void 0:r.files)==null?void 0:a[0];s&&(async()=>{try{const l=await et(s),n=await tt(l);T(n),G(!0)}catch(l){st(l)}})()},children:[e.jsxs("div",{className:"relative flex-1 flex flex-col items-center justify-center gap-2.5 p-4",children:[e.jsx("div",{className:"w-9 h-9 sm:w-10 sm:h-10 rounded-full bg-[#326CB4]/15 group-hover:bg-[#326CB4]/25 flex items-center justify-center transition-colors",children:e.jsx(gt,{className:"w-4 h-4 sm:w-5 sm:h-5 text-[#326CB4]"})}),e.jsxs("span",{className:"text-[10px] sm:text-xs text-gray-400 group-hover:text-gray-300 text-center leading-snug font-semibold capitalize tracking-wide transition-colors",children:["Upload your",e.jsx("br",{}),"own style"]}),!o&&e.jsx("span",{className:"text-[9px] sm:text-[11px] text-amber-400 font-medium tracking-wide text-center",children:"Sign in to access"})]}),e.jsx("input",{type:"file",accept:"image/png,image/jpeg,image/webp,image/heic,image/heif",className:"hidden",disabled:h,onChange:t=>{var r,a;if(!o)return;const s=(a=(r=t.target)==null?void 0:r.files)==null?void 0:a[0];s&&(async()=>{try{const l=await et(s),n=await tt(l);T(n),G(!0)}catch(l){st(l)}})(),t.target.value=""}})]})]})]}),Object.entries(H).map(([t,s])=>{var l;const r=Object.values(s.subtypes||{})[0],a=(l=r==null?void 0:r.variants)==null?void 0:l[0];return e.jsxs("div",{className:"flex flex-col gap-1 sm:gap-1.5",children:[e.jsx("span",{className:"text-xs font-medium px-1 truncate text-gray-400",children:s.title}),e.jsxs("div",{role:"button",tabIndex:0,onClick:()=>Us(w,t),onKeyDown:n=>{(n.key==="Enter"||n.key===" ")&&(n.preventDefault(),Us(w,t))},className:"group relative flex flex-col rounded-xl border-2 text-sm transition-all min-h-[190p
18x] overflow-hidden cursor-pointer bg-gray-900/50 border-gray-800 hover:border-[#326CB4]/60 hover:bg-gray-900/80",children:[(a==null?void 0:a.img)&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"absolute top-2 right-2 z-10 p-1.5 rounded-full bg-black/40 text-gray-400 hover:text-white hover:bg-black/60 transition-colors opacity-100 lg:opacity-0 lg:group-hover:opacity-100",onClick:n=>{n.stopPropagation(),Z(a.img)},title:"View enlarged",children:e.jsx(bt,{className:"w-4 h-4"})}),e.jsx("div",{className:"relative block w-full flex-1 min-h-[130px] lg:min-h-[145px]",children:e.jsx("img",{src:a.img,alt:s.title,loading:"lazy",className:"absolute inset-0 w-full h-full object-contain p-3 group-hover:scale-105 transition-transform duration-300"})})]}),e.jsx("div",{className:"absolute bottom-8 inset-x-0 z-[5] pointer-events-none",children:e.jsxs("span",{className:"text-[10px] text-gray-200 block px-3 pb-0.5 bg-gradient-to-t from-black/70 to-transparent pt-4",children:[Object.keys(s.subtypes||{}).length," ","sub-categories"]})}),e.jsx("div",{className:"px-3 pb-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[13px] font-semibold tracking-tight text-gray-200 group-hover:text-[#7fb0ff] transition-colors",children:"Select"}),e.jsx("svg",{className:"w-4 h-4 text-gray-400 group-hover:text-[#7fb0ff] transition-colors",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","aria-hidden":"true",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2.5,d:"M9 5l7 7-7 7"})})]})})]})]},t)})]}),R===2&&(()=>{var r;const t=z.wizardCategory,s=(r=H)==null?void 0:r[t];return s?e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 gap-2 sm:gap-3",children:Object.entries(s.subtypes||{}).map(([a,l])=>{var c,m;const n=(c=l.variants)==null?void 0:c[0];return e.jsxs("div",{className:"flex flex-col gap-1 sm:gap-1.5",children:[e.jsx("span",{className:"text-xs font-medium px-1 truncate text-gray-400",children:l.title}),e.jsxs("div",{role:"button",tabIndex:0,onClick:()=>Bs(w,a),onKeyDown:d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),Bs(w,a))},className:"group relative flex flex-col rounded-xl border-2 text-sm transition-all min-h-[190px] overflow-hidden cursor-pointer bg-gray-900/50 border-gray-800 hover:border-[#326CB4]/60 hover:bg-gray-900/80",children:[(n==null?void 0:n.img)&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"absolute top-2 right-2 z-10 p-1.5 rounded-full bg-black/40 text-gray-400 hover:text-white hover:bg-black/60 transition-colors opacity-100 lg:opacity-0 lg:group-hover:opacity-100",onClick:d=>{d.stopPropagation(),Z(n.img)},title:"View enlarged",children:e.jsx(bt,{className:"w-4 h-4"})}),e.jsx("div",{className:"relative block w-full flex-1 min-h-[130px] lg:min-h-[145px]",children:e.jsx("img",{src:n.img,alt:l.title,loading:"lazy",className:"absolute inset-0 w-full h-full object-contain p-3 group-hover:scale-105 transition-transform duration-300"})})]}),e.jsx("div",{className:"absolute bottom-8 inset-x-0 z-[5] pointer-events-none",children:e.jsxs("span",{className:"text-[10px] text-gray-200 block px-3 pb-0.5 bg-gradient-to-t from-black/70 to-transparent pt-4",children:[((m=l.variants)==null?void 0:m.length)||0," ","variants"]})}),e.jsx("div",{className:"px-3 pb-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[13px] font-semibold tracking-tight text-gray-200 group-hover:text-[#7fb0ff] transition-colors",children:"Select"}),e.jsx("svg",{className:"w-4 h-4 text-gray-400 group-hover:text-[#7fb0ff] transition-colors",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","aria-hidden":"true",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2.5,d:"M9 5l7 7-7 7"})})]})})]})]},a)})}):null})(),R===3&&(()=>{var l,n;const t=z.wizardCategory,s=z.wizardSubtype,r=(l=H)==null?void 0:l[t],a=(n=r==null?void 0:r.subtypes)==null?void 0:n[s];return a?e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 gap-2 sm:gap-3",children:(a.variants||[]).map((c,m)=>{const d=z.maskUrl===c.mask&&!z.useMyReference;return e.jsxs("div",{className:"flex flex-col gap-1 sm:gap-1.5",children:[e.jsx("span",{className:"text-xs font-medium px-1 truncate text-gray-400",children:c.title}),e.jsxs("div",{role:"button",tabIndex:0,onClick:()=>ut(w,m,c),onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),ut(w,m,c))},className:`group relative flex flex-col rounded-xl border-2 text-sm transition-all min-h-[190p
18x] overflow-hidden cursor-pointer ${d?"bg-[#326CB4]/10 border-[#326CB4] shadow-lg shadow-[#326CB4]/20":"bg-gray-900/50 border-gray-800 hover:border-[#326CB4]/60 hover:bg-gray-900/80"}`,children:[c.img&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"absolute top-2 right-2 z-10 p-1.5 rounded-full bg-black/40 text-gray-400 hover:text-white hover:bg-black/60 transition-colors opacity-100 lg:opacity-0 lg:group-hover:opacity-100",onClick:g=>{g.stopPropagation(),Z(c.img)},title:"View enlarged",children:e.jsx(bt,{className:"w-4 h-4"})}),e.jsx("div",{className:"relative block w-full flex-1 min-h-[130px] lg:min-h-[145px]",children:e.jsx("img",{src:c.img,alt:c.title,loading:"lazy",className:"absolute inset-0 w-full h-full object-contain p-3 group-hover:scale-105 transition-transform duration-300"})})]}),d&&e.jsx("div",{className:"absolute top-2 left-2 w-6 h-6 rounded-full bg-[#326CB4] flex items-center justify-center",children:e.jsx(me,{className:"w-3.5 h-3.5 text-white"})}),e.jsx("div",{className:"px-3 pb-2",children:e.jsx("div",{className:"flex items-center justify-start",children:e.jsx("span",{className:"text-[13px] font-semibold tracking-tight text-gray-200 group-hover:text-[#7fb0ff] transition-colors",children:"Select"})})})]})]},m)})}):null})()]}),!h&&A==="my"&&e.jsxs("div",{children:[P&&e.jsx("div",{className:"text-gray-300 text-sm mt-4 mb-14",children:"Loading…"}),!P&&!K&&S.length===0&&e.jsx("div",{className:"text-gray-400 text-sm mt-4 mb-14",children:"No references uploaded yet."}),e.jsx("div",{children:e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 gap-2 sm:gap-3",children:S.filter(t=>(t==null?void 0:t.originalUrl)&&(t==null?void 0:t.processedMaskUrl)).map(t=>{var a,l;const s=z.useMyReference&&((a=z.selectedMyReference)==null?void 0:a._id)===t._id,r=Nr===t._id;return e.jsxs("div",{className:"relative group cursor-pointer",onClick:()=>{r||mt(w,t)},children:[e.jsxs("div",{className:`w-full relative rounded-xl overflow-hidden aspect-[3/4] bg-black/40 border-2 transition-all ${r?"pointer-events-none select-none blur-[3px] opacity-40":s?"border-blue-500 ring-2 ring-blue-500/40":"border-white/10 hover:border-white/25"}`,children:[e.jsx("img",{src:t.originalUrl,alt:"reference",className:"w-full h-full object-contain p-2"}),e.jsxs("div",{className:"absolute top-1.5 right-1.5 z-10 flex items-center gap-1",children:[e.jsx("button",{type:"button",className:"p-1.5 rounded-full bg-black/40 text-gray-400 hover:text-white hover:bg-black/60 transition-colors opacity-100 lg:opacity-0 lg:group-hover:opacity-100",onClick:n=>{n.stopPropagation(),Z(t.originalUrl)},title:"View enlarged",children:e.jsx(bt,{className:"w-3.5 h-3.5"})}),s&&e.jsx("div",{className:"w-6 h-6 rounded-full bg-blue-500 flex items-center justify-center flex-shrink-0",children:e.jsx(me,{className:"w-3 h-3 text-white"})})]}),e.jsx("div",{className:"absolute bottom-0 inset-x-0 bg-gradient-to-t from-black/80 to-transparent p-2",children:e.jsx("span",{className:"text-[10px] sm:text-xs font-medium text-white truncate block",children:((l=t.name)==null?void 0:l.trim())||"Reference"})})]}),!r&&e.jsx("button",{onClick:n=>{n.stopPropagation(),Yt(t._id)},className:"absolute top-1.5 left-1.5 w-6 h-6 rounded-full bg-red-500/80 hover:bg-red-500 text-white flex items-center justify-center transition-all z-20 opacity-100 lg:opacity-0 lg:group-hover:opacity-100",title:"Delete reference",children:e.jsx(lr,{className:"w-3 h-3"})}),r&&e.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center p-2",children:e.jsxs("div",{className:"w-full rounded-xl p-3 text-center",children:[e.jsx("p",{className:"text-[13px] text-gray-100",children:"Are you sure you want to delete this?"}),e.jsxs("div",{className:"mt-2 flex flex-col gap-2",children:[e.jsx("button",{type:"button",onClick:async n=>{n.stopPropagation(),Yt(null);try{await xe(`${se}/api/custom-references/delete`,{id:t._id},{method:"POST"}),j(c=>c.filter(m=>m._id!==t._id)),s&&Os(w)}catch(c){U(c.message||"Failed to delete")}},className:"w-full h-8 rounded-full bg-red-600/80 hover:bg-red-600 text-white text-[12px] font-medium transition-colors",children:"Confirm"}),e.jsx("button",{type:"button",onClick:n=>{n.stopPropagation(),Yt(null)},className:"w-full h-8 rounded-full bg-gray-700 hover:bg-gray-600 text-white text-[12px] font-medium transition-colors",children:"Cancel"})]})]})})]},t._id)})})}),e.jsx("div",{className:"mt-5 pt-4 flex justify-end",children:Ct?e.jsxs("label",{className:"px-5 sm:px-8 py-2 rounded-full flex items-center justify-center gap-2 cursor-pointer bg-[#326CB4] hover:bg-[#3A78C6] text-sm text-white transition-colors",children:[e.jsx(gt,{className:"w-4 h-4"}),e.jsx("span",{className:"whitespace-nowrap",children:"Upload Reference"}),e.jsx("input",{type:"file",accept:"image/png,image/jpeg,image/webp,image/heic,image/heif",className:"hidden",disabled:h,onChange:t=>{var r,a;if(!o)return;const s=(a=(r=t.target)==null?void 0:r.files)==null?void 0:a[0];s&&(async()=>{try{const l=await et(s),n=await tt(l);T(n),G(!0)}catch(l){st(l)}})(),t.target.value=""}})]}):e.jsx("button",{onClick:()=>us({reason:"plan"}),className:"px-5 sm:px-8 py-2 rounded-full bg-gradient-to-r from-blue-600 to-indigo-600 text-white text-sm font-semibold transition-all",children:"Upgrade to Upload"})})]})]}):e.jsx("div",{className:"p-8 text-center",children:e.jsx("p",{className:"text-sm text-gray-500",children:"No garment uploaded for this slot."})})}),R>1&&z&&!h&&A==="default"&&!Pe&&e.jsx("div",{className:"shrink-0 px-3 sm:px-4 lg:px-5 py-3 border-x border-b border-white/10 rounded-b-xl bg-[#14161a]",children:e.jsx("button",{onClick:()=>ee(R-1),className:"px-8 py-2.5 bg-[#326CB4] hover:bg-[#3A78C6] active:bg-[#285789] rounded-full text-white text-sm font-semibold transition-colors shadow-md",children:"← Back"})})]})]})]})]}),_==="settings"&&e.jsxs("div",{className:"flex-1 min-h-0 flex flex-col space-y-1 sm:space-y-4",children:[e.jsx("h2",{className:"text-lg font-bold shrink-0",children:"Generation Settings"}),u.length>=2&&e.jsxs("div",{className:"space-y-1 shrink-0",children:[e.jsx("p",{className:"text-[11px] font-semibold text-gray-500 uppercase tracking-wider",children:"Apply to All"}),e.jsx("div",{className:"rounded-xl border border-white/10 bg-[#14161a] p-3 sm:p-4 overflow-visible",children:e.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-3 xl:grid-cols-5 ga
18p-3",children:[e.jsxs("div",{className:"flex flex-col gap-[2px] min-w-0",children:[e.jsx("label",{className:"text-[11px] font-medium text-gray-300",children:"Product View"}),e.jsxs("div",{className:"relative min-w-0",children:[e.jsxs("button",{ref:As,type:"button",onClick:()=>It(t=>!t),className:"w-full bg-[#16181A] border border-[#27272A] rounded-lg px-2.5 py-2 text-[13px] text-gray-100 focus:outline-none focus:ring-2 focus:ring-blue-500 transition-colors flex items-center justify-between",children:[e.jsx("span",{className:`truncate ${de===void 0?"text-gray-400":"text-gray-100"}`,children:de===void 0?"Mixed…":de==null?"Use Original":de==="front"?"Front":de==="back"?"Back":"Side"}),e.jsx(re,{className:`h-4 w-4 ml-2 transition-transform ${ks?"rotate-180":""}`})]}),ks&&e.jsx("div",{className:"absolute z-50 w-full top-full left-0 mt-1",children:e.jsx(fe,{options:hr,selectedValue:de===void 0?null:de===null?"as-is":de,onSelect:t=>{Tr(t),It(!1)},onClose:()=>It(!1),autoOpenOnMount:!0,hideButtonWhenOpen:!0,ignoreClickRefs:[As]})})]})]}),e.jsxs("div",{className:"flex flex-col gap-[2px] min-w-0",children:[e.jsx("label",{className:"text-[11px] font-medium text-gray-300",children:"Backgroun
18d"}),e.jsx("button",{type:"button",onClick:()=>Vt("all"),className:"flex items-center gap-2 px-2 py-1.5 rounded-md bg-[#16181A] border border-[#252629] hover:border-white/25 transition-colors cursor-pointer min-w-0",children:Xt===void 0?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-6 h-6 rounded border border-white/15 shrink-0 bg-gradient-to-br from-gray-500 to-gray-700"}),e.jsx("span",{className:"text-[13px] text-gray-400 truncate",children:"Mixed…"})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-6 h-6 rounded border border-white/15 shrink-0",style:{backgroundColor:Xt||Dt}}),e.jsx("span",{className:"text-[13px] font-mono text-white truncate",children:Xt||Dt})]})})]}),e.jsxs("div",{className:"flex flex-col gap-[2px] min-w-0",children:[e.jsx("label",{className:"text-[11px] font-medium text-gray-300",children:"Aspect Ratio"}),e.jsxs("div",{className:"relative min-w-0",children:[e.jsxs("button",{ref:Ps,type:"button",onClick:()=>Wt(t=>!t),className:"w-full bg-[#16181A] border border-[#27272A] rounded-lg px-2.5 py-2 text-[13px] text-gray-100 focus:outline-none focus:ring-2 focus:ring-blue-500 transition-colors flex items-center justify-between",children:[e.jsx("span",{className:`truncate ${Ge===void 0?"text-gray-400":"text-gray-100"}`,children:Ge===void 0?"Mixed…":cs(Ge)}),e.jsx(re,{className:`h-4 w-4 ml-2 transition-transform ${Cs?"rotate-180":""}`})]}),Cs&&e.jsx("div",{className:"absolute z-50 w-full top-full left-0 mt-1",children:e.jsx(fe,{options:cr,selectedValue:Ge===void 0?null:Ge,onSelect:t=>{dt("aspectRatio",t),Wt(!1)},onClose:()=>Wt(!1),autoOpenOnMount:!0,hideButtonWhenOpen:!0,ignoreClickRefs:[Ps]})})]})]}),e.jsxs("div",{className:"flex flex-col gap-[2px] min-w-0",children:[e.jsx("label",{className:"text-[11px] font-medium text-gray-300",children:"Resolution"}),e.jsxs("div",{className:"relative min-w-0",children:[e.jsxs("button",{ref:Ts,type:"button",onClick:()=>Kt(t=>!t),className:"w-full bg-[#16181A] border border-[#27272A] rounded-lg px-2.5 py-2 text-[13px] text-gray-100 focus:outline-none focus:ring-2 focus:ring-blue-500 transition-colors flex items-center justify-between",children:[e.jsx("span",{className:`truncate ${Ae===void 0?"text-gray-400":"text-gray-100"}`,children:Ae===void 0?"Mixed…":Ae==="1K"?"1K – Standard Quality":Ae==="2K"?`2K – High Definition${je?"":" (PRO)"}`:`4K – DSLR Print Quality${ne?"":" (ELITE)"}`}),e.jsx(re,{className:`h-4 w-4 ml-2 transition-transform ${Ss?"rotate-180":""}`})]}),Ss&&e.jsx("div",{className:"absolute z-50 w-full top-full left-0 mt-1",children:e.jsx(fe,{options:xr.map(t=>({...t,label:t.value==="2K"&&!je?`${t.label} (PRO)`:t.value==="4K"&&!ne?`${t.label} (ELITE)`:t.label})),selectedValue:Ae===void 0?null:Ae,onSelect:t=>{dt("resolution",t),Kt(!1)},onClose:()=>Kt(!1),autoOpenOnMount:!0,hideButtonWhenOpen:!0,ignoreClickRefs:[Ts]})})]})]}),e.jsxs("div",{className:"flex flex-col gap-[2px] min-w-0",children:[e.jsx("label",{className:"text-[11px] font-medium text-gray-300",children:"Cast Shadow"}),e.jsxs("div",{className:"relative min-w-0",children:[e.jsxs("button",{ref:_s,type:"button",onClick:()=>Gt(t=>!t),className:"w-full bg-[#16181A] border border-[#27272A] rounded-lg px-2.5 py-2 text-[13px] text-gray-100 focus:outline-none focus:ring-2 focus:ring-blue-500 transition-colors flex items-center justify-between",children:[e.jsx("span",{className:`truncate ${Ye===void 0?"text-gray-400":"text-gray-100"}`,children:Ye===void 0?"Mixed…":Ye?"Show":"Don't Show"}),e.jsx(re,{className:`h-4 w-4 ml-2 transition-transform ${Rs?"rotate-180":""}`})]}),Rs&&e.jsx("div",{className:"absolute z-50 w-full top-full left-0 mt-1",children:e.jsx(fe,{options:[{value:"show",label:"Show"},{value:"hide",label:"Don't Show"}],selectedValue:Ye===void 0?null:Ye?"show":"hide",onSelect:t=>{dt("showShadow",t==="show"),Gt(!1)},onClose:()=>Gt(!1),autoOpenOnMount:!0,hideButtonWhenOpen:!0,ignoreClickRefs:[_s]})})]})]})]})})]}),u.length>0?e.jsxs("div",{className:"flex flex-col md:flex-row gap-3 md:gap-4 flex-1 min-h-0",children:[e.jsx("div",{className:"md:w-[280px] lg:w-[340px] xl:w-[400px] shrink-0 flex flex-col gap-1.5 min-h-0",children:(sr=b[Q])!=null&&sr.preview?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"hidden sm:flex flex-1 min-h-0 rounded-2xl border border-white/10 bg-[#14161a] overflow-hidden",children:e.jsx("div",{className:"relative w-full h-full bg-black/30",children:e.jsx("img",{src:b[Q].preview,alt:`Product ${Q+1}`,className:"absolute inset-0 w-full h-full object-contain p-6"})})}),u.length>1&&e.jsx("div",{ref:js,className:"shrink-0 flex items-center gap-2.5 overflow-x-auto scrollbar-none px-2 py-2",children:b.map((t,s)=>{if(!t.preview)return null;const r=Q===s;return e.jsx("button",{"data-settings-thumb-idx":s,onClick:()=>ps(s),className:`relative shrink-0 rounded-xl transition-all ${r?"ring-[3px] ring-blue-500 ring-offset-2 ring-offset-[#0d0f12]":"hover:opacity-80"}`,children:e.jsx("div",{className:"w-[90px] h-[90px] sm:w-24 sm:h-24 rounded-xl overflow-hidden border border-white/15 bg-[#14161a] relative",children:e.jsx("img",{src:t.preview,alt:"",className:"w-full h-full object-contain p-0.5"})})},s)})})]}):e.jsx("div",{className:"flex-1 rounded-2xl border border-white/10 bg-[#14161a] flex items-center justify-center",children:e.jsx("p",{className:"text-sm text-gray-500",children:"No product uploaded for this slot."})})}),e.jsx("div",{className:"flex-1 min-w-0 flex flex-col min-h-0",children:(()=>{const t=Q,s=b[t];if(!(s!=null&&s.preview))return null;const r=he(s),a=yt(s.garmentView);return e.jsxs("div",{className:"rounded-xl border border-white/10 bg-[#14161a] p-3 sm:p-4 overflow-visible space-y-3 flex-1",children:[e.jsx("div",{className:"flex items-center gap-2.5",children:e.jsxs("span",{className:"text-sm font-semibold text-white",children:["Product ",t+1," Settings"]})}),e.jsxs("div",{className:"grid grid-cols-2 gap-3 overflow-visible",children:[e.jsxs("div",{className:"flex flex-col gap-[2px] min-w-0",children:[e.jsx("label",{className:"text-[11px] font-medium text-gray-300",children:"Product View"}),e.jsxs("div",{className:"relative min-w-0",children:[e.jsxs("button",{ref:l=>Lt.current[t]=l,type:"button",onClick:()=>Et(_t===t?null:t),className:"w-full bg-[#16181A] border border-[#27272A] rounded-lg px-2.5 py-2 text-[13px] text-gray-100 focus:outline-none focus:ring-2 focus:ring-blue-500 transition-colors flex items-center justify-between",children:[e.jsx("span",{className:"truncate",children:s.garmentView==null?"Use Original":s.garmentView==="front"?"Front":s.garmentView==="back"?"Back":"Side"}),e.jsx(re,{className:`h-4 w-4 ml-2 transition-transform ${_t===t?"rotate-180":""}`})]}),_t===t&&e.jsx("div",{className:"absolute z-50 w-full top-full left-0 mt-1",children:e.jsx(fe,{options:hr,selectedValue:s.garmentView==null?"as-is":s.garmentView,onSelect:l=>{Pr(t,l),Et(null)},onClose:()=>
18Et(null),autoOpenOnMount:!0,hideButtonWhenOpen:!0,ignoreClickRefs:[Lt.current[t]?{current:Lt.current[t]}:void 0].filter(Boolean)})})]})]}),e.jsxs("div",{className:"flex flex-col gap-[2px] min-w-0",children:[e.jsx("label",{className:"text-[11px] font-medium text-gray-300",children:"Background"}),e.jsxs("button",{type:"button",onClick:()=>Vt(t),className:"flex items-center gap-2 px-2 py-1.5 rounded-md bg-[#16181A] border border-[#252629] hover:border-white/25 transition-colors cursor-pointer min-w-0",children:[e.jsx("div",{className:"w-6 h-6 rounded border border-white/15 shrink-0",style:{backgroundColor:s.bgColor}}),e.jsx("span",{className:"text-[13px] font-mono text-white truncate",children:s.bgColor})]})]}),e.jsxs("div",{className:"flex flex-col gap-[2px] min-w-0",children:[e.jsx("label",{className:"text-[11px] font-medium text-gray-300",children:"Aspect Ratio"}),e.jsxs("div",{className:"relative min-w-0",children:[e.jsxs("button",{ref:l=>zt.current[t]=l,type:"button",onClick:()=>At(Rt===t?null:t),className:"w-full bg-[#16181A] border border-[#27272A] rounded-lg px-2.5 py-2 text-[13px] text-gray-100 focus:outline-none focus:ring-2 focus:ring-blue-500 transition-colors flex items-center justify-between",children:[e.jsx("span",{className:"truncate",children:cs(s.aspectRatio)}),e.jsx(re,{className:`h-4 w-4 ml-2 transition-transform ${Rt===t?"rotate-180":""}`})]}),Rt===t&&e.jsx("div",{className:"absolute z-50 w-full top-full left-0 mt-1",children:e.jsx(fe,{options:cr,selectedValue:s.aspectRatio,onSelect:l=>{ue(t,"aspectRatio",l),At(null)},onClose:()=>At(null),autoOpenOnMount:!0,hideButtonWhenOpen:!0,ignoreClickRefs:[zt.current[t]?{current:zt.current[t]}:void 0].filter(Boolean)})})]})]}),e.jsxs("div",{className:"flex flex-col gap-[2px] min-w-0",children:[e.jsx("label",{className:"text-[11px] font-medium text-gray-300",children:"Resolution"}),e.jsxs("div",{className:"relative min-w-0",children:[e.jsxs("button",{ref:l=>Ft.current[t]=l,type:"button",onClick:()=>Tt(Pt===t?null:t),className:"w-full bg-[#16181A] border border-[#27272A] rounded-lg px-2.5 py-2 text-[13px] text-gray-100 focus:outline-none focus:ring-2 focus:ring-blue-500 transition-colors flex items-center justify-between",children:[e.jsx("span",{className:"truncate",children:s.resolution==="1K"?"1K – Standard Quality":s.resolution==="2K"?`2K – High Definition${je?"":" (PRO)"}`:`4K – DSLR Print Quality${ne?"":" (ELITE)"}`}),e.jsx(re,{className:`h-4 w-4 ml-2 transition-transform ${Pt===t?"rotate-180":""}`})]}),Pt===t&&e.jsx("div",{className:"absolute z-50 w-full top-full left-0 mt-1",children:e.jsx(fe,{options:xr.map(l=>({...l,label:l.value==="2K"&&!je?`${l.label} (PRO)`:l.value==="4K"&&!ne?`${l.label} (ELITE)`:l.label})),selectedValue:s.resolution,onSelect:l=>{ue(t,"resolution",l),Tt(null)},onClose:()=>Tt(null),autoOpenOnMount:!0,hideButtonWhenOpen:!0,ignoreClickRefs:[Ft.current[t]?{current:Ft.current[t]}:void 0].filter(Boolean)})})]})]}),e.jsxs("div",{className:"flex flex-col gap-[2px] min-w-0",children:[e.jsx("label",{className:"text-[11px] font-medium text-gray-300",children:"Cast Shadow"}),e.jsxs("div",{className:"relative min-w-0",children:[e.jsxs("button",{ref:l=>Ut.current[t]=l,type:"button",onClick:()=>Mt($t===t?null:t),className:"w-full bg-[#16181A] border border-[#27272A] rounded-lg px-2.5 py-2 text-[13px] text-gray-100 focus:outline-none focus:ring-2 focus:ring-blue-500 transition-colors flex items-center justify-between",children:[e.jsx("span",{className:"truncate",children:s.showShadow!==!1?"Show":"Don't Show"}),e.jsx(re,{className:`h-4 w-4 ml-2 transition-transform ${$t===t?"rotate-180":""}`})]}),$t===t&&e.jsx("div",{className:"absolute z-50 w-full top-full left-0 mt-1",children:e.jsx(fe,{options:[{value:"show",label:"Show"},{value:"hide",label:"Don't Show"}],selectedValue:s.showShadow!==!1?"show":"hide",onSelect:l=>{ue(t,"showShadow",l==="show"),Mt(null)},onClose:()=>Mt(null),autoOpenOnMount:!0,hideButtonWhenOpen:!0,ignoreClickRefs:[Ut.current[t]?{current:Ut.current[t]}:void 0].filter(Boolean)})})]})]})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"text-[11px] font-medium text-gray-300 block mb-1.5",children:["Custom Instructions"," ",e.jsx("span",{className:"text-gray-500",children:"(optional)"})]}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:"text",value:s.customPrompt||"",onChange:l=>{const n=l.target.value;n.length<=vt&&ue(t,"customPrompt",n)},placeholder:"e.g. Shorten sleeves by 3 inches and keep the tag visible",className:"w-full bg-[#16181A] border border-[#27272A] rounded-lg px-3 py-2.5 pr-14 text-sm text-white placeholder-gray-500 focus:outline-none focus:ring-2 focus:ring-blue-500/50 focus:border-blue-500/40 transition-colors",maxLength:vt,disabled:!ne}),e.jsxs("span",{className:`absolute top-1/2 -translate-y-1/2 right-3 text-[10px] font-mono pointer-events-none ${vt-(s.customPrompt||"").length<=20?"text-amber-400":"text-gray-500"}`,children:[(s.customPrompt||"").length,"/",vt]}),!ne&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"absolute inset-x-0 top-0 flex items-start justify-start z-[2] pointer-events-auto w-full",children:e.jsx(Je,{label:e.jsx("span",{className:"text-xs sm:text-sm font-semibold leading-tight",children:"Subscribe To ELITE To Access"}),modalTab:"subscribe",size:"sm",variant:"primary",fullWidth:!0,className:"w-full py-2"})}),e.jsx("div",{className:"absolute inset-0 rounded-lg bg-[#16181a]/60 backdrop-blur-[1px] z-[1] pointer-events-none"})]})]})]}),Ee(s.garmentView)&&e.jsx("div",{className:"rounded-lg border border-white/10 bg-[#16181A] p-3",children:e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[e.jsx("div",{className:`w-14 h-16 rounded-lg overflow-hidden border shrink-0 bg-black/30 ${r?"border-emerald-500/30":"border-amber-500/30"}`,children:r?e.jsx("img",{src:r,alt:`${a} view reference`,className:"w-full h-full object-contain"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(Nt,{className:"w-5 h-5 text-amber-400"})})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-xs font-semibold text-white",children:r?`${a} view image uploaded`:`${a} view image not uploaded`}),e.jsx("p",{className:"text-[11px] text-gray-400 mt-0.5 leading-relaxed",children:r?`This ${a.toLowerCase()} image will be used as the product source.`:`AI will predict the ${a.toLowerCase()} view unless you add one.`})]})]}),e.jsxs("button",{type:"button",onClick:()=>oe({view:s.garmentView,slotIndexes:[t],warning:!1}),className:"shrink-0 inline-flex items-center justify-center gap-2 px-4 py-2 rounded-full bg-white/5 hover:bg-white/10 border border-white/10 text-xs font-semibold text-white transition-colors",children:[e.jsx(gt,{className:"w-3.5 h-3.5"}),r?"Replace Image":"Upload Image"]})]})})]})})()})]}):e.jsx("div",{className:"rounded-xl border border-white/10 bg-[#14161a] p-8 text-center",children:e.jsx("p",{className:"text-sm text-gray-500",children:"No products uploaded yet."})})]}),_==="generate"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-bold",children:"Summary"}),e.jsx("p",{className:"text-sm text-gray-400 mt-0.5",children:"Review everything below and generate."})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("span",{className:"text-[11px] font-semibold text-gray-400 uppercase tracking-wider",children:"Mode"}),e.jsx("span",{className:`inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-semibold ${C==="reference"?"bg-emerald-500/15 text-emerald-300 border border-emerald-500/30":"bg-blue-500/15 text-blue-300 border border-blue-500/30"}`,children:C==="reference"?"Reference":"AI Guess"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("span",{className:"text-[11px] font-semibold text-gray-400 uppercase tracking-wider",children:"Jobs"}),e.jsxs("span",{className:"inline-flex px-2 py-0.5 rounded-full bg-white/5 border border-white/10 text-[10px] font-medium text-gray-300",children:[u.length," flat lay",u.length!==1?"s":""]})]})]}),e.jsx("div",{className:"h-px bg-white/10"}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("span",{className:"text-[11px] font-semibold text-gray-400 uppercase tracking-wider",children:["Flat Lays (",u.length,")"]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 xl:grid-cols-3 gap-3",children:u.map((t,s)=>{var r;return e.jsxs("div",{className:"rounded-lg border border-white/10 bg-white/[0.02] p-2.5 space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"w-4 h-4 rounded-full bg-blue-500 flex items-center justify-center",children:e.jsx("span",{className:"text-[8px] font-bold text-white",children:s+1})}),e.jsxs("span",{className:"text-[10px] font-semibold text-white",children:["Garment ",s+1]})]}),e.jsxs("span",{className:"text-[9px] text-blue-300 font-semibold",children:[qt()," credit",qt()!==1?"s":""]})]}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsxs("div",{className:"flex flex-col items-center gap-0.5",children:[e.jsx("div",{className:"w-12 h-14 roun
18ded-lg overflow-hidden border border-white/10 bg-black/30",children:e.jsx("img",{src:t.preview,alt:"",className:"w-full h-full object-contain"})}),e.jsx("span",{className:"text-[8px] text-gray-500",children:"Original"})]}),he(t)&&e.jsxs("div",{className:"flex flex-col items-center gap-0.5",children:[e.jsx("div",{className:"w-12 h-14 rounded-lg overflow-hidden border border-blue-500/30 bg-black/30",children:e.jsx("img",{src:he(t),alt:"",className:"w-full h-full object-contain"})}),e.jsx("span",{className:"text-[8px] text-blue-300",children:yt(t.garmentView)})]}),C==="reference"&&t.maskPreview&&e.jsxs("div",{className:"flex flex-col items-center gap-0.5",children:[e.jsx("div",{className:"w-12 h-14 rounded-lg overflow-hidden border border-emerald-500/30 bg-black/30",children:e.jsx("img",{src:t.maskPreview,alt:"",className:"w-full h-full object-contain"})}),e.jsx("span",{className:"text-[8px] text-emerald-400",children:"Style Ref"})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[e.jsx("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full bg-blue-500/10 border border-blue-500/20 text-[9px] font-medium text-blue-300",children:t.garmentView?t.garmentView.charAt(0).toUpperCase()+t.garmentView.slice(1):"As-is"}),Ee(t.garmentView)&&e.jsx("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full border text-[9px] font-medium ${he(t)?"bg-emerald-500/10 border-emerald-500/20 text-emerald-300":"bg-amber-500/10 border-amber-500/20 text-amber-300"}`,children:he(t)?"View image uploaded":"AI predicts view"}),e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full bg-white/5 border border-white/10 text-[9px] font-medium text-gray-300",children:[e.jsx("span",{className:"w-2 h-2 rounded-full border border-white/20 shrink-0",style:{backgroundColor:t.bgColor}}),Rl(t.bgColor)]}),e.jsx("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full bg-white/5 border border-white/10 text-[9px] font-medium text-gray-300",children:cs(t.aspectRatio)}),e.jsx("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full bg-white/5 border border-white/10 text-[9px] font-medium text-gray-300",children:t.resolution||"1K"}),e.jsx("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full bg-white/5 border border-white/10 text-[9px] font-medium text-gray-300",children:t.showShadow!==!1?"Shadow: On":"Shadow: Off"})]}),((r=t.customPrompt)==null?void 0:r.trim())&&e.jsxs("p",{className:"text-[10px] text-gray-400 truncate",children:["💬 ",t.customPrompt.trim()]})]},s)})})]}),o&&!D&&ce>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-px bg-white/10"}),e.jsxs("div",{className:"rounded-xl border border-red-500/20 bg-red-500/10 p-4 space-y-3",children:[e.jsxs("p",{className:"text-xs text-red-400/80",children:["You need"," ",e.jsxs("strong",{children:[E-V," more"]})," ","credit",E-V!==1?"s":"","."]}),e.jsx("button",{onClick:()=>us({reason:"credits",needed:E,balance:V}),className:"w-full px-4 py-3 bg-[#326CB4] hover:bg-[#3A78C6] rounded-full text-sm font-semibold text-white transition-colors",children:"Upgrade Plan"})]})]}),!o&&e.jsxs("div",{className:"rounded-xl border border-white/10 bg-[#14161a] p-5 space-y-3 text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-2",children:[e.jsx(nl,{className:"w-5 h-5 text-blue-400"}),e.jsx("p",{className:"text-sm font-semibold text-white",children:"Sign up to generate"})]}),e.jsxs("p",{className:"text-xs text-gray-400",children:["Get"," ",e.jsx("strong",{className:"text-white",children:"7 free credits"})," ","when you sign up."]}),e.jsx("button",{onClick:()=>y("login",{mode:"login"}),className:"px-6 py-3 bg-[#326CB4] hover:bg-[#3A78C6] rounded-full text-sm font-semibold text-white transition-colors",children:"Get Started For Free"}),e.jsxs("div",{className:"flex items-center justify-center gap-1.5 pt-1",children:[e.jsx("svg",{className:"w-3.5 h-3.5 text-amber-400 shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.042-.133-2.052-.382-3.016z"})}),e.jsx("span",{className:"text-[12px] text-amber-400/90 font-medium",children:"Your current session will be saved"})]})]}),Le&&e.jsx("p",{className:"text-xs text-amber-300 font-medium text-center animate-pulse",children:"Please don't leave or close this page — this won't take long."})]})]})}),e.jsxs("div",{className:`hidden lg:flex items-center justify-between mt-auto pt-6 ${h?"opacity-50 pointer-events-none":""}`,children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("button",{onClick:Ys,disabled:X===0||h,className:"flex items-center gap-2 px-6 py-3 bg-white/5 hover:bg-white/10 rounded-full text-sm font-medium text-gray-300 transition-colors disabled:opacity-30 disabled:cursor-not-allowed",children:[e.jsx(ar,{className:"w-4 h-4"})," Back"]}),e.jsx(or,{workflow:"flat-lay"})]}),_==="generate"?We?e.jsx(Je,{label:Ke,hideTokenLabel:!0,size:"lg",className:"rounded-full"}):o?$?e.jsxs("button",{onClick:()=>p($.ctaHref),className:`flex items-center gap-2 px-10 py-3 rounded-full text-sm font-semibold border transition-colors ${$.kind==="past_due"?"bg-red-600/20 border-red-500/30 text-red-300 hover:bg-red-600/30":"bg-amber-600/20 border-amber-500/30 text-amber-300 hover:bg-amber-600/30"}`,children:[$.kind==="past_due"?e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",className:"w-4 h-4 flex-shrink-0",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"2",y:"5",width:"20",height:"14",rx:"2"}),e.jsx("line",{x1:"2",y1:"10",x2:"22",y2:"10"})]}):e.jsx("svg",{className:"w-4 h-4 flex-shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 15v2m0 0v2m0-2h2m-2 0H10m-4-6V8a6 6 0 1112 0v3"})}),$.label]}):e.jsx("button",{onClick:qs,disabled:Le||!D||!u.length||h,className:`flex items-center gap-2 px-10 py-3 rounded-full text-sm font-semibold text-white whitespace-nowrap transition-all disabled:opacity-50 disabled:cursor-not-allowed ${D&&u.length?"bg-[#326CB4] hover:bg-[#3A78C6] active:bg-[#285789]":"bg-gray-600"}`,children:Le?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-4 h-4 border-2 border-white/30 border-t-white rounded-full animate-spin"}),"Submitting…"]}):D?"Generate Images":"Not Enough Credits"}):e.jsx("button",{onClick:()=>y("login",{mode:"login"}),className:"flex items-center gap-2 px-10 py-3 rounded-full text-sm font-semibold text-white bg-[#326CB4] hover:bg-[#3A78C6] active:bg-[#285789]",children:"Get Started For Free"}):We&&_==="settings"?e.jsx(Je,{label:Ke,hideTokenLabel:!0,size:"lg",className:"rounded-full"}):e.jsxs("button",{onClick:ns,disabled:!is||h,className:"flex items-center gap-2 px-10 py-3 bg-[#326CB4] hover:bg-[#3A78C6] active:bg-[#285789] rounded-full text-sm font-semibold text-white transition-colors disabled:opacity-30 disabled:cursor-not-allowed",children:["Next Step ",e.jsx(Ze,{className:"w-4 h-4"})]})]})]}),e.jsx("div",{className:"lg:hidden fixed inset-0 bg-black/60 z-[59]",style:{opacity:it?1:0,pointerEvents:it?"auto":"none",transition:"opacity 500ms cubic-bezier(0.4, 0, 0.2, 1)"},onClick:()=>Es(!1)}),e.jsx("div",{className:"lg:hidden fixed bottom-0 left-0 right-0 z-[60]",style:{paddingBottom:"env(safe-area-inset-bottom, 0px)"},children:e.jsxs("div",{className:`bg-[#14161a] shadow-[0_-4px_20px_rgba(0,0,0,0.5)] overflow-hidden border-t border-white/10 ${h?"opacity-50 pointer-events-none":""}`,children:[e.jsxs("div",{className:"w-full px-4 py-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>Es(t=>
18!t),className:"flex items-center gap-2 flex-1 min-w-0",children:[u.length>0&&e.jsx("div",{className:"flex -space-x-1.5 shrink-0",children:u.slice(0,3).map((t,s)=>e.jsx("div",{className:"w-6 h-6 rounded-full overflow-hidden border-2 border-[#14161a]",children:e.jsx("img",{src:t.preview,alt:"",className:"w-full h-full object-cover"})},s))}),e.jsxs("div",{className:"text-left min-w-0 flex-1",children:[e.jsx("span",{className:"text-[11px] font-semibold text-white block leading-tight truncate",children:ce>0?`${ce} image${ce>1?"s":""} · ${E} credit${E!==1?"s":""}`:"Workflow Status"}),e.jsx("span",{className:`text-[10px] leading-tight ${D?"text-emerald-400":ce>0?"text-red-400":"text-gray-500"}`,children:ce>0?D?`Balance: ${V}`:`Need ${E-V} more credits`:`Your Balance: ${V} credits`})]}),e.jsx(al,{className:"w-4 h-4 text-gray-400 shrink-0",style:{transform:it?"rotate(180deg)":"rotate(0deg)",transition:"transform 500ms cubic-bezier(0.4, 0, 0.2, 1)"}})]}),e.jsx(or,{workflow:"flat-lay",iconOnly:!0})]}),e.jsxs("div",{className:"flex flex-row items-center gap-2",children:[e.jsxs("button",{onClick:Ys,disabled:X===0||h,className:"w-full flex-1 flex items-center justify-center gap-1.5 px-3 py-3.5 bg-white/5 hover:bg-white/10 rounded-full text-xs font-medium text-gray-300 transition-colors disabled:opacity-30 disabled:cursor-not-allowed",children:[e.jsx(ar,{className:"w-3.5 h-3.5"})," Back"]}),_==="generate"?We?e.jsx(Je,{label:Ke,hideTokenLabel:!0,size:"sm",className:"rounded-full w-full flex-[2]"}):o?$?e.jsxs("button",{onClick:()=>p($.ctaHref),className:`w-full flex-[2] flex items-center justify-center gap-1.5 px-3 py-3.5 rounded-full text-xs font-semibold border transition-colors ${$.kind==="past_due"?"bg-red-600/20 border-red-500/30 text-red-300 hover:bg-red-600/30":"bg-amber-600/20 border-amber-500/30 text-amber-300 hover:bg-amber-600/30"}`,children:[$.kind==="past_due"?e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",className:"w-3.5 h-3.5 flex-shrink-0",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"2",y:"5",width:"20",height:"14",rx:"2"}),e.jsx("line",{x1:"2",y1:"10",x2:"22",y2:"10"})]}):e.jsx("svg",{className:"w-3.5 h-3.5 flex-shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 15v2m0 0v2m0-2h2m-2 0H10m-4-6V8a6 6 0 1112 0v3"})}),$.label]}):e.jsx("button",{onClick:qs,disabled:Le||!D||!u.length||h,className:`w-full flex-[2] flex items-center justify-center gap-1.5 px-3 py-3.5 rounded-full text-xs font-semibold text-white whitespace-nowrap disabled:opacity-50 disabled:cursor-not-allowed ${D&&u.length?"bg-[#326CB4] hover:bg-[#3A78C6]":"bg-gray-600"}`,children:Le?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-3.5 h-3.5 border-2 border-white/30 border-t-white rounded-full animate-spin"}),"Submitting…"]}):D?"Generate Images":"Missing Credits"}):e.jsx("button",{onClick:()=>y("login",{mode:"login"}),className:"w-full flex-[2] flex items-center justify-center gap-1.5 px-3 py-3.5 rounded-full text-xs font-semibold text-white bg-[#326CB4] hover:bg-[#3A78C6]",children:"Get Started For Free"}):We&&_==="settings"?e.jsx(Je,{label:Ke,hideTokenLabel:!0,size:"sm",className:"rounded-full w-full flex-[2]"}):e.jsxs("button",{onClick:ns,disabled:!is||h,className:"w-full flex-[2] flex items-center justify-center gap-1.5 px-3 py-3.5 bg-[#326CB4] hover:bg-[#3A78C6] rounded-full text-xs font-semibold text-white disabled:opacity-30 disabled:cursor-not-allowed",children:["Next Step ",e.jsx(Ze,{className:"w-3.5 h-3.5"})]})]}),!o&&_==="generate"&&e.jsxs("div",{className:"flex items-center justify-center gap-1 pt-1",children:[e.jsx("svg",{className:"w-2.5 h-2.5 text-amber-400 shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.042-.133-2.052-.382-3.016z"})}),e.jsx("span",{className:"text-[12px] text-amber-400/90 font-medium",children:"Your current session will be saved"})]})]}),e.jsx("div",{className:"overflow-hidden",style:{maxHeight:it?"60vh":"0px",transition:"max-height 500ms cubic-bezier(0.4, 0, 0.2, 1)"},children:e.jsxs("div",{className:"overflow-y-auto max-h-[60vh] px-4 pb-4 space-y-3 border-t border-white/10",children:[e.jsx("div",{className:"grid grid-cols-1 gap-2 pt-3",children:e.jsxs("div",{className:"bg-white/5 rounded-lg p-2 space-y-1",children:[e.jsx("span",{className:"text-[9px] font-semibold text-gray-500 uppercase",children:"Mode"}),e.jsx("p",{className:"text-[10px] text-gray-300",children:C==="reference"?"Reference":"AI Guess"})]})}),e.jsx("div",{className:`rounded-lg px-3 py-2 border ${ce===0?"bg-white/5 border-white/10":D?"bg-blue-500/10 border-blue-500/20":"bg-red-500/10 border-red-500/20"}`,children:ce>0?e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between text-[10px]",children:[e.jsx("span",{className:"text-gray-500",children:"Total"}),e.jsxs("span",{className:"text-white font-semibold",children:[E," credit",E!==1?"s":""]})]}),e.jsxs("div",{className:"flex items-center justify-between text-[10px]",children:[e.jsx("span",{className:"text-gray-500",children:"Balance"}),e.jsxs("span",{className:`font-semibold ${D?"text-emerald-400":"text-red-400"}`,children:[V," credit",V!==1?"s":""]})]})]}):e.jsx("p",{className:"text-[10px] text-gray-500 text-center",children:"No garments uploaded"})})]})})]})})]})]}),h&&!ge&&e.jsx("div",{className:"fixed inset-0 z-[50] cursor-wait"}),ge&&x&&e.jsx(fl,{isOpen:ge,file:x,name:N,disabled:h,cost:$e,paused:!!$,accessBlock:$,onNameChange:t=>k(t),onCancel:()=>{G(!1),T(null),k("")},onSubmit:async()=>{const t=x,s=N.trim();G(!1);try{const{candidates:r,originalUrl:a}=await Mr(t);if(!r||r.length===0)return;let l=a||le||null;if(!l)try{const n=await Ds(t);l=(n==null?void 0:n.secure_url)||(n==null?void 0:n.url)||null}catch{}if(!l)throw new Error("Failed to upload reference");pe(l),Ve(s),Oe(r),Sr({candidates:r,originalUrl:l,name:s,slotIndex:w})}catch{v.error("Something went wrong. Please try again.")}finally{T(null),k("")}}}),Se&&jt.createPortal((()=>{const t=Se.view,s=yt(t),r=(Se.slotIndexes||[]).map(n=>({slotIdx:n,slot:b[n]})).filter(({slot:n})=>n==null?void 0:n.preview),a=r.filter(({slot:n})=>!he(n,t)),l=r.length>1;return r.length?e.jsxs("div",{className:"fixed inset-0 z-[9999] flex items-center justify-center p-4",style:{animation:"fadeIn 140ms ease-out"},children:[e.jsx("div",{className:"absolute inset-0 bg-black/70 backdrop-blur-sm cursor-pointer",role:"presentation","aria-hidden":"true",onClick:nt}),e.jsx("div",{className:"relative w-full max-w-2xl bg-[#16181A] border border-[#27272A] rounded-xl p-4 sm:p-6 shadow-2xl",style:{animation:"scaleIn 180ms cubic-bezier(.25,.8,.25,1)"},role:"dialog","aria-modal":"true","aria-labelledby":"view-upload-title",children:Se.warning?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-amber-500/15 flex items-center justify-center shrink-0",children:e.jsx(Nt,{className:"w-5 h-5 text-amber-300"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("h3",{id:"view-upload-title",className:"text-base sm:text-lg font-semibold text-white",children:["AI will predict the ",s.toLowerCase()," view"]}),e.jsxs("p",{className:"text-xs sm:text-sm text-gray-400 mt-1 leading-relaxed",children:["Without a ",s.toLowerCase()," image, AI will infer the hidden side from the original product photo. You can continue, but details that are not visible may be less accurate."]})]})]}),e.jsxs("div",{className:"mt-5 flex flex-col-reverse sm:flex-row sm:items-center sm:justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:()=>oe(n=>n&&{...n,warning:!1}),className:"px-5 py-2 rounded-full bg-white/5 hover:bg-white/10 border border-white/10 text-xs sm:text-sm font-semibold text-white transition-colors",children:"Choose Image Instead"}),e.jsx("button",{type:"button",onClick:nt,className:"px-5 py-2 rounded-full bg-[#326CB4] hover:bg-[#3A78C6] text-xs sm:text-sm font-semibold text-white transition-colors",children:"Continue Anyway"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("h3",{id:"view-upload-title",className:"text-base sm:text-lg font-semibold text-white mb-1",children:l?`Add ${s.toLowerCase()} view images?`:`Add a ${s.toLowerCase()} view image?`}),e.jsx("p",{className:"text-xs sm:text-sm text-gray-400 mb-4 leading-relaxed",children:l?`Upload a ${s.toLowerCase()} view for any product that has one. Products without an upload can still continue with AI prediction.`:`If you have a ${s.toLowerCase()} view photo of this product, upload it now for better accuracy.`}),e.jsx("div",{className:"space-y-2 max-h-[52vh] overflow-y-auto pr-1",children:r.map(({slotIdx:n,slot:c})=>{const m=he(c,t);return e.jsxs("div",{className:"flex items-center gap-3 rounded-lg border border-white/10 bg-white/[0.03] p-2.5",children:[e.jsx("div",{className:"w-14 h-16 rounded-lg overflow-hidden border border-white/10 bg-black/30 shrink-0",children:e.jsx("img",{src:c.preview,alt:"",className:"w-full h-full object-contain"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("p",{className:"text-xs font-semibold text-white",children:["Product ",n+1]}),e.jsx("p",{className:`text-[11px] mt-0.5 ${m?"text-emerald-300":"text-gray-400"}`,children:m?`${s} view image ready`:`No ${s.toLowerCase()} view image yet`})]}),m&&e.jsx("button",{type:"button",onClick:()=>
18Z(m),className:"hidden sm:block w-12 h-14 rounded-lg overflow-hidden border border-emerald-500/30 bg-black/30 shrink-0",title:"View enlarged",children:e.jsx("img",{src:m,alt:"",className:"w-full h-full object-contain"})}),e.jsxs("label",{className:"shrink-0 inline-flex items-center justify-center gap-2 px-3 py-2 rounded-full border text-xs font-semibold transition-colors bg-white/5 hover:bg-white/10 border-white/10 text-white cursor-pointer",children:[e.jsx(gt,{className:"w-3.5 h-3.5"}),m?"Replace":"Upload",e.jsx("input",{type:"file",accept:"image/jpeg,image/png,image/webp,image/heic,image/heif",className:"hidden",onChange:d=>{var I;const g=(I=d.target.files)==null?void 0:I[0];g&&$r(n,g,t),d.target.value=""}})]})]},n)})}),e.jsxs("div",{className:"mt-5 flex flex-col-reverse sm:flex-row sm:items-center sm:justify-between gap-2",children:[e.jsx("p",{className:"text-[11px] text-gray-500",children:a.length===0?`All selected products have a ${s.toLowerCase()} image.`:`${a.length} product${a.length===1?"":"s"} will need AI prediction if you continue without uploading.`}),e.jsx("div",{className:"flex flex-col sm:flex-row gap-2 sm:justify-end",children:e.jsx("button",{type:"button",onClick:()=>{a.length===0?oe(null):oe(n=>n&&{...n,warning:!0})},className:"px-5 py-2 rounded-full bg-white/5 hover:bg-white/10 border border-white/10 text-xs sm:text-sm font-semibold text-white transition-colors",children:a.length===0?"Done":"Continue Without Upload"})})]})]})})]}):null})(),document.body),Be.length>0&&jt.createPortal(e.jsxs("div",{className:"fixed inset-0 z-[9999] flex items-center justify-center p-4",style:{animation:"fadeIn 140ms ease-out"},children:[e.jsx("div",{className:"absolute inset-0 bg-black/70 backdrop-blur-sm",role:"presentation","aria-hidden":"true"}),e.jsxs("div",{className:"relative w-full max-w-2xl bg-[#16181A] border border-[#27272A] rounded-xl p-4 sm:p-6 shadow-2xl",style:{animation:"scaleIn 180ms cubic-bezier(.25,.8,.25,1)"},role:"dialog","aria-modal":"true","aria-labelledby":"mask-chooser-title",children:[e.jsx("h3",{id:"mask-chooser-title",className:"text-base sm:text-lg font-semibold text-white mb-1",children:"Pick your reference"}),e.jsxs("p",{className:"text-xs sm:text-sm text-gray-400 mb-4",children:["We generated two geometry-only references from your upload. Tap one to select it, then press ",e.jsx("strong",{children:"Confirm"})," to save it to your styles."]}),e.jsx("div",{className:"grid grid-cols-2 gap-3 sm:gap-4 mb-5",children:Be.map((t,s)=>{const r=J===s;return e.jsxs("button",{type:"button",disabled:Re,onClick:()=>{Re||ct(s)},className:`group relative aspect-square rounded-lg overflow-hidden bg-white border-2 transition-all focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 disabled:opacity-50 disabled:cursor-wait cursor-pointer ${r?"border-blue-500 ring-2 ring-blue-500/40":"border-[#27272A] hover:border-white/30"}`,"aria-pressed":r,"aria-label":`Option ${s+1}${r?" (selected)":""}`,children:[e.jsx("img",{src:t.maskUrl,alt:`Geometry reference option ${s+1}`,className:"w-full h-full object-contain"}),e.jsxs("div",{className:"absolute top-2 left-2 px-2 py-0.5 rounded-full bg-black/70 text-white text-[10px] font-semibold tracking-wide",children:["Option ",s+1]}),r&&e.jsx("div",{className:"absolute top-2 right-2 w-6 h-6 rounded-full bg-blue-500 flex items-center justify-center shadow-lg",children:e.jsx(me,{className:"w-3.5 h-3.5 text-white"})}),e.jsx("div",{className:`absolute inset-0 transition-colors pointer-events-none ${r?"bg-blue-500/10":"bg-blue-500/0 group-hover:bg-blue-500/5"}`})]},t.maskUrl||s)})}),e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("p",{className:"text-[11px] text-gray-500",children:J===null?"Tap an option to continue.":`Option ${J+1} selected.`}),e.jsx("button",{type:"button",disabled:J===null||Re,onClick:async()=>{if(J===null||Re||!Be[J])return;const t=Be[J];$s(!0);try{const s=le;if(!s){v.error("Original reference is missing.");try{const l=await ds(Te.CUSTOM_REFERENCE_UPLOAD,$e,{reason:"missing_original_url"});typeof(l==null?void 0:l.creditBalance)=="number"&&f(l.creditBalance)}catch{}De(),Oe([]),Ve(""),ct(null);return}const r=await xe(`${se}/api/custom-references`,{name:kr,originalUrl:s,processedMaskUrl:t.maskUrl},{method:"POST"}),a=(r==null?void 0:r.reference)||null;if(!a)throw new Error("No reference returned from server");j(l=>[a,...l]),mt(w,a),ie("my"),Qt(),De(),Oe([]),Ve(""),ct(null)}catch(s){console.warn("Save custom reference failed",s),v.error("Could not save your reference. Refunding the credit — please try again.");try{const r=await ds(Te.CUSTOM_REFERENCE_UPLOAD,$e,{reason:"save_failed"});typeof(r==null?void 0:r.creditBalance)=="number"&&f(r.creditBalance)}catch{}De(),Oe([]),Ve(""),ct(null)}finally{$s(!1)}},className:`px-5 py-2 text-xs sm:text-sm font-semibold rounded-full transition-all disabled:opacity-40 disabled:cursor-not-allowed ${J!==null&&!Re?"bg-blue-600 hover:bg-blue-500 text-white shadow-md cursor-pointer":"bg-[#252525] text-gray-400 border border-white/10"}`,children:Re?"Saving…":J===null?"Select an option":"Confirm Selection"})]})]})]}),document.body),Ce&&jt.createPortal(e.jsxs("div",{className:"fixed inset-0 z-[9999] flex items-center justify-center bg-black/60 backdrop-blur-sm p-4",onClick:()=>Z(null),style:{animation:"fadeIn 140ms ease-out"},children:[e.jsxs("div",{className:"relative flex items-center justify-center max-w-[90vw] max-h-[90vh] bg-[#16181A] rounded-xl shadow-2xl border border-[#27272A] p-4",onClick:t=>t.stopPropagation(),style:{animation:"scaleIn 180ms cubic-bezier(.25,.8,.25,1)"},children:[e.jsxs("button",{onClick:()=>Z(null),className:"absolute top-2 left-2 inline-flex items-center gap-2 px-3 h-9 rounded-md bg-[#252525] hover:bg-[#2f2f2f] text-gray-100 border border-white/10 focus:outline-none focus:ring-2 focus:ring-blue-500 cursor-pointer z-10","aria-label":"Close zoom preview",title:"Close",children:[e.jsx(ve,{className:"w-4 h-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Close"})]}),e.jsx("img",{src:Ce,alt:"Enlarged preview",className:"max-w-full max-h-[85vh] object-contain rounded-lg"})]}),e.jsx("style",{children:`
19              @keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
20              @keyframes scaleIn { from { transform: scale(.92); opacity:0 } to { transform: scale(1); opacity:1 } }
21            `})]}),document.body),e.jsx(xl,{isOpen:we!==null,color:we==="all"?Dt:we!==null&&((rr=b[we])==null?void 0:rr.bgColor)||"#f5f5f0",onChange:t=>{we==="all"?(jr(t),dt("bgColor",t)):we!==null&&ue(we,"bgColor",t)},onClose:()=>Vt(null)}),!es&&!Xe&&e.jsx(bl,{readSession:zr,clearSession:nr,onResume:ts,onStartFresh:ss,onDismiss:ss,onNoSession:ss,toolLabel:"Flat Lay",stepLabels:q.map(t=>t.label),buildSummary:t=>{var a;const s=((a=t.slots)==null?void 0:a.length)||0,r=[];return s&&r.push(`${s} product${s>1?"s":""}`),t.generationPath==="reference"&&r.push("Reference style"),t.generationPath==="guess"&&r.push("AI style"),{detail:r.length?r.join(" · "):"Session in progress"}}}),o&&e.jsx(kl,{})]})}
21export{da as default};

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.