import{c as h,d as G,a7 as C,e as c,g as s,i as a,p as b,f as t,h as i,y as p,O as m,o as d,K as w,M,t as o,J as r,Y as g,R as x,I as L,A as I,j as T,L as F,s as N}from"./index-BebFsTBB.js";import{_ as V}from"./PageHeader.vue_vue_type_script_setup_true_lang-BZ4Q4Q8A.js";var U=h("outline","database","Database",[["path",{d:"M4 6a8 3 0 1 0 16 0a8 3 0 1 0 -16 0",key:"svg-0"}],["path",{d:"M4 6v6a8 3 0 0 0 16 0v-6",key:"svg-1"}],["path",{d:"M4 12v6a8 3 0 0 0 16 0v-6",key:"svg-2"}]]);var z=h("outline","globe","Globe",[["path",{d:"M7 9a4 4 0 1 0 8 0a4 4 0 0 0 -8 0",key:"svg-0"}],["path",{d:"M5.75 15a8.015 8.015 0 1 0 9.25 -13",key:"svg-1"}],["path",{d:"M11 17v4",key:"svg-2"}],["path",{d:"M7 21h8",key:"svg-3"}]]);var P=h("outline","refresh","Refresh",[["path",{d:"M20 11a8.1 8.1 0 0 0 -15.5 -2m-.5 -4v4h4",key:"svg-0"}],["path",{d:"M4 13a8.1 8.1 0 0 0 15.5 2m.5 4v-4h-4",key:"svg-1"}]]);const j={class:"page-container"},A={key:0,class:"grid items-start gap-8 md:grid-cols-2"},E={class:"grid gap-8"},R={class:"grid grid-cols-1 gap-4 sm:grid-cols-2"},H={class:"flex items-center gap-2 text-stone-100"},O={class:"font-bold"},$={class:"text-muted font-mono text-xs"},K={class:"mt-2 flex flex-wrap gap-1"},J={key:0,class:"text-muted text-xs italic"},Y={key:1,class:"flex items-center gap-2"},q={class:"grid grid-cols-1 gap-4 sm:grid-cols-2"},Q={class:"mt-1 font-mono text-2xl text-stone-100"},W={class:"mt-1 font-mono text-2xl text-stone-100"},X={class:"mt-1 font-mono text-2xl text-stone-100"},Z={class:"mt-1 font-mono text-2xl text-stone-100"},tt={class:"mt-1 font-mono text-2xl text-stone-100"},et={class:"grid gap-8"},st={class:"space-y-4"},at={class:"font-mono text-lg"},ot={class:"font-mono text-lg"},lt={class:"space-y-4"},nt={class:"grid grid-cols-1 gap-4 sm:grid-cols-2"},it={class:"font-mono text-lg"},ct={class:"font-mono text-lg"},dt={class:"mt-8 flex flex-col items-center gap-4"},rt=["disabled","title"],ut={key:1,class:"relative flex h-64 items-center justify-center"},_t=G({__name:"StatsView",setup(vt){const l=m(null),y=m([]),v=m(!1),_=m(""),B=async()=>{try{const e=await fetch("/api/active-honeypots");e.ok&&(y.value=await e.json())}catch(e){console.error("Failed to fetch active honeypots",e)}},k=async()=>{try{const e=await fetch("/api/system-stats");e.ok&&(l.value=await e.json())}catch(e){console.error("Failed to fetch system stats",e)}},D=e=>{if(!e)return"0 B";const n=1024,u=["B","KB","MB","GB","TB"],f=Math.floor(Math.log(e)/Math.log(n));return parseFloat((e/Math.pow(n,f)).toFixed(2))+" "+u[f]},S=async()=>{if(!v.value){v.value=!0,_.value="";try{(await fetch("/api/system/update-geodb",{method:"POST"})).ok?(_.value="GeoLite database updated successfully",await k()):_.value="Failed to update GeoLite database"}catch(e){console.error("Failed to update GeoDB",e),_.value="Error updating GeoLite database"}finally{v.value=!1}}};return C(()=>{k(),B()}),(e,n)=>(d(),c("div",j,[s(V,{title:"System Statistics",icon:a(b).activity},null,8,["icon"]),l.value?(d(),c("div",A,[t("div",E,[s(p,{title:"Active Honeypots",icon:a(b).honeypotType},{default:i(()=>[t("div",R,[(d(!0),c(w,null,M(y.value,u=>(d(),c("div",{key:u.name,class:"flex flex-col rounded-lg border border-stone-800 bg-stone-900 p-4"},[t("div",H,[t("span",O,o(u.label),1),t("span",$,"("+o(u.name)+")",1)]),t("div",K,[!u.ports||u.ports.length===0?(d(),c("div",J," No active ports (passive) ")):(d(),c("div",Y,[n[0]||(n[0]=t("span",{class:"text-muted text-xs"},"Ports:",-1)),(d(!0),c(w,null,M(u.ports,f=>(d(),c("div",{key:f,class:"rounded bg-stone-800 px-2 py-0.5 font-mono text-xs font-semibold text-stone-100"},o(f),1))),128))]))])]))),128))])]),_:1},8,["icon"]),s(p,{title:"Database",icon:a(U)},{default:i(()=>[t("div",q,[s(r,{label:"Total Size",class:"bg-stone-900"},{default:i(()=>[t("div",Q,o(D(l.value.database.database_size)),1)]),_:1}),s(r,{label:"Total Events",class:"bg-stone-900"},{default:i(()=>[t("div",W,o(a(g)(l.value.database.rows_events)),1)]),_:1}),s(r,{label:"Tracked IPs",class:"bg-stone-900"},{default:i(()=>[t("div",X,o(a(g)(l.value.database.rows_ips)),1)]),_:1}),s(r,{label:"Blocklist Entries",class:"bg-stone-900"},{default:i(()=>[t("div",Z,o(a(g)(l.value.database.rows_blocklist)),1)]),_:1}),s(r,{label:"Unresolved IPs",class:"bg-stone-900"},{default:i(()=>[t("div",tt,o(a(g)(l.value.database.rows_unresolved_ips)),1)]),_:1})])]),_:1},8,["icon"])]),t("div",et,[s(p,{title:"Tickers & Caches",icon:a(b).time},{default:i(()=>[t("div",st,[s(r,{label:"IP Info Updater",class:"bg-stone-900"},{default:i(()=>[n[1]||(n[1]=t("div",{class:"mt-4 text-stone-400"},"Last successful run",-1)),t("div",at,o(a(x)(l.value.ip_info_last_run)),1)]),_:1}),s(r,{label:"Score Cache",class:"bg-stone-900"},{default:i(()=>[n[2]||(n[2]=t("div",{class:"mt-4"},[t("div",{class:"text-stone-400"},"Last updated")],-1)),t("div",ot,o(a(x)(l.value.score_cache_updated)),1)]),_:1})])]),_:1},8,["icon"]),s(p,{title:"GeoLite Databases",icon:a(z)},{default:i(()=>[t("div",lt,[t("div",nt,[s(r,{label:"ASN Database",class:"bg-stone-900"},{default:i(()=>[n[3]||(n[3]=t("div",{class:"mt-4 text-stone-400"},"Last updated",-1)),t("div",it,o(a(x)(l.value.geolite_asn_date)),1)]),_:1}),s(r,{label:"City Database",class:"bg-stone-900"},{default:i(()=>[n[4]||(n[4]=t("div",{class:"mt-4 text-stone-400"},"Last updated",-1)),t("div",ct,o(a(x)(l.value.geolite_city_date)),1)]),_:1})]),t("div",dt,[t("button",{onClick:S,disabled:v.value||!l.value.geolite_urls_set,title:l.value.geolite_urls_set?"":"Download URLs not configured",class:"btn-secondary px-4 py-2 text-sm disabled:opacity-50"},[s(a(P),{class:L(["h-5 w-5",{"animate-spin":v.value}])},null,8,["class"]),I(" "+o(v.value?"Updating...":"Update GeoLite Database"),1)],8,rt),_.value?(d(),c("div",{key:0,class:L(["text-sm font-semibold",_.value.includes("success")?"text-secondary-400":"text-rose-400"])},o(_.value),3)):T("",!0)])])]),_:1},8,["icon"])])])):(d(),c("div",ut,[s(F)]))]))}}),mt=N(_t,[["__scopeId","data-v-dcbe9fab"]]);export{mt as default};