import{t as h,af as x,K as e,H as b,a9 as l,L as c,N as g,m as f,g as u,ag as p}from"./index-CqfREQhZ.js";import{p as m,f as d}from"./products-Q1MHi1iw.js";import{S as w}from"./star-DW-815Mn.js";const j=[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]],y=h("share-2",j);async function N(s){const{title:a,text:o,url:n,imageUrl:r}=s,i=[o,"",`View this product: ${n}`,r?`Image: ${r}`:""].filter(Boolean).join(`
`);if(navigator.share)return await navigator.share({title:a,text:i,url:n}),"shared";if(navigator.clipboard)return await navigator.clipboard.writeText(`${a}

${i}`),"copied";const t=encodeURIComponent(`${a}

${i}`);return window.location.href=`mailto:?subject=${encodeURIComponent(a)}&body=${t}`,"emailed"}function P({product:s}){const{addToCart:a,toggleWishlist:o,wishlist:n}=x(),r=n.includes(s.id),i=typeof window>"u"?"":window.location.origin;return e.jsxs("div",{className:"group bg-card rounded-2xl border border-border overflow-hidden hover-lift relative transition-all duration-300 col-span-full sm:col-span-1 w-full",children:[s.badge&&e.jsx("span",{className:"absolute top-3 left-3 z-10 bg-brand text-white text-[10px] font-bold px-2.5 py-1 rounded-full shadow-md",children:s.badge}),e.jsx("button",{onClick:()=>{o(s.id),l.success(r?"Removed from wishlist":"Added to wishlist")},className:`absolute top-3 right-3 z-10 w-10 h-10 grid place-items-center rounded-full backdrop-blur-sm border transition-all ${r?"bg-brand text-white border-brand shadow-lg":"bg-white/80 text-muted-foreground border-border hover:bg-white hover:text-brand hover:border-brand"}`,"aria-label":"Wishlist",children:e.jsx(b,{className:`w-5 h-5 ${r?"fill-current":""}`})}),e.jsx("div",{className:"relative aspect-square overflow-hidden bg-secondary group",children:e.jsx(c,{to:"/product/$id",params:{id:s.id},className:"block w-full h-full",children:e.jsx("img",{src:m(s),alt:s.name,loading:"lazy",onError:t=>{t.currentTarget.src=g},className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"})})}),e.jsxs("div",{className:"p-4 space-y-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] uppercase tracking-widest font-semibold text-brand/60 mb-1",children:s.brand}),e.jsx(c,{to:"/product/$id",params:{id:s.id},className:"block font-semibold text-sm leading-tight line-clamp-2 hover:text-brand transition",children:s.name})]}),e.jsxs("div",{className:"flex items-center gap-1.5 text-xs",children:[e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx(w,{className:"w-3.5 h-3.5 fill-amber-400 text-amber-400"}),e.jsx("span",{className:"font-semibold text-foreground",children:s.rating})]}),e.jsxs("span",{className:"text-muted-foreground",children:["(",s.reviews,")"]})]}),e.jsxs("div",{className:"flex items-center gap-2 py-2 border-t border-b border-border/50",children:[e.jsx("span",{className:"text-lg font-bold text-brand",children:d(s.price)}),s.oldPrice&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-sm text-muted-foreground line-through",children:d(s.oldPrice)}),s.oldPrice&&e.jsxs("span",{className:"ml-auto text-xs font-bold bg-rose-100 text-rose-700 px-2 py-0.5 rounded-full",children:["-",Math.round((Number(s.oldPrice)-s.price)/Number(s.oldPrice)*100),"%"]})]})]}),e.jsxs("button",{onClick:()=>{a(s),l.success("Added to cart")},className:"w-full inline-flex items-center justify-center gap-2 bg-gradient-to-r from-brand to-[#ff8f1f] text-white font-semibold py-2.5 rounded-xl shadow-md hover:shadow-lg hover:brightness-110 transition-all active:scale-95",children:[e.jsx(f,{className:"w-4.5 h-4.5"}),e.jsx("span",{className:"inline",children:"Add to Cart"})]}),e.jsxs("div",{className:"flex gap-1.5 pt-1",children:[e.jsxs("a",{href:p(`Hi Amazing Soko, I want to buy this product:

*${s.name}*
${s.description}
Price: ${d(s.price)}
Link: ${i||`/product/${s.id}`}

Name:
Address:
Phone:`),target:"_blank",rel:"noreferrer",className:"flex-1 inline-flex items-center justify-center gap-1.5 bg-[#25D366] hover:bg-[#1da851] text-white font-medium py-2 rounded-lg transition border border-transparent shadow-sm",title:"Buy now via WhatsApp",children:[e.jsx(u,{className:"w-4 h-4 text-white"}),e.jsx("span",{className:"inline text-xs",children:"Buy Now"})]}),e.jsxs("button",{onClick:async()=>{try{const t=await N({title:s.name,text:s.description,url:`${window.location.origin}/product/${s.id}`,imageUrl:m(s)});l.success(t==="shared"?"Product shared successfully":"Product link copied to clipboard")}catch{l.error("Unable to share product. Please try again.")}},className:"flex-1 inline-flex items-center justify-center gap-1.5 bg-slate-50 hover:bg-slate-100 text-slate-700 font-medium py-2 rounded-lg transition border border-slate-200/50",title:"Share product",children:[e.jsx(y,{className:"w-4 h-4"}),e.jsx("span",{className:"inline text-xs",children:"Share"})]})]})]})]})}export{P,y as S,N as s};
