import{a as oe}from"./chunk-YYB674MU.js";import{a as $}from"./chunk-MWOEXFYD.js";import{c as J,d as Q,e as X,f as Y,g as Z,h as ee,p as te,r as ie,s as ne,t as re}from"./chunk-UDFQV3WY.js";import{c as q,f as G}from"./chunk-ZEULGWAI.js";import"./chunk-MBEC6LK4.js";import{Aa as F,B as A,Ba as _,Bb as U,D as N,Eb as l,Fa as a,Fb as p,Gb as y,Jb as v,Kb as E,Lb as C,M as h,R as x,S as f,T as R,Ta as L,Tb as w,U as V,Ub as W,Xb as S,Ya as u,ca as g,cb as T,h as M,jb as m,kb as r,l as k,lb as o,mb as b,nb as K,ob as z,qb as j,qc as P,rb as I,rc as B,sb as c,t as D,uc as H,vc as O}from"./chunk-TVKQFRWX.js";import"./chunk-DAQOROHW.js";function le(t,i){if(t&1&&b(0,"img",38),t&2){let e=c().ngIf;m("src",e.featuredImage,_)("alt",e.title)}}function me(t,i){if(t&1&&b(0,"img",43),t&2){let e=i.$implicit,n=c(2).ngIf;m("src",e.imageUrl,_)("alt",n.title)}}function se(t,i){if(t&1&&(r(0,"section",39)(1,"h2",40),l(2,"Galerie photos"),o(),r(3,"div",41),u(4,me,1,2,"img",42),o()()),t&2){let e=c().ngIf;a(4),m("ngForOf",e.galleryImages)}}function ce(t,i){if(t&1&&(r(0,"div",47)(1,"strong",48),l(2),o(),r(3,"span",49)(4,"a",50),l(5,"Voir"),o(),r(6,"a",51),l(7,"T\xE9l\xE9charger"),o()()()),t&2){let e=i.$implicit;a(2),p(e.fileName),a(2),m("href",e.fileUrl,_),a(2),m("href",e.fileUrl,_)}}function de(t,i){if(t&1&&(r(0,"section",44)(1,"h2",40),l(2,"Documents joints"),o(),r(3,"div",45),u(4,ce,8,3,"div",46),o()()),t&2){let e=c().ngIf;a(4),m("ngForOf",e.attachments)}}function pe(t,i){if(t&1&&(r(0,"p",52),l(1),o()),t&2){let e=c(2);a(),p(e.interactionError())}}function ue(t,i){t&1&&(r(0,"div",53),l(1,"Chargement des commentaires\u2026"),o())}function ge(t,i){t&1&&(r(0,"div",54),l(1," Aucun commentaire publi\xE9. Soyez la premi\xE8re personne \xE0 participer. "),o())}function xe(t,i){if(t&1&&(r(0,"article",57)(1,"div",58)(2,"strong",59),l(3),o(),r(4,"time",60),l(5),w(6,"date"),o()(),r(7,"p",61),l(8),o()()),t&2){let e=i.$implicit;a(3),p(e.authorName),a(2),p(S(6,3,e.createdAt,"d MMMM y \xE0 HH:mm","","fr")),a(3),p(e.content)}}function fe(t,i){if(t&1&&(r(0,"div",55),u(1,xe,9,8,"article",56),o()),t&2){let e=c(2);a(),m("ngForOf",e.interaction().comments)}}function _e(t,i){if(t&1&&(r(0,"p",62),l(1),o()),t&2){let e=c(2);a(),p(e.commentError())}}function be(t,i){if(t&1&&(r(0,"p",63),l(1),o()),t&2){let e=c(2);a(),p(e.commentNotice())}}function he(t,i){if(t&1){let e=j();K(0),r(1,"section",1)(2,"div",2)(3,"a",3),l(4,"\u2190 Toutes les actualit\xE9s"),o(),r(5,"time",4),l(6),w(7,"date"),o(),r(8,"h1",5),l(9),o()()(),r(10,"main",6)(11,"article",2),u(12,le,1,2,"img",7),b(13,"div",8),u(14,se,5,1,"section",9)(15,de,5,1,"section",10),r(16,"section",11)(17,"button",12),I("click",function(){let s=x(e).ngIf,d=c();return f(d.toggleLike(s))}),R(),r(18,"svg",13),b(19,"path",14),o(),l(20),V(),r(21,"span",15),l(22),o()(),u(23,pe,2,1,"p",16),o(),r(24,"section",17)(25,"div")(26,"div",18)(27,"div")(28,"p",19),l(29,"\xC9changes"),o(),r(30,"h2",20),l(31,"Commentaires"),o()(),r(32,"span",21),l(33),o()(),u(34,ue,2,0,"div",22)(35,ge,2,0,"div",23)(36,fe,2,1,"div",24),o(),r(37,"form",25),I("ngSubmit",function(){let s=x(e).ngIf,d=c();return f(d.submitComment(s))}),r(38,"h2",26),l(39,"Laisser un commentaire"),o(),r(40,"p",27),l(41,"Votre commentaire sera publi\xE9 apr\xE8s validation par l\u2019\xE9quipe du RSU."),o(),r(42,"label",28),l(43,"Votre nom *"),o(),r(44,"input",29),C("ngModelChange",function(s){x(e);let d=c();return E(d.commentForm.authorName,s)||(d.commentForm.authorName=s),f(s)}),o(),r(45,"label",30),l(46,"Adresse e-mail"),o(),r(47,"input",31),C("ngModelChange",function(s){x(e);let d=c();return E(d.commentForm.authorEmail,s)||(d.commentForm.authorEmail=s),f(s)}),o(),r(48,"p",32),l(49,"Elle ne sera jamais affich\xE9e sur le site."),o(),r(50,"label",33),l(51,"Commentaire *"),o(),r(52,"textarea",34),C("ngModelChange",function(s){x(e);let d=c();return E(d.commentForm.content,s)||(d.commentForm.content=s),f(s)}),o(),u(53,_e,2,1,"p",35)(54,be,2,1,"p",36),r(55,"button",37),l(56),o()()()()(),z()}if(t&2){let e=i.ngIf,n=c();a(6),p(S(7,32,e.date,"d MMMM y","","fr")),a(3),p(e.title),a(3),m("ngIf",e.featuredImage),a(),m("innerHTML",e.content,F),a(),m("ngIf",e.galleryImages==null?null:e.galleryImages.length),a(),m("ngIf",e.attachments==null?null:e.attachments.length),a(2),U("border-red-200",n.interaction().liked)("bg-red-50",n.interaction().liked)("text-red-700",n.interaction().liked)("border-slate-200",!n.interaction().liked)("text-slate-700",!n.interaction().liked),m("disabled",n.liking()||n.interactionsLoading()),a(),T("fill",n.interaction().liked?"currentColor":"none"),a(2),y(" ",n.interaction().liked?"Vous aimez":"J\u2019aime"," "),a(2),p(n.interaction().likeCount),a(),m("ngIf",n.interactionError()),a(10),y("",n.interaction().comments.length," publi\xE9(s)"),a(),m("ngIf",n.interactionsLoading()),a(),m("ngIf",!n.interactionsLoading()&&n.interaction().comments.length===0),a(),m("ngIf",n.interaction().comments.length),a(8),v("ngModel",n.commentForm.authorName),a(3),v("ngModel",n.commentForm.authorEmail),a(5),v("ngModel",n.commentForm.content),a(),m("ngIf",n.commentError()),a(),m("ngIf",n.commentNotice()),a(),m("disabled",n.submittingComment()),a(),y(" ",n.submittingComment()?"Envoi en cours\u2026":"Envoyer le commentaire"," ")}}var ae=class t{route=h(q);contentService=h($);interactionService=h(oe);visitorKey=this.getVisitorKey();loadedArticleKey="";interaction=g({likeCount:0,liked:!1,comments:[]});interactionsLoading=g(!1);interactionError=g("");liking=g(!1);submittingComment=g(!1);commentError=g("");commentNotice=g("");commentForm={authorName:"",authorEmail:"",content:""};article$=this.route.paramMap.pipe(k(i=>Number(i.get("id"))),A(i=>this.contentService.getArticle(i)),N(i=>{i&&this.loadInteractions(i)}));toggleLike(i){this.liking()||(this.liking.set(!0),this.interactionError.set(""),this.interactionService.toggleLike(this.articleKey(i),i.title,this.visitorKey).subscribe({next:e=>{this.interaction.set(e),this.liking.set(!1)},error:()=>{this.interactionError.set("Le vote n\u2019a pas pu \xEAtre enregistr\xE9. Veuillez r\xE9essayer."),this.liking.set(!1)}}))}submitComment(i){let e=this.commentForm.authorName.trim(),n=this.commentForm.authorEmail.trim(),s=this.commentForm.content.trim();if(this.commentError.set(""),this.commentNotice.set(""),!e||s.length<3){this.commentError.set("Veuillez renseigner votre nom et un commentaire d\u2019au moins 3 caract\xE8res.");return}this.submittingComment.set(!0),this.interactionService.submitComment({articleKey:this.articleKey(i),articleTitle:i.title,authorName:e,authorEmail:n,content:s}).subscribe({next:d=>{this.commentForm.content="",this.commentNotice.set(d.message||"Votre commentaire a \xE9t\xE9 envoy\xE9 pour validation."),this.submittingComment.set(!1)},error:()=>{this.commentError.set("Le commentaire n\u2019a pas pu \xEAtre envoy\xE9. V\xE9rifiez les informations et r\xE9essayez."),this.submittingComment.set(!1)}})}loadInteractions(i){let e=this.articleKey(i);this.loadedArticleKey!==e&&(this.loadedArticleKey=e,this.interactionsLoading.set(!0),this.interactionError.set(""),this.interactionService.getPublic(e,this.visitorKey).pipe(D(()=>(this.interactionError.set("Les r\xE9actions sont temporairement indisponibles."),M({likeCount:0,liked:!1,comments:[]})))).subscribe(n=>{this.interaction.set(n),this.interactionsLoading.set(!1)}))}articleKey(i){return i.reactionKey||`archive-${i.id}`}getVisitorKey(){let i="rsu-article-visitor-key",e=localStorage.getItem(i);if(e)return e;let n=typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():`visitor-${Date.now()}-${Math.random().toString(36).slice(2)}`;return localStorage.setItem(i,n),n}static \u0275fac=function(e){return new(e||t)};static \u0275cmp=L({type:t,selectors:[["app-rsu-article-detail"]],decls:2,vars:3,consts:[[4,"ngIf"],[1,"bg-primary-800","py-12","text-white"],[1,"container-custom","max-w-5xl"],["routerLink","/actualites",1,"text-sm","text-white/70","hover:text-white"],[1,"mt-6","block","text-sm","font-semibold","uppercase","tracking-wider","text-accent-300"],[1,"mt-3","text-3xl","font-bold","text-white","md:text-5xl"],[1,"section"],["class","mb-10 max-h-[560px] w-full rounded-3xl object-cover shadow-soft",3,"src","alt",4,"ngIf"],[1,"rsu-article","rounded-2xl","bg-white","text-slate-600",3,"innerHTML"],["class","mt-12",4,"ngIf"],["class","mt-12 rounded-2xl bg-slate-50 p-6",4,"ngIf"],["aria-label","R\xE9actions \xE0 l'article",1,"mt-12","border-t","border-slate-200","pt-8"],["type","button",1,"inline-flex","items-center","gap-3","rounded-full","border","px-5","py-3","font-semibold","transition","disabled:cursor-wait","disabled:opacity-60",3,"click","disabled"],["stroke","currentColor","viewBox","0 0 24 24",1,"h-6","w-6"],["stroke-linecap","round","stroke-linejoin","round","stroke-width","1.8","d","M20.84 4.61a5.5 5.5 0 00-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 00-7.78 7.78L12 21.23l8.84-8.84a5.5 5.5 0 000-7.78z"],[1,"rounded-full","bg-white/80","px-2.5","py-0.5","text-sm"],["class","mt-3 text-sm text-red-700",4,"ngIf"],["aria-labelledby","comments-title",1,"mt-10","grid","gap-8","lg:grid-cols-[1.1fr_.9fr]"],[1,"flex","items-end","justify-between","gap-4"],[1,"text-sm","font-bold","uppercase","tracking-[.16em]","text-primary-700"],["id","comments-title",1,"mt-1","text-2xl","font-bold","text-primary-950"],[1,"text-sm","text-slate-500"],["class","mt-6 rounded-2xl bg-slate-50 p-5 text-slate-500",4,"ngIf"],["class","mt-6 rounded-2xl border border-dashed border-slate-300 bg-slate-50 p-6 text-slate-600",4,"ngIf"],["class","mt-6 space-y-4",4,"ngIf"],[1,"h-fit","rounded-3xl","bg-primary-50","p-6","shadow-sm","sm:p-7",3,"ngSubmit"],[1,"text-xl","font-bold","text-primary-950"],[1,"mt-2","text-sm","leading-6","text-slate-600"],["for","comment-name",1,"mt-5","block","text-sm","font-semibold","text-slate-700"],["id","comment-name","name","authorName","required","","maxlength","120",1,"mt-2","w-full","rounded-xl","border","border-slate-300","bg-white","px-4","py-3","outline-none","focus:border-primary-600","focus:ring-2","focus:ring-primary-100",3,"ngModelChange","ngModel"],["for","comment-email",1,"mt-4","block","text-sm","font-semibold","text-slate-700"],["id","comment-email","name","authorEmail","type","email","maxlength","180",1,"mt-2","w-full","rounded-xl","border","border-slate-300","bg-white","px-4","py-3","outline-none","focus:border-primary-600","focus:ring-2","focus:ring-primary-100",3,"ngModelChange","ngModel"],[1,"mt-1","text-xs","text-slate-500"],["for","comment-content",1,"mt-4","block","text-sm","font-semibold","text-slate-700"],["id","comment-content","name","content","required","","minlength","3","maxlength","2000","rows","5",1,"mt-2","w-full","resize-y","rounded-xl","border","border-slate-300","bg-white","px-4","py-3","outline-none","focus:border-primary-600","focus:ring-2","focus:ring-primary-100",3,"ngModelChange","ngModel"],["class","mt-3 rounded-xl bg-red-50 px-4 py-3 text-sm text-red-700",4,"ngIf"],["class","mt-3 rounded-xl bg-emerald-50 px-4 py-3 text-sm text-emerald-800",4,"ngIf"],["type","submit",1,"mt-5","w-full","rounded-xl","bg-primary-700","px-5","py-3","font-bold","text-white","transition","hover:bg-primary-800","disabled:cursor-wait","disabled:opacity-60",3,"disabled"],[1,"mb-10","max-h-[560px]","w-full","rounded-3xl","object-cover","shadow-soft",3,"src","alt"],[1,"mt-12"],[1,"text-2xl","font-bold","text-primary-950"],[1,"mt-5","grid","gap-5","sm:grid-cols-2","lg:grid-cols-3"],["class","h-64 w-full rounded-2xl object-cover shadow-card",3,"src","alt",4,"ngFor","ngForOf"],[1,"h-64","w-full","rounded-2xl","object-cover","shadow-card",3,"src","alt"],[1,"mt-12","rounded-2xl","bg-slate-50","p-6"],[1,"mt-5","space-y-3"],["class","flex flex-col gap-3 rounded-xl border border-slate-200 bg-white p-4 sm:flex-row sm:items-center sm:justify-between",4,"ngFor","ngForOf"],[1,"flex","flex-col","gap-3","rounded-xl","border","border-slate-200","bg-white","p-4","sm:flex-row","sm:items-center","sm:justify-between"],[1,"text-slate-800"],[1,"flex","gap-2"],["target","_blank","rel","noopener",1,"rounded-lg","border","border-primary-700","px-4","py-2","text-sm","font-semibold","text-primary-700",3,"href"],["download","",1,"rounded-lg","bg-primary-700","px-4","py-2","text-sm","font-semibold","text-white",3,"href"],[1,"mt-3","text-sm","text-red-700"],[1,"mt-6","rounded-2xl","bg-slate-50","p-5","text-slate-500"],[1,"mt-6","rounded-2xl","border","border-dashed","border-slate-300","bg-slate-50","p-6","text-slate-600"],[1,"mt-6","space-y-4"],["class","rounded-2xl border border-slate-200 bg-white p-5 shadow-sm",4,"ngFor","ngForOf"],[1,"rounded-2xl","border","border-slate-200","bg-white","p-5","shadow-sm"],[1,"flex","flex-wrap","items-center","justify-between","gap-2"],[1,"text-primary-950"],[1,"text-xs","text-slate-500"],[1,"mt-3","whitespace-pre-line","leading-7","text-slate-600"],[1,"mt-3","rounded-xl","bg-red-50","px-4","py-3","text-sm","text-red-700"],[1,"mt-3","rounded-xl","bg-emerald-50","px-4","py-3","text-sm","text-emerald-800"]],template:function(e,n){e&1&&(u(0,he,57,37,"ng-container",0),w(1,"async")),e&2&&m("ngIf",W(1,1,n.article$))},dependencies:[re,ee,J,Q,X,te,ie,ne,Z,Y,P,B,G,H,O],styles:[`.rsu-article{font-size:1.05rem;line-height:1.85}.rsu-article :is(p,ul,ol){margin:1rem 0}.rsu-article :is(h2,h3){margin:2rem 0 1rem;color:#0f172a;font-weight:700}.rsu-article img{max-width:100%;border-radius:1rem;margin:1.5rem auto} `],encapsulation:2})};export{ae as RsuArticleDetailComponent};