1import{j as e,X as L,ag as A,au as X,q as E,aW as we,C as Ce,O as M,T as Y,R as J}from"./vendor-ui-fc56ca80.js";import{e as Se,r as c}from"./vendor-react-f9ccc48d.js";import{u as ke}from"./useMinutes-96d3858a.js";import{h as Ae,bJ as Ee,af as De,ae as Te,ag as Le,ah as K,B as o,I as Q,S as Me,o as Oe,p as Fe,q as Ie,r as D,K as O,M as F,N as I,O as P,Q as R,an as Pe,n as Re,az as $e,R as N}from"./index-90016d22.js";import{A as Be,b as Ge}from"./avatar-4e73900d.js";import{u as _e}from"./vendor-utils-323b9898.js";import"./vendor-firebase-a557f106.js";import"./auditService-c0bc5cfa.js";import"./vendor-charts-9af8b7c0.js";const Qe=()=>{const{t,i18n:U}=_e("salomon"),$=Se(),{userData:h}=Ae(),{fetchMinutes:T,deleteMinute:Z,restoreMinute:ee,hardDeleteMinute:se,updateMinute:te,loading:ae}=ke(),{members:B,loading:re}=Ee(),[x,G]=c.useState([]),[m,ne]=c.useState("active"),[p,le]=c.useState(""),[y,ie]=c.useState("ALL"),[ce,w]=c.useState(!1),[oe,C]=c.useState(!1),[n,f]=c.useState(null),[de,S]=c.useState(!1),[u,_]=c.useState([]),[j,v]=c.useState(""),[g,k]=c.useState(!1),me=(h==null?void 0:h.role)==="admin"||(h==null?void 0:h.role)==="superadmin",b=()=>{m==="active"?T("ALL_EXCEPT_DELETED").then(G):T("DELETED").then(G)};c.useEffect(()=>{b()},[T,m]),c.useEffect(()=>{x.length>0&&(console.log("Loaded Minutes:",x),x.forEach(s=>{s.salomonAnalysis&&console.log(`Minute ${s.correlative} Analysis:`,s.salomonAnalysis)}))},[x]);const xe=()=>{$("/app/salomon/new")},he=(s,r)=>{s.stopPropagation(),f(r),w(!0)},ue=(s,r)=>{s.stopPropagation(),f(r),C(!0)},ge=async()=>{n&&(await Z(n),w(!1),f(null),b())},pe=async(s,r)=>{s.stopPropagation(),await ee(r),b()},fe=async()=>{n&&(await se(n.id,n.correlative),C(!1),f(null),b())},je=(s,r)=>{s.stopPropagation(),f(r),_([...r.attendees||[],...r.absent||[]]),S(!0)},ve=async()=>{if(n)try{const s=n.absent||[],r=n.attendees||[],i=u.filter(d=>r.includes(d)),l=u.filter(d=>s.includes(d)),a=u.filter(d=>!r.includes(d)&&!s.includes(d));await te(n.id,{attendees:[...i,...a],absent:l}),S(!1),v(""),k(!1),b()}catch(s){console.error(s)}},V=s=>{_(r=>r.includes(s)?r.filter(i=>i!==s):[...r,s])},H=c.useMemo(()=>B.filter(s=>{var a;const i=`${s.firstName} ${s.lastName}`.toLowerCase().includes(j.toLowerCase())||((a=s.email)==null?void 0:a.toLowerCase().includes(j.toLowerCase())),l=u.includes(s.id);return g?i&&l:i}),[B,j,g,u]),z=c.useMemo(()=>x.filter(s=>{var l,a;const r=((l=s.correlative)==null?void 0:l.toString().includes(p))||((a=s.correlativeLabel)==null?void 0:a.toLowerCase().includes(p))||s.topics.some(d=>d.title.toLowerCase().includes(p.toLowerCase())),i=y==="ALL"||s.type===y;return r&&i}),[x,p,y]),be=s=>{switch(s){case"ELDERS_MEETING":return t("minutes.eldersMeeting");case"MEMBERS_ASSEMBLY":return t("minutes.membersAssembly");case"DEACONS_MEETING":return t("minutes.deaconsMeeting");default:return s}},Ne=s=>{switch(s){case"APPROVED":return e.jsx(N,{className:"bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-400 hover:bg-green-100 dark:hover:bg-green-900/30 border-none",children:t("minutes.approved")});case"IN_REVIEW":return e.jsx(N,{className:"bg-amber-100 dark:bg-amber-900/30 text-amber-700 dark:text-amber-400 hover:bg-amber-100 dark:hover:bg-amber-900/30 border-none",children:t("minutes.inReview")});case"DRAFT":return e.jsx(N,{className:"bg-gray-100 dark:bg-slate-800 text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-slate-800 border-none",children:t("minutes.draft")});case"DELETED":return e.jsx(N,{variant:"destructive",children:t("minutes.deleted")});default:return e.jsx(N,{variant:"outline",children:s})}},ye=s=>{var l;if(!((l=s.salomonAnalysis)!=null&&l.alerts))return{high:0,low:0};const r=s.salomonAnalysis.alerts.filter(a=>a.severity==="HIGH").length,i=s.salomonAnalysis.alerts.length-r;return{high:r,low:i}};return e.jsxs("div",{className:"space-y-6",children:[e.jsx(De,{title:t("minutes.title"),description:t("minutes.subtitle"),icon:e.jsx(L,{className:"h-6 w-6"}),action:e.jsxs("div",{className:"flex flex-wrap gap-3",children:[e.jsx(Te,{value:m,onValueChange:s=>ne(s),className:"w-auto",children:e.jsxs(Le,{children:[e.jsxs(K,{value:"active",className:"flex gap-2",children:[e.jsx(L,{className:"w-4 h-4"}),t("minutes.activeTab")]}),e.jsxs(K,{value:"trash",className:"flex gap-2 text-destructive data-[state=active]:text-destructive data-[state=active]:bg-destructive/10",children:[e.jsx(A,{className:"w-4 h-4"}),t("minutes.trashTab")]})]})}),m==="active"&&e.jsxs(o,{className:"gap-2 shadow-md transition-all font-semibold bg-primary hover:bg-primary/90 text-primary-foreground",onClick:xe,children:[e.jsx(X,{className:"w-4 h-4"}),t("minutes.newMinute")]})]})}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 mb-6",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(E,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),e.jsx(Q,{placeholder:t("minutes.searchPlaceholder"),className:"pl-9",value:p,onChange:s=>le(s.target.value)})]}),e.jsxs(Me,{value:y,onValueChange:s=>ie(s),children:[e.jsxs(Oe,{className:"w-full sm:w-[240px]",children:[e.jsx(we,{className:"w-4 h-4 mr-2 text-muted-foreground"}),e.jsx(Fe,{placeholder:t("minutes.filterType")})]}),e.jsxs(Ie,{children:[e.jsx(D,{value:"ALL",children:t("minutes.allMeetings")}),e.jsx(D,{value:"ELDERS_MEETING",children:t("minutes.eldersMeeting")}),e.jsx(D,{value:"MEMBERS_ASSEMBLY",children:t("minutes.membersAssembly")}
1),e.jsx(D,{value:"DEACONS_MEETING",children:t("minutes.deaconsMeeting")})]})]})]}),ae&&x.length===0?e.jsx("div",{className:"flex justify-center py-20",children:e.jsx("div",{className:"w-8 h-8 border-4 border-primary/20 border-t-primary rounded-full animate-spin"})}):z.length===0?e.jsxs("div",{className:"text-center py-20 bg-card rounded-xl border border-border border-dashed",children:[e.jsx("div",{className:"mx-auto w-12 h-12 bg-muted rounded-full flex items-center justify-center mb-4",children:e.jsx(E,{className:"w-6 h-6 text-muted-foreground"})}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:t("minutes.noMinutesFound")}),e.jsx("p",{className:"text-muted-foreground mt-1",children:t("minutes.noMinutesFoundSubtitle")})]}):e.jsx("div",{className:"grid gap-4",children:z.map(s=>{var r,i,l;return e.jsx("div",{onClick:()=>m==="active"&&$(`/app/salomon/minutes/${s.id}`),className:` 2 relative bg-card text-card-foreground p-5 rounded-xl border shadow-sm transition-all 3 ${m==="active"?"hover:border-primary/30 hover:shadow-md cursor-pointer group":"opacity-90"} 4 `,children:e.jsxs("div",{className:"flex justify-between items-start gap-4",children:[e.jsxs("div",{className:"flex gap-4",children:[e.jsxs("div",{className:"flex flex-col items-center justify-center w-14 h-14 bg-primary/10 text-primary rounded-lg shrink-0",children:[e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wider",children:"Acta"}),e.jsx("span",{className:"text-sm font-bold",children:s.correlativeLabel||`#${s.correlative||"?"}`})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("h3",{className:"font-semibold text-foreground text-lg",children:be(s.type)}),Ne(s.status)]}),e.jsxs("div",{className:"flex items-center text-sm text-muted-foreground gap-4",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ce,{className:"w-3.5 h-3.5"}),s.date.toLocaleDateString(U.language,{year:"numeric",month:"long",day:"numeric"})]}),e.jsx("span",{children:"â¢"}),e.jsx("span",{children:t("minutes.topicsCount",{count:s.topics.length})}),e.jsx("span",{children:"â¢"}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(M,{className:"w-3.5 h-3.5"}),t("minutes.present",{count:((r=s.attendees)==null?void 0:r.length)||0}),(((i=s.absent)==null?void 0:i.length)||0)>0&&`, ${t("minutes.absent",{count:(l=s.absent)==null?void 0:l.length})}`]}),(()=>{const a=ye(s);return a.high>0?e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"â¢"}),e.jsxs("span",{className:"flex items-center gap-1 text-destructive font-medium",title:t("minutes.conflictsDetected",{count:a.high}),children:[e.jsx(Y,{className:"w-3.5 h-3.5"}),t("minutes.conflictsDetected",{count:a.high})," ",a.low>0&&`(+${a.low})`]})]}):a.low>0?e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"â¢"}),e.jsxs("span",{className:"flex items-center gap-1 text-slate-500 hover:text-primary transition-colors",title:t("minutes.observations",{count:a.low}),children:[e.jsx(L,{className:"w-3.5 h-3.5"}),t("minutes.observations",{count:a.low})]})]}):null})()]}),s.topics.length>0&&e.jsxs("div",{className:"mt-3 flex gap-2 flex-wrap",children:[s.topics.slice(0,3).map(a=>e.jsx("span",{className:"inline-flex items-center px-2 py-1 rounded bg-muted text-muted-foreground text-xs",children:a.title},a.id)),s.topics.length>3&&e.jsx("span",{className:"inline-flex items-center px-2 py-1 rounded bg-muted/50 text-muted-foreground/70 text-xs",children:t("minutes.more",{count:s.topics.length-3})})]})]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[m==="active"&&me&&e.jsx(o,{variant:"ghost",size:"sm",className:"text-muted-foreground hover:text-primary hover:bg-primary/10",onClick:a=>je(a,s),title:"Gestionar Asistentes",children:e.jsx(M,{className:"w-4 h-4"})}),m==="active"?e.jsx(o,{variant:"ghost",size:"sm",className:"text-muted-foreground hover:text-red-600 dark:hover:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20",onClick:a=>he(a,s),children:e.jsx(A,{className:"w-4 h-4"})}):e.jsxs(e.Fragment,{children:[e.jsxs(o,{variant:"outline",size:"sm",className:"text-primary border-primary/20 hover:bg-primary/10",onClick:a=>pe(a,s.id),children:[e.jsx(J,{className:"w-4 h-4 mr-2"}),t("common.restore")]}),e.jsxs(o,{variant:"destructive",size:"sm",onClick:a=>ue(a,s),children:[e.jsx(A,{className:"w-4 h-4 mr-2"}),t("minutes.eliminateForever")]})]})]})]})},s.id)})}),e.jsx(O,{open:ce,onOpenChange:w,children:e.jsxs(F,{children:[e.jsxs(I,{children:[e.jsx(P,{children:t("minutes.softDeleteTitle")}),e.jsx(R,{children:t("minutes.softDeleteDescription",{number:n==null?void 0:n.correlative})})]}),e.jsxs("div",{className:"flex justify-end gap-3 pt-4",children:[e.jsx(o,{variant:"outline",onClick:()=>w(!1),children:t("common.cancel")}),e.jsxs(o,{variant:"destructive",onClick:ge,children:[e.jsx(A,{className:"w-4 h-4 mr-2"}),t("minutes.moveToTrash")]})]})]})}),e.jsx(O,{open:oe,onOpenChange:C,children:e.jsxs(F,{className:"border-red-200",children:[e.jsxs(I,{children:[e.jsxs(P,{className:"text-red-700 flex items-center gap-2",children:[e.jsx(Y,{className:"w-5 h-5"}),t("minutes.hardDeleteTitle")]}),e.jsx(R,{children:t("minutes.hardDeleteDescription",{number:n==null?void 0:n.correlative})})]}),e.jsxs("div",{className:"flex justify-end gap-3 pt-4",children:[e.jsx(o,{variant:"outline",onClick:()=>C(!1),children:t("common.cancel")}),e.jsx(o,{className:"bg-red-600 hover:bg-red-700 text-white",onClick:fe,children:t("minutes.eliminateForever")})]})]})}),e.jsx(O,{open:de,onOpenChange:s=>{S(s),s||(v(""),k(!1))},children:e.jsxs(F,{className:"sm:max-w-[500px]",children:[e.jsxs(I,{children:[e.jsxs(P,{className:"flex items-center gap-2",children:[e.jsx(M,{className:"w-5 h-5 text-primary"}),"Gestionar Asistentes"]}),e.jsxs(R,{children:["Selecciona los miembros que forman parte de la lista de asistencia para el acta #",n==null?void 0:n.correlative,"."]})]}),e.jsxs("div",{className:"py-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(E,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),e.jsx(Q,{placeholder:"Buscar por nombre o email...",className:"pl-9 h-9",value:j,onChange:s=>v(s.target.value)}),j&&e.jsx("button",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",onClick:()=>v(""),children:e.jsx(X,{className:"w-4 h-4 rotate-45"})})]}),e.jsx(o,{variant:g?"default":"outline",size:"sm",className:`h-9 whitespace-nowrap ${g?"bg-primary hover:bg-primary/90":""}`,onClick:()=>k(!g),children:g?"Ver todos":"Ver seleccionados"})]}),e.jsx(Pe,{className:"h-[300px] pr-4",children:re?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(J,{className:"w-6 h-6 animate-spin text-primary"})}):e.jsxs("div",{className:"space-y-2",children:[H.map(s=>{var a,d,q,W;const r=(a=n==null?void 0:n.attendees)==null?void 0:a.includes(s.id
4),i=(d=n==null?void 0:n.absent)==null?void 0:d.includes(s.id),l=u.includes(s.id);return e.jsxs("div",{className:`flex items-center justify-between p-3 rounded-lg border transition-all cursor-pointer ${l?"bg-primary/5 border-primary/20 ring-1 ring-primary/20":"border-border dark:border-border hover:bg-muted/50 dark:hover:bg-muted/50"}`,onClick:()=>V(s.id),children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Be,{className:`h-8 w-8 ${l?"bg-background":"bg-primary/10"}`,children:e.jsxs(Ge,{className:"text-primary text-xs font-bold",children:[(q=s.firstName)==null?void 0:q[0],(W=s.lastName)==null?void 0:W[0]]})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("p",{className:"text-sm font-medium text-foreground dark:text-foreground",children:[s.firstName," ",s.lastName]}),r&&e.jsx("span",{className:"text-[10px] bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-400 px-1.5 py-0.5 rounded font-bold uppercase tracking-wider",children:"Presente"}),i&&e.jsx("span",{className:"text-[10px] bg-slate-100 dark:bg-slate-800 text-slate-500 dark:text-slate-400 px-1.5 py-0.5 rounded font-bold uppercase tracking-wider",children:"Ausente"})]}),s.email&&e.jsx("p",{className:"text-xs text-muted-foreground dark:text-muted-foreground",children:s.email})]})]}),e.jsx(Re,{checked:l,onCheckedChange:()=>V(s.id),className:l?"border-primary data-[state=checked]:bg-primary text-primary-foreground":""})]},s.id)}),H.length===0&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground dark:text-muted-foreground",children:[e.jsx(E,{className:"w-8 h-8 mb-2 opacity-20"}),e.jsx("p",{className:"text-sm",children:"No se encontraron miembros"})]})]})})]}),e.jsxs($e,{children:[e.jsx(o,{variant:"outline",onClick:()=>{S(!1),v(""),k(!1)},children:"Cancelar"}),e.jsx(o,{className:"bg-primary hover:bg-primary/90 text-primary-foreground",onClick:ve,children:"Guardar Cambios"})]})]})})]})};export{Qe as MinuteListPage};
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.