import{w as g,p as a,j as e,q as N}from"./silentshield-vendor-lib-BOYiOmBi.js";import{c as T,g as Z,a as G,b as J,d as Q,e as V,_ as t,C as i,f as l,h as m,i as d,s as o,S as W,j as ee,Z as ae,B as S,k as te,l as ce,m as h}from"./silentshield-admin.js";import{u as se,P,A as re}from"./silentshield-useApiManagement-CVAxTEx4.js";import{T as ne,a as oe,b as q,c as y,d as ie,e as b}from"./silentshield-table-D7OkaxR3.js";import{u as le,A as de}from"./silentshield-useAnalytics-9--qtApf.js";import{M as me}from"./silentshield-minus-BT5uLD95.js";import{C as he}from"./silentshield-circle-check-big-NiZTsOJS.js";import{R as F,L as fe,C as pe,X as ue,Y as xe,T as I,a as ge,P as Ne,b as ye,d as be,e as ve}from"./silentshield-vendor-charts-CfxhkB09.js";import"./silentshield-vendor-ui-BEc9V-_C.js";/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const we=T("Link2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const ke=T("TrendingDown",[["polyline",{points:"22 17 13.5 8.5 8.5 13.5 2 7",key:"1r2t7k"}],["polyline",{points:"16 17 22 17 22 11",key:"11uiuu"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const _e=T("TrendingUp",[["polyline",{points:"22 7 13.5 15.5 8.5 10.5 2 17",key:"126l90"}],["polyline",{points:"16 7 22 7 22 13",key:"kwv8wd"}]]);function Ce(){return g({queryKey:["dashboard","stats"],queryFn:Z})}function Se(){return g({queryKey:["dashboard","modules"],queryFn:G})}function Le(c=30){return g({queryKey:["dashboard","timeline",c],queryFn:()=>J(c)})}function Te(c=30){return g({queryKey:["dashboard","reasons",c],queryFn:()=>Q(c)})}function De(c=10){return g({queryKey:["dashboard","recent-blocks",c],queryFn:()=>V({limit:c,days:7})})}const K=["hsl(0, 84%, 60%)","hsl(38, 92%, 50%)","hsl(207, 90%, 54%)","hsl(270, 60%, 55%)","hsl(142, 71%, 45%)","hsl(220, 14%, 45%)","hsl(330, 65%, 50%)","hsl(180, 60%, 40%)"],$={captcha:"Captcha",timer:"Timer",ip_limit:t("IP Block","captcha-for-contact-form-7"),ip_blacklist:t("IP Blacklist","captcha-for-contact-form-7"),javascript:t("JS missing","captcha-for-contact-form-7"),browser:t("Browser invalid","captcha-for-contact-form-7"),rules:t("Content Rule","captcha-for-contact-form-7"),multiple_submission:t("Multiple Submission","captcha-for-contact-form-7"),api:"API",blacklist:"Blacklist"},Ae={captcha:"destructive",timer:"default",ip_limit:"secondary",ip_blacklist:"secondary",javascript:"secondary",browser:"secondary",rules:"outline",multiple_submission:"default",api:"default"};function L(c){return c>=1e4?(c/1e3).toFixed(1).replace(".0","")+"k":c.toLocaleString("de-DE")}function Re(c){const v=Date.now()-new Date(c).getTime(),n=Math.floor(v/6e4);if(n<1)return t("just now","captcha-for-contact-form-7");if(n<60)return o(t("%d min. ago","captcha-for-contact-form-7"),n);const s=Math.floor(n/60);return s<24?o(t("%d hrs. ago","captcha-for-contact-form-7"),s):o(t("%d days ago","captcha-for-contact-form-7"),Math.floor(s/24))}function u(){return a(i,{children:[a(l,{className:"flex flex-row items-center justify-between pb-2",children:[e(h,{className:"h-4 w-28"}),e(h,{className:"h-4 w-4"})]}),a(d,{children:[e(h,{className:"h-8 w-20 mb-2"}),e(h,{className:"h-3 w-32"})]})]})}function E({className:c}){return a(i,{className:c,children:[e(l,{children:e(h,{className:"h-5 w-40"})}),e(d,{children:e(h,{className:"h-[280px] w-full rounded"})})]})}function Ee(){const{data:c,isLoading:v}=Ce(),{data:n}=le(30),{data:s,isLoading:H}=Se(),{data:w,isLoading:U}=Le(30),{data:k,isLoading:O}=Te(30),{data:_,isLoading:z}=De(8),{data:f}=se(),D=((w==null?void 0:w.timeline)??[]).map(r=>{const p=new Date(r.day);return{date:`${p.getDate()}.${p.getMonth()+1}`,spam:Number(r.count)}}),C=((k==null?void 0:k.by_protection)??[]).map((r,p)=>({name:$[r.protection]||r.protection,value:Number(r.count),color:K[p%K.length]})),x=(c==null?void 0:c.checks_total)??0,A=(c==null?void 0:c.checks_spam)??0,R=(c==null?void 0:c.checks_clean)??0,X=x>0?(A/x*100).toFixed(1):"0.0",Y=x>0?(R/x*100).toFixed(1):"0.0",j=s?Math.round(s.active_modules/Math.max(s.total_modules,1)*100):0,B=s?Math.round(s.active_integrations/Math.max(s.total_integrations,1)*100):0,M=(_==null?void 0:_.data)??[];return a("div",{className:"space-y-6",children:[a("div",{children:[e("h1",{className:"text-2xl font-bold tracking-tight",children:t("Dashboard","captcha-for-contact-form-7")}),e("p",{className:"text-muted-foreground",children:t("Overview of current protection status","captcha-for-contact-form-7")})]}),e("div",{className:"grid gap-4 md:grid-cols-3",children:v?a(N,{children:[e(u,{}),e(u,{}),e(u,{})]}):a(N,{children:[a(i,{children:[a(l,{className:"flex flex-row items-center justify-between pb-2",children:[e(m,{className:"text-sm font-medium text-muted-foreground",children:t("Total Checks","captcha-for-contact-form-7")}),e(de,{className:"h-4 w-4 text-muted-foreground"})]}),a(d,{children:[e("div",{className:"text-3xl font-bold",children:L(x)}),n&&a("div",{className:"flex items-center gap-1 text-xs text-muted-foreground mt-1",children:[e(me,{className:"h-3 w-3"}),e("span",{children:o(t("%s this month","captcha-for-contact-form-7"),n.month)})]})]})]}),a(i,{children:[a(l,{className:"flex flex-row items-center justify-between pb-2",children:[e(m,{className:"text-sm font-medium text-muted-foreground",children:t("Spam Blocked","captcha-for-contact-form-7")}),e(W,{className:"h-4 w-4 text-destructive"})]}),a(d,{children:[e("div",{className:"text-3xl font-bold",children:L(A)}),a("div",{className:"flex items-center gap-2 text-xs mt-1",children:[e("span",{className:"text-muted-foreground",children:o(t("%s%% of checks","captcha-for-contact-form-7"),X)}),n&&n.week>0&&a("span",{className:"flex items-center gap-0.5 text-destructive",children:[e(ke,{className:"h-3 w-3"}),o(t("%s this week","captcha-for-contact-form-7"),n.week)]})]})]})]}),a(i,{children:[a(l,{className:"flex flex-row items-center justify-between pb-2",children:[e(m,{className:"text-sm font-medium text-muted-foreground",children:t("Clean Submissions","captcha-for-contact-form-7")}),e(he,{className:"h-4 w-4 text-success"})]}),a(d,{children:[e("div",{className:"text-3xl font-bold",children:L(R)}),a("div",{className:"flex items-center gap-2 text-xs mt-1",children:[e("span",{className:"text-muted-foreground",children:o(t("%s%% of checks","captcha-for-contact-form-7"),Y)}),n&&a("span",{className:"flex items-center gap-0.5 text-success",children:[e(_e,{className:"h-3 w-3"}),o(t("%s today","captcha-for-contact-form-7"),n.today)]})]})]})]})]})}),a("div",{className:"grid gap-4 lg:grid-cols-5",children:[U?e(E,{className:"lg:col-span-3"}):a(i,{className:"lg:col-span-3",children:[e(l,{children:e(m,{className:"text-base",children:t("Blocks – 30 Days","captcha-for-contact-form-7")})}),e(d,{children:e("div",{className:"h-[280px]",children:D.length===0?e("div",{className:"flex items-center justify-center h-full text-sm text-muted-foreground",children:t("No data available yet","captcha-for-contact-form-7")}):e(F,{width:"100%",height:"100%",children:a(fe,{data:D,children:[e(pe,{strokeDasharray:"3 3",className:"stroke-border"}),e(ue,{dataKey:"date",className:"text-xs",tick:{fill:"hsl(218, 11%, 45%)"}}),e(xe,{className:"text-xs",tick:{fill:"hsl(218, 11%, 45%)"}}),e(I,{contentStyle:{backgroundColor:"hsl(var(--ss-card))",border:"1px solid hsl(var(--ss-border))",borderRadius:"8px",color:"hsl(var(--ss-foreground))"}}),e(ge,{type:"monotone",dataKey:"spam",stroke:"hsl(0, 84%, 60%)",strokeWidth:2,dot:!1,name:t("Blocked","captcha-for-contact-form-7")})]})})})})]}),O?e(E,{className:"lg:col-span-2"}):a(i,{className:"lg:col-span-2",children:[e(l,{children:e(m,{className:"text-base",children:t("Block Reasons","captcha-for-contact-form-7")})}),e(d,{children:e("div",{className:"h-[280px]",children:C.length===0?e("div",{className:"flex items-center justify-center h-full text-sm text-muted-foreground",children:t("No data available yet","captcha-for-contact-form-7")}):e(F,{width:"100%",height:"100%",children:a(Ne,{children:[e(ye,{data:C,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",outerRadius:90,innerRadius:50,paddingAngle:2,children:C.map((r,p)=>e(be,{fill:r.color},p))}),e(I,{contentStyle:{backgroundColor:"hsl(var(--ss-card))",border:"1px solid hsl(var(--ss-border))",borderRadius:"8px",color:"hsl(var(--ss-foreground))"}}),e(ve,{wrapperStyle:{fontSize:"11px"}})]})})})})]})]}),e("div",{className:"grid gap-4 md:grid-cols-3",children:H?a(N,{children:[e(u,{}),e(u,{}),e(u,{})]}):a(N,{children:[a(i,{children:[e(l,{className:"pb-3",children:a(m,{className:"text-sm font-medium flex items-center gap-2",children:[e(ee,{className:"h-4 w-4 text-primary"}),t("Active Protection Modules","captcha-for-contact-form-7")]})}),a(d,{className:"space-y-3",children:[a("div",{className:"flex items-center justify-between text-sm",children:[e("span",{children:o(t("%1$s of %2$s active","captcha-for-contact-form-7"),(s==null?void 0:s.active_modules)??0,(s==null?void 0:s.total_modules)??0)}),a("span",{className:"text-muted-foreground",children:[j,"%"]})]}),e(P,{value:j,className:"h-2"})]})]}),a(i,{children:[e(l,{className:"pb-3",children:a(m,{className:"text-sm font-medium flex items-center gap-2",children:[e(we,{className:"h-4 w-4 text-primary"}),t("Active Integrations","captcha-for-contact-form-7")]})}),a(d,{className:"space-y-3",children:[a("div",{className:"flex items-center justify-between text-sm",children:[e("span",{children:o(t("%1$s of %2$s detected","captcha-for-contact-form-7"),(s==null?void 0:s.active_integrations)??0,(s==null?void 0:s.total_integrations)??0)}),a("span",{className:"text-muted-foreground",children:[B,"%"]})]}),e(P,{value:B,className:"h-2"})]})]}),a(i,{children:[e(l,{className:"pb-3",children:a(m,{className:"text-sm font-medium flex items-center gap-2",children:[e(ae,{className:"h-4 w-4 text-primary"}),t("API Status","captcha-for-contact-form-7")]})}),e(d,{children:f!=null&&f.active?a("div",{className:"flex items-center justify-between",children:[a("div",{className:"space-y-1",children:[e(S,{variant:"outline",className:"border-warning text-warning",children:o(t("Trial – %d Days","captcha-for-contact-form-7"),f.days_remaining)}),f.expires_at&&e("p",{className:"text-xs text-muted-foreground",children:o(t("Expires on %s","captcha-for-contact-form-7"),new Date(f.expires_at).toLocaleDateString("de-DE"))})]}),a(te,{variant:"outline",size:"sm",className:"text-xs",onClick:()=>window.location.hash="/api",children:[t("Upgrade","captcha-for-contact-form-7")," ",e(re,{className:"ml-1 h-3 w-3"})]})]}):a("div",{className:"space-y-1",children:[e(S,{variant:"secondary",children:t("Not active","captcha-for-contact-form-7")}),e("p",{className:"text-xs text-muted-foreground",children:t("No API key configured","captcha-for-contact-form-7")})]})})]})]})}),a(i,{children:[a(l,{children:[e(m,{className:"text-base",children:t("Last Activity","captcha-for-contact-form-7")}),e(ce,{children:t("Recent blocked submissions","captcha-for-contact-form-7")})]}),e(d,{children:z?e("div",{className:"space-y-3",children:[1,2,3,4,5].map(r=>e(h,{className:"h-10 w-full"},r))}):M.length===0?e("div",{className:"text-center py-8 text-sm text-muted-foreground",children:t("No blocked submissions yet","captcha-for-contact-form-7")}):a(ne,{children:[e(oe,{children:a(q,{children:[e(y,{className:"w-[120px]",children:t("Time","captcha-for-contact-form-7")}),e(y,{children:t("IP","captcha-for-contact-form-7")}),e(y,{children:t("Reason","captcha-for-contact-form-7")}),e(y,{className:"text-right",children:t("Form","captcha-for-contact-form-7")})]})}),e(ie,{children:M.map(r=>a(q,{children:[e(b,{className:"text-muted-foreground text-xs",children:Re(r.ts)}),e(b,{className:"font-mono text-xs",children:r.ip_hash?r.ip_hash.substring(0,12)+"…":"–"}),e(b,{children:e(S,{variant:Ae[r.protection]||"secondary",className:"text-xs",children:$[r.protection]||r.protection})}),a(b,{className:"text-right text-xs text-muted-foreground",children:[r.form_plugin||"–",r.form_id?` #${r.form_id}`:""]})]},r.id))})]})})]})]})}export{Ee as default};
