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-DdTCUUJj.js";import{n as i,t as a}from"./AuditReportFilterBar-BAuwhx1P.js";import{t as o}from"./AuditPagination-CBygZfn3.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:`action`,label:`Action`,type:`select`,options:[{value:`APPROVE`,label:`Approve`},{value:`REJECT`,label:`Reject`},{value:`POST`,label:`Post`},{value:`OTHER`,label:`Other`}]}];function d(){let{data:e,loading:t,error:n,filters:d,page:f,pageSize:p,applyFilters:m,goToPage:h,changePageSize:g}=i(r.getWorkflow,l);return(0,s.useEffect)(()=>{m({})},[]),(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:`Audit Trail — Workflow`}),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:m,onExport:()=>r.exportXlsx(`workflow`,d),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`,`Action`,`Object`,`Reason`,`Source`,`IP Address`].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:7,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:(0,c.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-[10px] font-semibold ${e.action===`APPROVE`?`bg-emerald-100 text-emerald-700`:e.action===`REJECT`?`bg-rose-100 text-rose-700`:`bg-slate-100 text-slate-600`}`,children:e.action})}),(0,c.jsx)(`td`,{className:`px-3 py-1.5 border border-slate-200 max-w-[200px] truncate`,children:e.object_repr}),(0,c.jsx)(`td`,{className:`px-3 py-1.5 border border-slate-200 max-w-[180px] truncate text-muted-foreground`,children:e.reason||`—`}),(0,c.jsx)(`td`,{className:`px-3 py-1.5 border border-slate-200 text-muted-foreground`,children:e.source}),(0,c.jsx)(`td`,{className:`px-3 py-1.5 border border-slate-200 font-mono text-muted-foreground`,children:e.ip_address})]},e.id))]})]})}),(0,c.jsx)(o,{count:e.count,page:f,pageSize:p,totalPages:e.total_pages,onPageChange:h,onPageSizeChange:g})]})}export{d as default};