1import{r as e}from"./chunk-CilyBKbf.js";import{B as t,F as n,G as r,H as i,I as a,Q as o,R as s,U as c,X as l,Y as u,Z as d,c as f,et as p,q as m,u as h,z as g}from"./index-C3AHYAm6.js";import{t as _}from"./main-BRunuMB5.js";var v=e(_(),1),y=c(`<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=c(`<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=c(`<span class=peach-health-summary-warn> <!> attention`),S=c(`<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=c(`<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=c(`<span class=peach-health-summary-ok>Your vault looks healthy.`),C=c(`<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=c(`<div class=peach-health-loading>Computing...`),T=c(`<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=c(`<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=c(`<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=c(`<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=c(`<div class=peach-health-section-body>`),A=c(`<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=c(`<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,c]=o(!1),[_,k]=o([]),[A,j]=o(!0),[F,L]=o({breached:!0,reused:!0,weak:!0,old:!0,passkeys:!0}),[R,z]=o(null),[B,V]=o(null),[H,U]=o(!1),[W,G]=o(null);p(async()=>{if(e.isPro){U(!0);try{let e=await n({type:`GET_ADVANCED_HEALTH_REPORT`});e.ok&&V(e.data??null)}finally{U(!1)}}});async function K(e){G(e);let t=await n({type:`INITIATE_PASSWORD_CHANGE`,payload:{id:e}});G(null),t.ok&&window.close()}let q=365*24*60*60*1e3,J=l(()=>e.entries.filter(e=>(e.breach??0)>0).sort((e,t)=>(t.breach??0)-(e.breach??0))),Y=l(()=>{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=l(()=>e.entries.filter(e=>e.type===`login`&&e.modifiedAt<Date.now()-q).sort((e,t)=>e.modifiedAt-t.modifiedAt)),Z=l(()=>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(){c(!0);let t=await n({type:`CHECK_ALL_BREACHES`});c(!1),t.ok&&e.onRefresh()}let $=l(()=>J().length+_().length+Y().length+X().length+Z().length);return[(()=>{var n=S(),o=n.firstChild,c=o.firstChild,l=o.nextSibling,f=l.firstChild,p=f.nextSibling,v=p.firstChild;v.firstChild;var k=p.nextSibling;return a(c,`click`,e.onBack,!0),g(l,u(m,{get when(){return t(()=>!!e.isPro)()&&H()},get children(){return y()}}),f),g(l,u(m,{get when(){return t(()=>!!(e.isPro&&!H()&&B()))()&&B().remediation.length>0},get children(){var e=b(),t=e.firstChild.firstChild.nextSibling,n=t.firstChild.nextSibling;return n.nextSibling,g(t,()=>B().vaultScore,n),g(e,u(r,{get each(){return B().remediation.slice(0,8)},children:e=>(()=>{var t=ee(),n=t.firstChild,r=n.firstChild,a=r.nextSibling,o=a.nextSibling.firstChild,s=n.nextSibling;return g(r,()=>e.title),g(a,()=>e.reasons.join(` · `)),s.$$click=()=>void K(e.id),g(s,()=>W()===e.id?`opening…`:`Change this password`),d(t=>{var n=`${Math.min(e.score,100)}%`,r=W()===e.id;return n!==t.e&&i(o,`width`,t.e=n),r!==t.t&&(s.disabled=t.t=r),t},{e:void 0,t:void 0}),t})()}),null),e}}),f),g(f,u(m,{get when(){return $()>0},get fallback(){return te()},get children(){var e=x(),t=e.firstChild,n=t.nextSibling;return n.nextSibling,g(e,$,t),g(e,()=>$()===1?`entry needs`:`entries need`,n),e}})),v.$$click=()=>void ie(),g(v,()=>s()?`checking...`:`Check all breaches now`,null),g(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(r,{get each(){return J()},children:t=>(()=>{var n=C(),r=n.firstChild,i=r.firstChild,a=i.nextSibling,o=r.nextSibling;return g(i,()=>t.title),g(a,()=>N(t.breach??0)),o.$$click=()=>e.onFixEntry(t),n})()})}}),null),g(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(m,{get when(){return!A()},get fallback(){return w()},get children(){return u(r,{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 g(r,()=>e.entries.length,i),g(a,()=>e.entries.map(e=>e.title).join(`, `)),o.$$click=()=>z(e.entries),t})()})}})}}),null),g(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(r,{get each(){return Y()},children:({entry:n,score:r})=>(()=>{var i=E(),a=i.firstChild,o=a.firstChild,s=o.nextSibling,c=s.firstChild.nextSibling,l=c.nextSibling.nextSibling;l.nextSibling;var u=a.nextSibling;return g(o,(()=>{var e=t(()=>!!n.url);return()=>e()?h(n.url):n.title})()),g(s,r,c),g(s,()=>ne(r),l),u.$$click=()=>e.onFixEntry(n),i})()})}}),null),g(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(r,{get each(){return X()},children:n=>{let r=Date.now()-n.modifiedAt;return(()=>{var i=D(),a=i.firstChild,o=a.firstChild,s=o.nextSibling;s.firstChild;var c=a.nextSibling;return g(o,(()=>{var e=t(()=>!!n.url);return()=>e()?h(n.url):n.title})()),g(s,()=>P(r),null),c.$$click=()=>e.onFixEntry(n),i})()}})}}),null),g(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(r,{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 c=r.nextSibling;return g(i,()=>t.entry.title),g(a,()=>t.status,o),g(a,()=>t.entry.rpId,s),g(a,()=>P(Date.now()-t.lastActivity),null),c.$$click=()=>e.onFixEntry(t.entry),n})()})}}),null),d(()=>v.disabled=s()),n})(),u(m,{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 n=A(),r=n.firstChild,i=r.firstChild,o=i.firstChild,s=o.nextSibling,c=i.nextSibling;return a(r,`click`,e.onToggle,!0),g(o,()=>e.count),g(s,()=>e.title),g(n,u(m,{get when(){return e.expanded},get children(){var n=k();return g(n,u(m,{get when(){return t(()=>!e.loading)()&&e.count>0},get fallback(){return u(m,{get when(){return!e.loading},get children(){var t=j();return g(t,()=>e.emptyMessage),t}})},get children(){return e.children}})),n}}),null),d(()=>c.classList.toggle(`is-expanded`,!!e.expanded)),n})()}s([`click`]);export{F as HealthView};