import{o as e,r as t,t as n}from"./jsx-runtime-BbTa8W_M-1776590214964.js";import{o as r,r as i}from"./app-CXDQ5oEH-1776590214964.js";import{t as a}from"./useTranslation-D1etqd9u-1776590214964.js";import{t as o}from"./chevron-left-BPh9np_P-1776590214964.js";import{t as s}from"./chevron-right-CQG1mCkM-1776590214964.js";import{t as c}from"./clock-DUm1_ul1-1776590214964.js";import{t as l}from"./shopping-bag-DWQqpg3Q-1776590214964.js";import{t as u}from"./button-WiAFyHfP-1776590214964.js";import{n as d,t as f}from"./card-Cby8flFO-1776590214964.js";var p=e(t(),1),m=n();function h({superDeals:e}){let{activeCurrency:t,currencies:n}=r().props,{t:h}=a(),g=(0,p.useRef)(null),[_,v]=(0,p.useState)(!1),[y,b]=(0,p.useState)(!1),x=()=>{if(g.current){let{scrollLeft:e,scrollWidth:t,clientWidth:n}=g.current;v(e>0),b(Math.ceil(e+n)<t-2)}};(0,p.useEffect)(()=>(x(),window.addEventListener(`resize`,x),()=>window.removeEventListener(`resize`,x)),[e]);let S=e=>{g.current&&g.current.scrollBy({left:e===`left`?-300:300,behavior:`smooth`})};if(!e||e.length===0)return null;let C=t?.symbol||`$`,w=t?parseFloat(t.exchange_rate):1;return(0,m.jsxs)(`div`,{className:`mb-10 relative group`,children:[(0,m.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,m.jsx)(`div`,{className:`flex items-center gap-4`,children:(0,m.jsxs)(`h3`,{className:`text-xl md:text-2xl font-bold flex items-center gap-2`,children:[(0,m.jsx)(`span`,{className:`bg-red-500 text-white p-1 rounded-md`,children:(0,m.jsx)(c,{className:`w-5 h-5`})}),h(`Super Deals`)]})}),(0,m.jsx)(u,{variant:`link`,className:`text-primary pr-0`,asChild:!0,children:(0,m.jsxs)(i,{href:route(`deals.index`),children:[h(`View All`),` `,(0,m.jsx)(s,{className:`w-4 h-4 ml-1`})]})})]}),(0,m.jsxs)(`div`,{className:`relative`,children:[_&&(0,m.jsx)(`button`,{onClick:()=>S(`left`),className:`absolute -left-4 top-1/2 -translate-y-1/2 z-30 w-10 h-10 rounded-full bg-card border shadow-lg flex items-center justify-center hover:bg-muted transition-all text-primary`,children:(0,m.jsx)(o,{className:`w-6 h-6`})}),(0,m.jsx)(`div`,{ref:g,onScroll:x,className:`flex overflow-x-auto no-scrollbar gap-4 pb-4 scroll-smooth`,children:e.map(e=>{let t=e.images?.find(e=>e.is_main)||e.images?.[0],r=n?.find(t=>t.code===(e.currency_code||`USD`))?.exchange_rate||1,a=parseFloat(e.original_price||e.price||0)/parseFloat(r)*w,o=parseFloat(e.discount_percentage)||0,s=parseFloat(e.seller?.flash_sale_percentage)||0,c=Math.max(o,s),u=a-c/100*a;return(0,m.jsx)(i,{href:route(`product.view`,`${e.slug}_${e.id}`),className:`shrink-0`,children:(0,m.jsx)(f,{className:`w-[180px] sm:w-[220px] border-border/50 shadow-sm hover:shadow-md transition-all cursor-pointer group bg-card h-full flex flex-col`,children:(0,m.jsxs)(d,{className:`p-3 flex-1 flex flex-col`,children:[(0,m.jsx)(`div`,{className:`w-full h-[140px] sm:h-[180px] rounded-lg bg-white mb-3 flex items-center justify-center overflow-hidden border`,children:t?(0,m.jsx)(`img`,{src:`/storage/${t.path}`,className:`w-full h-full object-contain`,alt:e.title}):(0,m.jsx)(l,{className:`w-10 h-10 text-muted-foreground/20`})}),(0,m.jsx)(`p`,{className:`text-sm font-normal text-muted-foreground group-hover:text-primary transition-colors truncate mb-1`,title:e.title,children:e.title}),(0,m.jsxs)(`div`,{className:`flex items-end gap-2 mb-2 mt-auto`,children:[(0,m.jsxs)(`span`,{className:`text-red-500 font-bold text-lg`,children:[C,u.toFixed(2)]}),(0,m.jsxs)(`span`,{className:`text-muted-foreground text-xs line-through pb-0.5`,children:[C,a.toFixed(2)]})]}),(0,m.jsxs)(`div`,{className:`w-full bg-muted rounded-full h-4 mb-1 overflow-hidden relative`,children:[(0,m.jsx)(`div`,{className:`bg-red-500/20 absolute inset-0`}),(0,m.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center text-[9px] font-bold text-red-700`,children:h(`:percent% OFF`,{percent:c})})]})]})})},e.id)})}),y&&(0,m.jsx)(`button`,{onClick:()=>S(`right`),className:`absolute -right-4 top-1/2 -translate-y-1/2 z-30 w-10 h-10 rounded-full bg-card border shadow-lg flex items-center justify-center hover:bg-muted transition-all text-primary`,children:(0,m.jsx)(s,{className:`w-6 h-6`})})]})]})}export{h as default};