1import{n as ee,j as e,B as v,Q as L,X as se,r as i,T as F,U as te,A as ae,C as re,a as le,w as ne,t as oe}from"./index-RxDZGo8S.js";import{S as E}from"./skeleton-D7byxEEg.js";import{I as ce}from"./input-CS9s6izM.js";import{S as $,a as H,b as z,c as P,d as D}from"./select-B3f6lReZ.js";import{i as J,s as ie,P as B,a as I,b as R,C as V}from"./popover-BmbZGLdg.js";import{e as Q,t as M,g as k,a as de,b as me,d as xe,A as ue,c as pe,f as he,u as ge,h as fe,i as je}from"./useActivities-zEqKlSJ4.js";import{S as be}from"./search-Dss-hsDb.js";import{U as Ne}from"./user-Bt8OpLg1.js";import{F as ve}from"./filter-C3YzNlq7.js";import{C as O}from"./calendar-DWLwoYri.js";import{f}from"./format-DuJJlbci.js";import{e as w}from"./es-DhgJzuV8.js";import{T as we}from"./trash-2-DXjGIb-t.js";import{C as T}from"./clock-B-vpET2t.js";import{B as q}from"./badge-Kwp9j7fd.js";import{S as ye}from"./smartphone-SUciJ9ja.js";import{M as Ce}from"./monitor-BptUoSbb.js";import{D as Se}from"./download-C_n9HF-k.js";import"./index-BnR4gmtC.js";import"./index-Da3vg3Bj.js";import"./chevron-up-DbNI7lUd.js";import"./check-dsJNWiFz.js";import"./differenceInCalendarMonths-DeMmhVqA.js";import"./startOfMonth-CgcY1Hmt.js";import"./addMonths-CtX9b_RZ.js";import"./endOfDay-CVKAevRd.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 Ae=ee("PenLine",[["path",{d:"M12 20h9",key:"t2du7b"}],["path",{d:"M16.376 3.622a1 1 0 0 1 3.002 3.002L7.368 18.635a2 2 0 0 1-.855.506l-2.872.838a.5.5 0 0 1-.62-.62l.838-2.872a2 2 0 0 1 .506-.854z",key:"1ykcvy"}]]);function De(s){return J(s,Q(s))}function _e(s){return J(s,ie(Q(s),1))}const ke=({searchText:s,onSearchChange:n,selectedUser:r,onUserChange:t,selectedActionType:l,onActionTypeChange:d,dateFrom:a,onDateFromChange:j,dateTo:m,onDateToChange:y,users:b,actionTypes:_,onClearFilters:g,hasActiveFilters:C})=>e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(be,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),e.jsx(ce,{placeholder:"Buscar en actividades...",value:s,onChange:c=>n(c.target.value),className:"pl-9 bg-background/50 border-border/50"})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs($,{value:r,onValueChange:t,children:[e.jsxs(H,{
6className:"w-[160px] h-9 text-xs bg-background/50",children:[e.jsx(Ne,{className:"w-3 h-3 mr-1.5 text-muted-foreground"}),e.jsx(z,{placeholder:"Usuario"})]}),e.jsxs(P,{children:[e.jsx(D,{value:"all",children:"Todos"}),b.map(c=>e.jsx(D,{value:c.id,className:"text-xs",children:c.name},c.id))]})]}),e.jsxs($,{value:l,onValueChange:d,children:[e.jsxs(H,{className:"w-[160px] h-9 text-xs bg-background/50",children:[e.jsx(ve,{className:"w-3 h-3 mr-1.5 text-muted-foreground"}),e.jsx(z,{placeholder:"Acción"})]}),e.jsxs(P,{children:[e.jsx(D,{value:"all",children:"Todas"}),_.map(c=>e.jsx(D,{value:c,className:"text-xs",children:M(c)},c))]})]}),e.jsxs(B,{children:[e.jsx(I,{asChild:!0,children:e.jsxs(v,{variant:"outline",size:"sm",className:L("h-9 text-xs gap-1.5",a&&"text-primary border-primary/30"),children:[e.jsx(O,{className:"w-3 h-3"}),a?f(a,"dd/MM/yy",{locale:w}):"Desde"]})}),e.jsx(R,{className:"w-auto p-0",align:"start",children:e.jsx(V,{mode:"single",selected:a,onSelect:j,initialFocus:!0,className:"p-3 pointer-events-auto"})})]}),e.jsxs(B,{children:[e.jsx(I,{asChild:!0,children:e.jsxs(v,{variant:"outline",size:"sm",className:L("h-9 text-xs gap-1.5",m&&"text-primary border-primary/30"),children:[e.jsx(O,{className:"w-3 h-3"}),m?f(m,"dd/MM/yy",{locale:w}):"Hasta"]})}),e.jsx(R,{className:"w-auto p-0",align:"start",children:e.jsx(V,{mode:"single",selected:m,onSelect:y,initialFocus:!0,className:"p-3 pointer-events-auto"})})]}),C&&e.jsxs(v,{variant:"ghost",size:"sm",onClick:g,className:"h-9 text-xs gap-1 text-muted-foreground hover:text-destructive",children:[e.jsx(se,{className:"w-3 h-3"}),"Limpiar"]})]})]}),Te=({activities:s,totalUsers:n})=>{const r=i.useMemo(()=>{const l=new Date,d=new Date(l.getTime()-24*60*60*1e3);return{total:s.length,creates:s.filter(a=>a.action_type.includes("create")).length,updates:s.filter(a=>a.action_type.includes("update")||a.action_type.includes("stock")).length,deletes:s.filter(a=>a.action_type.includes("delete")).length,last24h:s.filter(a=>new Date(a.created_at)>=d).length}},[s]),t=[{label:"Total",value:r.total,icon:F,color:"text-primary"},{label:"Creaciones",value:r.creates,icon:F,color:"text-emerald-600"},{label:"Ediciones",value:r.updates,icon:Ae,color:"text-blue-600"},{label:"Eliminaciones",value:r.deletes,icon:we,color:"text-red-500"},{label:"Usuarios",value:n,icon:te,color:"text-violet-600"},{label:"Ãltimas 24h",value:r.last24h,icon:T,color:"text-amber-600"}];return e.jsx("div",{className:"grid grid-cols-3 md:grid-cols-6 gap-2",children:t.map(l=>e.jsxs("div",{className:"flex flex-col items-center p-2.5 rounded-xl bg-muted/40 border border-border/40",children:[e.jsx(l.icon,{className:`w-4 h-4 ${l.color} mb-1`}),e.jsx("span",{className:`text-lg font-bold ${l.color}`,children:l.value}),e.jsx("span",{className:"text-[10px] text-muted-foreground leading-tight",children:l.label})]},l.label))})},Me=s=>{if(!s||typeof s!="object")return null;const n=Object.entries(s).filter(([r,t])=>t!=null&&t!==""&&r!=="timestamp"&&r!=="time");return n.length===0?null:e.jsx("div",{className:"mt-2 p-2.5 bg-muted/30 rounded-lg border border-border/30 text-xs",children:e.jsxs("div",{className:"space-y-1",children:[n.slice(0,4).map(([r,t])=>e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsxs("span",{className:"font-medium text-muted-foreground whitespace-nowrap min-w-[80px]",children:[r.replace(/_/g," ").replace(/\b\w/g,l=>l.toUpperCase()),":"]}),e.jsx("span",{className:"text-foreground/80 font-mono break-all",children:typeof t=="object"?JSON.stringify(t):String(t)})]},r)),n.length>4&&e.jsxs("span",{className:"text-muted-foreground text-[10px]",children:["+",n.length-4," más"]})]})})},Ue=s=>De(s)?"Hoy":_e(s)?"Ayer":f(s,"EEEE d 'de' MMMM",{locale:w}),Le=({activities:s})=>{const n=i.useMemo(()=>{const r=[];let t="";return s.forEach(l=>{const d=new Date(l.created_at),a=Ue(d);a!==t&&(t=a,r.push({label:a,items:[]})),r[r.length-1].items.push(l)}),r},[s]);return s.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-muted-foreground",children:[e.jsx(T,{className:"w-12 h-12 mb-3 opacity-20"}),e.jsx("p",{className:"text-sm",children:"No hay actividades para mostrar"})]}):e.jsx("div",{className:"space-y-6",children:n.map(r=>e.jsxs("div",{children:[e.jsxs("div",{className:"sticky top-0 z-10 flex items-center gap-3 mb-3 py-1.5 bg-background/95 backdrop-blur-sm",children:[e.jsx("div",{className:"h-px flex-1 bg-border/60"}),e.jsx("span",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wider px-2",children:r.label}),e.jsx("div",{className:"h-px flex-1 bg-border/60"})]}),e.jsxs("div",{className:"relative pl-6 space-y-0",children:[e.jsx("div",{className:"absolute left-[11px] top-2 bottom-2 w-px bg-border/60"}),r.items.map(t=>{const l=k(t),d=de(l),a=me(t.action_type),j=xe(t.action_type);return e.jsxs("div",{className:"relative pb-4 group",children:[e.jsx("div",{className:`absolute -left-6 top-1.5 w-[10px] h-[10px] rounded-full ${a.dot} ring-2 ring-background z-10 group-hover:scale-125 transition-transform`}),e.jsx("div",{className:"p-3 rounded-xl border border-border/40 hover:border-primary/20 bg-card/50 hover:bg-accent/30 transition-all duration-200",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(ue,{className:"w-8 h-8 ring-1 ring-border/50 shrink-0",children:e.jsx(pe,{className:`${a.bg} ${a.text} text-[10px] font-bold`,children:d})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap mb-0.5",children:[e.jsx("span",{className:"text-sm font-semibold truncate",children:l}),e.jsxs(q,{className:`${a.bg} ${a.text} ${a.border} text-[10px] px-1.5 py-0 font-medium`,variant:"outline",children:[e.jsx("span",{className:"mr-0.5",children:j}),M(t.action_type)]}),t.source&&t.source!=="web"&&e.jsxs(q,{variant:"secondary",className:"text-[10px] px-1.5 py-0 gap-0.5",children:[e.jsx(ye,{className:"w-2.5 h-2.5"}),t.source==="telegram"?"Telegram":t.source]}),t.source==="web"&&e.jsx(Ce,{className:"w-3 h-3 text-muted-foreground
6/40"})]}),e.jsx("p",{className:"text-xs text-foreground/80 leading-relaxed",children:t.action_description}),Me(t.details),e.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] text-muted-foreground mt-2",children:[e.jsx(T,{className:"w-3 h-3"}),e.jsx("span",{children:f(new Date(t.created_at),"HH:mm",{locale:w})}),e.jsx("span",{className:"text-muted-foreground/40",children:"â¢"}),e.jsx("span",{children:he(new Date(t.created_at),{addSuffix:!0,locale:w})})]})]})]})})]},t.id)})]})]},r.label))})},G=50,ns=()=>{const[s,n]=i.useState(""),[r,t]=i.useState("all"),[l,d]=i.useState("all"),[a,j]=i.useState(),[m,y]=i.useState(),[b,_]=i.useState(G),{data:g,isLoading:C}=ge({limit:1e3}),c=fe(g),X=je(g),U=s!==""||r!=="all"||l!=="all"||!!a||!!m,Y=i.useCallback(()=>{n(""),t("all"),d("all"),j(void 0),y(void 0)},[]),x=i.useMemo(()=>{if(!g)return[];const p=s.toLowerCase();return g.filter(o=>{var S,N;if(r!=="all"&&o.user_id!==r||l!=="all"&&o.action_type!==l||a&&new Date(o.created_at)<a)return!1;if(m){const h=new Date(o.created_at),u=new Date(m);if(u.setHours(23,59,59,999),h>u)return!1}if(s){const h=((S=o.action_description)==null?void 0:S.toLowerCase())||"",u=((N=o.action_type)==null?void 0:N.toLowerCase())||"",A=k(o).toLowerCase();if(!h.includes(p)&&!u.includes(p)&&!A.includes(p))return!1}return!0})},[g,r,l,a,m,s]),Z=i.useMemo(()=>x.slice(0,b),[x,b]),K=b<x.length,W=i.useCallback(()=>{if(!x.length)return;const p=`Fecha,Hora,Usuario,Tipo,Descripción,Fuente 7`,o=x.map(u=>{const A=new Date(u.created_at);return[f(A,"dd/MM/yyyy"),f(A,"HH:mm:ss"),`"${k(u)}"`,`"${M(u.action_type)}"`,`"${(u.action_description||"").replace(/"/g,'""')}"`,u.source||"web"].join(",")}).join(` 8`),S=new Blob(["\uFEFF"+p+o],{type:"text/csv;charset=utf-8;"}),N=URL.createObjectURL(S),h=document.createElement("a");h.href=N,h.download=`actividad_${f(new Date,"yyyyMMdd_HHmm")}.csv`,h.click(),URL.revokeObjectURL(N)},[x]);return e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsxs("div",{className:"w-full p-4 pb-24 max-w-4xl mx-auto space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2.5 bg-primary/10 rounded-xl",children:e.jsx(ae,{className:"w-6 h-6 text-primary"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-bold",children:"Registro de Actividad"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[x.length," actividades",U&&" (filtradas)"]})]})]}),e.jsxs(v,{variant:"outline",size:"sm",onClick:W,disabled:!x.length,className:"gap-1.5 text-xs",children:[e.jsx(Se,{className:"w-3.5 h-3.5"}),"CSV"]})]}),e.jsx(re,{className:"border-border/40",children:e.jsx(le,{className:"p-4",children:e.jsx(ke,{searchText:s,onSearchChange:n,selectedUser:r,onUserChange:t,selectedActionType:l,onActionTypeChange:d,dateFrom:a,onDateFromChange:j,dateTo:m,onDateToChange:y,users:c,actionTypes:X,onClearFilters:Y,hasActiveFilters:U})})}),C?e.jsx("div",{className:"grid grid-cols-3 md:grid-cols-6 gap-2",children:Array.from({length:6}).map((p,o)=>e.jsx(E,{className:"h-20 rounded-xl"},o))}):e.jsx(Te,{activities:x,totalUsers:c.length}),C?e.jsx("div",{className:"space-y-3",children:Array.from({length:5}).map((p,o)=>e.jsx(E,{className:"h-24 rounded-xl"},o))}):e.jsxs(e.Fragment,{children:[e.jsx(Le,{activities:Z}),K&&e.jsx("div",{className:"flex justify-center pt-2",children:e.jsxs(v,{variant:"outline",size:"sm",onClick:()=>_(p=>p+G),className:"gap-1.5",children:[e.jsx(ne,{className:"w-4 h-4"}),"Cargar más (",x.length-b," restantes)"]})})]})]}),e.jsx(oe,{})]})};export{ns 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.