import{u as y,r as s,ci as k,j as e,g as x,P as C,ah as S,w as _}from"./vendor-laZsiqLO.js";import{C as I,a as R,b as A}from"./carousel-C9slTU5h.js";import{B as L}from"./badge-CJ9RzXvO.js";import{c as M}from"./utils-RgT4yCq8.js";import{u as P}from"./useTranslation-BW0o-tkY.js";import"./button-B8f8jW4H.js";function U({posts:n}){const{t:p}=P(),{locale:c}=y().props,[r,b]=s.useState(null),[d,u]=s.useState(0),[w,g]=s.useState(0),j=s.useRef(k({delay:6e3,stopOnInteraction:!0})),v=t=>`https://ui-avatars.com/api/?name=${encodeURIComponent(t)}&background=random&color=fff&size=1024&font-size=0.3`;s.useEffect(()=>{r&&(g(r.scrollSnapList().length),u(r.selectedScrollSnap()),r.on("select",()=>{u(r.selectedScrollSnap())}))},[r]);const N=t=>{if(!t)return"";const a=new Date(t),m=c?c.replace("_","-"):"en-US",o=new Intl.RelativeTimeFormat(m,{numeric:"auto",style:"short"}),h=Math.floor((new Date-a)/1e3);if(h<60)return p("_just_now","Just now");const l=Math.floor(h/60),i=Math.floor(l/60),f=Math.floor(i/24);return l<60?o.format(-l,"minute"):i<24?o.format(-i,"hour"):f<7?o.format(-f,"day"):new Intl.DateTimeFormat(m,{month:"short",day:"numeric",year:"numeric"}).format(a)};return!n||n.length===0?null:e.jsxs("div",{className:"relative w-full rounded-xl overflow-hidden border border-border bg-card shadow-md",children:[e.jsx(I,{setApi:b,plugins:[j.current],className:"w-full",opts:{loop:!0},children:e.jsx(R,{children:n.map(t=>e.jsxs(A,{className:"relative h-[350px] md:h-[480px] w-full",children:[e.jsxs(x,{href:t.route_url,className:"absolute inset-0 block",children:[e.jsx("img",{src:t.image_path||v(t.title),alt:t.title,className:"w-full h-full object-cover transition-none"}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black/90 via-black/30 to-transparent"})]}),e.jsx("div",{className:"absolute inset-0 flex flex-col justify-end p-6 md:p-10 pb-20 md:pb-24 pointer-events-none",children:e.jsxs("div",{className:"max-w-3xl space-y-3 pointer-events-auto",children:[t.category&&e.jsx(L,{variant:"secondary",className:"bg-primary text-primary-foreground border-none px-2.5 py-0.5 text-[10px] font-bold uppercase tracking-wider rounded-md",children:t.category.name}),e.jsx(x,{href:t.route_url,children:e.jsx("h2",{className:"text-xl md:text-3xl font-bold text-white leading-tight font-serif hover:text-white/90 transition-colors drop-shadow-sm",children:t.title})})]})})]},t.id))})}),e.jsxs("div",{className:"absolute bottom-5 left-6 right-6 flex items-center justify-between z-20 pointer-events-none",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-white/90 text-[11px] font-medium backdrop-blur-md bg-black/30 px-3 py-1.5 rounded-md border border-white/10 shadow-sm animate-in fade-in slide-in-from-left-2 duration-500 pointer-events-auto",children:[e.jsx(C,{className:"w-3.5 h-3.5"}),N(n[d]?.created_at)]}),e.jsxs("div",{className:"flex items-center gap-2 pointer-events-auto",children:[e.jsx("button",{onClick:()=>r?.scrollPrev(),className:"h-8 w-8 rounded-md bg-white/10 hover:bg-white/20 backdrop-blur-md text-white flex items-center justify-center transition-all active:scale-95 border border-white/10 rtl:rotate-180",children:e.jsx(S,{className:"w-4 h-4"})}),e.jsx("div",{className:"flex gap-1.5 px-1",children:Array.from({length:w}).map((t,a)=>e.jsx("div",{className:M("h-1 rounded-full transition-all duration-300",d===a?"w-6 bg-white":"w-1.5 bg-white/30")},a))}),e.jsx("button",{onClick:()=>r?.scrollNext(),className:"h-8 w-8 rounded-md bg-white/10 hover:bg-white/20 backdrop-blur-md text-white flex items-center justify-center transition-all active:scale-95 border border-white/10 rtl:rotate-180",children:e.jsx(_,{className:"w-4 h-4"})})]})]})]})}export{U as default};
