1import{r as n,a6 as m,j as t,x as j,H as u,S,c9 as w}from"./index-BACUqBz4.js";import{E as _}from"./EmptyState-CRi2jFBw.js";const A={register:"Account created",email_verified:"Email verified",login:"Login",role_change:"Role changed",invite_user:"User invited",resend_invite:"Invite resent",cancel_invite:"Invite cancelled",ai_toggle:"AI toggled",ai_access_requested:"AI access requested",branding_update:"Branding updated",branding_logo_upload:"Logo uploaded",branding_logo_delete:"Logo removed",first_dashboard_viewed:"First dashboard viewed"},g=r=>A[r]||(r||"").replace(/_/g," ").replace(/\b\w/g,l=>l.toUpperCase());function L(r){return r==="login"?{bg:"#dbeafe",fg:"#1d4ed8"}:r&&(r.includes("delete")||r.includes("cancel"))?{bg:"#fee2e2",fg:"#dc2626"}:r&&(r.includes("role")||r.includes("invite"))?{bg:"#fef3c7",fg:"#92400e"}:{bg:"#f0fdf4",fg:"#166534"}}function E(){const[r,l]=n.useState([]),[s,f]=n.useState(""),[o,x]=n.useState(""),[h,v]=n.useState(!0),[p,b]=n.useState("");n.useEffect(()=>{m.auditLog().then(e=>l(Array.isArray(e.data)?e.data:[])).catch(e=>{var a,i,d;b(((a=e.response)==null?void 0:a.status)===403?"Only owners and admins can view the audit log.":((d=(i=e.response)==null?void 0:i.data)==null?void 0:d.detail)||"Could not load the audit log.")}).finally(()=>v(!1))},[]);const y=[...new Set(r.map(e=>e.action).filter(Boolean))],c=r.filter(e=>{const a=s.toLowerCase(),i=!a||(e.action||"").toLowerCase().includes(a)||g(e.action).toLowerCase().includes(a)||(e.detail||"").toLowerCase().includes(a),d=!o||e.action===o;return i&&d});return t.jsxs(j,{children:[t.jsx(u,{title:t.jsxs(t.Fragment,{children:["Audit ",t.jsx(u.Accent,{children:"Log"})]}),description:"Every action in your workspace â real events, for compliance and security"}),t.jsxs("div",{style:{display:"flex",gap:12,marginBottom:20,flexWrap:"wrap"},children:[t.jsx("input",{value:s,onChange:e=>f(e.target.value),placeholder:"Search by action or detail...",style:{flex:1,padding:"9px 12px",border:"1px solid var(--border-default)",borderRadius:8,fontSize:"0.9rem"}}),t.jsxs("select",{value:o,onChange:e=>x(e.target.value),style:{padding:"9px 12px",border:"1px solid var(--border-default)",borderRadius:8,fontSize:"0.9rem"},children:[t.jsx("option",{value:"",children:"All Actions"}),y.map(e=>t.jsx("option",{value:e,children:g(e)},e))]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:"0.875rem",color:"var(--fg-tertiary)",padding:"0 12px",background:"var(--bg-sunken)",borderRadius:8},children:[c.length," events"]})]}),p?t.jsx("div",{style:{background:"#fee2e2",color:"#991b1b",padding:16,borderRadius:10},children:p}):h?t.jsx("div",{"aria-busy":"true","aria-label":"Loading audit log",children:[0,1,2,3,4,5].map(e=>t.jsx(S,{height:40,radius:8,style:{display:"block",marginBottom:"var(--space-2)"}},e))}):t.jsxs("div",{style:{background:"var(--bg-raised)",borderRadius:12,boxShadow:"var(--elev-1)",overflow:"hidden"},children:[t.jsx("div",{style:{overflowX:"auto"},children:t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:"0.85rem"},children:[t.jsx("thead",{children:t.jsx("tr",{style:{background:"var(--bg-sunken)"}
1,children:["Timestamp","Action","Detail"].map(e=>t.jsx("th",{style:{padding:"12px 14px",textAlign:"left",fontWeight:600,color:"var(--fg-secondary)",borderBottom:"1px solid var(--border-default)",whiteSpace:"nowrap"},children:e},e))})}),t.jsx("tbody",{children:c.slice(0,500).map((e,a)=>{const i=L(e.action);return t.jsxs("tr",{style:{background:a%2===0?"#fff":"#fafafa"},children:[t.jsx("td",{style:{padding:"10px 14px",color:"var(--fg-tertiary)",whiteSpace:"nowrap",fontFamily:"monospace",fontSize:"0.8rem"},children:e.created_at?new Date(e.created_at).toLocaleString():"â"}),t.jsx("td",{style:{padding:"10px 14px"},children:t.jsx("span",{style:{padding:"3px 10px",borderRadius:12,fontSize:"0.78rem",fontWeight:600,background:i.bg,color:i.fg},children:g(e.action)})}),t.jsx("td",{style:{padding:"10px 14px",color:"var(--fg-secondary)",fontSize:"0.82rem"},children:e.detail||"â"})]},e.id||a)})})]})}),c.length===0&&t.jsx(_,{icon:w,title:s||o?"No events match that filter":"No audit events yet",description:s||o?"Try a different search term, or clear the action filter.":"Every sign-in, export, share and settings change in this workspace will be recorded here."})]})]})}export{E 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.