import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-DE3RlOCf.js";import{s as r}from"./index-BY2WY3ZC.js";import{n as i,t as a}from"./AuditReportFilterBar-NfHzYNkm.js";import{t as o}from"./AuditPagination-CGcMWipj.js";var s=e(t(),1),c=e(n(),1),l={count:0,next:null,previous:null,results:[]},u=[{key:`date_from`,label:`From Date`,type:`date`},{key:`date_to`,label:`To Date`,type:`date`},{key:`username`,label:`Username`,type:`user_select`},{key:`event_type`,label:`Event Type`,type:`select`,options:[{value:`LOGIN_SUCCESS`,label:`Login Success`},{value:`LOGIN_FAILED`,label:`Login Failed`},{value:`LOGOUT`,label:`Logout`},{value:`PASSWORD_CHANGE`,label:`Password Change`},{value:`SESSION_EXPIRED`,label:`Session Expired`}]},{key:`severity`,label:`Severity`,type:`select`,options:[{value:`LOW`,label:`Low`},{value:`MEDIUM`,label:`Medium`},{value:`HIGH`,label:`High`},{value:`CRITICAL`,label:`Critical`}]},{key:`ip_address`,label:`IP Address`,type:`text`}];function d({severity:e}){return(0,c.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-[10px] font-semibold ${e===`LOW`?`bg-emerald-100 text-emerald-700`:e===`MEDIUM`?`bg-amber-100 text-amber-700`:e===`HIGH`?`bg-orange-100 text-orange-700`:e===`CRITICAL`?`bg-rose-100 text-rose-700`:`bg-slate-100 text-slate-600`}`,children:e})}function f(){let{data:e,loading:t,error:n,filters:f,page:p,pageSize:m,applyFilters:h,goToPage:g,changePageSize:_}=i(r.getLoginActivity,l);return(0,s.useEffect)(()=>{h({})},[]),(0,c.jsxs)(`div`,{className:`flex flex-col h-full p-4 gap-2`,children:[(0,c.jsxs)(`div`,{className:`flex items-center gap-1 text-sm border-b pb-2 mb-2`,children:[(0,c.jsx)(`span`,{className:`text-muted-foreground`,children:`Audit`}),(0,c.jsx)(`span`,{className:`text-muted-foreground mx-1`,children:`/`}),(0,c.jsx)(`span`,{className:`font-semibold`,children:`Login Activity`}),e.count>0&&(0,c.jsxs)(`span`,{className:`ml-auto text-muted-foreground text-xs`,children:[e.count,` records`]})]}),(0,c.jsx)(a,{filters:u,onApply:h,onExport:()=>r.exportXlsx(`login-activity`,f),loading:t}),n&&(0,c.jsx)(`div`,{className:`text-sm text-destructive bg-destructive/10 rounded p-3`,children:n}),(0,c.jsx)(`div`,{className:`flex-1 overflow-auto`,children:(0,c.jsxs)(`table`,{className:`w-full text-xs border-collapse`,children:[(0,c.jsx)(`thead`,{className:`sticky top-0 z-10 bg-slate-700 text-white`,children:(0,c.jsx)(`tr`,{children:[`Timestamp`,`Username`,`Event Type`,`Severity`,`Description`,`IP Address`,`Machine`,`Login Time`,`Logout Time`].map(e=>(0,c.jsx)(`th`,{className:`px-3 py-2 text-left border border-slate-600 whitespace-nowrap font-medium`,children:e},e))})}),(0,c.jsxs)(`tbody`,{children:[e.results.length===0&&!t&&(0,c.jsx)(`tr`,{children:(0,c.jsx)(`td`,{colSpan:9,className:`text-center py-8 text-muted-foreground`,children:`No records found`})}),e.results.map((e,t)=>(0,c.jsxs)(`tr`,{className:t%2==0?`bg-white hover:bg-slate-50`:`bg-slate-50 hover:bg-slate-100`,children:[(0,c.jsx)(`td`,{className:`px-3 py-1.5 border border-slate-200 whitespace-nowrap text-muted-foreground`,children:e.timestamp?.slice(0,19).replace(`T`,` `)}),(0,c.jsx)(`td`,{className:`px-3 py-1.5 border border-slate-200 font-medium`,children:e.username}),(0,c.jsx)(`td`,{className:`px-3 py-1.5 border border-slate-200`,children:e.event_type}),(0,c.jsx)(`td`,{className:`px-3 py-1.5 border border-slate-200`,children:(0,c.jsx)(d,{severity:e.severity})}),(0,c.jsx)(`td`,{className:`px-3 py-1.5 border border-slate-200 max-w-[200px] truncate text-muted-foreground`,children:e.description}),(0,c.jsx)(`td`,{className:`px-3 py-1.5 border border-slate-200 font-mono text-muted-foreground`,children:e.ip_address}),(0,c.jsx)(`td`,{className:`px-3 py-1.5 border border-slate-200 text-muted-foreground`,children:e.machine_name||`—`}),(0,c.jsx)(`td`,{className:`px-3 py-1.5 border border-slate-200 whitespace-nowrap text-muted-foreground`,children:e.login_time?.slice(0,19).replace(`T`,` `)||`—`}),(0,c.jsx)(`td`,{className:`px-3 py-1.5 border border-slate-200 whitespace-nowrap text-muted-foreground`,children:e.logout_time?.slice(0,19).replace(`T`,` `)||`—`})]},e.id))]})]})}),(0,c.jsx)(o,{count:e.count,page:p,pageSize:m,totalPages:e.total_pages,onPageChange:g,onPageSizeChange:_})]})}export{f as default};