import{r,j as e}from"./vendor-react-Ci7aBfa0.js";import{u as k,b as q,i as P,d as $,a as E,n as R}from"./index-Bc-jHh02.js";import{t as z}from"./vendor-ui-X4tvFhT0.js";import{b as W,p as I,S as M}from"./SEO-DMWyZzYz.js";import{P as B}from"./ProductReviews-C6I8yLPS.js";import{s as J}from"./prerender-CvGl2zE9.js";import{c as O,L as l}from"./vendor-Clsy4qE9.js";import{b as g,m as T,n as G,e as Q,d as _,G as H}from"./vendor-icons-4GGNjGXS.js";import"./vendor-helmet-X7vXU3pT.js";const K={securite:"Sécurité",surveillance:"Surveillance",connectivite:"Connectivité",confort:"Confort"};function re(){const{id:n}=O(),{addItem:b}=k(),[i,d]=r.useState(1),[s,f]=r.useState(null),[m,j]=r.useState([]),[x,N]=r.useState([]),[v,y]=r.useState(Object.entries(K).map(([t,a])=>({key:t,label:a}))),[o,h]=r.useState(!0);r.useEffect(()=>{window.scrollTo(0,0),n&&w(n),q("accessory").then(t=>{t&&t.length>0&&y(t.map(a=>({key:a.key,label:a.label})))}).catch(()=>{})},[n]),r.useEffect(()=>{o||J()},[o]);async function w(t){try{h(!0);const a=await P(t);f(a);const L=await $();j(L.filter(c=>c.id!==t&&c.category===a.category).slice(0,4));const p=a.compatibleWith?typeof a.compatibleWith=="string"?JSON.parse(a.compatibleWith):a.compatibleWith:[];if(p.length>0){const c=await E();N(c.filter(D=>p.includes(D.category)))}}catch{z.error("Accessoire non trouvé")}finally{h(!1)}}if(o)return e.jsx("div",{className:"min-h-screen pt-24 flex items-center justify-center",children:e.jsx("div",{className:"w-8 h-8 border-4 border-[#D45A00] border-t-transparent rounded-full animate-spin"})});if(!s)return e.jsx("div",{className:"min-h-screen pt-24 flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold text-[#333333] mb-4",children:"Accessoire non trouvé"}),e.jsx(l,{to:"/boutique",className:"text-[#D45A00] hover:underline",children:"Retour à la boutique"})]})});const A=()=>{b({productId:s.id,name:s.name,price:s.price,quantity:i,image:s.image,type:"accessory"})},F=v.find(t=>t.key===s.category)?.label??s.category,u=R(s.specs),C=W([{name:"Accueil",url:"/"},{name:"Boutique",url:"/boutique"},{name:s.name,url:`/accessoire/${s.id}`}]),S=I(s.name,s.description,s.price,s.image,void 0,"InStock",`https://abidjangps.com/accessoire/${s.id}`);return e.jsxs("main",{className:"min-h-screen pt-20 md:pt-24 pb-16 bg-white",children:[e.jsx(M,{title:`${s.name} — Accessoire GPS Abidjan`,description:`${s.description} Achetez à ${s.price.toLocaleString()} FCFA. Livraison rapide Abidjan.`,url:`/accessoire/${s.id}`,type:"product",price:s.price,image:s.image,jsonLd:[S,C]}),e.jsxs("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:[e.jsxs("nav",{className:"text-sm text-gray-500 mb-6",children:[e.jsx(l,{to:"/",className:"hover:text-[#D45A00]",children:"Accueil"}),e.jsx(g,{className:"w-4 h-4 inline mx-1"}),e.jsx(l,{to:"/boutique",className:"hover:text-[#D45A00]",children:"Boutique"}),e.jsx(g,{className:"w-4 h-4 inline mx-1"}),e.jsx("span",{className:"text-[#333333] font-medium",children:s.name})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-10 lg:gap-16",children:[e.jsx("div",{children:e.jsx("div",{className:"aspect-square bg-[#F2F2F2] rounded-xl overflow-hidden",children:e.jsx("img",{src:s.image,alt:s.name,className:"w-full h-full object-cover",loading:"lazy"})})}),e.jsxs("div",{children:[e.jsx("span",{className:"text-xs uppercase tracking-wider px-3 py-1 bg-[#F2F2F2] rounded-full text-gray-500 font-medium",children:F}),e.jsx("h1",{className:"text-2xl md:text-3xl font-bold text-[#333333] mt-2 mb-2",children:s.name}),e.jsxs("p",{className:"text-3xl md:text-4xl font-bold text-[#D45A00] mb-4",children:[s.price.toLocaleString()," FCFA"]}),e.jsx("p",{className:"text-gray-600 mb-6 leading-relaxed",children:s.longDescription||s.description}),e.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[e.jsx("span",{className:"text-sm font-medium text-[#333333]",children:"Quantité :"}),e.jsxs("div",{className:"flex items-center border rounded-lg",children:[e.jsx("button",{onClick:()=>d(Math.max(1,i-1)),className:"w-11 h-11 min-w-11 min-h-11 flex items-center justify-center hover:bg-[#F2F2F2]",children:e.jsx(T,{className:"w-4 h-4"})}),e.jsx("span",{className:"w-12 text-center font-semibold",children:i}),e.jsx("button",{onClick:()=>d(Math.min(10,i+1)),className:"w-11 h-11 min-w-11 min-h-11 flex items-center justify-center hover:bg-[#F2F2F2]",children:e.jsx(G,{className:"w-4 h-4"})})]})]}),e.jsxs("div",{className:"flex items-center justify-between mb-6 p-4 bg-[#D45A00]/5 rounded-lg",children:[e.jsx("span",{className:"font-medium text-[#333333]",children:"Total :"}),e.jsxs("span",{className:"text-2xl font-bold text-[#D45A00]",children:[(s.price*i).toLocaleString()," FCFA"]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsxs("button",{onClick:A,className:"flex-1 py-4 bg-[#D45A00] text-white rounded-lg font-bold text-lg hover:bg-[#E55A00] transition-all flex items-center justify-center gap-2",children:[e.jsx(Q,{className:"w-5 h-5"})," Ajouter au panier"]}),e.jsxs("a",{href:`https://wa.me/2250170090932?text=Bonjour, je souhaite commander ${s.name} (${s.price.toLocaleString()} FCFA)`,target:"_blank",rel:"noopener noreferrer",className:"flex-1 py-4 bg-[#25D366] text-white rounded-lg font-bold text-lg hover:bg-[#128C7E] transition-all flex items-center justify-center gap-2",children:[e.jsx(_,{className:"w-5 h-5"})," Commander sur WhatsApp"]})]}),u.length>0&&e.jsxs("div",{className:"mt-10",children:[e.jsx("h3",{className:"text-xl font-bold text-[#333333] mb-4",children:"Caractéristiques techniques"}),e.jsx("div",{className:"border rounded-xl overflow-hidden overflow-x-auto",children:e.jsx("table",{className:"w-full text-sm min-w-[280px]",children:e.jsx("tbody",{children:u.map((t,a)=>e.jsxs("tr",{className:a%2===0?"bg-[#F2F2F2]":"bg-white",children:[e.jsx("td",{className:"px-4 py-3 font-medium text-[#333333] capitalize",children:t.label}),e.jsx("td",{className:"px-4 py-3 text-gray-600 break-all",children:t.value})]},a))})})})]}),x.length>0&&e.jsxs("div",{className:"mt-6 p-4 bg-green-50 rounded-xl",children:[e.jsxs("h4",{className:"font-semibold text-green-800 mb-2 flex items-center gap-2",children:[e.jsx(H,{className:"w-4 h-4"})," Compatible avec"]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:x.map(t=>e.jsx(l,{to:`/produit/${t.id}`,className:"px-3 py-1 bg-white rounded-full text-sm text-green-700 border border-green-200 hover:bg-green-100 transition-colors",children:t.name},t.id))})]})]})]}),m.length>0&&e.jsxs("div",{className:"mt-16",children:[e.jsx("h2",{className:"text-2xl font-bold text-[#333333] mb-6",children:"Accessoires similaires"}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-6",children:m.map(t=>e.jsxs(l,{to:`/accessoire/${t.id}`,className:"group bg-white border border-gray-100 rounded-xl overflow-hidden hover:shadow-xl hover:-translate-y-1 transition-all duration-300",children:[e.jsx("div",{className:"aspect-square bg-[#F2F2F2] overflow-hidden",children:e.jsx("img",{src:t.image,alt:t.name,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-500",loading:"lazy"})}),e.jsxs("div",{className:"p-4",children:[e.jsx("h3",{className:"font-semibold text-[#333333] group-hover:text-[#D45A00] transition-colors",children:t.name}),e.jsxs("p",{className:"text-lg font-bold text-[#D45A00] mt-1",children:[t.price.toLocaleString()," FCFA"]})]})]},t.id))})]}),e.jsx(B,{productId:s.id})]})]})}export{re as default};