1import{j as e,D as Q,g as U,v as X,w as J,F as b,$ as K,p as W,Q as Y,B as n,X as Z,r,z as ee,t as S,ab as E,H as se,m as te,ah as ae,E as oe,ad as re}from"./index-DtinW7og.js";import{u as ne}from"./useConteudoInstitucional-BoKrATtS.js";import{u as le}from"./use-toast-DKsFbTKa.js";import{C as M}from"./ConteudoInstitucionalForm-BJAQfTVP.js";import{B as p}from"./badge-CYwYsgea.js";import{A as ie,b as de,c as ce,d as me,e as xe,f as ue}from"./alert-dialog-DwV0Dvrj.js";import{T as he,a as ge,b as y,c as g,d as fe,e as m}from"./table-DOm-_2pJ.js";import{T as be,a as pe,b as je,c as Ne}from"./tabs-CAMbxCVb.js";import"./slugUtils-BJw85F3D.js";import"./quill.snow-CL8hP-vq.js";import"./isEqual-BrC_hBtV.js";import"./save-DMXHa9et.js";const ve=({isOpen:i,onClose:a,conteudo:t})=>{if(!t)return null;const l=o=>o==="boletim"?"Boletim de Atualização":"Resumo de Documento",d=o=>{const x={publicado:"bg-success/10 text-success border-success/30",rascunho:"bg-warning/10 text-warning-foreground border-warning/30",arquivado:"bg-muted text-muted-foreground border-border"};return x[o]||x.rascunho},c=o=>o?new Date(o).toLocaleDateString("pt-BR",{day:"2-digit",month:"long",year:"numeric"}):"Data não disponÃvel";return e.jsx(Q,{open:i,onOpenChange:a,children:e.jsxs(U,{className:"max-w-4xl max-h-[90vh] overflow-y-auto p-0",children:[e.jsx("div",{className:"sticky top-0 z-10 bg-background border-b border-border px-6 py-4",children:e.jsx(X,{children:e.jsxs(J,{className:"flex items-center gap-2 text-2xl font-black",children:[e.jsx(b,{className:"w-6 h-6 text-primary"}),"Visualizar Conteúdo"]})})}),e.jsxs("div",{className:"px-6 py-6 space-y-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-3xl font-black text-foreground mb-4",children:t.titulo}),e.jsxs("div",{className:"flex flex-wrap gap-3 items-center",children:[e.jsx(p,{className:`${d(t.status)} border font-bold uppercase`,children:t.status}),e.jsx(p,{className:"bg-primary/10 text-primary border-primary/30 border font-bold uppercase",children:l(t.categoria)})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 p-4 bg-muted/30 rounded-xl border border-border",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(K,{className:"w-5 h-5"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-bold uppercase tracking-wider",children:"Autor"}),e.jsx("p",{className:"text-foreground font-bold",children:t.autor})]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(W,{className:"w-5 h-5"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-bold uppercase tracking-wider",children:"Data de Publicação"}),e.jsx("p",{className:"text-foreground font-bold",children:c(t.data_publicacao)})]})]})]}),t.imagem_capa&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(Y,{className:"w-5 h-5 text-muted-foreground"}),e.jsx("h3",{className:"text-lg font-bold text-foreground",children:"Imagem de Capa"})]}),e.jsx("img",{src:t.imagem_capa,alt:t.titulo,className:"w-full h-64 object-cover rounded-xl border border-border shadow-md"})]}),e.jsxs("div",{children:[e.jsxs("h3",{className:"text-lg font-bold text-foreground mb-3 flex items-center gap-2",children:[e.jsx(b,{className:"w-5 h-5 text-primary"}),"Conteúdo"]}),e.jsx("div",{className:"article-content-professional p-6 bg-muted/30 rounded-xl border border-border",dangerouslySetInnerHTML:{__html:t.corpo}})]})]}),e.jsx("div",{className:"sticky bottom-0 z-10 bg-background border-t border-border px-6 py-4",children:e.jsxs(n,{onClick:a,variant:"outline",className:"w-full h-12 font-bold rounded-full",children:[e.jsx(Z,{className:"w-5 h-5 mr-2"}),"Fechar"]})})]})})},Ce=({isOpen:i,onClose:a,conteudo:t,onSave:l})=>e.jsx(M,{isOpen:i,onClose:a,onSuccess:l,editingContent:t}),we=({isOpen:i,onClose:a,conteudoId:t,onDelete:l})=>{const[d,c]=r.useState(!1),o=async()=>{c(!0),await l(t),c(!1),a()};return e.jsx(ie,{open:i,onOpenChange:a,children:e.jsxs(de,{className:"max-w-md",children:[e.jsxs(ce,{children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("div",{className:"p-3 rounded-full bg-destructive/10",children:e.jsx(ee,{className:"w-6 h-6 text-destructive"})}),e.jsx(me,{className:"text-2xl font-black",children:"Confirmar Exclusão"})]}
1),e.jsx(xe,{className:"text-base text-foreground/80 mt-4",children:"Tem certeza que deseja deletar este conteúdo? Esta ação não pode ser desfeita e o conteúdo será permanentemente removido do sistema."})]}),e.jsxs(ue,{className:"flex flex-col sm:flex-row gap-3 mt-6",children:[e.jsx(n,{variant:"outline",onClick:a,disabled:d,className:"flex-1 h-12 font-bold rounded-full",children:"Cancelar"}),e.jsx(n,{variant:"destructive",onClick:o,disabled:d,className:"flex-1 h-12 font-bold rounded-full",children:d?e.jsxs(e.Fragment,{children:[e.jsx(S,{className:"w-5 h-5 mr-2 animate-spin"}),"Excluindo..."]}):e.jsxs(e.Fragment,{children:[e.jsx(E,{className:"w-5 h-5 mr-2"}),"Confirmar Exclusão"]})})]})]})})},Fe=()=>{const[i,a]=r.useState(!1),[t,l]=r.useState(!1),[d,c]=r.useState(!1),[o,x]=r.useState(!1),[D,j]=r.useState(null),[B,F]=r.useState(null),[N,k]=r.useState(1),v=10,{toast:A}=le(),{contents:u,loading:T,fetchContents:f,deleteContent:z}=ne();r.useEffect(()=>{console.log("ð¬ [AdminConteudoInstitucionalPanel] Component mounted, fetching contents"),f()},[f]);const L=()=>{console.log("â [AdminConteudoInstitucionalPanel] Opening form for new content"),j(null),a(!0)},R=s=>{console.log("ðï¸ [AdminConteudoInstitucionalPanel] Opening view modal for:",s.id),j(s),l(!0)},H=s=>{console.log("âï¸ [AdminConteudoInstitucionalPanel] Opening edit modal for:",s.id),j(s),c(!0)},V=s=>{console.log("ðï¸ [AdminConteudoInstitucionalPanel] Opening delete dialog for:",s.id),F(s.id),x(!0)},_=async s=>{console.log("ðï¸ [AdminConteudoInstitucionalPanel] Deleting content:",s);const h=await z(s);h.success?(A({title:"Conteúdo excluÃdo!",description:"O conteúdo foi removido com sucesso.",variant:"default"}),f()):A({title:"Erro ao excluir",description:h.error||"Não foi possÃvel excluir o conteúdo.",variant:"destructive"})},O=()=>{console.log("â
[AdminConteudoInstitucionalPanel] Form submitted successfully, refreshing list"),f()},q=s=>{const h={publicado:"bg-success/10 text-success border-success/30",rascunho:"bg-warning/10 text-warning-foreground border-warning/30",arquivado:"bg-muted text-muted-foreground border-border"};return h[s]||h.rascunho},$=s=>s==="boletim"?"Boletim":"Resumo",G=s=>s?new Date(s).toLocaleDateString("pt-BR",{day:"2-digit",month:"2-digit",year:"numeric"}):"-",C=Math.ceil(u.length/v),w=(N-1)*v,I=w+v,P=u.slice(w,I);return console.log("ð¨ [AdminConteudoInstitucionalPanel] Rendering. Contents:",u.length,"Loading:",T),e.jsxs(e.Fragment,{children:[e.jsxs(se,{children:[e.jsx("title",{children:"Gerenciar Conteúdos Institucionais | Admin MOV"}),e.jsx("meta",{name:"description",content:"Painel administrativo para gerenciar conteúdos institucionais - Boletins e Resumos de Documentos"})]}),e.jsx("div",{className:"min-h-screen bg-background py-12",children:e.jsxs("div",{className:"container mx-auto px-6 max-w-7xl",children:[e.jsx(te.div,{initial:{opacity:0,y:-20},animate:{opacity:1,y:0},className:"mb-8",children:e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-3 rounded-xl bg-primary/10",children:e.jsx(b,{className:"w-8 h-8 text-primary"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-4xl font-black text-foreground",children:"Conteúdos Institucionais"}),e.jsx("p",{className:"text-muted-foreground font-semibold",children:"Gerencie boletins e resumos de documentos"})]})]}),e.jsxs(n,{onClick:L,className:"bg-primary hover:bg-primary/90 text-white font-bold rounded-full px-6 py-6 shadow-lg",children:[e.jsx(ae,{className:"w-5 h-5 mr-2"}),"Novo Conteúdo"]})]})}),e.jsxs(be,{defaultValue:"list",className:"w-full",children:[e.jsx(pe,{className:"grid w-full max-w-md grid-cols-1 mb-8",children:e.jsxs(je,{value:"list",className:"font-bold",children:["Lista de Conteúdos (",u.length,")"]})}),e.jsx(Ne,{value:"list",children:T?e.jsx("div",{className:"flex justify-center items-center py-20",children:e.jsx(S,{className:"w-12 h-12 text-primary animate-spin"})}):e.jsxs("div",{className:"bg-card rounded-2xl border border-border shadow-lg overflow-hidden",children:[e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(he,{children:[e.jsx(ge,{children:e.jsxs(y,{className:"bg-muted/50",children:[e.jsx(g,{className:"font-black text-foreground",children:"TÃtulo"}),e.jsx(g,{className:"font-black text-foreground",children:"Autor"}),e.jsx(g,{className:"font-black text-foreground",children:"Categoria"}),e.jsx(g,{className:"font-black text-foreground",children:"Status"}),e.jsx(g,{className:"font-black text-foreground",children:"Data"}),e.jsx(g,{className:"font-black text-foreground text-right",children:"Ações"})]})}
1),e.jsx(fe,{children:P.length===0?e.jsx(y,{children:e.jsxs(m,{colSpan:6,className:"text-center py-12 text-muted-foreground",children:[e.jsx(b,{className:"w-12 h-12 mx-auto mb-3 opacity-50"}),e.jsx("p",{className:"font-bold",children:"Nenhum conteúdo cadastrado"}),e.jsx("p",{className:"text-sm",children:'Clique em "Novo Conteúdo" para começar'})]})}):P.map(s=>e.jsxs(y,{className:"hover:bg-muted/30 transition-colors",children:[e.jsx(m,{className:"font-bold text-foreground max-w-xs truncate",children:s.titulo}),e.jsx(m,{className:"text-muted-foreground font-semibold",children:s.autor}),e.jsx(m,{children:e.jsx(p,{className:"bg-primary/10 text-primary border-primary/30 border font-bold",children:$(s.categoria)})}),e.jsx(m,{children:e.jsx(p,{className:`${q(s.status)} border font-bold uppercase`,children:s.status})}),e.jsx(m,{className:"text-muted-foreground font-semibold",children:G(s.data_publicacao)}),e.jsx(m,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(n,{variant:"ghost",size:"sm",onClick:()=>R(s),className:"text-primary hover:text-primary hover:bg-primary/10 rounded-full",children:e.jsx(oe,{className:"w-4 h-4"})}),e.jsx(n,{variant:"ghost",size:"sm",onClick:()=>H(s),className:"text-foreground hover:text-primary hover:bg-primary/10 rounded-full",children:e.jsx(re,{className:"w-4 h-4"})}),e.jsx(n,{variant:"ghost",size:"sm",onClick:()=>V(s),className:"text-destructive hover:text-destructive hover:bg-destructive/10 rounded-full",children:e.jsx(E,{className:"w-4 h-4"})})]})})]},s.id))})]})}),C>1&&e.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-t border-border",children:[e.jsxs("p",{className:"text-sm text-muted-foreground font-semibold",children:["Mostrando ",w+1," a ",Math.min(I,u.length)," de ",u.length," conteúdos"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(n,{variant:"outline",size:"sm",onClick:()=>k(s=>Math.max(1,s-1)),disabled:N===1,className:"font-bold rounded-full",children:"Anterior"}),e.jsx(n,{variant:"outline",size:"sm",onClick:()=>k(s=>Math.min(C,s+1)),disabled:N===C,className:"font-bold rounded-full",children:"Próxima"})]})]})]})})]})]})}),e.jsx(M,{isOpen:i,onClose:()=>a(!1),onSuccess:O}),e.jsx(ve,{isOpen:t,onClose:()=>l(!1),conteudo:D}),e.jsx(Ce,{isOpen:d,onClose:()=>c(!1),conteudo:D,onSave:O}),e.jsx(we,{isOpen:o,onClose:()=>x(!1),conteudoId:B,onDelete:_})]})};export{Fe as default};
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.