import{iv as u,iP as m,fH as t,iY as j,iF as h,C as f,fI as y,A as v,bV as n,aD as c,bU as C,gZ as D,a$ as L,cy as A,jD as k,g as b}from"./strapi-ye6TfKul.js";import{W as d}from"./WidgetHelpers-DvKGKEsV.js";import{R as E}from"./RelativeTime-DGWrj7A0.js";import{b as M,g as R}from"./getActionTypesDefaultMessages-DP4LeCgl.js";const S=k(E)`
  display: inline-block;

  &::first-letter {
    text-transform: uppercase;
  }
`,w=({items:a})=>{const{formatMessage:i}=u(),{trackUsage:s}=j(),l=h(),r=e=>`/settings/audit-logs?pageSize=${b}&page=1&sort=date:DESC&id=${e.id}`,p=e=>()=>{s("willOpenAuditLogDetailsFromHome");const o=r(e);l(o)};return t.jsx(f,{colCount:4,rowCount:a?.length??0,children:t.jsx(y,{children:a?.map(e=>{const o=i({id:`Settings.permissions.auditLogs.${e.action}`,defaultMessage:R(e.action)},{model:e.payload.model??""}),g=e.user?.displayName??"-";return t.jsxs(v,{onClick:p(e),cursor:"pointer",children:[t.jsx(n,{children:t.jsx(c,{title:o,variant:"omega",textColor:"neutral800",children:o})}),t.jsx(n,{children:t.jsx(c,{variant:"omega",textColor:"neutral800",children:t.jsx(S,{timestamp:new Date(e.date)})})}),t.jsx(n,{children:t.jsx(c,{title:g,variant:"omega",textColor:"neutral800",children:g})}),t.jsx(n,{onClick:x=>x.stopPropagation(),children:t.jsx(C,{display:"inline-block",children:t.jsx(D,{tag:L,to:r(e),onClick:()=>s("willOpenAuditLogDetailsFromHome"),label:i({id:"global.details",defaultMessage:"Details"}),variant:"ghost",children:t.jsx(A,{})})})})]},`lastActivity_auditLog_${e.id}`)})})})},N=()=>{const{formatMessage:a}=u(),[{query:i}]=m(),{data:s,isLoading:l,error:r}=M({...i,page:1,pageSize:4,sort:"date:DESC"},{refetchOnMountOrArgChange:!0});return l?t.jsx(d.Loading,{}):r||!s?.results?t.jsx(d.Error,{}):s.results.length===0?t.jsx(d.NoData,{children:a({id:"widget.last-activity.no-activity",defaultMessage:"No activity"})}):t.jsx(w,{items:s.results??[]})};export{N as AuditLogsWidget};
