1import{M as w,S as y,j as t}from"./index-qp2ru7DR.js";import{A as k,P as N}from"./AppShell-CWyrekZ1.js";import{u as C,b as g,c as v}from"./db-Ci0KArjV.js";import{C as L}from"./circle-check-DE3iPqqG.js";import{Z as A}from"./zap-5sozaFg6.js";import{C as $}from"./clock-D0vaU3Ec.js";import{L as S}from"./loader-circle-Bf-CJzVz.js";import"./sheet-DPpwwA9Z.js";import"./index-Cq2L4fUL.js";import"./index-BUx1SUyn.js";import"./tslib.es6-eMSY344_.js";import"./index-Be3q6WH_.js";import"./x-eMSWKRxF.js";import"./BrandLogo-LhrbQrqn.js";import"./useMutation-C64P70D_.js";import"./dialog-DaKKZ7bQ.js";import"./button-D2uRa2eV.js";import"./index-hLWEBsPQ.js";import"./client-bPd5HcGv.js";import"./star-U1HfSnWB.js";import"./dropdown-menu-BEQrcLtD.js";import"./index-zocKir6P.js";import"./index-bG4Jkymn.js";import"./chevron-right-BaNm4SwX.js";import"./check-_AvfohVi.js";import"./building-2-D2YqBDUQ.js";import"./chevrons-up-down-DSqvJs7-.js";import"./menu-D4JVc0f8.js";import"./search-C6cy-ctd.js";import"./inbox-Br0eFZNU.js";import"./calendar-clock-1STufm64.js";import"./megaphone-GWHVyo_p.js";import"./brain-DyJUm11F.js";import"./bell-aykl8KOJ.js";import"./shield-check-Smp21mwG.js";import"./rocket-C931b47c.js";import"./log-out-ytDUMB6l.js";import"./travelcs.functions-CiSSQw1d.js";function ut(){const a=C(),o=g("conversations"),i=g("approvals",{scopeByOperator:!1,select:"conversation_id,conversations!inner(operator_id)",filters:{"conversations.operator_id":`eq.${a}`}}),m=v("tasks"),l=v("analytics_events",{order:{column:"created_at"},limit:500});(m.data??[]).filter(e=>/completed|done|closed|resolved/i.test(e.status??"")).length;const s=i.data??0,r=o.data??0,p=Math.max(r-s,0),n=r>0?Math.round(p/r*100):0,x=p*5,u=o.isLoading||i.isLoading||m.isLoading||l.isLoading,c=[{label:"Conversations",value:r.toLocaleString(),icon:w},{label:"AI Resolved",value:p.toLocaleString(),icon:y},{label:"Human Approved",value:s.toLocaleString(),icon:L},{label:"Automation Rate",value:`${n}%`,icon:A},{label:"Time Saved",value:`${Math.round(x/60)}h ${x%60}m`,icon:$}],d=M(l.data??[],14);return t.jsxs(k,{children:[t.jsx(N,{title:"Analytics",description:"How your AI agent is performing"}),u?t.jsxs("div",{className:"px-4 sm:px-8 py-12 flex items-center gap-2 text-sm text-muted-foreground",children:[t.jsx(S,{className:"h-4 w-4 animate-spin"})," Loading analyticsâ¦"]}):t.jsxs("div",{className:"px-4 sm:px-8 py-6 space-y-6",children:[t.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 gap-4",children:c.map(e=>{const f=e.icon;return t.jsxs("div",{className:"rounded-2xl border border-border bg-card p-4 sm:p-5 shadow-soft min-w-0",children:[t.jsx("div",{className:"flex items-center justify-between",children:t.jsx("div",{className:"h-8 w-8 rounded-lg gradient-brand-soft border border-border flex items-center justify-center",children:t.jsx(f,{className:"h-4 w-4 text-foreground"})})}),t.jsx("div",{className:"mt-4 text-xl sm:text-2xl font-semibold tracking-tight truncate",children:e.value}),t.jsx("div",{className:"mt-0.5 text-xs text-muted-foreground",children:e.label})]},e.label)})}),t.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-5",children:[t.jsx(j,{title:"Analytics Events",subtitle:"Last 14 days",children:t.jsx(b,{data:d})}),t.jsx(j,{title:"Automation Rate",subtitle:"AI-resolved share of conversations",children:t.jsx(b,{data:[n],suffix:"%",max:100})})]})]})]})}function M(a,o){const i=new Array(o).fill(0),m=new Date;m.setHours(0,0,0,0);for(const l of a){const h=l.created_at??l.timestamp??l.occurred_at;if(!h)continue;const s=new Date(h);s.setHours(0,0,0,0);const r=Math.round((m.getTime()-s.getTime())/864e5);r>=0&&r<o&&(i[o-1-r]+=1)}return i}function j({title:a,subtitle:o,children:i}){return t.jsxs("div",{className:"rounded-2xl border border-border bg-card p-4 sm:p-5 shadow-soft min-w-0",children:[t.jsx("div",{className:"flex items-start justify-between",children:t.jsxs("div",{children:[t.jsx("div",{className:"text-sm font-semibold",children:a}),t.jsx("div",{className:"text-xs text-muted-foreground",children:o})]})}),t.jsx("div",{className:"mt-4",children:i})]})}function b({data:a,suffix:o="",max:i}){const s=a.length<2?[0,...a]:a,r=i??Math.max(...s,1)*1.15,p=584/(s.length-1),n=s.map((c,d)=>{const e=8+d*p,f=172-c/r*164;return[e,f]}),x=n.map(([c,d],e)=>`${e===0?"M":"L"} ${c} ${d}`).join(" "),u=`${x} L ${n[n.length-1][0]} 172 L ${n[0][0]} 172 Z`;return t.jsxs("div",{className:"overflow-x-auto",children:[t.jsxs("svg",{viewBox:"0 0 600 180",className:"w-full min-w-[260px] h-36 sm:h-44",children:[t.jsxs("defs",{children:[t.jsxs("linearGradient",{id:"brandFill",x1:"0",x2:"0",y1:"0",y2:"1",children:[t.jsx("stop",{offset:"0%",stopColor:"oklch(0.62 0.22 295)",stopOpacity:"0.25"}),t.jsx("stop",{offset:"100%",stopColor:"oklch(0.75 0.18 50)",stopOpacity:"0.02"})]}),t.jsxs("linearGradient",{id:"brandStroke",x1:"0",x2:"1",y1:"0",y2:"0",children:[t.jsx("stop",{offset:"0%",stopColor:"oklch(0.65 0.19 250)"}),t.jsx("stop",{offset:"50%",stopColor:"oklch(0.62 0.22 295)"}),t.jsx("stop",{offset:"100%",stopColor:"oklch(0.75 0.18 50)"})]})]}),t.jsx("path",{d:u,fill:"url(#brandFill)"}
1),t.jsx("path",{d:x,fill:"none",stroke:"url(#brandStroke)",strokeWidth:"2.5",strokeLinecap:"round"}),n.map(([c,d],e)=>t.jsx("circle",{cx:c,cy:d,r:"2",fill:"white",stroke:"oklch(0.62 0.22 295)",strokeWidth:"1.5"},e))]}),t.jsxs("div",{className:"mt-2 flex items-center justify-between text-[11px] text-muted-foreground",children:[t.jsxs("span",{children:[s.length,"d range"]}),t.jsxs("span",{className:"font-semibold text-foreground",children:[s[s.length-1],o]})]})]})}export{ut as component};
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.