import{r as d,j as e,L as u,n as U,u as $}from"./vendor-react-f9GpqhU8.js";import{g as B,l as F,u as O,H as C,F as D,D as J,b as q,c as V,d as I,e as W,a as Z,t as G}from"./index-YIaDEtYb.js";import{N as K}from"./NewsletterForm-BzwPmoPn.js";import{S as Q}from"./SEOHead-_a__KoIo.js";import{B as X}from"./badge-NVovQy4N.js";import{B as A}from"./button-B-hxtExd.js";import{D as Y,g as ee,C as se,G as te,J as ae,K as re,N as le}from"./vendor-icons-CFki6-W-.js";import{B as ie}from"./Breadcrumb-D7Uf8n4s.js";import{p as ne}from"./markdownParser-Clx_ldLb.js";import{o as T,H as z}from"./vendor-utils-DjInyQU5.js";import"./vendor-ui-E0laiDhI.js";import"./vendor-supabase-DU84N46d.js";import"./input-BEyrNZiQ.js";import"./card-DyZWyZVu.js";const ce=({currentArticleId:l,currentArticleCategories:t,maxArticles:a=3})=>{const[s,o]=d.useState([]),[g,y]=d.useState(!0);return d.useEffect(()=>{(async()=>{try{y(!0);const x=await B(),f=(Array.isArray(x)?x:x?.data||[]).filter(h=>h.id!==l),k=t&&t.length>0?f.filter(h=>h.categories?.some(j=>t.includes(j))):[],b=f.filter(h=>!h.categories?.some(j=>t?.includes(j))),_=[...k,...b].slice(0,a);o(_)}catch(x){F.error("Error fetching related articles:",x)}finally{y(!1)}})()},[l,t,a]),g?e.jsxs("div",{className:"mt-12 p-6 bg-gray-50 rounded-lg",children:[e.jsx("h3",{className:"text-xl font-serif font-medium mb-4",children:"Articles connexes"}),e.jsx("div",{className:"space-y-4",children:[1,2,3].map(c=>e.jsxs("div",{className:"animate-pulse",children:[e.jsx("div",{className:"h-4 bg-gray-200 rounded w-3/4 mb-2"}),e.jsx("div",{className:"h-3 bg-gray-200 rounded w-full"})]},c))})]}):s.length===0?null:e.jsxs("div",{className:"mt-12 p-6 bg-gradient-to-br from-gray-50 to-gray-100 rounded-lg border",children:[e.jsx("h3",{className:"text-xl font-serif font-medium mb-6 text-gray-800",children:"📚 Articles connexes"}),e.jsx("div",{className:"space-y-4",children:s.map(c=>e.jsxs(u,{to:`/blog/article/${c.slug}`,className:"block p-4 bg-white rounded-lg shadow-sm hover:shadow-md transition-all duration-200 border border-gray-200 hover:border-gray-300",children:[e.jsx("h4",{className:"font-medium text-gray-900 mb-2 line-clamp-1",children:c.title}),e.jsx("p",{className:"text-sm text-gray-600 line-clamp-2 mb-3",children:c.excerpt}),e.jsxs("div",{className:"flex items-center justify-between text-xs text-gray-500",children:[e.jsx("span",{className:"bg-gray-100 px-2 py-1 rounded-full",children:c.categories?.[0]||"Non classé"}),e.jsx("span",{children:new Date(c.created_at).toLocaleDateString("fr-FR")})]})]},c.id))}),e.jsx("div",{className:"mt-6 pt-4 border-t border-gray-200",children:e.jsx(u,{to:"/blog",className:"inline-flex items-center text-sm text-blue-600 hover:text-blue-700 font-medium",children:"→ Voir tous les articles"})})]})},oe=(l,t)=>{const a=t.filter(o=>o.published).sort((o,g)=>new Date(g.published_at||g.created_at).getTime()-new Date(o.published_at||o.created_at).getTime()),s=a.findIndex(o=>o.id===l.id);return{previousArticle:s>0?a[s-1]:null,nextArticle:s<a.length-1?a[s+1]:null}},de=l=>{if(!l)return[];if(Array.isArray(l)&&l.every(t=>typeof t=="string"))return l;if(Array.isArray(l))return l.map(t=>typeof t=="string"?t:t&&typeof t=="object"&&"name"in t?t.name:null).filter(t=>t!==null);if(typeof l=="string")try{const t=JSON.parse(l);if(Array.isArray(t))return t.map(a=>typeof a=="string"?a:a&&typeof a=="object"&&a!==null&&"name"in a?a.name:null).filter(a=>a!==null)}catch{return[l]}return[]},ke=()=>{const{slug:l}=U(),t=$(),{isAdmin:a}=O(),[s,o]=d.useState(null),[g,y]=d.useState([]),[c,x]=d.useState([]),[S,f]=d.useState(!0),[k,b]=d.useState(null),_=window.location.hostname==="emergences.novahypnose.fr",h="https://novahypnose.fr",j=i=>`${h}/blog/article/${i}`;d.useEffect(()=>{l&&(async()=>{try{f(!0);const[r,n,m]=await Promise.all([W(l),B(),Z()]);r.data?o(r.data):b("Article non trouvé"),n.data&&y(n.data.filter(p=>p.published)),m.data&&x(m.data)}catch(r){F.error("Erreur lors du chargement",r),b(r)}finally{f(!1)}})()},[l]);const{previousArticle:v,nextArticle:N}=s?oe(s,g):{previousArticle:null,nextArticle:null};if(d.useEffect(()=>{if(!s)return;const i=s.author?.name||s.author||"Alain Zenatti",r={"@context":"https://schema.org","@type":"Article",headline:s.title,description:s.seo_description||s.excerpt,image:s.image_url||"",datePublished:s.published_at||s.created_at,dateModified:s.updated_at||s.created_at,author:{"@type":"Person",name:i,url:"https://novahypnose.fr"},publisher:{"@type":"Organization",name:"NovaHypnose",logo:{"@type":"ImageObject",url:"https://akrlyzmfszumibwgocae.supabase.co/storage/v1/object/public/images/zenatti.webp"}},mainEntityOfPage:{"@type":"WebPage","@id":`https://novahypnose.fr/blog/article/${s.slug}`},keywords:Array.isArray(s.keywords)?s.keywords.join(", "):"",articleSection:s.categories?.[0]||"Hypnose",wordCount:s.content?s.content.split(/\s+/).length:0,inLanguage:"fr-FR"},n=document.createElement("script");return n.type="application/ld+json",n.text=JSON.stringify(r),n.id="article-structured-data",document.head.appendChild(n),()=>{const m=document.getElementById("article-structured-data");m&&document.head.removeChild(m)}},[s]),S)return e.jsxs("div",{className:"min-h-screen flex flex-col",children:[e.jsx(C,{}),e.jsx("div",{className:"flex-grow flex items-center justify-center",children:e.jsx("p",{children:"Chargement de l'article..."})}),e.jsx(D,{})]});if(k||!s)return e.jsxs("div",{className:"min-h-screen flex flex-col",children:[e.jsx(C,{}),e.jsx("div",{className:"flex-grow flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold mb-4",children:"Article non trouvé"}),e.jsx("p",{className:"text-gray-600 mb-4",children:"L'article que vous recherchez n'existe pas ou a été supprimé."}),e.jsx(u,{to:"/blog",className:"text-nova-700 hover:underline",children:"Retour au blog"})]})}),e.jsx(D,{})]});const M=T(new Date(s.published_at||s.created_at),"d MMMM yyyy",{locale:z}),L=s.updated_at!==s.created_at?T(new Date(s.updated_at),"d MMMM yyyy",{locale:z}):null,R=s.author?.name||s.author||"Alain Zenatti",P=de(s.tags),w=i=>{const r=window.location.href,n=(s.title||"").replace(/['"]/g,""),m=(s.seo_description||s.excerpt||"").replace(/['"]/g,"");s.image_url;let p="",E="";switch(i){case"facebook":p="https://www.facebook.com/sharer/sharer.php?u="+encodeURIComponent(r);break;case"linkedin":p="https://www.linkedin.com/sharing/share-offsite/?url="+encodeURIComponent(r);break;case"whatsapp":E=n+`

`+m+`

`+r,p="https://api.whatsapp.com/send?text="+encodeURIComponent(E);break;case"copy":const H=n+`
`+m+`
`+r;navigator.clipboard.writeText(H),G.success("Lien copié dans le presse-papier",{description:"Le titre, la description et le lien ont été copiés"});return}p&&window.open(p,"_blank","width=600,height=400")};return e.jsxs("div",{className:"min-h-screen flex flex-col",children:[e.jsx(Q,{title:s.title,description:s.seo_description||s.excerpt,image:s.image_url,type:"article",publishedTime:s.created_at,modifiedTime:s.updated_at,author:R,keywords:Array.isArray(s.keywords)?s.keywords:[],url:j(s.slug),robots:_?"noindex, nofollow":"index, follow"}),e.jsx(C,{}),e.jsxs("main",{className:"flex-grow pt-20",children:[e.jsx("div",{className:"container mx-auto px-4 pt-4",children:e.jsx(ie,{items:[{label:"Blog",href:"/blog"},(()=>{if(s.categories?.[0]){const i=s.categories[0],r=c.find(n=>n.name===i);return r?{label:i,href:`/blog/categorie/${r.slug}`}:{label:i,href:"/blog"}}return{label:"Articles",href:"/blog"}})(),{label:s.title}]})}),e.jsxs("div",{className:"w-full h-[40vh] relative",children:[e.jsx("img",{src:s.image_url||"/placeholder.svg",alt:`Article hypnothérapie - ${s.title}`,className:"w-full h-full object-cover",loading:"eager"}),e.jsx("div",{className:"absolute inset-0 bg-black bg-opacity-30 flex items-end",children:e.jsx("div",{className:"container mx-auto px-4 pb-8 text-white",children:e.jsxs("div",{className:"max-w-3xl",children:[e.jsxs("div",{className:"flex justify-between items-start mb-4",children:[e.jsx("h1",{className:"text-3xl md:text-4xl font-serif flex-1",children:s.title}),a&&e.jsxs(A,{onClick:()=>t(`/admin-blog/article/${s.id}/edit`),variant:"secondary",size:"sm",className:"ml-4 flex items-center gap-2",children:[e.jsx(Y,{className:"h-4 w-4"}),"Modifier"]})]}),e.jsxs("div",{className:"flex flex-wrap items-center text-sm",children:[e.jsx("span",{children:R}),e.jsx("span",{className:"mx-2",children:"•"}),e.jsx("span",{children:M}),e.jsx("span",{className:"mx-2",children:"•"}),e.jsxs("span",{children:[s.read_time||5," min de lecture"]})]})]})})})]}),e.jsx("div",{className:"container mx-auto px-4 py-8",children:e.jsxs("div",{className:"flex flex-col lg:flex-row gap-8",children:[e.jsxs("div",{className:"lg:w-2/3",children:[P.length>0&&e.jsx("div",{className:"mb-4 flex flex-wrap gap-2",children:P.map((i,r)=>e.jsx(X,{variant:"outline",className:"text-xs bg-gray-100 text-gray-700 border-gray-300 hover:bg-gray-200",children:i},i+"-"+r))}),e.jsx("div",{className:"article-hypnose",dangerouslySetInnerHTML:{__html:ne(s.content)}}),e.jsx(ce,{currentArticleId:s.id,currentArticleCategories:s.categories,maxArticles:3}),(v||N)&&e.jsxs("div",{className:"mt-12 border-t pt-8",children:[e.jsx("h3",{className:"text-lg font-serif font-medium mb-6",children:"Navigation entre les articles"}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("div",{className:"flex-1",children:v&&e.jsxs(u,{to:"/blog/article/"+v.slug,className:"group flex items-center space-x-3 p-4 rounded-lg border hover:bg-gray-50 transition-colors",children:[e.jsx(ee,{className:"h-5 w-5 text-nova-600"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm text-gray-500 mb-1",children:"Article précédent"}),e.jsx("div",{className:"font-medium group-hover:text-nova-700 transition-colors line-clamp-2",children:v.title})]})]})}),e.jsx("div",{className:"mx-4",children:e.jsx(u,{to:"/blog",className:"text-sm text-gray-500 hover:text-nova-700 transition-colors",children:"Tous les articles"})}),e.jsx("div",{className:"flex-1 flex justify-end",children:N&&e.jsxs(u,{to:"/blog/article/"+N.slug,className:"group flex items-center space-x-3 p-4 rounded-lg border hover:bg-gray-50 transition-colors text-right",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm text-gray-500 mb-1",children:"Article suivant"}),e.jsx("div",{className:"font-medium group-hover:text-nova-700 transition-colors line-clamp-2",children:N.title})]}),e.jsx(se,{className:"h-5 w-5 text-nova-600"})]})})]})]}),e.jsxs("div",{className:"mt-8 pt-8 border-t flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:[e.jsxs("div",{className:"text-sm text-gray-600",children:[e.jsxs("div",{className:"mb-2",children:[e.jsxs("div",{children:["Publié le ",M]}),L&&e.jsxs("div",{className:"text-xs text-gray-500 mt-1",children:["Mis à jour le ",L]})]}),s.categories&&s.categories.length>0&&e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx("span",{children:"Catégories: "}),s.categories.map((i,r)=>e.jsxs("span",{children:[e.jsx(u,{to:"/blog?category="+encodeURIComponent(i),className:"text-nova-700 hover:underline",title:"Voir tous les articles de la catégorie "+i,children:i}),r<s.categories.length-1&&", "]},i))]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm text-gray-600",children:"Partager:"}),e.jsx(A,{size:"icon",variant:"ghost",onClick:()=>w("facebook"),"aria-label":"Partager sur Facebook",children:e.jsx(te,{className:"h-4 w-4"})}),e.jsx(A,{size:"icon",variant:"ghost",onClick:()=>w("linkedin"),"aria-label":"Partager sur LinkedIn",children:e.jsx(ae,{className:"h-4 w-4"})}),e.jsxs(J,{children:[e.jsx(q,{asChild:!0,children:e.jsx(A,{size:"icon",variant:"ghost","aria-label":"Plus d'options de partage",children:e.jsx(re,{className:"h-4 w-4"})})}),e.jsxs(V,{align:"end",children:[e.jsx(I,{onClick:()=>w("whatsapp"),children:"WhatsApp"}),e.jsxs(I,{onClick:()=>w("copy"),children:[e.jsx(le,{className:"mr-2 h-4 w-4"}),e.jsx("span",{children:"Copier le lien"})]})]})]})]})]})]}),e.jsx("aside",{className:"lg:w-1/3 space-y-8",children:e.jsx(K,{})})]})})]}),e.jsx(D,{})]})};export{ke as default};