import{j as e,L as k,r as d,n as E,u as P}from"./vendor-react-f9GpqhU8.js";import{f as p,H,F as M,g as q,a as F}from"./index-YIaDEtYb.js";import{C as V,d as O}from"./card-DyZWyZVu.js";import{B as U}from"./badge-NVovQy4N.js";import{o as Z,H as K}from"./vendor-utils-DjInyQU5.js";import{S as J}from"./SEOHead-_a__KoIo.js";import{B as Q}from"./Breadcrumb-D7Uf8n4s.js";import{j as G,k as W,l as b,m as X,n as Y,o as N,p as ee,q as v,r as te,s as ae,t as w,u as S,v as T,w as A}from"./vendor-ui-E0laiDhI.js";import{c as C,a as se,e as re}from"./vendor-icons-CFki6-W-.js";import{u as j}from"./useQuery-BCWjVG_Y.js";import"./vendor-supabase-DU84N46d.js";const le=({article:t,isFirst:r=!1,isLCP:s=!1})=>{const c=Z(new Date(t.published_at||t.created_at),"d MMMM yyyy",{locale:K}),u=n=>{if(!n)return[];if(Array.isArray(n)&&n.every(l=>typeof l=="string"))return n;if(Array.isArray(n))return n.map(l=>typeof l=="string"?l:l&&typeof l=="object"&&l.name?l.name:null).filter(Boolean);if(typeof n=="string")try{const l=JSON.parse(n);if(Array.isArray(l))return l.map(i=>typeof i=="string"?i:i&&typeof i=="object"&&i.name?i.name:null).filter(Boolean)}catch{return[n]}return[]},f=(()=>{if(t.read_time&&t.read_time>1)return t.read_time;if(t.content){const l=t.content.replace(/<[^>]*>/g,"").trim().split(/\s+/).length;return Math.max(1,Math.ceil(l/200))}return t.read_time||1})(),x=u(t.tags);return e.jsx(V,{className:"group hover:shadow-lg transition-shadow duration-300 overflow-hidden",children:e.jsxs(k,{to:`/blog/article/${t.slug}`,className:"block",children:[e.jsx("div",{className:"aspect-video overflow-hidden relative bg-gray-100",children:e.jsx("img",{src:t.image_url||"/placeholder.svg",alt:`Article hypnothérapie - ${t.title}`,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300",loading:r||s?"eager":"lazy"})}),e.jsxs(O,{className:"p-6 min-h-[160px] flex flex-col",children:[e.jsx("div",{className:"min-h-[32px] mb-3",children:x.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2",children:x.slice(0,3).map((n,l)=>e.jsx(U,{variant:"outline",className:"text-xs bg-gray-100 text-gray-700 border-gray-300 hover:bg-gray-200",children:n},`${n}-${l}`))})}),e.jsx("h3",{className:"text-xl font-serif font-medium mb-3 group-hover:text-nova-700 transition-colors line-clamp-2 flex-grow",children:t.title}),e.jsx("p",{className:"text-gray-600 mb-4 line-clamp-2 text-sm",children:t.excerpt}),e.jsxs("div",{className:"flex items-center justify-between text-sm text-gray-500 mt-auto",children:[e.jsx("span",{children:c}),e.jsxs("span",{children:[f," min de lecture"]})]})]})]})})},ne=G,oe=W,L=d.forwardRef(({className:t,children:r,...s},c)=>e.jsxs(b,{ref:c,className:p("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",t),...s,children:[r,e.jsx(X,{asChild:!0,children:e.jsx(C,{className:"h-4 w-4 opacity-50"})})]}));L.displayName=b.displayName;const B=d.forwardRef(({className:t,...r},s)=>e.jsx(w,{ref:s,className:p("flex cursor-default items-center justify-center py-1",t),...r,children:e.jsx(re,{className:"h-4 w-4"})}));B.displayName=w.displayName;const _=d.forwardRef(({className:t,...r},s)=>e.jsx(S,{ref:s,className:p("flex cursor-default items-center justify-center py-1",t),...r,children:e.jsx(C,{className:"h-4 w-4"})}));_.displayName=S.displayName;const D=d.forwardRef(({className:t,children:r,position:s="popper",...c},u)=>e.jsx(Y,{children:e.jsxs(N,{ref:u,className:p("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",s==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",t),position:s,...c,children:[e.jsx(B,{}),e.jsx(ee,{className:p("p-1",s==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:r}),e.jsx(_,{})]})}));D.displayName=N.displayName;const ie=d.forwardRef(({className:t,...r},s)=>e.jsx(T,{ref:s,className:p("py-1.5 pl-8 pr-2 text-sm font-semibold",t),...r}));ie.displayName=T.displayName;const R=d.forwardRef(({className:t,children:r,...s},c)=>e.jsxs(v,{ref:c,className:p("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...s,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(te,{children:e.jsx(se,{className:"h-4 w-4"})})}),e.jsx(ae,{children:r})]}));R.displayName=v.displayName;const ce=d.forwardRef(({className:t,...r},s)=>e.jsx(A,{ref:s,className:p("-mx-1 my-1 h-px bg-muted",t),...r}));ce.displayName=A.displayName;const de=[{value:"newest",label:"Plus récents"},{value:"oldest",label:"Plus anciens"},{value:"az",label:"A-Z"},{value:"za",label:"Z-A"}],ve=()=>{const{slug:t}=E(),r=P(),[s,c]=d.useState("newest"),{data:u,isLoading:g}=j({queryKey:["blog-articles"],queryFn:async()=>(await q()).data||[],staleTime:300*1e3}),{data:f,isLoading:x}=j({queryKey:["blog-categories"],queryFn:async()=>(await F()).data||[],staleTime:300*1e3}),n=u||[],l=f||[],i=g||x,o=l.find(a=>a.slug===t),y=n.filter(a=>a.categories&&a.categories.includes(o?.name||"")),h=[...y].sort((a,m)=>{switch(s){case"newest":return new Date(m.published_at||m.created_at).getTime()-new Date(a.published_at||a.created_at).getTime();case"oldest":return new Date(a.published_at||a.created_at).getTime()-new Date(m.published_at||m.created_at).getTime();case"az":return a.title.localeCompare(m.title);case"za":return m.title.localeCompare(a.title);default:return 0}});d.useEffect(()=>{!i&&!o&&r("/blog")},[o,r,i]);const I=a=>{c(a)};if(i||!o)return null;const z={"@context":"https://schema.org","@type":"CollectionPage",name:o.name,description:o.description,url:`https://novahypnose.fr/blog/categorie/${t}`,mainEntity:{"@type":"ItemList",itemListElement:h.map((a,m)=>({"@type":"ListItem",position:m+1,url:`https://novahypnose.fr/blog/article/${a.slug}`}))}},$={"@context":"https://schema.org","@type":"BreadcrumbList",itemListElement:[{"@type":"ListItem",position:1,name:"Accueil",item:"https://novahypnose.fr"},{"@type":"ListItem",position:2,name:"Blog",item:"https://novahypnose.fr/blog"},{"@type":"ListItem",position:3,name:o.name,item:`https://novahypnose.fr/blog/categorie/${t}`}]};return e.jsxs("div",{className:"min-h-screen flex flex-col",children:[e.jsx(J,{title:`${o.name} - Blog NovaHypnose`,description:o.description||`Découvrez tous nos articles sur ${o.name} - Hypnose ericksonienne et bien-être par Alain Zenatti`,type:"website",url:`https://novahypnose.fr/blog/categorie/${t}`,structuredData:[z,$]}),e.jsx(H,{}),e.jsxs("main",{className:"flex-grow container mx-auto px-4 pt-24 pb-12",children:[e.jsx(Q,{items:[{label:"Blog",href:"/blog"},{label:o.name}]}),e.jsxs("div",{className:"mb-12 mt-8",children:[e.jsx("h1",{className:"font-serif mb-2 text-center text-4xl md:text-5xl",children:o.name}),o.description&&e.jsx("p",{className:"text-center text-gray-600 max-w-2xl mx-auto",children:o.description})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row justify-between items-center mb-6",children:[e.jsxs("h2",{className:"text-xl font-medium mb-4 sm:mb-0",children:["Articles ",e.jsxs("span",{className:"text-gray-500 font-normal",children:["(",y.length,")"]})]}),e.jsxs("div",{className:"flex items-center",children:[e.jsx("span",{className:"text-sm text-gray-600 mr-2",children:"Trier par:"}),e.jsxs(ne,{onValueChange:I,defaultValue:s,children:[e.jsx(L,{className:"w-[180px]",children:e.jsx(oe,{placeholder:"Trier par"})}),e.jsx(D,{children:de.map(a=>e.jsx(R,{value:a.value,children:a.label},a.value))})]})]})]}),h.length>0?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:h.map(a=>e.jsx(le,{article:a},a.id))}):e.jsxs("div",{className:"text-center py-12",children:[e.jsx("h3",{className:"text-xl text-gray-600",children:"Aucun article trouvé dans cette catégorie"}),e.jsx("p",{className:"mt-2 text-gray-500",children:"Revenez plus tard pour découvrir de nouveaux articles."})]})]}),e.jsx(M,{})]})};export{ve as default};