import{C as e,Dt as t,I as n,It as r,Q as i,S as a,T as o,Wt as s,X as c,Y as l,bt as u,cn as d,j as f,rn as p,w as m,x as h}from"./_plugin-vue_export-helper-BVhEvvHC.js";import{An as g}from"./src-CD6Jsigc.js";import{y as _}from"./TopMenu-BzlJqoxc.js";import{t as v}from"./circle-check-CXnxHmGD.js";import{t as y}from"./cloud-upload-BT3rY1pD.js";import{r as b}from"./axios-DSyjHw-i.js";import{h as x}from"./useApi-CROJJdhE-bFLQvr8j.js";import{t as S}from"./cloudDatabaseStore-eYEU_N3O.js";n(),u(),s();var C=[`title`,`aria-label`],w={class:`inline-flex h-4 w-4 items-center justify-center shrink-0`,"aria-hidden":`true`},T={key:2,class:`h-2 w-2 rounded-full bg-amber-400`},E=f({__name:`CloudSyncIndicator`,setup(n){let{t:s}=b({useScope:`global`}),u=S(),f=x(),E=h(()=>u.hasAccess),D=h(()=>u.status),O=h(()=>!!D.value?.cloudReachable),k=h(()=>u.isBackingUp),A=h(()=>!!D.value?.hasLocalChanges),j=h(()=>D.value?.lastBackupAt??null),M=t(Date.now()),N;function P(e){if(!e)return s(`settings.account.database.time.unknown`);let t=new Date(e).getTime();if(Number.isNaN(t))return s(`settings.account.database.time.unknown`);let n=Math.round((M.value-t)/1e3);if(n<45)return s(`settings.account.database.time.justNow`);for(let e of[{limit:3600,div:60,key:`minutes`},{limit:86400,div:3600,key:`hours`},{limit:604800,div:86400,key:`days`},{limit:2629800,div:604800,key:`weeks`},{limit:31557600,div:2629800,key:`months`},{limit:1/0,div:31557600,key:`years`}])if(n<e.limit){let t=Math.max(1,Math.round(n/e.div));return s(`settings.account.database.time.${e.key}`,{n:t},t)}return s(`settings.account.database.time.unknown`)}let F=h(()=>j.value?P(j.value):null),I=h(()=>k.value?{tone:`neutral`,label:s(`settings.account.database.indicator.backingUp`),title:null}:O.value?A.value?{tone:`warning`,label:s(`settings.account.database.indicator.notBackedUp`),title:F.value?s(`settings.account.database.indicator.lastBackupTitle`,{time:F.value}):null}:F.value?{tone:`ok`,label:s(`settings.account.database.indicator.backedUp`,{time:F.value}),title:null}:{tone:`neutral`,label:s(`settings.account.database.indicator.none`),title:null}:{tone:`offline`,label:s(`settings.account.database.indicator.offline`),title:null});function L(){f.push({name:`settings`,query:{tab:`database`}})}return l(()=>{u.ensureLoaded(),N=setInterval(()=>{M.value=Date.now()},3e4)}),c(()=>{N&&clearInterval(N)}),(t,n)=>E.value?(i(),o(`button`,{key:0,type:`button`,title:I.value.title??void 0,"aria-label":r(s)(`settings.account.database.indicator.ariaOpenSettings`),class:`group inline-flex items-center gap-1.5 rounded-full border border-white/5 bg-secondarybackground px-3 h-8 text-xs font-roboto font-medium text-text transition-colors hover:border-highlights/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-highlights/60`,onClick:L},[a(`span`,w,[k.value?(i(),e(r(g),{key:0,class:`h-3.5 w-3.5 animate-spin text-highlights`})):I.value.tone===`offline`?(i(),e(r(_),{key:1,class:`h-3.5 w-3.5 text-muted-foreground`})):I.value.tone===`warning`?(i(),o(`span`,T)):I.value.tone===`ok`?(i(),e(r(v),{key:3,class:`h-3.5 w-3.5 text-emerald-400`})):(i(),e(r(y),{key:4,class:`h-3.5 w-3.5 text-muted-foreground`}))]),a(`span`,{class:p([`truncate max-w-[14rem]`,{"text-muted-foreground":I.value.tone===`offline`||I.value.tone===`neutral`,"text-amber-400":I.value.tone===`warning`}])},d(I.value.label),3)],8,C)):m(``,!0)}});export{E as t};