1import{r as u,j as t}from"./vendor-react-CoH7wDUq.js";import{u as G,s as K,p as P}from"./index-co-p2Yz-.js";import{p as M}from"./NewsCoverImage-B_GCzheZ.js";function H(e){const a=e.trim();return a?/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(a):!1}async function J(e,a){const s=await(await fetch(e)).blob(),r=s.type||"image/jpeg";return new File([s],a,{type:r})}const Q=({photos:e,onPhotosChange:a,disabled:o,labels:s,variant:r="dark"})=>{const i=d=>{if(o)return;const n=d.target.files;if(n){for(let p=0;p<n.length;p++){const v=n[p],g=new FileReader;g.onload=f=>{var x;(x=f.target)!=null&&x.result&&a([...e,f.target.result])},g.readAsDataURL(v)}d.target.value=""}},c=d=>{o||a(e.filter((n,p)=>p!==d))},h=r==="light"?"border border-slate-200":"border border-slate-600",E=r==="light"?"text-amber-700 text-sm":"text-amber-400/90 text-sm",b=r==="light"?o?"bg-slate-200 text-slate-400 cursor-not-allowed":"bg-blue-600 hover:bg-blue-700 text-white cursor-pointer transition-colors":o?"bg-slate-600/50 text-slate-400 cursor-not-allowed":"bg-slate-700 hover:bg-slate-600 text-white cursor-pointer transition-colors";return t.jsxs("div",{className:"space-y-3",children:[o&&t.jsx("p",{className:E,children:s.needEmail}),t.jsx("div",{className:"flex flex-wrap gap-2",children:e.map((d,n)=>t.jsxs("div",{className:"relative group",children:[t.jsx("img",{src:d,alt:`Upload ${n+1}`,className:`w-20 h-20 object-cover rounded-lg ${h}`}),t.jsx("button",{type:"button",onClick:()=>c(n),disabled:o,className:"absolute -top-2 -right-2 bg-red-500 text-white rounded-full w-5 h-5 text-xs opacity-0 group-hover:opacity-100 transition-opacity disabled:opacity-30",children:"â"})]},n))}),t.jsxs("label",{className:`inline-flex items-center gap-2 px-4 py-2 rounded-lg text-sm ${b}`,children:[t.jsx("span",{children:"ð·"}),t.jsx("span",{children:s.addPhotos}),t.jsx("input",{type:"file",accept:"image/*",multiple:!0,disabled:o,onChange:i,className:"hidden"})]})]})},X=({comment:e})=>{const a=o=>new Intl.DateTimeFormat("pt-BR",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit"}).format(o);return t.jsxs("div",{className:"bg-slate-800/50 rounded-xl p-4 border border-slate-700",children:[t.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[t.jsx("div",{className:"w-10 h-10 rounded-full bg-gradient-to-br from-indigo-500 to-blue-500 flex items-center justify-center text-white font-bold",children:e.author.charAt(0).toUpperCase()}),t.jsxs("div",{children:[t.jsx("p",{className:"font-medium text-white",children:e.author}),t.jsx("p",{className:"text-xs text-slate-400",children:a(e.timestamp)})]})]}),t.jsx("p",{className:"text-slate-200 whitespace-pre-wrap mb-3",children:e.text}),e.photos.length>0&&t.jsx("div",{className:"flex flex-wrap gap-2",children:e.photos.map((o,s)=>t.jsx("img",{src:o,alt:`Foto ${s+1}`,className:"w-24 h-24 object-cover rounded-lg cursor-pointer hover:scale-105 transition-transform",onClick:()=>window.open(o,"_blank"),onKeyDown:r=>r.key==="Enter"&&window.open(o,"_blank")},s))})]})},me=({newsId:e,newsTitle:a,comments:o,onAddComment:s,onAfterPersist:r,variant:i="dark"})=>{const{language:c}=G(),[h,E]=u.useState(o),[b,d]=u.useState(""),[n,p]=u.useState(""),[v,g]=u.useState(""),[f,x]=u.useState([]),[S,B]=u.useState(!1),[R,N]=u.useState(!1),[$,k]=u.useState(""),[A,T]=u.useState(!1);u.useEffect(()=>{E(o)},[o]);const l={pt:{comments:"Comentários",leaveComment:"Deixe seu comentário",yourName:"Seu nome",yourEmail:"Seu e-mail",emailInvalid:"Informe um e-mail válido para comentar e enviar fotos.",commentPlaceholder:"Escreva seu comentário sobre o evento...",submit:"Enviar comentário",saving:"A guardarâ¦",persistFail:"Não foi possÃvel guardar no servidor. Verifique se o backend está a correr.",first:"Seja o primeiro a comentar! Compartilhe suas fotos e experiências.",addPhotos:"Adicionar fotos",needEmail
1:"Informe um e-mail válido no campo acima para adicionar fotos."},en:{comments:"Comments",leaveComment:"Leave a comment",yourName:"Your name",yourEmail:"Your email",emailInvalid:"Please enter a valid email to comment and attach photos.",commentPlaceholder:"Write your comment...",submit:"Send comment",saving:"Savingâ¦",persistFail:"Could not save to the server. Is the backend running?",first:"Be the first to comment! Share your photos and experiences.",addPhotos:"Add photos",needEmail:"Enter a valid email above to add photos."},es:{comments:"Comentarios",leaveComment:"Deja tu comentario",yourName:"Tu nombre",yourEmail:"Tu correo electrónico",emailInvalid:"Introduce un correo válido para comentar y enviar fotos.",commentPlaceholder:"Escribe tu comentario...",submit:"Enviar comentario",saving:"Guardandoâ¦",persistFail:"No se pudo guardar en el servidor. ¿Está el backend en marcha?",first:"¡Sé el primero en comentar! Comparte tus fotos y experiencias.",addPhotos:"Añadir fotos",needEmail:"Introduce un correo válido arriba para añadir fotos."}}[c],y=H(n),_=R&&n.trim()!==""&&!y,q=async m=>{if(m.preventDefault(),N(!0),k(""),!b.trim()||!v.trim()||!y)return;const w={author:b.trim(),email:n.trim(),text:v.trim(),photos:f};if(/^\d+$/.test(String(e||"").trim())||!!(a!=null&&a.trim())){T(!0);try{let j;const C=f[0];C!=null&&C.startsWith("data:")&&(j=await J(C,"foto.jpg"));const F=String(e||"").trim(),Y=/^\d+$/.test(F)?`[NotÃcia:id:${F}]`:`[NotÃcia: ${(a||"").trim()}]`;await K({nome:w.author,email:w.email,comentario:`${Y} 2 3${w.text}`,foto:j??null}),await(r==null?void 0:r())}catch(j){k(j instanceof Error?j.message:l.persistFail);return}finally{T(!1)}d(""),p(""),g(""),x([]),N(!1);return}s(e,w),d(""),p(""),g(""),x([]),N(!1)},I=i==="light"?"w-full bg-white border border-slate-200 text-slate-800 placeholder-slate-400 rounded-lg px-4 py-2 outline-none focus:ring-2 focus:ring-blue-500":"w-full bg-slate-700 text-white placeholder-slate-400 rounded-lg px-4 py-2 outline-none focus:ring-2 focus:ring-indigo-500",L=i==="light"?"bg-slate-50 rounded-xl p-4 space-y-4 border border-slate-200":"bg-slate-800/30 rounded-xl p-4 space-y-4",O=i==="light"?"text-slate-800":"text-white",z=i==="light"?"text-slate-500":"text-slate-400",V=i==="light"?"px-6 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-full font-medium transition-all":"px-6 py-2 bg-gradient-to-r from-indigo-600 to-blue-600 text-white rounded-full font-medium hover:from-indigo-500 hover:to-blue-500 transition-all",W=i==="light"?"flex items-center gap-2 text-slate-800 font-medium mb-4 hover:text-blue-600 transition-colors":"flex items-center gap-2 text-white font-medium mb-4 hover:text-indigo-400 transition-colors";return t.jsxs("div",{className:`mt-6 pt-6 border-t ${i==="light"?"border-slate-200":"border-slate-700"}`,children:[t.jsxs("button",{type:"button",onClick:()=>B(!S),className:W,children:[t.jsx("span",{children:"ð¬"}),t.jsxs("span",{children:[l.comments," (",o.length,")"]}),t.jsx("span",{className:`transition-transform ${S?"rotate-180":""}`,children:"â¼"})]}),S&&t.jsxs("div",{className:"space-y-4 animate-fade-in",children:[t.jsxs("form",{onSubmit:q,className:L,children:[t.jsx("h4",{className:`font-medium ${O}`,children:l.leaveComment}),t.jsx("input",{type:"text",placeholder:l.yourName,value:b,onChange:m=>d(m.target.value),className:I,required:!0,autoComplete:"name"}),t.jsx("input",{type:"email",placeholder:l.yourEmail,value:n,onChange:m=>{p(m.target.value),N(!0)},onBlur:()=>N(!0),className:I,required:!0,autoComplete:"email"}),_&&t.jsx("p",{className:"text-red-500 text-sm",children:l.emailInvalid}),$&&t.jsx("p",{className:"text-red-500 text-sm",children:$}),t.jsx("textarea",{placeholder:l.commentPlaceholder,value:v,onChange:m=>g(m.target.value),rows:3,className:`${I} resize-none`,required:!0}),t.jsx(Q,{photos:f,onPhotosChange:x,disabled:!y,labels:{addPhotos:l.addPhotos,needEmail:l.needEmail},variant:i}),t.jsx("button",{type:"submit",className:V,disabled:!y||A,children:A?l.saving:l.submit})]}),t.jsx("div",{className:"space-y-3",children:h.length===0?t.jsx("p",{className:`${z} text-center py-4`,children:l.first}):h.map(m=>t.jsx("div",{className:i==="light"?"bg-slate-50 rounded-xl p-4 border border-slate-200":void 0,children:i==="light"?t.jsx(Z,{comment:m}):t.jsx(X,{comment:m})},m.id))})]})]})},Z=({comment:e})=>{const a=o=>new Intl.DateTimeFormat("pt-BR",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit"}
3).format(o);return t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[t.jsx("div",{className:"w-10 h-10 rounded-full bg-gradient-to-br from-blue-500 to-indigo-600 flex items-center justify-center text-white font-bold",children:e.author.charAt(0).toUpperCase()}),t.jsxs("div",{children:[t.jsx("p",{className:"font-medium text-slate-800",children:e.author}),t.jsx("p",{className:"text-xs text-slate-500",children:a(e.timestamp)})]})]}),t.jsx("p",{className:"text-slate-600 text-sm whitespace-pre-wrap mb-3",children:e.text}),e.photos.length>0&&t.jsx("div",{className:"flex flex-wrap gap-2",children:e.photos.map((o,s)=>t.jsx("img",{src:o,alt:`Foto ${s+1}`,className:"w-24 h-24 object-cover rounded-lg cursor-pointer hover:scale-105 transition-transform border border-slate-200",onClick:()=>window.open(o,"_blank")},s))})]})},ee=/^\[NotÃcia:id:(\d+)\]\s*(?:\r?\n)*([\s\S]*)$/,te=/^\[NotÃcia:\s*([^\]]+)\]\s*(?:\r?\n)*([\s\S]*)$/;function D(e){return String(e||"").trim().replace(/\s+/g," ")}function U(e){const a=String(e||""),o=a.match(ee);if(o){const r=parseInt(o[1],10);if(!Number.isNaN(r))return{kind:"id",id:r,body:o[2].trim()}}const s=a.match(te);if(s){const r=s[1].trim();if(/^id:\d+$/i.test(r)){const i=parseInt(r.replace(/^id:/i,""),10);if(!Number.isNaN(i))return{kind:"id",id:i,body:s[2].trim()}}return{kind:"title",title:r,body:s[2].trim()}}return null}function oe(e){const a=U(e.comentario);if(!a)return null;const o=[];return e.imagemArquivo&&o.push(P(`uploads/avaliacoes/${e.imagemArquivo}`)),{id:`db-${e.id}`,author:e.nome,email:e.email,text:a.body,photos:o,timestamp:new Date(e.criadoEm)}}function ae(e,a){const o=new Map;for(const r of e)o.set(D(r.title),r.id);const s={};for(const r of e)s[r.id]=[];for(const r of a){const i=U(r.comentario);if(!i)continue;let c;if(i.kind==="id"?c=String(i.id):c=o.get(D(i.title)),!c||!s[c])continue;const h=oe(r);h&&s[c].push(h)}for(const r of Object.keys(s))s[r].sort((i,c)=>i.timestamp.getTime()-c.timestamp.getTime());return s}function de(e,a){const o=ae(e.map(s=>({id:s.id,title:s.title})),a);return e.map(s=>({...s,comments:o[s.id]??[]}))}function se(e){const a=(e||"").trim();return a?/^https?:\/\//i.test(a)?a:P(a.replace(/^\//,"")):""}function ue(e,a=[]){return{id:String(e.id),title:e.titulo,summary:e.resumo??"",content:e.conteudo,imageUrl:se(e.imagemUrl),imageCapaAjuste:e.imagemCapaAjuste!=null?M(e.imagemCapaAjuste):null,date:new Date(e.dataPublicacao),source:e.fonteNome??void 0,sourceUrl:e.fonteUrl??void 0,comments:a}}export{me as N,ae as c,de as m,ue as n};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.