import{k as he,j as b,t as fe,m as p,n as c,p as t,f as y,i as z,v as _e,A as g,w as W,x as ve,s as me,S,z as B,q as X}from"./web.Os7kOAdY.js";import{g as Y,t as we}from"./i18n-runtime._BAkvU05.js";var ye=g("<p style=margin-top:12px;color:var(--text,#aaa)>"),Se=g("<p style=margin-top:12px;color:#e74c3c><!$><!/><!$><!/>"),ke=g("<div>"),Ce=g('<div style=max-width:540px><div style=display:flex;gap:8px;align-items:center><input style="flex:1;padding:10px 12px;border-radius:6px;border:1px solid var(--border,#444);background:var(--bg,#1a1a2e);color:var(--text,#eee);font-size:15px;font-family:monospace"><button style="padding:8px 12px;border-radius:6px;border:1px solid var(--border,#444);background:transparent;color:var(--text,#eee);cursor:pointer;font-size:13px"></button><button style="padding:8px 16px;border-radius:6px;border:none;background:var(--accent,#6c8);color:#000;cursor:pointer;font-weight:600"></button></div><!$><!/><!$><!/><!$><!/><!$><!/><div style="margin-top:20px;padding:12px;border-radius:8px;background:color-mix(in srgb, var(--text) 5%, transparent);font-size:12px;color:var(--text,#999)"><p style=margin:0>'),Pe=g('<div style="padding:10px 14px;border-radius:6px;background:color-mix(in srgb, var(--text) 5%, transparent);margin-bottom:12px"><p style="font-weight:600;margin:0 0 4px"></p><ul style=margin:0;padding-left:18px;font-size:13px>'),Ee=g("<div style=margin-top:20px><div style=margin-bottom:12px><div style=display:flex;justify-content:space-between;align-items:center;margin-bottom:6px><span style=font-weight:600></span><span><!$><!/> (<!$><!/>/5)</span></div><div style=height:8px;border-radius:4px;background:var(--border,#333);overflow:hidden><div></div></div></div><!$><!/>"),Ae=g("<li>"),ze=g("<p style=margin:0;font-weight:600;color:#e74c3c><!$><!/><strong></strong> <!$><!/>"),Le=g("<p style=margin:0;font-weight:600;color:#2ecc71>");async function He(o){const r=new TextEncoder().encode(o),n=await crypto.subtle.digest("SHA-1",r);return Array.from(new Uint8Array(n)).map(h=>h.toString(16).padStart(2,"0")).join("").toUpperCase()}function Te(o){let r=0;const n=[];o.length>=8?r+=1:n.push("长度至少 8 位"),o.length>=12&&(r+=1),o.length>=16&&(r+=1),/[a-z]/.test(o)?r+=1:n.push("添加小写字母"),/[A-Z]/.test(o)?r+=1:n.push("添加大写字母"),/\d/.test(o)?r+=1:n.push("添加数字"),/[^a-zA-Z0-9]/.test(o)?r+=1:n.push("添加特殊字符"),/^(.)\1+$/.test(o)&&(r-=2,n.push("避免重复字符")),/^(012|123|234|345|456|567|678|789|abc|bcd|cde|def)/.test(o.toLowerCase())&&(r-=1,n.push("避免连续序列")),o.length<4&&(r=0),r=Math.max(0,Math.min(5,r));const h=["极弱","弱","一般","中等","强","极强"],L=["#e74c3c","#e67e22","#f39c12","#f1c40f","#2ecc71","#27ae60"];return{score:r,label:h[r],color:L[r],tips:n}}function Ie(){const[o,r]=b(Y(),{equals:!1}),n=i=>we(i,o());fe(()=>{const i=d=>{const s=d.detail?.locale;s&&r(s)};window.addEventListener("taitan:locale-change",i),r(Y()),me(()=>window.removeEventListener("taitan:locale-change",i))});const[h,L]=b(""),[H,ee]=b(!1),[te,ne]=b(null),[m,N]=b(null),[Z,R]=b(!1),[D,F]=b(""),G=()=>{const i=h();i&&(ne(Te(i)),re(i))},re=async i=>{R(!0),F(""),N(null);try{const d=await He(i),s=d.slice(0,5),w=d.slice(5),f=await fetch(`https://api.pwnedpasswords.com/range/${s}`);if(!f.ok)throw new Error(`HTTP ${f.status}`);const k=(await f.text()).split(`
`);let C=0;for(const T of k){const[P,M]=T.split(":");if(P.trim().toUpperCase()===w){C=parseInt(M.trim(),10);break}}N(C)}catch(d){F(d.message||"查询失败")}finally{R(!1)}};return(()=>{var i=p(Ce),d=i.firstChild,s=d.firstChild,w=s.nextSibling,f=w.nextSibling,J=d.nextSibling,[k,C]=c(J.nextSibling),T=k.nextSibling,[P,M]=c(T.nextSibling),ie=P.nextSibling,[K,le]=c(ie.nextSibling),oe=K.nextSibling,[O,ae]=c(oe.nextSibling),se=O.nextSibling,ce=se.firstChild;return s.$$keydown=e=>{e.key==="Enter"&&G()},s.$$input=e=>L(e.currentTarget.value),w.$$click=()=>ee(!H()),t(w,()=>H()?"隐藏":"显示"),f.$$click=G,t(f,()=>n("检测")),t(i,y(S,{get when(){return te()},children:e=>(()=>{var a=p(Ee),l=a.firstChild,_=l.firstChild,u=_.firstChild,x=u.nextSibling,v=x.firstChild,[E,j]=c(v.nextSibling),I=E.nextSibling,U=I.nextSibling,[Q,de]=c(U.nextSibling);Q.nextSibling;var pe=_.nextSibling,ge=pe.firstChild,xe=l.nextSibling,[$e,ue]=c(xe.nextSibling);return t(u,()=>n("强度评分")),t(x,()=>e().label,E,j),t(x,()=>e().score,Q,de),t(a,y(S,{get when(){return e().tips.length>0},get children(){var $=p(Pe),A=$.firstChild,q=A.nextSibling;return t(A,()=>n("改进建议：")),t(q,()=>e().tips.map(be=>(()=>{var V=p(Ae);return t(V,be),V})())),$}}),$e,ue),z($=>{var A=`font-weight:700;color:${e().color}`,q=`height:100%;width:${e().score/5*100}%;background:${e().color};border-radius:4px;transition:width .3s;`;return $.e=B(x,A,$.e),$.t=B(ge,q,$.t),$},{e:void 0,t:void 0}),a})()}),k,C),t(i,y(S,{get when(){return Z()},get children(){var e=p(ye);return t(e,()=>n("正在查询 HaveIBeenPwned...")),e}}),P,M),t(i,y(S,{get when(){return D()},get children(){var e=p(Se),a=e.firstChild,[l,_]=c(a.nextSibling),u=l.nextSibling,[x,v]=c(u.nextSibling);return t(e,()=>n("查询失败:"),l,_),t(e,D,x,v),e}}),K,le),t(i,y(S,{get when(){return X(()=>m()!==null)()&&!Z()},get children(){var e=p(ke);return t(e,(()=>{var a=X(()=>m()>0);return()=>a()?(()=>{var l=p(ze),_=l.firstChild,[u,x]=c(_.nextSibling),v=u.nextSibling,E=v.nextSibling,j=E.nextSibling,[I,U]=c(j.nextSibling);return t(l,()=>n("此密码已在数据泄露中出现"),u,x),t(v,()=>m().toLocaleString()),t(l,()=>n("次，请立即更换！"),I,U),l})():(()=>{var l=p(Le);return t(l,()=>n("此密码未在已知泄露数据库中出现。")),l})()})()),z(a=>B(e,`margin-top:12px;padding:12px 16px;border-radius:8px;border:2px solid ${m()>0?"#e74c3c":"#2ecc71"};background:color-mix(in srgb, ${m()>0?"#e74c3c":"#2ecc71"} 8%, transparent);`,a)),e}}),O,ae),t(ce,()=>n("安全说明：密码不会发送到任何服务器。HaveIBeenPwned 查询使用 k-Anonymity 模型，仅发送 SHA-1 哈希的前 5 位前缀。")),z(e=>{var a=H()?"text":"password",l=n("输入密码...");return a!==e.e&&W(s,"type",e.e=a),l!==e.t&&W(s,"placeholder",e.t=l),e},{e:void 0,t:void 0}),z(()=>ve(s,"value",h())),_e(),i})()}he(["input","keydown","click"]);export{Ie as default};
