1import{u as p,j as e}from"./index-DPoJI_wR.js";import{a,ao as b,ad as w}from"./lucide-BOxB89cY.js";import{l as y,d as v,C,a as j,b as _}from"./CommunicationsDetailModal-BcX-Xbnp.js";import"./UserMemoryBadge-D1vKrJlx.js";const D=["whatsapp_chat_ai","whatsapp_chat_system","telegram_chat_ai","telegram_chat_system","uncategorized"];function S(){const s=new Date;return{trafficType:"conversational",startDate:new Date(s.getTime()-24*60*60*1e3).toISOString(),endDate:s.toISOString(),sort:"created_at",order:"desc",page:1,limit:50}}const R=()=>{const{t:s}=p(),[t,i]=a.useState(S),[u,g]=a.useState(null),[h,l]=a.useState(!1),[c,d]=a.useState(null),[f,m]=a.useState(null),n=a.useRef(null);a.useEffect(()=>{n.current&&n.current.abort();const o=new AbortController;return n.current=o,l(!0),d(null),y(t,o.signal).then(r=>g(r)).catch(r=>{r.name!=="AbortError"&&d(r.message||"Failed to load")}).finally(()=>l(!1)),()=>o.abort()},[t]);const x=a.useMemo(()=>!t.startDate||!t.endDate?0:(new Date(t.endDate).getTime()-new Date(t.startDate).getTime())/(24*60*60*1e3),[t.startDate,t.endDate]);return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-semibold",children:s("admin.chat_history.title",{defaultValue:"API v2 & Telegram â chat history"})}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:s("admin.chat_history.subtitle",{defaultValue:"High-volume conversational traffic from the chat bots (WhatsApp via Evolution API v2 and Telegram). Retained for 90 days."})})]}),e.jsxs("button",{onClick:()=>v(t),className:"inline-flex items-center gap-2 px-3 py-2 rounded-md bg-primary text-primary-foreground text-sm hover:opacity-90",children:[e.jsx(b,{className:"h-4 w-4"}),s("admin.communications.export_csv",{defaultValue:"Export CSV"})]})]}),e.jsx(C,{mode:"conversational",value:t,onChange:i,categoryOptions:D}),x>7&&e.jsxs("div",{className:"flex items-start gap-2 px-3 py-2 bg-surface-tint-amber border border-outline-warning-strong text-warning rounded-md text-sm",children:[e.jsx(w,{className:"h-4 w-4 mt-0.5 flex-shrink-0"}),e.jsx("div",{children:s("admin.chat_history.wide_range_warning",{defaultValue:"Wide range selected. For best performance, narrow down by phone/chat_id or user email."})})]}),c&&e.jsx("div",{className:"px-3 py-2 bg-surface-tint-red border border-outline-danger-strong text-danger rounded-md text-sm",children:c}),e.jsx(j,{data:u,loading:h,filters:t,onFiltersChange:i,onRowClick:m}),e.jsx(_,{row:f,onClose:()=>m(null)})]})};export{R as ChatHistoryTab,R 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.