import{r as x,j as r,B as v,I as O}from"./index-7T7TTikv.js";import{C as A,a as E,b as L,d as B}from"./card-_ldW-koX.js";import{T as F,a as R,b as y,c as f,d as z,e as p}from"./table-D_B7hhqb.js";import{S as j,a as S,b as T,c as b,d as g}from"./select--i8koVXg.js";import{f as M}from"./formatDistanceToNow-DU8jvZv6.js";import{d as C,f as I}from"./en-US-Cc-9gH5A.js";import{D as Y}from"./download-Btm1n-GQ.js";import{S as H}from"./search-y8VSu0lZ.js";import"./endOfMonth-DmxQbzXi.js";function J(t,e){const a=W(t);let i;if(a.date){const o=V(a.date,2);i=G(o.restDateString,o.year)}if(!i||isNaN(i.getTime()))return new Date(NaN);const d=i.getTime();let l=0,c;if(a.time&&(l=Q(a.time),isNaN(l)))return new Date(NaN);if(a.timezone){if(c=_(a.timezone),isNaN(c))return new Date(NaN)}else{const o=new Date(d+l),u=new Date(0);return u.setFullYear(o.getUTCFullYear(),o.getUTCMonth(),o.getUTCDate()),u.setHours(o.getUTCHours(),o.getUTCMinutes(),o.getUTCSeconds(),o.getUTCMilliseconds()),u}return new Date(d+l+c)}const D={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},Z=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,$=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,P=/^([+-])(\d{2})(?::?(\d{2}))?$/;function W(t){const e={},s=t.split(D.dateTimeDelimiter);let a;if(s.length>2)return e;if(/:/.test(s[0])?a=s[0]:(e.date=s[0],a=s[1],D.timeZoneDelimiter.test(e.date)&&(e.date=t.split(D.timeZoneDelimiter)[0],a=t.substr(e.date.length,t.length))),a){const i=D.timezone.exec(a);i?(e.time=a.replace(i[1],""),e.timezone=i[1]):e.time=a}return e}function V(t,e){const s=new RegExp("^(?:(\\d{4}|[+-]\\d{"+(4+e)+"})|(\\d{2}|[+-]\\d{"+(2+e)+"})$)"),a=t.match(s);if(!a)return{year:NaN,restDateString:""};const i=a[1]?parseInt(a[1]):null,d=a[2]?parseInt(a[2]):null;return{year:d===null?i:d*100,restDateString:t.slice((a[1]||a[2]).length)}}function G(t,e){if(e===null)return new Date(NaN);const s=t.match(Z);if(!s)return new Date(NaN);const a=!!s[4],i=h(s[1]),d=h(s[2])-1,l=h(s[3]),c=h(s[4]),o=h(s[5])-1;if(a)return te(e,c,o)?X(e,c,o):new Date(NaN);{const u=new Date(0);return!K(e,d,l)||!ee(e,i)?new Date(NaN):(u.setUTCFullYear(e,d,Math.max(i,l)),u)}}function h(t){return t?parseInt(t):1}function Q(t){const e=t.match($);if(!e)return NaN;const s=N(e[1]),a=N(e[2]),i=N(e[3]);return re(s,a,i)?s*C+a*I+i*1e3:NaN}function N(t){return t&&parseFloat(t.replace(",","."))||0}function _(t){if(t==="Z")return 0;const e=t.match(P);if(!e)return 0;const s=e[1]==="+"?-1:1,a=parseInt(e[2]),i=e[3]&&parseInt(e[3])||0;return se(a,i)?s*(a*C+i*I):NaN}function X(t,e,s){const a=new Date(0);a.setUTCFullYear(t,0,4);const i=a.getUTCDay()||7,d=(e-1)*7+s+1-i;return a.setUTCDate(a.getUTCDate()+d),a}const q=[31,null,31,30,31,30,31,31,30,31,30,31];function U(t){return t%400===0||t%4===0&&t%100!==0}function K(t,e,s){return e>=0&&e<=11&&s>=1&&s<=(q[e]||(U(t)?29:28))}function ee(t,e){return e>=1&&e<=(U(t)?366:365)}function te(t,e,s){return e>=1&&e<=53&&s>=0&&s<=6}function re(t,e,s){return t===24?e===0&&s===0:s>=0&&s<60&&e>=0&&e<60&&t>=0&&t<25}function se(t,e){return e>=0&&e<=59}const ae=t=>M(J(t),{addSuffix:!0}),w=[{id:"1",action:"CREATE",description:"Created new organization",performedBy:"John Doe",timestamp:new Date(Date.now()-36e5).toISOString(),module:"Organizations",resourceId:"org-123",status:"success"},{id:"2",action:"UPDATE",description:"Updated user permissions",performedBy:"Sarah Johnson",timestamp:new Date(Date.now()-72e5).toISOString(),module:"Users",resourceId:"user-456",status:"success"},{id:"3",action:"DELETE",description:"Deleted document template",performedBy:"Ahmed Mohamed",timestamp:new Date(Date.now()-864e5).toISOString(),module:"Templates",resourceId:"template-789",status:"success"},{id:"4",action:"LOGIN",description:"User login",performedBy:"John Doe",timestamp:new Date(Date.now()-18e5).toISOString(),module:"Authentication",status:"success"},{id:"5",action:"LOGIN",description:"Failed login attempt",performedBy:"Unknown User",timestamp:new Date(Date.now()-12e5).toISOString(),module:"Authentication",status:"failure"},{id:"6",action:"UPDATE",description:"Updated organization settings",performedBy:"Sarah Johnson",timestamp:new Date(Date.now()-72e5).toISOString(),module:"Settings",resourceId:"org-123",status:"success"},{id:"7",action:"CREATE",description:"Created new user account",performedBy:"John Doe",timestamp:new Date(Date.now()-1728e5).toISOString(),module:"Users",resourceId:"user-789",status:"success"},{id:"8",action:"EXPORT",description:"Exported organization data",performedBy:"Ahmed Mohamed",timestamp:new Date(Date.now()-2592e5).toISOString(),module:"Reports",status:"pending"}];function fe(){const[t,e]=x.useState(""),[s,a]=x.useState("all"),[i,d]=x.useState("all"),[l,c]=x.useState(w),o=Array.from(new Set(w.map(n=>n.module))),u=Array.from(new Set(w.map(n=>n.action)));x.useEffect(()=>{let n=[...w];t&&(n=n.filter(m=>m.description.toLowerCase().includes(t.toLowerCase())||m.performedBy.toLowerCase().includes(t.toLowerCase())||m.resourceId&&m.resourceId.toLowerCase().includes(t.toLowerCase()))),s!=="all"&&(n=n.filter(m=>m.module===s)),i!=="all"&&(n=n.filter(m=>m.action===i)),c(n)},[t,s,i]);const k=n=>{switch(n){case"success":return"bg-primary-100 text-primary-800 border-primary-300 dark:bg-primary-900/40 dark:text-primary-300 dark:border-primary-800";case"failure":return"bg-red-100 text-red-800 border-red-300 dark:bg-red-900/40 dark:text-red-300 dark:border-red-800";case"pending":return"bg-yellow-100 text-yellow-800 border-yellow-300 dark:bg-yellow-900/40 dark:text-yellow-300 dark:border-yellow-800";default:return"bg-gray-100 text-gray-800 border-gray-300 dark:bg-gray-800 dark:text-gray-200 dark:border-gray-700"}};return r.jsx("div",{className:"p-6 space-y-6",children:r.jsxs(A,{className:"shadow-lg border-gray-200 dark:border-gray-700",children:[r.jsx(E,{children:r.jsxs("div",{className:"flex justify-between items-center",children:[r.jsx(L,{className:"text-xl font-semibold",children:"Activity Log"}),r.jsxs(v,{variant:"outline",className:"flex items-center gap-2",children:[r.jsx(Y,{className:"w-4 h-4"}),"Export"]})]})}),r.jsxs(B,{children:[r.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[r.jsxs("div",{className:"relative flex-1",children:[r.jsx(H,{className:"absolute left-3 top-3 h-4 w-4 text-gray-400 dark:text-gray-500"}),r.jsx(O,{placeholder:"Search logs...",value:t,onChange:n=>e(n.target.value),className:"pl-10"})]}),r.jsxs(j,{value:s,onValueChange:a,children:[r.jsx(S,{className:"w-[180px]",children:r.jsx(T,{placeholder:"Filter by module"})}),r.jsxs(b,{children:[r.jsx(g,{value:"all",children:"All modules"}),o.map(n=>r.jsx(g,{value:n,children:n},n))]})]}),r.jsxs(j,{value:i,onValueChange:d,children:[r.jsx(S,{className:"w-[180px]",children:r.jsx(T,{placeholder:"Filter by action"})}),r.jsxs(b,{children:[r.jsx(g,{value:"all",children:"All actions"}),u.map(n=>r.jsx(g,{value:n,children:n},n))]})]})]}),r.jsx("div",{className:"rounded-md border border-gray-200 dark:border-gray-700",children:r.jsxs(F,{children:[r.jsx(R,{children:r.jsxs(y,{children:[r.jsx(f,{className:"w-[180px]",children:"Time"}),r.jsx(f,{children:"Action"}),r.jsx(f,{className:"w-[300px]",children:"Description"}),r.jsx(f,{children:"Performed By"}),r.jsx(f,{children:"Module"}),r.jsx(f,{children:"Status"})]})}),r.jsx(z,{children:l.length>0?l.map(n=>r.jsxs(y,{children:[r.jsx(p,{className:"font-medium",children:ae(n.timestamp)}),r.jsx(p,{children:n.action}),r.jsx(p,{children:n.description}),r.jsx(p,{children:n.performedBy}),r.jsx(p,{children:n.module}),r.jsx(p,{children:r.jsx("span",{className:`px-2 py-1 rounded-full text-xs font-semibold ${k(n.status)}`})})]},n.id)):r.jsx(y,{children:r.jsx(p,{colSpan:6,className:"h-24 text-center text-muted-foreground",children:"No activity logs found."})})})]})})]})]})})}export{fe as default};