1import{r as e}from"./chunk-CilyBKbf.js";import{B as t,F as n,G as r,H as i,K as a,L as o,N as s,P as c,R as l,W as u,Y as d,c as f,j as p,k as m,q as h,u as g}from"./index-BjsTZRdc.js";import{t as _}from"./main-BojJcRZj.js";var v=e(_(),1),y=l(`<div class=peach-health-loading-screen aria-busy=true aria-live=polite><div class=peach-health-loading-glyph aria-hidden=true><svg width=32 height=32 viewBox="0 0 32 32"fill=none><circle cx=16 cy=16 r=13 stroke=currentColor stroke-width=1.2 opacity=0.18></circle><path d="M16 3a13 13 0 0 1 13 13"stroke=currentColor stroke-width=1.6 stroke-linecap=round><animateTransform attributeName=transform type=rotate from="0 16 16"to="360 16 16"dur=1.2s repeatCount=indefinite></animateTransform></path></svg></div><h2 class=peach-health-loading-title>Checking your vault's health</h2><p class=peach-health-loading-copy>Scanning for reused, breached, weak, and aging credentials. Just a moment…</p><div class=peach-health-loading-track aria-hidden=true><div class=peach-health-loading-fill>`),b=l(`<div class=peach-health-pro-queue><div class=peach-health-pro-queue-head><span class=peach-health-pro-queue-title>Remediation queue</span><span class=peach-health-pro-queue-score>Vault score <!>/100`),x=l(`<span class=peach-health-summary-warn> <!> attention`),S=l(`<div class="peach-overlay-view ov-enter-right"style=display:flex><div class=peach-overlay-header><button class="peach-btn peach-btn--ghost peach-btn--sm peach-icon-btn"aria-label=Back><svg width=7 height=12 viewBox="0 0 7 12"fill=none stroke=currentColor stroke-width=1.1 stroke-linecap=round stroke-linejoin=round><path d="M6 1L1 6L6 11"></path></svg></button><span class=peach-overlay-title>vault health</span><div class=peach-overlay-spacer></div></div><div class=peach-health-body><div class=peach-health-summary></div><div class=peach-health-check-row><button class="peach-btn peach-btn--accent peach-btn--sm peach-health-check-btn"><svg width=10 height=12 viewBox="0 0 10 12"fill=none stroke=currentColor stroke-width=1.1 stroke-linecap=round stroke-linejoin=round style=margin-right:5px><path d="M9 6L5 10L1 6"></path><path d="M5 10V2"></path></svg></button></div><div class=peach-health-sections>`),ee=l(`<div class=peach-health-pro-row><div class=peach-health-pro-row-info><span class=peach-health-pro-row-name></span><span class=peach-health-pro-row-meta></span><div class=peach-health-pro-bar aria-hidden=true><div class=peach-health-pro-bar-fill></div></div></div><button class="peach-btn peach-btn--accent peach-btn--sm">`),te=l(`<span class=peach-health-summary-ok>Your vault looks healthy.`),C=l(`<div class=peach-health-row><div class=peach-health-row-info><span class=peach-health-row-name></span><span class=peach-health-row-meta style=color:var(--peach-breach)></span></div><button class="peach-btn peach-btn--ghost peach-btn--sm peach-health-fix-btn">Fix<svg width=6 height=10 viewBox="0 0 6 10"fill=none stroke=currentColor stroke-width=1.1 stroke-linecap=round stroke-linejoin=round style=margin-left:4px><path d="M1 5L5 9M5 9L5 5M5 9L1 9">`),w=l(`<div class=peach-health-loading>Computing...`),T=l(`<div class=peach-health-row><div class=peach-health-row-info><span class=peach-health-row-name>Used in <!> places</span><span class=peach-health-row-meta></span></div><button class="peach-btn peach-btn--ghost peach-btn--sm peach-health-fix-btn">View<svg width=6 height=10 viewBox="0 0 6 10"fill=none stroke=currentColor stroke-width=1.1 stroke-linecap=round stroke-linejoin=round style=margin-left:4px><path d="M1 5L5 9M5 9L5 5M5 9L1 9">`),E=l(`<div class=peach-health-row><div class=peach-health-row-info><span class=peach-health-row-name></span><span class=peach-health-row-meta>score: <!> (<!>)</span></div><button class="peach-btn peach-btn--ghost peach-btn--sm peach-health-fix-btn">Fix<svg width=6 height=10 viewBox="0 0 6 10"fill=none stroke=currentColor stroke-width=1.1 stroke-linecap=round stroke-linejoin=round style=margin-left:4px><path d="M1 5L5 9M5 9L5 5M5 9L1 9">`),D=l(`<div class=peach-health-row><div class=peach-health-row-info><span class=peach-health-row-name></span><span class=peach-health-row-meta>last changed </span></div><button class="peach-btn peach-btn--ghost peach-btn--sm peach-health-fix-btn">Fix<svg width=6 height=10 viewBox="0 0 6 10"fill=none stroke=currentColor stroke-width=1.1 stroke-linecap=round stroke-linejoin=round style=margin-left:4px><path d="M1 5L5 9M5 9L5 5M5 9L1 9">`),O=l(`<div class=peach-health-row><div class=peach-health-row-info><span class=peach-health-row-name></span><span class=peach-health-row-meta> • <!> • </span></div><button class="peach-btn peach-btn--ghost peach-btn--sm peach-health-fix-btn">View<svg width=6 height=10 viewBox="0 0 6 10"fill=none stroke=currentColor stroke-width=1.1 stroke-linecap=round stroke-linejoin=round style=margin-left:4px><path d="M1 5L5 9M5 9L5 5M5 9L1 9">`),k=l(`<div class=peach-health-section-body>`),A=l(`<div class=peach-health-section><button class=peach-health-section-header><div class=peach-health-section-title-row><span class=peach-health-count-badge></span><span class=peach-health-section-title></span></div><svg class=peach-health-chevron width=10 height=6 viewBox="0 0 10 6"fill=none stroke=currentColor stroke-width=1.1 stroke-linecap=round stroke-linejoin=round><path d="M1 1L5 5L9 1">`),j=l(`<div class=peach-health-empty>`);function M(e){let t=new TextEncoder().encode(e);return crypto.subtle.digest(`SHA-256`,t).then(e=>Array.from(new Uint8Array(e)).map(e=>e.toString(16).padStart(2,`0`)).join(``))}function N(e){return e>=1e3?`${(e/1e3).toFixed(e%1e3==0?0:1)}k exposures`:`${e.toLocaleString()} ${e===1?`exposure`:`exposures`}`}function P(e){let t=Math.floor(e/1e3);if(t<60)return`just now`;let n=Math.floor(t/60);if(n<60)return`${n} minute${n===1?``:`s`} ago`;let r=Math.floor(n/60);if(r<24)return`${r} hour${r===1?``:`s`} ago`;let i=Math.floor(r/24);if(i<30)return`${i} day${i===1?``:`s`} ago`;let a=Math.floor(i/30);if(a<12)return`${a} month${a===1?``:`s`} ago`;let o=Math.floor(a/12);return`${o} year${o===1?``:`s`} ago`}function ne(e){return[`very weak`,`weak`,`fair`,`good`,`strong`][e]??`unknown`}function F(e){let[s,l]=h(!1),[_,k]=h([]),[A,j]=h(!0),[F,L]=h({breached:!0,reused:!0,weak:!0,old:!0,passkeys:!0}),[R,z]=h(null),[B,V]=h(null),[H,U]=h(!1),[W,G]=h(null);d(async()=>{if(e.isPro){U(!0);try{let e=await m({type:`GET_ADVANCED_HEALTH_REPORT`});e.ok&&V(e.data??null)}finally{U(!1)}}});async function K(e){G(e);let t=await m({type:`INITIATE_PASSWORD_CHANGE`,payload:{id:e}});G(null),t.ok&&window.close()}let q=365*24*60*60*1e3,J=r(()=>e.entries.filter(e=>(e.breach??0)>0).sort((e,t)=>(t.breach??0)-(e.breach??0))),Y=r(()=>{let t=e.entries.filter(e=>e.type!==`note`&&e.password).map(e=>({entry:e,score:(0,v.default)(e.password).score})).filter(({score:e})=>e<=1);return t.sort((e,t)=>e.score-t.score),t}),X=r(()=>e.entries.filter(e=>e.type===`login`&&e.modifiedAt<Date.now()-q).sort((e,t)=>e.modifiedAt-t.modifiedAt)),Z=r(()=>e.entries.filter(e=>e.passkey!==void 0).map(e=>{let t=e.passkey,n=t.lastUsedAt??t.createdAt??e.createdAt,r=Date.now()-n;return{entry:e,lastActivity:n,status:t.signCount===0&&r>=720*60*60*1e3?`Unused`:r>=q?`Old`:null}}).filter(e=>e.status!==null).sort((e,t)=>e.lastActivity-t.lastActivity));async function re(){let t=e.entries.filter(e=>e.type!==`note`&&e.password);if(t.length===0){k([]),j(!1);return}let n=await Promise.all(t.map(async e=>({entry:e,hash:await M(e.password)}))),r=new Map;for(let{entry:e,hash:t}of n){let n=r.get(t)??[];n.push(e),r.set(t,n)}let i=[];r.forEach((e,t)=>{e.length>=2&&i.push({hash:t,entries:e})}),i.sort((e,t)=>t.entries.length-e.entries.length),k(i),j(!1)}re();function Q(e){L(t=>({...t,[e]:!t[e]}))}async function ie(){l(!0);let t=await m({type:`CHECK_ALL_BREACHES`});l(!1),t.ok&&e.onRefresh()}let $=r(()=>J().length+_().length+Y().length+X().length+Z().length);return[(()=>{var r=S(),l=r.firstChild,d=l.firstChild,f=l.nextSibling,m=f.firstChild,h=m.nextSibling,v=h.firstChild;v.firstChild;var k=h.nextSibling;return p(d,`click`,e.onBack,!0),c(f,u(i,{get when(){return n(()=>!!e.isPro)()&&H()},get children(){return y()}}),m),c(f,u(i,{get when(){return n(()=>!!(e.isPro&&!H()&&B()))()&&B().remediation.length>0},get children(){var e=b(),n=e.firstChild.firstChild.nextSibling,r=n.firstChild.nextSibling;return r.nextSibling,c(n,()=>B().vaultScore,r),c(e,u(t,{get each(){return B().remediation.slice(0,8)},children:e=>(()=>{var t=ee(),n=t.firstChild,r=n.firstChild,i=r.nextSibling,s=i.nextSibling.firstChild,l=n.nextSibling;return c(r,()=>e.title),c(i,()=>e.reasons.join(` · `)),l.$$click=()=>void K(e.id),c(l,()=>W()===e.id?`opening…`:`Change this password`),a(t=>{var n=`${Math.min(e.score,100)}%`,r=W()===e.id;return n!==t.e&&o(s,`width`,t.e=n),r!==t.t&&(l.disabled=t.t=r),t},{e:void 0,t:void 0}),t})()}),null),e}}),m),c(m,u(i,{get when(){return $()>0},get fallback(){return te()},get children(){var e=x(),t=e.firstChild,n=t.nextSibling;return n.nextSibling,c(e,$,t),c(e,()=>$()===1?`entry needs`:`entries need`,n),e}})),v.$$click=()=>void ie(),c(v,()=>s()?`checking...`:`Check all breaches now`,null),c(k,u(I,{title:`Breached`,get count(){return J().length},get expanded(){return F().breached},onToggle:()=>Q(`breached`),emptyMessage:`No breached entries`,get children(){return u(t,{get each(){return J()},children:t=>(()=>{var n=C(),r=n.firstChild,i=r.firstChild,a=i.nextSibling,o=r.nextSibling;return c(i,()=>t.title),c(a,()=>N(t.breach??0)),o.$$click=()=>e.onFixEntry(t),n})()})}}),null),c(k,u(I,{title:`Reused`,get count(){return _().length},get expanded(){return F().reused},onToggle:()=>Q(`reused`),get loading(){return A()},emptyMessage:`No reused passwords`,get children(){return u(i,{get when(){return!A()},get fallback(){return w()},get children(){return u(t,{get each(){return _()},children:e=>(()=>{var t=T(),n=t.firstChild,r=n.firstChild,i=r.firstChild.nextSibling;i.nextSibling;var a=r.nextSibling,o=n.nextSibling;return c(r,()=>e.entries.length,i),c(a,()=>e.entries.map(e=>e.title).join(`, `)),o.$$click=()=>z(e.entries),t})()})}})}}),null),c(k,u(I,{title:`Weak`,get count(){return Y().length},get expanded(){return F().weak},onToggle:()=>Q(`weak`),emptyMessage:`No weak passwords`,get children(){return u(t,{get each(){return Y()},children:({entry:t,score:r})=>(()=>{var i=E(),a=i.firstChild,o=a.firstChild,s=o.nextSibling,l=s.firstChild.nextSibling,u=l.nextSibling.nextSibling;u.nextSibling;var d=a.nextSibling;return c(o,(()=>{var e=n(()=>!!t.url);return()=>e()?g(t.url):t.title})()),c(s,r,l),c(s,()=>ne(r),u),d.$$click=()=>e.onFixEntry(t),i})()})}}),null),c(k,u(I,{title:`Old`,get count(){return X().length},get expanded(){return F().old},onToggle:()=>Q(`old`),emptyMessage:`No old entries`,get children(){return u(t,{get each(){return X()},children:t=>{let r=Date.now()-t.modifiedAt;return(()=>{var i=D(),a=i.firstChild,o=a.firstChild,s=o.nextSibling;s.firstChild;var l=a.nextSibling;return c(o,(()=>{var e=n(()=>!!t.url);return()=>e()?g(t.url):t.title})()),c(s,()=>P(r),null),l.$$click=()=>e.onFixEntry(t),i})()}})}}),null),c(k,u(I,{title:`Passkeys`,get count(){return Z().length},get expanded(){return F().passkeys},onToggle:()=>Q(`passkeys`),emptyMessage:`No stale passkeys`,get children(){return u(t,{get each(){return Z()},children:t=>(()=>{var n=O(),r=n.firstChild,i=r.firstChild,a=i.nextSibling,o=a.firstChild,s=o.nextSibling;s.nextSibling;var l=r.nextSibling;return c(i,()=>t.entry.title),c(a,()=>t.status,o),c(a,()=>t.entry.rpId,s),c(a,()=>P(Date.now()-t.lastActivity),null),l.$$click=()=>e.onFixEntry(t.entry),n})()})}}),null),a(()=>v.disabled=s()),r})(),u(i,{get when(){return R()},get children(){return u(f,{get entries(){return R()},selectedEntryId:void 0,sortOrder:`az`,onSortOrderChange:()=>{},onSelectEntry:t=>{z(null),e.onFixEntry(t)},onAdd:()=>{},onClose:()=>z(null)})}})]}function I(e){return(()=>{var t=A(),r=t.firstChild,o=r.firstChild,s=o.firstChild,l=s.nextSibling,d=o.nextSibling;return p(r,`click`,e.onToggle,!0),c(s,()=>e.count),c(l,()=>e.title),c(t,u(i,{get when(){return e.expanded},get children(){var t=k();return c(t,u(i,{get when(){return n(()=>!e.loading)()&&e.count>0},get fallback(){return u(i,{get when(){return!e.loading},get children(){var t=j();return c(t,()=>e.emptyMessage),t}})},get children(){return e.children}})),t}}),null),a(()=>d.classList.toggle(`is-expanded`,!!e.expanded)),t})()}s([`click`]);export{F as HealthView};