import{r as e}from"./chunk-QTnfLwEv.js";import{n as t}from"./index-7yDgay5u.js";import{i as n,o as r,t as i}from"./jsx-runtime-DHSfUA5-.js";import{P as a,R as o,s}from"./test.id-DxQrYxPk.js";import{n as c}from"./fileAssetService-gA4Q8V3n.js";import{t as l}from"./use-watch-event-Bmff5Oxc.js";import{t as u}from"./navigationService-BNBSAd9W.js";import{n as d}from"./appLockService-D-ij0gvy.js";import{t as f}from"./check-DqMliDjm.js";import{t as p}from"./copy-D1nqEVm3.js";import{o as m}from"./route-CPr17rXr.js";import{t as h}from"./useSuccessToast-CW8oLO3e.js";import{t as g}from"./HeaderLayoutPage-CDZOzzod.js";import{t as _}from"./useDialog-CjsjDZgz.js";import{n as v,t as y}from"./FormPage-B0BqbKo9.js";var b=e(r(),1),x=i();function S(){let e=a(c),r=a(o),i=a(d),S=a(u),C=_(),w=h();l(e.onDidChangeConfig);let T=e.getSyncConfig(),[E,D]=(0,b.useState)(!1),[O,k]=(0,b.useState)(!1);if(!T)return(0,x.jsx)(m,{to:`/settings/s3`,replace:!0});let A=T.recoveryKey,j=async()=>{if(A)try{await r.writeToClipboard(A),k(!0),w({message:t(`common.copied`,`Copied`),onDone:()=>k(!1)})}catch{k(!1)}},M=async()=>{if(i.enabled){C({title:t(`settings.sync.turnOff`,`Turn off sync`),message:t(`settings.sync.turnOff.appLockFirst`,`Authentication is on and uses your database encryption password. Turn off authentication first, then turn off sync.`),confirmLabel:t(`settings.sync.turnOff.goAppLock`,`Go to Authentication`),cancelLabel:t(`common.cancel`,`Cancel`),tone:`primary`,rootTestId:s.deleteAppLockDialog,confirmTestId:s.deleteAppLockConfirm,onConfirm:()=>S.navigate({path:`/settings/authentication`})});return}await e.clearSyncConfig()};return(0,x.jsx)(g,{rootClassName:n.Page.SurfaceRoot,contentClassName:n.WeuiForm.PageMain,pageTestId:s.page,contentTestId:s.deleteConfirm,header:{showBack:!0,tone:`surface`},children:(0,x.jsx)(y,{title:t(`settings.sync.turnOff`,`Turn off sync`),description:t(`settings.sync.turnOff.desc`,`After you turn off sync, this device stops syncing and its local sync settings are removed. Cloud data remains encrypted with the recovery key. Without a backup of the key, that data cannot be decrypted.`),check:A?{label:t(`settings.sync.key.backedUp`,`I have safely backed up this recovery key`),checked:E,testId:s.deleteBackedUp,onChange:D}:void 0,actions:[{label:t(`settings.sync.turnOff`,`Turn off sync`),variant:`warn`,testId:s.deleteConfirmAction,disabled:!!A&&!E,onClick:()=>void M()}],children:A&&(0,x.jsx)(v,{title:t(`settings.sync.recoveryKey`,`Recovery key`),children:(0,x.jsxs)(`div`,{className:n.RecoveryKey.Row,children:[(0,x.jsx)(`code`,{className:n.RecoveryKey.Code,"data-test-id":s.recoveryKeyValue,children:A}),(0,x.jsx)(`button`,{type:`button`,className:n.Button.Icon,"data-test-id":s.copyRecoveryKey,"aria-label":t(`common.copy`,`Copy`),onClick:()=>void j(),children:O?(0,x.jsx)(f,{size:18}):(0,x.jsx)(p,{size:18})})]})})})})}export{S as SettingsS3DeletePage};
//# sourceMappingURL=delete-Db2DLEe2.js.map