import{j as t,n as c,bx as d,at as u,w as m,i,s as n}from"./index-Bt7ohjT1.js";import{F as g}from"./file-text-Bg8xNIjU.js";import{C as x}from"./clock-Dim94Qys.js";function p(e,a=220){if(!e)return 1;const s=e.replace(/<[^>]+>/g," ").replace(/\s+/g," ").trim();if(!s)return 1;const r=s.split(" ").length;return Math.max(1,Math.ceil(r/a))}function y({post:e,featured:a=!1}){const s=e.category==="tips"?"Tips & Guides":"Company News",r=p(e.content);return t.jsxs(c,{to:`/blog/${e.slug}`,className:`group relative block bg-card overflow-hidden border border-border hover:border-primary/60 hover:shadow-2xl hover:shadow-primary/10 hover:-translate-y-1 transition-all duration-300 rounded-sm ${a?"lg:grid lg:grid-cols-2 lg:gap-0":""}`,children:[t.jsxs("div",{className:`relative overflow-hidden ${a?"aspect-[16/10] lg:aspect-auto lg:h-full":"aspect-video"}`,children:[e.featured_image_url?t.jsx("img",{src:e.featured_image_url,alt:e.title,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-500",loading:"lazy"}):t.jsx("div",{className:"w-full h-full bg-muted flex items-center justify-center",children:t.jsx(g,{className:"w-12 h-12 text-muted-foreground/30","aria-hidden":"true"})}),t.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black/70 via-black/10 to-transparent opacity-80 group-hover:opacity-90 transition-opacity"}),t.jsx("div",{className:"absolute top-4 left-4",children:t.jsx("span",{className:"inline-block bg-primary text-primary-foreground text-[10px] font-black uppercase tracking-widest px-3 py-1.5 rounded-sm shadow-lg",children:s})}),t.jsxs("div",{className:"absolute bottom-4 left-4 flex items-center gap-1.5 text-white/95 text-xs font-bold uppercase tracking-widest",children:[t.jsx(x,{className:"w-3.5 h-3.5"}),r," min read"]})]}),t.jsxs("div",{className:`p-6 ${a?"lg:p-10 lg:flex lg:flex-col lg:justify-center":""}`,children:[e.published_at&&t.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-bold uppercase tracking-widest text-muted-foreground mb-3",children:[t.jsx(d,{className:"w-3.5 h-3.5"}),u(new Date(e.published_at),"MMMM d, yyyy")]}),t.jsx("h3",{className:`font-display font-black uppercase tracking-tight text-foreground group-hover:text-primary transition-colors mb-3 line-clamp-2 leading-[1.05] ${a?"text-3xl md:text-4xl lg:text-5xl":"text-xl md:text-2xl"}`,children:e.title}),e.excerpt&&t.jsx("p",{className:`text-muted-foreground leading-relaxed mb-5 ${a?"text-base md:text-lg line-clamp-3":"text-sm line-clamp-3"}`,children:e.excerpt}),t.jsxs("div",{className:"inline-flex items-center gap-2 text-sm font-black uppercase tracking-widest text-primary group-hover:gap-3 transition-all",children:["Read article",t.jsx(m,{className:"w-4 h-4"})]})]})]})}function w(e){return i({queryKey:["blog-posts",e],queryFn:async()=>{let a=n.from("blog_posts").select("*").eq("status","published").order("published_at",{ascending:!1});e&&(a=a.eq("category",e));const{data:s,error:r}=await a;if(r)throw r;return s}})}function v(e,a){const s=(a==null?void 0:a.preview)??!1;return i({queryKey:["blog-post",e,s?"preview":"published"],queryFn:async()=>{let r=n.from("blog_posts").select("*").eq("slug",e);s||(r=r.eq("status","published"));const{data:o,error:l}=await r.maybeSingle();if(l)throw l;return o},enabled:!!e})}export{y as B,v as a,p as e,w as u};