import"./chunk-QTnfLwEv.js";import{n as e}from"./index-7yDgay5u.js";import{r as t}from"./file-asset-object-store-Bvk_AjCv.js";import{i as n,o as r,t as i}from"./jsx-runtime-DHSfUA5-.js";import{P as a,s as o}from"./test.id-DxQrYxPk.js";import{t as s}from"./navigationService-BNBSAd9W.js";import{t as c}from"./PageHeader-CzIJsNRF.js";import{t as l}from"./useDiaryModel-BQGj9xs8.js";import{t as u}from"./CellList-UkuVgkhN.js";r();var d=i();function f({config:r}){let i=l(),f=a(s);return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(c,{title:e(`settings.sync.title`,`Cloud Sync`),showBack:!0}),(0,d.jsxs)(`main`,{className:n.S3SettingsPage.ManagementContent,"data-test-id":o.managementContent,children:[(0,d.jsx)(u,{title:e(`settings.sync.storage`,`Storage`),bordered:!0,testId:o.storageGroup,className:n.S3SettingsPage.Group,items:[{label:t(r.provider),right:{type:`value`,text:r.provider===`webdav`?r.url:r.bucket},testId:o.storageSummary,onClick:()=>f.navigate({path:`/settings/s3/storage`})}]}),(0,d.jsx)(u,{title:e(`settings.sync.content`,`Sync content`),bordered:!0,testId:o.syncContentGroup,className:n.S3SettingsPage.Group,items:p(i)}),(0,d.jsx)(u,{bordered:!0,className:n.Common.SectionGap,items:[{type:`action`,danger:!0,label:e(`settings.sync.turnOff`,`Turn off sync`),testId:o.deleteSync,onClick:()=>f.navigate({path:`/settings/s3/delete`})}]})]})]})}function p(t){let n=t.entries.filter(e=>!e.deletedAt),r=t.attachments.filter(e=>!e.deletedAt),i=new TextEncoder().encode(JSON.stringify({version:t.version,profile:t.profile,notebooks:t.notebooks,entries:n,attachments:r})).byteLength,a=r.reduce((e,t)=>e+t.size,0);return[{label:e(`settings.sync.database`,`Database`),right:{type:`value`,text:e(`settings.sync.databaseStats`,`{0} entries · {1}`,n.length,m(i))}},{label:e(`settings.sync.attachments`,`Attachments`),right:{type:`value`,text:e(`settings.sync.attachmentsStats`,`{0} files · {1}`,r.length,m(a))}}]}function m(e){if(e<1024)return`${e} B`;let t=[`KB`,`MB`,`GB`],n=e/1024,r=0;for(;n>=1024&&r<t.length-1;)n/=1024,r+=1;return`${new Intl.NumberFormat(globalThis.language||void 0,{maximumFractionDigits:n>=10?1:2}).format(n)} ${t[r]}`}export{f as SyncManagementPage};
//# sourceMappingURL=sync-management-DD4u4AKM.js.map