PageSourceSearch

https://callnature.com/assets/product-image-manager-C4L9hN0z.js

js callnature.com collected 2026-10-05 06:43:50 UTC 33,105 bytes, 6 lines download raw bytes

1import{c as ye,j as e,s as ve,z as je,r as a,f as Z,A as C,q as Se,X as ee,t as ke}from"./index-BfSZzoVO.js";import{S as Ce,F as E}from"./sidebar-layout-WDd-fFOV.js";import{A as ze}from"./arrow-left-DAbwm_Xo.js";import{R as we}from"./refresh-cw-Ud-UceNq.js";import{I as le}from"./message-square-COqzhka2.js";import{P as Re}from"./vip-prices-DnYOR5nG.js";import{G as Be}from"./lipid-vs-water-animation-Dz78Ko3y.js";import{C as Ie}from"./circle-play-LKwTpawY.js";import{T as ue}from"./trash-2-CGVvoXv2.js";import{T as re}from"./trophy-BS8hO6rs.js";import{T as ce}from"./triangle-alert-DOirgQfU.js";import{G as Ae}from"./grip-vertical-CMxRhpWd.js";import{C as Te}from"./use-mab-variant-DJEvxQVA.js";import{C as We}from"./index-SCX75VB7.js";import{C as Pe}from"./copy-ChM5IikS.js";import"./skeleton-B4Kt7bS0.js";import"./log-out-VHdny78j.js";import"./addDays-Cn7XXooX.js";import"./format-CY5MepjP.js";import"./package-CQbmqUSP.js";import"./users-CkJlHalp.js";import"./use-page-variant-B08wBv5a.js";import"./uk-gum-claim-YdChH3V5.js";import"./crown-Pvz8ZRbt.js";import"./mail-_TWVs0D_.js";import"./zap-BQBJPQ1o.js";import"./shield-check-rZYnyyM4.js";import"./sparkles-BgaJaV8O.js";import"./store-breadcrumb-BalfFmGD.js";import"./store-theme-Ba8OuZWR.js";import"./trending-up-BjXSDMOh.js";import"./badge-BpVWFyyB.js";import"./shield-C_PFv88O.js";import"./credit-card-ByCiooYn.js";/**
2 * @license lucide-react v0.453.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const Fe=ye("CirclePause",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"10",x2:"10",y1:"15",y2:"9",key:"c1nkhi"}],["line",{x1:"14",x2:"14",y1:"15",y2:"9",key:"h65svq"}]]),Le="/assets/hero2_1772919057301-DoqzdGr8.jpg",De="/assets/hero-main_1772926698320-CNnt-tFP.jpg",Ve="/assets/gums-hero_1772932869651-BZC6L_j4.jpg",$e="/assets/gums-side-hero_1772934151368-BfLnxktg.jpg",Ee="/assets/dentalpro7-features_1773241899243-BD3tMI2Z.jpg",Ne="/assets/dentalpro7-before-after_1773245660035-BVzmMDZL.jpg";function pe(i){return typeof i=="string"?i:i.url}function oe(i){return i.map(n=>typeof n=="string"?{url:n,objectFit:"cover"}:{url:n.url,objectFit:n.objectFit??"cover"})}const Me=[{handle:"dental-pro-7",label:"Dental Pro 7"},{handle:"dp7-pro-rinse",label:"DP7 Pro Rinse"},{handle:"sd7-lipid-serum",label:"SD7 Lipid Serum"},{handle:"scarderma-pro",label:"ScarDerma Pro"},{handle:"provite",label:"ProVite"},{handle:"eco-refill",label:"Eco Refill"}],ge={"dental-pro-7":[De,Ne,Ee,Ve,Le,$e],"dp7-pro-rinse":[],"sd7-lipid-serum":[],"scarderma-
6pro":[],provite:[],"eco-refill":[]};function m({label:i,value:n,highlight:t}){return e.jsxs("div",{style:{textAlign:"center",padding:"8px 12px",background:t?"hsl(142 70% 45% / .15)":"hsl(var(--muted))",borderRadius:8,border:`1px solid ${t?"#bbf7d0":"hsl(var(--muted))"}`},children:[e.jsx("div",{style:{fontSize:18,fontWeight:800,color:t?"#15803d":"hsl(var(--foreground))"},children:n}),e.jsx("div",{style:{fontSize:11,color:t?"#16a34a":"hsl(var(--muted-foreground))",marginTop:2},children:i})]})}function Ue({url:i}){const[n,t]=a.useState(!1);return e.jsx("button",{onClick:z=>{z.stopPropagation(),navigator.clipboard.writeText(i),t(!0),setTimeout(()=>t(!1),2e3)},style:{background:"none",border:"none",cursor:"pointer",color:n?"#15803d":"hsl(var(--muted-foreground))",padding:"2px 4px"},title:"Copy URL",children:n?e.jsx(ke,{size:12}):e.jsx(Pe,{size:12})})}const Oe=[{value:"cover",label:"Cover"},{value:"contain",label:"Contain"},{value:"fill",label:"Fill"},{value:"scale-down",label:"Scale"}];function He({item:i,index:n,total:t,onRemove:z,onMoveUp:b,onMoveDown:W,onFitChange:d,dragging:p,onDragStart:N,onDragOver:P,onDrop:F}){const[l,y]=a.useState(!1),v=i.url,x=i.objectFit??"cover",j=v.startsWith("/uploads/webp/");return e.jsxs("div",{draggable:!0,onDragStart:N,onDragOver:P,onDrop:F,style:{background:p?"hsl(142 70% 45% / .15)":"hsl(var(--card))",border:`2px solid ${l?"#ef4444":p?"#15803d":"hsl(var(--border))"}`,borderRadius:12,overflow:"hidden",cursor:"grab",transition:"all 0.15s",position:"relative",userSelect:"none"},children:[e.jsxs("div",{style:{height:130,background:"hsl(var(--muted))",display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",position:"relative"},children:[e.jsx("img",{src:v,alt:`Image ${n+1}`,style:{width:"100%",height:"100%",objectFit:x,display:l?"none":void 0},loading:"lazy",onError:()=>{j&&y(!0)}}),l&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:6,padding:12,textAlign:"center"},children:[e.jsx(ce,{size:22,color:"#ef4444"}),e.jsxs("span",{style:{fontSize:11,color:"#ef4444",fontWeight:700,lineHeight:1.3},children:["Image missing",e.jsx("br",{}),"from cloud"]})]}),l&&e.jsxs("div",{style:{position:"absolute",top:6,right:6,background:"#ef4444",color:"hsl(var(--card))",borderRadius:6,padding:"2px 7px",fontSize:10,fontWeight:700,display:"flex",alignItems:"center",gap:3},children:[e.jsx(ce,{size:9})," 404"]})]}),e.jsx("div",{style:{padding:"5px 8px",display:"flex",gap:3,background:"hsl(var(--muted))",borderBottom:"1px solid hsl(var(--muted))",flexWrap:"wrap"},children:Oe.map(({value:h,label:L})=>e.jsx("button",{onClick:()=>d(h),style:{padding:"2px 6px",fontSize:10,fontWeight:x===h?700:400,borderRadius:4,border:`1px solid ${x===h?"#15803d":"hsl(var(--border))"}`,background:x===h?"hsl(142 70% 45% / .15)":"hsl(var(--card))",color:x===h?"#15803d":"hsl(var(--muted-foreground))",cursor:"pointer",lineHeight:1.4},children:L},h))}),e.jsxs("div",{style:{padding:"6px 10px",display:"flex",alignItems:"center",gap:4},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:3,flex:1,minWidth:0},children:[e.jsx(Ae,{size:14,color:"hsl(var(--border))",style:{flexShrink:0}}),e.jsxs("span",{style:{fontSize:12,fontWeight:700,color:"hsl(var(--muted-foreground))",flexShrink:0},children:["#",n+1]}),e.jsx(Ue,{url:v})]}),e.jsxs("div",{style:{display:"flex",gap:2,flexShrink:0},children:[e.jsx("button",{onClick:b,disabled:n===0,style:{background:"hsl(var(--muted))",border:"1px solid hsl(var(--border))",borderRadius:4,padding:"2px 5px",cursor:n===0?"not-allowed":"pointer",color:n===0?"hsl(var(--border))":"hsl(var(--muted-foreground))"},children:e.jsx(Te,{size:11})}),e.jsx("button",{onClick:W,disabled:n===t-1,style:{background:"hsl(var(--muted))",border:"1px solid hsl(var(--border))",borderRadius:4,padding:"2px 5px",cursor:n===t-1?"not-allowed":"pointer",color:n===t-1?"hsl(var(--border))":"hsl(var(--muted-foreground))"},children:e.jsx(We,{size:11})}),e.jsx("button",{onClick:z,style:{background:"hsl(var(--card))5f5",border:"1px solid #fecaca",borderRadius:4,padding:"2px 5px",cursor:"pointer",color:"#ef4444"},children:e.jsx(ue,{size:11})})]})]})]})}function qe(){const{toast:i}=ve(),n=je(),[t,z]=a.useState("dental-pro-7"),[b,W]=a.useState("images"),[d,p]=a.use
6State([]),[N,P]=a.useState(!1),[F,l]=a.useState(!1),[y,v]=a.useState(""),[x,j]=a.useState(!1),[h,L]=a.useState(null),[se,D]=a.useState(!1),[w,te]=a.useState(""),[R,he]=a.useState(50),[B,V]=a.useState([]),[M,ie]=a.useState(""),{data:g}=Z({queryKey:[`/api/product-images/${t}`],queryFn:async()=>(await fetch(`/api/product-images/${t}`)).json()}),{data:U,refetch:O}=Z({queryKey:[`/api/product-images/tests/for/${t}`],queryFn:async()=>(await fetch(`/api/product-images/tests/for/${t}`)).json()}),{data:H}=Z({queryKey:["/api/tools/webp-library"],queryFn:async()=>(await fetch("/api/tools/webp-library")).json(),enabled:x});a.useEffect(()=>{P(!1),l(!1)},[t]),a.useEffect(()=>{if(g!==void 0){const r=g.images??ge[t]??[];p(oe(r)),P(!0),l(!1)}},[g,t]);const S=C({mutationFn:async r=>(await fetch(`/api/product-images/${t}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({images:r})})).json(),onSuccess:()=>{n.invalidateQueries({queryKey:[`/api/product-images/${t}`]}),l(!1),i({title:"Images saved!",description:"Live on the product page."})}}),xe=C({mutationFn:async()=>(await fetch(`/api/product-images/${t}`,{method:"DELETE"})).json(),onSuccess:()=>{n.invalidateQueries({queryKey:[`/api/product-images/${t}`]}),p([]),l(!1),i({title:"Images cleared"})}}),$=C({mutationFn:async({id:r,status:o,winnerVariant:s})=>(await fetch(`/api/product-images/tests/${r}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:o,winnerVariant:s})})).json(),onSuccess:()=>O()}),fe=C({mutationFn:async r=>(await fetch(`/api/product-images/tests/${r}`,{method:"DELETE"})).json(),onSuccess:()=>O()}),q=C({mutationFn:async()=>(await fetch("/api/product-images/tests/create",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({productHandle:t,testName:w,variantA:d,variantB:B,trafficSplit:R})})).json(),onSuccess:()=>{O(),D(!1),te(""),V([]),i({title:"A/B test created!",description:"Now live — variants are being served to visitors."})}}),k=C({mutationFn:async()=>(await fetch("/api/product-images/_sync-to-object-storage",{method:"POST"})).json(),onSuccess:r=>{var o,s;if(r.error)i({title:"Re-sync failed",description:r.error,variant:"destructive"});else{const c=((o=r.synced)==null?void 0:o.length)??0,u=r.total??c,f=((s=r.errors)==null?void 0:s.length)??0;f>0?i({title:`Re-sync partial (${c} of ${u})`,description:`${f} file${f>1?"s":""} failed to sync. Check server logs for details.`,variant:"destructive"}):i({title:"Re-sync complete",description:`${c} of ${u} file${u!==1?"s":""} synced to cloud storage.`})}},onError:r=>{i({title:"Re-sync failed",description:String(r),variant:"destructive"})}}),G=a.useCallback((r,o,s,c)=>{const u=[...s],[f]=u.splice(r,1);u.splice(o,0,f),c(u)},[]),me=r=>{h===null||h===r||(G(h,r,d,o=>{p(o),l(!0)}),L(null))},I=(r,o)=>{r.trim()&&(o==="main"?(p(s=>(l(!0),[...s,{url:r.trim(),objectFit:"cover"}])),v("")):(V(s=>[...s,r.trim()]),ie("")))},ne=(r,o)=>{o==="main"?p(s=>{l(!0);const c=[...s];return c.splice(r,1),c}):V(s=>{const c=[...s];return c.splice(r,1),c})},be=(r,o)=>{p(s=>(l(!0),s.map((c,u)=>u===r?{...c,objectFit:o}:c)))},A=(U==null?void 0:U.tests)??[],ae=A.find(r=>r.status==="active"),de=(H==null?void 0:H.images)??[];return e.jsxs("div",{style:{minHeight:"100vh",background:"hsl(var(--muted))"},children:[e.jsxs("div",{style:{background:"hsl(var(--card))",borderBottom:"1px solid hsl(var(--border))",padding:"16px 24px",display:"flex",alignItems:"center",gap:16},children:[e.jsx(Se,{href:"/admin/tools",children:e.jsxs("button",{style:{background:"none",border:"1px solid hsl(var(--border))",borderRadius:8,padding:"6px 12px",cursor:"pointer",display:"flex",alignItems:"center",gap:6,color:"hsl(var(--muted-foreground))",fontSize:13},children:[e.jsx(ze,{size:14})," Back"]})}),e.jsxs("div",{style:{flex:1},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:2},children:[e.jsx("h1",{style:{fontSize:20,fontWeight:700,color:"hsl(var(--foreground))",margin:0},children:"Product Image Manager"}),e.jsx("span",{title:"You are editing PRODUCTION configs — changes here affect your live store immediately.",style:{fontSize:11,fontWeight:700,padding:"2px 8px",borderRadius:99,background:"hsl(142 70% 45% / .15)",color:"#166534",border:"1px solid #86efac",letterSpacing:"0.04em"},children:"PRODUCTION"})]}),e.jsx("p",{style:{fontSize:13,color:"hsl(var(--muted-foreground))",margin:0},children:"Drag to reorder, add, remove, and A/B test product gallery images"})]}),e.jsxs("button",{onClick:()=>k.mutate(),disabled:k.isPending,title:"Re-sync all images in the local library to cloud storage so they survive redeployments",style:{padding:"8px 14px",background:(k.isPending,"hsl(var(--muted))"),border:"1px solid hsl(var(--border))",borderRadius:8,cursor:k.isPending?"not-allowed":"pointer",fontSize:13,color:"hsl(var(--foreground))",display:"flex",alignItems:"center",gap:6,whiteSpace:"nowrap"},children:[e.jsx(we,{size:13,style:{animation:k.isPending?"spin 1s linear infinite":"none"}}),k.isPending?"Syncing…":"Re-sync to cloud"]}),F&&e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx("button",{onClick:()=>{p(oe((g==null?void 0:g.images)??ge[t]??[])),l(!1)},style:{padding:"8px 16px",background:"transparent",border:"1px solid hsl(var(--border))",borderRadius:8,cursor:"pointer",fontSize:13,color:"hsl(var(--muted-foreground))"},children:"Discard"}),e.jsx("button",{onClick:()=>S.mutate(d),disabled:S.isPending,style:{padding:"8px 20px",background:"#15803d",color:"hsl(var(--card))",border:"none",borderRadius:8,fontWeight:700,cursor:"pointer",fontSize:13},children:S.isPending?"Saving…":"Save & Go Live"})]})]}),e.jsx("div",{style:{background:"hsl(var(--card))",borderBottom:"1px solid hsl(var(--border))",padding:"0 24px",display:"flex",gap:0,overflowX:"auto"},children:Me.map(r=>e.jsx("button",{onClick:()=>z(r.handle),style:{padding:"12px 16px",border:"none",borderBottom:`3px solid ${t===r.handle?"#15803d":"transparent"}`,background:"none",cursor:"pointer",fontWeight:t===r.handle?700:400,fontSize:13,color:t===r.handle?"#15803d":"hsl(var(--muted-foreground))",whiteSpace:"nowrap",transition:"all 0.15s"},children:r.label},r.handle))}),e.jsxs("div",{style:{maxWidth:1200,margin:"0 auto",padding:"24px"},children:[e.jsx("div",{style:{display:"flex",gap:4,background:"hsl(var(--muted))",borderRadius:10,padding:4,marginBottom:20,width:"fit-content"},children:[["images",e.jsx(le,{size:13}),"Gallery Images"],["tests",e.jsx(E,{size:13}),`A/B Tests${A.length>0?` (${A.length})`:""}`]].map(([r,o,s])=>e.jsxs("button",{onClick:()=>W(r),style:{padding:"8px 18px",borderRadius:7,border:"none",cursor:"pointer",fontWeight:600,fontSize:13,background:b===r?"hsl(var(--card))":"transparent",color:b===r?"hsl(var(--foreground))":"hsl(var(--muted-foreground))",boxShadow:b===r?"0 1px 3px rgba(0,0,0,0.1)":"none",display:"flex",alignItems:"center",gap:6},children:[o,s]},r))}),b==="images"&&e.jsxs("div",{children:[ae&&e.jsxs("div",{style:{background:"hsl(39 92% 61% / .15)",border:"1px solid #fed7aa",borderRadius:10,padding:"12px 16px",marginBottom:16,display:"flex",alignItems:"center",gap:10},children:[e.jsx(E,{size:16,color:"#d97706"}),e.jsxs("div",{children:[e.jsxs("span",{style:{fontWeight:700,color:"#92400e",fontSize:13},children:['A/B test running: "',ae.testName,'"']}),e.jsx("p",{style:{margin:0,fontSize:12,color:"#b45309"},children:"Visitors are seeing variant A or B. Changes you save here become the new Variant A."})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:16},children:[e.jsxs("span",{style:{fontSize:13,fontWeight:600,color:"hsl(var(--foreground))"},children:[d.length," image",d.length!==1?"s":""]}),g!=null&&g.images&&d.length>0?e.jsx("span",{style:{fontSize:11,background:"hsl(142 70% 45% / .15)",color:"#15803d",padding:"2px 8px",borderRadius:20,border:"1px solid #bbf7d0",fontWeight:600},children:"Live config active"}):e.jsx("span",{style:{fontSize:11,background:"hsl(25 90% 55% / .15)",color:"#ea580c",padding:"2px 8px",borderRadius:20,border:"1px solid #fed7aa"},children:"No images set"}),(g==null?void 0:g.images)&&d.length>0&&e.jsx("button",{onClick:()=>xe.mutate(),style:{fontSize:11,color:"#ef4444",background:"none",border:"1px solid #fecaca",borderRadius:6,padding:"2px 8px",cursor:"pointer"},children:"Clear all images"})]}),N?e.jsxs(e.Fragment,{children:[d.length===0&&e.jsxs("div",{style:{background:"hsl(25 90% 55% / .15)",border:"1px dashed #fdba74",borderRadius:12,padding:"28px 20px",textAlign:"center",marginBottom:16},children:[e.jsx(le,{size:32,color:"#f97316",style:{margin:"0 auto 10px"}}),e.jsx("p",{style:{margin:"0 0 4px",fontWeight:700,fontSize:14,color:"#c2410c"},children:"No images set for this product"}),e.jsxs("p",{style:{margin:0,fontSize:13,color:"#9a3412",lineHeight:1.5},children:["Upload your images via the ",e.jsx("strong",{children:"WebP Converter"}),", then add them here using ",e.jsx("strong",{children:"From Library"})," or paste a URL below."]})]}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(180px, 1fr))",gap:12,marginBottom:16},children:d.map((r,o)=>e.jsx(He,{item:r,index:o,total:d.length,onRemove:()=>ne(o,"main"),onMoveUp:()=>{G(o,o-1,d,p),l(!0)},onMoveDown:()=>{G(o,o+1,d,p),l(!0)},onFitChange:s=>be(o,s),dragging:h===o,onDragStart:()=>L(o),onDragOver:s=>s.preventDefault(),onDrop:()=>me(o)},`${r.url}-${o}`))}),e.jsxs("div",{style:{background:"hsl(var(--card))",borderRadius:10,border:"1px solid hsl(var(--border))",padding:16},children:[e.jsxs("p",{style:{margin:"0 0 10px",fontWeight:600,fontSize:13,color:"hsl(var(--foreground))",display:"flex",alignItems:"center",gap:6},children:[e.jsx(Re,{size:14})," Add Image"]}),e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx("input",{value:y,onChange:r=>v(r.target.value),onKeyDown:r=>r.key==="Enter"&&I(y,"main"),placeholder:"Paste image URL (CDN, /uploads/webp/..., etc.)",style:{flex:1,padding:"9px 12px",border:"1px solid hsl(var(--border))",borderRadius:8,fontSize:13,outline:"none"}}),e.jsx("button",{onClick:()=>I(y,"main"),style:{padding:"9px 16px",background:y?"#15803d":"hsl(var(--border))",color:"hsl(var(--card))",border:"none",borderRadius:8,cursor:y?"pointer":"not-allowed",fontWeight:600,fontSize:13},children:"Add"}),e.jsxs("button",{onClick:()=>j(!0),style:{padding:"9px 16px",background:"hsl(var(--muted))",border:"1px solid hsl(var(--border))",borderRadius:8,cursor:"pointer",fontSize:13,color:"hsl(var(--foreground))",display:"flex",alignItems:"center",gap:6,fontWeight:500},children:[e.jsx(Be,{size:13})," From Library"]})]})]}),F&&e.jsx("div",{style:{display:"flex",gap:8,marginTop:16},children:e.jsx("button",{onClick:()=>S.mutate(d),disabled:S.isPending,style:{flex:1,padding:"13px",background:"#15803d",color:"hsl(var(--card))",border:"none",borderRadius:10,fontWeight:700,fontSize:14,cursor:"pointer"},children:S.isPending?"Saving…":"✓ Save & Go Live"})})]}):e.jsx("div",{style:{textAlign:"center",padding:40,color:"hsl(var(--muted-foreground))"},children:"Loading…"})]}),b==="tests"&&e.jsxs("div",{children:[!se&&e.jsxs("button",{onClick:()=>{V(d.map(r=>r.url)),D(!0)},style:{display:"flex",alignItems:"center",gap:8,padding:"12px 20px",background:"#15803d",color:"hsl(var(--card))",border:"none",borderRadius:10,fontWeight:700,cursor:"pointer",fontSize:14,marginBottom:20},children:[e.jsx(E,{size:15})," Create New A/B Test"]}),se&&e.jsxs("div",{style:{background:"hsl(var(--card))",borderRadius:12,border:"1px solid #d1fae5",padding:20,marginBottom:20},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:16},children:[e.jsx("h3",{style:{margin:0,fontSize:16,fontWeight:700,color:"hsl(var(--foreground))"},children:"New A/B Image Test"}),e.jsx("button",{onClick:()=>D(!1),style:{background:"none",border:"none",cursor:"pointer",color:"hsl(var(--muted-foreground))"},children:e.jsx(ee,{size:16})})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16,marginBottom:16},children:[e.jsxs("div",{children:[e.jsx("label",{style:{fontSize:12,fontWeight:600,color:"hsl(var(--foreground))",display:"block",marginBottom:4},children:"Test name"}),e.jsx("input",{value:w,onChange:r=>te(r.target.value),placeholder:"e.g. Hero first vs Before/After first",style:{width:"100%",padding:"9px 12px",border:"1px solid hsl(var(--border))",borderRadius:8,fontSize:13,boxSizing:"border-box"}})]}),e.jsxs("div",{children:[e.jsxs("label",{style:{fontSize:12,fontWeight:600,color:"hsl(var(--foreground))",display:"block",marginBottom:4},children:["Traffic to Variant B: ",e.jsxs("strong",{style:{color:"#15803d"},children:[R,"%"]})]}),e.jsx("input",{type:"range",min:10,max:90,step:5,value:R,onChange:r=>he(Number(r.target.value)),style:{width:"100%",accentColor:"#15803d",cursor:"pointer",marginTop:6}}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontSize:11,color:"hsl(var(--muted-foreground))"},children:[e.jsxs("span",{children:["Variant A: ",100-R,"%"]}),e.jsxs("span",{children:["Variant B: ",R,"%"]})]})]})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[e.jsxs("div",{children:[e.jsxs("div",{style:{fontSize:12,fontWeight:700,color:"hsl(var(--foreground))",marginBottom:8,display:"flex",alignItems:"center",gap:6},children:[e.jsx("span",{style:{background:"#dbeafe",color:"#1d4ed8",padding:"2px 8px",borderRadius:20,fontSize:11},children:"Variant A — Control"}),e.jsx("span",{style:{color:"hsl(var(--muted-foreground))",fontWeight:400},children:"Current image order"})]}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:6,maxHeight:220,overflowY:"auto"},children:d.map((r,o)=>e.jsxs("div",{style:{position:"relative",borderRadius:6,overflow:"hidden",aspectRatio:"1",background:"hsl(var(--muted))"},children:[e.jsx("img",{src:r.url,style:{width:"100%",height:"100%",objectFit:"cover"},loading:"lazy",onError:s=>{s.target.style.display="none"}}),e.jsxs("div",{style:{position:"absolute",top:2,left:2,background:"rgba(0,0,0,0.5)",color:"hsl(var(--card))",borderRadius:4,padding:"1px 5px",fontSize:10,fontWeight:700},children:["#",o+1]})]},o))})]}),e.jsxs("div",{children:[e.jsxs("div",{style:{fontSize:12,fontWeight:700,color:"hsl(var(--foreground))",marginBottom:8,display:"flex",alignItems:"center",gap:6},children:[e.jsx("span",{style:{background:"#d1fae5",color:"#065f46",padding:"2px 8px",borderRadius:20,fontSize:11},children:"Variant B — Challenger"}),e.jsx("span",{style:{color:"hsl(var(--muted-foreground))",fontWeight:400},children:"Edit below"})]}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:6,maxHeight:160,overflowY:"auto",marginBottom:8},children:B.map((r,o)=>e.jsxs("div",{style:{position:"relative",borderRadius:6,overflow:"hidden",aspectRatio:"1",background:"hsl(var(--muted))"},children:[e.jsx("img",{src:r,style:{width:"100%",height:"100%",objectFit:"cover"},loading:"lazy",onError:s=>{s.target.style.display="none"}}),e.jsxs("div",{style:{position:"absolute",top:2,left:2,background:"rgba(0,0,0,0.5)",color:"hsl(var(--card))",borderRadius:4,padding:"1px 5px",fontSize:10,fontWeight:700},children:["#",o+1]}),e.jsx("button",{onClick:()=>ne(o,"variantB"),style:{position:"absolute",top:2,right:2,background:"rgba(239,68,68,0.8)",border:"none",borderRadius:4,width:18,height:18,cursor:"pointer",color:"hsl(var(--card))",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(ee,{size:10})})]},o))}),e.jsxs("div",{style:{display:"flex",gap:6},children:[e.jsx("input",{value:M,onChange:r=>ie(r.target.value),onKeyDown:r=>r.key==="Enter"&&I(M,"variantB"),placeholder:"Paste URL to add to B",style:{flex:1,padding:"7px 10px",border:"1px solid hsl(var(--border))",borderRadius:7,fontSize:12}}),e.jsx("button",{onClick:()=>I(M,"variantB"),style:{padding:"7px 12px",background:"#15803d",color:"hsl(var(--card))",border:"none",borderRadius:7,cursor:"pointer",fontSize:12,fontWeight:600},children:"Add"})]}),e.jsx("p",{style:{margin:"6px 0 0",fontSize:11,color:"hsl(var(--muted-foreground))"},children:"Tip: Reorder within Variant A/B by changing the image order above, then start the test."})]})]}),e.jsxs("div",{style:{marginTop:16,display:"flex",gap:8},children:[e.jsx("button",{onClick:()=>q.mutate(),disabled:!w||B.length===0||q.isPending,style:{padding:"11px 24px",ba
6ckground:w&&B.length>0?"#15803d":"hsl(var(--border))",color:"hsl(var(--card))",border:"none",borderRadius:9,fontWeight:700,cursor:w&&B.length>0?"pointer":"not-allowed",fontSize:14},children:q.isPending?"Starting…":"🧪 Start A/B Test"}),e.jsx("button",{onClick:()=>D(!1),style:{padding:"11px 16px",background:"transparent",border:"1px solid hsl(var(--border))",borderRadius:9,cursor:"pointer",fontSize:13,color:"hsl(var(--muted-foreground))"},children:"Cancel"})]})]}),A.length===0?e.jsxs("div",{style:{background:"hsl(var(--card))",borderRadius:12,border:"1px solid hsl(var(--border))",padding:"40px",textAlign:"center"},children:[e.jsx(E,{size:36,color:"hsl(var(--border))",style:{margin:"0 auto 12px"}}),e.jsx("p",{style:{fontWeight:600,color:"hsl(var(--foreground))",margin:"0 0 6px"},children:"No tests for this product yet"}),e.jsx("p",{style:{color:"hsl(var(--muted-foreground))",fontSize:13,margin:0},children:"Create a test to compare different image orders or sets and see which drives more add-to-carts."})]}):e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:14},children:A.map(r=>{const o=JSON.parse(r.variantA),s=JSON.parse(r.variantB),c=r.impressionsA+r.impressionsB,u=r.impressionsA>0?(r.atcA/r.impressionsA*100).toFixed(1):"—",f=r.impressionsB>0?(r.atcB/r.impressionsB*100).toFixed(1):"—",_=r.winnerVariant==="A",K=r.winnerVariant==="B",J=r.atcA>0&&r.atcB>0&&r.atcA/Math.max(r.impressionsA,1)>r.atcB/Math.max(r.impressionsB,1),Q=r.atcA>0&&r.atcB>0&&r.atcB/Math.max(r.impressionsB,1)>r.atcA/Math.max(r.impressionsA,1);return e.jsxs("div",{style:{background:"hsl(var(--card))",borderRadius:12,border:`2px solid ${r.status==="active"?"#bbf7d0":"hsl(var(--border))"}`,overflow:"hidden"},children:[e.jsxs("div",{style:{padding:"14px 16px",display:"flex",alignItems:"center",gap:10,borderBottom:"1px solid hsl(var(--muted))"},children:[e.jsxs("div",{style:{flex:1},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:2},children:[e.jsx("h3",{style:{margin:0,fontSize:15,fontWeight:700,color:"hsl(var(--foreground))"},children:r.testName}),e.jsx("span",{style:{fontSize:11,padding:"2px 8px",borderRadius:20,fontWeight:700,background:r.status==="active"?"hsl(142 70% 45% / .15)":r.status==="paused"?"#fef9c3":"hsl(var(--muted))",color:r.status==="active"?"#15803d":r.status==="paused"?"#854d0e":"hsl(var(--muted-foreground))"},children:r.status==="active"?"● Live":r.status==="paused"?"⏸ Paused":"✓ Complete"}),r.winnerVariant&&e.jsxs("span",{style:{fontSize:11,padding:"2px 8px",borderRadius:20,background:"#fef3c7",color:"#92400e",fontWeight:700},children:["🏆 Winner: ",r.winnerVariant]})]}),e.jsxs("p",{style:{margin:0,fontSize:12,color:"hsl(var(--muted-foreground))"},children:[new Date(r.createdAt).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"})," · ",r.trafficSplit,"% → B · ",c," total impressions"]})]}),e.jsxs("div",{style:{display:"flex",gap:6},children:[r.status==="active"&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>$.mutate({id:r.id,status:"paused"}),title:"Pause test",style:{padding:"6px 10px",background:"#fef9c3",border:"1px solid #fde68a",borderRadius:7,cursor:"pointer",color:"#854d0e",display:"flex",alignItems:"center",gap:4,fontSize:12},children:[e.jsx(Fe,{size:13})," Pause"]}),r.atcA>0||r.atcB>0?e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>$.mutate({id:r.id,status:"complete",winnerVariant:"A"}),style:{padding:"6px 10px",background:"#dbeafe",border:"1px solid #bfdbfe",borderRadius:7,cursor:"pointer",color:"#1e40af",fontSize:12},children:"Declare A Winner"}),e.jsx("button",{onClick:()=>$.mutate({id:r.id,status:"complete",winnerVariant:"B"}),style:{padding:"6px 10px",background:"#d1fae5",border:"1px solid #a7f3d0",borderRadius:7,cursor:"pointer",color:"#065f46",fontSize:12},children:"Declare B Winner"})]}):null]}),r.status==="paused"&&e.jsxs("button",{onClick:()=>$.mutate({id:r.id,status:"active"}),style:{padding:"6px 10px",background:"hsl(142 70% 45% / .15)",border:"1px solid #bbf7d0",borderRadius:7,cursor:"pointer",color:"#15803d",display:"flex",alignItems:"center",gap:4,fontSize:12},children:[e.jsx(Ie,{size:13})," Resume"]}),e.jsx("button",{onClick:()=>fe.mutate(r.id),title:"Delete test",style:{padding:"6px 8px",background:"hsl(var(--card))5f5",border:"1px solid #fecaca",borderRadius:7,cursor:"pointer",color:"#ef4444"},children:e.jsx(ue,{size:13})})]})]}),e.jsxs("div",{style:{padding:"14px 16px",display:"grid",gridTemplateColumns:"1fr auto 1fr",gap:16,alignItems:"start"},children:[e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:8},children:[e.jsx("span",{style:{background:"#dbeafe",color:"#1d4ed8",padding:"2px 8px",borderRadius:20,fontSize:11,fontWeight:700},children:"A — Control"}),_&&e.jsx(re,{size:14,color:"#eab308"}),J&&!_&&!K&&e.jsx("span",{style:{fontSize:11,color:"#15803d",fontWeight:600},children:"↑ Leading"})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:6,marginBottom:8}
6,children:[e.jsx(m,{label:"Views",value:r.impressionsA}),e.jsx(m,{label:"ATC",value:r.atcA,highlight:J}),e.jsx(m,{label:"ATC Rate",value:u,highlight:J&&u!=="—"}),e.jsx(m,{label:"Purchases",value:r.purchasesA})]}),e.jsxs("div",{style:{display:"flex",gap:4,overflowX:"auto"},children:[o.slice(0,4).map((T,X)=>e.jsx("img",{src:pe(T),style:{width:48,height:48,objectFit:"cover",borderRadius:6,border:"1px solid hsl(var(--border))",flexShrink:0},loading:"lazy",onError:Y=>{Y.target.style.display="none"}},X)),o.length>4&&e.jsxs("div",{style:{width:48,height:48,background:"hsl(var(--muted))",borderRadius:6,display:"flex",alignItems:"center",justifyContent:"center",fontSize:11,color:"hsl(var(--muted-foreground))",flexShrink:0},children:["+",o.length-4]})]})]}),e.jsx("div",{style:{textAlign:"center",paddingTop:8},children:e.jsx("div",{style:{fontSize:20,fontWeight:900,color:"hsl(var(--border))"},children:"VS"})}),e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:8},children:[e.jsx("span",{style:{background:"#d1fae5",color:"#065f46",padding:"2px 8px",borderRadius:20,fontSize:11,fontWeight:700},children:"B — Challenger"}),K&&e.jsx(re,{size:14,color:"#eab308"}),Q&&!_&&!K&&e.jsx("span",{style:{fontSize:11,color:"#15803d",fontWeight:600},children:"↑ Leading"})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:6,marginBottom:8},children:[e.jsx(m,{label:"Views",value:r.impressionsB}),e.jsx(m,{label:"ATC",value:r.atcB,highlight:Q}),e.jsx(m,{label:"ATC Rate",value:f,highlight:Q&&f!=="—"}),e.jsx(m,{label:"Purchases",value:r.purchasesB})]}),e.jsxs("div",{style:{display:"flex",gap:4,overflowX:"auto"},children:[s.slice(0,4).map((T,X)=>e.jsx("img",{src:pe(T),style:{width:48,height:48,objectFit:"cover",borderRadius:6,border:"1px solid hsl(var(--border))",flexShrink:0},loading:"lazy",onError:Y=>{Y.target.style.display="none"}},X)),s.length>4&&e.jsxs("div",{style:{width:48,height:48,background:"hsl(var(--muted))",borderRadius:6,display:"flex",alignItems:"center",justifyContent:"center",fontSize:11,color:"hsl(var(--muted-foreground))",flexShrink:0},children:["+",s.length-4]})]})]})]}),r.winnerVariant&&e.jsx("div",{style:{padding:"10px 16px",background:"hsl(39 92% 61% / .15)",borderTop:"1px solid #fde68a"},children:e.jsxs("button",{onClick:()=>{const T=r.winnerVariant==="A"?o:s;p(oe(T)),l(!0),W("images"),i({title:`Variant ${r.winnerVariant} loaded!`,description:"Review and save to make it live."})},style:{padding:"8px 16px",background:"#eab308",color:"hsl(var(--card))",border:"none",borderRadius:8,fontWeight:700,cursor:"pointer",fontSize:13,display:"flex",alignItems:"center",gap:6},children:[e.jsx(re,{size:14})," Apply Variant ",r.winnerVariant," as Live Images"]})})]},r.id)})})]})]}),x&&e.jsx("div",{style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.5)",zIndex:1e3,display:"flex",alignItems:"center",justifyContent:"center"},onClick:()=>j(!1),children:e.jsxs("div",{style:{background:"hsl(var(--card))",borderRadius:14,width:"min(90vw, 680px)",maxHeight:"80vh",overflow:"hidden",display:"flex",flexDirection:"column"},onClick:r=>r.stopPropagation(),children:[e.jsxs("div",{style:{padding:"16px 20px",borderBottom:"1px solid hsl(var(--border))",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx("h3",{style:{margin:0,fontSize:16,fontWeight:700},children:"Pick from WebP Library"}),e.jsx("button",{onClick:()=>j(!1),style:{background:"none",border:"none",cursor:"pointer",color:"hsl(var(--muted-foreground))"},children:e.jsx(ee,{size:18})})]}),e.jsx("div",{style:{padding:16,overflowY:"auto",flex:1},children:de.length===0?e.jsx("p",{style:{color:"hsl(var(--muted-foreground))",textAlign:"center",padding:30},children:"No images in library yet. Upload some via the WebP Converter."}):e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(140px, 1fr))",gap:10},children:de.map(r=>e.jsxs("div",{onClick:()=>{I(r.url,"main"),j(!1)},style:{cursor:"pointer",borderRadius:8,border:"2px solid hsl(var(--border))",overflow:"hidden",transition:"all 0.15s"},onMouseEnter:o=>o.currentTarget.style.borderColor="#15803d",onMouseLeave:o=>o.currentTarget.style.borderColor="hsl(var(--border))",children:[e.jsx("div",{style:{height:100,background:"hsl(var(--muted))",overflow:"hidden"},children:e.jsx("img",{src:r.url,alt:r.originalName,style:{width:"100%",height:"100%",objectFit:"cover"},loading:"lazy"})}),e.jsx("div",{style:{padding:"6px 8px"},children:e.jsx("p",{style:{margin:0,fontSize:11,color:"hsl(var(--foreground))",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:r.originalName})})]},r.id))})})]})})]})}function wr(){return e.jsx(Ce,{children:e.jsx(qe,{})})}
6export{wr 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.