import{a as e,n as t,r as n}from"./useStore-CusP06SD.js";import{L as r}from"./sidebar-y9WJu7Jw.js";import{t as i}from"./Page-C7KClZ28.js";import{a}from"./dist-DhH_lYkz.js";import{d as o}from"./index-DinSQfHc.js";var s=e(n()),c=t();function l({title:e,value:t,description:n,className:r,trend:i}){return(0,c.jsxs)(`div`,{className:a(`bg-card text-card-foreground rounded-lg border p-6 shadow-sm`,r),children:[(0,c.jsx)(`div`,{className:`flex flex-row items-center justify-between space-y-0 pb-2`,children:(0,c.jsx)(`h3`,{className:`text-sm font-medium tracking-tight`,children:e})}),(0,c.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,c.jsx)(`div`,{className:`text-2xl font-bold`,children:t}),i&&(0,c.jsxs)(`div`,{className:`text-muted-foreground text-xs`,children:[(0,c.jsxs)(`span`,{className:a(`font-medium`,i.value>0?`text-green-600`:`text-red-600`),children:[i.value>0?`+`:``,i.value]}),` `,i.label]})]}),n&&(0,c.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:n})]})}function u(){let{data:e}=o(r().stats.getOverview.queryOptions()),t=(0,s.useMemo)(()=>e.queryCount!==e.totalSearchees,[e.queryCount,e.totalSearchees]),n=t,a=t?`lg:grid-cols-5`:`lg:grid-cols-4`,u=n?`lg:grid-cols-4`:`lg:grid-cols-3`,d=e.allIndexersHealthy?`Indexer Health`:`Unhealthy Indexers`,f=e.allIndexersHealthy?`All ${e.totalIndexers.toLocaleString()}`:e.unhealthyIndexers.toLocaleString(),p=e.allIndexersHealthy?`Indexers are all reporting healthy`:`${e.unhealthyIndexers.toLocaleString()} of ${e.totalIndexers.toLocaleString()} indexers need attention`;return(0,c.jsx)(i,{breadcrumbs:[`Dashboard`],children:(0,c.jsx)(`div`,{className:`main space-y-8`,children:(0,c.jsxs)(`section`,{className:`space-y-4`,children:[(0,c.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2 ${a}`,children:[(0,c.jsx)(l,{title:`Total Searchees`,value:e.totalSearchees.toLocaleString(),description:`Torrents being monitored`}),t&&(0,c.jsx)(l,{title:`Total Search Queries`,value:e.queryCount.toLocaleString(),description:`Distinct estimated searches`}),(0,c.jsx)(l,{title:`Total Query-Indexer Pairs`,value:e.queryIndexerCount.toLocaleString(),description:`Unique indexer searches`}),(0,c.jsx)(l,{title:`Total Snatches`,value:e.snatchCount.toLocaleString(),description:`Unique infohash attempts`}),(0,c.jsx)(l,{title:`Total Matches`,value:e.totalMatches.toLocaleString(),description:`Unique cross-seeds found`})]}),(0,c.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2 ${u}`,children:[(0,c.jsx)(l,{title:`Matches per Searchee`,value:e.matchRate.toFixed(2),description:`Average matches per monitored torrent`}),n&&(0,c.jsx)(l,{title:`Matches per Query`,value:e.matchesPerQuery.toFixed(2),description:`Matches per search estimate`}),(0,c.jsx)(l,{title:`Match Rate`,value:`${(e.matchesPerQueryIndexer*100).toFixed(1)}%`,description:`of indexer searches find a match`}),(0,c.jsx)(l,{title:`Wasted Snatches`,value:`${(e.wastedSnatchRate*100).toFixed(1)}%`,description:`${e.wastedSnatchCount.toLocaleString()} snatched but mismatched`})]}),(0,c.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,c.jsx)(l,{title:d,value:f,description:p}),(0,c.jsx)(l,{title:`Recent Activity`,value:e.recentMatches.toLocaleString(),description:`Matches in last 24h`})]})]})})})}export{u as component};