import{r as e}from"./rolldown-runtime-hePW80VL.js";import{o as t}from"./vendor-forms-yQg41KHz.js";import{t as n}from"./vendor-react-CAGJwf-T.js";import{t as r}from"./activity-BVt56MaT.js";import{n as i,t as a}from"./AuditTimeline-40ZnKzW7.js";import{i as o}from"./auditRtkApi-BKHeu9SP.js";var s=e(t(),1),c=n();function l(){return(0,c.jsx)(`div`,{className:`space-y-4 animate-pulse`,children:[0,1,2,3,4].map(e=>(0,c.jsxs)(`div`,{className:`flex gap-3`,children:[(0,c.jsx)(`div`,{className:`w-6 h-6 rounded-full bg-slate-200 dark:bg-slate-700 flex-shrink-0`}),(0,c.jsxs)(`div`,{className:`flex-1 space-y-1.5 pt-0.5`,children:[(0,c.jsx)(`div`,{className:`h-3 w-3/4 bg-slate-200 dark:bg-slate-700 rounded`}),(0,c.jsx)(`div`,{className:`h-3 w-1/3 bg-slate-100 dark:bg-slate-800 rounded`})]})]},e))})}function u({objectId:e,title:t=`Activity`,pageSize:n=50,showHeader:u=!0}){let[d,f]=(0,s.useState)(null),{data:p,isLoading:m,isError:h}=o({object_id:e,ordering:`-created_at`,page_size:n}),g=p?.results??[];return(0,c.jsxs)(`div`,{children:[u&&(0,c.jsxs)(`div`,{className:`flex items-center gap-2 mb-4`,children:[(0,c.jsx)(r,{className:`w-4 h-4 text-[var(--color-text-muted)]`}),(0,c.jsx)(`h3`,{className:`text-[13px] font-semibold text-[var(--color-text-primary)]`,children:t}),!m&&!h&&p&&(0,c.jsxs)(`span`,{className:`text-[11px] text-[var(--color-text-muted)]`,children:[`(`,p.count??g.length,` events)`]})]}),m&&(0,c.jsx)(l,{}),h&&(0,c.jsx)(`div`,{className:`flex items-center gap-2 px-3 py-2.5 rounded-lg bg-red-50 dark:bg-red-950/40 border border-red-200 dark:border-red-900`,children:(0,c.jsx)(`p`,{className:`text-[13px] text-[var(--color-error)]`,children:`Failed to load activity. Please refresh.`})}),!m&&!h&&g.length===0&&(0,c.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-14 bg-[var(--color-surface)] border border-[var(--color-border)] rounded-xl`,children:[(0,c.jsx)(r,{className:`w-8 h-8 text-[var(--color-text-muted)] mb-3`}),(0,c.jsx)(`p`,{className:`text-[14px] font-medium text-[var(--color-text-primary)]`,children:`No activity recorded yet`}),(0,c.jsx)(`p`,{className:`text-[12px] text-[var(--color-text-muted)] mt-1`,children:`Actions on this record will appear here.`})]}),!m&&!h&&g.length>0&&(0,c.jsx)(a,{events:g,onSelect:e=>f(e)}),(0,c.jsx)(i,{eventId:d,onClose:()=>f(null)})]})}export{u as t};