import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{I as t,f as n,mt as r,p as i,x as a}from"./antd-NNbrPHoG.js";import{P as o}from"./antd-icons-BW4cpGcx.js";import{t as s}from"./i18n-BuHCC44e.js";import{n as c}from"./api-BW0YTlHd.js";import{t as l}from"./react-vendor-nIJYBVRh.js";import{n as u}from"./AuthContext-Bb7tFn4r.js";import{t as d}from"./ConsolePage-BgvAIq9_.js";import{n as f,t as p}from"./useInitialTableLoading-adK-LcHZ.js";var m=e(r(),1),h=l(),g=50;function _(){let{t:e}=s(),{isAdmin:r,authRequired:l}=u(),[_,v]=(0,m.useState)([]),[y,b]=(0,m.useState)(0),[x,S]=(0,m.useState)(!0),[C,w]=(0,m.useState)(1),T=p(x),E=(C-1)*g,D=(0,m.useCallback)(async()=>{if(l){S(!0);try{let{items:e,total:t}=await c.listAuditLogs({limit:g,offset:E});v(e),b(t)}catch(e){a.error(e instanceof Error?e.message:String(e))}finally{S(!1)}}},[l,E]);(0,m.useEffect)(()=>{D()},[D]);let O=e=>e>=200&&e<300?`green`:e>=400&&e<500?`orange`:e>=500?`red`:`default`;return(0,h.jsx)(d,{title:e(`audit.title`),subtitle:e(r?`audit.hintAdmin`:`audit.hintSelf`),icon:(0,h.jsx)(o,{}),children:(0,h.jsx)(t,{size:`small`,children:(0,h.jsx)(i,{rowKey:e=>`${e.id}-${e.ts_ms}`,loading:T,dataSource:_,pagination:{pageSize:g,current:C,total:y,showSizeChanger:!1,onChange:e=>w(e),showTotal:(t,n)=>e(`common.showTotalRange`,{start:n[0],end:n[1],total:t})},scroll:{x:900},columns:[{title:e(`audit.colTime`),dataIndex:`ts_ms`,key:`ts_ms`,width:200,render:e=>f(e)},{title:e(`audit.colUser`),dataIndex:`username`,key:`username`,width:140,ellipsis:!0},{title:e(`audit.colRole`),dataIndex:`role`,key:`role`,width:100,render:e=>(0,h.jsx)(n,{children:e})},{title:e(`audit.colMethod`),dataIndex:`method`,key:`method`,width:80},{title:e(`audit.colPath`),dataIndex:`path`,key:`path`,ellipsis:!0},{title:e(`audit.colStatus`),dataIndex:`status`,key:`status`,width:90,render:e=>(0,h.jsx)(n,{color:O(e),children:e})}]})})})}export{_ as default};