import{r as e}from"./rolldown-runtime-BM3Ffeng.js";import{A as t,D as n,E as r,I as i,N as a,O as o,P as s,Xt as c,at as l,et as u,gt as d,ht as f,it as p,k as m,nt as h,ot as g,qt as _,x as v}from"./vue-vendor-DMUmTARL.js";import{Xt as y,li as b}from"./icons-vendor-Buq6V-Ga.js";import{t as x}from"./pro-capability-D8kuUk-o.js";import{t as S}from"./useCapability-CA4VtDqE.js";import{t as C}from"./ProBadge-v9S-_mI9.js";var w={id:`security`,class:`rounded-zf-lg border border-border-light bg-surface p-5 sm:p-6`},T={class:`mb-4 flex items-center justify-between`},E={class:`grid grid-cols-2 gap-4 lg:grid-cols-4`},D={class:`flex items-center justify-between`},O={class:`flex items-center gap-1 text-xs text-placeholder`},k={class:`mt-1 text-xs font-medium text-placeholder group-hover:text-zp`},A={class:`flex items-center justify-between`},j={class:`flex items-center gap-1 text-xs text-secondary`},M={class:`mt-1 text-xs text-placeholder`},N={class:`mt-4 border-t border-border-light pt-4`},P={class:`mb-1 flex items-center justify-between`},F={key:0,class:`space-y-2 py-1`},I={key:1,class:`py-6 text-center text-xs text-placeholder`},L={key:2,class:`divide-y divide-border-light`},R=[`title`],z={class:`w-16 shrink-0 truncate font-medium text-regular`},B={class:`min-w-0 flex-1 truncate font-mono text-secondary`},V={class:`shrink-0 text-right font-mono tabular-nums text-placeholder`},H=i({__name:`SecuritySection`,props:{data:{},loading:{type:Boolean}},setup(e){let i=e,H={isCapabilityEnabled:e=>!1};Object.assign(H,S());let U=e=>({...e,authorized:!e.capability||H.isCapabilityEnabled(e.capability)}),W=r(()=>[{label:`今日登录`,key:`todayLoginCount`,tone:`text-primary`,href:`/admin/login-log`,capability:``,lockReason:``,sub:`今日成功登录次数`},{label:`登录失败`,key:`todayLoginFailCount`,tone:`text-warning`,href:`/admin/login-log`,capability:``,lockReason:``,sub:`今日失败尝试次数`},{label:`在线会话`,key:`onlineSessionCount`,tone:`text-primary`,href:`/admin/online-session`,capability:x.onlineSession,lockReason:`在线会话为 Pro 功能`,sub:`当前在线终端数`},{label:`审计事件`,key:`auditEventCount`,tone:`text-primary`,href:`/admin/audit-log`,capability:x.auditLog,lockReason:`审计为 Pro 功能`,sub:`今日审计记录数`}].map(U)),G=e=>i.data?.[e]??0,K=r(()=>i.data?.recentLogins??[]);return(r,i)=>{let x=p(`router-link`),S=b,H=y,U=l(`count`);return u(),t(`section`,w,[n(`div`,T,[i[1]||=n(`div`,null,[n(`h2`,{class:`text-sm font-semibold text-primary`},`安全概览`),n(`p`,{class:`mt-0.5 text-xs text-placeholder`},`登录、会话与审计的今日汇总`)],-1),s(x,{to:`/admin/login-log`,class:`text-xs font-medium text-zp hover:underline`},{default:f(()=>[...i[0]||=[a(` 查看日志 → `,-1)]]),_:1})]),n(`div`,E,[e.loading&&!e.data?(u(),t(v,{key:0},h(4,e=>n(`div`,{key:`kpi-skeleton-${e}`,class:`h-[6.5rem] animate-pulse rounded-zf-md border border-border-light bg-zf-hover`})),64)):(u(!0),t(v,{key:1},h(W.value,e=>(u(),t(v,{key:e.label},[e.capability&&!e.authorized?(u(),o(x,{key:0,to:`/admin/license`,class:`group rounded-zf-md border border-dashed border-border p-4 transition hover:border-border-dark`},{default:f(()=>[n(`div`,D,[n(`span`,O,[a(c(e.label)+` `,1),s(C,{capability:e.capability},null,8,[`capability`])]),s(S,{class:`h-3.5 w-3.5 text-placeholder`})]),i[2]||=n(`div`,{class:`mt-1.5 text-2xl font-semibold leading-none tracking-tight text-placeholder`},` — `,-1),n(`div`,k,c(e.lockReason)+` → `,1)]),_:2},1024)):m(``,!0),!e.capability||e.authorized?(u(),o(g(e.href?`router-link`:`div`),{key:1,to:e.href||void 0,class:_([`group rounded-zf-md border border-border-light p-4 transition`,e.href?`hover:bg-zf-hover`:``])},{default:f(()=>[n(`div`,A,[n(`span`,j,[a(c(e.label)+` `,1),e.capability?(u(),o(C,{key:0,capability:e.capability},null,8,[`capability`])):m(``,!0)]),e.href?(u(),o(H,{key:0,class:`h-3.5 w-3.5 text-placeholder transition group-hover:text-zp`})):m(``,!0)]),d(n(`div`,{class:_([`mt-1.5 text-2xl font-semibold tabular-nums leading-none tracking-tight`,e.tone])},null,2),[[U,G(e.key)]]),n(`div`,M,c(e.sub),1)]),_:2},1032,[`to`,`class`])):m(``,!0)],64))),128))]),n(`div`,N,[n(`div`,P,[i[4]||=n(`span`,{class:`text-xs font-medium uppercase tracking-wider text-placeholder`},`最近登录`,-1),s(x,{to:`/admin/login-log`,class:`text-xs font-medium text-zp hover:underline`},{default:f(()=>[...i[3]||=[a(` 全部 → `,-1)]]),_:1})]),e.loading&&!e.data?(u(),t(`div`,F,[(u(),t(v,null,h(3,e=>n(`div`,{key:`login-skeleton-${e}`,class:`h-6 animate-pulse rounded-zf-sm bg-zf-hover`})),64))])):K.value.length===0?(u(),t(`div`,I,` 暂无登录记录 `)):(u(),t(`ul`,L,[(u(!0),t(v,null,h(K.value,(e,r)=>(u(),t(`li`,{key:`${e.ip??`-`}-${e.loginTime??r}`,class:`flex items-center gap-3 py-2 text-xs`,title:e.userAgent||``},[n(`span`,{class:_([`h-1.5 w-1.5 shrink-0 rounded-full`,e.success?`bg-success`:`bg-danger`])},null,2),n(`span`,z,c(e.username||`-`),1),n(`span`,B,c(e.ip||`-`),1),n(`span`,{class:_([`shrink-0`,e.success?`text-success`:`text-danger`])},c(e.success?`成功`:`失败`),3),n(`span`,V,c(e.loginTime||`-`),1)],8,R))),128))]))])])}}}),U=e({default:()=>W}),W=H;export{U as n,W as t};