import{aX as j,r as x,j as e,ap as f,ag as b,Y as v,m as N,p as w,at as y}from"./vendor-DyCecx-5.js";const C=({hotel:s,isInWishlist:r=!1,onToggleWishlist:n,onClick:i})=>{const{t}=j(),[a,l]=x.useState(0),o=h=>{var d;h.stopPropagation();const c=((d=s.images)==null?void 0:d.length)||0;c>0&&l(u=>(u+1)%c)},m=h=>{var d;h.stopPropagation();const c=((d=s.images)==null?void 0:d.length)||0;c>0&&l(u=>(u-1+c)%c)},p=s.images||["https://images.unsplash.com/photo-1566073771259-6a8506099945?auto=format&fit=crop&q=80&w=800"];return e.jsxs("div",{className:"group bg-white rounded overflow-hidden border border-slate-200 shadow-sm relative",children:[e.jsxs("div",{className:"relative h-48 overflow-hidden",children:[e.jsx("img",{src:p[a],alt:s.name,className:"w-full h-full object-cover transition-transform duration-500 group-hover:scale-110"}),p.length>1&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:m,className:"absolute left-2 top-1/2 -translate-y-1/2 p-1 bg-white/50 rounded-full text-slate-900",children:e.jsx(f,{className:"w-4 h-4"})}),e.jsx("button",{onClick:o,className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 bg-white/50 rounded-full text-slate-900",children:e.jsx(b,{className:"w-4 h-4"})})]}),s.rating&&e.jsxs("div",{className:"absolute top-2 right-2 px-2 py-0.5 bg-white rounded text-xs font-bold text-slate-900 border border-slate-200",children:[e.jsx(v,{className:"w-3 h-3 fill-amber-400 text-amber-400 inline mr-1"}),s.rating]})]}),e.jsxs("div",{className:"p-4",children:[e.jsx("div",{className:"flex justify-between items-start mb-1",children:e.jsx("h3",{className:"text-lg font-bold text-slate-900 truncate flex-1",children:s.name})}),e.jsxs("p",{className:"text-xs text-slate-500 mb-3 flex items-center gap-1",children:[e.jsx(N,{className:"w-3 h-3"}),s.address]}),e.jsxs("div",{className:"flex justify-between items-center mt-4 pt-4 border-t border-slate-100",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-bold text-slate-400 uppercase",children:"From"}),e.jsxs("div",{className:"text-lg font-bold text-slate-900",children:["₹",(s.startingPrice||0).toLocaleString()]})]}),e.jsx("button",{onClick:i,className:"px-4 py-2 bg-slate-900 text-white rounded text-sm font-bold hover:bg-slate-800 transition-colors",children:"View"})]})]})]})},g="smart_hotel_recently_viewed",I=10,R=()=>{const[s,r]=x.useState([]);return x.useEffect(()=>{const t=localStorage.getItem(g);if(t)try{r(JSON.parse(t))}catch{}},[]),{recentHotels:s,addHotel:t=>{r(a=>{const l=a.filter(m=>m.id!==t.id),o=[t,...l].slice(0,I);return localStorage.setItem(g,JSON.stringify(o)),o})},clearRecentlyViewed:()=>{localStorage.removeItem(g),r([])}}},k=()=>{const{recentHotels:s}=R(),r=w(),n=x.useRef(null);if(s.length===0)return null;const i=t=>{if(n.current){const{scrollLeft:a,clientWidth:l}=n.current,o=t==="left"?a-l:a+l;n.current.scrollTo({left:o,behavior:"smooth"})}};return e.jsx("section",{className:"py-12 border-t border-slate-100 mt-20",children:e.jsxs("div",{className:"max-w-7xl mx-auto px-4 md:px-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-8",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2.5 bg-slate-900 text-white rounded shadow-lg",children:e.jsx(y,{className:"w-5 h-5"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-black text-slate-900 tracking-tight",children:"Recently Viewed"}),e.jsx("p",{className:"text-sm text-slate-500 font-medium",children:"Hotels you've checked out recently."})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:()=>i("left"),className:"p-2 border border-slate-200 rounded hover:bg-slate-50 transition-colors",children:e.jsx(f,{className:"w-5 h-5 text-slate-600"})}),e.jsx("button",{onClick:()=>i("right"),className:"p-2 border border-slate-200 rounded hover:bg-slate-50 transition-colors",children:e.jsx(b,{className:"w-5 h-5 text-slate-600"})})]})]}),e.jsx("div",{ref:n,className:"flex gap-6 overflow-x-auto pb-6 scrollbar-hide snap-x no-scrollbar",children:s.map(t=>e.jsx("div",{className:"min-w-[320px] max-w-[320px] snap-start",children:e.jsx(C,{hotel:t,onClick:()=>r(`/customer/hotel/${t.id}`)})},t.id))})]})})};export{C as H,k as R,R as u};
