PageSourceSearch

https://vovv.ai/assets/Generate-0_aRUROj.js

js vovv.ai collected 2026-10-05 13:16:19 UTC 235,296 bytes, 6 lines download raw bytes

1import{j as e,u as zt,b as Ln}from"./vendor-query-CtIF-MNZ.js";import{r as i,L as Bn,e as Rn,i as Un,j as Fn}from"./vendor-react-BfTl68nP.js";import{u as xl,t as A,p as fl,s as Me,q as En,g as K,j as ka,k as Ia,l as _a,m as Ta,r as za,B as w,v as va,c as G,d as qn,w as bl,o as On,b as Dn,x as Gn,y as Vn,z as Kn,A as Pt,C as Cr,F as Hn,G as Jn,I as tl}from"./index-BfEqxQPi.js";import{g as Qn,d as Yn}from"./dropDownload-YeYVr9jl.js";import{S as Zn}from"./SEOHead-CywBROiR.js";import{getAuthToken as rl,paceDelay as Zt,enqueueWithRetry as Xt,isEnqueueError as Wt,sendWake as er}from"./enqueueGeneration-D4M7QE8C.js";import{A as Xn}from"./AddProductModal-BLe2ejRd.js";import{C as jl,a as yl,b as vl}from"./collapsible-ClmED2q9.js";import{I as st}from"./input-DGx5Zmm3.js";import{C as Wn}from"./ContextualFeedbackCard-D_p8RiT0.js";import{S as Gs}from"./shimmer-image-DO136dW3.js";import{C as re,a as le}from"./card-GdQB7DL8.js";import{B as de}from"./badge-_Q0w0Wgx.js";import{L as oe}from"./label-C1sTlncr.js";import{S as tt}from"./separator-Cjclmnz3.js";import{A as hs,a as ps}from"./alert-w3-DR9DQ.js";import{P as kr}from"./progress-Cz9tGMLO.js";import{S as Ze,a as Xe,b as We,c as es,d as D}from"./select-BZVUL-8l.js";import{P as eo}from"./PageHeader-DcBp0qDG.js";import{a1 as so,a2 as wl,D as sr,a3 as et,a4 as al,a5 as Pa,a6 as to,a7 as Aa,a8 as bt,a as Is,X as Fs,a9 as ro,I as tr,aa as ao,ab as Nl,ac as il,y as io,v as Pr,V as Ma,b as Ws,d as Vs,ad as lo,ae as no,af as Tr,ag as ll,P as zr,ah as wa,s as nl,L as oo,R as co,ai as mo,K as uo,aj as ho,J as po,_ as ol,ak as go}from"./vendor-icons-hHTr3Gms.js";import{T as dl,g as xo}from"./TemplatePreviewCard-DgqHIOtB.js";import{I as fo}from"./ImageLightbox-DRpYB_EW.js";import{N as bo}from"./NoCreditsModal-CDq_2Gmb.js";import{r as jo,P as yo,U as vo}from"./UpgradeValueDrawer-BPk6LtDL.js";import{u as wo}from"./useConversionState-BnC_zIZm.js";import{u as No}from"./useGenerationQueue-BjH2TDQE.js";import{T as So,a as Co,b as ko,c as Io}from"./tooltip-CMWaDq-g.js";import{M as _o,Q as cl}from"./MultiProductProgressBanner-DeLqZp_8.js";import{M as To}from"./ModelSelectorCard-DLeTDr8i.js";import{M as Na}from"./MissingRequestBanner-CdrF0bua.js";import{C as zo}from"./checkbox-VpTDRbdW.js";import{T as $a}from"./textarea-Dsr0mbqv.js";import{g as Po,A as Ao,a as Mo,B as $o}from"./analyzeUploadedProduct-XAy8ZRtH.js";import{u as Lo}from"./useFileUpload-BtKRogSM.js";import{i as Zs}from"./optimisticJobInjection-Cc0X2ljb.js";import{c as Cs}from"./imageUtils-C6M6zh-1.js";import{u as Bo}from"./useCustomModels-bYsc11aZ.js";import{u as Ro}from"./useUserModels-BNxgUUry.js";import{u as Uo}from"./useModelSortOrder-CqVdRgxN.js";import{u as Fo}from"./useHiddenScenes-Bslj3nrI.js";import{u as Eo}from"./useCustomScenes-B3eWoIPS.js";import{u as qo}from"./useSceneSortOrder-9XiY04dN.js";import"./vendor-radix-q0rzatl0.js";import"./jszip.min-BvJYAAfF.js";import"./constants-Beo90Mnx.js";import"./tabs-Dp4c8Ez6.js";import"./ShopifyImportTab-B7jRnWVo.js";import"./hover-card-ZNsdnnyT.js";import"./dialogAutoFocus-B5GwR1SF.js";import"./productCategories-CM_X0SvN.js";import"./popover-gUGV4mQj.js";import"./avatar-Di8Tr9Ps.js";import"./useVisibilityTick-CPST0Spx.js";import"./HeartToggle-BeKAiNJ7.js";import"./useFavorites-DR-YNdld.js";import"./UnifiedFeedbackBanner-DO6ihKMw.js";const ml=1,ul={jobs:[],totalJobs:0,completedJobs:0,failedJobs:0,totalImages:0,readyImages:0,allDone:!1,aggregatedImages:[],aggregatedLabels:[],hasPartialFailure:!1};function Oo(n){const{onCreditRefresh:l}=n||{},{user:h}=xl(),[o,m]=i.useState(null),[S,N]=i.useState(!1),b=i.useRef(null),v=i.useRef([]),p=i.useRef(null),T=i.useRef(l);i.useEffect(()=>{T.current=l},[l]),i.useEffect(()=>()=>{b.current&&clearInterval(b.current)},[]);const k=i.useCallback(()=>{b.current&&(clearInterval(b.current),b.current=null)},[]),V=i.useCallback(()=>{k();const P=v.current;if(P.length===0)return;const ce=async()=>{var Y,$e;const ee="https://azwiljtrbtaupofwmpzb.supabase.co",he="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImF6d2lsanRyYnRhdXBvZndtcHpiIiwicm9sZSI6ImFub24iLCJpYXQiOjE3Njk3OTkzNzEsImV4cCI6MjA4NTM3NTM3MX0.w8Flgj4nld44gT4w-S_TSqzZ-FRPt4xTFiHm1U_c5VY";let Ce=await rl()||he;const _e=P.map(M=>`"${M}"`).join(",");let H=await fetch(`${ee}/rest/v1/generation_queue?id=in.(${_e})&select=id,status,result,error_message`,{headers:{apikey:he,Authorization:`Bearer ${Ce}`}});if(H.status===401){const{data:M}=await Me.auth.getSession(),Re=(Y=M==null?void 0:M.session)==null?void 0:Y.access_token;Re&&(Ce=Re,H=await fetch(`${ee}/rest/v1/generation_queue?id=in.(${_e})&select=id,status,result,error_message`,{headers:{apikey:he,Authorization:`Bearer ${Re}`}}))}if(!H.ok)return;const pe=await H.json();if(!pe||pe.length===0)return;const J=new Map;for(const M of pe)J.set(M.id,{jobId:M.id,status:M.status,result:M.result,error_message:M.error_message});const Be=P.map(M=>J.get(M)||{jobId:M,status:"queued",result:null,error_message:null}),z=Be.filter(M=>M.status==="completed").length,ie=Be.filter(M=>M.status==="failed").length,ke=Be.every(M=>M.status==="completed"||M.status==="failed"||M.status==="cancelled"),$=[],ve=[];for(const M of Be)if(M.status==="completed"&&M.result){const Re=M.result;Re.images&&$.push(...Re.images),Re.variations&&ve.push(...Re.variations.map(Ue=>Ue.label))}if(m({jobs:Be,totalJobs:Be.length,completedJobs:z,failedJobs:ie,totalImages:Be.length*ml,readyImages:$.length,allDone:ke,aggregatedImages:$,aggregatedLabels:ve,hasPartialFailure:ie>0&&z>0}),ke){k(),($e=T.current)==null||$e.call(T);const M=p.current,Re=Be.find(Ue=>Ue.status==="completed");h&&M&&Re&&$.length>0&&En({userId:h.id,productId:M.productId??null,generationId:Re.jobId,visualType:M.visualType,resultCount:$.length})}};ce(),b.current=setInterval(ce,3e3)},[k,h]),I=i.useCallback(async P=>{var ve;if(!h)return A.error("Sign in to start generating"),{success:!1,newBalance:null};const{payload:ce,selectedVariationIndices:ee,angleMultiplier:he,quality:Ce,imageCount:_e}=P,H=Math.max(1,Math.floor(ml/he)),pe=[];for(let Y=0;Y<ee.length;
1Y+=H)pe.push(ee.slice(Y,Y+H));N(!0),m({...ul,totalJobs:pe.length,totalImages:_e}),A.info(`Splitting into ${pe.length} generation batch${pe.length>1?"es":""}...`);const J=crypto.randomUUID(),Be=await rl();if(!Be)return A.error("Please sign in first"),N(!1),m(null),{success:!1,newBalance:null};const z=[];let ie=null;const ke=30,$=2e3;for(let Y=0;Y<pe.length;Y++){const $e=pe[Y],M=$e.length*he,Re={...ce,selected_variations:$e,batch_id:J};await Zt(Y),Y>0&&Y%ke===0&&await new Promise(ms=>setTimeout(ms,$));const Ue=await Xt({jobType:"workflow",payload:Re,imageCount:M,quality:Ce,hasModel:P.hasModel??!1,hasScene:P.hasScene??!1,skipWake:!0},Be);if(Wt(Ue)){Ue.type==="insufficient_credits"?A.error(`Insufficient credits. ${Y} of ${pe.length} batches queued.`):Ue.type==="rate_limit"?A.error(`Rate limit reached. ${Y} of ${pe.length} batches queued.`):A.error(Ue.message||`Failed to enqueue batch ${Y+1}`);break}if(z.push(Ue.jobId),ie=Ue.newBalance,(ve=P.onJobEnqueued)==null||ve.call(P,Ue.jobId),z.length===1){const ms=ce.product_id,ne=ce.workflow_name||ce.workflow_slug||"product_images";p.current={productId:ms??null,visualType:ne},fl({userId:h.id,productId:ms??null,generationId:Ue.jobId,visualType:ne})}}return z.length>0&&er(Be),z.length===0?(N(!1),m(null),{success:!1,newBalance:null}):(v.current=z,m(Y=>({...Y||ul,jobs:z.map($e=>({jobId:$e,status:"queued",result:null,error_message:null})),totalJobs:z.length,totalImages:_e})),V(),N(!1),{success:!0,newBalance:ie})},[h,V]),B=i.useCallback(()=>{k(),m(null),v.current=[]},[k]);return{startBatch:I,batchState:o,isBatching:S,resetBatch:B}}function Do({url:n,index:l,selected:h,onToggle:o,onView:m,onDownload:S}){const[N,b]=i.useState(()=>K(n,{quality:45})),[v,p]=i.useState(!1),[T,k]=i.useState(!1);return e.jsxs("div",{className:`generation-preview relative group cursor-pointer rounded-lg overflow-hidden bg-muted/10 ${h?"ring-2 ring-primary ring-offset-2":""}`,children:[e.jsx("div",{className:"aspect-[4/5] w-full",children:v?e.jsxs("button",{type:"button",onClick:m,className:"w-full h-full flex flex-col items-center justify-center gap-2 text-xs text-muted-foreground bg-muted/30 hover:bg-muted/40 transition-colors",children:[e.jsx(so,{className:"w-5 h-5"}),e.jsx("span",{children:"Preview unavailable"}),e.jsx("span",{className:"underline",children:"View full size"})]}):e.jsx(Gs,{src:N,alt:`Upscaled ${l+1}`,loading:"lazy",decoding:"async",fetchPriority:"low",className:"w-full h-full object-cover",wrapperClassName:"w-full h-full",onClick:o,onError:()=>{T?p(!0):(k(!0),b(K(n,{quality:60})))}})}),e.jsxs("div",{className:"absolute inset-0 bg-black/50 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center gap-2",onClick:o,children:[e.jsx("button",{onClick:V=>{V.stopPropagation(),m()},className:"w-8 h-8 rounded-full bg-white/90 flex items-center justify-center hover:bg-white",title:"View full size",children:e.jsx(wl,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:V=>{V.stopPropagation(),S()},className:"w-8 h-8 rounded-full bg-white/90 flex items-center justify-center hover:bg-white",title:"Download",children:e.jsx(sr,{className:"w-3.5 h-3.5"})})]}),e.jsx("div",{className:`absolute top-1.5 right-1.5 w-6 h-6 rounded-full border-2 flex items-center justify-center transition-all ${h?"bg-primary border-primary scale-110":"border-white bg-black/50"}`,onClick:o,children:h&&e.jsx(et,{className:"w-3.5 h-3.5 text-primary-foreground"})})]})}function Go({open:n,onClose:l,onPublish:h,selectedImages:o,product:m,existingImages:S}){var P;const[N,b]=i.useState("add"),[v,p]=i.useState("all"),[T,k]=i.useState("");i.useEffect(()=>{(!n||N!=="replace")&&k("")},[n,N]);const V=N==="add"||N==="replace"&&(S.length===0||T==="REPLACE"),I=()=>{V&&h(N,v==="all"?void 0:v)},B=N==="add"?S.length+o.length:o.length;return e.jsx(ka,{open:n,onOpenChange:l,children:e.jsxs(Ia,{className:"max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsx(_a,{children:e.jsxs(Ta,{children:["Download ",o.length," Image",o.length>1?"s":""]})}),e.jsxs("div",{className:"space-y-5",children:[m&&e.jsxs("div",{className:"p-4 rounded-lg border-2 border-primary bg-primary/5 flex items-center gap-4",children:[e.jsx("div",{className:"w-14 h-14 roun
1ded-lg overflow-hidden flex-shrink-0 border border-border",children:e.jsx("img",{src:K((P=m.images[0])==null?void 0:P.url,{quality:60})||"/placeholder.svg",alt:m.title,className:"w-full h-full object-cover"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Downloading for"}),e.jsx("p",{className:"font-bold",children:m.title}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["by ",m.vendor]})]})]}),e.jsx(tt,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"font-semibold",children:"Selected Images"}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[o.slice(0,6).map((ce,ee)=>e.jsx("div",{className:"w-14 h-14 rounded-lg overflow-hidden border border-border",children:e.jsx("img",{src:K(ce,{quality:60}),alt:`Selected ${ee+1}`,loading:"lazy",className:"w-full h-full object-cover"})},ee)),o.length>6&&e.jsx("div",{className:"w-14 h-14 rounded-lg bg-muted flex items-center justify-center",children:e.jsxs("span",{className:"text-sm font-semibold",children:["+",o.length-6]})})]})]}),e.jsx(tt,{}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"font-semibold",children:"Download mode"}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:`p-4 rounded-lg border-2 cursor-pointer transition-colors ${N==="add"?"border-primary bg-primary/5":"border-border hover:border-muted-foreground"}`,onClick:()=>b("add"),children:[e.jsx("p",{className:"font-semibold",children:"Download individually"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Download each image as a separate file."})]}),e.jsxs("div",{className:`p-4 rounded-lg border-2 cursor-pointer transition-colors ${N==="replace"?"border-destructive bg-destructive/5":"border-border hover:border-muted-foreground"}`,onClick:()=>b("replace"),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"font-semibold",children:"Replace all existing images"}),S.length>0&&e.jsx(al,{className:"w-4 h-4 text-yellow-600"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Remove current images and use only the new ones."})]})]}),N==="replace"&&S.length>0&&e.jsxs("div",{className:"p-4 rounded-lg border-2 border-destructive bg-destructive/5 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(al,{className:"w-4 h-4 text-destructive"}),e.jsx("p",{className:"font-semibold text-destructive",children:"⚠️ Danger Zone"})]}),e.jsxs("p",{className:"text-sm",children:["This will ",e.jsxs("strong",{children:["permanently delete all ",S.length," current product images"]}),"."]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(oe,{htmlFor:"replace-confirm",children:'Type "REPLACE" to confirm'}),e.jsx(st,{id:"replace-confirm",value:T,onChange:ce=>k(ce.target.value),placeholder:"REPLACE"})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(oe,{children:"Assign to variant (optional)"}),e.jsxs(Ze,{value:v,onValueChange:p,children:[e.jsx(Xe,{children:e.jsx(We,{})}),e.jsxs(es,{children:[e.jsx(D,{value:"all",children:"All variants"}),e.jsx(D,{value:"variant_1",children:"Size: Small"}),e.jsx(D,{value:"variant_2",children:"Size: Medium"}),e.jsx(D,{value:"variant_3",children:"Size: Large"})]})]})]}),e.jsx(tt,{}),e.jsx(hs,{variant:N==="replace"?"destructive":"default",children:e.jsx(ps,{children:e.jsxs("div",{className:"flex gap-6",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold",children:"Current"}),e.jsx("p",{className:"text-lg font-bold",children:S.length})]}),e.jsx("span",{className:"text-2xl self-center",children:"→"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold",children:"After"}),e.jsx("p",{className:"text-lg font-bold",children:B})]})]})})})]}),e.jsxs(za,{children:[e.jsx(w,{variant:"outline",onClick:l,children:"Cancel"}),e.jsxs(w,{onClick:I,disabled:!V,children:['Download to "',m==null?void 0:m.title,'"']})]})]})})}function Vo({open:n,onClose:l,onConfirm:h,product:o,model:m,models:S,pose:N,imageCount:b,aspectRatio:v,creditsRemaining:p,isLoading:T=!1,sourceImageUrl:k,onBuyCredits:V}){var Ce;const I=S&&S.length>0?S:m?[m]:[];if(!o||I.length===0||!N)return null;const B=k||((Ce=o.images[0])==null?void 0:Ce.url)||"/placeholder.svg",P=6,ce=b*P,ee=p>=ce,he={"1:1":"Square (1:1)","4:5":"Portrait (4:5)","9:16":"Story (9:16)","16:9":"Wide (16:9)"};return e.jsx(ka,{open:n,onOpenChange:l,children:e.jsxs(Ia,{className:"max-w-lg",children:[e.jsx(_a,{children:e.jsx(Ta,{children:"Confirm Virtual Try-On Generation"})}),e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{className:"p-3 rounded-lg border-2 border-primary bg-primary/5 space-y-2",children:[e.jsx("p",{className:"text-xs font-semibold",children:"Source"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg overflow-hidden flex-shrink-0",children:e.jsx("img",{src:K(B,{qual
1ity:60}),alt:o.title,loading:"lazy",className:"w-full h-full object-cover"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-xs font-bold truncate",children:o.title}),e.jsx("p",{className:"text-[10px] text-muted-foreground truncate",children:o.vendor})]})]})]}),e.jsxs("div",{className:"p-3 rounded-lg border border-border bg-muted/50 space-y-2",children:[e.jsxs("p",{className:"text-xs font-semibold",children:["Model",I.length>1?`s (${I.length})`:""]}),I.length===1?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-10 h-10 rounded-full overflow-hidden flex-shrink-0",children:e.jsx("img",{src:K(I[0].previewUrl,{quality:60}),alt:I[0].name,className:"w-full h-full object-cover"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-xs font-bold truncate",children:I[0].name}),e.jsx("p",{className:"text-[10px] text-muted-foreground truncate",children:I[0].ethnicity})]})]}):e.jsxs("div",{className:"flex items-center gap-1",children:[I.slice(0,3).map(_e=>e.jsx("div",{className:"w-8 h-8 rounded-full overflow-hidden border border-border flex-shrink-0",children:e.jsx("img",{src:K(_e.previewUrl,{quality:60}),alt:_e.name,className:"w-full h-full object-cover"})},_e.modelId)),I.length>3&&e.jsxs("span",{className:"text-[10px] font-medium text-muted-foreground",children:["+",I.length-3]})]})]}),e.jsxs("div",{className:"p-3 rounded-lg border border-border bg-muted/50 space-y-2",children:[e.jsx("p",{className:"text-xs font-semibold",children:"Pose"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg overflow-hidden flex-shrink-0",children:e.jsx("img",{src:K(N.previewUrl,{quality:60}),alt:N.name,className:"w-full h-full object-cover"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-xs font-bold truncate",children:N.name}),e.jsx("p",{className:"text-[10px] text-muted-foreground truncate",children:va[N.category]})]})]})]})]}),e.jsx(tt,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"font-semibold",children:"What You'll Get"}),e.jsxs("div",{className:"p-3 rounded-lg bg-muted border border-border space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Pa,{className:"w-4 h-4 text-muted-foreground"}),e.jsxs("p",{className:"text-sm",children:["AI-generated photos of ",I.length>1?e.jsxs("strong",{children:[I.length," models"]}):e.jsx("strong",{children:I[0].name})," wearing your ",e.jsx("strong",{children:o.title})]})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["The garment will be digitally placed on the model",I.length>1?"s":""," with realistic fabric draping"]})]}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsx(de,{variant:"secondary",children:`${b} images`}),I.length>1&&e.jsx(de,{variant:"secondary",children:`${I.length} models`}),e.jsx(de,{variant:"secondary",children:he[v]}),e.jsx(de,{children:"High Quality"})]})]}),e.jsx(tt,{}),e.jsxs("div",{className:"p-4 rounded-lg bg-muted border border-border flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(to,{className:"w-5 h-5"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold",children:"Credit Cost"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[P," credits × ",b," images"]})]})]}),e.jsxs("div",{className:"text-right",children:[e.jsxs("p",{className:"text-xl font-bold",children:[ce," credits"]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[p-ce," remaining after"]})]})]}),e.jsxs(hs,{children:[e.jsx(Aa,{className:"h-4 w-4"}),e.jsxs(ps,{children:["Virtual Try-On uses advanced AI and typically takes 40-90 seconds to generate ",b," images."]})]}),!ee&&e.jsxs(hs,{variant:"destructive",children:[e.jsx(bt,{className:"h-4 w-4"}),e.jsxs(ps,{className:"space-y-2",children:[e.jsxs("p",{children:["You need ",ce," credits but only have ",p,"."]}),V&&e.jsx(w,{size:"sm",onClick:V,children:"Buy Credits"})]})]})]}),e.jsxs(za,{children:[e.jsx(w,{variant:"outline",onClick:l,disabled:T,children:"Go Back"}),e.jsx(w,{onClick:h,disabled:!ee||T,children:T?"Generating...":`Generate ${b} Images`})]})]})})}const Sl=[{id:"auto",label:"Auto",vibe:"Smart pick for the scene",phrase:"",recommended:!0},{id:"bright-minimal-activewear",label:"Bright Minimal Activewear",vibe:"Crisp white sport set",phrase:"wearing a fitted bright white minimal activewear set, clean lines, no visible logos"},{id:"soft-beige-loungewear",label:"Soft Beige Loungewear",vibe:"Tonal beige 
1knit set",phrase:"wearing a tonal soft beige ribbed loungewear set, relaxed and quiet"},{id:"crisp-white-shirt",label:"Crisp White Shirt",vibe:"White shirt, light denim",phrase:"wearing a crisp oversized white cotton shirt with light-wash straight jeans"},{id:"black-tee-tailored",label:"Black Tee Tailored",vibe:"Black tee, black trousers",phrase:"wearing a fitted plain black t-shirt tucked into tailored black trousers"},{id:"cream-linen-set",label:"Cream Linen Set",vibe:"Soft cream linen co-ord",phrase:"wearing a soft cream linen shirt and matching wide-leg linen trousers"},{id:"oversized-grey-knit",label:"Oversized Grey Knit",vibe:"Grey knit, light denim",phrase:"wearing an oversized soft grey fine-knit sweater with light-wash straight jeans"},{id:"camel-trench-minimal",label:"Camel Trench Minimal",vibe:"Camel coat, white tee",phrase:"wearing a clean camel trench coat over a plain white t-shirt and slim dark jeans"}];function Ko(n,l){if(!n||n==="auto"||Ar(l))return;const h=Sl.find(o=>o.id===n);return(h==null?void 0:h.phrase)||void 0}function Ar(n){const l=(n||"").toLowerCase();return l.includes("wearing")||l.includes("worn ")}const Cl=[{id:"auto",label:"Auto Pair",vibe:"Neutral complement",pieces:{},recommended:!0},{id:"light-denim",label:"Light Denim",vibe:"Light wash, white sneakers",pieces:{bottom:"light-wash straight-leg jeans",top:"a plain crisp white t-shirt",shoes:"clean white minimal sneakers",accessories:"minimal and quiet"}},{id:"tailored-black",label:"Tailored Black",vibe:"Black trousers, black loafers",pieces:{bottom:"tailored straight black trousers",top:"a fitted plain black t-shirt",shoes:"polished black leather loafers",accessories:"minimal and quiet"}},{id:"cream-linen",label:"Cream Linen",vibe:"Linen co-ord, tan sandals",pieces:{bottom:"wide-leg cream linen trousers",top:"a soft cream linen shirt",shoes:"tan leather minimal sandals",accessories:"minimal and quiet"}},{id:"soft-beige",label:"Soft Beige",vibe:"Beige set, white sneakers",pieces:{bottom:"tonal beige relaxed joggers",top:"a tonal beige soft hoodie",shoes:"clean white minimal sneakers",accessories:"minimal and quiet"}},{id:"crisp-white",label:"Crisp White",vibe:"All white, minimal sandals",pieces:{bottom:"crisp white wide-leg trousers",top:"a crisp oversized white cotton shirt",shoes:"minimal white leather sandals",accessories:"minimal and quiet"}},{id:"grey-knit",label:"Grey Knit",vibe:"Grey knit, white sneakers",pieces:{bottom:"mid-grey straight tailored trousers",top:"an oversized soft grey fine-knit sweater",shoes:"clean white minimal sneakers",accessories:"minimal and quiet"}},{id:"camel-trench",label:"Camel Trench",vibe:"Camel coat, leather boots",pieces:{bottom:"slim dark indigo jeans",top:"a plain white t-shirt",outerwear:"a clean camel trench coat",shoes:"polished brown leather ankle boots",accessories:"minimal and quiet"}}];function Ho(n,l){const h=(n||"").toLowerCase().trim(),o=(l||"").toLowerCase().trim(),m=`${h} ${o}`;return/\b(dress|gown|jumpsuit|romper|playsuit|co-?ord|two-?piece set|matching set)\b/.test(m)?"dress":h==="shoes"||/\b(sneaker|trainer|boot|loafer|heel|sandal|mule|pump|oxford|derby|espadrille)s?\b/.test(m)?"shoes":/\b(jean|denim|trouser|pant|short|skirt|legging|jogger|chino|culotte)s?\b/.test(m)?"bottom":/\b(tee|t-?shirt|shirt|blouse|top|crop|tank|cami|sweater|knit|hoodie|sweatshirt|jacket|blazer|coat|cardigan|trench|bomber|parka|vest|polo|tunic|turtleneck)\b/.test(m)?"top":h.includes("bag")||/\b(bag|tote|clutch|backpack|crossbody|handbag|purse|wallet|cardholder)\b/.test(m)?"bag":h.includes("jewel")||/\b(necklace|earring|bracelet|ring|pendant|chain)s?\b/.test(m)?"jewellery":h==="eyewear"||/\b(sunglass|glasses|eyewear|optical)\b/.test(m)?"eyewear":"other"}function Jo(n,l){if(!n||n==="auto")return;const h=Cl.find(T=>T.id===n);if(!h)return;const{bottom:o,top:m,shoes:S,outerwear:N,accessories:b}=h.pieces,v=[];if(l==="dress"?(N&&v.push(N),S&&v.push(S)):l==="top"?(o&&v.push(o),N&&v.push(N),S&&v.push(S)):l==="bottom"?(m&&v.push(m),N&&v.push(N),S&&v.push(S)):l==="shoes"?(m&&v.push(m),o&&v.push(o),N&&v.push(N)):(m&&v.push(m),o&&v.push(o),N&&v.push(N),S&&v.push(S)),v.length===0)return;const p=b?`, accessories ${b}`:"";return`paired with ${v.join(", ")}${p}`}const ks=20,Qo={"1:1":{width:1,height:1,label:"Square"},"4:5":{width:4,height:5,label:"Portrait"},"9:16":{width:9,height:16,label:"Story"},"16:9":{width:16,height:9,label:"Wide"}},Yo={small:44,medium:60,large:80};function kl({ratio:n,size:l="medium"}){const h=Qo[n],o=Yo[l],m=h.width/h.height;let S,N;return m>1?(S=o,N=o/m):(N=o,S=Math.max(o*m,28)),e.jsxs("div",{className:"flex flex-col items-center gap-1",children:[e.jsx("div",{className:"border-2 border-primary rounded-sm bg-primary/10 flex items-center justify-center",style:{width:`${S}px`,height:`${N}px`},children:e.jsx("span",{className:"text-xs font-semibold",children:n})}),e.jsx("p",{className:"text-xs font-medium text-center",children:h.label})]})}function Sa({value:n,onChange:l}){const h=["1:1","4:5","9:16","16:9"],o=m=>{const S=new Set(n);S.has(m)?S.delete(m):S.add(m),l(S)};return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold",children:"Image Size"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Tap to select one or more sizes"})]}),n.size>1&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:[n.size," sizes × each scene"]}
1),e.jsx("div",{className:"flex gap-3 flex-wrap",children:h.map(m=>{const S=n.has(m);return e.jsxs("button",{type:"button",onClick:()=>o(m),className:G("relative p-4 rounded-xl border-2 transition-all flex-1 min-w-[120px]",S?"border-primary bg-primary/10 ring-2 ring-primary/30":"border-border/60 hover:border-muted-foreground"),children:[S&&e.jsx(Is,{className:"absolute top-2 right-2 w-4 h-4 text-primary"}),e.jsx(kl,{ratio:m,size:"small"})]},m)})}),e.jsxs("div",{className:G("flex items-center gap-2 px-3 py-2 rounded-lg bg-destructive/10 text-destructive text-sm font-medium transition-all",n.size===0?"opacity-100":"opacity-0 h-0 overflow-hidden py-0"),children:[e.jsx(bt,{className:"w-4 h-4 shrink-0"}),"Select at least 1 image size"]})]})}function Zo({value:n,onChange:l}){const h=["1:1","4:5","9:16","16:9"];return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold",children:"Image Size"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Choose a size for your images"})]}),e.jsx("div",{className:"flex gap-3 flex-wrap",children:h.map(o=>{const m=n===o;return e.jsxs("button",{type:"button",onClick:()=>l(o),className:G("relative p-4 rounded-xl border-2 transition-all flex-1 min-w-[120px]",m?"border-primary bg-primary/10 ring-2 ring-primary/30":"border-border/60 hover:border-muted-foreground"),children:[m&&e.jsx(Is,{className:"absolute top-2 right-2 w-4 h-4 text-primary"}),e.jsx(kl,{ratio:o,size:"small"})]},o)})})]})}const ha=[{label:"Hands",value:"hands"},{label:"Text overlays",value:"text overlays"},{label:"Busy backgrounds",value:"busy backgrounds"},{label:"Watermarks",value:"watermarks"},{label:"Other products",value:"other products"},{label:"People",value:"people"},{label:"Shadows",value:"harsh shadows"},{label:"Reflections",value:"reflections"}];function Xo({value:n,onChange:l}){const[h,o]=i.useState(""),m=b=>{const v=b.toLowerCase();n.some(p=>p.toLowerCase()===v)?l(n.filter(p=>p.toLowerCase()!==v)):l([...n,b])},S=()=>{const b=h.trim();b&&!n.some(v=>v.toLowerCase()===b.toLowerCase())&&(l([...n,b]),o(""))},N=b=>n.some(v=>v.toLowerCase()===b.toLowerCase());return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold",children:"Don't show these things"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Click to select items you don't want in your photos"})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:ha.map(({label:b,value:v})=>e.jsx("button",{type:"button",onClick:()=>m(v),className:`px-3 py-1.5 rounded-full text-sm font-medium transition-all border ${N(v)?"bg-primary text-primary-foreground border-primary":"bg-card border-border hover:border-primary hover:bg-primary/5"}`,children:e.jsx("span",{className:"flex items-center gap-1",children:N(v)?e.jsxs(e.Fragment,{children:[e.jsx("span",{children:b}),e.jsx(Fs,{className:"w-3 h-3"})]}):e.jsxs(e.Fragment,{children:[e.jsx(ro,{className:"w-3 h-3"}),e.jsx("span",{children:b})]})})},v))}),n.filter(b=>!ha.some(v=>v.value.toLowerCase()===b.toLowerCase())).length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Your custom items:"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:n.filter(b=>!ha.some(v=>v.value.toLowerCase()===b.toLowerCase())).map(b=>e.jsxs("button",{type:"button",onClick:()=>m(b),className:"px-3 py-1.5 rounded-full text-sm font-medium bg-primary text-primary-foreground border border-primary flex items-center gap-1",children:[b,e.jsx(Fs,{className:"w-3 h-3"})]},b))})]}),e.jsxs("div",{className:"flex gap-2 items-end",children:[e.jsx(st,{placeholder:"Type something to avoid...",value:h,onChange:b=>o(b.target.value),className:"flex-1",onKeyDown:b=>{b.key==="Enter"&&(b.preventDefault(),S())}}),e.jsx(w,{size:"sm",onClick:S,disabled:!h.trim(),children:"Add"})]})]})}function Wo({pose:n,isSelected:l,onSelect:h,selectedGender:o,selectionIndex:m}){const S=K(n.previewUrl,{quality:60});return e.jsxs("div",{onClick:h,className:`relative cursor-pointer rounded-lg sm:rounded-xl overflow-hidden transition-all duration-200 group ${l?"ring-2 ring-primary ring-offset-1 sm:ring-offset-2 shadow-lg scale-[1.02]":"ring-1 ring-border hover:ring-primary hover:shadow-md hover:scale-[1.01]"}`,children:[e.jsx("div",{className:"aspect-[4/5] overflow-hidden bg-muted",children:e.jsx(Gs,{src:S,alt:n.name,className:"w-full h-full object-cover transition-transform duration-500 group-hover:scale-105",aspectRatio:"4/5"})}),l&&e.jsx("div",{className:"absolute inset-0 bg-primary/10 pointer-events-none",children:e.jsx("div",{className:"absolute top-1.5 right-1.5 sm:top-2 sm:right-2 w-5 h-5 sm:w-7 sm:h-7 bg-primary rounded-full flex items-center justify-center shadow-md",children:m!==void 0?e.jsx("span",{className:"text-[10px] sm:text-xs font-bold text-primary-foreground",children:m}
1):e.jsx("svg",{className:"w-3 h-3 sm:w-4 sm:h-4 text-white",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:3,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})})}),e.jsx("div",{className:"absolute bottom-0 inset-x-0 bg-gradient-to-t from-black/90 via-black/70 to-transparent p-2 sm:p-3 pt-6 sm:pt-10",children:e.jsx("div",{className:"space-y-0.5 sm:space-y-1",children:e.jsx("p",{className:"text-white text-xs sm:text-sm font-bold",children:n.name})})})]})}const ed=[{id:"product-only",icon:tr,title:"Product Shot",subtitle:"Focus on the product itself",creditCost:"4-6 credits/image",useCases:["Detail shots","Flat lay","Studio backgrounds","E-commerce listings"]},{id:"virtual-try-on",icon:Pa,title:"Virtual Try-On",subtitle:"See it on a model",creditCost:"6 credits/image",useCases:["Lookbooks","Social media","Lifestyle shots","Model photography"],badgeText:"AI-Powered"}];function sd({mode:n,onChange:l}){return e.jsx("div",{className:"grid grid-cols-2 gap-3 sm:gap-4 w-full max-w-3xl",children:ed.map(h=>{const o=n===h.id;return e.jsxs(re,{onClick:()=>l(h.id),className:`relative cursor-pointer p-3 sm:p-5 transition-all duration-200 group ${o?"ring-2 ring-primary bg-primary/5 shadow-md":"hover:shadow-lg hover:border-border"}`,children:[h.badgeText&&e.jsx("div",{className:"absolute top-2 right-2 sm:top-3 sm:right-3",children:e.jsx("span",{className:"px-1.5 py-0.5 text-[8px] sm:text-[10px] font-semibold rounded-full bg-foreground
1/10 text-foreground/70",children:h.badgeText})}),o&&e.jsx("div",{className:"absolute top-2 left-2 sm:top-3 sm:left-3",children:e.jsx("div",{className:"w-4 h-4 sm:w-5 sm:h-5 rounded-full bg-primary flex items-center justify-center",children:e.jsx("svg",{className:"w-2.5 h-2.5 sm:w-3 sm:h-3 text-white",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:3,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})})}),e.jsxs("div",{className:"flex flex-col items-center text-center space-y-2 sm:space-y-4 pt-3 sm:pt-4",children:[e.jsx("div",{className:`w-10 h-10 sm:w-16 sm:h-16 rounded-xl sm:rounded-2xl flex items-center justify-center transition-colors ${o?"bg-primary/10":"bg-muted"}`,children:e.jsx(h.icon,{className:`w-5 h-5 sm:w-8 sm:h-8 ${o?"text-primary":"text-muted-foreground"}`})}),e.jsxs("div",{className:"space-y-0.5 sm:space-y-1",children:[e.jsx("p",{className:"text-sm sm:text-base font-bold",children:h.title}),e.jsx("p",{className:"text-[10px] sm:text-xs text-muted-foreground",children:h.subtitle})]}),e.jsx("div",{className:`inline-flex items-center px-2 py-1 sm:px-3 sm:py-1.5 rounded-full text-[10px] sm:text-xs font-medium border ${o?"border-primary/30 bg-primary/5 text-primary":"border-border bg-muted text-muted-foreground"}`,children:h.creditCost}),e.jsxs("div",{className:"hidden sm:block w-full pt-3 border-t border-border",children:[e.jsx("p",{className:"text-xs font-semibold text-muted-foreground",children:"Best for:"}),e.jsx("div",{className:"flex flex-wrap gap-1.5 justify-center mt-2",children:h.useCases.map(m=>e.jsx("span",{className:"px-2 py-0.5 text-[11px] rounded-md bg-muted text-muted-foreground",children:m},m))})]})]})]},h.id)})})}const td=[{value:"all",label:"All"},{value:"female",label:"Female"},{value:"male",label:"Male"}],rd=[{value:"all",label:"All"},{value:"slim",label:"Slim"},{value:"athletic",label:"Athletic"},{value:"average",label:"Average"},{value:"plus-size",label:"Plus Size"}],ad=[{value:"all",label:"All"},{value:"young-adult",label:"Young Adult"},{value:"adult",label:"Adult"},{value:"mature",label:"Mature"}];function id({genderFilter:n,bodyTypeFilter:l,ageFilter:h,onGenderChange:o,onBodyTypeChange:m,onAgeChange:S}){const N=qn(),[b,v]=i.useState(!1),p=[n,l,h].filter(k=>k!=="all").length,T=e.jsxs(e.Fragment,{children:[e.jsx(pa,{label:"Gender",options:td,value:n,onChange:o}),e.jsx(pa,{label:"Body Type",options:rd,value:l,onChange:m}),e.jsx(pa,{label:"Age",options:ad,value:h,onChange:S})]});return N?e.jsxs(jl,{open:b,onOpenChange:v,children:[e.jsx(yl,{asChild:!0,children:e.jsxs("button",{className:"flex items-center gap-2 px-3.5 py-2 rounded-xl border border-border bg-background hover:bg-accent transition-colors w-full justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ao,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm font-medium",children:"Filters"}),p>0&&e.jsx(de,{variant:"secondary",className:"rounded-full px-1.5 h-5 min-w-5 text-[10px] flex items-center justify-center",children:p})]}),e.jsx(Nl,{className:`w-4 h-4 text-muted-foreground transition-transform duration-200 ${b?"rotate-180":""}`})]})}),e.jsx(vl,{className:"mt-2",children:e.jsx("div",{className:"flex flex-col gap-3 p-3 bg-muted rounded-xl border border-border",children:T})})]}):e.jsx("div",{className:"flex flex-col gap-3 sm:gap-4 p-3 sm:p-4 bg-muted rounded-xl border border-border",children:T})}function pa({label:n,options:l,value:h,onChange:o}){return e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center gap-2",children:[e.jsxs("span",{className:"text-xs sm:text-sm font-medium text-muted-foreground sm:min-w-[80px]",children:[n,":"]}),e.jsx("div",{className:"flex flex-wrap gap-1 sm:gap-1.5",children:l.map(m=>e.jsx(w,{size:"sm",variant:h===m.value?"default":"outline",onClick:()=>o(m.value),className:"h-7 text-xs",children:m.label},m.value))})]})}function Ca({product:n,scratchUpload:l,model:h,models:o,pose:m,poses:S,creditCost:N=0,selectedGender:b,products:v}){var pe;const p=S&&S.length>0?S:m?[m]:[],T=o&&o.length>0?o:h?[h]:[],k=p[0]||null,V=T[0]||null,I=k==null?void 0:k.previewUrl,B=((pe=n==null?void 0:n.images[0])==null?void 0:pe.url)||(l==null?void 0:l.previewUrl),P=(n==null?void 0:n.title)||(l==null?void 0:l.productInfo.title)||"",ce=!!(n||l),ee=v&&v.length>1,he=p.length>1,Ce=T.length>1,_e=ce&&T.length>0&&p.length>0,H=_e?ee?`${T.map(J=>J.name).slice(0,2).join(", ")}${T.length>
12?` +${T.length-2}`:""} wearing ${v.length} products in ${p.length} scene${p.length>1?"s":""}`:Ce?`${T.map(J=>J.name).slice(0,3).join(", ")}${T.length>3?` +${T.length-3}`:""} wearing ${P} in ${p.length} scene${p.length>1?"s":""}`:he?`${V.name} wearing ${P} in ${p.length} scenes`:`${V.name} in ${k.name} wearing ${P}`:"Complete your selections to see preview";return e.jsx(re,{className:"p-3 sm:p-4 bg-gradient-to-br from-muted/30 to-muted/50 border-2 border-dashed border-border",children:e.jsxs("div",{className:"space-y-3 sm:space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"font-bold text-sm",children:"Preview"}),N>0&&e.jsxs("span",{className:"px-2 py-0.5 text-[10px] sm:text-xs font-medium rounded-full bg-primary/10 text-primary",children:[N," credits"]})]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-2 sm:gap-3",children:[ee?e.jsx(ld,{products:v}):e.jsx(ga,{image:B,label:"Product",active:ce}),e.jsx("div",{className:"w-5 h-5 rounded-full bg-muted flex items-center justify-center",children:e.jsx(il,{className:"w-3 h-3 text-muted-foreground"})}),Ce?e.jsx(hl,{items:T.map(J=>({id:J.modelId,image:J.previewUrl,name:J.name})),label:"models",round:!0}):e.jsx(ga,{image:V==null?void 0:V.previewUrl,label:"Model",active:T.length>0,round:!0}),e.jsx("div",{className:"w-5 h-5 rounded-full bg-muted flex items-center justify-center",children:e.jsx(il,{className:"w-3 h-3 text-muted-foreground"})}),he?e.jsx(hl,{items:p.map(J=>({id:J.poseId,image:J.previewUrl,name:J.name})),label:"scenes"}):e.jsx(ga,{image:I,label:"Scene",active:!!k}),_e&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-5 h-5 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx(io,{className:"w-3 h-3 text-primary"})}),e.jsx("div",{className:"w-14 h-14 sm:w-20 sm:h-20 rounded-lg border-2 border-primary bg-primary/5 flex items-center justify-center",children:e.jsx("span",{className:"text-[8px] sm:text-[10px] text-primary font-medium text-center px-1",children:"AI Generated"})})]})]}),e.jsx("div",{className:"text-center",children:_e?e.jsxs("p",{className:"font-medium text-xs sm:text-sm",children:['"',H,'"']}):e.jsx("p",{className:"text-xs sm:text-sm text-muted-foreground",children:H})}),e.jsxs("div",{className:"flex justify-center gap-3 sm:gap-4 pt-2 border-t border-border",children:[e.jsx(xa,{label:"Product",completed:ce,count:ee?v.length:void 0}),e.jsx(xa,{label:"Model",completed:T.length>0,count:Ce?T.length:void 0}),e.jsx(xa,{label:"Scene",completed:p.length>0,count:he?p.length:void 0})]})]})})}function hl({items:n,label:l,round:h}){const o=Math.min(n.length,3);return e.jsxs("div",{className:"flex items-center gap-1.5",children:[n.slice(0,o).map(m=>e.jsx("div",{className:`w-12 h-12 sm:w-16 sm:h-16 ${h?"rounded-full":"rounded-lg"} overflow-hidden border-2 border-primary bg-card flex-shrink-0`,children:e.jsx("img",{src:m.image,alt:m.name,className:"w-full h-full object-cover"})},m.id)),n.length>o&&e.jsxs("span",{className:"px-1.5 py-0.5 text-[10px] font-semibold rounded-full bg-primary text-primary-foreground",children:["+",n.length-o]}),e.jsxs("span",{className:"ml-1 text-[10px] sm:text-xs font-medium text-primary",children:[n.length," ",l]})]})}function ld({products:n}){const l=Math.min(n.length,3),h=n.length-l;return e.jsxs("div",{className:"relative flex items-center",children:[e.jsx("div",{className:"flex gap-1.5",children:n.slice(0,l).map(o=>{var m;return e.jsx("div",{className:"w-12 h-12 sm:w-16 sm:h-16 rounded-lg overflow-hidden border-2 border-primary bg-card flex-shrink-0",children:(m=o.images[0])!=null&&m.url?e.jsx("img",{src:K(o.images[0].url,{quality:60}),alt:o.title,className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center bg-muted",children:e.jsx("span",{className:"text-[8px] text-muted-foreground",children:"No img"})})},o.id)})}),h>0&&e.jsxs("span",{className:"ml-1 px-1.5 py-0.5 text-[10px] font-semibold rounded-full bg-primary text-primary-foreground",children:["+",h]}),e.jsxs("span",{className:"ml-2 text-[10px] sm:text-xs font-medium text-primary",children:[n.length," products"]})]})}function ga({image:n,label:l,active:h,round:o}){return e.jsx("div",{className:`w-14 h-14 sm:w-20 sm:h-20 ${o?"rounded-full":"rounded-lg sm:rounded-xl"} overflow-hidden border-2 flex-shrink-0 ${h?"border-primary bg-card":"border-dashed border-muted-foreground
1/30 bg-muted"}`,children:n?e.jsx("img",{src:n,alt:l,className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx("span",{className:"text-[8px] sm:text-[10px] text-muted-foreground text-center px-1",children:l})})})}function xa({label:n,completed:l,count:h}){return e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:`w-2 h-2 rounded-full ${l?"bg-primary":"bg-muted-foreground/30"}`}),e.jsxs("span",{className:`text-xs ${l?"text-foreground font-medium":"text-muted-foreground"}`,children:[n,h&&h>1?` (${h})`:""]})]})}function nd(n,l){const h=[],o=n.find(k=>k.name==="Yuki"),m=n.find(k=>k.name==="Amara"),S=n.find(k=>k.name==="Marcus"),N=n.find(k=>k.name==="Isabella"),b=l.find(k=>k.category==="studio"&&k.name.includes("Front")),v=l.find(k=>k.category==="lifestyle"),p=l.find(k=>k.category==="streetwear"),T=l.find(k=>k.category==="editorial");return o&&b&&h.push({id:"combo_1",model:o,pose:b,label:"Classic Lookbook",bestFor:"E-commerce product pages"}),m&&v&&h.push({id:"combo_2",model:m,pose:v,label:"Lifestyle Casual",bestFor:"Social media & ads"}),S&&p&&h.push({id:"combo_3",model:S,pose:p,label:"Urban Street",bestFor:"Streetwear brands"}),N&&T&&h.push({id:"combo_4",model:N,pose:T,label:"Editorial Plus",bestFor:"Inclusive campaigns"}),h}function od({sourceType:n,onChange:l,showLibrary:h=!1}){const o=[...h?[{id:"library",title:"From Library",description:"Select from your previously generated images",icon:tr}]:[],{id:"product",title:"From Product(s)",description:"Select one or multiple products",icon:Pr},{id:"scratch",title:"From Scratch",description:"Upload your own image file to generate from",icon:Ma}];return e.jsx("div",{className:`grid grid-cols-1 ${h?"sm:grid-cols-3":"sm:grid-cols-2"} gap-4`,children:o.map(m=>e.jsx("button",{type:"button",onClick:()=>l(m.id),className:`p-6 rounded-xl border-2 transition-all duration-200 text-left cursor-pointer ${n===m.id?"border-primary bg-primary/5 shadow-md":"border-border hover:border-primary/50 hover:bg-muted"}`,children:e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:`w-12 h-12 rounded-lg flex items-center justify-center ${n===m.id?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground"}`,children:e.jsx(m.icon,{className:"w-6 h-6"})}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-lg font-semibold",children:m.title}),e.jsx("p",{className:"text-sm text-muted-foreground",children:m.description})]}),n===m.id&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-primary"}),e.jsx("span",{className:"text-sm font-medium",children:"Selected"})]})]})},m.id))})}const dd=10*1024*1024,cd=["image/jpeg","image/png","image/webp"];function md(n){return new Promise((l,h)=>{const o=new FileReader;o.onloadend=()=>l(o.result),o.onerror=()=>h(new Error("Failed to read file")),o.readAsDataURL(n)})}function ud({scratchUpload:n,onUpload:l,onRemove:h,onUpdateProductInfo:o,isUploading:m=!1,variant:S="product",saveToLibrary:N=!1,onSaveToLibraryChange:b,onBulkFiles:v}){const p=S==="room",T=!p&&!!v,[k,V]=i.useState(!1),[I,B]=i.useState(null),[P,ce]=i.useState(!1),[ee,he]=i.useState(!1),Ce=z=>cd.includes(z.type)?z.size>dd?"File size must be under 10MB.":null:"Please upload a JPG, PNG, or WEBP image.",_e=i.useCallback(async(z,ie)=>{ce(!0);try{const ke=await md(z),{data:{session:$}}=await Me.auth.getSession();if(!($!=null&&$.access_token))throw new Error("Not authenticated");const ve=await fetch("https://azwiljtrbtaupofwmpzb.supabase.co/functions/v1/analyze-product-image",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${$.access_token}`},body:JSON.stringify({imageUrl:ke})});if(!ve.ok)throw new Error("Analysis failed");const Y=await ve.json();if((Y==null?void 0:Y.kind)==="not_product"){const $e=typeof Y.reason=="string"&&Y.reason?Y.reason:"That image doesn't look like a product";A.error(`${$e}. Please upload a product photo.`),h();return}o({title:Y.title||ie.title,productType:Y.productType||ie.productType,description:Y.description||ie.description,category:Y.category||ie.category,categoryConfirmed:!1})}catch{A.error("AI analysis failed — fill in details manually")}finally{ce(!1)}},[o,h]),H=i.useCallback(z=>{const ie=Ce(z);if(ie){B(ie);return}B(null);const ke=URL.createObjectURL(z),$={title:p?"Uploaded Room":z.name.replace(/\.[^/.]+$/,"").replace(/[-_]/g," "),productType:p?"Room":"",description:""};l({file:z,previewUrl:ke,productInfo:$}),p||_e(z,$)},[l,_e,p]),pe=i.useCallback(z=>{if(z.length===0)return;if(z.length===1||!T){H(z[0]);return}const ie=[];for(const ke of z){const $=Ce(ke);if($){B(`${ke.name}: ${$}`);return}ie.push(ke)}B(null),v(ie)},[H,v,T]),J=i.useCallback(z=>{z.preventDefault(),V(!1);const ie=Array.from(z.dataTransfer.files);ie.length&&pe(ie)},[pe]),Be=i.useCallback(z=>{const ie=Array.from(z.target.files||[]);ie.length&&pe(ie),z.target.value=""},[pe]);if(i.useEffect(()=>{if(n)return;const z=ie=>{var $;const ke=($=ie.clipboardData)==null?void 0:$.items;if(ke){for(const ve of Array.from(ke))if(ve.type.startsWith("image/")){ie.preventDefault();const Y=ve.getAsFile();Y&&H(Y);return}}};return document.addEventListener("paste",z),()=>document.removeEventListener("paste",z)},[n,H]),n){const z=n.productInfo,ie=!!z.category,ke=!!z.categoryConfirmed;return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"aspect-square max-w-[200px] sm:max-w-xs rounded-lg overflow-hidden border border-border bg-card",children:e.jsx("img",{src:n.previewUrl,alt:p?"Uploaded room photo":"Uploaded product",className:"w-full h-full object-contain"})}),e.jsx("button",{type:"button",onClick:h,className:"absolute top-2 right-2 p-1.5 rounded-full bg-background/90 hover:bg-destructive hover:text-destructive-foreground transition-colors border border-border",children:e.jsx(Fs,{className:"w-4 h-4"})})]}),!p&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("h4",{className:"font-semibold",children:"Product Details"}),P?e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground py-4",children:[e.jsx(Ws,{className:"w-4 h-4 animate-spin"}),e.jsx(Vs,{className:"w-4 h-4 text-primary/60"}),"AI analyzing product…"]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(oe,{className:"flex items-center gap-1.5",children:[e.jsx(Vs,{className:"w-3 h-3 text-primary/70"}),"AI detected category"]}),ie&&!ee&&ke?e.jsxs("div",{className:"flex items-center justify-between rounded-md border border-border bg-muted/40 px-3 py-2",children:[e.jsxs("span",{className:"text-sm flex items-center gap-1.5",children:[e.jsx(Is,{className:"w-3.5 h-3.5 text-primary"}),"Category: ",e.jsx("span",{className:"font-medium",children:Po(z.category)})]}),e.jsxs("button",{type:"button",onClick:()=>he(!0),className:"text-xs text-muted-foreground hover:text-foreground flex items-center gap-1",children:[e.jsx(lo,{className:"w-3 h-3"})," Edit"]})]}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(Ze,{value:z.category||"",onValueChange:$=>{o({...z,category:$,categoryConfirmed:!0}),he(!1)},children:[e.jsx(Xe,{className:`h-10 flex-1 ${!ke&&ie?"ring-1 ring-primary/40":""}`,children:e.jsx(We,{placeholder:"Pick a category…"})}),e.jsx(es,{children:Ao.map($=>e.jsx(D,{value:$.value,children:$.label},$.value))})]}),ie&&!ke&&e.jsxs(w,{type:"button",size:"sm",onClick:()=>o({...z,categoryConfirmed:!0}),children:[e.jsx(Is,{className:"w-4 h-4 mr-1"})," Looks right"]})]})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Add details to help the AI generate better images."}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(oe,{htmlFor:"product-title",children:"Product Title"}),e.jsx(st,{id:"product-title",value:z.title,onChange:$=>o({...z,title:$.target.value}),placeholder:"e.g., High-Waist Yoga Leggings"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(oe,{children:["Product Type ",e.jsx("span",{className:"text-xs text-muted-foreground font-normal",children:"(optional — refines AI understanding)"})]}
1),e.jsx(st,{value:z.productType,onChange:$=>o({...z,productType:$.target.value}),placeholder:"e.g. Scented Candle, Sneakers, Face Serum…",maxLength:100})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(oe,{htmlFor:"product-desc",children:"Description (optional)"}),e.jsx($a,{id:"product-desc",value:z.description,onChange:$=>o({...z,description:$.target.value}),placeholder:"e.g., Black seamless leggings with high waistband",rows:3})]}),b&&e.jsxs("label",{className:"flex items-start gap-2.5 pt-1 cursor-pointer group",children:[e.jsx(zo,{checked:N,onCheckedChange:$=>b(!!$),className:"mt-0.5"}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx("span",{className:"text-sm font-medium group-hover:text-foreground transition-colors",children:"Save to My Products"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Save this product to your library so you can reuse it across Visual Types without uploading again."})]})]})]})]}),m&&e.jsx(hs,{children:e.jsx(ps,{children:"Uploading image to storage..."})})]})}return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{onDrop:J,onDragOver:z=>{z.preventDefault(),V(!0)},onDragLeave:z=>{z.preventDefault(),V(!1)},className:`relative border-2 border-dashed rounded-xl p-8 text-center transition-all cursor-pointer ${k?"border-primary bg-primary/5":"border-border hover:border-primary/50 hover:bg-muted"}`,children:[e.jsx("input",{type:"file",accept:".jpg,.jpeg,.png,.webp",multiple:T,onChange:Be,className:"absolute inset-0 w-full h-full opacity-0 cursor-pointer"}),e.jsxs("div",{className:"flex flex-col items-center gap-3",children:[e.jsx("div",{className:`w-16 h-16 rounded-full flex items-center justify-center ${k?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground"}`,children:k?e.jsx(tr,{className:"w-7 h-7"}):e.jsx(Ma,{className:"w-7 h-7"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold",children:k?"Drop your image here":"Drag & drop, paste, or tap to upload"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:T?"JPG, PNG, WEBP • Max 10MB • Upload multiple at once":"JPG, PNG, WEBP • Max 10MB"}),e.jsxs("p",{className:"flex items-center gap-1.5 text-xs text-muted-foreground/70 mt-1",children:[e.jsx(no,{className:"w-3 h-3"}),"⌘V / Ctrl+V to paste from clipboard"]})]}),e.jsx(w,{variant:"outline",size:"sm",disabled:k,children:T?"Choose File(s)":"Choose File"})]})]}),I&&e.jsx(hs,{variant:"destructive",children:e.jsxs(ps,{className:"flex items-center justify-between",children:[I,e.jsx("button",{onClick:()=>B(null),className:"ml-2",children:e.jsx(Fs,{className:"w-4 h-4"})})]})})]})}function hd({open:n,onClose:l,products:h,selectedProduct:o,onSelectProduct:m,onPublish:S,selectedImageCount:N}){var V;const[b,v]=i.useState(""),[p,T]=i.useState("add"),k=i.useMemo(()=>{if(!b.trim())return h;const I=b.toLowerCase();return h.filter(B=>B.title.toLowerCase().includes(I)||B.vendor.toLowerCase().includes(I)||B.productType.toLowerCase().includes(I))},[h,b]);return e.jsx(ka,{open:n,onOpenChange:l,children:e.jsxs(Ia,{className:"max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsx(_a,{children:e.jsx(Ta,{children:"Assign to Product"})}),e.jsx("div",{className:"space-y-5",children:o?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"p-4 border border-primary rounded-lg bg-primary/5 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-md overflow-hidden flex-shrink-0 border border-border",children:e.jsx("img",{src:K((V=o.images[0])==null?void 0:V.url,{quality:60})||"/placeholder.svg",alt:o.title,className:"w-full h-full object-cover"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(et,{className:"w-4 h-4 text-primary"}),e.jsx("p",{className:"font-semibold text-sm",children:o.title})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:o.vendor})]})]}),e.jsx(w,{variant:"ghost",size:"sm",onClick:()=>m(null),children:"Change"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-semibold",children:"Download Mode"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("button",{type:"button",onClick:()=>T("add"),className:`p-4 rounded-lg border-2 text-left ${p==="add"?"border-primary bg-primary/5":"border-border hover:border-primary/50"}`,children:[e.jsx("p",{className:"font-semibold text-sm",children:"Add to Product"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Keep existing images"})]}),e.jsxs("button",{type:"button",onClick:()=>T("replace"),className:`p-4 rounded-lg border-2 text-left ${p==="replace"?"border-primary bg-primary/5":"border-border hover:border-primary/50"}`,children:[e.jsx("p",{className:"font-semibold text-sm",children:"Replace All"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Use only new images"})]})]})]}),e.jsx(hs,{children:e.jsxs(ps,{children:[N," image",N!==1?"s":""," will be ",p==="add"?"added to":"set as the images for"," ",e.jsx("strong",{children:o.title})]})})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-muted-foreground",children:"Search and select a product to assign your generated images to."}),e.jsxs("div",{className:"relative",children:[e.jsx(Tr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),e.jsx(st,{placeholder:"Search by name, vendor, or type...",value:b,onChange:I=>v(I.target.value),className:"pl-9"})]}),e.jsx("div",{className:"space-y-2 max-h-[300px] overflow-y-auto",children:k.length===0?e.jsx(hs,{children:e.jsxs(ps,{children:['No products found matching "',b,'"']})}):k.slice(0,10).map(I=>{var B;return e.jsxs("button",{type:"button",onClick:()=>m(I),className:"w-full p-3 border border-border rounded-lg hover:bg-muted transition-colors text-left flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-md overflow-hidden flex-shrink-0 border border-border",children:e.jsx("img",{src:K((B=I.images[0])==null?void 0:B.url,{quality:60})||"/placeholder.svg",alt:I.title,loading:"lazy",className:"w-full h-full object-cover"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"font-semibold text-sm",children:I.title}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[I.vendor," • ",I.productType]}),e.jsx("div",{className:"flex gap-1 mt-1",children:I.tags.slice(0,3).map(P=>e.jsx(de,{variant:"secondary",className:"text-[10px]",children:P},P))})]})]},I.id)})})]})}),e.jsxs(za,{children:[e.jsx(w,{variant:"outline",onClick:l,children:"Cancel"}),e.jsxs(w,{onClick:()=>o&&S(o,p),disabled:!o,children:["Download ",N," Image",N!==1?"s":""]})]})]})})}const At=n=>
1K(bl(n),{quality:60}),pd=[{src:At("products/tank-white-1.jpg"),label:"Front-facing"},{src:At("products/sports-bra-black-1.jpg"),label:"Single item"},{src:At("products/leggings-black-1.jpg"),label:"Clean background"}],gd=[{src:At("products/avoid-flatlay.jpg"),label:"Busy background"},{src:At("products/avoid-lowcontrast.jpg"),label:"Too many items"},{src:At("products/avoid-cropped.jpg"),label:"Cropped photo"}];function xd(){const[n,l]=i.useState("good"),[h,o]=i.useState(!0);i.useEffect(()=>{if(!h)return;const N=setInterval(()=>{l(b=>b==="good"?"bad":"good")},4e3);return()=>clearInterval(N)},[h]);const m=N=>{l(N),o(!1)},S=n==="good"?pd:gd;return e.jsxs("div",{className:"rounded-lg border border-border bg-card overflow-hidden",children:[e.jsxs("div",{className:"flex",children:[e.jsxs("button",{type:"button",onClick:()=>m("good"),className:G("flex-1 py-1.5 px-2 text-[11px] font-semibold transition-colors flex items-center justify-center gap-1",n==="good"?"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 border-b-2 border-emerald-500":"text-muted-foreground hover:bg-muted/50 border-b border-border"),children:[e.jsx(Is,{className:"w-3 h-3"}),"Best"]}),e.jsxs("button",{type:"button",onClick:()=>m("bad"),className:G("flex-1 py-1.5 px-2 text-[11px] font-semibold transition-colors flex items-center justify-center gap-1",n==="bad"?"bg-destructive/10 text-destructive border-b-2 border-destructive":"text-muted-foreground hover:bg-muted/50 border-b border-border"),children:[e.jsx(Fs,{className:"w-3 h-3"}),"Avoid"]})]}),e.jsx("div",{className:"p-2",children:e.jsx("div",{className:"grid grid-cols-3 gap-1.5 animate-in fade-in slide-in-from-bottom-1 duration-300",children:S.map((N,b)=>e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"aspect-square rounded-md overflow-hidden border border-border bg-muted",children:e.jsx("img",{src:N.src,alt:N.label,className:"w-full h-full object-cover"})}),e.jsx("div",{className:G("absolute top-0.5 right-0.5 w-3.5 h-3.5 rounded-full flex items-center justify-center shadow-sm",n==="good"?"bg-emerald-500 text-white":"bg-destructive text-destructive-foreground"),children:n==="good"?e.jsx(Is,{className:"w-2 h-2",strokeWidth:3}):e.jsx(Fs,{className:"w-2 h-2",strokeWidth:3})}),e.jsx("p",{className:"text-[9px] text-muted-foreground mt-0.5 text-center leading-tight truncate",children:N.label})]},b))},n)}),h&&e.jsx("div",{className:"h-0.5 bg-muted overflow-hidden",children:e.jsx("div",{className:"h-full bg-primary/40",style:{animation:"progress 4s linear forwards"}},n)}),e.jsx("style",{children:`
2        @keyframes progress {
3          from { width: 0%; }
4          to { width: 100%; }
5        }
6      `})]})}const Xs="v2",La=[{value:"full_body",label:"Full Body",description:"Head to toe, full outfit",keywords:["dress","jumpsuit","romper","outfit","full body"],previewUrl:`/images/framing/full_body.png?${Xs}`},{value:"upper_body",label:"Upper Body",description:"Waist up, tops & social",keywords:["top","shirt","blouse","hoodie","sweater","jacket"],previewUrl:`/images/framing/upper_body.png?${Xs}`},{value:"close_up",label:"Close-Up",description:"Shoulders up, detail focus",keywords:["scarf","scarves","glasses","sunglasses"],previewUrl:`/images/framing/close_up.png?${Xs}`},{value:"hand_wrist",label:"Hand / Wrist",description:"Watches, bracelets, rings",keywords:["watch","bracelet","ring","bangle","wristband","cuff"],previewUrl:`/images/framing/hand_wrist.png?${Xs}`},{value:"neck_shoulders",label:"Neck / Shoulders",description:"Necklaces, pendants, chokers",keywords:["necklace","pendant","choker","collar"],previewUrl:`/images/framing/neck_shoulders.png?${Xs}`},{value:"side_profile",label:"Side Profile",description:"Earrings, ear cuffs",keywords:["earring","earrings","ear cuff","ear"],previewUrl:`/images/framing/side_profile.png?${Xs}`},{value:"lower_body",label:"Lower Body",description:"Shoes, pants, skirts",keywords:["shoes","sneakers","boots","heels","sandals","loafers","slides"],previewUrl:`/images/framing/lower_body.png?${Xs}`},{value:"back_view",label:"Back View",description:"Backpacks, rear details",keywords:["backpack","tote","rucksack"],previewUrl:`/images/framing/back_view.png?${Xs}`}];function fd(n,l=[]){const h=`${n} ${l.join(" ")}`.toLowerCase();for(const o of La)if(!(o.value==="full_body"||o.value==="upper_body")&&o.keywords.some(m=>h.includes(m)))return o.value;return null}function bd({selectedProduct:n,scratchUpload:l,sourceType:h,isMultiProductMode:o,productQueue:m,creditCost:S,upscaleImageCount:N,balance:b,openBuyModal:v,handleGenerateClick:p,setCurrentStep:T}){var V;const k=h==="scratch"?"upload":h==="library"?"library":"product";return e.jsxs("div",{className:"space-y-4",children:[e.jsx(re,{children:e.jsxs(le,{className:"p-5 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:h==="scratch"?"Uploaded Image":o?`Selected Images (${m.length})`:"Selected Product"}),e.jsx(w,{variant:"link",size:"sm",onClick:()=>T(k),children:"Change"})]}),o?e.jsx("div",{className:"flex gap-2 overflow-x-auto pb-1",children:m.map(I=>{var B;return e.jsxs("div",{className:"flex-shrink-0 w-[72px]",children:[e.jsx("div",{className:"w-14 h-14 roun
6ded-lg overflow-hidden border border-border mx-auto",children:e.jsx("img",{src:K((B=I.images[0])==null?void 0:B.url,{quality:60})||"/placeholder.svg",alt:I.title,loading:"lazy",className:"w-full h-full object-cover"})}),e.jsx("p",{className:"text-[10px] text-muted-foreground text-center mt-1 truncate",children:I.title})]},I.id)})}):e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"w-16 h-16 rounded-lg overflow-hidden border border-border",children:e.jsx("img",{src:K(h==="scratch"?l==null?void 0:l.previewUrl:((V=n==null?void 0:n.images[0])==null?void 0:V.url)||"/placeholder.svg",{quality:60}),alt:"",className:"w-full h-full object-cover"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold",children:h==="scratch"?l==null?void 0:l.productInfo.title:n==null?void 0:n.title}),e.jsx("p",{className:"text-sm text-muted-foreground",children:h==="scratch"?"Custom Upload":n==null?void 0:n.productType})]})]})]})}),e.jsx(re,{children:e.jsxs(le,{className:"p-5 space-y-4",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(Vs,{className:"w-5 h-5 text-primary"}),"Enhance to 4K"]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Print-ready 4096px output with AI texture recovery"})]}),e.jsxs("div",{className:"rounded-xl border border-primary/30 bg-primary/5 p-5 flex items-center gap-4",children:[e.jsxs("div",{className:"flex flex-col items-center justify-center w-16 h-16 rounded-xl bg-primary text-primary-foreground shrink-0",children:[e.jsx("span",{className:"text-lg font-bold leading-none",children:"4K"}),e.jsx("span",{className:"text-[10px] font-medium opacity-80 mt-1",children:"4096px"})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-semibold text-foreground",children:"Maximum resolution"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-0.5",children:"Sharper textures, richer detail, ready for print & large displays"}),e.jsx("p",{className:"text-sm font-semibold text-primary mt-2",children:"15 credits per image"})]})]})]})}),e.jsxs("div",{className:G("p-4 rounded-lg border flex items-center justify-between",b>=S?"border-border bg-muted/30":"border-destructive/30 bg-destructive/5"),children:[e.jsxs("div",{children:[e.jsxs("p",{className:"text-sm font-semibold",children:["Total: ",S," credits"]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[N," image",N!==1?"s":""," × 15 credits (4K)"]})]}),b>=S?e.jsxs("p",{className:"text-sm text-muted-foreground",children:[b," credits available"]}):e.jsxs("button",{onClick:v,className:"flex items-center gap-1 text-sm text-destructive font-semibold hover:underline",children:[e.jsx(bt,{className:"w-3.5 h-3.5"}),b," credits — need ",S,". Top up"]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx(w,{variant:"outline",onClick:()=>T(k),children:"Back"}),e.jsxs(w,{onClick:b>=S?p:v,className:G("gap-2",b<S?"bg-primary text-primary-foreground hover:bg-primary/90":""),children:[e.jsx(Vs,{className:"w-4 h-4"}),b>=S?`Enhance ${N} Image${N!==1?"s":""} to 4K`:"Buy Credits"]})]})]})}[...La.map(n=>({value:n.value,label:n.label,description:n.description,previewUrl:n.previewUrl}))];function Il({selectedFramings:n,onSelectedFramingsChange:l}){const h=o=>{const m=new Set(n);o==="auto"?m.has("auto")?m.delete("auto"):(m.clear(),m.add("auto")):(m.delete("auto"),m.has(o)?(m.delete(o),m.size===0&&m.add("auto")):m.add(o)),l(m)};return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("label",{className:"text-sm font-medium",children:"Framing"}),n.size>1&&!n.has("auto")&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:[n.size," framings × each scene"]})]}),e.jsxs("div",{className:"flex flex-nowrap overflow-x-auto gap-2 pb-1 scrollbar-hide sm:grid sm:grid-cols-5 sm:overflow-visible sm:pb-0",children:[e.jsxs("button",{onClick:()=>h("auto"),className:G("flex flex-col items-center gap-1 min-w-[4.5rem] sm:min-w-0 px-1.5 py-2 sm:px-2 sm:py-3 rounded-xl border-2 text-center transition-all",n.has("auto")?"border-primary bg-primary/5 text-primary":"border-border hover:border-primary/40 text-muted-foreground hover:text-foreground"),children:[e.jsx(ll,{className:"w-10 h-10 sm:w-14 sm:h-14"}),e.jsx("span",{className:"text-[10px] sm:text-[11px] font-medium leading-tight",children:"Auto"})]}),La.map(o=>e.jsxs("button",{onClick:()=>
6h(o.value),className:G("flex flex-col items-center gap-1 min-w-[4.5rem] sm:min-w-0 px-1.5 py-2 sm:px-2 sm:py-3 rounded-xl border-2 text-center transition-all",n.has(o.value)?"border-primary bg-primary/5 text-primary":"border-border hover:border-primary/40 text-muted-foreground hover:text-foreground"),children:[o.previewUrl?e.jsx("img",{src:K(o.previewUrl,{quality:60}),alt:o.label,className:"w-10 h-10 sm:w-14 sm:h-14 rounded-lg object-cover"}):e.jsx(ll,{className:"w-10 h-10 sm:w-14 sm:h-14"}),e.jsx("span",{className:"text-[10px] sm:text-[11px] font-medium leading-tight",children:o.label})]},o.value))]})]})}const jd=1,pl=6,gl=[{id:"minimal",label:"Minimal",hint:"clean, few props, whitespace"},{id:"botanical",label:"Botanical",hint:"dried flowers, eucalyptus leaves, greenery accents"},{id:"coffee-books",label:"Coffee & Books",hint:"coffee cup, open book pages"},{id:"textured",label:"Textured",hint:"linen fabric, kraft paper, washi tape"},{id:"soft-glam",label:"Soft Glam",hint:"silk ribbon, dried petals, soft fabric swatches"},{id:"cozy",label:"Cozy",hint:"knit blanket, candle, warm tones"},{id:"seasonal",label:"Seasonal",hint:"seasonal elements matching current time of year"}],yd=[{id:"excited",emoji:"🤩",label:"Excited",desc:'"OMG I love this!" energy',example:"Wide smile, bright eyes",recommended:!0},{id:"chill",emoji:"😌",label:"Chill",desc:"Everyday casual vibe",example:"Soft smile, relaxed gaze"},{id:"confident",emoji:"😎",label:"Confident",desc:'"I know what works" energy',example:"Subtle smile, direct eye contact"},{id:"surprised",emoji:"😲",label:"Surprised",desc:'"Wait, this actually works?!"',example:"Raised eyebrows, open mouth"},{id:"focused",emoji:"🧐",label:"Focused",desc:"Tutorial / demo mode",example:"Concentrated, friendly"}];function vd(n){var Br,ys,Ut;const{selectedProduct:l,scratchUpload:h,sourceType:o,isMultiProductMode:m,productQueue:S,userProducts:N,activeWorkflow:b,workflowConfig:v,variationStrategy:p,uiConfig:T,isFlatLay:k,isMirrorSelfie:V,isSelfieUgc:I,isInteriorDesign:B,selectedVariationIndices:P,setSelectedVariationIndices:ce,sceneFilterCategory:ee,setSceneFilterCategory:he,flatLayPhase:Ce,setFlatLayPhase:_e,selectedFlatLayProductIds:H,selectedAesthetics:pe,setSelectedAesthetics:J,stylingNotes:Be,setStylingNotes:z,flatLayPropStyle:ie,setFlatLayPropStyle:ke,mirrorSettingsPhase:$,ugcMood:ve,setUgcMood:Y,ugcOutfit:$e,setUgcOutfit:M,ugcInteractionPhrase:Re,productSlot:Ue,quality:ms,setQuality:ne,aspectRatio:$r,setAspectRatio:se,selectedAspectRatios:rr,setSelectedAspectRatios:jt,framing:Fe,setFraming:Ba,selectedFramings:Lr,setSelectedFramings:ar,productAngle:_s,setProductAngle:Mt,selectedBrandProfile:rt,selectedBrandProfileId:at,brandProfiles:ir,balance:He,creditCost:t,isFreeUser:yt,workflowImageCount:Ks,multiProductCount:$t,angleMultiplier:Lt,aspectRatioCount:it,framingCount:os,interiorType:we,isAdmin:Bt,isGeneratingPreviews:lr,openBuyModal:Q,handleGenerateClick:x,handleGenerateScenePreviews:Ra,setCurrentStep:ws,onFreeLimit:Rt}=n;return i.useEffect(()=>{(I||k)&&ne("high")},[I,k,ne]),e.jsxs("div",{className:"space-y-4",children:[!(V&&$==="final")&&!(k&&Ce==="details")&&e.jsx(re,{children:e.jsxs(le,{className:"p-5 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:o==="scratch"?"Uploaded Image":k&&H.size>1?`Selected Products (${H.size})`:m?`Selected Products (${S.length})`:"Selected Product"}),e.jsx(w,{variant:"link",size:"sm",onClick:()=>ws(o==="scratch"?"upload":"source"),children:"Change"})]}),k&&H.size>1?e.jsx("div",{className:"flex gap-2 overflow-x-auto pb-1",children:N.filter(C=>H.has(C.id)).map(C=>e.jsxs("div",{className:"flex-shrink-0 w-[72px]",children:[e.jsx("div",{className:"w-14 h-14 rounded-lg overflow-hidden border border-border mx-auto",children:e.jsx("img",{src:K(C.image_url||"/placeholder.svg",{quality:60}),alt:C.title,className:"w-full h-full object-cover"})}),e.jsx("p",{className:"text-[10px] text-muted-foreground text-center mt-1 truncate",children:C.title})]},C.id))}):m?e.jsx("div",{className:"flex gap-2 overflow-x-auto pb-1",children:S.map(C=>{var ue;return e.jsxs("div",{className:"flex-shrink-0 w-[72px]",children:[e.jsx("div",{className:"w-14 h-14 roun
6ded-lg overflow-hidden border border-border mx-auto",children:e.jsx("img",{src:K(((ue=C.images[0])==null?void 0:ue.url)||"/placeholder.svg",{quality:60}),alt:C.title,className:"w-full h-full object-cover"})}),e.jsx("p",{className:"text-[10px] text-muted-foreground text-center mt-1 truncate",children:C.title})]},C.id)})}):e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"w-16 h-16 rounded-lg overflow-hidden border border-border",children:e.jsx("img",{src:K(o==="scratch"?h==null?void 0:h.previewUrl:((Br=l==null?void 0:l.images[0])==null?void 0:Br.url)||"/placeholder.svg",{quality:60}),alt:"",className:"w-full h-full object-cover"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold",children:o==="scratch"?h==null?void 0:h.productInfo.title:l==null?void 0:l.title}),e.jsx("p",{className:"text-sm text-muted-foreground",children:o==="scratch"?h==null?void 0:h.productInfo.productType:`${l==null?void 0:l.vendor} • ${l==null?void 0:l.productType}`})]})]}),rt&&e.jsx("div",{className:"pt-2 border-t border-border",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(zr,{className:"w-4 h-4 text-primary"}),e.jsx("span",{className:"text-sm font-medium",children:rt.name}),e.jsx(de,{variant:"secondary",className:"text-[10px] capitalize",children:rt.tone})]}),e.jsx(w,{variant:"link",size:"sm",onClick:()=>ws("brand-profile"),children:"Change"})]})})]})}),!(V&&$==="final")&&!(k&&Ce==="details")&&e.jsx(re,{children:e.jsxs(le,{className:"p-5 space-y-4",children:[(p==null?void 0:p.type)==="scene"&&!k&&!B&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(de,{variant:"outline",className:"text-[10px]",children:(b==null?void 0:b.name)==="Mirror Selfie Set"?`${p.variations.length} Environments`:`${p.variations.length} Scenes`}),(b==null?void 0:b.name)==="Mirror Selfie Set"&&e.jsxs(de,{variant:"secondary",className:"text-[10px]",children:[e.jsx(wa,{className:"w-3 h-3 mr-1"}),"Mirror Selfie"]})]}),e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("h3",{className:"text-base font-semibold",children:k?"Select Your Surfaces":B?"Select Design Style":(p==null?void 0:p.type)==="scene"?"Select Your Scenes":"What You'll Get"}),Bt&&I&&e.jsx(Bn,{to:"/app/admin/ugc-bulk-upload",className:"text-[10px] underline text-muted-foreground hover:text-foreground",children:"Bulk upload previews"}),k&&e.jsxs(e.Fragment,{children:[e.jsxs(de,{variant:"secondary",className:"text-[10px]",children:[e.jsx(nl,{className:"w-3 h-3 mr-1"}),"Flat Lay"]}),e.jsxs(de,{variant:"outline",className:"text-[10px]",children:[p==null?void 0:p.variations.length," Surfaces"]})]}),B&&e.jsxs(e.Fragment,{children:[e.jsx(de,{variant:"secondary",className:"text-[10px]",children:we==="interior"?"Interior":"Exterior"}),e.jsxs(de,{variant:"outline",className:"text-[10px]",children:[p==null?void 0:p.variations.length," Styles"]})]})]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:k?"Choose surfaces for your flat lay — select at least 1":B?"Choose 1 design style to generate for your room":(p==null?void 0:p.type)==="scene"?"Pick at least 1 scene":(p==null?void 0:p.type)==="seasonal"?"Each image captures a different season":(p==null?void 0:p.type)==="multi-ratio"?"Images optimized for different platforms":(p==null?void 0:p.type)==="layout"?"Different layout compositions":(p==null?void 0:p.type)==="paired"?"Before and after comparison":(p==null?void 0:p.type)==="angle"?"Multiple angles and perspectives":(p==null?void 0:p.type)==="mood"?"Different mood and energy styles":(p==null?void 0:p.type)==="surface"?"Different surface and styling options":"Workflow-specific variations"}),(p==null?void 0:p.type)==="scene"&&e.jsx("p",{className:"text-xs text-muted-foreground/70 mt-1 hidden sm:block",children:"Products shown are reference examples only. Our VOVV Studio AI team will generate each scene with your selected product."})]}),!B&&P.size>0&&e.jsx(w,{variant:"ghost",size:"sm",className:"shrink-0 text-muted-foreground",onClick:()=>ce(new Set),children:"Deselect All"})]}),(p==null?void 0:p.type)==="scene"&&(()=>{if((b==null?void 0:b.slug)==="product-listing-set")return null;const C=B?p.variations.filter(ds=>!ds.scope||ds.scope===we):p.variations,ue=Array.from(new Set(C.map(ds=>
6ds.category).filter(Boolean)));if(ue.length<=1)return null;const ss=ds=>e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>{he("all")},className:G("px-3 py-1.5 rounded-full text-xs font-medium transition-colors whitespace-nowrap",ee==="all"?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground hover:bg-muted/80"),children:"All"}),ue.map(ts=>e.jsx("button",{onClick:()=>{he(ts)},className:G("px-3 py-1.5 rounded-full text-xs font-medium transition-colors whitespace-nowrap",ee===ts?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground hover:bg-muted/80"),children:ts},ts))]});return e.jsx("div",{className:"hidden sm:flex gap-1.5 overflow-x-auto pb-1 -mx-1 px-1 no-scrollbar flex-wrap",children:ss()})})(),(b==null?void 0:b.name)==="Mirror Selfie Set"&&e.jsxs(hs,{className:"border-primary/20 bg-primary/5",children:[e.jsx(wa,{className:"w-4 h-4 text-primary"}),e.jsxs(ps,{className:"space-y-1.5",children:[e.jsx("p",{className:"font-semibold text-sm",children:"Mirror Selfie Composition"}),e.jsxs("ul",{className:"text-xs text-muted-foreground space-y-1 list-disc list-inside",children:[e.jsx("li",{children:"Your model will appear holding a smartphone, capturing their reflection in a mirror"}),e.jsx("li",{children:"Each environment places your product in a different real-world mirror setting"}),e.jsx("li",{children:"Choose any aspect ratio in the next step — 4:5 portrait recommended for Instagram"})]})]})]}),e.jsx("div",{className:G("grid gap-3",V||I?"grid-cols-3 sm:grid-cols-4 lg:grid-cols-5":"grid-cols-2 sm:grid-cols-3 lg:grid-cols-4"),children:p==null?void 0:p.variations.map((C,ue)=>({v:C,i:ue})).filter(({v:C})=>!(B&&C.scope&&C.scope!==we||ee!=="all"&&C.category&&C.category!==ee)).map(({v:C,i:ue})=>{const ss=P.has(ue),ds=!!C.preview_url;return e.jsx("div",{children:e.jsx("div",{onClick:()=>{ce(ts=>{const Je=new Set(ts);if(Je.has(ue))Je.delete(ue);else{if(yt&&Je.size>=jd)return Rt?Rt("scene_limit"):A.error("Free plan allows 1 scene per generation. Upgrade to unlock more."),ts;if(!yt&&k&&Je.size>=pl)return A.error(`Maximum ${pl} surfaces per generation.`),ts;Je.add(ue)}return Je})},className:G("relative rounded-xl overflow-hidden cursor-pointer transition-all duration-200 group border-2",ss?"border-primary ring-2 ring-primary/20 scale-[1.02]":"border-border hover:border-primary/40 hover:scale-[1.02]"),children:e.jsxs("div",{className:G("relative",V||I?"aspect-[9/16]":"aspect-square"),children:[ds?e.jsx("img",{src:K(C.preview_url,{quality:60}),alt:C.label,className:"w-full h-full object-cover",loading:"lazy"}):C.label==="AI Creative Pick"?e.jsxs("div",{className:"w-full h-full flex flex-col items-center justify-center bg-gradient-to-br from-slate-800 via-slate-700 to-slate-500 relative overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 bg-[linear-gradient(110deg,transparent_25%,rgba(255,255,255,0.3)_50%,transparent_75%)] bg-[length:250%_100%] animate-shimmer"}),e.jsx(Vs,{className:"w-8 h-8 text-white drop-shadow-lg relative z-10"}),e.jsx("span",{className:"text-[10px] font-bold text-white/90 mt-1.5 relative z-10 tracking-wide",children:"AI PICKS"})]}):e.jsx("div",{className:G("w-full h-full flex items-center justify-center",ue%8===0?"bg-gradient-to-br from-gray-100 to-white":ue%8===1?"bg-gradient-to-br from-gray-200 to-gray-100":ue%8===2?"bg-gradient-to-br from-amber-100 to-orange-50":ue%8===3?"bg-gradient-to-br from-pink-50 to-purple-50":ue%8===4?"bg-gradient-to-br from-green-100 to-emerald-50":ue%8===5?"bg-gradient-to-br from-blue-100 to-sky-50":ue%8===6?"bg-gradient-to-br from-yellow-100 to-amber-50":"bg-gradient-to-br from-gray-700 to-gray-900"),children:e.jsx(Pr,{className:G("w-8 h-8",ue%8===7?"text-gray-400":"text-muted-foreground/40")})}),e.jsxs("div",{className:"absolute inset-x-0 bottom-0 bg-gradient-to-t from-black/70 via-black/30 to-transparent p-2 pt-6",children:[e.jsx("p",{className:"text-[11px] font-semibold text-white leading-tight",children:C.label}),C.category&&e.jsx("span",{className:"text-[9px] text-white/60 font-medium",children:C.category})]}),ss&&e.jsx("div",{className:"absolute top-1.5 right-1.5 w-5 h-5 rounded-full bg-primary flex items-center justify-center shadow-md",children:e.jsx(Is,{className:"w-3 h-3 text-primary-foreground"})})]})})},ue)})}),e.jsx(Na,{category:"scene",title:"Missing a scene? Tell us and we'll add it."}),e.jsxs("div",{className:"flex items-start gap-2 px-1",children:[e.jsx(Aa,{className:"w-3.5 h-3.5 text-muted-foreground mt-0.5 shrink-0"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:B?"Each style will generate a uniquely staged ver
6sion of your room while preserving its architecture.":"Products shown are for demonstration only — your product will be placed in each selected scene."})]}),e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[B?P.size===0?e.jsx("p",{className:"text-xs text-muted-foreground",children:"Tap a style to select it"}):e.jsxs("p",{className:"text-xs text-muted-foreground",children:[P.size," style",P.size!==1?"s":""," selected"]}):e.jsx("p",{className:"text-xs text-muted-foreground",children:P.size===0?e.jsx("span",{className:"text-destructive font-medium",children:"Select at least 1 scene to continue"}):e.jsxs(e.Fragment,{children:[P.size," scene",P.size!==1?"s":""," selected"]})}),yt&&e.jsxs("div",{className:"mt-2 flex items-center gap-2 rounded-lg border border-primary/20 bg-primary/5 px-4 py-2.5",children:[e.jsx(oo,{className:"w-3.5 h-3.5 text-primary flex-shrink-0"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Free plan: 1 ",B?"style":"scene"," per generation."," ",e.jsx("button",{onClick:Q,className:"text-primary font-semibold hover:underline",children:"Upgrade"})," ","to unlock up to 3."]})]})]})})]})}),V&&$==="scenes"&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx(w,{variant:"outline",onClick:()=>ws(o==="scratch"?"upload":"product"),children:"Back"}),e.jsx(w,{disabled:P.size===0,onClick:()=>ws("model"),children:"Continue to Model"})]}),k&&Ce==="surfaces"&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx(w,{variant:"outline",onClick:()=>ws(ir.length>0?"brand-profile":"product"),children:"Back"}),e.jsx(w,{disabled:P.size===0,onClick:()=>_e("details"),children:"Continue to Details"})]}),k&&Ce==="details"&&e.jsxs(e.Fragment,{children:[e.jsx(re,{children:e.jsxs(le,{className:"p-5 space-y-4",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(nl,{className:"w-5 h-5 text-primary"}),"Composition Style"]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Choose what appears alongside your products"})]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[{key:"clean",label:"Products Only",desc:"Clean layout with just your products, no extra items"},{key:"decorated",label:"Add Styling Props",desc:"Include decorative elements (leaves, fabric, abstract shapes) around your products"}].map(C=>e.jsxs("button",{onClick:()=>{ke(C.key),C.key==="clean"&&(J([]),z(""))},className:G("p-4 rounded-xl border-2 text-left transition-all",ie===C.key?"border-primary bg-primary/5 ring-1 ring-primary/20":"border-border hover:border-primary/40"),children:[e.jsx("p",{className:"text-sm font-semibold",children:C.label}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:C.desc})]},C.key))})]})}),ie==="decorated"&&e.jsx(re,{children:e.jsxs(le,{className:"p-5 space-y-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-semibold",children:"Styling & Aesthetics"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Add decorative props and mood to your flat lay"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(oe,{children:"Quick Aesthetics"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:gl.map(C=>{const ue=pe.includes(C.id);return e.jsx("button",{onClick:()=>J(ss=>ue?ss.filter(ds=>ds!==C.id):[...ss,C.id]),className:G("px-3 py-1.5 rounded-full text-xs font-medium transition-all border",ue?"border-primary bg-primary text-primary-foreground":"border-border bg-muted text-muted-foreground hover:border-primary/40"),title:C.hint,children:C.label},C.id)})}),pe.length>0&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Props: ",pe.map(C=>{var ue;return(ue=gl.find(ss=>ss.id===C))==null?void 0:ue.hint}).filter(Boolean).join(", ")]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(oe,{children:"Styling Notes (optional)"}),e.jsx($a,{placeholder:"e.g. eucalyptus leaves, silk ribbon, warm tones...",value:Be,onChange:C=>
6z(C.target.value),className:"min-h-[60px]"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Describe any specific decorative props, colors, or mood (no commercial products)"})]})]})}),e.jsx(re,{children:e.jsxs(le,{className:"p-5 space-y-4",children:[e.jsx("h3",{className:"text-base font-semibold",children:"Generation Settings"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(oe,{children:"Quality"}),k?e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"High — Best quality"}):e.jsxs(Ze,{value:ms,onValueChange:C=>ne(C),children:[e.jsx(Xe,{children:e.jsx(We,{})}),e.jsxs(es,{children:[e.jsx(D,{value:"standard",children:"Standard — Fast generation"}),e.jsx(D,{value:"high",children:"High — Best quality"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(oe,{children:"Aspect Ratio"}),e.jsx(Sa,{value:rr,onChange:jt})]})]})]})}),e.jsxs("div",{className:G("p-4 rounded-lg border flex items-center justify-between",He>=t?"border-border bg-muted/30":"border-destructive/30 bg-destructive/5"),children:[e.jsxs("div",{children:[e.jsxs("p",{className:"text-sm font-semibold",children:["Total: ",t," credits"]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[P.size," surface",P.size!==1?"s":""," ","× 6 credits",H.size>1&&` + ${(H.size-1)*2*P.size} extra (${H.size} products)`]})]}),He>=t?e.jsxs("p",{className:"text-sm text-muted-foreground",children:[He," credits available"]}):e.jsxs("button",{onClick:Q,className:"flex items-center gap-1 text-sm text-destructive font-semibold hover:underline",children:[e.jsx(bt,{className:"w-3.5 h-3.5"}),He," credits — need ",t,". Top up"]})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(w,{variant:"outline",onClick:()=>_e("surfaces"),children:"Back to Surfaces"}),e.jsx(w,{onClick:He>=t?x:Q,disabled:P.size===0,className:He<t&&P.size>0?"bg-primary text-primary-foreground hover:bg-primary/90":"",children:He>=t?`Generate ${P.size} Flat Lay Images`:"Buy Credits"})]})]}),I&&e.jsx(re,{children:e.jsxs(le,{className:"p-5 space-y-4",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(Vs,{className:"w-5 h-5 text-primary"}),"Creator Mood"]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Set the expression and energy for your UGC content"})]}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-3",children:yd.map(C=>e.jsxs("button",{onClick:()=>Y(C.id),className:G("relative p-4 rounded-xl border-2 text-left transition-all flex flex-col gap-1",ve===C.id?"border-primary bg-primary/5 ring-1 ring-primary/20":"border-border hover:border-primary/40"),children:[C.recommended&&e.jsx("span",{className:"absolute -top-2.5 right-3 px-2 py-0.5 text-[10px] font-semibold uppercase tracking-wider bg-primary text-primary-foreground rounded-full",children:"Popular"}),e.jsx("span",{className:"text-2xl",children:C.emoji}),e.jsx("p",{className:"text-sm font-semibold",children:C.label}),e.jsx("p",{className:"text-[11px] text-muted-foreground leading-tight",children:C.desc}),e.jsx("p",{className:"text-[10px] text-muted-foreground/70 italic",children:C.example})]},C.id))})]})}),I&&(()=>{const C=Ar(Re),ue=Ue||"other",ss=C?Cl:Sl,ds=$e||"auto",ts={top:"top",bottom:"bottoms",shoes:"shoes",dress:"piece",bag:"bag",jewellery:"piece",eyewear:"eyewear",other:"product"};return e.jsx(re,{children:e.jsxs(le,{className:"p-5 space-y-4",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(Vs,{className:"w-5 h-5 text-primary"}),C?"Pair Outfit":"Outfit"]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:C?`Style the rest of the look around the ${ts[ue]} you're wearing — Auto Pair lets the AI pick neutral complements.`:"Pick what your creator wears — Auto picks a smart default per scene."})]}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:ss.map(Je=>{const W=ds===Je.id;return e.jsxs("button",{onClick:()=>M(Je.id),className:G("relative p-4 rounded-xl border-2 text-left transition-all flex flex-col gap-1",W?"border-primary bg-primary/5 ring-1 ring-primary/20":"border-border hover:border-primary/40"),children:[Je.recommended&&e.jsx("span",{className:"absolute -top-2.5 right-3 px-2 py-0.5 text-[10px] font-semibold uppercase tracking-wider bg-primary text-primary-foreground rounded-full",children:"Popular"}),e.jsx("p",{className:"text-sm font-semibold",children:Je.label}),e.jsx("p",{className:"text-[11px] text-muted-foreground leading-tight",children:Je.vibe})]},Je.id)})})]})})})(),I&&e.jsx(re,{children:e.jsx(le,{className:"p-5",children:e.jsx(Il,{selectedFramings:Lr,onSelectedFramingsChange:ar})})}),(p==null?void 0:p.type)==="scene"&&!V&&!k&&!I&&!B&&e.jsx(re,{children:e.jsxs(le,{className:"p-5 space-y-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-semibold",children:"Product Angles"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Choose which angles to generate for each scene"})]}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:[{key:"front",label:"Front Only",desc:"1 image per scene",multiplier:"×1"},{key:"front-side",label:"Front + Side",desc:"2 images per scene",multiplier:"×2"},{key:"front-back",label:"Front + Back",desc:"2 images per scene",multiplier:"×2"},{key:"all",label:"All Angles",desc:"3 images per scene",multiplier:"×3"}].map(C=>e.jsxs("button",{onClick:()=>Mt(C.key),className:G("p-3 rounded-xl border-2 text-left transition-all",_s===C.key?"border-primary bg-primary/5 ring-1 ring-primary/20":"border-border hover:border-primary/40"),children:[e.jsx("p",{className:"text-sm font-semibold",children:C.label}),e.jsx("p",{className:"text-xs text-muted-foreground",children:C.desc}),e.jsx(de,{variant:"secondary",className:"mt-1.5 text-[10px]",children:C.multiplier})]},C.key))})]})}),!(V&&$==="scenes")&&!k&&e.jsxs(e.Fragment,{children:[e.jsx(re,{children:e.jsxs(le,{className:"p-5 space-y-4",children:[e.jsx("h3",{className:"text-base font-semibold",children:"Generation Settings"}),e.jsxs("div",{className:G("grid gap-4",I?"grid-cols-1":"grid-cols-1 md:grid-cols-2"),children:[!I&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(oe,{children:"Quality"}),e.jsxs(Ze,{value:ms,onValueChange:C=>ne(C),children:[e.jsx(Xe,{children:e.jsx(We,{})}),e.jsxs(es,{children:[e.jsx(D,{value:"standard",children:"Standard — Fast generation"}),e.jsx(D,{value:"high",children:"High — Best quality"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(oe,{children:"Aspect Ratio"}),B?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(de,{variant:"secondary",children:"Original"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Matches uploaded photo"})]}
6):T!=null&&T.lock_aspect_ratio?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(de,{variant:"secondary",children:((Ut=(ys=v==null?void 0:v.fixed_settings)==null?void 0:ys.aspect_ratios)==null?void 0:Ut[0])||$r}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Locked by Visual Type"})]}):(p==null?void 0:p.type)==="multi-ratio"?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(de,{variant:"secondary",children:"Multiple"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Each variation uses its own ratio"})]}):e.jsx(Sa,{value:rr,onChange:jt})]})]})]})}),e.jsx("div",{className:G("p-4 rounded-lg border",He>=t?"border-border bg-muted/30":"border-destructive/30 bg-destructive/5"),children:e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-2",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"text-sm font-semibold",children:[Ks*$t," image",Ks*$t!==1?"s":""," · ",t," credits"]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[m?`${S.length} products × `:"",n.workflowModelCount>1?`${n.workflowModelCount} models × `:"",P.size," ",B?"style":"scene",P.size!==1?"s":"",Lt>1?` × ${Lt} angles`:"",it>1?` × ${it} sizes`:"",os>1?` × ${os} framings`:""," ","× 6 credits"]})]}),He>=t?e.jsxs("p",{className:"text-sm text-muted-foreground whitespace-nowrap",children:[He," credits available"]}):e.jsxs("button",{onClick:Q,className:"flex items-center gap-1 text-sm text-destructive font-semibold hover:underline whitespace-nowrap",children:[e.jsx(bt,{className:"w-3.5 h-3.5"}),He," / ",t," credits. Top up"]})]})}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(w,{variant:"outline",onClick:()=>{ws(V?"model":B?"upload":ir.length>0?"brand-profile":o==="scratch"?"upload":"product")},children:"Back"}),e.jsx(w,{onClick:He>=t?x:Q,disabled:P.size===0||!B&&rr.size===0,className:He<t&&P.size>0?"bg-primary text-primary-foreground hover:bg-primary/90":"",children:He>=t?"Generate":"Buy Credits"})]})]})]})}function wd({selectedProduct:n,scratchUpload:l,selectedModel:h,selectedModels:o,selectedModelMap:m,selectedPose:S,selectedPoses:N,selectedPoseMap:b,creditCost:v,imageCount:p,setImageCount:T,quality:k,setQuality:V,framing:I,setFraming:B,selectedFramings:P,setSelectedFramings:ce,aspectRatio:ee,setAspectRatio:he,selectedAspectRatios:Ce,setSelectedAspectRatios:_e,balance:H,isFreeUser:pe,isMultiProductMode:J,multiProductCount:Be,productQueue:z,tryOnSceneCount:ie,openBuyModal:ke,handleGenerateClick:$,setCurrentStep:ve}){const Y=Array.from(N).map(ne=>b.get(ne)).filter(Boolean),$e=m?Array.from(m.values()):h?[h]:[],M=Math.max(1,$e.length),Re=Math.max(1,Ce.size),Ue=P.has("auto")?1:Math.max(1,P.size),ms=parseInt(p)*ie*M*Be*Re*Ue;return e.jsxs("div",{className:"space-y-4",children:[e.jsx(Ca,{product:n,scratchUpload:l,model:h,models:$e,pose:S,poses:Y,creditCost:v,selectedGender:h==null?void 0:h.gender,products:J?z:void 0}),e.jsx(re,{children:e.jsxs(le,{className:"p-5 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-sm text-muted-foreground",children:["Selected Model",$e.length>1?"s":""," & ",N.size>1?"Scenes":"Scene"]}),e.jsx(w,{variant:"link",size:"sm",onClick:()=>ve("model"),children:"Change"})]}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-[10px] uppercase tracking-wider text-muted-foreground mb-2",children:["Model",$e.length>1?`s (${$e.length})`:""]}),e.jsx("div",{className:"grid grid-cols-3 sm:grid-cols-4 md:grid-cols-5 gap-2",children:$e.map(ne=>e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("div",{className:"w-8 h-8 rounded-full overflow-hidden border-2 border-primary/20 flex-shrink-0",children:e.jsx("img",{src:K(ne.previewUrl,{quality:60}),alt:"",className:"w-full h-full object-cover"})}),e.jsx("p",{className:"text-xs font-medium truncate",children:ne.name})]},ne.modelId))})]}),e.jsx(tt,{}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-[10px] uppercase tracking-wider text-muted-foreground mb-2",children:["Scene",N.size>1?`s (${N.size})`:""]}),e.jsx("div",{className:"grid grid-cols-3 sm:grid-cols-4 md:grid-cols-5 ga
6p-2",children:Y.map(ne=>e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg overflow-hidden border-2 border-primary/20 flex-shrink-0",children:e.jsx("img",{src:K(ne.previewUrl,{quality:60}),alt:"",className:"w-full h-full object-cover"})}),e.jsx("p",{className:"text-xs font-medium truncate",children:ne.name})]},ne.poseId))})]})]})}),e.jsx(re,{children:e.jsxs(le,{className:"p-5 space-y-4",children:[e.jsx("h3",{className:"text-base font-semibold",children:"Generation Settings"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(oe,{children:"Number of Images per Scene"}),e.jsxs(Ze,{value:p,onValueChange:ne=>T(ne),children:[e.jsx(Xe,{children:e.jsx(We,{})}),e.jsxs(es,{children:[e.jsx(D,{value:"1",children:"1 image"}),!pe&&e.jsx(D,{value:"2",children:"2 images"}),!pe&&e.jsx(D,{value:"3",children:"3 images"}),!pe&&e.jsx(D,{value:"4",children:"4 images"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(oe,{children:"Quality"}),e.jsxs(Ze,{value:k,onValueChange:ne=>V(ne),children:[e.jsx(Xe,{children:e.jsx(We,{})}),e.jsxs(es,{children:[e.jsx(D,{value:"standard",children:"Standard — Fast generation, good quality"}),e.jsx(D,{value:"high",children:"High (Pro Model) — Best quality, ~30-60s per image"})]})]})]})]}),e.jsx(Il,{selectedFramings:P,onSelectedFramingsChange:ce}),e.jsx(Sa,{value:Ce,onChange:_e})]})}),e.jsx("div",{className:G("p-4 rounded-lg border",H>=v?"border-border bg-muted/30":"border-destructive/30 bg-destructive/5"),children:e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-2",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"text-sm font-semibold",children:[ms," image",ms!==1?"s":""," · ",v," credits"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:(()=>{const ne=[];return ne.push(`${parseInt(p)} image${parseInt(p)>1?"s":""}`),M>1&&ne.push(`${M} models`),N.size>1&&ne.push(`${N.size} scenes`),Re>1&&ne.push(`${Re} sizes`),Ue>1&&ne.push(`${Ue} framings`),J&&ne.push(`${Be} products`),ne.push("6 credits each"),ne.join(" × ")})()})]}),H>=v?e.jsxs("p",{className:"text-sm text-muted-foreground whitespace-nowrap",children:[H," credits available"]}):e.jsxs("button",{onClick:ke,className:"flex items-center gap-1 text-sm text-destructive font-semibold hover:underline whitespace-nowrap",children:[e.jsx(bt,{className:"w-3.5 h-3.5"}),H," / ",v," credits. Top up"]})]})}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(w,{variant:"outline",onClick:()=>ve("pose"),children:"Back"}),e.jsx(w,{onClick:H>=v?$:ke,disabled:Ce.size===0||P.size===0,className:H<v?"bg-primary text-primary-foreground hover:bg-primary/90":"",children:H>=v?"Generate":"Buy Credits"})]})]})}const Mr=n=>K(bl(`team/${n}`),{quality:60}),Nd=Mr("avatar-sophia.jpg"),Sd=Mr("avatar-zara.jpg"),Cd=Mr("avatar-kenji.jpg"),kd=Mr("avatar-luna.jpg"),Id=1,Ir={id:"sample_listing_ring",title:"Diamond Engagement Ring",vendor:"Sample",productType:"Jewelry",tags:["ring","diamond","jewelry","engagement"],description:"Pavé-set diamond engagement ring in white gold with signature ruby accent.",images:[{id:"img_sample_listing",url:"/images/samples/sample-ring.png"}],status:"active",createdAt:"2024-01-01T00:00:00Z",updatedAt:"2024-01-01T00:00:00Z"},fa={id:"sample_tryon_crop_top",title:"Ribbed Crop Top",vendor:"Sample",productType:"Tops",tags:["crop-top","ribbed","basics","white"],description:"Classic ribbed crop top in white. Soft stretch fabric with a clean, minimal silhouette.",images:[{id:"img_sample_tryon",url:"/images/samples/sample-crop-top.png"}],status:"active",createdAt:"2024-01-01T00:00:00Z",updatedAt:"2024-01-01T00:00:00Z"},ba={id:"sample_ugc_ice_roller",title:"Ice Roller",vendor:"Sample",productType:"Skincare Tools",tags:["ice-roller","skincare","beauty"],description:"Cooling ice roller for face and body. Soothes skin and reduces puffiness.",images:[{id:"img_sample_ugc",url:"/images/samples/sample-ice-roller.png"}],status:"active",createdAt:"2024-01-01T00:00:00Z",updatedAt:"2024-01-01T00:00:00Z"}
6,_r={id:"sample_mirror_sweater",title:"Ribbed Knit Sweater",vendor:"Sample",productType:"Knitwear",tags:["sweater","knit","beige","cozy"],description:"Chunky ribbed knit sweater in warm beige. Relaxed cropped fit.",images:[{id:"img_sample_mirror",url:"/images/samples/sample-sweater.png"}],status:"active",createdAt:"2024-01-01T00:00:00Z",updatedAt:"2024-01-01T00:00:00Z"};async function ja(n){var l;if(!n)return null;if(n.startsWith("/"))try{const{data:h}=await Me.auth.getUser(),o=(l=h.user)==null?void 0:l.id;if(!o)return n;const S=await(await fetch(n)).blob(),N=await new Promise(ee=>{const he=new FileReader;he.onloadend=()=>ee(he.result),he.readAsDataURL(S)}),b=n.split(".").pop()||"png",v=`image/${b==="jpg"?"jpeg":b}`,p=`${o}/sample-products/${Date.now()}-${Math.random().toString(36).substring(2,8)}.${b}`,T=atob(N.split(",")[1]),k=new ArrayBuffer(T.length),V=new Uint8Array(k);for(let ee=0;ee<T.length;ee++)V[ee]=T.charCodeAt(ee);const I=new File([k],p,{type:v}),{data:B,error:P}=await Me.storage.from("generation-inputs").upload(p,I,{contentType:v,upsert:!1});if(P)throw P;const{data:ce}=Me.storage.from("generation-inputs").getPublicUrl(B.path);return ce.publicUrl}catch(h){return console.error("[resolveProductImageUrl] Failed to upload sample image:",h),n}return n}const _d=[{id:"minimal",label:"Minimal",hint:"clean, few props, whitespace"},{id:"botanical",label:"Botanical",hint:"dried flowers, eucalyptus leaves, greenery accents"},{id:"coffee-books",label:"Coffee & Books",hint:"coffee cup, open book pages"},{id:"textured",label:"Textured",hint:"linen fabric, kraft paper, washi tape"},{id:"soft-glam",label:"Soft Glam",hint:"silk ribbon, dried petals, soft fabric swatches"},{id:"cozy",label:"Cozy",hint:"knit blanket, candle, warm tones"},{id:"seasonal",label:"Seasonal",hint:"seasonal elements matching current time of year"}],ya={beauty:[{id:"apply",label:"Applying it",description:"Putting it on skin / face",phrase:"applying the product to their skin and showing the texture or finish",emoji:"💆"},{id:"near-face",label:"Holding near face",description:"Bottle/tube up by the cheek",phrase:"holding the product up close to their face so the packaging is clearly visible next to their skin",emoji:"🤳"},{id:"texture",label:"Showing the texture",description:"On the back of the hand",phrase:"showing the product texture or shade on the back of their hand toward the camera",emoji:"🖐️"},{id:"packaging",label:"Showing the packaging",description:"Bottle / box hero shot",phrase:"holding the product packaging up to the camera to show the label and design",emoji:"📦"}],fragrance:[{id:"spray",label:"Spraying on wrist/neck",description:"Mid-spritz moment",phrase:"spraying the fragrance on their wrist or neck as if just applied",emoji:"💨"},{id:"bottle",label:"Holding the bottle",description:"Near collarbone / chest",phrase:"holding the fragrance bottle elegantly near their neck or collarbone",emoji:"🍾"},{id:"packaging",label:"Showing the packaging",description:"Box + bottle to camera",phrase:"holding the bottle and packaging up to the camera to show the design",emoji:"📦"}],haircare:[{id:"hair",label:"Running through hair",description:"Product going through strands",phrase:"running the product through their hair naturally",emoji:"💇"},{id:"near-hair",label:"Holding near hair",description:"Bottle next to a strand",phrase:"holding the product next to a strand of their hair so both are clearly visible",emoji:"🧴"},{id:"bottle",label:"Showing the bottle",description:"Label to camera",phrase:"holding the bottle up to the camera to show the label clearly",emoji:"📦"}],garments:[{id:"wear",label:"Wearing it",description:"On-body, natural outfit",phrase:"wearing the item naturally as part of their outfit",emoji:"👕"},{id:"hold-up",label:"Holding it up",description:"Showing it to the camera",phrase:"holding the garment up to the camera so it is fully visible",emoji:"🙌"},{id:"styling",label:"Styling it",description:"Adjusting / smoothing it",phrase:"styling the garment on themselves — adjusting the collar, sleeves or fit",emoji:"✨"}],shoes:[{id:"wear",label:"Wearing on feet",description:"Showing them on",phrase:"showing the shoes on their feet, casually angled to the camera",emoji:"👟"},{id:"hold-up",label:"Holding them up",description:"Lifted next to face",phrase:"holding the shoes up next to their face excitedly",emoji:"🙌"},{id:"detail",label:"Showing the sole/detail",description:"Close-up of detail",phrase:"tilting the shoes to show the sole, side profile or material detail",emoji:"🔍"}],jewellery:[{id:"wear",label:"Wearing it",description:"On finger / wrist / neck",phrase:"wearing the jewellery piece and casually showing it off (on finger, wrist, neck or ear)",emoji:"💍"},{id:"hold-up",label:"Holding it up to camera",description:"Pinched between fingers",phrase:"holding the jewellery piece up to the camera between their fingers so the detail is clearly visible",emoji:"✨"},{id:"detail",label:"Showing the detail",description:"Close-up shot",phrase:"showing a close-up of the jewellery on themselves, focused on the craftsmanship",emoji:"🔍"}],bags:[{id:"carry",label:"Wearing/carrying it",description:"On shoulder / in hand",phrase:"wearing or carrying the bag naturally on their shoulder or in hand",emoji:"👜"},{id:"hold-up",label:"Holding it up",description:"Lifted to camera",phrase:"holding the bag up to the camera so the full silhouette is visible",emoji:"🙌"},{id:"inside",label:"Showing inside / detail",description:"Open + interior view",phrase:"opening the bag to show the interior or a hardware detail to the camera",emoji:"🔍"}],food:[{id:"taste",label:"Tasting / sipping",description:"Mid-bite or sip",phrase:"tasting or sipping the product naturally toward the camera",emoji:"😋"},{id:"hold",label:"Holding the package",description:"Package to camera",phrase:"holding the food or drink package up to the camera so the label is clearly visible",emoji:"🥤"},{id:"label",label:"Showing the label",description:"Front of the package",phrase:"angling the package so the label and branding face the camera directly",emoji:"🏷️"}],supplements:[{id:"bottle",label:"Holding the bottle",description:"Hero in-hand shot",phrase:"holding the supplement bottle naturally in front of them",emoji:"💊"},{id:"pour",label:"Pouring into hand",description:"Capsules in palm",phrase:"pouring the capsules or powder into their hand to show the dose",emoji:"🥄"},{id:"label",label:"Showing the label",description:"Bottle label to camera",phrase:"tilting the bottle so the label and ingredients face the camera",emoji:"🏷️"}],tech:[{id:"use",label:"Using / demonstrating",description:"Showing it in action",phrase:"using or demonstrating the device naturally as if reviewing it",emoji:"📱"},{id:"hold-up",label:"Holding it up",description:"Lifted to camera",phrase:"holding the device up to the camera so the design is clearly visible",emoji:"🙌"},{id:"feature",label:"Showing the screen/feature",description:"Close-up of feature",phrase:"pointing out a specific feature, screen or detail of the device to the camera",emoji:"🔍"}],home:[{id:"space",label:"Showing it in their space",description:"In context at home",phrase:"casually showing the item in their home next to where they actually use it",emoji:"🏠"},{id:"point",label:"Pointing it out",description:"Look-at-this energy",phrase:'pointing at the item with a "look at this" expression',emoji:"👉"},{id:"hold",label:"Holding/placing it",description:"Placing it down",phrase:"holding or gently placing the item, showing its size and finish",emoji:"🤲"}],default:[{id:"hold",label:"Holding it",description:"Naturally near chest/face",phrase:"holding the product naturally near their face or chest",emoji:"🤲"},{id:"show",label:"Showing it to camera",description:"Lifted to camera",phrase:"holding the product up to the camera so it is fully visible",emoji:"🙌"},{id:"point",label:"Pointing it out",description:"Look-at-this energy",phrase:'pointing at the product with a "look at this" expression',emoji:"👉"}]};function Td(n,l){const h=(n||"").toLowerCase(),o=(l||"").toLowerCase(),m=`${h} ${o}`;return/fragrance|perfume|cologne|eau de|parfum/.test(m)?"fragrance":/haircare|shampoo|conditioner|hair/.test(m)?"hair
6care":/beauty|skincare|makeup|lipstick|serum|cream|cosmetic|mascara|foundation|lotion/.test(m)?"beauty":/sneaker|boot|heel|shoe|footwear|loafer|sandal/.test(m)?"shoes":/jewell?ery|necklace|earring|bracelet|ring|watch|eyewear|sunglass|glasses/.test(m)?"jewellery":/bag|backpack|wallet|cardholder|belt|scarf|tote|clutch|purse/.test(m)?"bags":/food|snack|chocolate|cereal|granola|candy|cookie|beverage|drink|coffee|tea|juice|wine|beer|kombucha|water|smoothie/.test(m)?"food":/supplement|vitamin|capsule|protein|collagen|wellness|probiotic/.test(m)?"supplements":/tech|device|phone|laptop|headphone|earbuds|speaker|gadget|charger|tablet|keyboard/.test(m)?"tech":/furniture|home-decor|home decor|candle|vase|lamp|pillow|decor|interior/.test(m)?"home":/garment|apparel|clothing|dress|hoodie|shirt|jeans|jacket|activewear|swimwear|lingerie|kidswear|skirt|pants|coat|top|sweater/.test(m)?"garments":"default"}function Bc(){var Vi,Ki,Hi,Ji,Qi,Yi,Zi,Xi;const n=Rn(),{user:l}=xl(),{filterVisible:h}=Fo(),{asPoses:o}=Eo(),{sortScenes:m,applyCategoryOverrides:S,deriveCategoryOrder:N}=qo(),{asProfiles:b}=Bo(),{asProfiles:v}=Ro(),{sortModels:p,applyOverrides:T,applyNameOverrides:k,filterHidden:V}=Uo(),{workflowSlug:I}=Un(),[B]=Fn(),P=B.get("workflow"),ce=B.get("template"),ee=B.get("model"),he=B.get("scene"),Ce=B.get("modelImage"),_e=B.get("sceneImage"),[H,pe]=i.useState(ee||he?{modelName:ee||void 0,sceneName:he||void 0,modelImageUrl:Ce||void 0,sceneImageUrl:_e||void 0}:null),{balance:J,isEmpty:Be,openBuyModal:z,deductCredits:ie,calculateCost:ke,setBalanceFromServer:$,refreshBalance:ve,plan:Y}=On(),{enqueue:$e,activeJob:M,isProcessing:Re,isEnqueuing:Ue,reset:ms,cancel:ne}=No({jobTypes:["workflow","tryon"],onGenerationFailed:(s,r,a)=>{if(li.current.size>0)return;const c={timeout:"Generation timed out. Your credits have been refunded.",rate_limit:"Too many generations at once. Please wait and try again.",generic:"Generation failed. Your credits have been refunded — try again."};A.error(c[a]||c.generic),x("settings"),ve(),ms()}}),{startBatch:$r,batchState:se,isBatching:rr,resetBatch:jt}=Oo({onCreditRefresh:ve}),Fe=Y==="free",{isAdmin:Ba}=Dn(),[Lr,ar]=i.useState(!1),_s=wo(),{data:Mt}=zt({queryKey:["profile-categories",l==null?void 0:l.id],queryFn:async()=>{if(!(l!=null&&l.id))return null;const{data:s}=await Me.from("profiles").select("product_categories").eq("user_id",l.id).maybeSingle();return s},enabled:!!(l!=null&&l.id)&&Fe,staleTime:1/0}),rt=jo(Mt==null?void 0:Mt.product_categories),at=i.useMemo(()=>{const s=new Map;for(const r of k(T(Gn)))s.set(r.modelId,r);for(const r of b)s.set(r.modelId,r);for(const r of v)s.set(r.modelId,r);return p(V([...s.values()]))},[b,v,p,T,k,V]),ir=async()=>{if(yt){ar(!0);try{const{data:s,error:r}=await Me.functions.invoke("generate-scene-previews",{body:{workflow_id:yt,force_regenerate:!0}});if(r)throw r;A.success("Scene previews generated! Refreshing..."),window.location.reload()}catch(s){A.error("Failed to generate scene previews"),console.error(s)}finally{ar(!1)}}},He=I||P,{data:t}=zt({queryKey:["workflow",He],queryFn:async()=>{if(!He)return null;const s=I?Me.from("workflows").select("*").eq("slug",I).single():Me.from("workflows").select("*").eq("id",P).single(),{data:r,error:a}=await s;return a?null:r},enabled:!!He}),yt=(t==null?void 0:t.id)??P;i.useEffect(()=>{var s;if(t!=null&&t.generation_config){const r=t.generation_config;((s=r==null?void 0:r.variation_strategy)==null?void 0:s.type)==="angle"&&n("/app/perspectives",{replace:!0})}},[t,n]);const Ks=B.get("product"),$t=i.useRef(!1),Lt=i.useRef(!1),it=i.useCallback(s=>{Lt.current||!(l!=null&&l.id)||!s.jobId||(Vn()&&console.log("[GTM DEBUG first_generation_started]",{flow:"generate",hasUser:!0,userId:l.id,jobId:s.jobId,isError:!1,productId:s.productId,visualType:s.visualType,dedupKey:`gtm:firstgen-started:${l.id}`,dedupExists:Kn(`gtm:firstgen-started:${l.id}`),willFire:!0}),fl({userId:l.id,productId:s.productId,generationId:s.jobId,visualType:s.visualType}),Lt.current=!0)},[l]),{data:os=[]}=zt({queryKey:["brand-profiles"],queryFn:async()=>{const{data:s,error:r}=await Me.from("brand_profiles").select("*").order("name");return r?[]:s},enabled:!!l}),{data:we=[],isLoading:Bt}=zt({queryKey:["user-products",l==null?void 0:l.id],queryFn:async()=>{const{data:s,error:r}=await Me.from("user_products").select("*").order("created_at",{ascending:!1});if(r)throw r;return s},enabled:!!(l!=null&&l.id)}),{data:lr=[]}=zt({queryKey:["previous-uploads",l==null?void 0:l.id],queryFn:async()=>
6{if(!(l!=null&&l.id))return[];const{data:s,error:r}=await Me.storage.from("product-uploads").list(l.id,{limit:20,sortBy:{column:"created_at",order:"desc"}});return r||!s?[]:s.filter(a=>/\.(jpg|jpeg|png|webp)$/i.test(a.name)).map(a=>{const{data:c}=Me.storage.from("product-uploads").getPublicUrl(`${l.id}/${a.name}`);return{name:a.name,url:c.publicUrl,created_at:a.created_at}})},enabled:!!(l!=null&&l.id)&&(t==null?void 0:t.slug)==="interior-exterior-staging"}),[Q,x]=i.useState("source"),[Ra,ws]=i.useState(null);i.useState(!1);const[Rt,Br]=i.useState(""),[ys,Ut]=i.useState(""),[C,ue]=i.useState("grid"),ss=22,ds=(s,r)=>{const a=r.trim().toLowerCase();if(!a)return!0;const c=[s.title,s.description,s.product_type,s.color,s.materials,s.sku,s.dimensions,s.weight,Array.isArray(s.tags)?s.tags.join(" "):""].filter(Boolean).join(" ").toLowerCase();return a.split(/\s+/).every(d=>c.includes(d))},[ts,Je]=i.useState(ss),[W,gs]=i.useState(new Set),[ae,Hs]=i.useState(null),[y,Ts]=i.useState(null),[nr,Ua]=i.useState(null),[Ft,Rr]=i.useState(null);i.useEffect(()=>{if(!nr||nr.length===0)return;let s=!1;return(async()=>{const r=await Mo(nr);if(s){r.forEach(a=>URL.revokeObjectURL(a.previewUrl));return}Rr(r),Ua(null)})(),()=>{s=!0}},[nr]);const[Fa,Ea]=i.useState(!1),[_l,Tl]=i.useState(null),[zl,qa]=i.useState(!1),[Ms,Ur]=i.useState(new Set),[or,Pl]=i.useState(""),[Oa,Da]=i.useState(12);i.useEffect(()=>{Da(12)},[or]);const{data:Fr=[],isLoading:Al}=zt({queryKey:["generate-library-items",l==null?void 0:l.id],queryFn:async()=>{var c,d;const[s,r]=await Promise.all([Me.from("freestyle_generations").select("id, image_url, prompt, created_at").order("created_at",{ascending:!1}).limit(50),Me.from("generation_jobs").select("id, results, created_at, status, prompt_final").eq("user_id",l.id).eq("status","completed").order("created_at",{ascending:!1}).limit(50)]),a=[];if(s.data)for(const u of s.data)a.push({id:`fs-${u.id}`,imageUrl:u.image_url,label:((c=u.prompt)==null?void 0:c.slice(0,60))||"Freestyle",createdAt:u.created_at});if(r.data)for(const u of r.data){const f=u.results;if(Array.isArray(f))for(let j=0;j<f.length;j++){const _=f[j],L=typeof _=="string"?_:(_==null?void 0:_.url)||(_==null?void 0:_.image_url);!L||L.startsWith("data:")||a.push({id:`job-${u.id}-${j}`,imageUrl:L,label:((d=u.prompt_final)==null?void 0:d.slice(0,60))||"Generated",createdAt:u.created_at})}}return a.sort((u,f)=>new Date(f.createdAt).getTime()-new Date(u.createdAt).getTime()),a},enabled:!!(l!=null&&l.id)&&ae==="library"}),{upload:Ml,isUploading:Ga}=Lo(),[g,rs]=i.useState(null),[vt,Es]=i.useState(new Set),[zs,dr]=i.useState(ce&&Pt.find(s=>s.templateId===ce)||null),[lt,Er]=i.useState("all"),[nt,$l]=i.useState(""),Z=os.find(s=>s.id===nt)||null,[De,Va]=i.useState("product-only"),[fe,Ka]=i.useState(null),[Te,Ha]=i.useState(new Set),[$s,Ja]=i.useState(new Map),[Et,Qa]=i.useState(null),[Le,Ya]=i.useState(new Set),[ot,Za]=i.useState(new Map),[qr,Ll]=i.useState("all"),[Or,Bl]=i.useState("all"),[Dr,Rl]=i.useState("all"),[Gr,Ul]=i.useState(!0),[Fl,Xa]=i.useState("clean"),[El,Wa]=i.useState("studio"),[ql,ei]=i.useState(["text overlays","busy backgrounds"]);i.useState(!0);const[ze,si]=i.useState("1"),[Ls,wt]=i.useState("1:1"),[as,ti]=i.useState(new Set),[is,cr]=i.useState("high"),[Nt,Vr]=i.useState(null),[Ee,ri]=i.useState(new Set(["auto"])),[Ol,Bs]=i.useState(0),[qt,ai]=i.useState(null),[mr,ii]=i.useState(0),[ls,St]=i.useState([]),[vs,dt]=i.useState(new Set),[qe,Js]=i.useState([]),[zd,ct]=i.useState(0),[Dl,mt]=i.useState(new Map);i.useState(!1);const Ge=qe.length>1,[Ie,Ct]=i.useState(new Map),li=i.useRef(Ie);i.useEffect(()=>{li.current=Ie},[Ie]),i.useEffect(()=>{Q==="generating"?qt===null&&ai(Date.now()):(qt!==null&&ai(null),mr!==0&&ii(0))},[Q]),i.useEffect(()=>{if(qt===null)return;const s=setInterval(()=>{ii(Math.floor((Date.now()-qt)/1e3))},1e3);return()=>clearInterval(s)},[qt]);const ut=Ie.size>1,[Gl,Kr]=i.useState(new Map),Rs=i.useRef(null),[Hr,ni]=i.useState(!1),[Vl,Jr]=i.useState(!1),[Kl,oi]=i.useState(!1),[Hl,di]=i.useState(!1),[Jl,ci]=i.useState(0),[Ql,qs]=i.useState(!1),[Yl,Ot]=i.useState(!1),Pe=Ln(),xs=(t==null?void 0:t.generation_config)??null,cs=!!xs,Ps=xs==null?void 0:xs.variation_strategy,U=xs==null?void 0:xs.ui_config,Zl=["studio","lifestyle","editorial","streetwear"],ge=i.useMemo(()=>
6{if(!Ps||Ps.type!=="scene"||(t==null?void 0:t.slug)!=="product-listing-set")return Ps;const s=Ps.variations,r=new Set(s.map(u=>u.label.toLowerCase())),c=m(S([...h(Cr),...o])).filter(u=>!Zl.includes(u.category)).filter(u=>!r.has(u.name.toLowerCase()));if(c.length===0)return Ps;const d=c.map(u=>{var f,j;return{label:u.name,instruction:((f=u.promptHint)==null?void 0:f.trim())||((j=u.description)==null?void 0:j.trim())||`Place the product in a ${u.name} environment, styled as ${va[u.category]||u.category} product photography`,preview_url:u.previewUrl,prompt_only:u.promptOnly||!1,use_scene_reference:!u.promptOnly&&!!u.previewUrl,category:va[u.category]||u.category}});return{...Ps,variations:[...s,...d]}},[Ps,o,t==null?void 0:t.slug,m,S,h]),ur=((Vi=Ps==null?void 0:Ps.variations)==null?void 0:Vi.length)??0,kt=i.useCallback(s=>{const r=s.filter(d=>d>=ur).sort((d,u)=>d-u),a=r.map(d=>ge==null?void 0:ge.variations[d]).filter(Boolean);return{remapped:s.map(d=>{if(d<ur)return d;const u=r.indexOf(d);return ur+u}),extras:a.length>0?a:[]}},[ur,ge]),[Ae,It]=i.useState(new Set),mi=i.useRef(null),[Xl,Qr]=i.useState([]),[ht,Wl]=i.useState("front"),[en,ui]=i.useState("all"),[Yr,Dt]=i.useState("scenes"),us=(t==null?void 0:t.slug)==="flat-lay-set",be=(t==null?void 0:t.slug)==="image-upscaling",sn=!1,[Zr,Xr]=i.useState("surfaces"),[pt,Pd]=i.useState("4k");i.useEffect(()=>{if(be)return document.body.setAttribute("data-hide-studio-chat","true"),()=>document.body.removeAttribute("data-hide-studio-chat")},[be]);const[hi,tn]=i.useState(""),[pi,rn]=i.useState([]),[As,an]=i.useState(new Set),[gi,ln]=i.useState("clean"),[Wr,nn]=i.useState("excited"),[Gt,_t]=i.useState(null),[hr,xi]=i.useState("auto"),Qe=(t==null?void 0:t.slug)==="mirror-selfie-set",me=(t==null?void 0:t.slug)==="selfie-ugc-set",X=(t==null?void 0:t.slug)==="interior-exterior-staging",[Ve,on]=i.useState("interior"),[Os,fi]=i.useState(""),[bi,dn]=i.useState("Keep Original"),[ji,cn]=i.useState("Keep Original"),[yi,vi]=i.useState("Match Design Style"),[wi,mn]=i.useState("Keep Original"),[pr,Ni]=i.useState("Keep & Restyle"),[Si,un]=i.useState("Medium"),[Vt,ea]=i.useState([]),[sa,hn]=i.useState(""),[gr,Ci]=i.useState(""),[ta,ki]=i.useState("As Photographed"),[xr,pn]=i.useState(""),[Kt,Ii]=i.useState(!1),[ra,_i]=i.useState("Standard"),[aa,Ti]=i.useState(""),[ia,zi]=i.useState(""),Pi={"Living Room":["Sofa","Sectional","Coffee Table","TV Console","Bookshelf","Side Table","Kitchen Island","Bar Cart","Floor Lamp","Area Rug"],"Bedroom (Master)":["King Bed","Queen Bed","Nightstands","Dresser","Vanity","Armchair","Floor Mirror"],"Bedroom (Guest)":["Double Bed","Single Bed","Sofa Bed","Nightstand","Small Desk","Armchair"],"Kids Room (Girl)":["Single Bed","Bunk Bed","Loft Bed","Study Desk","Bookshelf","Toy Storage","Bean Bag","Wall Shelves"],"Kids Room (Boy)":["Single Bed","Bunk Bed","Loft Bed","Study Desk","Bookshelf","Toy Storage","Bean Bag","Wall Shelves"],"Kids Room (Twins/Shared)":["Twin Beds","Bunk Bed","Shared Desk","Individual Nightstands","Toy Storage","Bookshelf"],"Baby Nursery (Girl)":["Crib","Changing Table","Rocking Chair","Dresser","Wall Shelves","Storage Baskets"],"Baby Nursery (Boy)":["Crib","Changing Table","Rocking Chair","Dresser","Wall Shelves","Storage Baskets"],Kitchen:["Kitchen Island","Bar Stools","Dining Nook","Open Shelving","Pendant Lights"],"Dining Room":["Dining Table (4-seat)","Dining Table (6-seat)","Sideboard","Display Cabinet","Chandelier"],"Bathroom (Master)":["Vanity","Freestanding Tub","Shower","Storage Cabinet","Mirror","Towel Rack"],"Bathroom (Guest)":["Vanity","Shower","Storage Cabinet","Mirror","Towel Rack"],"Home Office / Work Room":["Desk","Ergonomic Chair","Bookshelf","Filing Cabinet","Monitor Stand","Floor Lamp"],"Walk-in Closet":["Shelving Unit","Hanging Rails","Drawer Unit","Island Dresser","Mirror","Shoe Rack"],"Hallway / Entryway":["Console Table","Mirror","Coat Hooks","Shoe Storage","Bench"],"Laundry Room":["Folding Table","Storage Shelves","Baskets","Drying Rack"],"Storage Room / Utility":["Shelving Units","Labeled Containers","Workbench","Pegboard"],"Basement / Rec Room":["Sofa","TV Console","Game Table","Bar Area","Bookshelf"],"Front Facade":["Lounge Chairs","Planters","Outdoor Lighting","Welcome Mat"],Backyard:["Lounge Chairs","Dining Set","Planters","Fire Pit","Pergola","Outdoor Rug"],Garden:["Garden Bench","Planters","Water Feature","Pathway Lighting"],"Pool Area":["Lounge Chairs","Umbrellas","Side Tables","Planters","Outdoor Shower"],Driveway:["Planters","Pathway Lighting","Gate","Bollards"],"Rooftop Terrace":["Lounge Set","Planters","Privacy Screen","String Lights","Outdoor Rug"],"Entrance / Porch":["Rocking Chair","Bench","Planters","Pendant Light","Welcome Mat"],"Patio / Outdoor Living":["Dining Set","Lounge Set","Planters","Fire Pit","Pergola","Outdoor Rug"],"Balcony / Terrace":["Compact Table","Chairs","Planters","String Lights"],Garage:["Tool Storage","Workbench","Wall-mounted Racks","Floor Mat"]},gn=["Living Room","Bedroom (Master)","Bedroom (Guest)","Kids Room (Girl)","Kids Room (Boy)","Kids Room (Twins/Shared)","Baby Nursery (Girl)","Baby Nursery (Boy)","Kitchen","Dining Room","Bathroom (Master)","Bathroom (Guest)","Home Office / Work Room","Walk-in Closet","Hallway / Entryway","
6Laundry Room","Storage Room / Utility","Basement / Rec Room"],xn=["Front Facade","Backyard","Garden","Pool Area","Driveway","Rooftop Terrace","Entrance / Porch","Patio / Outdoor Living","Balcony / Terrace","Garage"];i.useEffect(()=>{X&&Hs("scratch")},[X]),i.useEffect(()=>{fi(""),ea([]),Ci(""),ki("As Photographed"),Ii(!1),_i("Standard"),Ti(""),zi(""),It(new Set),ui("all")},[Ve]),i.useEffect(()=>{ea([])},[Os]),i.useEffect(()=>{Kt&&Ni("Replace All")},[Kt]),i.useEffect(()=>{var s,r,a,c,d;if(t){if(t.uses_tryon&&Va("virtual-try-on"),(r=(s=xs==null?void 0:xs.fixed_settings)==null?void 0:s.aspect_ratios)!=null&&r.length){const u=xs.fixed_settings.aspect_ratios[0];["1:1","4:5","9:16","16:9"].includes(u)&&wt(u)}else if(((a=t.recommended_ratios)==null?void 0:a.length)>0){const u=t.recommended_ratios[0];["1:1","4:5","9:16","16:9"].includes(u)&&wt(u)}if((c=ge==null?void 0:ge.variations)!=null&&c.length&&mi.current!==t.id&&(mi.current=t.id,ge.type==="scene"?It(new Set):It(new Set(ge.variations.map((u,f)=>f)))),!xs&&((d=t.template_ids)==null?void 0:d.length)>0){const u=Pt.find(f=>t.template_ids.some(j=>f.templateId.includes(j)||f.name.toLowerCase().includes(j.replace(/-/g," "))));u&&dr(u)}}},[t,xs]),i.useEffect(()=>{var r;if(!ee&&!he)return;const s=[...h(Cr),...o];if(ee){const a=at.find(c=>c.name.toLowerCase()===ee.toLowerCase());a&&(Ka(a),Ha(new Set([a.modelId])),Ja(new Map([[a.modelId,a]])))}if(he){const a=s.find(c=>c.name.toLowerCase()===he.toLowerCase());if(a&&(Qa(a),Ya(new Set([a.poseId])),Za(new Map([[a.poseId,a]]))),(ge==null?void 0:ge.type)==="scene"&&((r=ge.variations)!=null&&r.length)){const c=ge.variations.findIndex(d=>d.label.toLowerCase()===he.toLowerCase());c>=0&&It(d=>{const u=new Set(d);return u.add(c),u})}}},[ee,he,o,at,ge]),i.useEffect(()=>{if(!H)return;let s=!1;const r={...H};if(!r.modelImageUrl&&r.modelName){const a=at.find(c=>c.name.toLowerCase()===r.modelName.toLowerCase());a&&(r.modelImageUrl=a.previewUrl,s=!0)}if(!r.sceneImageUrl&&r.sceneName){const c=[...Cr,...o].find(d=>d.name.toLowerCase()===r.sceneName.toLowerCase());c&&(r.sceneImageUrl=c.previewUrl,s=!0)}s&&pe(r)},[at,o]),i.useEffect(()=>{var s;(s=document.querySelector("main"))==null||s.scrollTo({top:0,behavior:"smooth"})},[Q]),i.useEffect(()=>{var s;Z&&(Xa(Z.tone),Wa(Z.background_style),((s=Z.do_not_rules)==null?void 0:s.length)>0&&ei(Z.do_not_rules))},[Z]);const fn=[{id:"all",label:"All Templates"},{id:"garments",label:"Clothing"},{id:"beauty-skincare",label:"Cosmetics"},{id:"food",label:"Food"},{id:"beverages",label:"Beverages"},{id:"furniture",label:"Furniture"},{id:"home-decor",label:"Home Decor"},{id:"supplements-wellness",label:"Supplements"},{id:"other",label:"Universal"}];Pt.filter(s=>!(!s.enabled||lt!=="all"&&s.category!==lt)),Hn.filter(s=>s.title.toLowerCase().includes(Rt.toLowerCase())||s.vendor.toLowerCase().includes(Rt.toLowerCase()));const bn=at.filter(s=>!(qr!=="all"&&s.gender!==qr||Or!=="all"&&s.bodyType!==Or||Dr!=="all"&&s.ageRange!==Dr)),jn=["studio","lifestyle","editorial","streetwear"],Ai=m(S([...h(Cr),...o])),yn=Ai.reduce((s,r)=>(t!=null&&t.uses_tryon&&!jn.includes(r.category)||(s[r.category]||(s[r.category]=[]),s[r.category].push(r)),s),{});nd(at,Ai);const fr=s=>{if(!s)return!1;const r=s.productType.toLowerCase(),a=["sweater","shirt","apparel","dress","jacket","pants","jeans","coat","blouse","skirt","suit","hoodie","t-shirt","clothing","legging","bra","sports bra","tank","jogger","shorts","top","long sleeve","crop","bodysuit","romper","jumpsuit","sweatshirt","pullover","cardigan","vest","active","athletic","yoga","workout"];return a.some(c=>r.includes(c))||s.tags.some(c=>a.some(d=>c.toLowerCase().includes(d)))},br=s=>({id:s.id,title:s.title,vendor:"My Products",productType:s.product_type,tags:s.tags||[],description:s.description,images:[{id:`img-${s.id}`,url:s.image_url}],status:"active",createdAt:s.created_at,updatedAt:s.updated_at}),jr=s=>{if(!s)return null;const r=s.productType.toLowerCase(),a=s.tags.map(F=>F.toLowerCase()).join(" "),c=`${r} ${a}`;return["serum","moisturizer","lipstick","foundation","mascara","skincare","beauty","makeup","cream","treatment","powder","lip"].some(F=>c.includes(F))?"beauty-skincare":["coffee","tea","juice","beverage","soda","wine","beer","water","drink","kombucha","smoothie"].some(F=>c.includes(F))?"beverages":["cereal","granola","chocolate","honey","snack","food","organic","candy","chips","cookie"].some(F=>c.includes(F))?"food":["sofa","couch","sectional","loveseat","armchair","recliner","dining table","coffee table","desk","bookshelf","bookcase","cabinet","dresser","wardrobe","sideboard","credenza","nightstand","ottoman","bench","stool","bed frame","headboard","futon","mattress","tv stand","media console","kitchen island","bar cart","furniture"].some(F=>c.includes(F))?"furniture":["candle","vase","planter","pillow","lamp","decor","home","interior","carafe","ceramic","diffuser","figurine","tray","coaster"].some(F=>
6c.includes(F))?"home-decor":["vitamin","supplement","capsule","protein","collagen","omega","wellness","greens","superfood"].some(F=>c.includes(F))?"supplements-wellness":fr(s)?"garments":null},Qs=i.useCallback(s=>{var d;if(!s)return ya.default;const r=(d=s.analysis_json)==null?void 0:d.category,a=jr(s),c=Td(r||a||"",s.productType);return ya[c]||ya.default},[]),gt=i.useCallback(s=>{if(!me)return;const r=Qs(s),a=r.find(c=>c.id===Gt)||r[0];return a==null?void 0:a.phrase},[me,Gt,Qs]),la=i.useCallback(s=>{var a;if(!s)return"other";const r=((a=s.analysis_json)==null?void 0:a.category)||jr(s)||"";return Ho(r,`${s.title||""} ${s.productType||""}`)},[]),Mi=i.useCallback(s=>{if(!me)return;const r=gt(s);return Ar(r)?Jo(hr,la(s)):Ko(hr,r)},[me,hr,gt,la]),na=i.useRef(null);i.useEffect(()=>{if(!me)return;const s=Ar(gt(g));na.current!==null&&na.current!==s&&xi("auto"),na.current=s},[me,Gt,g,gt]),i.useEffect(()=>{var c;if(!Ks||$t.current||!t||Bt)return;let s=null;const r={sample_tryon_crop_top:fa,sample_listing_ring:Ir,sample_ugc_ice_roller:ba,sample_mirror_sweater:_r};if(r[Ks])s=r[Ks];else{const d=we.find(u=>u.id===Ks);d&&(s=br(d))}if(!s)return;$t.current=!0,rs(s),Hs("products"),s.images.length>0&&Es(new Set([s.images[0].id])),gs(new Set([s.id]));const a=fd(s.productType,s.tags);if(a&&Vr(a),me){const d=Qs(s);_t(((c=d[0])==null?void 0:c.id)??null),x("interaction")}else t.uses_tryon||U!=null&&U.show_model_picker?x("model"):U!=null&&U.skip_template&&cs?x("settings"):x("template")},[Ks,t,we,Bt]);const $i=()=>{us?(Xr("surfaces"),x("settings")):t!=null&&t.uses_tryon||U!=null&&U.show_model_picker?x("model"):U!=null&&U.skip_template&&cs?x("settings"):fr(g)?x("mode"):x("template")},vn=s=>{Es(r=>{const a=new Set(r);return a.has(s)?a.size>1&&a.delete(s):a.add(s),a})},Li=s=>{dr(s),wt(s.defaults.aspectRatio),cr(s.defaults.quality),A.success(`"${s.name}" selected! Click Continue when ready.`)},wn=s=>{Ha(r=>{const a=new Set(r),c=new Map($s);if(a.has(s.modelId))a.delete(s.modelId),c.delete(s.modelId);else{if(Fe&&a.size>=1)return _s.openUpgradeDrawer("model_limit"),r;if(a.add(s.modelId),c.set(s.modelId,s),!Fe&&a.size>1){const u=a.size,f=Math.max(1,Le.size),j=parseInt(ze),_=Ge?qe.length:1,L=u*f*j*6*_;L>J&&A.warning(`${u} models × ${f} scenes will cost ${L} credits — you have ${J}. Top up before generating.`,{duration:4e3})}}Ja(c);const d=Array.from(a)[0];return Ka(d&&c.get(d)||null),a})},Nn=s=>{Ya(r=>{const a=new Set(r),c=new Map(ot);if(a.has(s.poseId))a.delete(s.poseId),c.delete(s.poseId);else{if(Fe&&a.size>=Id)return _s.openUpgradeDrawer("scene_limit"),r;if(a.add(s.poseId),c.set(s.poseId,s),!Fe){const u=a.size,f=parseInt(ze),j=Ge?qe.length:1,_=u*f*6*j;_>J&&A.warning(`${u} scenes will cost ${_} credits — you have ${J}. Top up before generating.`,{duration:4e3})}}Za(c);const d=Array.from(a)[0];return Qa(d&&c.get(d)||null),a})},Sn=()=>{x("settings"),Bs(0),A.info("Generation cancelled")},Cn=async()=>{var s,r,a;try{if(!g&&!y)return;x("generating"),Bs(0);const{data:c}=await Me.auth.getSession(),d=(s=c==null?void 0:c.session)==null?void 0:s.access_token;if(!d){A.error("Authentication required"),x("settings");return}const u=[];if(Ge)for(const L of qe){const F=(r=L.images[0])==null?void 0:r.url;F&&u.push({imageUrl:F,sourceType:"generation",sourceId:L.id,title:L.title})}else if(ae==="scratch"&&(y!=null&&y.uploadedUrl))u.push({imageUrl:y.uploadedUrl,sourceType:"freestyle",sourceId:"scratch",title:y.productInfo.title||"Upload"});else if(g){const L=(a=g.images[0])==null?void 0:a.url;L&&u.push({imageUrl:L,sourceType:"generation",sourceId:g.id,title:g.title})}if(u.length===0){A.error("No source image available"),x("settings");return}const f=new Map;let j=null;for(let L=0;L<u.length;L++){const F=u[L];await Zt(L);const E=await Xt({jobType:"upscale",payload:{imageUrl:F.imageUrl,sourceType:F.sourceType,sourceId:F.sourceId,resolution:pt},imageCount:1,quality:"standard",resolution:pt,skipWake:!0},d);if(Wt(E)){E.type==="insufficient_credits"?A.error(E.message):E.type==="rate_limit"?A.error("Rate limited. Please wait."):A.error(E.message||`Failed to enqueue upscale for "${F.title}"`);break}f.set(F.sourceId,E.jobId),j=E.newBalance,it({jobId:E.jobId,productId:F.sourceType==="generation"?F.sourceId??null:null,visualType:"upscale"}),Zs(Pe,{jobId:E.jobId,workflow_id:t==null?void 0:t.id,workflow_name:t==null?void 0:t.name,workflow_slug:t==null?void 0:t.slug,product_name:F.title,job_type:"upscale",quality:"standard",resolution:pt})}if(f.size===0){A.error("Could not queue any images"),x("settings");return}j!==null&&$(j),Ct(f),er(d);const _=pt==="4k"?"4K":"2K";A.success(`Upscaling ${f.size} image${f.size>1?"s":""} to ${_}
6…`),Pe.invalidateQueries({queryKey:["workflow-active-jobs"]})}catch(c){console.error("Upscale workflow failed:",c),A.error("Something went wrong starting the upscale. Please try again."),x("settings")}},yr=()=>{if(!g&&!(ae==="scratch"&&y)){A.error("Pick a product first");return}if(J<fs){qs(!0);return}if(be){Cn();return}if(De==="virtual-try-on"&&!me){if(Te.size===0||Le.size===0){A.error("Please select a model and at least one scene");return}Ri();return}if(cs){kn();return}if(!zs){A.error("Please select a Visual Type first");return}A.error("This Visual Type is no longer supported. Please pick another from Visual Studio.")},kn=async()=>{var s,r,a,c;try{if(!g&&!y)return;if(Ge){x("generating"),Bs(0);const{data:O}=await Me.auth.getSession(),te=(s=O==null?void 0:O.session)==null?void 0:s.access_token;if(!te){A.error("Authentication required"),x("settings");return}const q=crypto.randomUUID(),Ne=(U==null?void 0:U.show_model_picker)&&fe,Oe=(me||Qe)&&Te.size>0?Array.from(Te).map(R=>$s.get(R)).filter(Boolean):Ne?[fe]:[],je=new Map;let Ye=null;for(const R of qe){const Se=R.images[0],ye=(Se==null?void 0:Se.url)||"";if(!ye)continue;const Ns=we.find(js=>js.id===R.id),Us={title:R.title,productType:R.productType,description:R.description,dimensions:(Ns==null?void 0:Ns.dimensions)||void 0},bs=await Cs(ye),Ds=Ae.size>0?Array.from(Ae):[0],Ss=as.size>0?Array.from(as):[Ls],Ys=Ee.has("auto")?[null]:Array.from(Ee),$n=Oe.length>0?Oe:[null];for(const js of $n){const Wi=js?await Cs(js.previewUrl):void 0;for(const ua of Ds)for(const el of Ss)for(const sl of Ys){const Yt={workflow_id:t.id,workflow_name:t.name,workflow_slug:t.slug,product:{...Us,imageUrl:bs},product_name:R.title,product_image_url:await ja((r=R.images[0])==null?void 0:r.url),brand_profile:Z?{tone:Z.tone,background_style:Z.background_style,lighting_style:Z.lighting_style,color_temperature:Z.color_temperature,brand_keywords:Z.brand_keywords,color_palette:Z.color_palette,target_audience:Z.target_audience,do_not_rules:Z.do_not_rules,composition_bias:Z.composition_bias,preferred_scenes:Z.preferred_scenes,photography_reference:Z.photography_reference}:void 0,selected_variations:(()=>{const{remapped:Sr}=kt([ua]);return Sr})(),extra_variations:(()=>{const{extras:Sr}=kt([ua]);return Sr.length>0?Sr:void 0})(),product_angles:ht!=="front"?ht:void 0,quality:is,aspectRatio:el,framing:sl||void 0,ugc_mood:me?Wr:void 0,interaction_phrase:gt(R),outfit_phrase:me?Mi(R):void 0,batch_id:q};js&&Wi&&(Yt.model={name:js.name,gender:js.gender,ethnicity:js.ethnicity,bodyType:js.bodyType,ageRange:js.ageRange,imageUrl:Wi}),await Zt(je.size);const ft=await Xt({jobType:"workflow",payload:Yt,imageCount:Tt,quality:is,additionalProductCount:0,hasModel:!!js,hasScene:!1,skipWake:!0},te);if(!Wt(ft))je.set(`${R.id}_${(js==null?void 0:js.modelId)||"no-model"}_${ua}_${el}_${sl}`,ft.jobId),Ye=ft.newBalance,it({jobId:ft.jobId,productId:(Yt==null?void 0:Yt.product_id)??(R==null?void 0:R.id)??null,visualType:(t==null?void 0:t.slug)||(t==null?void 0:t.name)||"workflow"}),Zs(Pe,{jobId:ft.jobId,workflow_id:t==null?void 0:t.id,workflow_name:t==null?void 0:t.name,workflow_slug:t==null?void 0:t.slug,product_name:R.title,job_type:"workflow",quality:is,imageCount:1,batch_id:q});else if(ft.type==="insufficient_credits"){A.error(ft.message);break}}}}if(je.size===0){A.error("Could not queue any products"),x("settings");return}Ye!==null&&$(Ye),Ct(je),er(te);return}let d="",u={title:"",productType:"",description:""};if(ae==="scratch"&&(y!=null&&y.uploadedUrl))d=y.uploadedUrl,u=y.productInfo;else if(g){const O=Array.from(vt)[0],te=g.images.find(Ne=>Ne.id===O);d=(te==null?void 0:te.url)||((a=g.images[0])==null?void 0:a.url)||"";const q=we.find(Ne=>Ne.id===g.id);u={title:g.title,productType:g.productType,description:g.description,dimensions:(q==null?void 0:q.dimensions)||void 0}}if(!d){A.error("No source image available");return}x("generating"),Bs(0);const f=(U==null?void 0:U.show_model_picker)&&fe,j=await Cs(d),_=(me||Qe)&&Te.size>0?Array.from(Te).map(O=>$s.get(O)).filter(Boolean):f?[fe]:[],L=us?[...pi.map(O=>{var te;return(te=_d.find(q=>q.id===O))==null?void 0:te.hint}
6).filter(Boolean),hi].filter(Boolean).join(", "):void 0,F=us&&As.size>1?await Promise.all((we.length>0?we:[]).filter(O=>As.has(O.id)&&O.id!==(g==null?void 0:g.id)).map(async O=>({title:O.title,productType:O.product_type,description:O.description,imageUrl:await Cs(O.image_url)}))):void 0,E=_.length>1,xe=()=>({workflow_id:t.id,workflow_name:t.name,workflow_slug:t.slug,product:{...u,imageUrl:j},brand_profile:Z?{tone:Z.tone,background_style:Z.background_style,lighting_style:Z.lighting_style,color_temperature:Z.color_temperature,brand_keywords:Z.brand_keywords,color_palette:Z.color_palette,target_audience:Z.target_audience,do_not_rules:Z.do_not_rules,composition_bias:Z.composition_bias,preferred_scenes:Z.preferred_scenes,photography_reference:Z.photography_reference}:void 0,selected_variations:(()=>{if(Ae.size===0)return;const{remapped:O}=kt(Array.from(Ae));return O})(),extra_variations:(()=>{if(Ae.size===0)return;const{extras:O}=kt(Array.from(Ae));return O.length>0?O:void 0})(),product_angles:ht!=="front"?ht:void 0,quality:is,aspectRatio:as.size>0?Array.from(as)[0]:Ls,framing:Ee.has("auto")?void 0:Ee.size>0?Array.from(Ee)[0]:Nt||void 0,styling_notes:L||void 0,prop_style:us?gi:void 0,additional_products:F,ugc_mood:me?Wr:void 0,interaction_phrase:gt(g),outfit_phrase:me?Mi(g):void 0,room_type:X?Os:void 0,wall_color:X?bi:void 0,flooring_preference:X?ji:void 0,interior_type:X?Ve:void 0,furniture_style:X?yi:void 0,lighting_mood:X?wi:void 0,furniture_handling:X?pr:void 0,room_size:X?Si:void 0,key_pieces:X&&Vt.length>0?Vt:void 0,design_notes:X&&sa?sa:void 0,color_palette_preference:X&&gr?gr:void 0,time_of_day:X&&ta!=="As Photographed"?ta:void 0,staging_purpose:X&&xr?xr:void 0,is_empty_room:X?Kt:void 0,ceiling_height:X&&ra!=="Standard"?ra:void 0,room_dimensions:X&&aa?aa:void 0,exact_ceiling_height:X&&ia?ia:void 0}),Ke=as.size>0?Array.from(as):[Ls],ns=Ee.has("auto")?[null]:Array.from(Ee);if(Ke.length===1&&ns.length===1&&!E){const O=xe();if(O.aspectRatio=Ke[0],O.framing=ns[0]||void 0,_.length===1){const q=_[0],Ne=await Cs(q.previewUrl);O.model={name:q.name,gender:q.gender,ethnicity:q.ethnicity,bodyType:q.bodyType,ageRange:q.ageRange,imageUrl:Ne}}const te=cs?Ae.size*Tt:parseInt(ze);if(te<=1){const q=await $e({jobType:"workflow",payload:O,imageCount:te,quality:"high",additionalProductCount:0},{imageCount:te,quality:"high",hasModel:_.length>0,hasScene:!1,hasProduct:!0});q?($(q.newBalance),Zs(Pe,{jobId:q.jobId,workflow_id:t==null?void 0:t.id,workflow_name:t==null?void 0:t.name,workflow_slug:t==null?void 0:t.slug,product_name:u.title,job_type:"workflow",quality:"high",imageCount:te})):x("settings")}else{const q=await $r({payload:O,selectedVariationIndices:kt(Array.from(Ae)).remapped,angleMultiplier:Tt,quality:"high",imageCount:te,hasModel:_.length>0,hasScene:!1,onJobEnqueued:Ne=>Zs(Pe,{jobId:Ne,workflow_id:t==null?void 0:t.id,workflow_name:t==null?void 0:t.name,workflow_slug:t==null?void 0:t.slug,product_name:u.title,job_type:"workflow",quality:"high",imageCount:1})});q.success&&q.newBalance!==null&&$(q.newBalance),q.success||x("settings")}}else{const{data:O}=await Me.auth.getSession(),te=(c=O==null?void 0:O.session)==null?void 0:c.access_token;if(!te){A.error("Authentication required"),x("settings");return}const q=crypto.randomUUID(),Ne=new Map;let Oe=null;const je=Ae.size>0?Array.from(Ae):[0],Ye=_.length>0?_:[null];for(const R of Ye){const Se=R?await Cs(R.previewUrl):void 0;for(const ye of Ke)for(const Ns of ns)for(const Us of je){const{remapped:bs,extras:Ds}=kt([Us]),Ss={...xe(),aspectRatio:ye,framing:Ns||void 0,selected_variations:bs,extra_variations:Ds.length>0?Ds:void 0,batch_id:q};R&&Se&&(Ss.model={name:R.name,gender:R.gender,ethnicity:R.ethnicity,bodyType:R.bodyType,ageRange:R.ageRange,imageUrl:Se}),await Zt(Ne.size);const Ys=await Xt({jobType:"workflow",payload:Ss,imageCount:Tt,quality:"high",hasModel:!!R,hasScene:!1,skipWake:!0},te);if(!Wt(Ys))Ne.set(`${(R==null?void 0:R.modelId)||"no-model"}_${Us}_${ye}_${Ns}`,Ys.jobId),Oe=Ys.newBalance,it({jobId:Ys.jobId,productId:(Ss==null?void 0:Ss.product_id)??null,visualType:(t==null?void 0:t.slug)||(t==null?void 0:t.name)||"workflow"}),Zs(Pe,{jobId:Ys.jobId,workflow_id:t==null?void 0:t.id,workflow_name:t==null?void 0:t.name,workflow_slug:t==null?void 0:t.slug,product_name:u.title,job_type:"workflow",quality:"high",imageCount:1,batch_id:q});else if(Ys.type==="insufficient_credits"){A.error("Insufficient credits");break}}}if(Ne.size===0){A.error("Could not queue any images"),x("settings");return}
6Oe!==null&&$(Oe),Ct(Ne),Pe.invalidateQueries({queryKey:["workflow-active-jobs"]}),er(te)}}catch(d){console.error("Workflow generation failed:",d),A.error("Something went wrong starting the generation. Please try again."),x("settings")}},Bi=async(s,r,a,c,d,u,f)=>{var Ne,Oe;const j=a||Et,_=c||fe;if(!_||!j)return null;const L=Array.from(vt)[0],F=s.images.find(je=>je.id===L),E=(F==null?void 0:F.url)||((Ne=s.images[0])==null?void 0:Ne.url)||"";if(!E)return null;const[xe,Ke,ns]=await Promise.all([Cs(E),Cs(_.previewUrl),j.previewUrl?Cs(j.previewUrl):Promise.resolve(void 0)]),O=d||(as.size>0?Array.from(as)[0]:Ls),te=u!==void 0?u:Ee.has("auto")?null:Ee.size>0?Array.from(Ee)[0]:Nt,q=await Xt({jobType:"tryon",payload:{product:{title:s.title,description:s.description,productType:s.productType,imageUrl:xe},model:{name:_.name,gender:_.gender,ethnicity:_.ethnicity,bodyType:_.bodyType,ageRange:_.ageRange,imageUrl:Ke,originalImageUrl:_.previewUrl},pose:{name:j.name,description:j.promptHint||j.description,category:j.category,imageUrl:ns,originalImageUrl:j.previewUrl},aspectRatio:O,imageCount:parseInt(ze),framing:te||void 0,workflow_id:(t==null?void 0:t.id)||null,workflow_name:(t==null?void 0:t.name)||null,workflow_slug:(t==null?void 0:t.slug)||null,product_id:we.some(je=>je.id===s.id)?s.id:null,product_name:s.title,product_image_url:E||await ja((Oe=s.images[0])==null?void 0:Oe.url),brand_profile_id:nt||null,batch_id:f||void 0},imageCount:parseInt(ze),quality:is,hasModel:!0,hasScene:!0,skipWake:!0},r);return Wt(q)?(q.type==="insufficient_credits"?A.error(`Not enough credits for "${s.title}"`):q.type!=="rate_limit"&&A.error(q.message||`Failed to queue "${s.title}"`),null):(it({jobId:q.jobId,productId:we.some(je=>je.id===s.id)?s.id:null,visualType:(t==null?void 0:t.slug)||(t==null?void 0:t.name)||"tryon"}),{jobId:q.jobId,newBalance:q.newBalance})},Ri=async()=>{var s,r,a,c;try{if(Te.size===0||Le.size===0)return;const d=Array.from(Le).map(E=>ot.get(E)).filter(Boolean),u=Array.from(Te).map(E=>$s.get(E)).filter(Boolean);if(Ge){const E=as.size>0?Array.from(as):[Ls],xe=Ee.has("auto")?[null]:Array.from(Ee),Ke=qe.length*u.length*d.length*E.length*xe.length,ns=parseInt(ze)*6,O=Ke*ns;if(J<O){A.error(`Need ${O} credits for ${Ke} generations but you only have ${J}. Please top up first.`),qs(!0);return}Jr(!1),x("generating"),Bs(0);const{data:te}=await Me.auth.getSession(),q=(s=te==null?void 0:te.session)==null?void 0:s.access_token;if(!q){A.error("Authentication required"),x("settings");return}const Ne=crypto.randomUUID(),Oe=new Map,je=new Map;let Ye=null,R=0;for(const Se of qe)for(const ye of u)for(const Ns of d)for(const Us of E)for(const bs of xe){R>0&&await new Promise(Ss=>setTimeout(Ss,300));const Ds=await Bi(Se,q,Ns,ye,Us,bs,Ne);if(Ds){const Ss=`${Se.id}::${ye.modelId}::${Ns.poseId}::${Us}::${bs}`;Oe.set(Ss,Ds.jobId),je.set(Ss,{productName:Se.title,ratio:Us,framing:bs}),Ye=Ds.newBalance,Zs(Pe,{jobId:Ds.jobId,workflow_id:t==null?void 0:t.id,workflow_name:t==null?void 0:t.name,workflow_slug:t==null?void 0:t.slug,product_name:Se.title,job_type:"tryon",quality:is,imageCount:parseInt(ze),batch_id:Ne})}R++}if(Oe.size>0&&fetch("https://azwiljtrbtaupofwmpzb.supabase.co/functions/v1/enqueue-generation",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${q}`},body:JSON.stringify({jobType:"tryon",payload:{},imageCount:0,wakeOnly:!0})}).catch(()=>{}),Oe.size===0){A.error("Could not queue any products"),x("settings");return}Ye!==null&&$(Ye),Kr(je),Ct(Oe),Pe.invalidateQueries({queryKey:["workflow-active-jobs"]});return}let f="",j=null;if(ae==="scratch"&&(y!=null&&y.uploadedUrl))f=y.uploadedUrl,j={title:y.productInfo.title,productType:y.productInfo.productType,description:y.productInfo.description};else if(g){const E=Array.from(vt)[0],xe=g.images.find(Ke=>Ke.id===E);f=(xe==null?void 0:xe.url)||((r=g.images[0])==null?void 0:r.url)||"",j={title:g.title,productType:g.productType,description:g.description}}if(!f||!j){A.error("No source image available");return}Jr(!1),x("generating"),Bs(0);const _=as.size>0?Array.from(as):[Ls],L=Ee.has("auto")?[null]:Array.from(Ee);if(u.length>1||d.length>1||_.length>1||L.length>1){const{data:E}=await Me.auth.getSession(),xe=(c=E==null?void 0:E.session)==null?void 0:c.access_token;if(!xe){A.error("Authentication required"),x("settings");return}const Ke=crypto.randomUUID(),ns=new Map,O=new Map;let te=null;
6const q=g||{id:"scratch",title:j.title,description:j.description,productType:j.productType,vendor:"",tags:[],images:[{id:"scratch-img",url:f}],status:"active",createdAt:"",updatedAt:""},Ne=(g==null?void 0:g.title)||(j==null?void 0:j.title)||"";for(const Oe of u)for(const je of d)for(const Ye of _)for(const R of L){await Zt(ns.size);const Se=await Bi(q,xe,je,Oe,Ye,R,Ke);if(Se){const ye=`${Oe.modelId}::${je.poseId}::${Ye}::${R}`;ns.set(ye,Se.jobId),O.set(ye,{productName:Ne,ratio:Ye,framing:R}),te=Se.newBalance,Zs(Pe,{jobId:Se.jobId,workflow_id:t==null?void 0:t.id,workflow_name:t==null?void 0:t.name,workflow_slug:t==null?void 0:t.slug,product_name:Ne,job_type:"tryon",quality:is,imageCount:parseInt(ze),batch_id:Ke})}}if(ns.size===0){A.error("Could not queue any combinations"),x("settings");return}te!==null&&$(te),Kr(O),Ct(ns),Pe.invalidateQueries({queryKey:["workflow-active-jobs"]}),er(xe)}else{const E=u[0],xe=d[0],Ke=await Cs(f),ns=await Cs(E.previewUrl),O=xe.previewUrl?await Cs(xe.previewUrl):void 0,te=await $e({jobType:"tryon",payload:{product:{title:j.title,description:j.description,productType:j.productType,imageUrl:Ke},model:{name:E.name,gender:E.gender,ethnicity:E.ethnicity,bodyType:E.bodyType,ageRange:E.ageRange,imageUrl:ns},pose:{name:xe.name,description:xe.promptHint||xe.description,category:xe.category,imageUrl:O},aspectRatio:_[0],imageCount:parseInt(ze),framing:L[0]||void 0,workflow_id:(t==null?void 0:t.id)||null,workflow_name:(t==null?void 0:t.name)||null,workflow_slug:(t==null?void 0:t.slug)||null,product_id:g&&we.some(q=>q.id===g.id)?g.id:null,product_name:(g==null?void 0:g.title)||j.title,product_image_url:await ja((a=g==null?void 0:g.images[0])==null?void 0:a.url),brand_profile_id:nt||null},imageCount:parseInt(ze),quality:is},{imageCount:parseInt(ze),quality:is,hasModel:!0,hasScene:!0,hasProduct:!0});te?($(te.newBalance),Zs(Pe,{jobId:te.jobId,workflow_id:t==null?void 0:t.id,workflow_name:t==null?void 0:t.name,workflow_slug:t==null?void 0:t.slug,product_name:(g==null?void 0:g.title)||(j==null?void 0:j.title),job_type:"tryon",quality:is,imageCount:parseInt(ze)}),Pe.invalidateQueries({queryKey:["workflow-active-jobs"]})):x("settings")}}catch(d){console.error("Try-on generation failed:",d),A.error("Something went wrong starting the generation. Please try again."),x("settings")}};i.useEffect(()=>{var s;if(M&&!(Ie.size>0)&&!se&&Q!=="results"&&M.status==="completed"&&M.result){const r=M.result;r.images&&r.images.length>0&&(St(r.images),Qr(((s=r.variations)==null?void 0:s.map(a=>a.label))||[]),Bs(100),ws(M.id),x("results"),A.success(`Generated ${r.images.length} images!`),ve(),Pe.invalidateQueries({queryKey:["library"]}),Pe.invalidateQueries({queryKey:["recent-creations"]}),ms())}},[M,ve,ms,Ie.size,se,Q]),i.useEffect(()=>{var s;se&&(Ie.size>0||se.allDone&&(se.aggregatedImages.length>0?(St(se.aggregatedImages),Qr(se.aggregatedLabels),Bs(100),ws(((s=se.jobs.find(r=>r.status==="completed"))==null?void 0:s.jobId)||null),x("results"),se.hasPartialFailure?A.warning(`Generated ${se.aggregatedImages.length} images. ${se.failedJobs} batch${se.failedJobs>1?"es":""} failed — credits refunded for those.`):A.success(`Generated ${se.aggregatedImages.length} images!`),ve(),Pe.invalidateQueries({queryKey:["library"]}),Pe.invalidateQueries({queryKey:["recent-creations"]}),jt()):(A.error("All generation batches failed. Credits have been refunded."),x("settings"),ve(),jt())))},[se,ve,jt,Ie.size]),i.useEffect(()=>{if(Ie.size!==0)return()=>{Rs.current&&(clearInterval(Rs.current),Rs.current=null)}},[Ie.size]),i.useEffect(()=>{if(Ie.size===0)return;const s="https://azwiljtrbtaupofwmpzb.supabase.co",r="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImF6d2lsanRyYnRhdXBvZndtcHpiIiwicm9sZSI6ImFub24iLCJpYXQiOjE3Njk3OTkzNzEsImV4cCI6MjA4NTM3NTM3MX0.w8Flgj4nld44gT4w-S_TSqzZ-FRPt4xTFiHm1U_c5VY",a=Array.from(Ie.values()),c=async()=>{var O,te,q,Ne,Oe;const{data:d}=await Me.auth.getSession(),u=((O=d==null?void 0:d.session)==null?void 0:O.access_token)||r,f=await fetch(`${s}/rest/v1/generation_queue?id=in.(${a.join(",")})&select=id,status,result,error_message,completed_at`,{headers:{apikey:r,Authorization:`Bearer ${u}`}});if(!f.ok)return;const j=await f.json(),_=new Map;for(const je of j)_.set(je.id,je);const L=new Map;let F=!0,E=0,xe=0;for(const[je,Ye]of Ie.entries()){const R=_.get(Ye);if(!R){F=!1;continue}const Se=((te=R.result)==null?void 0:te.images)||((q=R.result)!=null&&q.imageUrl?[R.result.imageUrl]:[]);R.status==="completed"&&Se.length>0?(E++,L.set(je,{images:Se,labels:((Oe=(Ne=R.result)==null?void 0:Ne.variations)==null?void 0:Oe.map(ye=>ye.label))||[]})):R.status==="failed"||R.status==="cancelled"?xe++:F=!1}const Ke=Ie.size,ns=E+xe;if(Bs(Math.round(ns/Ke*100)),ct(ns),mt(L),F){Rs.current&&(clearInterval(Rs.current),Rs.current=null);const je=[],Ye=[];for(const[R]of Ie){const Se=L.get(R);if(Se){const ye=Gl.get(R),Ns=(ye==null?void 0:ye.productName)||"",Us=Se.labels.length>0?Se.labels:Se.images.map(()=>{const bs=[];return ye!=null&&ye.ratio&&ye.ratio!=="null"&&bs.push(ye.ratio),ye!=null&&ye.framing&&ye.framing!=="null"&&ye.framing!=="auto"&&bs.push(String(ye.framing).replace(/_/g," ")),bs.join(" · ")||"Generated"});je.push(...Se.images),Ye.push(...Us.map(bs=>Ns?`${Ns} — ${bs}`:bs))}}je.length>0?(ni(!0),Bs(100),await new Promise(R=>setTimeout(R,1500)),St(je),Qr(Ye),ni(!1),ws([...Ie.keys()][0]||null),x("results"),xe>0?A.warning(`Completed with ${xe} failure${xe>1?"s":""}. ${je.length} images generated.`):A.success(`Generated ${je.length} images!`)):(A.error("All generations failed. Credits refunded."),x("settings")),ve(),Pe.invali
6dateQueries({queryKey:["library"]}),Pe.invalidateQueries({queryKey:["recent-creations"]}),ms(),Ct(new Map),Kr(new Map)}};return c(),Rs.current=setInterval(c,3e3),()=>{Rs.current&&(clearInterval(Rs.current),Rs.current=null)}},[Ie,qe,ve,Pe]);const In=s=>{oi(!1),n("/app/library")},Ht=s=>{dt(r=>{const a=new Set(r);return a.has(s)?a.delete(s):a.add(s),a})},Ui=s=>{ci(s),di(!0)},_n=s=>{var d,u;const r=f=>f.toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_|_$/g,"").substring(0,30),a=[],c=(g==null?void 0:g.title)||(y==null?void 0:y.productInfo.title);if(c&&a.push(r(c)),t!=null&&t.name&&a.push(r(t.name)),fe!=null&&fe.name&&a.push(r(fe.name)),(d=ge==null?void 0:ge.variations)!=null&&d.length&&Ae.size>0){const f=Array.from(Ae).sort((L,F)=>L-F),j=f[s%f.length],_=(u=ge.variations[j])==null?void 0:u.label;_&&a.push(r(_))}return a.push(String(s+1)),a.join("-")+".png"},vr=async s=>{const r=ls[s];try{const a=await fetch(r),c=a.headers.get("content-type"),d=Qn(c),u=_n(s).replace(/\.[^.]+$/,""),f=await a.blob(),j=URL.createObjectURL(f),_=document.createElement("a");_.href=j,_.download=`${u}${d}`,_.click(),URL.revokeObjectURL(j)}catch{A.error("Download failed")}},[xt,Fi]=i.useState(!1),[Ei,qi]=i.useState(0),oa=async s=>{const r=s?s.map(a=>ls[a]):ls;if(r.length!==0){if(r.length===1){await vr((s==null?void 0:s[0])??0);return}Fi(!0),qi(0);try{const a=new Date().toISOString().split("T")[0],c=(t==null?void 0:t.name)||"Virtual Try On Set",d=`${a}-${c} (VOVV.AI)`,u={},f=r.map((j,_)=>{const L=(s==null?void 0:s[_])??_,E=((Xl[L]||"").split(" — ")[0]||(g==null?void 0:g.title)||(y==null?void 0:y.productInfo.title)||"Generated").trim();return u[E]=(u[E]||0)+1,{url:j,workflow_name:d,scene_name:`${E}_${u[E]}`}});await Yn(f,d,j=>qi(j))}catch{A.error("Download failed")}finally{Fi(!1)}}},Tn=s=>A.info("Regenerating variation... (this would cost 1 credit)"),Jt=()=>be?{source:1,product:1,upload:1,library:1,settings:2,generating:3,results:3}[Q]||1:us?Q==="settings"&&Zr==="surfaces"?3:Q==="settings"&&Zr==="details"?4:{source:1,product:1,upload:1,"brand-profile":2,generating:5,results:5}[Q]||1:Qe?Q==="settings"&&Yr==="scenes"?2:Q==="settings"&&Yr==="final"?4:{source:1,product:1,upload:1,model:3,generating:5,results:5}[Q]||1:me?{source:1,product:1,upload:1,interaction:2,model:3,settings:4,generating:5,results:5}[Q]||1:De==="virtual-try-on"?{source:1,product:1,upload:1,"brand-profile":2,mode:2,model:3,pose:4,settings:5,generating:6,results:6}[Q]||1:X?{source:1,upload:2,settings:3,generating:4,results:4}[Q]||1:cs&&(U!=null&&U.skip_template)?U!=null&&U.show_model_picker?{source:1,product:1,upload:1,"brand-profile":2,mode:2,model:3,settings:4,generating:5,results:5}[Q]||1:{source:1,product:1,upload:1,"brand-profile":2,mode:2,settings:3,generating:4,results:4}[Q]||1:{source:1,product:1,upload:1,"brand-profile":2,mode:2,template:3,settings:4,generating:5,results:5}[Q]||1,Oi=()=>be?[{name:ae==="scratch"?"Upload":ae==="library"?"Library":"Product(s)"},{name:"Settings"},{name:"Results"}]:us?[{name:ae==="scratch"?"Source":"Product(s)"},{name:"Brand"},{name:"Surfaces"},{name:"Details"},{name:"Results"}]:Qe?[{name:ae==="scratch"?"Source":"Product"},{name:"Scenes"},{name:"Model"},{name:"Settings"},{name:"Results"}]:me?[{name:ae==="scratch"?"Source":"Product"},{name:"Interaction"},{name:"Model"},{name:"Settings"},{name:"Results"}]:De==="virtual-try-on"?[{name:ae==="scratch"?"Source":"Product"},{name:"Brand"},{name:"Model"},{name:"Scene"},{name:"Settings"},{name:"Results"}]:X?[{name:"Type"},{name:"Upload Photo"},{name:"Style"},{name:"Results"}]:cs&&(U!=null&&U.skip_template)?U!=null&&U.show_model_picker?[{name:ae==="scratch"?"Source":"Product"},{name:"Brand"},{name:"Model"},{name:"Settings"},{name:"Results"}]:[{name:ae==="scratch"?"Source":"Product"},{name:"Brand"},{name:"Settings"},{name:"Results"}]:[{name:ae==="scratch"?"Source":"Product"},{name:"Brand"},{name:"Template"},{name:"Settings"},{name:"Results"}],Tt=ht==="all"?3:ht==="front"?1:2,da=Math.max(1,as.size),ca=Ee.has("auto")?1:Math.max(1,Ee.size),Di=(me||Qe)&&Te.size>1?Te.size:1,ma=cs?Ae.size*Tt*da*ca*Di:parseInt(ze),zn=(us&&As.size>1?As.size-1:0)*2*ma,wr=Ge?qe.length:1,Nr=De==="virtual-try-on"?Math.max(1,Le.size):1,Gi=De==="virtual-try-on"?Math.max(1,Te.size):1,Qt=be?Ge?qe.length:1:0,Pn=be?Qt*15:0,An=be?0:De==="virtual-try-on"&&!me&&!Qe?parseInt(ze)*6*Nr*Gi*da*ca:cs?ma*6:parseInt(ze)*6*Nr,fs=be?Pn:An*wr+zn,Mn=t?`Create: ${t.name}`:"Generate Visuals";return e.jsxs(e.Fragment,{children:[be&&e.jsxs(w,{variant:"ghost",size:"sm",onClick:()=>n("/app/workflows"),className:"gap-1.5 -ml-2 mb-2 self-start",children:[e.jsx(co,{className:"w-4 h-4"}),"Visual Studio"]}),e.jsxs(eo,{title:be?"Image Upscaling":Mn,subtitle:be?"Enhance images to 4K, print-ready resolution":void 0,backAction:be?void 0:{content:t?"Visual Studio":"Dashboard",onAction:()=>n(t?"/app/workflows":"/app")},children:[e.jsx(Zn,{title:"Generate — VOVV.AI",description:"Generate AI product visuals.",noindex:!0}),e.jsxs("div",{className:"space-y-6 overflow-x-hidden",children:[t&&!be&&e.jsx(hs,{className:"hidden sm:block",children:e.jsx(ps,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold",children:t.name}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t.description})]}),e.jsx(de,{variant:"secondary",children:t.uses_tryon?"Try-On":"Visual Type"})]})})}),H&&e.jsx(hs,{className:"border-primary/20 bg-primary/5",children:e.jsx(ps,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(Vs,{className:"w-4 h-4 text-primary shrink-0"}),e.jsx("span",{className:"text-muted-foreground",children:"Recreating look from Explore"}),H.modelName&&e.jsxs(de,{variant:"secondary",className:"text-xs gap-1.5 pl-1 pr-2",children:[H.modelImageUrl&&e.jsx("img",{src:K(H.modelImageUrl,{quality:40}),alt:"",className:"w-5 h-5 rounded object-cover"}),H.modelName]}),H.sceneName&&e.jsxs(de,{variant:"secondary",className:"text-xs gap-1.5 pl-1 pr-2",children:[H.sceneImageUrl&&e.jsx("img",{src:K(H.sceneImageUrl,{quality:40}),alt:"",className:"w-5 h-5 rounded object-cover"}),H.sceneName]})]}),e.jsx("button",{onClick:()=>
6pe(null),className:"text-muted-foreground/60 hover:text-foreground",children:e.jsx(Fs,{className:"w-4 h-4"})})]})})}),e.jsx(re,{children:e.jsx(le,{className:"p-4",children:e.jsx("div",{className:"flex items-center justify-center gap-1 sm:gap-2 overflow-hidden",children:Oi().map((s,r)=>e.jsxs("div",{className:"flex items-center gap-1 sm:gap-2 min-w-0",children:[e.jsx("div",{className:`w-6 h-6 sm:w-7 sm:h-7 rounded-full flex items-center justify-center text-[10px] sm:text-xs font-medium flex-shrink-0 ${Jt()>r+1||Jt()===r+1?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground"}`,children:Jt()>r+1?"✓":r+1}),e.jsx("span",{className:`text-xs hidden md:inline truncate ${Jt()===r+1?"font-semibold":"text-muted-foreground"}`,children:s.name}),r<Oi().length-1&&e.jsx("div",{className:`w-3 sm:w-6 md:w-10 h-0.5 flex-shrink ${Jt()>r+1?"bg-primary":"bg-muted"}`})]},s.name))})})}),Q==="source"&&X&&e.jsx(re,{children:e.jsxs(le,{className:"p-5 space-y-5",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold",children:"Choose Staging Type"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Are you staging an interior room or an exterior/facade?"})]}),e.jsx("div",{className:"grid grid-cols-2 gap-3",children:[{id:"interior",label:"Interior",desc:"Rooms & indoor spaces"},{id:"exterior",label:"Exterior",desc:"Building facades & outdoor"}].map(s=>e.jsxs("button",{type:"button",onClick:()=>on(s.id),className:G("p-4 sm:p-6 rounded-xl border-2 text-left transition-all cursor-pointer",Ve===s.id?"border-primary bg-primary/5 shadow-md":"border-border hover:border-primary/40"),children:[e.jsx("p",{className:"text-base sm:text-lg font-semibold",children:s.label}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:s.desc}),Ve===s.id&&e.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-primary"}),e.jsx("span",{className:"text-sm font-medium",children:"Selected"})]})]},s.id))}),e.jsx("div",{className:"flex justify-end",children:e.jsx(w,{onClick:()=>x("upload"),children:"Continue"})})]})}),Q==="source"&&!X&&e.jsx(re,{children:e.jsxs(le,{className:"p-5 space-y-5",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold",children:t!=null&&t.uses_tryon?"Add Your Product":"How do you want to start?"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t!=null&&t.uses_tryon?"Choose a clothing item from your products or upload a new photo to try on.":"Choose whether to use existing products or upload your own image file."})]}),t!=null&&t.uses_tryon?e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsx("button",{type:"button",onClick:()=>{Hs("product"),rs(null),Ts(null)},className:`p-4 sm:p-6 rounded-xl border-2 transition-all duration-200 text-left cursor-pointer ${ae==="product"?"border-primary bg-primary/5 shadow-md":"border-border hover:border-primary/50 hover:bg-muted"}`,children:e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:`w-10 h-10 sm:w-12 sm:h-12 rounded-lg flex items-center justify-center ${ae==="product"?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground"}`,children:e.jsx(mo,{className:"w-5 h-5 sm:w-6 sm:h-6"})}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-base sm:text-lg font-semibold",children:"From My Products"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Select a clothing item you've already added to your product library"})]}),ae==="product"&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-primary"}),e.jsx("span",{className:"text-sm font-medium",children:"Selected"})]})]})}),e.jsx("button",{type:"button",onClick:()=>{Hs("scratch"),rs(null),Ts(null)},className:`p-4 sm:p-6 rounded-xl border-2 transition-all duration-200 text-left cursor-pointer ${ae==="scratch"?"border-primary bg-primary/5 shadow-md":"border-border hover:border-primary/50 hover:bg-muted"}`,children:e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:`w-10 h-10 sm:w-12 sm:h-12 rounded-lg flex items-center justify-center ${ae==="scratch"?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground"}`,children:e.jsx(Ma,{className:"w-5 h-5 sm:w-6 sm:h-6"})}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-base sm:text-lg font-semibold",children:"Upload New Photo"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Upload a clothing photo — model shots, mannequin, or hanger photos work best"})]}),ae==="scratch"&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-primary"}),e.jsx("span",{className:"text-sm font-medium",children:"Selected"})]})]})})]}):e.jsx(od,{sourceType:ae,onChange:s=>{Hs(s),rs(null),Ts(null),Ur(new Set)},showLibrary:be}),e.jsx("div",{className:"flex justify-end",children:e.jsx(w,{disabled:!ae,onClick:()=>x(ae==="product"?"product":ae==="library"?"library":"upload"),children:"Continue"})})]})}),Q==="upload"&&e.jsx(re,{children:e.jsxs(le,{className:"p-5 space-y-5",children:[e.jsxs("div",{className:G(t!=null&&t.uses_tryon&&!y?"grid grid-cols-1 lg:grid-cols-[1fr,220px] gap-4":""),children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold",children:X?"Upload Your Photo":t!=null&&t.uses_tryon?"Upload Your Clothing Photo":"Upload Your Image"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:X?"Upload a photo of the room or building you want to transform. Empty rooms or plain exteriors work best.":t!=null&&t.uses_tryon?"Upload a clear photo of the clothing item you want to try on.":"Upload a product image from your computer."})]}),X&&!y&&e.jsxs(hs,{className:"border-primary/20 bg-primary/5",children:[e.jsx(Aa,{className:"w-4 h-4 text-primary"}),e.jsx(ps,{className:"text-xs space-y-1",children:Ve==="interior"?e.jsxs("ul",{className:"list-disc list-inside text-muted-foreground",children:[e.jsx("li",{children:"Shoot from a corner to capture two walls for best depth"}),e.jsx("li",{children:"Use well-lit, daytime photos — avoid heavy shadows"}),e.jsx("li",{children:"Avoid extreme wide-angle or fisheye lens distortion"})]}):e.jsxs("ul",{className:"list-disc list-inside text-muted-foreground",children:[e.jsx("li",{children:"Shoot straight-on or at a 30° angle for best results"}),e.jsx("li",{children:"Include the full facade — avoid cutting off edges"}),e.jsx("li",{children:"Daytime photos with even lighting work best"})]})})]}),e.jsx(ud,{scratchUpload:y,onUpload:Ts,onRemove:()=>{Ts(null),Ea(!1)},onUpdateProductInfo:s=>{Ts(r=>r&&{...r,productInfo:s})},isUploading:Ga,variant:X?"room":"product",saveToLibrary:Fa,onSaveToLibraryChange:X?void 0:Ea,onBulkFiles:!X&&l?s=>Ua(s):void 0}),X&&lr.length>0&&!y&&e.jsxs(jl,{children:[e.jsxs(yl,{className:"flex items-center gap-2 text-sm text-muted-foreground hover:text-foreground transition-colors group w-full",children:[e.jsx(Nl,{className:"w-4 h-4 transition-transform group-data-[state=open]:rotate-180"}),"Or reuse a previous photo (",lr.length," available)"]}),e.jsx(vl,{className:"pt-3",children:e.jsx("div",{className:"grid grid-cols-3 sm:grid-cols-4 md:grid-cols-5 ga
6p-2",children:lr.slice(0,10).map(s=>e.jsx("button",{type:"button",onClick:()=>{Ts({file:new File([],s.name),previewUrl:s.url,uploadedUrl:s.url,productInfo:{title:"Uploaded Room",productType:"Room",description:""}})},className:"aspect-square rounded-lg overflow-hidden border-2 border-border hover:border-primary transition-colors bg-muted",children:e.jsx("img",{src:s.url,alt:"Previous upload",className:"w-full h-full object-cover",loading:"lazy"})},s.name))})})]}),X&&y&&e.jsx(re,{children:e.jsxs(le,{className:"p-5 space-y-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-semibold flex items-center gap-2",children:"Room Details"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Specify the space type and optional preferences"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(oe,{children:["Staging Purpose ",e.jsx("span",{className:"text-xs text-muted-foreground",children:"(optional)"})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:[{id:"real-estate",label:"Real Estate Listing"},{id:"design-portfolio",label:"Design Portfolio"},{id:"airbnb",label:"Airbnb / Rental"},{id:"personal",label:"Personal Inspiration"}].map(s=>e.jsx("button",{type:"button",onClick:()=>pn(xr===s.id?"":s.id),className:G("px-3 py-1.5 rounded-full text-sm font-medium transition-all border",xr===s.id?"bg-primary text-primary-foreground border-primary":"bg-card border-border hover:border-primary hover:bg-primary/5"),children:s.label},s.id))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(oe,{children:[Ve==="interior"?"Room Type":"Exterior Area"," ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsxs(Ze,{value:Os,onValueChange:fi,children:[e.jsx(Xe,{children:e.jsx(We,{placeholder:"Select room type..."})}),e.jsx(es,{children:(Ve==="interior"?gn:xn).map(s=>e.jsx(D,{value:s,children:s},s))})]})]}),Ve==="interior"&&e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border border-border bg-muted/30",children:[e.jsxs("div",{children:[e.jsx(oe,{className:"text-sm font-medium",children:"Empty Room"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Room has no furniture — stage from scratch"})]}),e.jsx(Jn,{checked:Kt,onCheckedChange:Ii})]}),Ve==="interior"&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs(oe,{children:["Furniture ",e.jsx("span",{className:"text-xs text-muted-foreground",children:"(how to handle existing pieces)"})]}),e.jsx("div",{className:"grid grid-cols-3 gap-2",children:[{value:"Keep & Restyle",label:"Keep & Restyle",desc:"Keep pieces, update style"},{value:"Replace All",label:"Replace All",desc:"Fully restage the room"},{value:"Keep Layout, Swap Style",label:"Keep Layout",desc:"Same layout, new pieces"}].map(s=>{const r=Kt&&s.value!=="Replace All";return e.jsxs("button",{type:"button",disabled:r,onClick:()=>{Ni(s.value),s.value==="Keep & Restyle"&&vi("Match Design Style")},className:G("rounded-lg border-2 p-3 text-left transition-colors",r&&"opacity-40 cursor-not-allowed",pr===s.value?"border-primary bg-primary/5":"border-border hover:border-primary/40"),children:[e.jsx("span",{className:"text-sm font-medium block",children:s.label}),e.jsx("span",{className:"text-xs text-muted-foreground",children:s.desc})]},s.value)})})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(oe,{children:[Ve==="interior"?"Room Size":"Area Size"," ",e.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",Ve==="interior"?"helps scale furniture":"helps scale elements",")"]})]}),e.jsxs(Ze,{value:Si,onValueChange:un,children:[e.jsx(Xe,{children:e.jsx(We,{})}),e.jsxs(es,{children:[e.jsx(D,{value:"Small",children:"Small (under 10 sqm / 100 sqft)"}),e.jsx(D,{value:"Medium",children:"Medium (10–20 sqm / 100–200 sqft)"}),e.jsx(D,{value:"Large",children:"Large (20–40 sqm / 200–400 sqft)"}),e.jsx(D,{value:"Very Large",children:"Very Large (40+ sqm / 400+ sqft)"})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs(oe,{className:"text-xs text-muted-foreground",children:["Exact Dimensions ",e.jsx("span",{className:"text-xs",children:"(optional)"})]}),e.jsx("input",{type:"text",placeholder:"e.g. 4.5m x 3.2m or 15ft x 10ft",value:aa,onChange:s=>Ti(s.target.value),className:"flex h-9 w-full rounded-md border border-input bg-background px-3 py-1 text-base md:text-sm r
6ing-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"})]})]}),Ve==="interior"&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs(oe,{children:["Ceiling Height ",e.jsx("span",{className:"text-xs text-muted-foreground",children:"(optional)"})]}),e.jsxs(Ze,{value:ra,onValueChange:_i,children:[e.jsx(Xe,{children:e.jsx(We,{})}),e.jsxs(es,{children:[e.jsx(D,{value:"Low",children:"Low (under 2.4m / 8ft)"}),e.jsx(D,{value:"Standard",children:"Standard (2.4–2.7m / 8–9ft)"}),e.jsx(D,{value:"High",children:"High (2.7m+ / 9ft+)"}),e.jsx(D,{value:"Double Height",children:"Double Height (5m+ / 16ft+)"})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs(oe,{className:"text-xs text-muted-foreground",children:["Exact Height ",e.jsx("span",{className:"text-xs",children:"(optional)"})]}),e.jsx("input",{type:"text",placeholder:"e.g. 2.8m or 9.5ft",value:ia,onChange:s=>zi(s.target.value),className:"flex h-9 w-full rounded-md border border-input bg-background px-3 py-1 text-base md:text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"})]})]})]}),Ve==="interior"&&e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(oe,{children:["Wall Color ",e.jsx("span",{className:"text-xs text-muted-foreground",children:"(optional)"})]}),e.jsxs(Ze,{value:bi,onValueChange:dn,children:[e.jsx(Xe,{children:e.jsx(We,{})}),e.jsx(es,{children:["Keep Original","White","Warm White","Light Gray","Beige / Cream","Sage Green","Navy Blue","Terracotta","Blush Pink","Charcoal","Olive Green"].map(s=>e.jsx(D,{value:s,children:s},s))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(oe,{children:["Flooring ",e.jsx("span",{className:"text-xs text-muted-foreground",children:"(optional)"})]}),e.jsxs(Ze,{value:ji,onValueChange:cn,children:[e.jsx(Xe,{children:e.jsx(We,{})}),e.jsx(es,{children:["Keep Original","Hardwood Light","Hardwood Dark","Marble White","Marble Dark","Ceramic Tiles","Carpet","Polished Concrete","Herringbone Parquet"].map(s=>e.jsx(D,{value:s,children:s},s))})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(oe,{children:[Ve==="interior"?"Furniture Style":"Outdoor Style"," ",e.jsx("span",{className:"text-xs text-muted-foreground",children:"(optional)"})]}),e.jsxs(Ze,{value:yi,onValueChange:vi,disabled:Ve==="interior"&&pr==="Keep & Restyle",children:[e.jsx(Xe,{className:Ve==="interior"&&pr==="Keep & Restyle"?"opacity-50":"",children:e.jsx(We,{})}),e.jsx(es,{children:(Ve==="interior"?["Match Design Style","Modern Minimalist","Mid-Century Modern","Scandinavian","Industrial","Traditional / Classic","Bohemian / Eclectic","Art Deco","Japandi","Coastal / Hampton"]:["Match Design Style","Modern","Tropical","Mediterranean","Rustic","Contemporary","Coastal","Desert / Arid","Japanese Garden","English Garden"]).map(s=>e.jsx(D,{value:s,children:s},s))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(oe,{children:["Lighting Mood ",e.jsx("span",{className:"text-xs text-muted-foreground",children:"(optional)"})]}),e.jsxs(Ze,{value:wi,onValueChange:mn,children:[e.jsx(Xe,{children:e.jsx(We,{})}),e.jsx(es,{children:(Ve==="interior"?["Keep Original","Warm & Cozy","Bright & Airy","Dramatic / Moody","Natural Daylight","Soft Evening / Golden Hour"]:["Keep Original","Golden Hour Glow","Bright Daylight","Dramatic Twilight","Soft Overcast","Night / Uplighting"]).map(s=>e.jsx(D,{value:s,children:s},s))})]})]})]}),Os&&Pi[Os]&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs(oe,{children:["Key Furniture & Features ",e.jsx("span",{className:"text-xs text-muted-foreground",children:"(optional — helps the AI pick the right pieces)"})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:Pi[Os].map(s=>{const r=Vt.includes(s);return e.jsx("button",{type:"button",onClick:()=>{ea(a=>r?a.filter(c=>c!==s):[...a,s])},className:G("px-3 py-1.5 rounded-full text-sm font-medium transition-all border",r?"bg-primary text-primary-foreground border-primary":"bg-card border-border hover:border-primary hover:bg-primary/5"),children:s},s)})}),Vt.length>0&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Selected: ",Vt.join(", ")
6]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(oe,{children:["Color Palette ",e.jsx("span",{className:"text-xs text-muted-foreground",children:"(optional)"})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:["Neutral / Earth Tones","Cool & Calming","Warm & Inviting","Monochrome","Bold & Vibrant","Pastel Soft"].map(s=>e.jsx("button",{type:"button",onClick:()=>Ci(gr===s?"":s),className:G("px-3 py-1.5 rounded-full text-sm font-medium transition-all border",gr===s?"bg-primary text-primary-foreground border-primary":"bg-card border-border hover:border-primary hover:bg-primary/5"),children:s},s))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(oe,{children:["Natural Light / Time of Day ",e.jsx("span",{className:"text-xs text-muted-foreground",children:"(optional)"})]}),e.jsxs(Ze,{value:ta,onValueChange:ki,children:[e.jsx(Xe,{children:e.jsx(We,{})}),e.jsx(es,{children:["As Photographed","Morning Light","Midday Bright","Golden Hour","Blue Hour / Twilight","Overcast Soft"].map(s=>e.jsx(D,{value:s,children:s},s))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(oe,{children:["Design Notes ",e.jsx("span",{className:"text-xs text-muted-foreground",children:"(optional)"})]}),e.jsx($a,{placeholder:"e.g. client prefers warm Japandi feel, no curtains, maximize natural light, shutters only...",value:sa,onChange:s=>
6hn(s.target.value),className:"min-h-[60px]"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Add specific instructions for the AI designer"})]})]})]})})]}),(t==null?void 0:t.uses_tryon)&&!y&&e.jsx("div",{className:"order-first lg:order-last",children:e.jsx(xd,{})})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx(w,{variant:"outline",onClick:()=>x("source"),children:"Back"}),e.jsx(w,{disabled:!y||!X&&!be&&(!y.productInfo.title||!y.productInfo.productType)||X&&!Os,onClick:async()=>{if(!y)return;let s=y.uploadedUrl;if(s||(s=await Ml(y.file)||void 0),s)if(Ts({...y,uploadedUrl:s}),Fa&&l&&Me.from("user_products").insert({user_id:l.id,title:y.productInfo.title,product_type:y.productInfo.productType,description:y.productInfo.description,image_url:s,analysis_json:y.productInfo.category?{category:y.productInfo.category,userCategory:y.productInfo.category}:null}).then(({error:r})=>{r||Pe.invalidateQueries({queryKey:["user-products"]})}),be)x("settings");else if(me)x("interaction");else if(t!=null&&t.uses_tryon)x(os.length>0?"brand-profile":"model");else if(X)x("settings");else if(os.length>0)x("brand-profile");else if(U!=null&&U.skip_template&&cs)x("settings");else{const r=["leggings","hoodie","t-shirt","sports bra","jacket","tank top","joggers"].some(a=>y.productInfo.productType.toLowerCase().includes(a));x(r?"mode":"template")}},children:Ga?"Uploading...":"Continue"})]})]})}),Q==="product"&&e.jsxs("div",{className:"space-y-4 pb-20",children:[e.jsx(re,{children:e.jsxs(le,{className:"p-5 space-y-5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold",children:us?"Select Products for Flat Lay":me||Qe?"Select Product":t!=null&&t.uses_tryon?"Select Clothing Item(s)":"Select Product(s)"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:us?"Select 1–3 products to arrange together in your flat lay composition":me||Qe?"Choose the product to feature in this generation":t!=null&&t.uses_tryon?"Choose one or more clothing items to try on a model.":"Pick one or more products"})]}),e.jsx(w,{variant:"link",onClick:()=>x("source"),children:"Change source"})]}),sn,Bt?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(Ws,{className:"w-6 h-6 animate-spin text-muted-foreground"})}):we.length===0?t!=null&&t.uses_tryon?(()=>{const s=me?ba:fa;return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(de,{variant:"secondary",className:"text-[10px] uppercase tracking-wider",children:"Sample"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Try with a sample product, or add your own"})]}),e.jsx("div",{className:`relative rounded-lg border-2 cursor-pointer transition-all overflow-hidden ${W.has(s.id)?"border-primary ring-2 ring-primary/20":"border-border hover:border-primary/40"}`,onClick:()=>{const r=new Set(W);r.has(s.id)?(r.delete(s.id),rs(null)):(r.clear(),r.add(s.id),rs(s)),gs(r)},children:e.jsxs("div",{className:"flex items-center gap-4 p-3",children:[e.jsx("div",{className:"w-20 h-20 rounded-md overflow-hidden bg-muted flex-shrink-0",children:e.jsx("img",{src:K(s.images[0].url,{quality:60}),alt:s.title,className:"w-full h-full object-cover"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:s.title}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s.productType}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1 line-clamp-2",children:s.description})]}),W.has(s.id)&&e.jsx(et,{className:"w-5 h-5 text-primary flex-shrink-0"})]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"flex-1 border-t border-border"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"or"}),e.jsx("div",{className:"flex-1 border-t border-border"})]}),e.jsxs("div",{className:"flex items-center justify-center gap-3",children:[e.jsx(w,{variant:"outline",size:"sm",onClick:()=>Ot(!0),children:"Add Your Products"}),e.jsx(w,{variant:"secondary",size:"sm",onClick:()=>{Hs("scratch"),x("upload")},children:"Upload Instead"})]})]})})():(()=>{const s=Qe?_r:Ir;return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(de,{variant:"secondary",className:"text-[10px] uppercase tracking-wider",children:"Sample"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Try with a sample product, or add your own"})]}),e.jsx("div",{className:`relative rounded-lg border-2 cursor-pointer transition-all overflow-hidden ${W.has(s.id)?"border-primary ring-2 ring-primary/20":"border-border hover:border-primary/40"}`,onClick:()=>{const r=new Set(W);r.has(s.id)?(r.delete(s.id),rs(null)):(r.clear(),r.add(s.id),rs(s)),gs(r)},children:e.jsxs("div",{className:"flex items-center gap-4 p-3",children:[e.jsx("div",{className:"w-20 h-20 rounded-md overflow-hidden bg-muted flex-shrink-0",children:e.jsx("img",{src:K(s.images[0].url,{quality:60}),alt:s.title,className:"w-full h-full object-cover",loading:"eager"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:s.title}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s.productType}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1 line-clamp-2",children:s.description})]}),W.has(s.id)&&e.jsx(et,{className:"w-5 h-5 text-primary flex-shrink-0"})]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"flex-1 border-t border-border"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"or"}),e.jsx("div",{className:"flex-1 border-t border-border"})]}),e.jsxs("div",{className:"flex items-center justify-center gap-3",children:[e.jsx(w,{variant:"outline",size:"sm",onClick:()=>Ot(!0),children:"Add Your Products"}),e.jsx(w,{variant:"secondary",size:"sm",onClick:()=>{Hs("scratch"),x("upload")},children:"Upload Instead"})]})]})})():t!=null&&t.uses_tryon?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(Tr,{className:"absolute left-3.5 to
6p-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),e.jsx(st,{placeholder:"Search by name, type, color, SKU, tag…",value:ys,onChange:s=>{Ut(s.target.value),Je(ss)},className:"h-10 text-sm pl-10 pr-4 rounded-full"})]}),!Fe&&e.jsxs(e.Fragment,{children:[e.jsx(w,{size:"sm",variant:"outline",className:"h-8 text-xs",onClick:()=>{const s=we.filter(r=>ds(r,ys));gs(new Set(s.slice(0,ks).map(r=>r.id)))},children:"Select All"}),e.jsx(w,{size:"sm",variant:"outline",className:"h-8 text-xs",onClick:()=>gs(new Set),children:"Clear"})]}),e.jsxs("div",{className:"flex border border-border rounded-md overflow-hidden",children:[e.jsx("button",{onClick:()=>ue("grid"),className:G("p-1.5 transition-colors",C==="grid"?"bg-accent text-accent-foreground":"text-muted-foreground hover:bg-muted"),children:e.jsx(uo,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>ue("list"),className:G("p-1.5 transition-colors",C==="list"?"bg-accent text-accent-foreground":"text-muted-foreground hover:bg-muted"),children:e.jsx(ho,{className:"w-3.5 h-3.5"})})]})]}),!Fe&&W.size>0&&e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsxs(de,{variant:W.size>=2?"default":"secondary",children:[W.size," selected"]}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["(max ",ks,")"]})]}),(()=>{const s=we.filter(c=>ds(c,ys)),r=s.slice(0,ts),a=!Fe;return s.length===0&&ys?e.jsxs("p",{className:"text-center text-sm text-muted-foreground py-6",children:['No products match "',ys,'"']}):C==="list"?e.jsx("div",{className:"space-y-1 max-h-[420px] overflow-y-auto pr-1",children:r.map(c=>{const d=W.has(c.id),u=!d&&a&&W.size>=ks;return e.jsxs("button",{type:"button",onClick:()=>{if(a){const f=new Set(W);f.has(c.id)?f.delete(c.id):f.size<ks&&f.add(c.id),gs(f)}else gs(new Set([c.id]))},disabled:u,className:G("w-full flex items-center gap-3 px-3 py-2 rounded-lg border-2 transition-all text-left",d?"border-primary bg-primary/5":"border-transparent hover:bg-muted/50",u&&"opacity-40 cursor-not-allowed"),children:[e.jsx(Gs,{src:K(c.image_url,{quality:60}),alt:c.title,className:"w-10 h-10 rounded-md object-cover flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium text-foreground truncate",children:c.title}),c.product_type&&e.jsx("p",{className:"text-[10px] text-muted-foreground truncate",children:c.product_type})]}),a&&e.jsx("div",{className:G("w-5 h-5 rounded-full border-2 flex items-center justify-center flex-shrink-0 transition-colors",d?"border-primary bg-primary text-primary-foreground":"border-muted-foreground/30"),children:d&&e.jsx(Is,{className:"w-3 h-3"})})]},c.id)})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-3 sm:grid-cols-4 md:grid-cols-5 lg:grid-cols-6 gap-3",children:[r.map(c=>{const d=W.has(c.id),u=!d&&a&&W.size>=ks;return e.jsxs("button",{type:"button",onClick:()=>{if(a){const f=new Set(W);f.has(c.id)?f.delete(c.id):f.size<ks&&f.add(c.id),gs(f)}else gs(new Set([c.id]))},disabled:u,className:G("group relative flex flex-col rounded-lg overflow-hidden border-2 transition-all text-left",d?"border-primary ring-2 ring-primary/30":"border-transparent hover:border-border",u&&"opacity-40 cursor-not-allowed"),children:[a&&e.jsx("div",{className:G("absolute top-1.5 left-1.5 z-10 w-5 h-5 rounded-full border-2 flex items-center justify-center transition-all",d?"border-primary bg-primary text-primary-foreground shadow-md":"border-background/80 bg-background/60 opacity-0 group-hover:opacity-100"),children:d&&e.jsx(Is,{className:"w-3 h-3"})}),e.jsx(Gs,{src:K(c.image_url,{quality:60}),alt:c.title,className:"w-full aspect-square object-cover rounded-t-md"}),e.jsxs("div",{className:"px-1.5 py-1.5 bg-card",children:[e.jsx("p",{className:"text-[10px] font-medium text-foreground leading-tight line-clamp-2",children:c.title}),c.product_type&&e.jsx("p",{className:"text-[9px] text-muted-foreground truncate mt-0.5",children:c.product_type})]})]},c.id)}),e.jsxs("button",{type:"button",onClick:()=>Ot(!0),className:"flex flex-col items-center justify-center rounded-lg border-2 border-dashed border-border hover:border-primary/40 hover:bg-muted/50 transition-all aspect-square text-muted-foreground",children:[e.jsx(Pr,{className:"w-6 h-6 mb-1 opacity-50"}),e.jsx("span",{className:"text-[10px] font-medium",children:"Add New"})]})]}),s.length>ts&&e.jsxs(w,{variant:"outline",size:"sm",onClick:()=>Je(c=>c+ss),className:"w-full mt-3",children:["Load more (",s.length-ts," remaining)"]})]})})()]}):e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(Tr,{className:"absolute left-3.5 to
6p-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),e.jsx(st,{placeholder:"Search by name, type, color, SKU, tag…",value:ys,onChange:s=>{Ut(s.target.value),Je(ss)},className:"h-10 text-sm pl-10 pr-4 rounded-full"})]}),e.jsx(w,{variant:"outline",className:"h-10 rounded-full px-4 text-sm",onClick:()=>{const s=we.filter(r=>ds(r,ys));gs(new Set(s.slice(0,ks).map(r=>r.id)))},children:"Select All"}),e.jsx(w,{variant:"outline",className:"h-10 rounded-full px-4 text-sm",onClick:()=>gs(new Set),children:"Clear"})]}),W.size>0&&e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsxs(de,{variant:W.size>=2?"default":"secondary",children:[W.size," selected"]}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["(max ",ks,")"]})]}),(()=>{const s=we.filter(a=>ds(a,ys)),r=s.slice(0,ts);return s.length===0&&ys?e.jsxs("p",{className:"text-center text-sm text-muted-foreground py-6",children:['No products match "',ys,'"']}):C==="list"?e.jsx("div",{className:"space-y-1 max-h-[420px] overflow-y-auto pr-1",children:s.map(a=>{const c=W.has(a.id),d=!c&&W.size>=ks;return e.jsxs("button",{type:"button",onClick:()=>{const u=new Set(W);u.has(a.id)?u.delete(a.id):u.size<ks&&u.add(a.id),gs(u)},disabled:d,className:G("w-full flex items-center gap-3 px-3 py-2 rounded-lg border-2 transition-all text-left",c?"border-primary bg-primary/5":"border-transparent hover:bg-muted/50",d&&"opacity-40 cursor-not-allowed"),children:[e.jsx(Gs,{src:K(a.image_url,{quality:60}),alt:a.title,className:"w-10 h-10 rounded-md object-cover flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium text-foreground truncate",children:a.title}),a.product_type&&e.jsx("p",{className:"text-[10px] text-muted-foreground truncate",children:a.product_type})]}),e.jsx("div",{className:G("w-5 h-5 rounded-full border-2 flex items-center justify-center flex-shrink-0 transition-colors",c?"border-primary bg-primary text-primary-foreground":"border-muted-foreground/30"),children:c&&e.jsx(Is,{className:"w-3 h-3"})})]},a.id)})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-3 sm:grid-cols-4 md:grid-cols-5 lg:grid-cols-6 gap-3",children:[r.map(a=>{const c=W.has(a.id),d=!c&&W.size>=ks;return e.jsxs("button",{type:"button",onClick:()=>{const u=new Set(W);u.has(a.id)?u.delete(a.id):u.size<ks&&u.add(a.id),gs(u)},disabled:d,className:G("group relative flex flex-col rounded-lg overflow-hidden border-2 transition-all text-left",c?"border-primary ring-2 ring-primary/30":"border-transparent hover:border-border",d&&"opacity-40 cursor-not-allowed"),children:[e.jsx("div",{className:G("absolute top-1.5 left-1.5 z-10 w-5 h-5 rounded-full border-2 flex items-center justify-center transition-all",c?"border-primary bg-primary text-primary-foreground shadow-md":"border-background/80 bg-background/60 opacity-0 group-hover:opacity-100"),children:c&&e.jsx(Is,{className:"w-3 h-3"})}),e.jsx(Gs,{src:K(a.image_url,{quality:60}),alt:a.title,className:"w-full aspect-square object-cover rounded-t-md"}),e.jsxs("div",{className:"px-1.5 py-1.5 bg-card",children:[e.jsx("p",{className:"text-[10px] font-medium text-foreground leading-tight line-clamp-2",children:a.title}),a.product_type&&e.jsx("p",{className:"text-[9px] text-muted-foreground truncate mt-0.5",children:a.product_type})]})]},a.id)}),e.jsxs("button",{type:"button",onClick:()=>Ot(!0),className:"flex flex-col items-center justify-center rounded-lg border-2 border-dashed border-border hover:border-primary/40 hover:bg-muted/50 transition-all aspect-square text-muted-foreground",children:[e.jsx(Pr,{className:"w-6 h-6 mb-1 opacity-50"}),e.jsx("span",{className:"text-[10px] font-medium",children:"Add New"})]})]}),s.length>ts&&e.jsxs(w,{variant:"outline",size:"sm",onClick:()=>Je(a=>a+ss),className:"w-full mt-3",children:["Load more (",s.length-ts," remaining)"]})]})})()]})]})}),e.jsx("div",{className:"fixed bottom-4 left-0 right-0 lg:left-[var(--sidebar-offset)] z-50 px-4",children:e.jsxs("div",{className:"max-w-3xl mx-auto bg-background border border-border rounded-2xl shadow-lg p-4 flex items-center justify-between gap-4",children:[e.jsx(w,{variant:"outline",onClick:()=>x("source"),children:"Back"}),W.size===0&&e.jsx("span",{className:"text-xs text-muted-foreground text-center flex-1",children:"Select a product to continue"}),e.jsx(w,{disabled:W.size===0,onClick:()=>{var s,r,a,c;if(t!=null&&t.uses_tryon){const d=we.filter(j=>W.has(j.id)).map(j=>br(j)),u=[fa,ba,_r].filter(j=>W.has(j.id)),f=[...d,...u];
6if(f.length>0)if(rs(f[0]),Es(new Set([f[0].images[0].id])),f.length>1)if(Js(f),ct(0),mt(new Map),Qe)Dt("scenes"),x("settings");else if(me){const j=Qs(f[0]);_t(((s=j[0])==null?void 0:s.id)??null),x("interaction")}else x(os.length>0?"brand-profile":"model");else if(Js([]),me){const j=Qs(f[0]);_t(((r=j[0])==null?void 0:r.id)??null),x("interaction")}else x(os.length>0?"brand-profile":"model")}else{const d=Qe?_r:Ir,f=(we.length>0?we.map(j=>br(j)):[d]).filter(j=>W.has(j.id));if(us){an(new Set(f.map(j=>j.id))),rs(f[0]),f[0].images.length>0&&Es(new Set([f[0].images[0].id])),os.length>0?x("brand-profile"):(Xr("surfaces"),x("settings"));return}if(Qe){rs(f[0]),f[0].images.length>0&&Es(new Set([f[0].images[0].id])),f.length>1?(Js(f),ct(0),mt(new Map)):Js([]),Dt("scenes"),x("settings");return}if(f.length===1){const j=f[0];rs(j),j.images.length>0&&Es(new Set([j.images[0].id]));const _=jr(j);if(_&&Er(_),be)x("settings");else if(me){const L=Qs(j);_t(((a=L[0])==null?void 0:a.id)??null),x("interaction")}else os.length>0?x("brand-profile"):U!=null&&U.show_model_picker?x("model"):U!=null&&U.skip_template&&cs?x("settings"):fr(j)?x("mode"):x("template")}else{Js(f),ct(0),mt(new Map);const j=f[0];rs(j),j.images.length>0&&Es(new Set([j.images[0].id]));const _=jr(j);if(_&&Er(_),be)x("settings");else if(me){const L=Qs(j);_t(((c=L[0])==null?void 0:c.id)??null),x("interaction")}else os.length>0?x("brand-profile"):U!=null&&U.show_model_picker?x("model"):U!=null&&U.skip_template&&cs?x("settings"):fr(j)?x("mode"):x("template")}}},children:W.size===0?"Select at least 1":t!=null&&t.uses_tryon?`Continue with ${W.size} product${W.size>1?"s":""}`:us?`Continue with ${W.size} product${W.size>1?"s":""}`:W.size===1?"Continue with 1 product":`Continue with ${W.size} products`})]})})]}),Q==="library"&&e.jsx(re,{children:e.jsxs(le,{className:"p-5 space-y-5",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-1 sm:gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h2",{className:"text-base font-semibold",children:"Select from Library"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Pick up to 10 images to remix"})]}),e.jsx(w,{variant:"link",size:"sm",className:"self-start sm:self-auto -ml-3 sm:ml-0 px-0 sm:px-2 h-auto",onClick:()=>x("source"),children:"Change"})]}),e.jsxs("div",{className:"relative",children:[e.jsx(Tr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),e.jsx(st,{placeholder:"Search",value:or,onChange:s=>Pl(s.target.value),className:"h-9 text-sm pl-9 rounded-full"})]}),Ms.size>0&&e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsxs(de,{variant:"default",children:[Ms.size," selected"]}),e.jsx(w,{size:"sm",variant:"ghost",className:"h-6 text-xs",onClick:()=>Ur(new Set),children:"Clear"})]}),Al?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(Ws,{className:"w-6 h-6 animate-spin text-muted-foreground"})}):Fr.length===0?e.jsxs("div",{className:"text-center py-10 space-y-3",children:[e.jsx(tr,{className:"w-12 h-12 mx-auto text-muted-foreground/30"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No generated images in your library yet."}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Generate some images first, then come back here to create new perspectives."})]}):(()=>{const s=Fr.filter(a=>!or||a.label.toLowerCase().includes(or.toLowerCase())),r=s.slice(0,Oa);return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"grid grid-cols-3 sm:grid-cols-4 md:grid-cols-5 lg:grid-cols-6 gap-3",children:r.map(a=>{const c=Ms.has(a.id),d=!c&&Ms.size>=10;return e.jsxs("button",{type:"button",onClick:()=>{const u=new Set(Ms);u.has(a.id)?u.delete(a.id):u.size<10&&u.add(a.id),Ur(u)},disabled:d,className:G("group relative flex flex-col rounded-lg overflow-hidden border-2 transition-all text-left",c?"border-primary ring-2 ring-primary/30":"border-transparent hover:border-border",d&&"opacity-40 cursor-not-allowed"),children:[e.jsx("div",{className:G("absolute top-1.5 left-1.5 z-10 w-5 h-5 rounded-full border-2 flex items-center justify-center transition-all",c?"border-primary bg-primary text-primary-foreground shadow-md":"border-background/80 bg-background/60 opacity-0 group-hover:opacity-100"),children:c&&e.jsx(Is,{className:"w-3 h-3"})}),e.jsx("img",{src:K(a.imageUrl,{quality:55}),alt:a.label,className:"w-full aspect-square object-cover rounded-t-md",loading:"lazy",decoding:"async"}),e.jsxs("div",{className:"px-1.5 py-1.5 bg-card",children:[e.jsx("p",{className:"text-[10px] font-medium text-foreground leading-tight line-clamp-2",children:a.label}),e.jsx("p",{className:"text-[9px] text-muted-foreground truncate mt-0.5",children:new Date(a.createdAt).toLocaleDateString("en-US",{month:"short",day:"numeric"})})]})]},a.id)})}),s.length>Oa&&e.jsx("div",{className:"flex justify-center pt-1",children:e.jsx(w,{variant:"outline",size:"sm",className:"rounded-full px-5",onClick:()=>Da(a=>a+12),children:"Load more"})})]})})(),e.jsxs("div",{className:"flex justify-between",children:[e.jsx(w,{variant:"outline",onClick:()=>x("source"),children:"Back"}),e.jsx(w,{disabled:Ms.size===0,onClick:()=>{const s=Fr.filter(r=>Ms.has(r.id));if(s.length===1){const r=s[0];rs({id:r.id,title:r.label,vendor:"Library",productType:"Generated",tags:[],description:"",images:[{id:r.id,url:r.imageUrl}],status:"active",createdAt:r.createdAt,updatedAt:r.createdAt}),Es(new Set([r.id])),x("settings")}else{const r=s.map(a=>({id:a.id,title:a.label,vendor:"Library",productType:"Generated",tags:[],description:"",images:[{id:a.id,url:a.imageUrl}],status:"active",createdAt:a.createdAt,updatedAt:a.createdAt}));
6Js(r),ct(0),mt(new Map),rs(r[0]),Es(new Set([r[0].images[0].id])),x("settings")}},children:Ms.size===0?"Select at least 1":`Continue with ${Ms.size} image${Ms.size>1?"s":""}`})]})]})}),Q==="brand-profile"&&e.jsx(re,{children:e.jsxs(le,{className:"p-5 space-y-5",children:[e.jsxs("div",{children:[e.jsxs("h2",{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(zr,{className:"w-5 h-5 text-primary"}),"Select Brand Profile"]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Apply your brand's visual identity to this generation."})]}),os.length>0?e.jsx("div",{className:"space-y-3",children:os.map(s=>e.jsx("div",{onClick:()=>$l(s.id),className:`p-4 rounded-lg border-2 cursor-pointer transition-all ${nt===s.id?"border-primary bg-primary/5":"border-border hover:border-primary/30"}`,children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:s.name}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[s.tone," · ",s.lighting_style," · ",s.background_style]})]}),e.jsx(de,{variant:"secondary",className:"capitalize",children:s.tone})]})},s.id))}):e.jsxs("div",{className:"text-center py-6",children:[e.jsx(zr,{className:"w-10 h-10 text-muted-foreground mx-auto mb-3"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No brand profiles yet."}),e.jsx(w,{variant:"link",onClick:()=>n("/app/brand-profiles"),children:"Create one"})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx(w,{variant:"outline",onClick:()=>x(ae==="scratch"?"upload":"product"),children:"Back"}),e.jsxs("div",{className:"flex gap-2",children:[!nt&&e.jsx(w,{variant:"ghost",onClick:$i,children:"Skip"}),e.jsx(w,{onClick:$i,disabled:!1,children:nt?"Continue":"Continue without profile"})]})]})]})}),Q==="interaction"&&me&&(g||y)&&e.jsx(re,{children:e.jsxs(le,{className:"p-5 space-y-5",children:[e.jsxs("div",{children:[e.jsxs("h2",{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(wa,{className:"w-5 h-5 text-primary"}),"How should the creator engage with your product?"]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Pick the action that best fits the shot you want — this drives the model's pose and the product's role in the frame."})]}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:Qs(g).map(s=>{const r=Gt===s.id;return e.jsxs("button",{type:"button",onClick:()=>_t(s.id),className:`text-left p-4 rounded-xl border-2 transition-all ${r?"border-primary bg-primary/5":"border-border hover:border-primary/30"}`,children:[e.jsx("div",{className:"text-2xl mb-2",children:s.emoji}),e.jsx("p",{className:"font-medium text-sm",children:s.label}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:s.description})]},s.id)})}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx(w,{variant:"outline",onClick:()=>x(ae==="scratch"?"upload":"product"),children:"Back"}),e.jsx(w,{disabled:!Gt,onClick:()=>x("model"),children:"Continue to Model"})]})]})}),Q==="mode"&&(g||y)&&e.jsx(re,{children:e.jsxs(le,{className:"p-5 space-y-5",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold",children:"Choose Generation Mode"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["How would you like to showcase your ",(g==null?void 0:g.title)||(y==null?void 0:y.productInfo.title),"?"]})]}),e.jsx("div",{className:"flex justify-center",children:e.jsx(sd,{mode:De,onChange:Va})}),De==="virtual-try-on"&&e.jsx(hs,{children:e.jsxs(ps,{children:[e.jsx("p",{className:"font-semibold",children:"✨ Virtual Try-On Mode"}),e.jsx("p",{className:"text-sm",children:"AI will digitally dress your selected model in your clothing. Uses 3 credits per image."})]})}),De==="product-only"&&e.jsx(hs,{children:e.jsx(ps,{children:"Standard product photography — flat lay, studio, or lifestyle shots."})}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(w,{variant:"outline",onClick:()=>x(os.length>0?"brand-profile":ae==="scratch"?"upload":"product"),children:"Back"}),e.jsx(w,{onClick:()=>x(De==="virtual-try-on"?"model":"template"),children:"Continue"})]})]})}),Q==="model"&&(g||y)&&e.jsxs("div",{className:"space-y-4 pb-20",children:[e.jsx(Ca,{product:g,scratchUpload:y,model:fe,models:Array.from($s.values()),pose:Et,credit
6Cost:fs,selectedGender:fe==null?void 0:fe.gender,products:Ge?qe:void 0}),e.jsx(re,{children:e.jsxs(le,{className:"p-5 space-y-4",children:[e.jsx("div",{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs("h2",{className:"text-base font-semibold",children:["Select Model",Fe?"":"s"]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:Qe?"This model will appear taking a mirror selfie wearing your product":Fe?"Choose the model who will wear your clothing":"Select one or more models for your shoot"})]}),Te.size>0&&e.jsxs(de,{variant:"secondary",className:"text-xs",children:[Te.size," selected",!Fe&&Te.size>0?` · ${Te.size*Math.max(1,Le.size)*parseInt(ze)*6*(Ge?qe.length:1)} credits`:""]})]})}),e.jsx(id,{genderFilter:qr,bodyTypeFilter:Or,ageFilter:Dr,onGenderChange:Ll,onBodyTypeChange:Bl,onAgeChange:Rl}),e.jsx("div",{className:"grid grid-cols-3 sm:grid-cols-4 md:grid-cols-5 lg:grid-cols-6 gap-3",children:bn.map(s=>e.jsx(To,{model:s,isSelected:Te.has(s.modelId),onSelect:()=>wn(s)},s.modelId))}),e.jsx(Na,{category:"model",title:"Missing a model? Tell us and we'll create it.",placeholder:"Describe the model you'd like us to create…"})]})}),e.jsx("div",{className:"fixed bottom-4 left-0 right-0 lg:left-[var(--sidebar-offset)] z-50 px-4",children:e.jsxs("div",{className:"max-w-3xl mx-auto bg-background border border-border rounded-2xl shadow-lg p-4 flex items-center justify-between gap-4",children:[e.jsx(w,{variant:"outline",onClick:()=>{Qe?(Dt("scenes"),x("settings")):x(me?"interaction":os.length>0?"brand-profile":"product")},children:"Back"}),Te.size===0&&e.jsx("span",{className:"text-xs text-muted-foreground text-center flex-1",children:"Select a model to continue"}),Qe?e.jsx(w,{disabled:Te.size===0,onClick:()=>{Dt("final"),x("settings")},children:"Continue to Settings"}):me||U!=null&&U.show_model_picker&&!(t!=null&&t.uses_tryon)?e.jsx(w,{disabled:Te.size===0,onClick:()=>x("settings"),children:"Continue to Settings"}):e.jsxs(w,{disabled:Te.size===0,onClick:()=>x("pose"),children:["Continue to Scene ",Te.size>1&&`(${Te.size} models)`]})]})})]}),Q==="pose"&&fe&&e.jsxs("div",{className:"space-y-4 pb-20",children:[e.jsx(Ca,{product:g,scratchUpload:y,model:fe,models:Array.from($s.values()),pose:Et,poses:Array.from(Le).map(s=>ot.get(s)).filter(Boolean),creditCost:fs,selectedGender:fe==null?void 0:fe.gender,products:Ge?qe:void 0}),e.jsx(re,{children:e.jsxs(le,{className:"p-5 space-y-4",children:[e.jsx("div",{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold",children:"Select Scenes"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:Fe?"Free plan: 1 scene per generation":"Select scenes for your shoot"})]}),e.jsxs(de,{variant:"secondary",className:"text-xs",children:[Le.size," selected",!Fe&&Le.size>0?` · ${Le.size*parseInt(ze)*6*(Ge?qe.length:1)} credits`:""]})]})}),Le.size>0&&e.jsxs("div",{className:"flex flex-wrap gap-2 p-3 bg-muted/50 rounded-lg border border-border/50",children:[e.jsx("span",{className:"text-xs text-muted-foreground self-center mr-1",children:"Selected:"}),Array.from(Le).map(s=>{const r=ot.get(s);return r?e.jsxs("div",{className:"flex items-center gap-1.5 bg-background rounded-md px-2 py-1 border border-border text-xs",children:[e.jsx("img",{src:K(r.previewUrl,{quality:50}),alt:r.name,className:"w-6 h-6 rounded object-cover"}),e.jsx("span",{className:"font-medium truncate max-w-[120px] text-foreground",children:r.name})]},s):null})]}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 gap-3",children:Object.values(yn).flat().map(s=>{const r=Le.has(s.poseId)?Array.from(Le).indexOf(s.poseId)+1:void 0;return e.jsx(Wo,{pose:s,isSelected:Le.has(s.poseId),onSelect:()=>Nn(s),selectedGender:fe==null?void 0:fe.gender,selectionIndex:r},s.poseId)})}),e.jsx(Na,{category:"scene",title:"Missing a scene? Tell us and we'll create it.",placeholder:"Describe the scene or environment you'd like…"})]})}),e.jsx("div",{className:"fixed bottom-4 left-0 right-0 lg:left-[var(--sidebar-offset)] z-50 px-4",children:e.jsxs("div",{className:"max-w-3xl mx-auto bg-background border border-border rounded-2xl shadow-lg p-4 flex items-center justify-between gap-4",children:[e.jsx(w,{variant:"outline",onClick:()=>x("model"),children:"Back"}),e.jsxs(w,{disabled:Le.size===0,onClick:()=>x("settings"),children:["Continue to Settings ",Le.size>0&&`(${Le.size} scene${Le.size>1?"s":""})`]})]})})]}),!cs&&(Q==="template"||Q==="settings"&&De==="product-only")&&(g||y)&&e.jsxs(e.Fragment,{children:[e.jsx(re,{children:e.jsxs(le,{className:"p-5 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:ae==="scratch"?"Uploaded Image":"Selected Product"}),e.jsx(w,{variant:"link",size:"sm",onClick:()=>x(ae==="scratch"?"upload":"source"),children:"Change"})]}),ae==="scratch"&&y?e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"w-16 h-16 rounded-lg overflow-hidden border border-border",children:e.jsx("img",{src:y.previewUrl,alt:"",className:"w-full h-full object-cover"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold",children:y.productInfo.title}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Custom Upload • ",y.productInfo.productType]})]})]}):g&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"w-16 h-16 rounded-lg overflow-hidden border border-border",children:e.jsx("img",{src:((Ki=g.images[0])==null?void 0:Ki.url)||"/placeholder.svg",alt:"",className:"w-full h-full object-cover"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold",children:g.title}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[g.vend
6or," • ",g.productType]}),e.jsx("div",{className:"flex gap-1 mt-1",children:g.tags.map(s=>e.jsx(de,{variant:"secondary",className:"text-xs",children:s},s))})]})]}),g.images.length>1&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(tt,{}),e.jsx("p",{className:"text-sm font-medium",children:"Source images for generation"}),e.jsx("div",{className:"flex flex-wrap gap-3",children:g.images.map(s=>{const r=vt.has(s.id);return e.jsxs("div",{onClick:()=>vn(s.id),className:`relative cursor-pointer rounded-lg overflow-hidden transition-all ${r?"ring-2 ring-primary ring-offset-2":"ring-1 ring-border hover:ring-primary"}`,children:[e.jsx("img",{src:K(s.url,{quality:60}),alt:"",loading:"lazy",className:"w-16 h-16 object-cover"}),r&&e.jsx("div",{className:"absolute inset-0 bg-primary/20 flex items-center justify-center",children:e.jsx("div",{className:"w-6 h-6 bg-primary rounded-full flex items-center justify-center",children:e.jsx(et,{className:"w-3 h-3 text-primary-foreground"})})})]},s.id)})})]})]}),Z&&e.jsx("div",{className:"pt-2 border-t border-border",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(zr,{className:"w-4 h-4 text-primary"}),e.jsx("span",{className:"text-sm font-medium",children:Z.name}),e.jsx(de,{variant:"secondary",className:"text-[10px] capitalize",children:Z.tone})]}),e.jsx(w,{variant:"link",size:"sm",onClick:()=>x("brand-profile"),children:"Change"})]})})]})}),Q==="template"&&e.jsxs("div",{className:zs?"pb-24":"",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx(hs,{children:e.jsx(ps,{children:"Visual Types define the photography style. Each Visual Type produces a different look."})}),(()=>{const s=((g==null?void 0:g.productType)||(y==null?void 0:y.productInfo.productType)||"").toLowerCase();let r="other";["sweater","shirt","apparel","hoodie","leggings","tank","jogger"].some(d=>s.includes(d))?r="garments":["serum","cream","beauty"].some(d=>s.includes(d))?r="beauty-skincare":["food","cereal"].some(d=>s.includes(d))?r="food":["coffee","tea","juice","beverage","drink"].some(d=>s.includes(d))?r="beverages":["sofa","couch","table","desk","chair","bed","shelf","cabinet","dresser","wardrobe","furniture"].some(d=>s.includes(d))?r="furniture":["decor","home","candle","vase","lamp","pillow"].some(d=>s.includes(d))?r="home-decor":["supplement","vitamin"].some(d=>s.includes(d))&&(r="supplements-wellness");const a=Pt.filter(d=>d.enabled&&d.category===r).slice(0,3);a.length<3&&a.push(...Pt.filter(d=>d.enabled&&d.category==="other").slice(0,3-a.length));const c=a.map(d=>d.templateId);return e.jsxs(e.Fragment,{children:[e.jsx(re,{children:e.jsxs(le,{className:"p-5 space-y-4",children:[e.jsxs("div",{children:[e.jsxs("h2",{className:"text-base font-semibold",children:["Top Picks for ",tl[r]]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Best Visual Types for ",s||"your"," products"]})]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-4",children:a.map(d=>e.jsx(dl,{template:{...d,recommended:!1},isSelected:(zs==null?void 0:zs.templateId)===d.templateId,onSelect:()=>Li(d),showCredits:!1},d.templateId))})]})}),e.jsx(re,{children:e.jsxs(le,{className:"p-5 space-y-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold",children:"Browse All Visual Types"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Explore all available photography styles"})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:fn.map(d=>e.jsx(w,{variant:lt===d.id?"default":"outline",size:"sm",onClick:()=>Er(d.id),children:d.label},d.id))}),(()=>{const d=Pt.filter(u=>u.enabled&&(lt==="all"||u.category===lt)&&!c.includes(u.templateId));return d.length>0?e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 gap-3",children:d.map(u=>e.jsx(dl,{template:{...u,recommended:!1},isSelected:(zs==null?void 0:zs.templateId)===u.templateId,onSelect:()=>Li(u),showCredits:!1},u.templateId))}):e.jsx("p",{className:"py-8 text-center text-sm text-muted-foreground",children:lt==="all"?"All Visual Types shown above.":`No additional ${tl[lt]} Visual Types.`})})()]})})]})})()]}),zs&&e.jsx("div",{className:"fixed bottom-0 left-0 right-0 bg-card border-t border-border p-4 shadow-lg z-30 lg:left-60",children:e.jsxs("div",{className:"max-w-7xl mx-auto flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("img",{src:xo(zs.templateId),alt:"",className:"w-10 h-10 rounded-lg object-cover"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold",children:zs.name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[fs," credits"]})]})]}),e.jsx(w,{onClick:()=>x("settings"),children:"Continue to Settings"})]})})]}),Q==="settings"&&De==="product-only"&&e.jsxs("div",{className:"space-y-4",children:[e.jsx(re,{children:e.jsxs(le,{className:"p-5 space-y-4",children:[e.jsx("h3",{className:"text-base font-semibold",children:"Generation Settings"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(oe,{children:"Number of Images"}),e.jsxs(Ze,{value:ze,onValueChange:s=>si(s),children:[e.jsx(Xe,{children:e.jsx(We,{})}),e.jsxs(es,{children:[e.jsx(D,{value:"1",children:"1 image"}),!Fe&&e.jsx(D,{value:"2",children:"2 images"}),!Fe&&e.jsx(D,{value:"3",children:"3 images"}),!Fe&&e.jsx(D,{value:"4",children:"4 images"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(oe,{children:"Quality"}),e.jsxs(Ze,{value:is,onValueChange:s=>cr(s),children:[e.jsx(Xe,{children:e.jsx(We,{})}),e.jsxs(es,{children:[e.jsx(D,{value:"standard",children:"Standard — Fast generation, good quality"}),e.jsx(D,{value:"high",children:"High (Pro Model) — Best quality, ~30-60s per image"})]})]})]})]}),e.jsx(Zo,{value:Ls,onChange:wt})]})}),e.jsx(re,{children:e.jsxs(le,{className:"p-5 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between cursor-pointer",onClick:()=>Ul(!Gr),children:[e.jsx("h3",{className:"text-base font-semibold",children:Z?`Brand Settings — ${Z.name}`:"Brand Settings"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:Gr?"▲":"▼"})]}),Gr&&e.jsxs("div",{className:"space-y-4",children:[Z&&e.jsx(hs,{children:e.jsxs(ps,{className:"text-xs",children:['Settings pre-filled from your brand profile "',Z.name,'". You can still adjust them below.']})}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(oe,{children:"Brand Tone"}),e.jsxs(Ze,{value:Fl,onValueChange:s=>Xa(s),children:[e.jsx(Xe,{children:e.jsx(We,{})}),e.jsxs(es,{children:[e.jsx(D,{value:"clean",children:"Clean"}),e.jsx(D,{value:"luxury",children:"Luxury"}),e.jsx(D,{value:"playful",children:"Playful"}),e.jsx(D,{value:"bold",children:"Bold"}),e.jsx(D,{value:"minimal",children:"Minimal"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(oe,{children:"Backgroun
6d"}),e.jsxs(Ze,{value:El,onValueChange:s=>Wa(s),children:[e.jsx(Xe,{children:e.jsx(We,{})}),e.jsxs(es,{children:[e.jsx(D,{value:"studio",children:"Studio"}),e.jsx(D,{value:"lifestyle",children:"Lifestyle"}),e.jsx(D,{value:"gradient",children:"Gradient"}),e.jsx(D,{value:"pattern",children:"Pattern"}),e.jsx(D,{value:"contextual",children:"Contextual"})]})]})]})]}),e.jsx(Xo,{value:ql,onChange:ei})]})]})}),e.jsxs("div",{className:G("p-4 rounded-lg border flex items-center justify-between",J>=fs?"border-border bg-muted/30":"border-destructive/30 bg-destructive/5"),children:[e.jsxs("div",{children:[e.jsxs("p",{className:"text-sm font-semibold",children:["Total: ",fs," credits"]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[ze," images × ",is==="high"?2:1," credit",is==="high"?"s":""]})]}),J>=fs?e.jsxs("p",{className:"text-sm text-muted-foreground",children:[J," credits available"]}):e.jsxs("button",{onClick:()=>qs(!0),className:"flex items-center gap-1 text-sm text-destructive font-semibold hover:underline",children:[e.jsx(bt,{className:"w-3.5 h-3.5"}),J," credits — need ",fs,". Top up"]})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(w,{variant:"outline",onClick:()=>x("template"),children:"Back"}),e.jsx(w,{onClick:J>=fs?yr:()=>qs(!0),className:J<fs?"bg-primary text-primary-foreground hover:bg-primary/90":"",children:J>=fs?`Generate ${ze} Images`:"Buy Credits"})]})]})]}),be&&Q==="settings"&&(g||y)&&e.jsx(bd,{selectedProduct:g,scratchUpload:y,sourceType:ae,isMultiProductMode:Ge,productQueue:qe,creditCost:fs,upscaleImageCount:Qt,balance:J,openBuyModal:()=>qs(!0),handleGenerateClick:yr,setCurrentStep:x}),cs&&!be&&Q==="settings"&&(De!=="virtual-try-on"||me)&&(g||y)&&e.jsx(vd,{selectedProduct:g,scratchUpload:y,sourceType:ae,isMultiProductMode:Ge,productQueue:qe,userProducts:we,activeWorkflow:t??null,workflowConfig:xs,variationStrategy:ge,uiConfig:U,isFlatLay:us,isMirrorSelfie:Qe,isSelfieUgc:me,isInteriorDesign:X,selectedVariationIndices:Ae,setSelectedVariationIndices:It,sceneFilterCategory:en,setSceneFilterCategory:ui,flatLayPhase:Zr,setFlatLayPhase:Xr,selectedFlatLayProductIds:As,selectedAesthetics:pi,setSelectedAesthetics:rn,stylingNotes:hi,setStylingNotes:tn,flatLayPropStyle:gi,setFlatLayPropStyle:ln,mirrorSettingsPhase:Yr,setMirrorSettingsPhase:Dt,ugcMood:Wr,setUgcMood:nn,ugcOutfit:hr,setUgcOutfit:xi,ugcInteractionPhrase:gt(g),productSlot:la(g),quality:is,setQuality:cr,aspectRatio:Ls,setAspectRatio:wt,selectedAspectRatios:as,setSelectedAspectRatios:ti,framing:Nt,setFraming:Vr,selectedFramings:Ee,setSelectedFramings:ri,productAngle:ht,setProductAngle:Wl,selectedBrandProfile:Z,selectedBrandProfileId:nt,brandProfiles:os,balance:J,creditCost:fs,isFreeUser:Fe,workflowImageCount:ma,workflowModelCount:Di,multiProductCount:wr,angleMultiplier:Tt,aspectRatioCount:da,framingCount:ca,interiorType:Ve,isAdmin:Ba,isGeneratingPreviews:Lr,openBuyModal:()=>qs(!0),handleGenerateClick:yr,handleGenerateScenePreviews:ir,setCurrentStep:x,onFreeLimit:s=>_s.openUpgradeDrawer(s)}),Q==="settings"&&De==="virtual-try-on"&&Te.size>0&&Le.size>0&&e.jsx(wd,{selectedProduct:g,scratchUpload:y,selectedModel:fe,selectedModels:Te,selectedModelMap:$s,selectedPose:Et,selectedPoses:Le,selectedPoseMap:ot,creditCost:fs,imageCount:ze,setImageCount:si,quality:is,setQuality:cr,framing:Nt,setFraming:Vr,selectedFramings:Ee,setSelectedFramings:ri,aspectRatio:Ls,setAspectRatio:wt,selectedAspectRatios:as,setSelectedAspectRatios:ti,balance:J,isFreeUser:Fe,isMultiProductMode:Ge,multiProductCount:wr,productQueue:qe,tryOnSceneCount:Nr,openBuyModal:()=>qs(!0),handleGenerateClick:yr,setCurrentStep:x}),Q==="generating"&&e.jsx(re,{children:e.jsxs(le,{className:"p-10 flex flex-col items-center gap-6",children:[(()=>{var c,d;const s=ae==="scratch"?y==null?void 0:y.previewUrl:(d=(c=g==null?void 0:g.images)==null?void 0:c[0])==null?void 0:d.url,r=fe==null?void 0:fe.previewUrl;if((De==="virtual-try-on"||(t==null?void 0:t.uses_tryon))&&r&&s)return e.jsxs("div",{className:"relative w-20 h-20",children:[e.jsx("div",{className:"w-16 h-16 rounded-full overflow-hidden ring-2 ring-primary/20 animate-pulse-subtle",children:e.jsx("img",{src:K(r,{quality:60}),alt:"",className:"w-full h-full object-cover"})}),e.jsx("div",{className:"absolute -bottom-1 -right-1 w-10 h-10 rounded-full overflow-hidden border-2 border-background ring-2 ring-primary/20 animate-pulse-subtle",children:e.jsx("img",{src:K(s,{quality:60}),alt:"",className:"w-full h-full object-cover"})})]});if(us&&As.size>1){const u=we.filter(f=>As.has(f.id));
6return e.jsx("div",{className:"flex -space-x-3 mb-2",children:u.map(f=>e.jsx("div",{className:"w-14 h-14 rounded-full overflow-hidden ring-2 ring-primary/20 border-2 border-background animate-pulse-subtle",children:e.jsx(Gs,{src:K(f.image_url,{quality:60}),alt:f.title,className:"w-full h-full object-cover"})},f.id))})}return s?e.jsx("div",{className:"w-16 h-16 rounded-full overflow-hidden ring-2 ring-primary/20 animate-pulse-subtle",children:e.jsx("img",{src:K(s,{quality:60}),alt:"",className:"w-full h-full object-cover"})}):e.jsx("div",{className:"w-16 h-16 rounded-full bg-primary/10 flex items-center justify-center animate-pulse-subtle",children:De==="virtual-try-on"?e.jsx(Pa,{className:"w-7 h-7 text-primary"}):e.jsx(tr,{className:"w-7 h-7 text-primary"})})})(),e.jsxs("div",{className:"text-center",children:[e.jsx("h2",{className:"text-lg font-semibold",children:be?`Enhancing to ${pt==="4k"?"4K":"2K"}...`:cs||me||Qe?`Creating ${t==null?void 0:t.name}...`:De==="virtual-try-on"?"Creating Virtual Try-On...":"Creating Your Images..."}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:be?`Upscaling ${Qt} image${Qt!==1?"s":""}`:De==="virtual-try-on"||t!=null&&t.uses_tryon?(()=>{const s=ut?Ie.size:Gi*Nr*(as.size>0?as.size:1)*(Ee.has("auto")?1:Math.max(1,Ee.size))*wr;return`Dressing ${fe==null?void 0:fe.name} in "${g==null?void 0:g.title}"${s>1?` · ${s} images`:""}`})():cs||me||Qe?`Generating ${ut?Ie.size:Ae.size} image${(ut?Ie.size:Ae.size)!==1?"s":""} of "${(g==null?void 0:g.title)||(y==null?void 0:y.productInfo.title)}"`:us&&As.size>1?`Arranging ${As.size} products on ${Ae.size} surface${Ae.size!==1?"s":""}`:X?(()=>{const s=Array.from(Ae).map(r=>{var a;return(a=ge==null?void 0:ge.variations[r])==null?void 0:a.label}).filter(Boolean);return s.length>1?`Staging your ${Os||"room"} in ${s.length} styles: ${s.join(", ")}`:`Staging your ${Os||"room"} in ${s[0]||"selected"} style`})():`Creating ${ze} images of "${g==null?void 0:g.title}"`})]}),be&&!Ge&&!ut&&!Hr&&(()=>{const r=Math.max(Qt*(pt==="4k"?75:25),1),a=Math.round(r*.8),c=Math.round(r*1.4),d=Math.min(99,Math.max(2,Math.round(mr/r*100))),u=String(Math.floor(mr/60)).padStart(2,"0"),f=String(mr%60).padStart(2,"0");
6return e.jsxs("div",{className:"w-full max-w-md space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsx("span",{className:"font-medium",children:"Enhancing to 4K…"}),e.jsxs("span",{className:"text-muted-foreground tabular-nums",children:[u,":",f]})]}),e.jsx(kr,{value:d,className:"h-2"}),e.jsxs("div",{className:"flex items-center justify-between text-xs text-muted-foreground",children:[e.jsxs("span",{children:["Est. ~",a===c?a:`${a}–${c}`," sec"]}),e.jsxs("span",{children:[d,"%"]})]})]})})(),Hr&&e.jsxs("div",{className:"w-full max-w-md text-center space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-center gap-2",children:[e.jsx(Ws,{className:"w-5 h-5 animate-spin text-primary"}),e.jsx("span",{className:"font-medium",children:"Finalizing results…"})]}),e.jsx(kr,{value:100,className:"h-2"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Preparing your images for review"})]}),(Ge||ut)&&!Hr&&e.jsx(_o,{productQueue:qe,multiProductResults:Dl,multiProductJobIds:Ie,generatingProgress:Ol,activeJob:M,onCancel:ne,totalExpectedImages:Ie.size>0?Ie.size:void 0,totalJobs:Ie.size,workflowName:be?"Image Upscaling":t==null?void 0:t.name,isProModel:!be&&(De==="virtual-try-on"||is==="high")}),se&&se.totalJobs>1&&!Ge&&!ut&&(()=>{var d;const s=cs&&((d=ge==null?void 0:ge.variations)==null?void 0:d.length),r=Array.from(Ae).sort((u,f)=>u-f),a=X?"style":s?"variation":"image",c=se.completedJobs+se.failedJobs;
6return e.jsxs("div",{className:"w-full max-w-md space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsx("span",{className:"font-medium",children:se.allDone?`All ${se.totalJobs} ${a}s complete`:`${a.charAt(0).toUpperCase()+a.slice(1)} ${Math.min(c+1,se.totalJobs)} of ${se.totalJobs} generating...`}),e.jsxs("span",{className:"text-muted-foreground",children:[c," of ",se.totalJobs," done · ",se.readyImages," image",se.readyImages!==1?"s":""," ready"]})]}),e.jsx(kr,{value:c/se.totalJobs*100,className:"h-2"}),(()=>{const u=is==="high"?12:4,f=Math.max(se.totalJobs*u,1),j=Math.round(f*.8),_=Math.round(f*1.2),L=_<60,F=L?j:Math.max(1,Math.ceil(j/60)),E=L?_:Math.max(F,Math.ceil(_/60)),xe=L?"sec":"min",Ke=Math.round(c/se.totalJobs*100);return e.jsxs("div",{className:"flex items-center justify-between text-xs text-muted-foreground",children:[e.jsxs("span",{children:["Est. ~",F===E?F:`${F}-${E}`," ",xe," for ",se.totalJobs," ",a,se.totalJobs!==1?"s":""]}),e.jsxs("span",{children:[Ke,"%"]})]})})(),s&&r.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5",children:r.map((u,f)=>{var F;const j=((F=ge.variations[u])==null?void 0:F.label)??`#${u+1}`,_=se.jobs[f],L=(_==null?void 0:_.status)??"queued";return e.jsxs("div",{className:`flex items-center gap-1 rounded-full border px-2 py-0.5 text-[10px] transition-all ${L==="completed"?"border-primary/30 bg-primary/5 text-foreground":L==="processing"?"border-primary bg-primary/10 ring-1 ring-primary/30 text-foreground":L==="failed"?"border-destructive/30 bg-destructive/5 text-destructive":"border-border bg-muted/30 text-muted-foreground opacity-70"}`,children:[L==="completed"&&e.jsx(et,{className:"w-3 h-3 text-primary flex-shrink-0"}),L==="processing"&&e.jsx(Ws,{className:"w-3 h-3 text-primary animate-spin flex-shrink-0"}),L==="failed"&&e.jsx(Fs,{className:"w-3 h-3 text-destructive flex-shrink-0"}),L==="queued"&&e.jsx(po,{className:"w-3 h-3 text-muted-foreground flex-shrink-0"}),e.jsx("span",{className:"truncate max-w-[100px]",children:j})]},u)})}),se.failedJobs>0&&e.jsxs("p",{className:"text-xs text-amber-600",children:[se.failedJobs," ",a,se.failedJobs>1?"s":""," failed — credits refunded"]}),M&&e.jsx(cl,{job:M,onCancel:ne})]})})(),(!se||se.totalJobs<=1)&&!Ge&&!ut&&!be&&e.jsx("div",{className:"w-full max-w-md",children:M?e.jsx(cl,{job:M,onCancel:ne}):e.jsx(kr,{value:0,className:"h-2 animate-pulse"})}),e.jsxs(w,{variant:"link",onClick:Sn,children:[e.jsx(Fs,{className:"w-4 h-4 mr-1"})," Cancel"]})]})}),Q==="results"&&(g||y)&&e.jsxs("div",{className:"space-y-4",children:[!be&&e.jsx(re,{children:e.jsxs(le,{className:"p-5 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-sm font-semibold text-foreground",children:(t==null?void 0:t.name)||(X?"Interior Staging":ae==="scratch"?"Image Generation":"Generation Summary")}),t&&e.jsx(de,{variant:"secondary",className:"text-[10px]",children:"Visual Type"})]}),e.jsxs("div",{className:"flex gap-4 overflow-x-auto pb-1",children:[Ge&&qe.length>1?qe.map(s=>{var r,a;return e.jsxs("div",{className:"flex-shrink-0 text-center",children:[e.jsx("div",{className:"w-12 h-12 rounded-lg overflow-hidden border border-border bg-muted/30",children:e.jsx("img",{src:((a=(r=s.images)==null?void 0:r[0])==null?void 0:a.url)||"/placeholder.svg",alt:s.title,className:"w-full h-full object-cover"})}),e.jsx("p",{className:"text-[10px] text-muted-foreground mt-1 max-w-[56px] truncate",children:"Product"}),e.jsx("p",{className:"text-[10px] font-medium mt-0.5 max-w-[56px] truncate",children:s.title})]},s.id)}):us&&As.size>1?we.filter(s=>As.has(s.id)).map(s=>e.jsxs("div",{className:"flex-shrink-0 text-center",children:[e.jsx("div",{className:"w-12 h-12 rounded-lg overflow-hidden border border-border bg-muted/30",children:e.jsx(Gs,{src:K(s.image_url||"/placeholder.svg",{quality:60}),alt:s.title,className:"w-full h-full object-cover"})}),e.jsx("p",{className:"text-[10px] text-muted-foreground mt-1 max-w-[56px] truncate",children:"Product"}
6),e.jsx("p",{className:"text-[10px] font-medium mt-0.5 max-w-[56px] truncate",children:s.title})]},s.id)):(g||y)&&e.jsxs("div",{className:"flex-shrink-0 text-center",children:[e.jsx("div",{className:"w-12 h-12 rounded-lg overflow-hidden border border-border bg-muted/30",children:e.jsx("img",{src:K(ae==="scratch"?y==null?void 0:y.previewUrl:((Hi=g==null?void 0:g.images[0])==null?void 0:Hi.url)||"/placeholder.svg",{quality:60}),alt:"Product",className:"w-full h-full object-cover"})}),e.jsx("p",{className:"text-[10px] text-muted-foreground mt-1 max-w-[56px] truncate",children:"Product"}),e.jsx("p",{className:"text-[10px] font-medium mt-0.5 max-w-[56px] truncate",children:ae==="scratch"?y==null?void 0:y.productInfo.title:g==null?void 0:g.title})]}),Array.from($s.values()).map(s=>e.jsxs("div",{className:"flex-shrink-0 text-center",children:[e.jsx("div",{className:"w-12 h-12 rounded-lg overflow-hidden border border-border bg-muted/30",children:e.jsx("img",{src:K(s.previewUrl,{quality:60}),alt:s.name,className:"w-full h-full object-cover"})}),e.jsx("p",{className:"text-[10px] text-muted-foreground mt-1 max-w-[56px] truncate",children:"Model"}),e.jsx("p",{className:"text-[10px] font-medium mt-0.5 max-w-[56px] truncate",children:s.name})]},s.modelId)),Array.from(ot.values()).map(s=>e.jsxs("div",{className:"flex-shrink-0 text-center",children:[e.jsx("div",{className:"w-12 h-12 rounded-lg overflow-hidden border border-border bg-muted/30",children:e.jsx("img",{src:K(s.previewUrl,{quality:60}),alt:s.name,className:"w-full h-full object-cover"})}),e.jsx("p",{className:"text-[10px] text-muted-foreground mt-1 max-w-[56px] truncate",children:"Scene"}),e.jsx("p",{className:"text-[10px] font-medium mt-0.5 max-w-[56px] truncate",children:s.name})]},s.poseId)),(ge==null?void 0:ge.type)==="scene"&&Ae.size>0&&ge.variations.filter((s,r)=>Ae.has(r)).map((s,r)=>e.jsxs("div",{className:"flex-shrink-0 text-center",children:[e.jsx("div",{className:"w-12 h-12 rounded-lg overflow-hidden border border-border bg-muted/30",children:s.preview_url?e.jsx("img",{src:K(s.preview_url,{quality:60}),alt:s.label,className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-muted-foreground text-[10px]",children:"Scene"})}),e.jsx("p",{className:"text-[10px] text-muted-foreground mt-1 max-w-[56px] truncate",children:"Scene"}),e.jsx("p",{className:"text-[10px] font-medium mt-0.5 max-w-[56px] truncate",children:s.label})]},`scene-${r}`))]}),e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[Nt&&e.jsxs(de,{variant:"outline",className:"text-[10px] font-normal",children:["Framing: ",Nt.replace(/_/g," ")]}),Z&&e.jsxs(de,{variant:"outline",className:"text-[10px] font-normal",children:["Brand: ",Z.name]})]})]})}),Fe&&_s.canShowLayer1&&e.jsx(yo,{category:rt,onSeeMore:()=>{_s.dismissLayer1(),z("post_gen_card")},onDismiss:_s.dismissLayer1}),be?e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("h1",{className:"text-2xl sm:text-3xl font-semibold tracking-tight",children:"Your visuals are ready"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[ls.length," image",ls.length!==1?"s":""," generated successfully"]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("h3",{className:"text-sm font-semibold truncate",children:"Upscaled Images"}),e.jsxs(de,{variant:"secondary",className:"text-[10px] flex-shrink-0 whitespace-nowrap",children:[ls.length," image",ls.length!==1?"s":""," · ",pt==="4k"?"4K":"2K"]})]}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 gap-3",children:ls.map((s,r)=>e.jsx(Do,{url:s,index:r,selected:vs.has(r),onToggle:()=>Ht(r),onView:()=>Ui(r),onDownload:()=>vr(r)},r))})]}),e.jsx(re,{children:e.jsxs(le,{className:"p-4 flex flex-wrap gap-3 items-center justify-center",children:[e.jsxs(w,{variant:"outline",onClick:()=>x("settings"),className:"gap-1.5",children:[e.jsx(ol,{className:"w-4 h-4"}),"Generate More"]}),e.jsx(So,{delayDuration:200,children:e.jsxs(Co,{children:[e.jsx(ko,{asChild:!0,children:e.jsxs(w,{variant:"outline",onClick:()=>{x("source"),rs(null),Ts(null),dr(null),St([]),dt(new Set),Js([]),ct(0),mt(ne
6w Map)},className:"gap-1.5",children:[e.jsx(Vs,{className:"w-4 h-4"}),"Start New"]})}),e.jsx(Io,{children:"Begin a fresh upscale"})]})}),e.jsxs(w,{variant:"outline",onClick:()=>oa(),disabled:xt||ls.length===0,className:"gap-1.5",children:[xt?e.jsx(Ws,{className:"w-4 h-4 animate-spin"}):e.jsx(go,{className:"w-4 h-4"}),xt?"Downloading…":"Download All"]}),e.jsxs(w,{variant:"outline",onClick:()=>n("/app/library"),className:"gap-1.5",children:[e.jsx(sr,{className:"w-4 h-4"}),"View in Library"]})]})})]}):e.jsxs(e.Fragment,{children:[e.jsx(re,{children:e.jsxs(le,{className:"p-5 space-y-4",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold",children:"Generated Images"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Click images to select them"})]}),e.jsxs("div",{className:"grid grid-cols-2 sm:flex sm:flex-wrap gap-2 w-full sm:w-auto",children:[e.jsx(w,{variant:"outline",size:"sm",onClick:()=>{vs.size===ls.length?dt(new Set):dt(new Set(ls.map((s,r)=>r)))},children:vs.size===ls.length?"Deselect All":"Select All"}),e.jsx(w,{variant:"outline",size:"sm",onClick:()=>oa(),disabled:xt,children:xt?e.jsxs(e.Fragment,{children:[e.jsx(Ws,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}),Ei,"%"]}):e.jsxs(e.Fragment,{children:[e.jsx(sr,{className:"w-3.5 h-3.5 mr-1.5"})," Download All"]})}),e.jsx(w,{variant:"outline",size:"sm",onClick:()=>x("settings"),children:"Adjust"}),X&&e.jsxs(w,{variant:"outline",size:"sm",onClick:()=>{St([]),dt(new Set),It(new Set),x("settings")},children:[e.jsx(ol,{className:"w-3.5 h-3.5 mr-1.5"})," Try Another Style"]}),e.jsx(w,{variant:"outline",size:"sm",onClick:()=>{x("source"),rs(null),Ts(null),dr(null),St([]),dt(new Set),Js([]),ct(0),mt(new Map)},children:"Start Over"})]})]}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-5 lg:grid-cols-6 gap-3",children:ls.map((s,r)=>e.jsxs("div",{className:`generation-preview relative group cursor-pointer rounded-lg overflow-hidden ${vs.has(r)?"ring-2 ring-primary ring-offset-2":""}`,children:[e.jsx(Gs,{src:K(s,{quality:70}),alt:`Generated ${r+1}`,className:"w-full object-cover aspect-auto rounded",wrapperClassName:"bg-muted/10 rounded",onClick:()=>Ht(r)}),e.jsxs("div",{className:"absolute inset-0 bg-black/50 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center gap-2",onClick:()=>Ht(r),children:[e.jsx("button",{onClick:a=>{a.stopPropagation(),Ui(r)},className:"w-8 h-8 rounded-full bg-white/90 flex items-center justify-center hover:bg-white",title:"View full size",children:e.jsx(wl,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:a=>{a.stopPropagation(),vr(r)},className:"w-8 h-8 rounded-full bg-white/90 flex items-center justify-center hover:bg-white",title:"Download",children:e.jsx(sr,{className:"w-3.5 h-3.5"})})]}),e.jsx("div",{className:`absolute top-1.5 right-1.5 w-6 h-6 rounded-full border-2 flex items-center justify-center transition-all ${vs.has(r)?"bg-primary border-primary scale-110":"border-white bg-black/50"}`,onClick:()=>Ht(r),children:vs.has(r)&&e.jsx(et,{className:"w-3.5 h-3.5 text-primary-foreground"})})]},r))})]})}),e.jsx(Wn,{workflow:(t==null?void 0:t.slug)||"freestyle",questionText:t!=null&&t.slug?"Does this result look right for your product?":"Did this generation match what you had in mind?",buttonLabels:t!=null&&t.slug?{yes:"Yes",almost:"Almost",no:"No"}:{yes:"Yes",almost:"Almost",no:"No"},reasonChips:t!=null&&t.slug?["Fit looks wrong","Product not preserved","Model doesn't match","Pose variety is weak","Styling feels off","Scene/background off","Needs more realism","Other"]:["Prompt too hard to control","Product not preserved","Model/look is off","Scene/style is off","Composition is wrong","Not realistic enough","Needs better quality","Too slow","Other"],textPlaceholder:t!=null&&t.slug?"What should improve? e.g. better fit, more natural pose":"What were you hoping to get instead?",resultId:Ra||(M==null?void 0:M.id),imageUrl:ls[0],triggerType:"result_ready"}),e.jsxs("div",{className:"flex flex-col items-center gap-2 pt-2",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex items-center",children:[Nd,Sd,Cd,kd].map((s,r)=>e.jsx("img",{src:s,alt:"Team member",className:"w-7 h-7 rounded-full border-2 border-background object-cover",style:{marginLeft:r===0?0:"-0.4rem"}},r))}),e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center gap-1.5",children:["Crafted by your studio team",e.jsx("span",{className:"mx-1",children:"·"}),e.jsx(et,{className:"w-3.5 h-3.5 text-primary"}),"Saved to your library"]})]}),e.jsx(w,{className:"min-h-[44px]",onClick:()=>n("/app/library"),children:"View in Library"})]})]}),vs.size>0&&e.jsxs("div",{className:"fixed bottom-6 left-1/2 -translate-x-1/2 z-50 flex items-center gap-3 bg-background/95 backdrop-blur-xl border border-border shadow-2xl rounded-2xl px-5 py-3",children:[e.jsxs("span",{className:"text-sm font-medium whitespace-nowrap",children:[vs.size," selected"]}),e.jsx(tt,{orientation:"vertical",className:"h-6"}),e.jsx(w,{size:"sm",variant:"outline",onClick:()=>oa(Array.from(vs)),disabled:xt,children:xt?e.jsxs(e.Fragment,{children:[e.jsx(Ws,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}),Ei,"%"]}):e.jsxs(e.Fragment,{children:[e.jsx(sr,{className:"w-3.5 h-3.5 mr-1.5"}),"Download ZIP"]})}),e.jsx("button",{onClick:()=>dt(new Set),className:"w-8 h-8 rounded-full hover:bg-muted flex items-center justify-center transition-colors",children:e.jsx(Fs,{className:"w-4 h-4 text-muted-foreground"})})]})]})]}),e.jsx(Vo,{open:Vl,onClose:()=>Jr(!1),onConfirm:Ri,product:g,model:fe,models:Array.from($s.values()),pose:Et,imageCount:parseInt(ze),aspectRatio:Ls,creditsRemaining:J,isLoading:Ue,onBuyCredits:()=>qs(!0),sourceImageUrl:g&&vt.size>0?(Ji=g.images.find(s=>vt.has(s.id)))==null?void 0:Ji.url:void 0}),e.jsx(Go,{open:Kl,onClose:()=>oi(!1),onPublish:In,selectedImages:Array.from(vs).map(s=>ls[s]),product:g,existingImages:(g==null?void 0:g.images)||[]}),e.jsx(hd,{open:zl,onClose:()=>qa(!1),products:we.length>0?we.map(s=>br(s)):[Ir],selectedProduct:_l,onSelectProduct:Tl,onPublish:(s,r)=>{A.success(`${vs.size} image(s) ${r==="add"?"added to":"replaced on"} "${s.title}"!`),qa(!1),n("/app/library")},selectedImageCount:vs.size}),e.jsx(fo,{images:ls,currentIndex:Jl,open:Hl,onClose:()=>di(!1),onNavigate:ci,onSelect:Ht,onDownload:vr,onRegenerate:Tn,selectedIndices:vs,productName:(g==null?void 0:g.title)||(y==null?void 0:y.productInfo.title)}
6),e.jsx(bo,{open:Ql,onClose:()=>qs(!1),category:rt,generationCount:ls.length}),Ft&&l&&e.jsx($o,{open:!!Ft,items:Ft,userId:l.id,onClose:()=>{Ft.forEach(s=>URL.revokeObjectURL(s.previewUrl)),Rr(null)},onComplete:s=>{Ft.forEach(r=>URL.revokeObjectURL(r.previewUrl)),Rr(null),Pe.invalidateQueries({queryKey:["user-products"]}),Hs("product"),Ts(null),gs(new Set(s)),x("product")}}),e.jsx(Xn,{open:Yl,onOpenChange:Ot,onProductAdded:()=>Pe.invalidateQueries({queryKey:["user-products"]})}),e.jsx(vo,{open:_s.layer2Open,onClose:_s.dismissLayer2,category:rt,source:_s.layer2Reason||void 0,generationContext:{productThumbnail:((Yi=(Qi=g==null?void 0:g.images)==null?void 0:Qi[0])==null?void 0:Yi.url)||(y==null?void 0:y.previewUrl),productTitle:(g==null?void 0:g.title)||(y==null?void 0:y.productInfo.title),sceneName:(Zi=Array.from(ot.values())[0])==null?void 0:Zi.name,modelName:(Xi=Array.from($s.values())[0])==null?void 0:Xi.name}})]})]})}export{Bc 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.