1import{j as e,r as f,N as se,w as C,I,e as ne,X as oe,v as de,O as le,t as ce,u as ie,a as ue,Q as O,d as W,B as U,R as be,y as fe,z as xe,D as T,F as _}from"./index-Btwx4YXX.js";import{S as ge,a as he,b as me,c as pe,d as Be}from"./select-DLGxWm2i.js";import{A as je}from"./AgentPageHeader-DIYuewEW.js";import{u as ye}from"./useStoreConfig-B_-2iGtZ.js";import{C as ke,S as ve,D as $,a as z,g as Ce,b as Ne,c as we,d as w,e as A}from"./chat-translations-0obM_6nu.js";import{u as Se}from"./useUrlTab-B5yRGy8J.js";import{C as p,a as B,b as j,c as G,d as y}from"./card-Dog6i7KT.js";import{C as Te}from"./chevron-up-D0HXn05K.js";import{S as P}from"./shopping-cart-CGAY9NoB.js";import{S as _e}from"./star-CYDfsaWC.js";import{G as Ae}from"./globe-mwczqShG.js";import{S as Fe}from"./settings-2-DT0MlO6N.js";import{M as Ie}from"./message-circle-CnaS8ix4.js";import{S as Ge}from"./save--kx05C4x.js";import"./index-BdQq_4o_.js";import"./index-CpXTCiuj.js";import"./check-DKR8YjKo.js";import"./useQuery-PbToW9tp.js";import"./useMutation-B2EqUmaj.js";const q=[{name:"Cloudy White",icon:"âï¸",skinId:"modern-blue",primaryColor:"linear-gradient(135deg, #3B82F6, #60A5FA)",accentColor:"#3B82F6",headerBackground:"#ffffff",headerTextColor:"#1e293b",assistantBubbleBackgroun
1d:"#f1f5f9",bubbleBackground:"#ffffff",bubbleText:"#475569",bubbleBorder:"#e2e8f0",cartBackground:"linear-gradient(135deg, #3B82F6, #60A5FA)",cartText:"#ffffff",cartBorder:"transparent",bgGradient:"#ffffff"},{name:"Blue Steel",icon:"ð",skinId:"modern-blue",primaryColor:"linear-gradient(135deg, #3B82F6, #60A5FA)",accentColor:"#3B82F6",headerBackground:"linear-gradient(135deg, #3B82F6, #60A5FA)",headerTextColor:"#ffffff",assistantBubbleBackground:"#eff6ff",bubbleBackground:"#ffffff",bubbleText:"#1e40af",bubbleBorder:"#bfdbfe",cartBackground:"linear-gradient(135deg, #3B82F6, #60A5FA)",cartText:"#ffffff",cartBorder:"transparent",bgGradient:"#ffffff"},{name:"Rosy Garden",icon:"ð¸",skinId:"modern-blue",primaryColor:"linear-gradient(135deg, #e11d48, #f43f5e)",accentColor:"#e11d48",headerBackground:"#fff1f2",headerTextColor:"#881337",assistantBubbleBackground:"#fff1f2",bubbleBackground:"#FDF2F8",bubbleText:"#9f1239",bubbleBorder:"#fecdd3",cartBackground:"linear-gradient(135deg, #e11d48, #f43f5e)",cartText:"#ffffff",cartBorder:"transparent",bgGradient:"#ffffff"},{name:"Royal Velvet",icon:"ð",skinId:"modern-blue",primaryColor:"linear-gradient(135deg, #7c3aed, #a78bfa)",accentColor:"#7c3aed",headerBackground:"#faf5ff",headerTextColor:"#4c1d95",assistantBubbleBackgroun
1d:"#f5f3ff",bubbleBackground:"#F5F3FF",bubbleText:"#5B21B6",bubbleBorder:"#DDD6FE",cartBackground:"linear-gradient(135deg, #7c3aed, #a78bfa)",cartText:"#ffffff",cartBorder:"transparent",bgGradient:"#ffffff"},{name:"Tangerine",icon:"ð",skinId:"modern-blue",primaryColor:"linear-gradient(135deg, #ea580c, #f97316)",accentColor:"#ea580c",headerBackground:"#fff7ed",headerTextColor:"#7c2d12",assistantBubbleBackground:"#fff7ed",bubbleBackground:"#FFF7ED",bubbleText:"#9a3412",bubbleBorder:"#fed7aa",cartBackground:"linear-gradient(135deg, #ea580c, #f97316)",cartText:"#ffffff",cartBorder:"transparent",bgGradient:"#ffffff"},{name:"Emerald Isle",icon:"ð",skinId:"modern-blue",primaryColor:"linear-gradient(135deg, #059669, #34d399)",accentColor:"#059669",headerBackground:"#ecfdf5",headerTextColor:"#064e3b",assistantBubbleBackground:"#ecfdf5",bubbleBackground:"#ecfdf5",bubbleText:"#065f46",bubbleBorder:"#a7f3d0",cartBackground:"linear-gradient(135deg, #059669, #34d399)",cartText:"#ffffff",cartBorder:"transparent",bgGradient:"#ffffff"},{name:"Midnight",icon:"ð¤",skinId:"modern-blue",primaryColor:"linear-gradient(135deg, #334155, #475569)",accentColor:"#334155",headerBackground:"#f8fafc",headerTextColor:"#0f172a",assistantBubbleBackgroun
1d:"#f1f5f9",bubbleBackground:"#f8fafc",bubbleText:"#334155",bubbleBorder:"#cbd5e1",cartBackground:"linear-gradient(135deg, #334155, #475569)",cartText:"#ffffff",cartBorder:"transparent",bgGradient:"#ffffff"}],Q=[{name:"Lagoon",icon:"ð ",skinId:"classic",primaryColor:"linear-gradient(135deg, #0e7490, #06b6d4)",accentColor:"#06b6d4",headerBackground:"linear-gradient(135deg, #0e7490, #06b6d4)",headerTextColor:"#ffffff",assistantBubbleBackground:"#f3f4f6",bubbleBackground:"#ffffff",bubbleText:"#0c4a6e",bubbleBorder:"#22d3ee",cartBackground:"#ccfbf1",cartText:"#0e7490",cartBorder:"#5eead4",bgGradient:"linear-gradient(to bottom, #f0fdfa, #ccfbf1)"},{name:"Deep Sea",icon:"ð",skinId:"classic",primaryColor:"linear-gradient(135deg, #1d4ed8, #3b82f6)",accentColor:"#3b82f6",headerBackground:"linear-gradient(135deg, #1d4ed8, #3b82f6)",headerTextColor:"#ffffff",assistantBubbleBackground:"#eff6ff",bubbleBackground:"#F0F9FF",bubbleText:"#1e40af",bubbleBorder:"#93c5fd",cartBackground:"#dbeafe",cartText:"#1e40af",cartBorder:"#93c5fd",bgGradient:"linear-gradient(to bottom, #eff6ff, #dbeafe)"},{name:"Enchanted",icon:"ð¿",skinId:"classic",primaryColor:"linear-gradient(135deg, #166534, #22c55e)",accentColor:"#22c55e",headerBackground:"linear-gradient(135deg, #166534, #22c55e)",headerTextColor:"#ffffff",assistantBubbleBackgroun
1d:"#f0fdf4",bubbleBackground:"#ECFDF5",bubbleText:"#166534",bubbleBorder:"#86efac",cartBackground:"#FEF3C7",cartText:"#92400E",cartBorder:"#FDE68A",bgGradient:"linear-gradient(to bottom, #f0fdf4, #dcfce7)"},{name:"Golden Hour",icon:"ð
",skinId:"classic",primaryColor:"linear-gradient(135deg, #c2410c, #f97316)",accentColor:"#f97316",headerBackground:"linear-gradient(135deg, #c2410c, #f97316)",headerTextColor:"#ffffff",assistantBubbleBackground:"#fff7ed",bubbleBackground:"#FFF7ED",bubbleText:"#9a3412",bubbleBorder:"#fdba74",cartBackground:"#dcfce7",cartText:"#166534",cartBorder:"#86efac",bgGradient:"linear-gradient(to bottom, #fff7ed, #ffedd5)"},{name:"Berry Bliss",icon:"ð«",skinId:"classic",primaryColor:"linear-gradient(135deg, #7e22ce, #a855f7)",accentColor:"#a855f7",headerBackground:"linear-gradient(135deg, #7e22ce, #a855f7)",headerTextColor:"#ffffff",assistantBubbleBackground:"#faf5ff",bubbleBackground:"#faf5ff",bubbleText:"#6b21a8",bubbleBorder:"#d8b4fe",cartBackground:"#f3e8ff",cartText:"#6b21a8",cartBorder:"#d8b4fe",bgGradient:"linear-gradient(to bottom, #faf5ff, #f3e8ff)"},{name:"Cherry Pop",icon:"ð",skinId:"classic",primaryColor:"linear-gradient(135deg, #be123c, #f43f5e)",accentColor:"#f43f5e",headerBackground:"linear-gradient(135deg, #be123c, #f43f5e)",headerTextColor:"#ffffff",assistantBubbleBackgroun
1d:"#fff1f2",bubbleBackground:"#fff1f2",bubbleText:"#9f1239",bubbleBorder:"#fda4af",cartBackground:"#fce7f3",cartText:"#9f1239",cartBorder:"#f9a8d4",bgGradient:"linear-gradient(to bottom, #fff1f2, #ffe4e6)"}];[...q,...Q];function De({selectedSkin:a,onApply:r}){return e.jsxs(p,{children:[e.jsxs(B,{className:"pb-3",children:[e.jsx(j,{className:"text-base",children:"Design Presets"}),e.jsx(G,{children:"Pick a preset to apply skin + colors in one click"})]}),e.jsx(y,{children:e.jsxs("div",{className:"grid grid-cols-2 gap-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-semibold text-foreground",children:"Modern Blue"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"White header, flat frame, clean look"}),e.jsx(K,{presets:q,selectedSkin:a,onApply:r})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-semibold text-foreground",children:"Classic"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Gradient header, framed, bold look"}),e.jsx(K,{presets:Q,selectedSkin:a,onApply:r})]})]})})]})}function K({presets:a,selectedSkin:r,onApply:n}){const d=f.useRef(null),[i,b]=f.useState(!1),[x,h]=f.useState(!1),s=()=>{const u=d.current;u&&(b(u.scrollTop>0),h(u.scrollTop<u.scrollHeight-u.clientHeight-1))};f.useEffect(()=>{s()},[a]);const g=u=>{var S;(S=d.current)==null||S.scrollBy({top:u==="up"?-200:200,behavior:"smooth"})};return e.jsxs("div",{className:"relative group/scroll",children:[i&&e.jsx("button",{onClick:()=>g("up"),className:"absolute -top-1 left-1/2 -translate-x-1/2 z-10 w-7 h-7 rounded-full bg-white shadow-md border flex items-center justify-center hover:bg-gray-50 opacity-0 group-hover/scroll:opacity-100 transition-opacity",children:e.jsx(Te,{className:"h-4 w-4 text-muted-foreground"})}),e.jsx("div",{ref:d,onScroll:s,className:"max-h-[320px] overflow-y-auto space-y-2",style:{scrollbarWidth:"none",msOverflowStyle:"none"},children:a.map(u=>e.jsx(Ee,{preset:u,isActive:r===u.skinId,onApply:n},u.name))}),x&&e.jsx("button",{onClick:()=>g("down"),className:"absolute -bottom-1 left-1/2 -translate-x-1/2 z-10 w-7 h-7 rounded-full bg-white shadow-md border flex items-center justify-center hover:bg-gray-50 opacity-0 group-hover/scroll:opacity-100 transition-opacity",children:e.jsx(se,{className:"h-4 w-4 text-muted-foreground"})})]})}function Ee({preset:a,isActive:r,onApply:n}){return e.jsxs("button",{onClick:()=>n(a.skinId,{...a,chatIcon:a.icon}),className:`w-full flex items-center gap-3 p-2.5 rounded-xl border-2 transition-all text-left hover:shadow-sm ${r?"border-blue-400 bg-blue-50/50":"border-gray-100 hover:border-gray-300 bg-white"}`,children:[e.jsxs("div",{className:"w-14 h-10 rounded-md overflow-hidden flex flex-col flex-shrink-0 border border-gray-200",children:[e.jsx("div",{className:"h-3",style:{background:a.headerBackground}}),e.jsx("div",{className:"flex-1 flex items-center justify-center",style:{background:a.bgGradient},children:e.jsx("div",{className:"w-6 h-1.5 rounded-full",style:{background:a.primaryColor}})})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"text-xs font-semibold text-foreground",children:[a.icon," ",a.name]}),e.jsxs("div",{className:"flex gap-1 mt-1",children:[e.jsx("div",{className:"h-2.5 w-2.5 rounded-full",style:{background:a.primaryColor}}),e.jsx("div",{className:"h-2.5 w-2.5 rounded-full",style:{background:a.headerBackground,border:"1px solid #e5e7eb"}}),e.jsx("div",{className:"h-2.5 w-2.5 rounded-full",style:{background:a.accentColor}}),e.jsx("div",{className:"h-2.5 w-2.5 rounded-full border",style:{background:a.bubbleBackgroun
1d,borderColor:a.bubbleBorder}})]})]})]})}const Le=a=>{if(a.startsWith("#"))return a.length>7?a.substring(0,7):a;const r=a.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);if(r){const d=parseInt(r[1]).toString(16).padStart(2,"0"),i=parseInt(r[2]).toString(16).padStart(2,"0"),b=parseInt(r[3]).toString(16).padStart(2,"0");return`#${d}${i}${b}`}const n=a.match(/#[0-9a-fA-F]{6}/);return n?n[0]:"#000000"},V=a=>{const r=a.match(/#[0-9a-fA-F]{6}/g);return r?{start:r[0],end:r[1]||r[0]}:{start:"#3B82F6",end:"#60A5FA"}};function m({label:a,value:r,onChange:n,description:d}){return e.jsxs("div",{className:"space-y-1",children:[e.jsx(C,{className:"text-xs font-medium",children:a}),e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx("input",{type:"color",value:Le(r),onChange:i=>n(i.target.value),className:"h-9 w-12 rounded border border-gray-200 cursor-pointer flex-shrink-0",style:{padding:"2px"}}),e.jsx(I,{value:r,onChange:i=>n(i.target.value),className:"font-mono text-xs h-9"})]}),d&&e.jsx("p",{className:"text-xs text-muted-foreground/70",children:d})]})}function Me({config:a,updateConfig:r}){const[n,d]=f.useState(()=>V(a.primaryColor)),[i,b]=f.useState(()=>V(a.bgGradient)),x=(s,g)=>{const u=`linear-gradient(135deg, ${s} 0%, ${g} 100%)`;r("primaryColor",u),d({start:s,end:g})},h=(s,g)=>{const u=`linear-gradient(to bottom, ${s}, ${g})`;r("bgGradient",u),b({start:s,end:g})};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs(p,{children:[e.jsx(B,{className:"pb-2",children:e.jsx(j,{className:"text-sm",children:"Primary & Accent"})}),e.jsxs(y,{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{className:"text-xs font-medium",children:"Primary Gradient"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[10px] text-muted-foreground/70",children:"Start"}),e.jsx("input",{type:"color",value:n.start,onChange:s=>x(s.target.value,n.end),className:"h-9 w-full rounded border border-gray-200 cursor-pointer",style:{padding:"2px"}})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[10px] text-muted-foreground/70",children:"End"}),e.jsx("input",{type:"color",value:n.end,onChange:s=>x(n.start,s.target.value),className:"h-9 w-full rounded border border-gray-200 cursor-pointer",style:{padding:"2px"}})]})]}),e.jsx("div",{className:"h-8 rounded",style:{background:a.primaryColor}})]}),e.jsx(m,{label:"Accent Color",value:a.accentColor,onChange:s=>r("accentColor",s),description:"Highlights, prices, hover states"})]})]}),e.jsxs(p,{children:[e.jsx(B,{className:"pb-2",children:e.jsx(j,{className:"text-sm",children:"Header"})}),e.jsxs(y,{className:"space-y-3",children:[e.jsx(m,{label:"Background",value:a.headerBackground,onChange:s=>r("headerBackground",s)}),e.jsx(m,{label:"Text Color",value:a.headerTextColor,onChange:s=>r("headerTextColor",s)})]})]}),e.jsxs(p,{children:[e.jsx(B,{className:"pb-2",children:e.jsx(j,{className:"text-sm",children:"Message Bubbles"})}),e.jsxs(y,{className:"space-y-3",children:[e.jsx(m,{label:"Assistant Bubble",value:a.assistantBubbleBackgroun
1d,onChange:s=>r("assistantBubbleBackground",s)}),e.jsx(m,{label:"Send Button",value:a.sendButtonBackground,onChange:s=>r("sendButtonBackground",s)})]})]}),e.jsxs(p,{children:[e.jsx(B,{className:"pb-2",children:e.jsx(j,{className:"text-sm",children:"Quick Reply Chips"})}),e.jsxs(y,{className:"space-y-3",children:[e.jsx(m,{label:"Background",value:a.bubbleBackground,onChange:s=>r("bubbleBackground",s)}),e.jsx(m,{label:"Text",value:a.bubbleText,onChange:s=>r("bubbleText",s)}),e.jsx(m,{label:"Border",value:a.bubbleBorder,onChange:s=>r("bubbleBorder",s)})]})]}),e.jsxs(p,{children:[e.jsx(B,{className:"pb-2",children:e.jsx(j,{className:"text-sm",children:"Cart / Action Buttons"})}),e.jsxs(y,{className:"space-y-3",children:[e.jsx(m,{label:"Background",value:a.cartBackground,onChange:s=>r("cartBackground",s)}),e.jsx(m,{label:"Text",value:a.cartText,onChange:s=>r("cartText",s)}),e.jsx(m,{label:"Border",value:a.cartBorder,onChange:s=>r("cartBorder",s)})]})]}),e.jsxs(p,{children:[e.jsx(B,{className:"pb-2",children:e.jsx(j,{className:"text-sm",children:"Chat Backgroun
1d"})}),e.jsx(y,{className:"space-y-3",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{className:"text-xs font-medium",children:"Background Gradient"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[10px] text-muted-foreground/70",children:"Top"}),e.jsx("input",{type:"color",value:i.start,onChange:s=>h(s.target.value,i.end),className:"h-9 w-full rounded border border-gray-200 cursor-pointer",style:{padding:"2px"}})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[10px] text-muted-foreground/70",children:"Bottom"}),e.jsx("input",{type:"color",value:i.end,onChange:s=>h(i.start,s.target.value),className:"h-9 w-full rounded border border-gray-200 cursor-pointer",style:{padding:"2px"}})]})]}),e.jsx("div",{className:"h-8 rounded",style:{background:a.bgGradient}})]})})]})]})}function Pe({config:a,updateConfig:r}){var n;return e.jsxs(p,{children:[e.jsxs(B,{children:[e.jsx(j,{children:"Brand Identity"}),e.jsx(G,{children:"Customize the assistant's name and appearance"})]}),e.jsxs(y,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"assistantName",children:"Assistant Name"}),e.jsx(I,{id:"assistantName",value:a.assistantName,onChange:d=>r("assistantName",d.target.value),placeholder:"e.g., Don, Bella, Sophie"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"The name shown in the chat header and used in conversations"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"assistantAvatar",children:"Assistant Avatar URL"}),e.jsx(I,{id:"assistantAvatar",value:a.assistantAvatar,onChange:d=>r("assistantAvatar",d.target.value),placeholder:"https://... or emoji",className:"font-mono text-sm"}),((n=a.assistantAvatar)==null?void 0:n.startsWith("http"))&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("img",{src:a.assistantAvatar,alt:"Avatar preview",className:"w-10 h-10 rounded-full object-cover"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Avatar preview"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Image URL or emoji shown next to assistant messages"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"chatIcon",children:"Chat Button Icon"}),e.jsx(I,{id:"chatIcon",value:a.chatIcon,onChange:d=>r("chatIcon",d.target.value),placeholder:"ð¸",maxLength:2,className:"text-2xl h-12"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Emoji shown on the floating chat button"})]})]})]})}const M=[{value:"S",label:"S",caption:"Compact · 0.75Ã"},{value:"M",label:"M",caption:"Balanced · 0.875Ã"},{value:"L",label:"L",caption:"Spacious · 1.0à (current)"}];function Re({config:a,updateConfig:r}){var d;const n=a.chatSize||"L";return e.jsxs(p,{children:[e.jsxs(B,{children:[e.jsx(j,{className:"text-base",children:"Chat size"}),e.jsx(G,{children:"How dense should the chat widget feel? Scales widget size, fonts, product cards, and the suggestion drawer in one go."})]}),e.jsxs(y,{className:"space-y-4",children:[e.jsx("div",{className:"inline-flex rounded-lg border border-gray-300 overflow-hidden bg-gray-50",role:"radiogroup","aria-label":"Chat widget size",children:M.map((i,b)=>{const x=n===i.value;return e.jsx("button",{role:"radio","aria-checked":x,onClick:()=>r("chatSize",i.value),className:`px-6 py-2.5 text-sm font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary ${x?"bg-primary text-white":"text-muted-foreground hover:bg-gray-100"} ${b<M.length-1?"border-r border-gray-300":""}`,children:i.label},i.value)})}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[(d=M.find(i=>i.value===n))==null?void 0:d.caption," · Base font ",Math.round(16*ke[n]),"px"]})]})]})}function $e({background:a,textColor:r,borderBottom:n,avatar:d,name:i,statusText:b="Online now",isWhiteHeader:x,actions:h}){return e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 flex-shrink-0",style:{background:a,color:r,borderBottom:n},children:[e.jsxs("div",{className:"flex items-center gap-3",children:[d,e.jsxs("div",{children:[e.jsx("div",{className:"font-semibold text-sm",style:{color:"inherit"},children:i}),e.jsxs("div",{className:"flex items-center gap-1 text-[11px]",style:{color:x?"#64748b":"inherit",opacity:x?1:.75},children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-green-500"}),b]})]})]}),h&&e.jsx("div",{className:"flex items-center gap-1.5",style:{color:"inherit"},children:h})]})}function R({src:a,size:r=36}){return(a==null?void 0:a.startsWith("http"))?e.jsx("img",{src:a,alt:"",className:"rounded-full object-cover flex-shrink-0",style:{width:r,height:r}}):e.jsx("div",{className:"rounded-full flex items-center justify-center bg-gray-100 text-lg flex-shrink-0",style:{width:r,height:r},children:a})}const H=[{title:"Classic Love - 12 Red Roses",price:"â¬76.90",rating:4.9,reviews:127,image:"https://cdn.shopify.com/s/files/1/0895/6408/6600/files/FQ108_zcombo_c84c8d24-7103-4da7-9b51-a7777aa86f63.png?v=1771431313"},{title:"Classy Touch - White Roses",price:"â¬62.90",rating:4.8,reviews:89,image:"https://cdn.shopify.com/s/files/1/0895/6408/6600/files/66ed2048edcba708034671.jpg?v=1761282030"}
1],ze=["Bouquet","Under â¬70","Gift card","Ship to London","Same day"];function He({config:a}){var n;const r=a.headerBackground==="#ffffff"||a.headerBackground==="white"||((n=a.headerBackground)==null?void 0:n.startsWith("#fff"));return e.jsx(e.Fragment,{children:H.map(d=>e.jsxs("div",{className:"flex items-center gap-2 p-1.5 rounded-lg",style:{background:r?"#f8fafc":`${a.bubbleBackground}20`,border:`1px solid ${r?"#e2e8f0":a.bubbleBorder}66`},children:[e.jsx("img",{src:d.image,alt:d.title,className:"w-9 h-9 rounded-md object-cover flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-[11px] font-semibold truncate",style:{color:a.bubbleText},children:d.title}),e.jsxs("div",{className:"text-[10px] text-gray-400",children:[d.price," · â ",d.rating]})]}),e.jsx("span",{className:"text-sm text-gray-300",children:"âº"})]},d.title))})}function Oe({config:a,name:r,avatar:n}){return e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(R,{src:n,size:28}),e.jsxs("div",{className:"max-w-[78%] px-3 py-2 rounded-[16px] rounded-bl-[4px] text-xs text-gray-900 leading-relaxed",style:{background:a.assistantBubbleBackgroun
1d||"#f1f5f9",boxShadow:"0 1px 4px rgba(0,0,0,0.04)"},children:["Hey! I'm ",r,", your personal shopping assistant. Looking for something beautiful?"]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx("div",{className:"max-w-[70%] px-3 py-2 rounded-[16px] rounded-br-[4px] text-xs text-white leading-relaxed",style:{background:a.primaryColor,boxShadow:a.userBubbleShadow},children:"I need anniversary flowers, something elegant"})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(R,{src:n,size:28}),e.jsxs("div",{className:"max-w-[80%] px-3 py-2 rounded-[16px] rounded-bl-[4px] text-xs text-gray-900 space-y-1.5 leading-relaxed",style:{background:a.assistantBubbleBackground||"#f1f5f9",boxShadow:"0 1px 4px rgba(0,0,0,0.04)"},children:[e.jsx("p",{children:"How romantic! ð Two stunning arrangements:"}),e.jsx(He,{config:a})]})]})]})}function We({config:a}){return e.jsx("div",{className:"px-3 py-1.5 flex gap-1 overflow-x-auto",children:ze.map(r=>e.jsx("span",{className:"text-[10px] px-2.5 py-1 rounded-full whitespace-nowrap",style:{background:a.bubbleBackgroun
1d,color:a.bubbleText,border:`1.5px solid ${a.bubbleBorder}`},children:r},r))})}function Ue({config:a}){const r=H[0];return e.jsx("div",{className:"px-3 py-1.5",children:e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg",style:{background:`${a.bubbleBackground}30`,border:`1px solid ${a.bubbleBorder}60`},children:[e.jsx("img",{src:r.image,alt:"",className:"w-8 h-8 rounded-md object-cover"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-[9px] font-semibold uppercase tracking-wide",style:{color:a.bubbleText},children:"⨠My Recommendation"}),e.jsx("div",{className:"text-[11px] font-medium text-gray-900 truncate",children:r.title})]}),e.jsx("span",{className:"px-2.5 py-1 rounded-full text-[10px] font-semibold flex-shrink-0",style:{background:a.cartBackground,color:a.cartText,border:`1px solid ${a.cartBorder}`},children:"Let's go â"})]})})}function Ke({config:a}){return e.jsx("div",{className:"px-3 py-2.5 border-t border-gray-100",children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx("div",{className:"flex-1 rounded-full px-3 py-2 text-xs text-gray-400",style:{background:a.inputBackground||"#f8fafc",border:`1px solid ${a.inputBorderColor||"#e2e8f0"}`},children:"Type a message..."}),e.jsx("div",{className:"h-9 w-9 rounded-full flex items-center justify-center text-white flex-shrink-0",style:{background:a.sendButtonBackground},children:e.jsx(ve,{className:"h-3.5 w-3.5"})})]})})}function Ve({config:a}){return e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsx("div",{className:"flex border-b",children:["Suggestions","Cart","Feedback"].map(r=>e.jsxs("button",{className:`flex-1 px-3 py-2.5 text-xs font-medium transition-colors ${r==="Suggestions"?"border-b-2 text-gray-900":"text-gray-400"}`,style:r==="Suggestions"?{borderColor:a.accentColor||"#3B82F6"}:void 0,children:[r==="Suggestions"&&e.jsx(ne,{className:"h-3 w-3 inline mr-1"}),r==="Cart"&&e.jsx(P,{className:"h-3 w-3 inline mr-1"}),r]},r))}),e.jsx("div",{className:"flex-1 overflow-y-auto p-3 space-y-3",children:H.map(r=>e.jsxs("div",{className:"border rounded-xl overflow-hidden",style:{borderColor:a.productCardBorder||"#f1f5f9",boxShadow:a.productCardShadow},children:[e.jsx("div",{className:"h-[200px] overflow-hidden",children:e.jsx("img",{src:r.image,alt:r.title,className:"w-full h-full object-cover"})}),e.jsxs("div",{className:"p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx("h4",{className:"text-sm font-bold text-gray-900 line-clamp-2",children:r.title}),e.jsx("span",{className:"text-base font-bold flex-shrink-0",style:{color:a.accentColor},children:r.price})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[Array.from({length:5}).map((n,d)=>e.jsx(_e,{className:`h-3.5 w-3.5 ${d<Math.floor(r.rating)?"fill-yellow-400 text-yellow-400":"fill-gray-200 text-gray-200"}`},d)),e.jsxs("span",{className:"text-xs text-gray-500 ml-1",children:[r.rating," (",r.reviews,")"]})]}),e.jsxs("button",{className:"w-full py-2 rounded-lg text-xs font-semibold border-2 flex items-center justify-center gap-1.5",style:{background:a.cartBackground,color:a.cartText,borderColor:a.cartBorder},children:[e.jsx(P,{className:"h-3.5 w-3.5"})," Select This One"]})]})]},r.title))})]})}function qe({config:a}){var g;const r=a,n=r.assistantName||$,d=r.assistantAvatar||z,i=r.headerBackground==="#ffffff"||r.headerBackground==="white"||((g=r.headerBackground)==null?void 0:g.startsWith("#fff")),[b,x]=f.useState(!1),h=Ce(r.defaultLanguage),s={S:.75,M:.875,L:1}[r.chatSize||"L"];return e.jsx(Ne,{frameStyle:r.chatFrameStyle||"flat",chatBg:r.bgGradient||"#ffffff",primaryColor:r.primaryColor,chatWidth:r.chatWidth,drawerWidth:r.drawerWidth,chatHeight:r.chatHeight,chatScale:s,drawerOpen:b,onDrawerToggle:()=>x(!b),drawerContent:e.jsx(Ve,{config:r}),header:e.jsx($e,{background:r.headerBackground,textColor:r.headerTextColor,borderBottom:r.headerBorderBottom,avatar:e.jsx(R,{src:d,size:38}),name:n,statusText:h.chat.onlineNow,isWhiteHeader:i,actions:e.jsxs(e.Fragment,{children:[e.jsx(Ae,{className:"h-3.5 w-3.5 opacity-60"}),e.jsx(Fe,{className:"h-3.5 w-3.5 opacity-60"}),e.jsx(P,{className:"h-3.5 w-3.5 opacity-60"}),e.jsx(oe,{className:"h-3.5 w-3.5 opacity-60"})]})}),chips:e.jsxs(e.Fragment,{children:[e.jsx(We,{config:r}),e.jsx(Ue,{config:r})]}),inputBar:e.jsx(Ke,{config:r}),children:e.jsx(Oe,{config:r,name:n,avatar:d})})}function Qe({selectedSkin:a,config:r}){var n;return e.jsxs(p,{children:[e.jsx(B,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(j,{className:"flex items-center gap-2",children:[e.jsx(Ie,{className:"h-5 w-5"}),"Live Preview"]}),e.jsx(G,{children:"See your changes in real-time"})]}),e.jsx("span",{className:"text-xs font-medium px-2 py-1 rounded-full bg-blue-50 text-primary",children:((n=we[a])==null?void 0:n.label)||"Custom"})]})}),e.jsx(y,{children:e.jsx(qe,{config:r})})]})}function F(a,r){return{assistantName:(r==null?void 0:r.assistantName)||$,assistantAvatar:(r==null?void 0:r.assistantAvatar)||z,chatIcon:(r==null?void 0:r.chatIcon)||"ð ",primaryColor:a.primaryColor,accentColor:a.accentColor,headerBackgroun
1d:a.headerBackground,headerTextColor:a.headerTextColor,headerBorderBottom:a.headerBorderBottom,bubbleBackground:a.bubbleBackground,bubbleText:a.bubbleText,bubbleBorder:a.bubbleBorder,assistantBubbleBackground:a.assistantBubbleBackground,userBubbleShadow:a.userBubbleShadow,cartBackground:a.cartButtonBackground,cartText:a.cartButtonText,cartBorder:a.cartButtonBorder,inputBorderColor:a.inputBorderColor,inputBackground:a.inputBackground,sendButtonBackground:a.sendButtonBackground,bgGradient:a.chatBackgroundGradient,productCardBorder:a.productCardBorder,productCardShadow:a.productCardShadow,chatFrameStyle:a.chatFrameStyle,chatSize:"L"}}function ga(){const{toast:a}=de(),r=le(),{shopId:n}=ce(),{userShops:d}=ie(),i=ue(),{data:b,isLoading:x,update:h}=ye(n),[s,g]=f.useState(null),[u,S]=f.useState("");f.useEffect(()=>{if(!n)return;let o=!1;return(async()=>{try{const t=await O("don","chat-design","read",{shopId:n});if(o)return;if(g(t.design),t.shopifyDomain){const k=t.shopifyDomain.replace(".myshopify.com","").split("-").map(v=>v.charAt(0).toUpperCase()+v.slice(1)).join(" ");S(k)}}catch(t){console.warn("[ChatDesign] /v1/don/chat-design:read failed:",t)}})(),()=>{o=!0}},[n]);const[Z,J]=f.useState("en");f.useEffect(()=>{if(!n)return;let o=!1;return(async()=>{var t;try{const k=await fetch(`https://bgivcrhwvvlnbokhwwwl.supabase.co/rest/v1/shop_settings?shop_id=eq.${n}&select=default_language`,{headers:{apikey:"sb_publishable_9KAONvqB29TfkhvZePrCSA_kVeclAKp",Authorization:"Bearer sb_publishable_9KAONvqB29TfkhvZePrCSA_kVeclAKp"}});if(!k.ok||o)return;const v=await k.json(),c=(t=v==null?void 0:v[0])==null?void 0:t.default_language;c&&typeof c=="string"&&J(c)}catch{}})(),()=>{o=!0}},[n]);const[l,N]=f.useState(()=>F(A(w))),[D,E]=f.useState(w),[X,Y]=Se(["presets","colors","branding","dimensions"],"presets"),L=(o,t)=>{N(k=>({...k,[o]:t}))},ee=o=>{E(o),N(F(A(o),{assistantName:l.assistantName,assistantAvatar:l.assistantAvatar,chatIcon:l.chatIcon}))};f.useEffect(()=>{var o;if(b){const t=b,k=t.chat_skin||w,v=A(k);E(k);const c=F(v,{chatIcon:t.chat_icon||(s==null?void 0:s.widget_icon)||"ð ",assistantName:(s==null?void 0:s.assistant_name)||$,assistantAvatar:((o=t.assistant_avatar)!=null&&o.startsWith("http")?t.assistant_avatar:null)||z});N({...c,defaultLanguage:(s==null?void 0:s.default_language)||"en",primaryColor:t.primary_color||c.primaryColor,accentColor:t.accent_color||c.accentColor,headerBackground:t.header_background||c.headerBackground,headerTextColor:t.header_text_color||c.headerTextColor,headerBorderBottom:t.header_border_bottom||c.headerBorderBottom,bubbleBackgroun
1d:t.bubble_background_color||c.bubbleBackground,bubbleText:t.bubble_text_color||c.bubbleText,bubbleBorder:t.bubble_border_color||c.bubbleBorder,assistantBubbleBackground:t.assistant_bubble_background||c.assistantBubbleBackground,userBubbleShadow:t.user_bubble_shadow||c.userBubbleShadow,cartBackground:t.cart_button_background||c.cartBackground,cartText:t.cart_button_text||c.cartText,cartBorder:t.cart_button_border||c.cartBorder,inputBorderColor:t.input_border_color||c.inputBorderColor,inputBackground:t.input_background||c.inputBackground,sendButtonBackground:t.send_button_background||c.sendButtonBackground,bgGradient:t.chat_background_gradient||c.bgGradient,productCardBorder:t.product_card_border||c.productCardBorder,productCardShadow:t.product_card_shadow||c.productCardShadow,chatFrameStyle:t.chat_frame_style||c.chatFrameStyle,chatSize:t.chat_size||c.chatSize})}},[b,s]);const ae=async()=>{if(!n){a({title:"Error",description:"Please select a shop first",variant:"destructive"});return}try{await O("don","chat-design","write",{shopId:n,design:{chat_skin:D,assistant_name:l.assistantName,widget_icon:l.chatIcon,assistant_avatar:l.assistantAvatar,primary_color:l.primaryColor,accent_color:l.accentColor,header_background:l.headerBackground,header_text_color:l.headerTextColor,header_border_bottom:l.headerBorderBottom,bubble_background_color:l.bubbleBackgroun
1d,bubble_text_color:l.bubbleText,bubble_border_color:l.bubbleBorder,assistant_bubble_background:l.assistantBubbleBackground,user_bubble_shadow:l.userBubbleShadow,cart_button_background:l.cartBackground,cart_button_text:l.cartText,cart_button_border:l.cartBorder,input_border_color:l.inputBorderColor,input_background:l.inputBackground,send_button_background:l.sendButtonBackground,chat_background_gradient:l.bgGradient,product_card_border:l.productCardBorder,product_card_shadow:l.productCardShadow,chat_frame_style:l.chatFrameStyle,chat_size:l.chatSize}}),r.invalidateQueries({queryKey:["store-config",n]}),a({title:"Saved",description:"Chat design settings saved."})}catch(o){console.error("Error saving config:",(o==null?void 0:o.message)||(o==null?void 0:o.details)||JSON.stringify(o)),a({title:"Error",description:(o==null?void 0:o.message)||"Failed to save settings.",variant:"destructive"})}},re=o=>{N(t=>({...t,primaryColor:o.primaryColor||t.primaryColor,accentColor:o.accentColor||t.accentColor,chatIcon:o.chatIcon||t.chatIcon,headerBackground:o.headerBackground||t.headerBackground,headerTextColor:o.headerTextColor||t.headerTextColor,assistantBubbleBackgroun
1d:o.assistantBubbleBackground||t.assistantBubbleBackground,bubbleBackground:o.bubbleBackground||t.bubbleBackground,bubbleText:o.bubbleText||t.bubbleText,bubbleBorder:o.bubbleBorder||t.bubbleBorder,cartBackground:o.cartBackground||t.cartBackground,cartText:o.cartText||t.cartText,cartBorder:o.cartBorder||t.cartBorder,bgGradient:o.bgGradient||t.bgGradient,sendButtonBackground:o.primaryColor||t.primaryColor}))},te=()=>{confirm("Reset all design settings to defaults?")&&(E(w),N(F(A(w),{assistantName:l.assistantName,assistantAvatar:l.assistantAvatar,chatIcon:l.chatIcon})))};return e.jsx("div",{className:"flex-1 p-8 overflow-auto",children:e.jsxs("div",{className:"max-w-6xl mx-auto space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(je,{title:"Chat Design",pageId:"chat-design"}),e.jsx("p",{className:"text-muted-foreground -mt-4 mb-2",children:"Customize your chat widget to match your store's brand"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[d.length>0?e.jsxs(ge,{value:n,onValueChange:o=>i(`/shop/${o}/chat-design`),children:[e.jsxs(he,{className:"w-full sm:w-[200px]",children:[e.jsx(W,{className:"h-4 w-4 mr-2 text-muted-foreground"}),e.jsx(me,{})]}),e.jsx(pe,{children:d.map(o=>e.jsx(Be,{value:o.id,children:o.name},o.id))})]}):e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 rounded-md border text-sm text-muted-foreground",children:[e.jsx(W,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs",children:u||"Loading..."})]}),e.jsxs(U,{variant:"outline",onClick:te,children:[e.jsx(be,{className:"h-4 w-4 mr-2"}),"Reset"]}),e.jsxs(U,{onClick:ae,disabled:h.isPending||x,children:[e.jsx(Ge,{className:"h-4 w-4 mr-2"}),h.isPending?"Saving...":"Save"]})]})]}),e.jsxs(fe,{value:X,onValueChange:Y,className:"w-full",children:[e.jsxs(xe,{className:"grid w-full grid-cols-2 sm:grid-cols-4 h-auto",children:[e.jsx(T,{value:"presets",children:"Presets"}),e.jsx(T,{value:"colors",children:"Colors"}),e.jsx(T,{value:"branding",children:"Branding"}),e.jsx(T,{value:"dimensions",children:"Dimensions"})]}),e.jsx(_,{value:"presets",className:"mt-4",children:e.jsx(De,{selectedSkin:D,onApply:(o,t)=>{ee(o),re(t)}})}),e.jsx(_,{value:"colors",className:"mt-4",children:e.jsx(Me,{config:l,updateConfig:L})}),e.jsx(_,{value:"branding",className:"mt-4",children:e.jsx(Pe,{config:l,updateConfig:L})}),e.jsx(_,{value:"dimensions",className:"mt-4",children:e.jsx(Re,{config:l,updateConfig:L})})]}),e.jsx(Qe,{selectedSkin:D,config:{...l,defaultLanguage:Z}})]})})}export{ga 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.