import{j as t}from"./jsx-runtime.D_zvdyIk.js";import{r as x}from"./index.DIfZGIpv.js";function p({sizes:c}){const[r,s]=x.useState(!1),n=[...c].sort((e,l)=>parseFloat(e)-parseFloat(l)),a=10,i=n.length>a,o=r?n:n.slice(0,a);return t.jsxs("div",{children:[t.jsxs("button",{onClick:e=>{e.preventDefault(),s(!r)},className:"text-xs text-text-muted hover:text-accent transition-colors",children:["· ",c.length," maten ",r?"▾":"▸"]}),r&&t.jsxs("div",{className:"mt-1 flex flex-wrap gap-1",children:[o.map(e=>t.jsx("span",{className:"rounded bg-bg-elevated px-1.5 py-0.5 text-[10px] text-text-muted",children:e},e)),i&&!r&&t.jsxs("span",{className:"text-[10px] text-text-muted",children:["en ",n.length-a," meer"]})]})]})}function h({offers:c,lowestPrice:r,selectedSize:s,sneakerData:n}){const i=[...s?c.filter(e=>e.sizes.includes(s)):c].sort((e,l)=>e.price-l.price),o=e=>{n&&(window.dataLayer=window.dataLayer||[],window.dataLayer.push({ecommerce:null}),window.dataLayer.push({event:"select_promotion",ecommerce:{promotion_id:e.shop,promotion_name:e.shop,items:[n]}}),window.dataLayer.push({event:"outbound_click",destination_url:e.url,shop_name:e.shop}))};return t.jsxs("div",{className:"overflow-hidden rounded-2xl border border-border/50",children:[t.jsx("div",{className:"bg-bg-elevated px-4 py-3",children:t.jsxs("h3",{className:"text-sm font-bold uppercase tracking-widest text-text-muted",children:["Prijsvergelijking",s&&t.jsxs("span",{className:"ml-2 text-accent",children:["· Maat ",s]})]})}),i.length===0?t.jsxs("div",{className:"px-4 py-8 text-center text-sm text-text-muted",children:["Geen shops gevonden met maat ",s]}):t.jsx("div",{className:"divide-y divide-border/30",children:i.map((e,l)=>{const d=e.price===Math.min(...i.map(m=>m.price));return t.jsxs("div",{className:`flex items-center gap-4 px-4 py-4 transition-colors hover:bg-bg-hover ${l===0?"bg-accent/5":""}`,children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"font-semibold text-text",children:e.shop}),d&&t.jsx("span",{className:"rounded-full bg-accent/20 px-2 py-0.5 text-[10px] font-bold text-accent",children:"LAAGSTE"})]}),t.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[e.inStock?t.jsx("span",{className:"text-xs text-accent",children:"✓ Op voorraad"}):t.jsx("span",{className:"text-xs text-danger",children:"✗ Uitverkocht"}),e.sizes.length>0&&t.jsx(p,{sizes:e.sizes})]})]}),t.jsx("div",{className:"text-right",children:t.jsxs("div",{className:"flex items-baseline gap-2",children:[e.originalPrice&&e.originalPrice>e.price&&t.jsxs("span",{className:"text-sm text-text-muted line-through",children:["€",e.originalPrice.toFixed(2).replace(".",",")]}),t.jsxs("span",{className:`text-lg font-black ${d?"text-accent":"text-text"}`,children:["€",e.price.toFixed(2).replace(".",",")]})]})}),t.jsx("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>o(e),className:`rounded-xl px-4 py-2 text-sm font-bold transition-all ${e.inStock?"bg-accent text-bg hover:bg-accent-dim hover:shadow-lg hover:shadow-accent/20":"cursor-not-allowed bg-surface text-text-muted"}`,children:"Bekijk"})]},e.shop)})})]})}function b({offers:c,lowestPrice:r,sizes:s,sneakerData:n}){const[a,i]=x.useState(null),o=[...s].sort((e,l)=>parseFloat(e)-parseFloat(l));return t.jsxs("div",{children:[o.length>0&&t.jsxs("div",{className:"mb-4",children:[t.jsx("h4",{className:"mb-2 text-xs font-bold uppercase tracking-widest text-text-muted",children:"Filter op maat"}),t.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[t.jsx("button",{onClick:()=>i(null),className:`rounded-lg px-3 py-1.5 text-xs font-bold transition-colors ${a===null?"bg-accent text-bg":"bg-bg-elevated text-text-muted hover:text-text"}`,children:"Alle maten"}),o.map(e=>{const l=c.some(d=>d.inStock&&d.sizes.includes(e));return t.jsx("button",{onClick:()=>i(a===e?null:e),className:`rounded-lg px-3 py-1.5 text-xs font-bold transition-colors ${a===e?"bg-accent text-bg":l?"bg-bg-elevated text-text-muted hover:text-text":"bg-bg-elevated text-text-muted/40"}`,children:e},e)})]})]}),t.jsx(h,{offers:c,lowestPrice:r,sneakerData:n,selectedSize:a})]})}export{b as default};
