PageSourceSearch

https://irpa2026colombia.org/assets/SystemHealthMonitor-4oni7MPo.js

js irpa2026colombia.org collected 2026-10-08 03:17:21 UTC 24,795 bytes, 6 lines download raw bytes

1import{c as Be,u as Fe,g as Ue,d as ze,r as c,j as e,b as I,L as te,B as k,s as L}from"./index-DnVm687U.js";import{H as He,F as Oe}from"./Footer-Bvqa_r8G.js";import{C as h,a as j,b as N,c as w,d as re}from"./card-CRFaJYNz.js";import{I as Je}from"./input-D4ugazI8.js";import{B as y}from"./badge-BLNB1n0H.js";import{T as Pe,a as Ve,b as z,c as H}from"./tabs-DbatMKTI.js";import{T as pe,a as ge,b as O,c as m,d as fe,e as x}from"./table-DWz2i9MN.js";import{S as J,a as P,b as V,c as q,d as i}from"./select-BBeLgipb.js";import{S as qe}from"./switch-BVLlnVxk.js";import{L as De}from"./label-BWZGrcrB.js";import{C as Ge}from"./chevron-left-DHM-10nb.js";import{A as Ke}from"./activity-D4gwBZFW.js";import{E as be}from"./eye-Bub6U8nG.js";import{R as ve}from"./refresh-cw-Idxe6BZk.js";import{W as _e}from"./wrench-D972h4fF.js";import{C as We}from"./clock-CIC8GvrU.js";import{U as Ne}from"./users-qgl9wAWj.js";import{U as Ze}from"./user-check-gn5bepNx.js";import{U as D}from"./user-cog-Bj68fsds.js";import{C as Qe}from"./circle-alert-DRJhAiAk.js";import{S as G}from"./shield-alert-csZ0oKw4.js";import{K as Xe}from"./key-round-K7wKfepe.js";import{T as Ye}from"./trending-up-Co0Wxhb6.js";import{S as es}from"./search-BNZJvCG8.js";import{C as le}from"./circle-check-CEudxvXQ.js";import{T as we}from"./triangle-alert-DrFwYdXz.js";import"./dropdown-menu-elZyZctl.js";import"./index-B-Wc5f3e.js";import"./Combination-D1NCdNup.js";import"./index-C7OIboLl.js";import"./shield-BN1RiLGr.js";import"./log-out-CtUQRbPX.js";import"./mail-BBtFmBsn.js";import"./index-Cue5PJE5.js";import"./chevron-up-46FaISor.js";/**
2 * @license lucide-react v0.462.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const ss=Be("ArrowRightLeft",[["path",{d:"m16 3 4 4-4 4",key:"1x1c3m"}],["path",{d:"M20 7H4",key:"zbl0bi"}],["path",{d:"m8 21-4-4 4-4",key:"h9nckh"}],["path",{d:"M4 17h16",key:"g4d7ey"}]]),as={green:{label:"Sano",cls:"bg-emerald-500/15 text-emerald-700 dark:text-emerald-400 border-emerald-500/30",icon:le},blue:{label:"Multi-perfil",cls:"bg-blue-500/15 text-blue-700 dark:text-blue-400 border-blue-500/30",icon:D},yellow:{label:"Revisar",cls:"bg-amber-500/15 text-amber-700 dark:text-amber-400 border-amber-500/30",icon:we},red:{label:"Crítico",cls:"bg-red-500/15 text-red-700 dark:text-red-400 border-red-500/30",icon:G},gray:{label:"Juez inactivo",cls:"bg-slate-500/15 text-slate-700 dark:text-slate-400 border-slate-500/30",icon:D}},ts={green:{label:"Sistema saludable",cls:"from-emerald-500/20 to-emerald-500/5 border-emerald-500/40",icon:le,description:"Sin inconsistencias detectadas. Integridad correcta entre todas las tablas."},yellow:{label:"Atención requerida",cls:"from-amber-500/20 to-amber-500/5 border-amber-500/40",icon:we,description:"Inconsistencias leves detectadas. Revisar la tabla de usuarios para ver detalles."},red:{label:"Intervención inmediata",cls:"from-red-500/20 to-red-500/5 border-red-500/40",icon:G,description:"Errores críticos detectados. Ejecutar auto-reparación o revisar manualmente."}},rs={super_admin:"Super Admin",admin_association:"Admin Asociación",judge:"Juez",participant:"Participante",registration_staff:"Staff Registro"},ls={role_assigned:"Rol asignado",role_revoked:"Rol revocado",role_changed:"Rol modificado",auto_repair_user_consistency:"Auto-reparación ejecutada"},is={manual_reassignment:"Reasignación manual",auto_assignment:"Asignación automática",manual_assignment:"Asignación manual",unassignment:"Desasignación",deletion:"Eliminación",redistribution:"Redistribución"},Js=()=>{var ue,he;const S=Fe(),{userRole:d,loading:f}=Ue(),{toast:g}=ze(),[r,K]=c.useState(null),[_,ye]=c.useState(!0),[$,Se]=c.useState([]),[W,ie]=c.useState(!0),[M,Ce]=c.useState(""),[A,Ae]=c.useState("all"),[R,Re]=c.useState("all"),[Z,Te]=c.useState(!1),[ne,ce]=c.useState(!1),[Ee,ke]=c.useState([]),[Q,de]=c.useState(!1),[X,Le]=c.useState("all"),[Y,Ie]=c.useState("all"),B=["super_admin","admin_association"],oe=d==="admin_association";c.useEffect(()=>{f||(!d||!B.includes(d))&&(g({title:"Acceso denegado",description:"No tiene permisos para acceder a esta sección.",variant:"destructive"}),S("/admin"))},[d,f,S,g]);const F=async()=>{try{const{data:s,error:l}=await L.rpc("get_system_health_metrics");if(l)throw l;K(s)}catch(s){g({title:"Error al cargar métricas",description:s.message??"No se pudieron obtener las métricas del sistema.",variant:"destructive"})}finally{ye(!1)}},T=async()=>{ie(!0);try{const{data:s,error:l}=await L.rpc("get_user_health_status",{p_search:M||null,p_status_filter:A==="all"?null:A,p_role_filter:R==="all"?null:R,p_limit:200,p_offset:0});if(l)throw l;Se(s??[])}catch(s){g({title:"Error al cargar usuarios",description:s.message??"No se pudo obtener el estado de los usuarios.",variant:"destructive"})}finally{ie(!1)}},me=async()=>{de(!0);try{const{data:s,error:l}=await L.from("assignment_audit_logs").select("id, created_at, abstract_id, abstract_title, previous_judge_id, previous_judge_name, new_judge_id, new_judge_name, previous_status, new_status, action_type, triggered_by_email, reason").order("created_at",{ascending:!1}).limit(500);if(l)throw l;const a=Array.from(new Set((s??[]).map(v=>
6v.abstract_id).filter(Boolean)));let b={};if(a.length>0){const{data:v}=await L.from("abstract_evaluations").select("abstract_id").in("abstract_id",a);(v??[]).forEach(E=>{b[E.abstract_id]=(b[E.abstract_id]??0)+1})}ke((s??[]).map(v=>({...v,evaluations_count:b[v.abstract_id]??0,had_evaluation:(b[v.abstract_id]??0)>0})))}catch(s){g({title:"Error al cargar reasignaciones",description:s.message??"No se pudo obtener el historial de reasignaciones.",variant:"destructive"})}finally{de(!1)}};c.useEffect(()=>{d&&B.includes(d)&&(F(),T(),me())},[d]),c.useEffect(()=>{if(!Z)return;const s=setInterval(()=>{F(),T()},6e4);return()=>clearInterval(s)},[Z,M,A,R]),c.useEffect(()=>{if(!d||!B.includes(d))return;const s=setTimeout(()=>T(),350);return()=>clearTimeout(s)},[M,A,R]);const $e=async()=>{if(confirm("¿Ejecutar auto-reparación de inconsistencias? Esta acción intentará corregir errores menores y queda registrada en el historial.")){ce(!0);try{const{data:s,error:l}=await L.rpc("auto_repair_user_consistency");if(l)throw l;const a=s;g({title:"Reparación completada",description:`Perfiles creados: ${a.profiles_created} · Roles participant añadidos: ${a.participant_roles_added} · Roles judge añadidos: ${a.judge_roles_added} · Roles judge revocados: ${a.judge_roles_removed}`}),await F(),await T()}catch(s){g({title:"Error en reparación",description:s.message??"No se pudo completar la reparación automática.",variant:"destructive"})}finally{ce(!1)}}},n=r==null?void 0:r.totals,t=r==null?void 0:r.integrity,o=r==null?void 0:r.activity_7d,p=r==null?void 0:r.auto_repairs,ee=(r==null?void 0:r.global_status)??"green",U=ts[ee],Me=U.icon,xe=$.length,se=((ue=$[0])==null?void 0:ue.total_count)??0;return f||!d||!B.includes(d)?e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:e.jsx(I,{className:"h-8 w-8 animate-spin text-primary"})}):e.jsxs("div",{className:"min-h-screen bg-background flex flex-col",children:[e.jsx(He,{}),e.jsxs("main",{className:"flex-1 container mx-auto px-4 pt-28 pb-12",children:[e.jsxs("div",{className:"mb-6 flex items-center justify-between flex-wrap gap-3",children:[e.jsxs("div",{children:[e.jsxs(te,{to:"/admin",className:"inline-flex items-center text-sm text-muted-foreground hover:text-foreground mb-2",children:[e.jsx(Ge,{className:"h-4 w-4 mr-1"})," Volver al panel"]}),e.jsxs("h1",{className:"text-3xl font-bold flex items-center gap-2 flex-wrap",children:[e.jsx(Ke,{className:"h-7 w-7 text-primary"}),"Salud del Sistema",oe&&e.jsxs(y,{variant:"outline",className:"ml-2 text-xs font-normal border-amber-500/40 text-amber-700 dark:text-amber-400 bg-amber-500/10",children:[e.jsx(be,{className:"h-3 w-3 mr-1"})," Solo lectura"]})]}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Monitoreo en tiempo real de usuarios, roles y perfiles"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qe,{id:"auto-refresh",checked:Z,onCheckedChange:Te}),e.jsx(De,{htmlFor:"auto-refresh",className:"text-sm",children:"Auto-refresh 60s"})]}),e.jsxs(k,{variant:"outline",size:"sm",onClick:()=>{F(),T()},disabled:_||W,children:[e.jsx(ve,{className:`h-4 w-4 mr-2 ${_||W?"animate-spin":""}`}),"Actualizar"]}),!oe&&e.jsxs(k,{size:"sm",onClick:$e,disabled:ne||_,children:[ne?e.jsx(I,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(_e,{className:"h-4 w-4 mr-2"}),"Auto-reparar ahora"]})]})]}),e.jsx(h,{className:`mb-6 bg-gradient-to-br ${U.cls} border-2`,children:e.jsxs(j,{className:"pt-6 pb-6 flex items-center gap-4",children:[e.jsx(Me,{className:`h-12 w-12 ${ee==="red"?"text-red-600":ee==="yellow"?"text-amber-600":"text-emerald-600"}`}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"text-2xl font-bold",children:U.label}),e.jsx("div",{className:"text-sm text-muted-foreground",children:U.description}),r&&e.jsxs("div",{className:"text-xs text-muted-foreground mt-1 flex items-center gap-1",children:[e.jsx(We,{className:"h-3 w-3"}),"Calculado: ",r.computed_at_bogota.split(".")[0]," (Bogotá)"]})]})]})}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-3 mb-6",children:[e.jsx(C,{icon:Ne,label:"Usuarios totales",value:n==null?void 0:n.total_users,loading:_}),e.jsx(C,{icon:Ze,label:"Participantes",value:n==null?void 0:n.total_participants,loading:_}),e.jsx(C,{icon:D,label:"Jueces",value:n==null?void 0:n.total_judges,loading:_,accent:"blue"}),e.jsx(C,{icon:D,label:"Multi-perfil",value:n==null?void 0:n.multi_role,loading:_,accent:"blue"}),e.jsx(C,{icon:Ne,label:"Mono-perfil",value:n==null?void 0:n.single_role,loading:_}),e.jsx(C,{icon:Qe,label:"Sin rol",value:n==null?void 0:n.no_role,loading:_,accent:((n==null?void 0:n.no_role)??0)>0?"red":"neutral"})]}),e.jsxs(Pe,{defaultValue:"metrics",className:"w-full",children:[e.jsxs(Ve,{className:"grid w-full grid-cols-4 max-w-3xl",children:[e.jsx(z,{value:"metrics",children:"Métricas de salud"}),e.jsx(z,{value:"users",children:"Estado de usuarios"}),e.jsx(z,{value:"reassignments",children:"Auditoría reasignaciones"}),e.jsx(z,{value:"history",children:"Historial"})]}
6),e.jsxs(H,{value:"metrics",className:"space-y-4 mt-6",children:[e.jsxs("div",{className:"grid md:grid-cols-2 lg:grid-cols-3 gap-4",children:[e.jsxs(h,{children:[e.jsx(N,{className:"pb-3",children:e.jsxs(w,{className:"text-base flex items-center gap-2",children:[e.jsx(G,{className:"h-4 w-4 text-primary"})," Integridad"]})}),e.jsxs(j,{className:"space-y-2 text-sm",children:[e.jsx(u,{label:"Inconsistencias detectadas",value:(t==null?void 0:t.inconsistencies)??0,highlight:((t==null?void 0:t.inconsistencies)??0)>0?"amber":"green"}),e.jsx(u,{label:"Críticas",value:(t==null?void 0:t.critical)??0,highlight:((t==null?void 0:t.critical)??0)>0?"red":"green"}),e.jsx(u,{label:"Altas",value:(t==null?void 0:t.high)??0,highlight:((t==null?void 0:t.high)??0)>0?"amber":"green"}),e.jsx(u,{label:"Pendientes de revisión",value:(t==null?void 0:t.pending_review)??0,highlight:((t==null?void 0:t.pending_review)??0)>0?"amber":"green"}),e.jsx(u,{label:"% Integridad",value:`${(t==null?void 0:t.integrity_pct)??100}%`,highlight:"green"}),e.jsx(u,{label:"% Multi-perfil",value:`${(t==null?void 0:t.multi_role_pct)??0}%`,highlight:"blue"})]})]}),e.jsxs(h,{children:[e.jsx(N,{className:"pb-3",children:e.jsxs(w,{className:"text-base flex items-center gap-2",children:[e.jsx(Xe,{className:"h-4 w-4 text-primary"})," Actividad (7 días)"]})}),e.jsxs(j,{className:"space-y-2 text-sm",children:[e.jsx(u,{label:"Logins exitosos",value:(o==null?void 0:o.login_success)??0,highlight:"green"}),e.jsx(u,{label:"Logins fallidos",value:(o==null?void 0:o.login_failed)??0,highlight:((o==null?void 0:o.login_failed)??0)>20?"amber":"neutral"}),e.jsx(u,{label:"Nuevos registros",value:(o==null?void 0:o.signups)??0,highlight:"blue"}),e.jsx(u,{label:"Cambios de rol",value:(o==null?void 0:o.role_changes)??0,highlight:"neutral"})]})]}),e.jsxs(h,{children:[e.jsx(N,{className:"pb-3",children:e.jsxs(w,{className:"text-base flex items-center gap-2",children:[e.jsx(_e,{className:"h-4 w-4 text-primary"})," Correcciones automáticas"]})}),e.jsxs(j,{className:"space-y-2 text-sm",children:[e.jsx(u,{label:"Últimas 24 horas",value:(p==null?void 0:p.last_24h)??0,highlight:((p==null?void 0:p.last_24h)??0)>0?"amber":"neutral"}),e.jsx(u,{label:"Últimos 7 días",value:(p==null?void 0:p.last_7d)??0,highlight:"neutral"}),e.jsx(u,{label:"Últimos 30 días",value:(p==null?void 0:p.last_30d)??0,highlight:"neutral"})]})]})]}),e.jsxs(h,{children:[e.jsxs(N,{children:[e.jsxs(w,{className:"text-base flex items-center gap-2",children:[e.jsx(Ye,{className:"h-4 w-4 text-primary"})," Eventos críticos recientes"]}),e.jsx(re,{children:"Últimos 10 cambios de rol y reparaciones (hora Bogotá)"})]}),e.jsx(j,{children:(he=r==null?void 0:r.recent_events)!=null&&he.length?e.jsx("div",{className:"space-y-2",children:r.recent_events.map(s=>{var l,a;return e.jsxs("div",{className:"flex items-start gap-3 p-3 rounded-md border bg-muted/30",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx(y,{variant:"outline",className:"text-xs",children:ls[s.action_type]??s.action_type}),s.target_email&&e.jsx("span",{className:"text-sm font-medium truncate",children:s.target_email})]}),s.details&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1 break-all",children:[s.details.role_after&&`Rol: ${s.details.role_after}`,s.details.role_before&&s.details.role_after&&" ← ",s.details.role_before&&`(antes: ${s.details.role_before})`,s.details.participant_roles_added!==void 0&&` Participants: +${s.details.participant_roles_added}, Judges: +${s.details.judge_roles_added}, Profiles: +${s.details.profiles_created}`]})]}),e.jsx("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:(a=(l=s.created_at_bogota)==null?void 0:l.split(".")[0])==null?void 0:a.replace("T"," ")})]},s.id)})}):e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"Sin eventos recientes"})})]})]}),e.jsxs(H,{value:"users",className:"space-y-4 mt-6",children:[e.jsxs(h,{children:[e.jsx(N,{children:e.jsx(w,{className:"text-base",children:"Filtros y búsqueda"})}),e.jsxs(j,{className:"grid md:grid-cols-3 gap-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(es,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Je,{placeholder:"Buscar por nombre o correo…",value:M,onChange:s=>Ce(s.target.value),className:"pl-9"})]}),e.jsxs(J,{value:A,onValueChange:Ae,children:[e.jsx(P,{children:e.jsx(V,{placeholder:"Estado"})}),e.jsxs(q,{children:[e.jsx(i,{value:"all",children:"Todos los estados"}),e.jsx(i,{value:"red",children:"🔴 Crítico"}),e.jsx(i,{value:"yellow",children:"🟡 Revisar"}),e.jsx(i,{value:"blue",children:"🔵 Multi-perfil"}),e.jsx(i,{value:"green",children:"🟢 Sano"}),e.jsx(i,{value:"gray",children:"⚪ Juez inactivo"})]})]}),e.jsxs(J,{value:R,onValueChange:Re,children:[e.jsx(P,{children:e.jsx(V,{placeholder:"Rol"})}),e.jsxs(q,{children:[e.jsx(i,{value:"all",children:"Todos los roles"}),e.jsx(i,{value:"super_admin",children:"Super Admin"}),e.jsx(i,{value:"admin_association",children:"Admin Asociación"}),e.jsx(i,{value:"judge",children:"Juez"}),e.jsx(i,{value:"participant",children:"Participante"}),e.jsx(i,{value:"registration_staff",children:"Staff Registro"})]})]})]})]}),e.jsxs(h,{children:[e.jsx(N,{children:e.jsxs(w,{className:"text-base flex items-center justify-between",children:[e.jsxs("span",{children:["Usuarios (",se,")"]}),e.jsxs("span",{className:"text-xs font-normal text-muted-foreground",children:["Mostrando ",xe," ",xe<se&&`de ${se}`," · Ordenados por criticidad"]})]})}),e.jsx(j,{children:W?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(I,{className:"h-6 w-6 animate-spin text-primary"})}):$.length===0?e.jsx("p",{className:"text-center text-muted-foreground py-8",children:"No hay usuarios que coincidan con los filtros"}):e.jsx("div",{className:"rounded-md border overflow-x-auto",children:e.jsxs(pe,{children:[e.jsx(ge,{children:e.jsxs(O,{children:[e.jsx(m,{className:"w-[110px]",children:"Estado"}),e.jsx(m,{children:"Nombre / Correo"}),e.jsx(m,{children:"Roles"}),e.jsx(m,{children:"Observación"}),e.jsx(m,{children:"Último acceso"}),e.jsx(m,{children:"Creado"})]})}),e.jsx(fe,{children:$.map(s=>{var b,v,E,je;const l=as[s.status],a=l.icon;return e.jsxs(O,{children:[e.jsx(x,{children:e.jsxs(y,{variant:"outline",className:`${l.cls} gap-1`,children:[e.jsx(a,{className:"h-3 w-3"}),l.label]})}),e.jsxs(x,{children:[e.jsx("div",{className:"font-medium text-sm",children:s.full_name||"—"}),e.jsx("div",{className:"text-xs text-muted-foreground",children:s.email})]}),e.jsx(x,{children:e.jsx("div",{className:"flex flex-wrap gap-1",children:(b=s.roles)!=null&&b.length?s.roles.map(ae=>e.jsx(y,{variant:"secondary",className:"text-xs",children:rs[ae]??ae},ae)):e.jsx(y,{variant:"destructive",className:"text-xs",children:"Sin rol"})})}),e.jsx(x,{className:"max-w-md",children:e.jsx("span",{className:"text-xs text-muted-foreground line-clamp-2",children:s.observation})}),e.jsx(x,{className:"text-xs text-muted-foreground whitespace-nowrap",children:s.last_login_bogota?(v=s.last_login_bogota.split(".")[0])==null?void 0:v.replace("T"," "):e.jsx("span",{className:"italic",children:"Nunca"})}),e.jsx(x,{className:"text-xs text-muted-foreground whitespace-nowrap",children:(je=(E=s.created_at_bogota)==null?void 0:E.split(".")[0])==null?void 0:je.replace("T"," ")})]}
6,s.user_id)})})]})})})]})]}),e.jsx(H,{value:"reassignments",className:"space-y-4 mt-6",children:e.jsxs(h,{children:[e.jsxs(N,{children:[e.jsxs(w,{className:"text-base flex items-center gap-2",children:[e.jsx(ss,{className:"h-4 w-4 text-primary"})," Auditoría de asignaciones y reasignaciones"]}),e.jsx(re,{children:"Historial completo de movimientos sobre las asignaciones de resúmenes a jueces. Las reasignaciones sólo son válidas cuando el resumen NO tiene evaluación previa."})]}),e.jsxs(j,{className:"space-y-4",children:[e.jsxs("div",{className:"grid md:grid-cols-3 gap-3",children:[e.jsxs(J,{value:X,onValueChange:Le,children:[e.jsx(P,{children:e.jsx(V,{placeholder:"Tipo de acción"})}),e.jsxs(q,{children:[e.jsx(i,{value:"all",children:"Todas las acciones"}),e.jsx(i,{value:"manual_reassignment",children:"Reasignación manual"}),e.jsx(i,{value:"auto_assignment",children:"Asignación automática"}),e.jsx(i,{value:"manual_assignment",children:"Asignación manual"}),e.jsx(i,{value:"unassignment",children:"Desasignación"}),e.jsx(i,{value:"deletion",children:"Eliminación"}),e.jsx(i,{value:"redistribution",children:"Redistribución"})]})]}),e.jsxs(J,{value:Y,onValueChange:Ie,children:[e.jsx(P,{children:e.jsx(V,{placeholder:"Integridad"})}),e.jsxs(q,{children:[e.jsx(i,{value:"all",children:"Todas"}),e.jsx(i,{value:"violations",children:"⚠️ Sólo violaciones (con evaluación previa)"}),e.jsx(i,{value:"safe",children:"✅ Sólo válidas (sin evaluación)"})]})]}),e.jsxs(k,{variant:"outline",onClick:me,disabled:Q,children:[e.jsx(ve,{className:`h-4 w-4 mr-2 ${Q?"animate-spin":""}`}),"Actualizar"]})]}),(()=>{const s=Ee.filter(a=>!(X!=="all"&&a.action_type!==X||Y==="violations"&&!a.had_evaluation||Y==="safe"&&a.had_evaluation)),l=s.filter(a=>a.had_evaluation&&a.action_type==="manual_reassignment").length;return Q?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(I,{className:"h-6 w-6 animate-spin text-primary"})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid md:grid-cols-3 gap-3",children:[e.jsx(h,{className:"bg-muted/30",children:e.jsxs(j,{className:"pt-4 pb-4",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:"Total movimientos"}),e.jsx("div",{className:"text-2xl font-bold",children:s.length})]})}),e.jsx(h,{className:"bg-emerald-500/5 border-emerald-500/30",children:e.jsxs(j,{className:"pt-4 pb-4",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:"Reasignaciones válidas"}),e.jsx("div",{className:"text-2xl font-bold text-emerald-600",children:s.filter(a=>a.action_type==="manual_reassignment"&&!a.had_evaluation).length})]})}),e.jsx(h,{className:l>0?"bg-red-500/5 border-red-500/40":"bg-emerald-500/5 border-emerald-500/30",children:e.jsxs(j,{className:"pt-4 pb-4",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:"⚠️ Violaciones detectadas"}),e.jsx("div",{className:`text-2xl font-bold ${l>0?"text-red-600":"text-emerald-600"}`,children:l})]})})]}),s.length===0?e.jsx("p",{className:"text-center text-muted-foreground py-8",children:"No hay movimientos de reasignación registrados con los filtros aplicados."}):e.jsx("div",{className:"rounded-md border overflow-x-auto",children:e.jsxs(pe,{children:[e.jsx(ge,{children:e.jsxs(O,{children:[e.jsx(m,{className:"whitespace-nowrap",children:"Fecha"}),e.jsx(m,{children:"Resumen"}),e.jsx(m,{children:"Acción"}),e.jsx(m,{children:"Juez anterior"}),e.jsx(m,{children:"Juez nuevo"}),e.jsx(m,{children:"Integridad"}),e.jsx(m,{children:"Ejecutado por"})]})}),e.jsx(fe,{children:s.map(a=>{var b;return e.jsxs(O,{className:a.had_evaluation&&a.action_type==="manual_reassignment"?"bg-red-500/5":"",children:[e.jsx(x,{className:"text-xs whitespace-nowrap text-muted-foreground",children:new Date(a.created_at).toLocaleString("es-CO",{timeZone:"America/Bogota"})}),e.jsxs(x,{className:"max-w-xs",children:[e.jsx("div",{className:"text-xs font-medium line-clamp-2",title:a.abstract_title??"",children:a.abstract_title??"—"}),e.jsxs("div",{className:"text-[10px] text-muted-foreground font-mono",children:[(b=a.abstract_id)==null?void 0:b.slice(0,8),"…"]})]}),e.jsx(x,{children:e.jsx(y,{variant:"outline",className:"text-xs",children:is[a.action_type]??a.action_type})}),e.jsx(x,{className:"text-xs",children:a.previous_judge_name??e.jsx("span",{className:"italic text-muted-foreground",children:"—"})}),e.jsx(x,{className:"text-xs font-medium",children:a.new_judge_name??e.jsx("span",{className:"italic text-muted-foreground",children:"—"})}),e.jsx(x,{children:a.had_evaluation?e.jsxs(y,{variant:"outline",className:"bg-red-500/15 text-red-700 dark:text-red-400 border-red-500/30 text-xs gap-1",children:[e.jsx(G,{className:"h-3 w-3"}),"Con evaluación (",a.evaluations_count,")"]}):e.jsxs(y,{variant:"outline",className:"bg-emerald-500/15 text-emerald-700 dark:text-emerald-400 border-emerald-500/30 text-xs gap-1",children:[e.jsx(le,{className:"h-3 w-3"}),"Sin evaluación"]})}),e.jsx(x,{className:"text-xs text-muted-foreground",children:a.triggered_by_email??"sistema"})]},a.id)})})]})})]})})()]})]})}
6),e.jsx(H,{value:"history",className:"space-y-4 mt-6",children:e.jsxs(h,{children:[e.jsxs(N,{children:[e.jsxs(w,{className:"text-base flex items-center gap-2",children:[e.jsx(be,{className:"h-4 w-4 text-primary"})," Historial completo"]}),e.jsx(re,{children:"Para revisar el historial completo con filtros avanzados, visita la página de auditoría."})]}),e.jsxs(j,{className:"flex gap-3 flex-wrap",children:[e.jsx(k,{variant:"outline",asChild:!0,children:e.jsx(te,{to:"/admin/auditoria",children:"Auditoría de accesos"})}),e.jsx(k,{variant:"outline",asChild:!0,children:e.jsx(te,{to:"/admin/consistencia-usuarios",children:"Consistencia de usuarios"})})]})]})})]})]}),e.jsx(Oe,{})]})},C=({icon:S,label:d,value:f,loading:g,accent:r="neutral"})=>{const K=r==="blue"?"text-blue-600 bg-blue-500/10":r==="red"?"text-red-600 bg-red-500/10":r==="green"?"text-emerald-600 bg-emerald-500/10":"text-primary bg-primary/10";return e.jsx(h,{children:e.jsxs(j,{className:"pt-4 pb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("div",{className:`p-1.5 rounded ${K}`,children:e.jsx(S,{className:"h-3.5 w-3.5"})}),e.jsx("span",{className:"text-xs text-muted-foreground line-clamp-1",children:d})]}),e.jsx("div",{className:"text-2xl font-bold",children:g?e.jsx(I,{className:"h-5 w-5 animate-spin"}):f??0})]})})},u=({label:S,value:d,highlight:f="neutral"})=>{const g=f==="green"?"text-emerald-600 dark:text-emerald-400 font-semibold":f==="amber"?"text-amber-600 dark:text-amber-400 font-semibold":f==="red"?"text-red-600 dark:text-red-400 font-semibold":f==="blue"?"text-blue-600 dark:text-blue-400 font-semibold":"font-medium";return e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:S}),e.jsx("span",{className:g,children:d})]})};export{Js 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.