import{r as i,j as e,I as l,z as D,Q as N,L as S,q as T}from"./index-Dbk1Plmn.js";import{u as w}from"./use_timeline-DHzluypB.js";import{P as A}from"./page_shell-C0CL85dt.js";import{D as C}from"./data-table-B-cqS3KC.js";import{E as P}from"./entity_link-qYsgSBpl.js";import{A as b}from"./agent_badge-BZd6ZAh5.js";import{u as k}from"./agent_filter-DUlgHUAb.js";import{O as I}from"./pagination-BoJeck8D.js";import{s as Q,a as R}from"./query_loading-BFETHugg.js";import{Q as O}from"./query_refresh_indicator-1_XqkpX1.js";import"./timeline-B_D7qsoU.js";import"./chevron-right-L2MnFoxW.js";const d=25;function M(){var u;const[c,h]=i.useState(""),[m,f]=i.useState(""),[p,v]=i.useState(""),[o,n]=i.useState(0),s=w({start_date:c||void 0,end_date:m||void 0,event_type:p||void 0,limit:d,offset:o}),j=[{header:"Event Type",accessorKey:"event_type",cell:({row:t})=>e.jsx(S,{to:`/timeline/${encodeURIComponent(t.original.id)}`,className:"font-medium text-primary hover:underline",children:t.original.event_type||"event"})},{header:"Timestamp",accessorKey:"event_timestamp",cell:({getValue:t})=>T(t())},{header:"Entities",id:"entities",cell:({row:t})=>{const a=t.original,r=a.entity_id?[a.entity_id]:a.entity_ids??[];return r.length?e.jsxs("div",{className:"flex flex-wrap gap-1",children:[r.slice(0,3).map(g=>e.jsx(P,{id:g},g)),r.length>3&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["+",r.length-3]})]}):e.jsx("span",{className:"text-muted-foreground",children:"—"})}},{header:"Properties",id:"prop_count",cell:({row:t})=>{const a=t.original.properties;return a?`${Object.keys(a).length} props`:"—"}},{header:"Agent",id:"agent",cell:({row:t})=>e.jsx(b,{provenance:t.original.provenance??null})}],x=((u=s.data)==null?void 0:u.events)??[],{filterRows:y,AgentFilterControl:E}=k(x),_=y(x);return e.jsxs(A,{title:"Timeline",description:"Chronological event stream",actions:R(s)?e.jsx(O,{}):void 0,children:[e.jsxs("div",{className:"flex flex-wrap items-end gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:"Start Date"}),e.jsx(l,{type:"date",value:c,onChange:t=>{h(t.target.value),n(0)},className:"w-[160px]"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:"End Date"}),e.jsx(l,{type:"date",value:m,onChange:t=>{f(t.target.value),n(0)},className:"w-[160px]"})]}),e.jsx(l,{placeholder:"Event type…",value:p,onChange:t=>{v(t.target.value),n(0)},className:"w-[160px]"}),e.jsx(E,{})]}),Q(s)?e.jsx(D,{rows:12,cols:5}):s.error?e.jsx(N,{title:"Could not load timeline",children:s.error.message}):e.jsxs(e.Fragment,{children:[e.jsx(C,{columns:j,data:_}),s.data&&s.data.events.length>=d&&e.jsx(I,{offset:o,limit:d,total:s.data.events.length+o+1,onPageChange:n})]})]})}export{M as default};
