1import{r as l,j as e,O as w,Q as N,T as v,u as b,E as S,m as C,G as E,S as p,s as f}from"../index.js";import{S as k}from"./index-44bf2282.js";function L({log:t}){const[s,i]=l.useState(!1),[c,n]=l.useState(null),[r,a]=l.useState(!1);l.useEffect(()=>{function x(){var o;try{let m=JSON.parse(t.metadata);a(((o=Object.keys(m))==null?void 0:o.length)>0),n(m)}catch{}}x()},[t.metadata]);const d=()=>{t.metadata!=="{}"&&i(!s)};return e.jsxs(e.Fragment,{children:[e.jsxs("tr",{onClick:d,className:`bg-transparent text-white text-opacity-80 text-xs font-medium border-b border-white/10 h-10 ${r?"cursor-pointer hover:bg-white/5":""}`,children:[e.jsx(T,{event:t.event}),e.jsx("td",{className:"px-6 border-transparent transform transition-transform duration-200",children:t.user.username}),e.jsx("td",{className:"px-6 border-transparent transform transition-transform duration-200",children:t.occurredAt}),r&&e.jsx("div",{className:"mt-1",children:s?e.jsxs("td",{className:"px-2 gap-x-1 flex items-center justify-center transform transition-transform duration-200",children:[e.jsx(w,{weight:"bold",size:20}),e.jsx("p",{className:"text-xs text-white/50 w-[20px]",children:"hide"})]}):e.jsxs("td",{className:"px-2 gap-x-1 flex items-center justify-center transform transition-transform duration-200",children:[e.jsx(N,{weight:"bold",size:20}),e.jsx("p",{className:"text-xs text-white/50 w-[20px]",children:"show"})]})})]}),e.jsx(M,{metadata:c,expanded:s})]})}const M=({metadata:t,expanded:s=!1})=>!t||!s?null:e.jsxs("tr",{className:"bg-theme-bg-primary",children:[e.jsx("td",{colSpan:"2",className:"px-6 py-4 font-medium text-theme-text-primary rounded-l-2xl",children:"Event Metadata"}),e.jsx("td",{colSpan:"4",className:"px-6 py-4 rounded-r-2xl",children:e.jsx("div",{className:"w-full rounded-lg bg-theme-bg-secondary p-2 text-white shadow-sm border-white/10 border bg-opacity-10",children:e.jsx("pre",{className:"overflow-scroll",children:JSON.stringify(t,null,2)})})})]}),T=({event:t})=>{let s={bg:"bg-sky-600/20",text:"text-sky-400 light:text-sky-800"};return t.includes("update")&&(s={bg:"bg-yellow-600/20",text:"text-yellow-400 light:text-yellow-800"}),(t.includes("failed_")||t.includes("deleted"))&&(s={bg:"bg-red-600/20",text:"text-red-400 light:text-red-800"}),t==="login_event"&&(s={bg:"bg-green-600/20",text:"text-green-400 light:text-green-800"}),e.jsx("td",{className:"px-6 py-2 font-medium whitespace-nowrap text-white flex items-center",children:e.jsx("span",{className:`rounded-full ${s.bg} px-2 py-0.5 text-xs font-medium ${s.text} shadow-sm`,children:t})})};function _(){const t=v(),[s,i]=l.useState(!0),[c,n]=l.useState([]),[r,a]=l.useState(Number(t.get("offset")||0)),[d,x]=l.useState(!1),{t:o}=b();l.useEffect(()=>{async function h(){const{logs:u,hasPages:y=!1}=await p.eventLogs(r);n(u),x(y),i(!1)}h()},[r]);const m=async()=>{if(!window.confirm("Are you sure you want to clear all event logs? This action is irreversible."))return;const{success:h,error:u}=await p.clearEventLogs();h?(f("Event logs cleared successfully.","success"),n([]),x(!1),a(0)):f(`Failed to clear logs: ${u}`,"error")},g=()=>{a(Math.max(r-1,0))},j=()=>{a(r+1)};return e.jsxs("div",{className:"w-screen h-screen overflow-hidden bg-theme-bg-container flex",children:[e.jsx(S,{}),e.jsx("div",{style:{height:C?"100%":"calc(100% - 32px)"},className:"relative md:ml-[2px] md:mr-[16px] md:my-[16px] md:rounded-[16px] bg-theme-bg-secondary w-full h-full overflow-y-scroll p-4 md:p-0",children:e.jsxs("div",{className:"flex flex-col w-full px-1 md:pl-6 md:pr-[50px] md:py-6 py-16",children:[e.jsxs("div",{className:"w-full flex flex-col gap-y-1 pb-6 border-white/10 border-b-2",children:[e.jsx("div",{className:"flex gap-x-4 items-center",children:e.jsx("p",{className:"text-lg leading-6 font-bold text-theme-text-primary",children:o("event.title")})}),e.jsx("p",{className:"text-xs leading-[18px] font-base text-theme-text-secondary mt-2",children:o("event.description")})]}),e.jsx("div",{className:"w-full justify-end flex",children:e.jsx(E,{onClick:m,className:"mt-3 mr-0 mb-4 md:-mb-14 z-10",children:o("event.clear")})}),e.jsx("div",{className:"overflow-x-auto mt-6",children:e.jsx(A,{loading:s,logs:c,offset:r,canNext:d,handleNext:j,handlePrevious:g})})]})})]})}function A({loading:t,logs:s,offset:i,canNext:c,handleNext:n,handlePrevious:r}){const{t:a}=b();return t?e.jsx(k,{height:"80vh",width:"100%",highlightColor:"var(--theme-bg
1-primary)",baseColor:"var(--theme-bg-secondary)",count:1,className:"w-full p-4 rounded-b-2xl rounded-tr-2xl rounded-tl-sm",containerClassName:"flex w-full"}):e.jsxs(e.Fragment,{children:[e.jsxs("table",{className:"w-full text-xs text-left rounded-lg min-w-[640px] border-spacing-0",children:[e.jsx("thead",{className:"text-theme-text-secondary text-xs leading-[18px] font-bold uppercase border-white/10 border-b",children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",className:"px-6 py-3 rounded-tl-lg",children:a("event.table.type")}),e.jsx("th",{scope:"col",className:"px-6 py-3",children:a("event.table.user")}),e.jsx("th",{scope:"col",className:"px-6 py-3",children:a("event.table.occurred")}),e.jsx("th",{scope:"col",className:"px-6 py-3 rounded-tr-lg",children:" "})]})}),e.jsx("tbody",{children:!!s&&s.map(d=>e.jsx(L,{log:d},d.id))})]}),e.jsxs("div",{className:"flex w-full justify-between items-center mt-6",children:[e.jsx("button",{onClick:r,className:"px-4 py-2 rounded-lg border border-slate-200 text-slate-200 light:text-theme-text-secondary light:border-theme-sidebar-border text-sm items-center flex gap-x-2 hover:bg-slate-200 hover:text-slate-800 disabled:invisible",disabled:i===0,children:a("common.previous")}),e.jsx("button",{onClick:n,className:"px-4 py-2 rounded-lg border border-slate-200 text-slate-200 light:text-theme-text-secondary light:border-theme-sidebar-border text-sm items-center flex gap-x-2 hover:bg-slate-200 hover:text-slate-800 disabled:invisible",disabled:!c,children:a("common.next")})]})]})}export{_ 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.