@dominevo/addon-admin-ui 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/assets/{Addons-B_GcPZgg.js → Addons-DXj_703d.js} +3 -3
  3. package/dist/assets/{AdminPage-Cy0Hlqrw.js → AdminPage-CA4Sxydy.js} +1 -1
  4. package/dist/assets/{AdminSectionedPage-Cyf_oaxf.js → AdminSectionedPage-3XsaKUPh.js} +1 -1
  5. package/dist/assets/{AiProfiles-BwmLsTsc.js → AiProfiles-BPuugVHP.js} +1 -1
  6. package/dist/assets/{Archive-CMb_EiSA.js → Archive-Cs7NaNc_.js} +1 -1
  7. package/dist/assets/{BootstrapSettingsForm-g-uhhdRB.js → BootstrapSettingsForm-B7n4Tn8W.js} +1 -1
  8. package/dist/assets/{Build-eZuH-uBL.js → Build-D7v3yZ31.js} +1 -1
  9. package/dist/assets/{Calendars-DDbpjPON.js → Calendars-5ikY87Kt.js} +1 -1
  10. package/dist/assets/{Cluster-Da9vleGf.js → Cluster-CMcu7Iqn.js} +1 -1
  11. package/dist/assets/{CompositionBlockEditor-B6d7pAgH.js → CompositionBlockEditor-BP9BOpRr.js} +2 -2
  12. package/dist/assets/{CompositionEditorPage-Bjhg5ty4.js → CompositionEditorPage-D_4Dx_8C.js} +1 -1
  13. package/dist/assets/{Data-CoPymLmU.js → Data-Dlx9uZ0Q.js} +1 -1
  14. package/dist/assets/DeviceDetail-DJXx7Dh3.js +1 -0
  15. package/dist/assets/{Devices-Clym16mI.js → Devices-DJd001mb.js} +1 -1
  16. package/dist/assets/EmbedDevicePage-Cxe3_S-n.js +1 -0
  17. package/dist/assets/EmbedPlayerPage-BKq1BRg_.js +1 -0
  18. package/dist/assets/{FormBuilder-IsyNJFZJ.js → FormBuilder-BjcOGVVa.js} +1 -1
  19. package/dist/assets/{History-Cxu6A7W4.js → History-CqTLHyoj.js} +1 -1
  20. package/dist/assets/{Identity-BdVuMade.js → Identity-CELdhZ4o.js} +1 -1
  21. package/dist/assets/{InstancesTable-D73WwV7t.js → InstancesTable-DVnHkIbJ.js} +1 -1
  22. package/dist/assets/{IntegrationDetail-1zQcDDrK.js → IntegrationDetail-BlopkLuy.js} +1 -1
  23. package/dist/assets/{Integrations-BnFUd4mG.js → Integrations-BOr-rN3Z.js} +1 -1
  24. package/dist/assets/{Integrations-BeYh1QBu.js → Integrations-C8TECl9Z.js} +1 -1
  25. package/dist/assets/{Jobs-S9NgHLBc.js → Jobs-DnObAnQR.js} +1 -1
  26. package/dist/assets/{Library-B9aczX77.js → Library-sG9Ie6Ay.js} +1 -1
  27. package/dist/assets/{Locations-YV2IEkCM.js → Locations-Dh63x-8T.js} +1 -1
  28. package/dist/assets/{Logs-D_rTJW5O.js → Logs-B3LPrdqh.js} +1 -1
  29. package/dist/assets/{MaskShapeCanvas-QeHdurNy.js → MaskShapeCanvas-T6ZNfW4J.js} +1 -1
  30. package/dist/assets/{MotionZonesSettings-DqSgWBqG.js → MotionZonesSettings-B5KDfHoK.js} +1 -1
  31. package/dist/assets/{MyAccess-DIkZLp-T.js → MyAccess-WIUGe7rE.js} +1 -1
  32. package/dist/assets/{Network-Cnzu95Od.js → Network--neqNeoA.js} +1 -1
  33. package/dist/assets/{NewExportModal-Ci35Hza9.js → NewExportModal-D64AhGe8.js} +1 -1
  34. package/dist/assets/{NodeAddonsSettingsPanel-BrbWHDXZ.js → NodeAddonsSettingsPanel-Bc_UiSsk.js} +1 -1
  35. package/dist/assets/Notifications-I66jIXko.js +1 -0
  36. package/dist/assets/{Pipeline-qOg4XR2i.js → Pipeline-DX80qRVf.js} +1 -1
  37. package/dist/assets/{PrivacyMaskSettings-lyXsRvjs.js → PrivacyMaskSettings-CERwQtiu.js} +1 -1
  38. package/dist/assets/{SceneMonitorEditor-3X1N_Zzg.js → SceneMonitorEditor-DxTYd8U2.js} +1 -1
  39. package/dist/assets/{SessionsList-BBLFllCq.js → SessionsList-BoOCsi8N.js} +1 -1
  40. package/dist/assets/{Showroom-Dt4sqjQ4.js → Showroom-Dkom3it5.js} +1 -1
  41. package/dist/assets/{StorageLocationsTable-tjGQ6sFA.js → StorageLocationsTable-CujqHG2j.js} +1 -1
  42. package/dist/assets/{System-Co-lErWN.js → System-PnjU9olQ.js} +1 -1
  43. package/dist/assets/{TemplateEditorDialog-C_wnE2XS.js → TemplateEditorDialog-B_8g2CrL.js} +1 -1
  44. package/dist/assets/{Terminal-GGV-4LpZ.js → Terminal-BVqOTvEA.js} +1 -1
  45. package/dist/assets/{TrainingProviders-CTKgh54Z.js → TrainingProviders-5e1QS5zN.js} +1 -1
  46. package/dist/assets/{Viewer-o-5Yx_Z-.js → Viewer-CyLueECm.js} +1 -1
  47. package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-DET6LKET.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-Cc7iYWcG.js} +1 -1
  48. package/dist/assets/{ai-page.helpers-D3IdbvIN.js → ai-page.helpers-CiDsxXp3.js} +1 -1
  49. package/dist/assets/{assignment-candidates-BuZUcPHA.js → assignment-candidates-BfhoJg-T.js} +1 -1
  50. package/dist/assets/{auth-context-D7WimVyk.js → auth-context-CkfOTCG-.js} +1 -1
  51. package/dist/assets/{authed-media-CAMmxmIa.js → authed-media-C-zK1a1B.js} +1 -1
  52. package/dist/assets/{board-model-vUxvnXlS.js → board-model-BvqJSvTB.js} +1 -1
  53. package/dist/assets/{broker-oauth-popup-DoGeZWOR.js → broker-oauth-popup-B_GRcwxo.js} +1 -1
  54. package/dist/assets/{camera-block-model-wKfhIPM1.js → camera-block-model-QrJ_0XZY.js} +1 -1
  55. package/dist/assets/compat-muhdrMna.js +64 -0
  56. package/dist/assets/{device-integration-icon-DyMMisMz.js → device-integration-icon-D9fVWv4K.js} +1 -1
  57. package/dist/assets/device-picker-model-CYNi1aEm.js +1 -0
  58. package/dist/assets/{dist-cYE4Jx2-.js → dist-2ETbjdqB.js} +1 -1
  59. package/dist/assets/dist-B0ixn42U.js +1326 -0
  60. package/dist/assets/{format-Bo94cUyo.js → format-D43HvBR0.js} +1 -1
  61. package/dist/assets/{hostInit-BAJfwZtn.js → hostInit-BjOFEl3v.js} +1 -1
  62. package/dist/assets/{i18n-g8Fd49Vu.js → i18n-BHLBFC1-.js} +1 -1
  63. package/dist/assets/{icons-DFpDlM4_.js → icons-CNI0rnl8.js} +1 -1
  64. package/dist/assets/{index-BN3HzZ11.js → index-C1r-vzdu.js} +4 -4
  65. package/dist/assets/index-CyIIY_ZD.css +2 -0
  66. package/dist/assets/{linked-devices-model-BDA6pKP_.js → linked-devices-model-Dl4vHeXt.js} +1 -1
  67. package/dist/assets/{mf-entry-bootstrap-0-660bf7ef.js → mf-entry-bootstrap-0-64d22ef4.js} +2 -2
  68. package/dist/assets/mount-CYNi1aEm.js +1 -0
  69. package/dist/assets/{notification-rule-status-BcELEBcO.js → notification-rule-status-T3SwZb2I.js} +1 -1
  70. package/dist/assets/{player-overlays-CtaighPh.js → player-overlays-qzCoRsrQ.js} +1 -1
  71. package/dist/assets/remoteEntry-Dc97BJQ9.js +1 -0
  72. package/dist/assets/src-CJoX3s-1.js +1326 -0
  73. package/dist/assets/src-Cf1Uvi4o.js +289 -0
  74. package/dist/assets/{sso-popup-zoeFkFmc.js → sso-popup-CPavla3I.js} +1 -1
  75. package/dist/assets/{step-inspector-model-DX_ifTOn.js → step-inspector-model-CMrG9Xaa.js} +1 -1
  76. package/dist/assets/{use-scenes-feed-DGzhHlOE.js → use-scenes-feed-CosaOMpn.js} +1 -1
  77. package/dist/assets/{useAdminDeviceRemoval-Cgjyp11U.js → useAdminDeviceRemoval-bOibMOT6.js} +1 -1
  78. package/dist/assets/{useDevice-ukTZkHFj.js → useDevice-JbC1lVOL.js} +1 -1
  79. package/dist/assets/useEventInvalidation-CYNi1aEm.js +1 -0
  80. package/dist/assets/{useFaultTypeOptions-A-AeenGT.js → useFaultTypeOptions-BCjpEaI1.js} +1 -1
  81. package/dist/assets/{useNodeUrlSelection-DusZi3D9.js → useNodeUrlSelection-DBU1LRHP.js} +1 -1
  82. package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-MJWzvEFZ.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-BZ1YRJXZ.js} +2 -2
  83. package/dist/index.html +17 -17
  84. package/dist/server/addon.js +154 -29
  85. package/package.json +8 -8
  86. package/dist/assets/DeviceDetail-CMMwA8Es.js +0 -1
  87. package/dist/assets/EmbedDevicePage-D75EmreE.js +0 -1
  88. package/dist/assets/EmbedPlayerPage-CWNw4o1J.js +0 -1
  89. package/dist/assets/Notifications-CkrjKG7-.js +0 -1
  90. package/dist/assets/__vite-browser-external-DIbVKiho.js +0 -64
  91. package/dist/assets/device-picker-model-xzrEHV_a.js +0 -1
  92. package/dist/assets/dist-Dk8KbW2q.js +0 -1327
  93. package/dist/assets/index-UUDT8A1I.css +0 -2
  94. package/dist/assets/mount-xzrEHV_a.js +0 -1
  95. package/dist/assets/remoteEntry-DThl5dZH.js +0 -1
  96. package/dist/assets/src-CLFOv5WF.js +0 -1327
  97. package/dist/assets/src-Nh32OK3s.js +0 -299
  98. package/dist/assets/useEventInvalidation-xzrEHV_a.js +0 -1
@@ -1 +1 @@
1
- import{C as e,S as t}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Va as n,yt as r}from"./player-overlays-CtaighPh.js";import{Ma as i}from"./src-CLFOv5WF.js";import{Ms as a}from"./src-Nh32OK3s.js";import{f as o,i as s,l as c,n as l}from"./chunk-4ZMWKKQ3-BCeNTgXs.js";import{t as u}from"./useTranslation-uIxPZ_3N.js";import{et as d,it as f}from"./index-BN3HzZ11.js";import{t as p}from"./CompositionBlockEditor-B6d7pAgH.js";import{t as m}from"./AdminPage-Cy0Hlqrw.js";var h=`rounded-lg border border-border bg-surface p-4`,g=`new`;function _(){let{blockId:_}=o(),{t:v}=u(),y=c(),b=_===void 0||_===g,x=a({blockId:_??``},{enabled:!b}),S=e=>t(m,{icon:n,title:v(`compositionEditor.pageTitle`),children:e});if(b)return t(s,{to:`${d}&new=helper`,replace:!0});if(x.status===`success`&&x.data.state===`loaded`&&x.data.view!==null){let e=x.data.view;if(i(e.block)?.target.kind===`existing`){let n=e.state.kind===`answered`?e.state.state?.deviceId??null:null;if(n!==null)return S(t(`section`,{className:h,children:t(l,{className:`text-primary text-sm`,to:f(n),children:v(`compositionEditor.openOnDevice`)})}))}}return S(e(`section`,{className:`${h} flex flex-col gap-2`,children:[t(r,{variant:`ghost`,size:`sm`,onClick:()=>y(d),children:v(`compositionEditor.cancel`)}),t(p,{blockId:_??``})]}))}export{_ as CompositionEditorPage};
1
+ import{C as e,S as t}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Va as n,yt as r}from"./player-overlays-qzCoRsrQ.js";import{Ma as i}from"./src-CJoX3s-1.js";import{Ms as a}from"./src-Cf1Uvi4o.js";import{f as o,i as s,l as c,n as l}from"./chunk-4ZMWKKQ3-BCeNTgXs.js";import{t as u}from"./useTranslation-uIxPZ_3N.js";import{et as d,it as f}from"./index-C1r-vzdu.js";import{t as p}from"./CompositionBlockEditor-BP9BOpRr.js";import{t as m}from"./AdminPage-CA4Sxydy.js";var h=`rounded-lg border border-border bg-surface p-4`,g=`new`;function _(){let{blockId:_}=o(),{t:v}=u(),y=c(),b=_===void 0||_===g,x=a({blockId:_??``},{enabled:!b}),S=e=>t(m,{icon:n,title:v(`compositionEditor.pageTitle`),children:e});if(b)return t(s,{to:`${d}&new=helper`,replace:!0});if(x.status===`success`&&x.data.state===`loaded`&&x.data.view!==null){let e=x.data.view;if(i(e.block)?.target.kind===`existing`){let n=e.state.kind===`answered`?e.state.state?.deviceId??null:null;if(n!==null)return S(t(`section`,{className:h,children:t(l,{className:`text-primary text-sm`,to:f(n),children:v(`compositionEditor.openOnDevice`)})}))}}return S(e(`section`,{className:`${h} flex flex-col gap-2`,children:[t(r,{variant:`ghost`,size:`sm`,onClick:()=>y(d),children:v(`compositionEditor.cancel`)}),t(p,{blockId:_??``})]}))}export{_ as CompositionEditorPage};
@@ -1,2 +1,2 @@
1
- import{C as e,K as t,R as n,S as r,V as i,Y as a,et as o,o as s,x as c}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{$i as l,$n as u,Ar as d,Co as f,D as p,Da as m,Ea as h,En as g,Gi as _,Ia as v,Lr as y,Ri as b,Tr as x,X as S,Xi as C,_a as w,_n as T,_t as E,at as D,br as O,bt as k,da as A,fo as ee,ht as j,ii as te,io as ne,ir as M,la as re,mi as ie,oi as N,or as ae,pr as P,pt as oe,ri as se,uo as ce,wr as le,xn as ue,xo as F,xt as I,yt as L}from"./player-overlays-CtaighPh.js";import{Ki as de}from"./src-CLFOv5WF.js";import{t as fe}from"./chevron-down-CBb-F8DT.js";import{c as pe}from"./terminal-BncJ-1sF.js";import{t as me}from"./circle-slash-Duh934sZ.js";import{n as he,t as ge}from"./database-zap-DHuELz_w.js";import{t as _e}from"./hard-drive-download-C6N6tovA.js";import{$ as ve,$a as R,$i as z,Am as ye,Gr as be,Ho as xe,Im as B,Jr as V,Nr as Se,Pa as Ce,Qa as we,X as Te,Yr as Ee,Za as H,_i as De,_s as Oe,aa as U,as as ke,au as Ae,cs as je,cu as Me,ds as Ne,du as Pe,ea as W,et as Fe,fs as Ie,fu as Le,gi as Re,gs as ze,hi as Be,hs as Ve,ia as G,is as He,iu as Ue,jr as We,kr as Ge,ls as Ke,lu as qe,mm as Je,ms as Ye,mu as Xe,na as Ze,os as Qe,ou as $e,pc as et,ps as tt,pu as nt,qr as rt,ra as K,sm as it,ss as at,st as q,su as ot,ta as J,us as st,uu as ct,vi as lt,vs as ut,xm as dt,ys as ft}from"./src-Nh32OK3s.js";import{i as pt,p as mt}from"./chunk-4ZMWKKQ3-BCeNTgXs.js";import{t as Y}from"./i18n-g8Fd49Vu.js";import{t as X}from"./useTranslation-uIxPZ_3N.js";import"./mount-xzrEHV_a.js";import{$t as ht,A as gt,N as _t}from"./index-BN3HzZ11.js";import{t as vt}from"./AdminSectionedPage-Cyf_oaxf.js";import{n as yt}from"./authed-media-CAMmxmIa.js";import{t as Z}from"./format-size-DIxKXxtj.js";import{t as bt}from"./StorageLocationsTable-tjGQ6sFA.js";import{n as xt}from"./InstancesTable-D73WwV7t.js";import{t as St}from"./AdminPage-Cy0Hlqrw.js";function Ct(){return r(St,{embedded:!0,children:r(bt,{})})}o();var wt={settings:{labelKey:`helpers.backupDatabases.settings.label`,descriptionKey:`helpers.backupDatabases.settings.description`,shortKey:`helpers.backupDatabases.settings.short`},events:{labelKey:`helpers.backupDatabases.events.label`,descriptionKey:`helpers.backupDatabases.events.description`,shortKey:`helpers.backupDatabases.events.short`},history:{labelKey:`helpers.backupDatabases.history.label`,descriptionKey:`helpers.backupDatabases.history.description`,shortKey:`helpers.backupDatabases.history.short`}},Tt=Object.keys(wt),Et=[`settings`];function Dt(){return Y.t(`helpers.backupDatabases.notCreated`)}function Ot(e){return Y.t(wt[e].labelKey)}function kt(e){return Y.t(wt[e].shortKey)}function At(e){return Y.t(wt[e].descriptionKey)}function jt(e){let t=new Set(e);return Tt.filter(e=>t.has(e))}function Mt(e){return e!==void 0&&e.length>0?jt(e):Et}function Nt(e){return jt(e)}function Pt(e,t){return t===void 0||!t.answered?`unknown`:t.databases.includes(e)?`present`:`absent`}function Ft(e,t,n){return Pt(e,t)===`absent`&&!n.has(e)}function It(e,t){let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n}function Lt(e){return!e.includes(`settings`)}function Rt(e){return{databases:[...Nt(e)]}}function zt(e,t){return e!==void 0&&e.length>0?jt(e):t!==void 0&&t.length>0?jt(t.map(e=>e.databaseId??`settings`)):Et}function Q({databases:e}){return r(`span`,{className:`text-xs font-medium uppercase tracking-wide text-foreground-muted`,"data-testid":`backup-database-badges`,children:e.map(e=>kt(e)).join(` · `)})}var Bt=[[`backup`,`listDestinations`]],Vt=[`backup`,`listArchives`];function Ht({destinationId:i,restoreSupported:o,onOpenRestoreWizard:c}){let{t:l}=X(),u=s(),d=j(),{data:f,isLoading:p,isError:m}=st({destinationId:i}),h=f??[],g=ke({onSuccess:()=>{u.invalidateQueries({queryKey:[[...Vt]]}),u.invalidateQueries({queryKey:Bt})}}),v=n(async e=>{await d({title:l(`backup.archiveList.deleteThisArchive`,`Delete this archive?`),message:l(`backup.archiveList.permanentlyDeletesAndFrees`,`Permanently deletes "{{value1}}" and frees {{value2}}.`,{value1:e.label??e.id,value2:Z(e.sizeBytes)}),confirmLabel:l(`common.delete`,`Delete`),variant:`danger`})&&g.mutate({destinationId:i,backupId:e.id})},[d,i,g,l]),[y,b]=a(null),x=n(async e=>{b(e.id);try{let t=await yt(Ut(i,e.id)),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=`${e.label??e.id}.tar.gz${e.encryption===void 0?``:`.csbk`}`,document.body.appendChild(r),r.click(),r.remove(),URL.revokeObjectURL(n)}finally{b(null)}},[i]),S=t(()=>[...h].toSorted((e,t)=>t.createdAt-e.createdAt),[h]);return p?r(`div`,{className:`text-xs text-foreground-subtle animate-pulse py-2`,children:l(`backup.archiveList.loadingArchives`,`Loading archives…`)}):m?r(`div`,{className:`text-xs text-danger py-2`,children:l(`backup.archiveList.failedToReadManifestFor`,`Failed to read manifest for this destination`)}):S.length===0?r(`div`,{className:`text-xs text-foreground-subtle italic py-2`,children:l(`backup.archiveList.noArchivesAtThisDestination`,`No archives at this destination yet.`)}):r(V,{columns:[{mobile:`primary`,key:`when`,header:l(`backup.archiveList.when`,`When`),sortValue:e=>e.createdAt,render:e=>r(`span`,{className:`tabular-nums`,children:Wt(e.createdAt)})},{mobile:`detail`,key:`label`,header:l(`backup.archiveList.label`,`Label`),sortValue:e=>e.label??null,render:t=>e(`span`,{className:`inline-flex items-center gap-1`,children:[t.encryption!==void 0&&r(se,{className:`h-3 w-3 text-success`,"aria-label":l(`backup.archiveList.encryptedRestoreNeedsBackupKey`,`encrypted — restore needs backup key {{keyId}}`,{keyId:t.encryption.keyId})}),t.label??r(`span`,{className:`text-foreground-subtle italic`,children:`—`})]})},{mobile:`hidden`,key:`databases`,header:l(`backup.archiveList.databases`,`Databases`),nowrap:!1,notSortableReason:`Database badges`,render:e=>r(Q,{databases:Mt(e.databases)})},{mobile:`hidden`,key:`includes`,header:l(`backup.archiveList.files`,`Files`),nowrap:!1,notSortableReason:`Location list`,render:e=>e.locations.length>0?r(`span`,{className:`text-foreground-subtle`,children:e.locations.join(`, `)}):r(`span`,{className:`text-foreground-subtle italic`,children:l(`common.none`)})},{mobile:`detail`,key:`size`,header:l(`backup.archiveList.size`,`Size`),align:`right`,sortValue:e=>e.sizeBytes,render:e=>r(`span`,{className:`tabular-nums`,children:Z(e.sizeBytes)})},{mobile:`keep`,key:`actions`,header:``,align:`right`,notSortableReason:`Actions`,render:t=>e(`span`,{className:`flex items-center justify-end gap-1`,children:[e(L,{variant:`ghost`,size:`sm`,onClick:()=>{x(t)},disabled:y===t.id,title:l(`backup.archiveList.downloadArchive`,`Download archive`),children:[y===t.id?r(N,{className:`h-3 w-3 animate-spin`}):r(_,{className:`h-3 w-3`}),l(`backup.archiveList.download`,`Download`)]}),o&&c&&e(L,{variant:`ghost`,size:`sm`,onClick:()=>c({destinationId:i,archiveId:t.id}),title:l(`backup.archiveList.restoreFromThisArchive`,`Restore from this archive`),children:[r(P,{className:`h-3 w-3`}),l(`backup.archiveList.restore`,`Restore`)]}),r(Je,{variant:`ghost`,size:`sm`,icon:ue,"aria-label":l(`backup.archiveList.delete`,`Delete {{value1}}`,{value1:t.label??t.id}),disabled:g.isPending,onClick:()=>{v(t)}})]})}],rows:S,rowKey:e=>e.id,minWidthPx:760,emptyMessage:l(`backup.archiveList.noArchivesAtThisDestination`,`No archives at this destination yet.`)})}function Ut(e,t){return D(`/api/backup/download/${encodeURIComponent(e)}/${encodeURIComponent(t)}`)}function Wt(e){return new Date(e).toLocaleString(void 0,{day:`2-digit`,month:`short`,year:`numeric`,hour:`2-digit`,minute:`2-digit`})}o();var Gt=[[`backup`,`listSchedules`]];function Kt({onEdit:i,onOpenRestoreWizard:o}){let{t:c}=X(),{data:l,isLoading:u,isError:d,error:f,refetch:p}=Ye(),m=l??[],h=Ie().data??[],g=t(()=>{let e=new Map;for(let t of h)e.set(t.id,t);return e},[h]),[_,y]=a(null),b=n(e=>{y(t=>t===e?null:e)},[]),x=s(),C=ft(),[w,T]=a({}),[E,D]=a(null),O=n((e,t)=>{T(n=>({...n,[e]:{...n[e],...t}}))},[]),k=t(()=>Jt(m,w),[m,w]),A=k.some(e=>e.retentionCount===null),ee=n(()=>{T({}),D(null)},[]),j=n(()=>{A||k.length===0||(D(null),Promise.all(k.map(e=>C.mutateAsync({...Qt(e.row),enabled:e.enabled,retentionCount:e.retentionCount??e.row.retentionCount}))).then(()=>(T({}),x.invalidateQueries({queryKey:Gt}))).catch(e=>{D(e instanceof Error?e.message:String(e)),x.invalidateQueries({queryKey:Gt})}))},[k,A,C,x]),te=t(()=>Yt({destById:g,expandedId:_,onToggleExpand:b,onEdit:i,draft:w,onDraft:O,saving:C.isPending,onSave:j,onDiscard:ee}),[g,_,b,i,w,O,C.isPending,j,ee]);return u?e(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle animate-pulse`,children:[r(N,{className:`h-3.5 w-3.5 animate-spin`}),c(`backup.backupEntriesTable.loadingBackupEntries`,`Loading backup entries…`)]}):d?r(H,{title:c(`backup.backupEntriesTable.failedToLoadBackupEntries`,`Failed to load backup entries`),message:f instanceof Error?f.message:c(`backup.backupEntriesTable.unknownError`,`Unknown error`),onRetry:()=>void p()}):m.length===0?r(Ce,{icon:v,title:c(`backup.backupEntriesTable.noBackupEntriesYet`,`No backup entries yet`),description:c(`backup.backupEntriesTable.createOneToScheduleBackups`,`Create one to schedule backups across one or more storage locations.`)}):e(`div`,{className:`space-y-2`,children:[r(V,{columns:te,rows:m,rowKey:e=>e.id,minWidthPx:980,maxBodyHeight:Ee,emptyMessage:c(`backup.backupEntriesTable.noBackupEntriesYet`,`No backup entries yet`),onRowClick:e=>i(e),sheetOpenLabel:c(`backup.backupEntriesTable.editEntry`,`Edit entry`),isExpanded:e=>e.id===_,renderExpanded:e=>r(nn,{row:e,destById:g,...o?{onOpenRestoreWizard:o}:{}})}),E!==null&&r(`p`,{role:`alert`,className:`text-xs text-danger`,children:E}),r(S,{pendingCount:k.length,saving:C.isPending,onSave:j,onDiscard:ee,...A?{problem:c(`backup.backupEntriesTable.retentionInvalid`,`Retention must be a whole number of at least 1.`)}:{}})]})}function qt(e){let t=Number.parseInt(e,10);return Number.isNaN(t)||t<1?null:t}function Jt(e,t){let n=[];for(let r of e){let e=t[r.id];if(e===void 0)continue;let i=e.enabled??r.enabled,a=e.retention===void 0?r.retentionCount:qt(e.retention);(i!==r.enabled||a!==r.retentionCount)&&n.push({row:r,enabled:i,retentionCount:a})}return n}function Yt(t){return[{mobile:`keep`,key:`expand`,header:``,width:`w-8`,nowrap:!0,notSortableReason:`Expand control`,render:e=>{let n=t.expandedId===e.id;return r(Je,{variant:`ghost`,size:`sm`,icon:n?fe:h,"aria-label":n?Y.t(`backup.backupEntriesTable.hideArchives`,`Hide archives`):Y.t(`backup.backupEntriesTable.showArchives`,`Show archives`),"aria-expanded":n,onClick:n=>{n.stopPropagation(),t.onToggleExpand(e.id)}})}},{mobile:`primary`,key:`entry`,header:Y.t(`backup.backupEntriesTable.entry`,`Entry`),sortValue:e=>e.label,render:t=>e(`span`,{className:`flex min-w-0 flex-col`,children:[r(`span`,{className:`truncate font-medium text-foreground`,children:t.label||Y.t(`backup.backupEntriesTable.unnamed`,`(unnamed)`)}),t.lastRunAt!==void 0&&r(`span`,{className:`text-[10px] text-foreground-subtle`,children:Y.t(`backup.backupEntriesTable.lastRun`,{when:new Date(t.lastRunAt).toLocaleString()})})]})},{mobile:`keep`,key:`enabled`,header:Y.t(`backup.backupEntriesTable.enabled`,`Enabled`),width:`w-20`,nowrap:!0,sortValue:e=>+!!e.enabled,render:e=>r(`span`,{onClick:e=>e.stopPropagation(),children:r($t,{row:e,checked:t.draft[e.id]?.enabled??e.enabled,disabled:t.saving,onChange:n=>t.onDraft(e.id,{enabled:n})})})},{mobile:`sheet`,key:`databases`,header:Y.t(`backup.backupEntriesTable.backsUp`,`Backs up`),nowrap:!1,notSortableReason:`Database badges`,render:e=>r(Q,{databases:Mt(e.databases)})},{mobile:`sheet`,key:`locations`,header:Y.t(`backup.backupEntriesTable.locations`,`Locations`),nowrap:!1,notSortableReason:`Location chips`,render:e=>r(Xt,{row:e,destById:t.destById})},{mobile:`sheet`,key:`retention`,header:Y.t(`backup.backupEntriesTable.retention`,`Retention`),width:`w-24`,nowrap:!0,sortValue:e=>e.retentionCount,render:e=>r(`span`,{onClick:e=>e.stopPropagation(),children:r(en,{row:e,value:t.draft[e.id]?.retention??String(e.retentionCount),disabled:t.saving,onChange:n=>t.onDraft(e.id,{retention:n}),onSave:t.onSave,onDiscard:t.onDiscard})})},{mobile:`detail`,key:`schedule`,header:Y.t(`backup.backupEntriesTable.schedule`,`Schedule`),width:`w-48`,nowrap:!0,sortValue:e=>e.cron,render:e=>r(Zt,{row:e})},{mobile:`keep`,key:`actions`,header:``,align:`right`,nowrap:!0,notSortableReason:`Actions`,render:e=>r(`span`,{onClick:e=>e.stopPropagation(),children:r(tn,{row:e,onEdit:()=>t.onEdit(e)})})}]}function Xt({row:e,destById:t}){let{t:n}=X();return e.locationIds.length===0?r(`span`,{className:`text-[11px] italic text-danger`,children:n(`backup.backupEntriesTable.noLocations`,`No locations`)}):r(`span`,{className:`flex flex-wrap gap-1`,children:e.locationIds.map(e=>r(`span`,{className:`inline-flex items-center rounded border border-border bg-background px-1.5 py-0.5 text-[10px] text-foreground`,title:e,children:t.get(e)?.displayName??e},e))})}function Zt({row:t}){let{t:n}=X(),i=t.cron.trim().length>0;return e(`span`,{className:`flex flex-row items-center gap-1.5 sm:flex-col sm:items-start sm:gap-0.5`,children:[e(`span`,{className:`inline-flex items-center gap-1`,children:[r(v,{className:`h-3 w-3 text-foreground-subtle`}),r(`span`,{className:`font-mono text-[11px] text-foreground`,children:i?t.cron:n(`backup.backupEntriesTable.manual`,`Manual`)})]}),i&&t.nextRunAt!==void 0&&r(`span`,{className:`text-[10px] text-foreground-subtle`,children:Y.t(`common.nextRun`,{when:new Date(t.nextRunAt).toLocaleString()})})]})}function Qt(e){return{id:e.id,label:e.label,cron:e.cron,locationIds:[...e.locationIds],retentionCount:e.retentionCount,...e.dataSources?{dataSources:[...e.dataSources]}:{},...e.databases?{databases:[...e.databases]}:{}}}function $t({row:e,checked:t,disabled:n,onChange:i}){let{t:a}=X();return r(`label`,{className:`inline-flex cursor-pointer items-center`,children:r(F,{className:`accent-primary`,checked:t,disabled:n,onChange:e=>i(e.target.checked),"aria-label":a(`backup.backupEntriesTable.enable`,`Enable {{value1}}`,{value1:e.label||e.id})})})}function en({row:e,value:t,disabled:n,onChange:i,onSave:a,onDiscard:o}){let{t:s}=X();return r(`div`,{className:`flex items-center gap-1`,children:r(I,{type:`number`,min:1,max:1e3,value:t,disabled:n,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`?a():e.key===`Escape`&&o()},className:`w-16`,"aria-label":s(`backup.backupEntriesTable.retentionFor`,`Retention for {{value1}}`,{value1:e.label||e.id})})})}function tn({row:t,onEdit:n}){let{t:i}=X(),a=dt(),o=s(),c=j(),l=Qe({onSuccess:()=>{o.invalidateQueries({queryKey:Gt})}}),u=ut({onMutate:()=>{o.invalidateQueries({queryKey:[[`backup`,`listRuns`]]})},onSuccess:()=>{o.invalidateQueries({queryKey:[[`backup`,`listArchives`]]}),o.invalidateQueries({queryKey:[[`backup`,`listDestinations`]]}),o.invalidateQueries({queryKey:[[`backup`,`listRuns`]]})}}),f=()=>{t.locationIds.length!==0&&u.mutate({destinations:[...t.locationIds],...t.dataSources&&t.dataSources.length>0?{locations:[...t.dataSources]}:{},label:t.label,retentionCount:t.retentionCount,databases:[...Mt(t.databases)]})},p=async()=>{await c({title:i(`backup.backupEntriesTable.deleteBackupEntry`,`Delete backup entry?`),message:i(`backup.backupEntriesTable.willStopRunningExistingArchives`,`"{{value1}}" will stop running. Existing archives are kept.`,{value1:t.label||t.id}),confirmLabel:i(`common.delete`,`Delete`),variant:`warning`})&&l.mutate({id:t.id})};return e(`span`,{className:`flex items-center justify-end gap-1.5`,children:[e(L,{size:`sm`,type:`button`,onClick:f,disabled:u.isPending||t.locationIds.length===0,title:i(`backup.backupEntriesTable.runThisEntryNow`,`Run this entry now`),children:[u.isPending?r(N,{className:`h-3 w-3 animate-spin`}):r(x,{className:`h-3 w-3`}),a?r(`span`,{className:`sr-only`,children:i(`backup.backupEntriesTable.runNow`,`Run now`)}):i(`backup.backupEntriesTable.runNow`,`Run now`)]}),r(Je,{variant:`ghost`,size:`sm`,icon:d,"aria-label":i(`backup.backupEntriesTable.edit`,`Edit {{value1}}`,{value1:t.label||t.id}),onClick:n}),r(Je,{variant:`ghost`,size:`sm`,icon:ue,"aria-label":i(`backup.backupEntriesTable.delete`,`Delete {{value1}}`,{value1:t.label||t.id}),disabled:l.isPending,onClick:()=>{p()}})]})}function nn({row:t,destById:n,onOpenRestoreWizard:i}){let{t:a}=X();return e(`div`,{className:`space-y-4 rounded-lg border border-border bg-background/30 px-4 py-3`,children:[r(`p`,{className:`text-[11px] font-medium text-foreground-subtle`,children:a(`backup.backupEntriesTable.archivesFor`,{name:t.label||t.id})}),t.locationIds.length===0&&r(`p`,{className:`text-xs italic text-foreground-subtle`,children:a(`backup.backupEntriesTable.thisEntryHasNoLocations`,`This entry has no locations selected.`)}),t.locationIds.map(t=>e(`div`,{className:`space-y-1.5`,children:[r(`div`,{className:`text-[11px] font-medium text-foreground-subtle`,children:n.get(t)?.displayName??t}),r(Ht,{destinationId:t,restoreSupported:n.get(t)?.restoreSupported??!0,...i?{onOpenRestoreWizard:i}:{}})]},t))]})}function rn({selected:t,onChange:n,disabled:i=!1,testId:a=`backup-databases`}){let{t:o}=X(),s=Ne().data,c=t.size>0&&Lt(jt(t)),l=t.size===0?`Pick at least one.`:c?`Snapshots only: configuration and files are not part of this backup.`:null;return r(q,{label:o(`backup.backupDatabasePicker.whatToBackUp`,`What to back up`),required:!0,...l===null?{}:{description:l},children:r(`div`,{className:`divide-y divide-border rounded border border-border bg-background`,"data-testid":a,children:Tt.map(o=>{let c=Pt(o,s),l=i||Ft(o,s,t);return e(`label`,{className:`flex items-start gap-2 px-3 py-2 text-xs ${l?`opacity-60`:`cursor-pointer hover:bg-primary/5`}`,children:[r(F,{checked:t.has(o),disabled:l,onChange:()=>n(It(t,o)),"data-testid":`${a}-${o}`}),e(`span`,{className:`min-w-0 flex-1`,children:[r(`span`,{className:`flex flex-wrap items-center gap-1.5 text-foreground`,children:Ot(o)}),r(`span`,{className:`block text-[11px] text-foreground-subtle`,children:c===`absent`?Dt():At(o)})]})]},o)})})})}o();function an({onClose:t}){let{t:n}=X(),i=s(),[o,c]=a(new Set(Et)),l=ut({onMutate:()=>{i.invalidateQueries({queryKey:[[`backup`,`listRuns`]]})},onSuccess:()=>{i.invalidateQueries({queryKey:[[`backup`,`listArchives`]]}),i.invalidateQueries({queryKey:[[`backup`,`listDestinations`]]}),i.invalidateQueries({queryKey:[[`backup`,`listRuns`]]}),t()}});return r(z,{open:!0,onOpenChange:e=>!e&&t(),children:e(J,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[e(G,{children:[r(U,{children:n(`backup.backupNowDialog.backUpNow`,`Back up now`)}),r(`p`,{className:`text-xs text-foreground-subtle`,children:n(`backup.backupNowDialog.runsOnceAndWritesThe`,`Runs once and writes the archive to every enabled backup location.`)})]}),r(W,{children:e(`div`,{className:`p-4`,children:[r(rn,{selected:o,onChange:c,disabled:l.isPending,testId:`backup-now-databases`}),l.error&&r(`p`,{role:`alert`,className:`pt-2 text-xs text-danger`,children:l.error.message})]})}),e(K,{children:[r(L,{variant:`outline`,size:`sm`,onClick:t,children:n(`common.cancel`,`Cancel`)}),e(L,{size:`sm`,onClick:()=>{o.size!==0&&l.mutate(Rt(o))},disabled:o.size===0||l.isPending,"data-testid":`backup-now-run`,children:[l.isPending?r(N,{className:`h-3.5 w-3.5 animate-spin`}):r(x,{className:`h-3.5 w-3.5`}),n(`backup.backupNowDialog.backUpNow`,`Back up now`)]})]})]})})}o();function on(e){return e===null?`—`:new Date(e).toLocaleString()}function sn(e){let t=new Blob([`${e.secretKey}\n`],{type:`text/plain`}),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=`camstack-backup-key-${e.keyId}.txt`,r.click(),URL.revokeObjectURL(n)}function cn({revealed:t,onDone:n}){let{t:i}=X(),[o,s]=a(!1),[c,u]=a(!1);return r(z,{open:!0,onOpenChange:e=>!e&&o&&n(),children:e(J,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,className:`border-danger/40`,"aria-labelledby":`backup-key-title`,children:[r(G,{children:r(U,{id:`backup-key-title`,children:i(`backup.encryptionCard.yourKey`,{keyId:t.keyId})})}),e(W,{className:`space-y-3`,children:[e(`p`,{className:`flex items-start gap-2 rounded-md border border-danger/40 bg-danger/10 p-2 text-xs text-foreground`,children:[r(T,{className:`mt-0.5 h-4 w-4 shrink-0 text-danger`}),r(`span`,{children:i(`backup.backupEncryptionCard.thisKeyIsShownOnly`,`This key is shown only once. Dominevo does not keep it — not the hub, not its database, not its backups. Without it, an encrypted backup cannot be restored by anyone, including you. Store it in a password manager or print it, away from this server.`)})]}),r(`div`,{className:`break-all rounded-md border border-border bg-background p-2 font-mono text-xs text-foreground select-all`,children:t.secretKey}),e(`div`,{className:`flex flex-wrap gap-2`,children:[e(L,{size:`sm`,variant:`outline`,onClick:()=>{navigator.clipboard?.writeText(t.secretKey).then(()=>u(!0))},children:[r(l,{className:`mr-1 h-3.5 w-3.5`}),c?i(`backup.backupEncryptionCard.copied`,`Copied`):i(`common.copy`,`Copy`)]}),e(L,{size:`sm`,variant:`outline`,onClick:()=>sn(t),children:[r(_,{className:`mr-1 h-3.5 w-3.5`}),i(`backup.backupEncryptionCard.downloadAsFile`,`Download as file`)]})]}),e(`label`,{className:`flex items-center gap-2 text-xs text-foreground`,children:[r(F,{checked:o,onChange:e=>s(e.target.checked),className:`accent-primary`}),i(`backup.backupEncryptionCard.iHaveStoredThisKey`,`I have stored this key somewhere safe, off this server.`)]})]}),r(K,{children:r(L,{size:`sm`,disabled:!o,onClick:n,children:i(`backup.backupEncryptionCard.iHaveStoredIt`,`I have stored it`)})})]})})}function ln(){let{t}=X(),n=je(),i=Oe(),o=at(),s=j(),[l,u]=a(null),[d,f]=a(null),p=n.data?.enabled??!1,m=n.data?.active??null,h=(n.data?.keys??[]).filter(e=>e.retiredAt!==null),g=async()=>{if(await s({title:p?t(`backup.backupEncryptionCard.replaceTheBackupKey`,`Replace the backup key`):t(`backup.backupEncryptionCard.encryptBackups`,`Encrypt backups`),message:p?t(`backup.backupEncryptionCard.aNewKeyIsGenerated`,`A new key is generated and shown once; new backups are encrypted to it. Older backups keep needing the key they were made with — keep that one too.`):t(`backup.backupEncryptionCard.aBackupKeyIsGenerated`,`A backup key is generated and shown once. Every new backup is encrypted to it, and restoring one will ask for it. Existing backups stay as they are.`),confirmLabel:p?t(`backup.backupEncryptionCard.generateANewKey`,`Generate a new key`):t(`backup.backupEncryptionCard.generateTheKey`,`Generate the key`),variant:`warning`})){f(null);try{let e=await i.mutateAsync({});u({keyId:e.keyId,secretKey:e.secretKey})}catch(e){f(e instanceof Error?e.message:String(e))}}},_=async()=>{if(await s({title:t(`backup.backupEncryptionCard.turnBackupEncryptionOff`,`Turn backup encryption off`),message:t(`backup.backupEncryptionCard.newBackupsWillBeWritten`,`New backups will be written unencrypted. Existing encrypted backups still need their key to be restored.`),confirmLabel:t(`backup.backupEncryptionCard.turnOff`,`Turn off`),variant:`danger`})){f(null);try{await o.mutateAsync({}),n.refetch()}catch(e){f(e instanceof Error?e.message:String(e))}}};return e(`div`,{className:`space-y-2 rounded-lg border border-border bg-surface p-4`,children:[e(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[e(`div`,{className:`flex items-center gap-2`,children:[p?r(se,{className:`h-4 w-4 text-success`}):r(te,{className:`h-4 w-4 text-foreground-subtle`}),r(`h2`,{className:`text-sm font-semibold text-foreground`,children:t(`backup.backupEncryptionCard.encryption`,`Encryption`)}),r(`span`,{className:`text-xs text-foreground-subtle`,children:p&&m!==null?t(`backup.backupEncryptionCard.onKeySince`,`On — key {{keyId}}, since {{value2}}`,{keyId:m.keyId,value2:on(m.createdAt)}):t(`backup.backupEncryptionCard.offBackupsAreNotEncrypted`,`Off — backups are not encrypted`)})]}),r(`div`,{className:`flex gap-2`,children:p?e(c,{children:[r(L,{size:`sm`,variant:`outline`,disabled:i.isPending,onClick:()=>void g(),children:t(`backup.backupEncryptionCard.replaceKey`,`Replace key`)}),r(L,{size:`sm`,variant:`outline`,disabled:o.isPending,onClick:()=>void _(),children:t(`backup.backupEncryptionCard.turnOff`,`Turn off`)})]}):r(L,{size:`sm`,disabled:i.isPending,onClick:()=>void g(),children:t(`backup.backupEncryptionCard.enableEncryption`,`Enable encryption`)})})]}),r(`p`,{className:`text-xs text-foreground-subtle`,children:t(`backup.backupEncryptionCard.archivesAreEncryptedOnThis`,`Archives are encrypted on this server before they reach any destination. The server keeps only a public key, so it can encrypt scheduled backups but cannot decrypt them — only your backup key can. Covers the database snapshot, addon data (HomeKit pairing, Matter fabric, Tailscale state) and TLS.`)}),h.length>0&&e(`div`,{className:`text-xs`,children:[r(`p`,{className:`text-foreground-subtle`,children:t(`backup.backupEncryptionCard.olderKeysBackupsMadeWith`,`Older keys (backups made with them still need them):`)}),r(`ul`,{className:`font-mono text-foreground`,children:h.map(t=>e(`li`,{children:[t.keyId,` · `,on(t.createdAt),` → `,on(t.retiredAt)]},t.keyId))})]}),d!==null&&r(`p`,{className:`text-xs text-danger`,children:d}),l!==null&&r(cn,{revealed:l,onDone:()=>{u(null),n.refetch()}})]})}o();var un=[{id:`manual`,labelKey:`backup.cronEditor.presetManual`,cron:``},{id:`hourly`,labelKey:`backup.cronEditor.presetHourly`,cron:`0 * * * *`,descriptionKey:`backup.cronEditor.presetHourlyDesc`},{id:`every-3h`,labelKey:`backup.cronEditor.preset3h`,cron:`0 */3 * * *`,description:`00:00, 03:00, 06:00, 09:00 …`},{id:`every-6h`,labelKey:`backup.cronEditor.preset6h`,cron:`0 */6 * * *`,description:`00:00, 06:00, 12:00, 18:00`},{id:`daily-3am`,labelKey:`backup.cronEditor.presetDaily`,cron:`0 3 * * *`,descriptionKey:`backup.cronEditor.presetDailyDesc`},{id:`weekly-sun`,labelKey:`backup.cronEditor.presetWeekly`,cron:`0 3 * * 0`,descriptionKey:`backup.cronEditor.presetWeeklyDesc`}];function dn(e){let t=e.trim();for(let e of un)if(e.cron===t)return e.id;return`custom`}function fn({value:t,onChange:n,previewCount:o=5,disabled:s=!1}){let{t:c}=X(),l=dn(t),[u,d]=a(l===`custom`);i(()=>{l!==`custom`&&d(!1)},[l]);let f=hn(t,250),p=Ve({cron:f,count:o},{enabled:f.trim().length>0}),m=p.data??null,h=e=>{d(!1),n(e.cron)},g=u||l===`custom`;return e(`div`,{className:`space-y-3`,children:[e(`div`,{className:`space-y-1`,children:[r(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:c(`backup.cronEditor.schedulePreset`,`Schedule preset`)}),e(`div`,{className:`flex flex-wrap gap-1.5`,children:[un.map(e=>r(L,{variant:`unstyled`,type:`button`,onClick:()=>h(e),disabled:s,className:`rounded border px-2 py-1 text-[11px] transition-colors disabled:opacity-50 `+(!u&&l===e.id?`border-primary bg-primary/10 text-primary`:`border-border bg-background text-foreground-subtle hover:bg-primary/5 hover:text-foreground`),title:e.descriptionKey===void 0?e.description??c(e.labelKey):c(e.descriptionKey),children:c(e.labelKey)},e.id)),r(L,{variant:`unstyled`,type:`button`,onClick:()=>{d(!0),t.trim().length===0&&n(`0 3 * * *`)},disabled:s,className:`rounded border px-2 py-1 text-[11px] transition-colors disabled:opacity-50 `+(g?`border-primary bg-primary/10 text-primary`:`border-border bg-background text-foreground-subtle hover:bg-primary/5 hover:text-foreground`),children:c(`backup.cronEditor.custom`,`Custom…`)})]})]}),g&&e(`div`,{className:`space-y-1`,children:[r(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:c(`backup.cronEditor.cronExpression5FieldPosix`,`Cron expression (5-field POSIX)`)}),r(I,{type:`text`,value:t,onChange:e=>n(e.target.value),disabled:s,placeholder:`0 3 * * *`,spellCheck:!1,className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs font-mono text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-1 focus:ring-primary`}),e(`p`,{className:`text-[10px] text-foreground-subtle`,children:[c(`backup.cronEditor.format`,`Format:`),` `,r(ht,{i18nKey:`backup.cronEditor.formatLine`,components:{code:r(`span`,{className:`font-mono`})}})]})]}),r(pn,{cron:f,preview:m,loading:p.isFetching})]})}function pn({cron:t,preview:n,loading:i}){let{t:a}=X();return i&&n===null?e(`div`,{className:`flex items-center gap-2 rounded border border-border bg-background/40 px-3 py-2 text-[11px] text-foreground-subtle`,children:[r(N,{className:`h-3 w-3 animate-spin`}),a(`backup.cronEditor.validating`,`Validating…`)]}):n===null?null:n.ok?n.nextRuns.length===0?r(`div`,{className:`rounded border border-border bg-background/40 px-3 py-2 text-[11px] text-foreground-subtle`,children:a(`backup.cronEditor.noFutureRunsMatchThis`,`No future runs match this expression.`)}):e(`div`,{className:`space-y-1`,children:[r(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:a(`backup.cronEditor.nextRuns`,`Next runs`)}),r(`ul`,{className:`rounded border border-border bg-background/40 divide-y divide-border`,children:n.nextRuns.map((t,n)=>e(`li`,{className:`flex items-center justify-between px-3 py-1.5 text-[11px]`,children:[r(`span`,{className:`text-foreground tabular-nums`,children:new Date(t).toLocaleString()}),r(`span`,{className:`text-foreground-subtle text-[10px] tabular-nums`,children:mn(t)})]},`${t}-${n}`))})]}):r(`div`,{className:`rounded border border-danger/40 bg-danger/10 px-3 py-2 text-[11px] text-danger`,children:n.error??a(`backup.cronEditor.invalidCronExpression`,`Invalid cron expression`)})}function mn(e){let t=e-Date.now();if(t<=0)return Y.t(`helpers.relativeTime.now`);let n=Math.floor(t/1e3);if(n<60)return Y.t(`helpers.relativeTime.inSeconds`,{count:n});let r=Math.floor(n/60);if(r<60)return Y.t(`helpers.relativeTime.inMinutes`,{count:r});let i=Math.floor(r/60);if(i<24)return Y.t(`helpers.relativeTime.inHours`,{count:i});let a=Math.floor(i/24);return Y.t(`helpers.relativeTime.inDays`,{count:a})}function hn(e,n){let[r,o]=a(e),s=t(()=>e,[e]);return i(()=>{let e=setTimeout(()=>o(s),n);return()=>clearTimeout(e)},[s,n]),r}o();var gn=[[`backup`,`listSchedules`]];function _n({entry:n,onClose:i,onSaved:o}){let{t:c}=X(),l=s(),u=Ie(),d=u.data??[],[f,p]=a(n?.label??``),[m,h]=a(n?.cron??`0 3 * * *`),[g,_]=a(n?.enabled??!0),[y,b]=a(String(n?.retentionCount??7)),[x,S]=a(new Set(n?.locationIds??[])),[C,w]=a(new Set(n===null?Et:Mt(n.databases))),T=ft({onSuccess:()=>{l.invalidateQueries({queryKey:gn}),o()}}),E=e=>{S(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},D=Number.parseInt(y,10),O=t(()=>f.trim().length>0&&x.size>0&&C.size>0&&!Number.isNaN(D)&&D>=1&&D<=1e3,[f,x,C,D]),k=()=>{O&&T.mutate({...n?{id:n.id}:{},label:f.trim(),cron:m.trim(),enabled:g,locationIds:Array.from(x),retentionCount:D,databases:[...Nt(C)]})},A=T.error instanceof Error?T.error.message:null;return r(Fe,{open:!0,onClose:i,title:n?c(`backup.backupEntryModal.editBackupEntry`,`Edit backup entry`):c(`backup.backupEntryModal.newBackupEntry`,`New backup entry`),icon:v,error:A,width:`lg`,testId:`backup-entry-form`,footer:e(L,{size:`sm`,type:`button`,onClick:k,disabled:!O||T.isPending,children:[T.isPending?r(N,{className:`h-3.5 w-3.5 animate-spin`}):null,n?c(`common.save`,`Save`):c(`backup.backupEntryModal.createEntry`,`Create entry`)]}),children:e(`div`,{className:`space-y-4`,children:[r(q,{label:c(`backup.backupEntryModal.name`,`Name`),required:!0,children:r(I,{value:f,onChange:e=>p(e.target.value),placeholder:c(`backup.backupEntryModal.nightlyOffsite`,`Nightly offsite`),autoFocus:!0,"data-testid":`backup-entry-name`})}),e(q,{label:c(`backup.backupEntryModal.locationsSelected`,`Locations ({{value1}} selected)`,{value1:String(x.size)}),required:!0,children:[u.isLoading&&e(`div`,{className:`flex items-center gap-2 px-1 py-2 text-xs text-foreground-subtle`,children:[r(N,{className:`h-3.5 w-3.5 animate-spin`}),c(`backup.backupEntryModal.loadingLocations`,`Loading locations…`)]}),!u.isLoading&&d.length===0&&r(`div`,{className:`rounded border border-border bg-background px-3 py-2 text-xs text-foreground-subtle italic`,children:c(`backup.backupEntryModal.noBackupsStorageLocationsConfigured`,"No `backups` storage locations configured. Add one in Settings → Storage first.")}),d.length>0&&r(`div`,{className:`max-h-52 divide-y divide-border overflow-y-auto rounded border border-border bg-background`,children:d.map(t=>e(`label`,{className:`flex cursor-pointer items-center justify-between px-3 py-2 text-xs hover:bg-primary/5`,children:[e(`div`,{className:`flex items-center gap-2`,children:[r(F,{checked:x.has(t.id),onChange:()=>E(t.id),className:`accent-primary`}),r(`span`,{className:`text-foreground`,children:t.displayName})]}),e(`div`,{className:`flex items-center gap-1.5`,children:[r(`span`,{className:`rounded border border-border bg-surface px-1.5 py-0.5 text-[10px] uppercase tracking-wide text-foreground-subtle`,children:t.kind}),r(`span`,{className:`font-mono text-[10px] text-foreground-subtle`,children:t.id})]})]},t.id))})]}),r(rn,{selected:C,onChange:w,disabled:T.isPending,testId:`backup-entry-databases`}),e(`div`,{className:`grid grid-cols-2 gap-3`,children:[r(q,{label:c(`backup.backupEntryModal.retentionArchivesKept`,`Retention (archives kept)`),required:!0,children:r(I,{type:`number`,min:1,max:1e3,value:y,onChange:e=>b(e.target.value),"data-testid":`backup-entry-retention`})}),r(q,{label:c(`backup.backupEntryModal.enabled`,`Enabled`),description:c(`backup.backupEntryModal.runOnScheduleWhenChecked`,`Run on schedule when checked.`),children:e(`label`,{className:`inline-flex cursor-pointer items-center gap-2 py-1.5 text-xs text-foreground`,children:[r(F,{checked:g,onChange:e=>_(e.target.checked),className:`accent-primary`,"data-testid":`backup-entry-enabled`}),r(`span`,{children:c(`backup.backupEntryModal.runOnSchedule`,`Run on schedule`)})]})})]}),r(q,{label:c(`backup.backupEntryModal.schedule`,`Schedule`),children:r(fn,{value:m,onChange:h,disabled:T.isPending})})]})})}o();var vn=2e3,yn=5e3;function bn(e){return e.state===`queued`||e.state===`running`}function xn(e){if(e.state===`queued`)return{title:Y.t(`backup.backupRunsPanel.cancelQueuedBackupRun`,`Cancel queued backup run?`),message:Y.t(`backup.backupRunsPanel.thisRunHasNotStarted`,`This run has not started. Cancelling removes it from the queue — nothing has been written, nothing is deleted.`),confirmLabel:Y.t(`backup.backupRunsPanel.cancelRun`,`Cancel run`),variant:`warning`};let t=e.completedDestinationIds.length,n=t>0?`${t===1?`The 1 destination`:`The ${t} destinations`} that already completed KEEP${t===1?`S`:``} the archive.`:`No destination has completed yet, so nothing will be kept.`;return{title:Y.t(`backup.backupRunsPanel.stopThisBackupRun`,`Stop this backup run?`),message:Y.t(`backup.backupRunsPanel.theHalfWrittenStagingArchive`,`The half-written staging archive is deleted and the destination currently uploading discards its partial copy. {{keptSentence}}`,{keptSentence:n}),confirmLabel:Y.t(`backup.backupRunsPanel.stopRun`,`Stop run`),variant:`danger`}}function Sn(){let e=j(),[t,i]=a(null),o=tt(void 0,{refetchInterval:e=>(e.state.data??[]).some(bn)?vn:yn}),s=He({onSettled:()=>{i(null),o.refetch()}}),c=n(async t=>{await e(xn(t))&&(i(t.id),s.mutate({runId:t.id}))},[e,s]);return r(Cn,{queryState:o.isError?`error`:o.data===void 0?`pending`:`ready`,runs:o.data??[],cancelingId:t,onCancelRequest:e=>{c(e)},now:Date.now()})}function Cn({queryState:t,runs:n,cancelingId:i,onCancelRequest:a,now:o}){let{t:s}=X(),c=t===`ready`&&n.some(bn),l=n.filter(e=>e.state===`running`),u=n.filter(e=>e.state===`queued`),d=n.filter(e=>!bn(e)),f=[...l,...u,...d];return e(`section`,{className:`rounded-lg border border-border bg-surface`,children:[e(`div`,{className:`flex items-center gap-2 px-3 py-2 border-b border-border`,children:[r(`h2`,{className:`text-xs font-semibold text-foreground`,children:s(`backup.backupRunsPanel.runs`,`Runs`)}),c&&e(`span`,{className:`inline-flex items-center gap-1 text-[10px] font-medium text-primary`,title:s(`backup.backupRunsPanel.aBackupRunIsIn`,`A backup run is in progress`),children:[r(`span`,{className:`h-1.5 w-1.5 rounded-full bg-primary animate-pulse`}),s(`backup.runsPanel.live`)]}),r(`span`,{className:`ml-auto text-[10px] text-foreground-subtle`,children:s(`backup.backupRunsPanel.oneRunExecutesAtA`,`One run executes at a time — queued runs wait in line.`)})]}),t===`pending`&&r(`div`,{className:`px-3 py-2.5 text-xs text-foreground-subtle animate-pulse`,children:s(`backup.backupRunsPanel.checkingForBackupRuns`,`Checking for backup runs…`)}),t===`error`&&r(`div`,{className:`px-3 py-2.5 text-xs text-danger`,children:s(`backup.backupRunsPanel.couldNotReadBackupRuns`,`Could not read backup runs — the orchestrator did not answer.`)}),t===`ready`&&n.length===0&&r(`div`,{className:`px-3 py-2.5 text-xs text-foreground-subtle italic`,children:s(`backup.backupRunsPanel.noBackupRunsYetRuns`,`No backup runs yet. Runs appear here the moment one starts — manual or scheduled.`)}),t===`ready`&&n.length>0&&r(V,{bordered:!1,minWidthPx:720,rows:f,rowKey:e=>e.id,columns:wn({cancelingId:i,onCancelRequest:a,now:o,t:s})})]})}function wn({cancelingId:t,onCancelRequest:n,now:i,t:a}){return[{mobile:`primary`,key:`run`,header:a(`backup.backupRunsPanel.run`,`Run`),render:e=>r(`div`,{className:`text-foreground`,title:e.id,children:e.label??r(`span`,{className:`text-foreground-subtle italic`,children:a(`backup.runsPanel.manual`)})})},{mobile:`keep`,key:`state`,header:a(`backup.backupRunsPanel.state`,`State`),render:t=>e(c,{children:[r(Tn,{run:t}),t.state===`failed`&&t.error!==void 0&&r(`div`,{className:`mt-1 text-[10px] text-danger max-w-56 truncate`,title:t.error,children:t.error})]})},{mobile:`detail`,key:`progress`,header:a(`backup.backupRunsPanel.progress`,`Progress`),nowrap:!1,render:e=>r(En,{run:e})},{mobile:`hidden`,key:`destinations`,header:a(`backup.backupRunsPanel.destinations`,`Destinations`),nowrap:!1,render:e=>r(Dn,{run:e})},{mobile:`detail`,key:`timing`,header:a(`backup.backupRunsPanel.timing`,`Timing`),render:e=>r(`span`,{className:`text-foreground-subtle tabular-nums`,children:r(On,{run:e,now:i})})},{mobile:`keep`,key:`actions`,header:a(`backup.backupRunsPanel.actions`,`Actions`),align:`right`,width:`w-28`,render:i=>bn(i)?e(L,{variant:`unstyled`,onClick:()=>n(i),disabled:t===i.id,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10 disabled:opacity-50`,title:i.state===`queued`?a(`backup.backupRunsPanel.removeThisRunFromThe`,`Remove this run from the queue before it starts`):a(`backup.backupRunsPanel.stopThisRunTheHalf`,`Stop this run — the half-written archive is discarded`),children:[t===i.id?r(N,{className:`h-3 w-3 animate-spin`}):r(ne,{className:`h-3 w-3`}),i.state===`queued`?a(`common.cancel`,`Cancel`):a(`backup.backupRunsPanel.stop`,`Stop`)]}):null}]}function Tn({run:t}){let{t:n}=X();switch(t.state){case`queued`:return e(`span`,{className:`inline-flex items-center gap-1 rounded bg-foreground-subtle/10 px-1.5 py-0.5 text-[10px] font-medium text-foreground-subtle`,children:[r(re,{className:`h-3 w-3`}),n(`backup.backupRunsPanel.queued`,`Queued`)]});case`running`:return e(`span`,{className:`inline-flex items-center gap-1 rounded bg-primary/10 px-1.5 py-0.5 text-[10px] font-medium text-primary`,children:[r(N,{className:`h-3 w-3 animate-spin`}),t.phase===`uploading`?n(`backup.backupRunsPanel.uploading`,`Uploading`):n(`backup.backupRunsPanel.buildingArchive`,`Building archive`)]});case`succeeded`:return e(`span`,{className:`inline-flex items-center gap-1 rounded bg-success/10 px-1.5 py-0.5 text-[10px] font-medium text-success`,children:[r(w,{className:`h-3 w-3`}),n(`backup.backupRunsPanel.succeeded`,`Succeeded`)]});case`failed`:return e(`span`,{className:`inline-flex items-center gap-1 rounded bg-danger/10 px-1.5 py-0.5 text-[10px] font-medium text-danger`,children:[r(A,{className:`h-3 w-3`}),n(`backup.backupRunsPanel.failed`,`Failed`)]});case`cancelled`:return e(`span`,{className:`inline-flex items-center gap-1 rounded bg-amber-500/10 px-1.5 py-0.5 text-[10px] font-medium text-amber-700 dark:text-amber-300`,title:n(`backup.backupRunsPanel.stoppedBeforeCompletingEveryDestination`,`Stopped before completing every destination — not a success`),children:[r(me,{className:`h-3 w-3`}),n(`backup.backupRunsPanel.stopped`,`Stopped`)]})}}function En({run:t}){let{t:n}=X();if(t.state===`queued`)return r(`span`,{className:`text-foreground-subtle`,children:t.queuePosition===void 0?r(`span`,{className:`italic`,children:n(`backup.backupRunsPanel.waitingItsTurn`,`waiting its turn`)}):e(`span`,{className:`inline-flex items-center gap-1`,children:[r(`span`,{className:t.queuePosition===1?`rounded bg-primary/10 px-1.5 py-0.5 text-[10px] font-medium text-primary`:`rounded bg-foreground-subtle/10 px-1.5 py-0.5 text-[10px] font-medium`,children:kn(t.queuePosition)}),n(`backup.backupRunsPanel.inLine`,`in line`)]})});if(t.state===`running`&&t.phase===`building`)return e(`span`,{className:`inline-flex items-center gap-1.5 text-foreground`,children:[r(_e,{className:`h-3 w-3 text-primary`}),r(`span`,{className:`tabular-nums font-medium animate-pulse`,children:Z(t.stagedBytes)}),r(`span`,{className:`text-foreground-subtle`,children:n(`backup.backupRunsPanel.stagedSoFar`,`staged so far`)})]});if(t.state===`running`){let i=t.archiveSizeBytes;return e(`span`,{className:`inline-flex items-center gap-1.5 text-foreground`,children:[r(he,{className:`h-3 w-3 text-primary`}),e(`span`,{className:`tabular-nums font-medium`,children:[Z(t.uploadedBytes),i===void 0?``:` / ${Z(i)}`]}),r(`span`,{className:`text-foreground-subtle`,children:n(`backup.backupRunsPanel.toCurrentDestination`,`to current destination`)})]})}let i=t.archiveSizeBytes??(t.stagedBytes>0?t.stagedBytes:void 0);return i===void 0?r(`span`,{className:`text-foreground-subtle italic`,children:`—`}):r(`span`,{className:`tabular-nums text-foreground`,children:n(`backup.runsPanel.archiveSize`,{size:Z(i)})})}function Dn({run:t}){let{t:n}=X(),i=t.destinationIds.length,a=t.completedDestinationIds.length,o=t.failedDestinationIds.length;return i===0?r(`span`,{className:`text-foreground-subtle italic`,children:n(`backup.backupRunsPanel.notResolvedYet`,`not resolved yet`)}):e(`div`,{className:`flex flex-col gap-0.5`,children:[r(`span`,{className:`text-foreground-subtle`,title:t.destinationIds.join(`, `),children:n(`backup.runsPanel.targets`,{count:i})}),e(`span`,{className:`inline-flex items-center gap-2 text-[10px]`,children:[a>0&&r(`span`,{className:`text-success`,title:n(`backup.backupRunsPanel.keptTheirArchive`,`Kept their archive: {{value1}}`,{value1:t.completedDestinationIds.join(`, `)}),children:n(`backup.runsPanel.completed`,{count:a})}),o>0&&r(`span`,{className:`text-danger`,title:n(`backup.backupRunsPanel.failed2`,`Failed: {{value1}}`,{value1:t.failedDestinationIds.join(`, `)}),children:n(`backup.runsPanel.failedCount`,{count:o})})]})]})}function On({run:t,now:n}){let{t:i}=X();return t.state===`queued`?r(`span`,{children:i(`backup.runsPanel.queuedAgo`,{elapsed:An(n-t.requestedAt)})}):t.startedAt===void 0?r(`span`,{children:`—`}):t.finishedAt===void 0?r(`span`,{children:i(`backup.runsPanel.runningFor`,{elapsed:An(n-t.startedAt)})}):e(`div`,{className:`flex flex-col gap-0.5`,children:[r(`span`,{children:jn(t.finishedAt)}),r(`span`,{className:`text-[10px]`,children:i(`backup.runsPanel.took`,{elapsed:An(t.finishedAt-t.startedAt)})})]})}function kn(e){if(e<=1)return`next`;let t=e%100;if(t>=11&&t<=13)return`${e}th`;switch(e%10){case 1:return`${e}st`;case 2:return`${e}nd`;case 3:return`${e}rd`;default:return`${e}th`}}function An(e){let t=Math.max(0,Math.floor(e/1e3));if(t<60)return`${t}s`;let n=Math.floor(t/60);return n<60?`${n}m ${String(t%60).padStart(2,`0`)}s`:`${Math.floor(n/60)}h ${String(n%60).padStart(2,`0`)}m`}function jn(e){return new Date(e).toLocaleString(void 0,{day:`2-digit`,month:`short`,hour:`2-digit`,minute:`2-digit`})}o();var Mn=[[`backup`,`list`]];function Nn({initialDestinationId:n,initialArchiveId:o,onClose:c,onScheduled:l}){let{t:u}=X(),d=s(),[f,p]=a(n&&o?2:1),[m,h]=a(n),[g,_]=a(o),[v,y]=a(new Set),[b,x]=a(``),{data:S}=Ie(),C=S??[],{data:w,isLoading:T}=st({destinationId:m??``},{enabled:!!m}),E=w??[];i(()=>{if(m!==void 0)return;let e=C.filter(e=>e.restoreSupported);e.length===1&&h(e[0].id)},[m,C]);let{data:D}=Ke({destinationId:m??``,backupId:g??``},{enabled:!!m&&!!g}),O=t(()=>D?.locations??[],[D]);i(()=>{O.length!==0&&y(e=>e.size===0?new Set(O):e)},[O]);let k=ze({onSuccess:()=>{d.invalidateQueries({queryKey:Mn}),l(),c()}}),A=e=>{y(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},j=E.find(e=>e.id===g),te=j?.encryption!==void 0,ne=zt(j?.databases,D?.sqliteSnapshots),M=Lt(ne),re=!!m&&!!g,ie=M||v.size>0,ae=re&&ie&&!k.isPending&&(!te||b.trim().length>0),oe=()=>{!m||!g||k.mutate({destinationId:m,backupId:g,...M?{}:{locations:[...v]},...te?{backupSecretKey:b.trim()}:{}})};return r(z,{open:!0,onOpenChange:e=>!e&&c(),children:e(J,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[e(G,{children:[r(U,{children:u(`backup.restoreWizard.restoreBackup`,`Restore Backup`)}),r(`p`,{className:`text-xs text-foreground-subtle`,children:u(`backup.restoreWizard.stepOf`,{step:f,name:f===1?u(`backup.restoreWizard.pickSource`,`pick source`):f===2?u(`backup.restoreWizard.pickLocations`,`pick locations`):u(`backup.restoreWizard.confirmStep`)})})]}),e(W,{children:[f===1&&r(Pn,{destinations:C,destinationId:m,onPickDestination:e=>{h(e),_(void 0),y(new Set)},archives:E,archivesLoading:T,archiveId:g,onPickArchive:_}),f===2&&r(Fn,{locations:O,picked:v,onToggle:A,databases:ne,snapshotsOnly:M}),f===3&&r(In,{destinationName:C.find(e=>e.id===m)?.displayName??m??``,archive:j,picked:[...v],databases:ne,snapshotsOnly:M}),f===3&&j?.encryption!==void 0&&r(Ln,{keyId:j.encryption.keyId,value:b,onChange:x}),f===3&&k.error&&r(`p`,{role:`alert`,className:`px-4 pb-2 text-xs text-danger`,children:k.error.message})]}),e(K,{className:`justify-between`,children:[r(`div`,{children:f>1&&e(L,{variant:`outline`,size:`sm`,onClick:()=>p(e=>e===3?2:1),children:[r(ee,{className:`h-3 w-3`}),u(`common.back`,`Back`)]})}),e(`div`,{className:`flex items-center gap-2`,children:[r(L,{variant:`outline`,size:`sm`,onClick:c,children:u(`common.cancel`,`Cancel`)}),f<3?e(L,{size:`sm`,disabled:f===1&&!re||f===2&&!ie,onClick:()=>p(e=>e===1?2:3),children:[u(`common.next`,`Next`),r(ce,{className:`h-3 w-3`})]}):e(L,{size:`sm`,onClick:oe,disabled:!ae,children:[k.isPending?r(N,{className:`h-3.5 w-3.5 animate-spin`}):r(P,{className:`h-3.5 w-3.5`}),u(`backup.restoreWizard.scheduleRestore`,`Schedule Restore`)]})]})]})]})})}function Pn({destinations:t,destinationId:n,onPickDestination:i,archives:a,archivesLoading:o,archiveId:s,onPickArchive:c}){let{t:l}=X(),u=t.filter(e=>e.restoreSupported);return e(`div`,{className:`p-4 space-y-3`,children:[e(`div`,{className:`space-y-1.5`,children:[r(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:l(`backup.restoreWizard.destination`,`Destination`)}),r(k,{value:n??``,onChange:e=>i(e.target.value),options:[{value:``,label:l(`backup.restoreWizard.selectDestination`,`Select destination…`)},...u.map(e=>({value:e.id,label:`${e.displayName} (${e.kind})`}))]})]}),e(`div`,{className:`space-y-1.5`,children:[r(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:l(`backup.restoreWizard.archive`,`Archive`)}),!n&&r(`div`,{className:`text-xs text-foreground-subtle italic`,children:l(`backup.restoreWizard.pickADestinationFirst`,`Pick a destination first.`)}),n&&o&&r(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:l(`backup.restoreWizard.readingArchives`,`Reading archives…`)}),n&&!o&&a.length===0&&r(`div`,{className:`text-xs text-foreground-subtle italic`,children:l(`backup.restoreWizard.noArchivesAvailableAtThis`,`No archives available at this destination.`)}),n&&a.length>0&&r(`div`,{className:`rounded border border-border bg-background divide-y divide-border max-h-64 overflow-y-auto`,children:a.map(t=>{let n=s===t.id;return e(`label`,{className:`flex items-center justify-between px-3 py-2 text-xs cursor-pointer ${n?`bg-primary/10`:`hover:bg-primary/5`}`,children:[e(`div`,{className:`flex items-center gap-2`,children:[r(we,{name:`archive`,checked:n,onChange:()=>c(t.id),className:`accent-primary`}),e(`div`,{children:[e(`div`,{className:`flex items-center gap-1 font-medium text-foreground`,children:[t.encryption!==void 0&&r(se,{className:`h-3 w-3 text-success`,"aria-label":l(`backup.restoreWizard.encryptedKey`,`encrypted (key {{keyId}})`,{keyId:t.encryption.keyId})}),t.label??t.id]}),r(`div`,{className:`text-[10px] text-foreground-subtle`,children:new Date(t.createdAt).toLocaleString()}),r(`div`,{className:`pt-1`,children:r(Q,{databases:zt(t.databases,void 0)})})]})]}),r(`span`,{className:`text-[10px] text-foreground-subtle tabular-nums`,children:Z(t.sizeBytes)})]},t.id)})})]})]})}function Fn({locations:t,picked:n,onToggle:i,databases:a,snapshotsOnly:o}){let{t:s}=X();return o?e(`div`,{className:`space-y-3 p-4`,children:[e(`div`,{className:`space-y-1.5`,children:[r(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:s(`backup.restoreWizard.databasesInThisArchive`,`Databases in this archive`)}),r(Q,{databases:a})]}),r(`div`,{className:`rounded border border-info/30 bg-info/10 px-3 py-2 text-[11px] text-info`,children:s(`backup.restoreWizard.snapshotsOnlyRestoringThisArchive`,`Snapshots only: restoring this archive replaces just these databases. It does NOT touch configuration, addons, addon data or certificates.`)})]}):t.length===0?r(`div`,{className:`p-4`,children:r(`div`,{className:`text-xs text-foreground-subtle`,children:s(`backup.restoreWizard.loadingArchiveManifestIfThis`,`Loading archive manifest… If this persists, the archive may predate manifests — restoring will apply everything in the tarball.`)})}):e(`div`,{className:`p-4 space-y-3`,children:[e(`div`,{className:`space-y-1.5`,children:[r(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:s(`backup.restoreWizard.databasesInThisArchive`,`Databases in this archive`)}),r(Q,{databases:a})]}),r(`div`,{className:`rounded border border-warning/30 bg-warning/10 px-3 py-2 text-[11px] text-warning`,children:s(`backup.restoreWizard.selectedEntriesWillOverwriteLive`,`Selected entries will overwrite live data on the next server restart. Unchecked entries stay current.`)}),e(`div`,{className:`space-y-1.5`,children:[r(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:s(`common.apply`,`Apply`)}),r(`div`,{className:`rounded border border-border bg-background divide-y divide-border max-h-64 overflow-y-auto`,children:t.map(t=>e(`label`,{className:`flex items-center gap-2 px-3 py-2 text-xs hover:bg-primary/5 cursor-pointer`,children:[r(F,{checked:n.has(t),onChange:()=>i(t),className:`accent-primary`}),r(`span`,{className:`font-mono text-foreground`,children:t}),r(`span`,{className:`ml-auto text-[10px] text-foreground-subtle`,children:Bn(t)})]},t))})]})]})}function In({destinationName:t,archive:n,picked:i,databases:a,snapshotsOnly:o}){let{t:s}=X();return e(`div`,{className:`p-4 space-y-3 text-xs`,children:[r(`div`,{className:`rounded border border-warning/30 bg-warning/10 px-3 py-2 text-warning`,children:s(`backup.restoreWizard.restoreIsAppliedAtNext`,`Restore is applied at next server boot. Active connections will drop when you restart.`)}),e(`dl`,{className:`space-y-1.5`,children:[r(Rn,{term:`Destination`,value:t}),r(Rn,{term:`Archive`,value:n?.label??n?.id??`—`}),n&&r(Rn,{term:`Created`,value:`${new Date(n.createdAt).toLocaleString()} · ${Z(n.sizeBytes)}`}),e(`div`,{className:`flex justify-between gap-3`,children:[r(`dt`,{className:`text-foreground-subtle`,children:s(`backup.restoreWizard.databases`,`Databases`)}),r(`dd`,{className:`text-right`,children:r(Q,{databases:a})})]}),r(Rn,{term:`Locations`,value:o?`none (configuration is not touched)`:i.length>0?i.join(`, `):`— (full archive)`})]})]})}function Ln({keyId:t,value:n,onChange:i}){let{t:a}=X();return e(`div`,{className:`space-y-1.5 px-4 pb-3`,children:[r(`label`,{htmlFor:`restore-backup-key`,className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:a(`backup.restoreWizard.backupKey`,`Backup key`)}),r(I,{id:`restore-backup-key`,type:`password`,autoComplete:`off`,spellCheck:!1,value:n,onChange:e=>i(e.target.value),placeholder:a(`backup.restoreWizard.camstackBackupSecretV1`,`camstack-backup-secret-v1:…`),className:`w-full rounded border border-border bg-background px-2 py-1.5 font-mono text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`}),r(`p`,{className:`text-[11px] text-foreground-subtle`,children:r(ht,{i18nKey:`backup.restoreWizard.encryptedTo`,values:{keyId:t},components:{mono:r(`span`,{className:`font-mono`})}})})]})}function Rn({term:t,value:n}){return e(`div`,{className:`flex justify-between gap-3`,children:[r(`dt`,{className:`text-foreground-subtle`,children:t}),r(`dd`,{className:`text-foreground font-mono text-right truncate`,children:n})]})}var zn={db:`Database`,addons:`Addon configs`,"addons-data":`Addon data`,tls:`TLS certificates`,cache:`Cache`,data:`Top-level data`};function Bn(e){return zn[e]??``}o();function Vn(){let{t}=X(),n=j(),o=xe(),{state:s,openNew:c,openEdit:l,close:u}=ve({editKey:`edit`,newKey:`new`}),d=Ye(),f=d.data??[],[p,m]=a(null),[h,g]=a(!1),[_,v]=a(!1),[y,b]=a(!1),S=s.mode===`edit`?f.find(e=>e.id===s.id)??null:null;i(()=>{s.mode===`edit`&&!d.isLoading&&S===null&&u()},[s.mode,d.isLoading,S,u]);let C=s.mode===`new`||s.mode===`edit`&&S!==null,w=async()=>{await n({title:t(`system.backup.restartServerNow`,`Restart server now?`),message:t(`system.backup.activeConnectionsWillDropAnd`,`Active connections will drop and the apply-backup hook will run before boot.`),confirmLabel:t(`system.backup.restart`,`Restart`),variant:`warning`})&&o.mutate({confirm:!0})};return e(St,{embedded:!0,children:[e(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,"data-testid":`backup-actions`,children:[e(L,{variant:`outline`,size:`sm`,type:`button`,onClick:()=>b(!0),"data-testid":`backup-now`,children:[r(x,{className:`h-3.5 w-3.5`}),t(`system.backup.backUpNow`,`Back up now`)]}),e(L,{variant:`outline`,size:`sm`,type:`button`,onClick:()=>g(!0),children:[r(P,{className:`h-3.5 w-3.5`}),t(`system.backup.restore`,`Restore…`)]}),e(L,{size:`sm`,type:`button`,onClick:c,"data-testid":`backup-new-entry`,children:[r(le,{className:`h-3.5 w-3.5`}),t(`system.backup.newEntry`,`New entry`)]})]}),_&&r(`div`,{className:`rounded-lg border border-warning/30 bg-warning/10 px-3 py-2.5 text-xs text-warning`,children:e(`div`,{className:`flex items-center justify-between gap-3`,children:[e(`div`,{className:`flex items-center gap-2`,children:[r(P,{className:`h-3.5 w-3.5`}),r(`span`,{children:t(`system.backup.restoreScheduledRestartTheServer`,`Restore scheduled. Restart the server to apply.`)})]}),e(L,{size:`sm`,variant:`outline`,type:`button`,onClick:()=>{w()},disabled:o.isPending,children:[o.isPending?r(N,{className:`h-3.5 w-3.5 animate-spin`}):r(P,{className:`h-3.5 w-3.5`}),t(`system.backup.restartNow`,`Restart Now`)]})]})}),r(ln,{}),r(Sn,{}),r(Kt,{onEdit:e=>l(e.id),onOpenRestoreWizard:e=>m(e)}),C&&r(_n,{entry:S,onClose:u,onSaved:u}),y&&r(an,{onClose:()=>b(!1)}),(p||h)&&r(Nn,{...p?{initialDestinationId:p.destinationId,initialArchiveId:p.archiveId}:{},onClose:()=>{m(null),g(!1)},onScheduled:()=>v(!0)})]})}var Hn=[`locked`,`reset`,`shares-backup`,`recovery-key`,`rotation-pending`,`orphans`],Un={"key-missing":`helpers.keychainNotices.lockedKeyMissing`,"wrong-key":`helpers.keychainNotices.lockedWrongKey`,"key-file-unreadable":`helpers.keychainNotices.lockedKeyFileUnreadable`,"store-unavailable":`helpers.keychainNotices.lockedStoreUnavailable`,"not-initialized":`helpers.keychainNotices.lockedNotInitialized`,"decrypt-failed":`helpers.keychainNotices.lockedDecryptFailed`};function Wn(e){let t=Un[e];return t===void 0?e:Y.t(t)}function Gn({status:e,reset:t,pendingReentry:n,orphans:r}){let i=e.keychain.state===`locked`,a=e.keySource??e.configuredSource,o=[];return e.keychain.state===`locked`&&o.push({id:`locked`,tone:`danger`,title:Y.t(`helpers.keychainNotices.locked`,{reason:Wn(e.keychain.reason)})}),t!==null&&t.acknowledgedAt===null&&o.push({id:`reset`,tone:`danger`,title:n>0?Y.t(`helpers.keychainNotices.resetPending`,{count:n}):Y.t(`helpers.keychainNotices.resetDone`)}),a.sharesBackupWithDatabase&&o.push({id:`shares-backup`,tone:`warning`,title:Y.t(`helpers.keychainNotices.sharesBackup`)}),!i&&e.recoveryKeyDownloadedAt===null&&o.push({id:`recovery-key`,tone:`warning`,title:Y.t(`helpers.keychainNotices.recoveryKey`)}),!i&&e.rotationPending&&o.push({id:`rotation-pending`,tone:`info`,title:Y.t(`helpers.keychainNotices.rotationPending`)}),!i&&r>0&&o.push({id:`orphans`,tone:`info`,title:Y.t(`helpers.keychainNotices.orphans`,{count:r})}),[...o].sort((e,t)=>Hn.indexOf(e.id)-Hn.indexOf(t.id))}var Kn={dateStyle:`short`,timeStyle:`short`};function qn(e){return e===null?`—`:new Date(e).toLocaleString(void 0,Kn)}function Jn({value:t,copyValue:n,srLabel:i,maxWidthClass:a,className:o}){let s=n??t;return e(`span`,{className:f(`flex min-w-0 items-center gap-0.5`,a),children:[r(`span`,{className:f(`min-w-0 truncate font-mono`,o),title:s,children:t}),r(Se,{value:s,srLabel:i,className:`h-6 shrink-0 px-1.5`})]})}o();var Yn=new Set([`reveal`,`download-recovery-key`,`rotate-master-key`,`reset`]);function Xn(e){return[{mobile:`detail`,key:`at`,header:e(`system.keychainAuditTable.colWhen`),render:e=>qn(e.at)},{mobile:`primary`,key:`action`,header:e(`system.keychainAuditTable.colAction`),render:e=>r(R,{variant:Yn.has(e.action)?`warning`:`default`,children:e.action})},{mobile:`detail`,key:`actor`,header:e(`system.keychainAuditTable.colActor`),render:e=>r(`span`,{className:`font-mono`,children:e.actor})},{mobile:`detail`,key:`ref`,header:e(`system.keychainAuditTable.colRef`),render:e=>e.ref===null?r(`span`,{className:`text-foreground-subtle`,children:`—`}):r(Jn,{value:e.ref,srLabel:`secret ref`,maxWidthClass:`max-w-[22rem]`})},{mobile:`hidden`,key:`detail`,header:e(`system.keychainAuditTable.colDetail`),render:e=>r(`span`,{className:`text-foreground-muted`,children:e.detail??``})}]}function Zn({entries:n}){let{t:i}=X(),[o,s]=a(0),c=t(()=>Xn(i),[i]);if(n===void 0)return r(`p`,{className:`text-xs text-foreground-subtle`,children:i(`common.loading`,`Loading…`)});let l=Math.max(1,Math.ceil(n.length/25)),u=Math.min(o,l-1),d=u*25,f=n.slice(d,d+25);return e(`div`,{className:`space-y-2`,children:[r(V,{columns:c,rows:f,rowKey:e=>e.id,minWidthPx:760,emptyMessage:i(`secrets.keychainAuditTable.nothingHasBeenAuditedYet`,`Nothing has been audited yet.`)}),n.length>25&&e(`div`,{className:`flex flex-wrap items-center justify-between gap-2 text-[11px] text-foreground-subtle`,children:[r(`span`,{children:i(n.length>=500?`system.keychainAuditTable.rangeRecent`:`system.keychainAuditTable.range`,{from:d+1,to:d+f.length,total:n.length})}),e(`span`,{className:`inline-flex items-center gap-1`,children:[r(L,{size:`sm`,variant:`outline`,"aria-label":i(`secrets.keychainAuditTable.previousPage`,`Previous page`),disabled:u===0,onClick:()=>s(u-1),children:r(m,{className:`h-3.5 w-3.5`,"aria-hidden":!0})}),e(`span`,{className:`tabular-nums`,children:[u+1,` / `,l]}),r(L,{size:`sm`,variant:`outline`,"aria-label":i(`secrets.keychainAuditTable.nextPage`,`Next page`),disabled:u>=l-1,onClick:()=>s(u+1),children:r(h,{className:`h-3.5 w-3.5`,"aria-hidden":!0})})]})]})]})}function Qn(e,t){switch(e){case`locked`:return r(L,{size:`sm`,variant:`danger`,disabled:t.busy,onClick:t.onReset,children:Y.t(`secrets.keychainNoticeContent.resetKeychain`,`Reset keychain`)});case`reset`:return r(L,{size:`sm`,variant:`outline`,disabled:t.busy,onClick:t.onAcknowledgeReset,children:Y.t(`secrets.keychainNoticeContent.dismiss`,`Dismiss`)});case`recovery-key`:return r(L,{size:`sm`,variant:`outline`,disabled:t.busy,onClick:t.onDownload,children:Y.t(`secrets.keychainNoticeContent.download`,`Download`)});case`rotation-pending`:return r(L,{size:`sm`,variant:`outline`,disabled:t.busy,onClick:t.onRotate,children:Y.t(`secrets.keychainNoticeContent.rotate`,`Rotate`)});case`orphans`:return r(L,{size:`sm`,variant:`outline`,onClick:t.onShowOrphans,children:Y.t(`secrets.keychainNoticeContent.review`,`Review`)});case`shares-backup`:return null}}function $n(e,t){switch(e){case`locked`:return r(`p`,{children:Y.t(`secrets.keychainNoticeContent.noValueCanBeRead`,`No value can be read or stored. If the master key is lost for good, Reset archives every stored value and starts a new keychain; every secret field then reads “not set”.`)});case`reset`:return t.reset===null?null:r(er,{reset:t.reset,pending:t.pendingReentry});case`shares-backup`:return r(`p`,{children:r(ht,{i18nKey:`secrets.keychainNoticeContent.backupKeyFile`,components:{code:r(`code`,{className:`font-mono`})}})});case`recovery-key`:return r(`p`,{children:Y.t(`secrets.keychainNoticeContent.withoutACopyOfThe`,`Without a copy of the master key, the stored values cannot be recovered.`)});case`rotation-pending`:return r(`p`,{children:Y.t(`secrets.keychainNoticeContent.theKeychainUnlockedWithA`,`The keychain unlocked with a previous key. Rotate to move onto the configured one.`)});case`orphans`:return null}}function er({reset:t,pending:n}){let{t:i}=X(),a=t.actor===`trigger-file`?i(`secrets.keychainNoticeContent.resetByTrigger`):i(`secrets.keychainNoticeContent.resetByAdmin`,{actor:t.actor});return e(`div`,{className:`space-y-1.5`,children:[r(`p`,{children:i(`secrets.keychainNoticeContent.resetDetail`,{when:qn(t.at),by:a,archived:t.archived})}),n.length>0&&r(`ul`,{className:`max-h-40 space-y-0.5 overflow-y-auto rounded-md border border-border bg-background p-2 font-mono text-[11px] text-foreground`,children:n.map(t=>e(`li`,{className:`break-all`,children:[t.owner,` · `,t.scope,` · `,t.fieldPath]},t.ref))})]})}o();var tr=2,nr={danger:{icon:y,text:`text-danger`,border:`border-danger/40`},warning:{icon:T,text:`text-warning`,border:`border-warning/40`},info:{icon:ie,text:`text-info`,border:`border-border`}};function rr({notices:t,renderAction:n,renderDetail:i}){let{t:o}=X(),[s,c]=a(!1),l=t[0];if(l===void 0)return null;let u=t.length>tr,d=u&&!s?t.slice(0,1):t,p=t.length-d.length;return e(`section`,{"aria-label":o(`secrets.keychainNotices.keychainNotices`,`Keychain notices`),className:f(`rounded-lg border bg-surface`,nr[l.tone].border),children:[r(`ul`,{className:`divide-y divide-border`,children:d.map(e=>r(ir,{notice:e,action:n(e.id),detail:i(e.id)},e.id))}),u&&r(`div`,{className:`border-t border-border px-3 py-1`,children:e(L,{size:`sm`,variant:`ghost`,"aria-expanded":s,onClick:()=>c(e=>!e),children:[r(fe,{className:f(`h-3.5 w-3.5 transition-transform`,s&&`rotate-180`),"aria-hidden":!0}),s?o(`secrets.keychainNotices.showLess`,`Show less`):o(`secrets.keychainNotices.more`,`{{hidden}} more`,{hidden:p})]})})]})}function ir({notice:t,action:n,detail:i}){let{t:o}=X(),[s,c]=a(!1),l=nr[t.tone],u=l.icon,d=i!=null,p=`keychain-notice-${t.id}`;return e(`li`,{className:`px-3 py-2`,children:[e(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center sm:gap-3`,children:[e(`p`,{className:`flex min-w-0 flex-1 items-start gap-2 text-xs text-foreground`,children:[r(u,{className:f(`mt-0.5 h-3.5 w-3.5 shrink-0`,l.text),"aria-hidden":!0}),r(`span`,{className:`min-w-0 break-words`,children:t.title})]}),e(`div`,{className:`flex shrink-0 flex-wrap items-center gap-1.5 pl-5 sm:pl-0`,children:[d&&r(L,{size:`sm`,variant:`ghost`,"aria-expanded":s,"aria-controls":p,onClick:()=>c(e=>!e),children:o(`secrets.keychainNotices.details`,`Details`)}),n]})]}),d&&s&&r(`div`,{id:p,className:`mt-2 pl-5 text-xs text-foreground-muted`,children:i})]})}var ar={"mounted-file":`Mounted key file (/run/secrets)`,"previous-mounted-file":`Previous mounted key file`,platform:`OS keychain`,"default-file":`Default key file (data volume)`},or=8;function sr({status:t,busy:n,onDownload:i,onRotate:a,onPurge:o}){let{t:s}=X(),c=t.keychain.state===`locked`,l=t.keySource??t.configuredSource;return r(be,{headingId:`keychain-status`,title:s(`secrets.keychainStatusCard.keychain`,`Keychain`),icon:pe,actions:e(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[t.retiredWraps>0&&r(L,{size:`sm`,variant:`ghost`,disabled:n||c,onClick:o,children:s(`secrets.keychainStatusCard.purge`,{count:t.retiredWraps})}),r(L,{size:`sm`,variant:`outline`,disabled:n||c,onClick:a,children:s(`secrets.keychainStatusCard.rotateKey`,`Rotate key`)}),r(L,{size:`sm`,variant:`outline`,disabled:n||c,onClick:i,children:s(`secrets.keychainStatusCard.downloadRecoveryKey`,`Download recovery key`)})]}),children:e(`dl`,{className:`${p} grid grid-cols-1 gap-x-6 gap-y-3 sm:grid-cols-2 xl:grid-cols-4`,children:[e(cr,{label:s(`secrets.keychainStatusCard.state`,`State`),children:[c?e(R,{variant:`danger`,className:`gap-1`,children:[r(se,{className:`h-3 w-3`,"aria-hidden":!0}),s(`secrets.keychainStatusCard.locked`,`Locked`)]}):e(R,{variant:`success`,className:`gap-1`,children:[r(u,{className:`h-3 w-3`,"aria-hidden":!0}),s(`secrets.keychainStatusCard.unlocked`,`Unlocked`)]}),r(`span`,{className:`ml-2 text-foreground-subtle`,children:s(`common.stored`,{count:t.secretCount})})]}),e(cr,{label:s(`secrets.keychainStatusCard.keySource`,`Key source`),children:[r(`span`,{className:`block`,children:ar[l.kind]}),l.path!==void 0&&r(Jn,{value:l.path,srLabel:`key path`})]}),r(cr,{label:s(`secrets.keychainStatusCard.fingerprint`,`Fingerprint`),children:t.fingerprint===null?r(`span`,{className:`text-foreground-subtle`,children:`—`}):e(`span`,{className:`inline-flex items-center gap-0.5`,children:[r(`span`,{className:`font-mono`,title:t.fingerprint,children:t.fingerprint.slice(0,or)}),r(Se,{value:t.fingerprint,srLabel:`fingerprint`})]})}),r(cr,{label:s(`secrets.keychainStatusCard.recoveryKey`,`Recovery key`),children:t.recoveryKeyDownloadedAt===null?r(R,{variant:`warning`,children:s(`secrets.keychainStatusCard.notTaken`,`Not taken`)}):r(`span`,{children:s(`secrets.keychainStatusCard.taken`,{when:qn(t.recoveryKeyDownloadedAt)})})})]})})}function cr({label:t,children:n}){return e(`div`,{className:`min-w-0 text-xs`,children:[r(`dt`,{className:`text-foreground-subtle`,children:t}),r(`dd`,{className:`mt-0.5 min-w-0 text-foreground`,children:n})]})}o();var lr=1e3;function ur({revealed:t,onClose:n}){let{t:o}=X(),[s,l]=a(it);i(()=>{if(t===null)return;let e=Date.now();l(it);let r=setTimeout(n,it),i=setInterval(()=>l(Math.max(0,it-(Date.now()-e))),lr);return()=>{clearTimeout(r),clearInterval(i)}},[t,n]);let u=Math.ceil(s/1e3);return r(z,{open:t!==null,onOpenChange:e=>!e&&n(),children:r(J,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,children:t!==null&&e(c,{children:[e(G,{children:[r(U,{className:`break-all`,children:t.entry.fieldPath}),e(Ze,{className:`break-all`,children:[t.entry.owner,` · `,t.entry.scope]})]}),r(W,{children:r(`pre`,{"data-testid":`revealed-value`,className:`whitespace-pre-wrap break-all rounded-md border border-border bg-background p-3 font-mono text-xs text-foreground`,children:t.value})}),e(K,{className:`flex-col items-stretch gap-2 sm:flex-row sm:items-center sm:justify-between`,children:[r(`p`,{className:`text-[11px] text-foreground-subtle`,children:o(`secrets.revealDialog.recorded`,{seconds:u})}),e(`div`,{className:`flex justify-end gap-2`,children:[r(Se,{value:t.value,label:o(`common.copy`,`Copy`),srLabel:`revealed value`}),r(L,{size:`sm`,variant:`outline`,onClick:n,children:o(`secrets.revealDialog.hide`,`Hide`)})]})]})]})})})}var dr={orphan:{labelKey:`secrets.secretsTableState.usageOrphan`,variant:`warning`,hintKey:`secrets.secretsTableState.usageOrphanHint`,rank:0},unknown:{labelKey:`secrets.secretsTableState.usageUnknown`,variant:`default`,hintKey:`secrets.secretsTableState.usageUnknownHint`,rank:1},"in-use":{labelKey:`secrets.secretsTableState.usageInUse`,variant:`success`,hintKey:`secrets.secretsTableState.usageInUseHint`,rank:2}},fr=[{id:`all`,labelKey:`common.all`},{id:`in-use`,labelKey:`secrets.secretsTableState.usageInUse`},{id:`orphan`,labelKey:`secrets.secretsTableState.filterOrphans`},{id:`unknown`,labelKey:`secrets.secretsTableState.usageUnknown`}],pr=`system`;function mr(t){let{t:n}=X(),{secrets:i,filter:a,onFilterChange:o,onDeleteOrphans:s,deleting:c,locked:l}=t;if(i===void 0)return r(`p`,{className:`text-xs text-foreground-subtle`,children:n(`common.loading`,`Loading…`)});let u=e=>e===`all`?i.length:i.filter(t=>t.usage===e).length,d=i.filter(e=>e.usage===`orphan`).map(e=>e.ref),f=a===`all`?i:i.filter(e=>e.usage===a);return e(`div`,{className:`space-y-2`,children:[e(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[r(`div`,{className:`flex flex-wrap gap-1`,role:`group`,"aria-label":n(`secrets.secretsTable.filterByUsage`,`Filter by usage`),children:fr.map(t=>e(L,{size:`sm`,variant:a===t.id?`secondary`:`ghost`,"aria-pressed":a===t.id,className:a===t.id?`ring-1 ring-border`:void 0,onClick:()=>o(t.id),children:[n(t.labelKey),r(`span`,{className:`text-foreground-subtle tabular-nums`,children:u(t.id)})]},t.id))}),d.length>0&&e(L,{size:`sm`,variant:`outline`,className:`ml-auto`,disabled:c||l,onClick:()=>s(d),children:[r(ue,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),n(`secrets.secretsTableState.deleteOrphans`,{count:d.length})]})]}),r(V,{columns:gr(t),rows:f,rowKey:e=>e.ref,minWidthPx:860,maxBodyHeight:Ee,defaultSort:{columnKey:`owner`,dir:`asc`},emptyMessage:i.length===0?n(`secrets.secretsTable.noValueIsStoredIn`,`No value is stored in the keychain yet.`):n(`secrets.secretsTable.noStoredValueMatchesThis`,`No stored value matches this filter.`)})]})}function hr({owner:t}){let{t:n}=X();return e(`span`,{className:`flex items-center gap-2`,children:[r(xt,{addonId:t,fallback:t===pr?M:O,tileClassName:`bg-surface-hover text-foreground-subtle`,size:`sm`}),r(`span`,{className:`font-medium`,children:t===pr?n(`secrets.secretsTable.hubSystem`,`Hub (system)`):t})]})}function gr({locked:t,onReveal:n,revealing:i}){return[{mobile:`primary`,key:`owner`,header:Y.t(`secrets.secretsTable.owner`,`Owner`),render:e=>r(hr,{owner:e.owner}),sortValue:e=>e.owner},{mobile:`hidden`,key:`scope`,header:Y.t(`secrets.secretsTable.scope`,`Scope`),render:e=>r(`span`,{className:`block max-w-[11rem] truncate font-mono`,title:e.scope,children:e.scope}),sortValue:e=>e.scope},{mobile:`detail`,key:`field`,header:Y.t(`secrets.secretsTable.field`,`Field`),render:e=>r(Jn,{value:e.fieldPath,copyValue:e.ref,srLabel:`secret ref`,maxWidthClass:`max-w-[16rem]`}),sortValue:e=>e.fieldPath},{mobile:`hidden`,key:`updated`,header:Y.t(`secrets.secretsTable.updated`,`Updated`),render:e=>qn(e.updatedAt),sortValue:e=>e.updatedAt},{mobile:`hidden`,key:`last-read`,header:Y.t(`secrets.secretsTable.lastRead`,`Last read`),render:e=>qn(e.lastReadAt),sortValue:e=>e.lastReadAt},{mobile:`detail`,key:`status`,header:Y.t(`secrets.secretsTable.status`,`Status`),render:e=>r(R,{variant:dr[e.usage].variant,title:Y.t(dr[e.usage].hintKey),children:Y.t(dr[e.usage].labelKey)}),sortValue:e=>dr[e.usage].rank},{mobile:`keep`,key:`actions`,header:``,align:`right`,notSortableReason:`Actions`,render:a=>e(L,{size:`sm`,variant:`ghost`,disabled:t||i,"aria-label":Y.t(`secrets.secretsTable.reveal`,`Reveal {{fieldPath}}`,{fieldPath:a.fieldPath}),title:t?Y.t(`secrets.secretsTable.theKeychainIsLocked`,`The keychain is locked`):Y.t(`secrets.secretsTable.revealAudited`,`Reveal (audited)`),onClick:()=>n(a),children:[r(b,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),Y.t(`secrets.secretsTable.reveal2`,`Reveal`)]})}]}function _r(e){return e instanceof Error?e.message:String(e)}function vr(e){let{t}=X(),n=j(),r=oe(),i=E(),a=$e(),o=nt(),s=qe(),c=ct(),l=Ue(),u=Ae(),d=async(t,n)=>{try{await n()}catch(e){await r({title:t,message:_r(e),variant:`danger`})}e()};return{busy:a.isPending||o.isPending||s.isPending||c.isPending,deleting:u.isPending,download:async()=>{await n({title:t(`secrets.useKeychainActions.downloadTitle`),message:t(`secrets.useKeychainActions.downloadMessage`),confirmLabel:t(`secrets.useKeychainActions.downloadConfirm`),variant:`warning`})&&await d(t(`secrets.useKeychainActions.downloadRefused`),async()=>{let e=await a.mutateAsync({});await i({title:t(`secrets.useKeychainActions.recoveryTitle`,{fingerprint:e.fingerprint}),message:t(`secrets.useKeychainActions.recoveryMessage`),defaultValue:e.key,readOnly:!0,confirmLabel:t(`secrets.useKeychainActions.recoveryDone`)})})},rotate:async()=>{await n({title:t(`secrets.useKeychainActions.rotateTitle`),message:t(`secrets.useKeychainActions.rotateMessage`),confirmLabel:t(`secrets.useKeychainActions.rotateConfirm`),variant:`warning`})&&await d(t(`secrets.useKeychainActions.rotateRefused`),async()=>{let e=await o.mutateAsync({});await r({title:t(`secrets.useKeychainActions.rotatedTitle`),message:t(`secrets.useKeychainActions.rotatedMessage`,{fingerprint:e.fingerprint})})})},purge:async()=>{await n({title:t(`secrets.useKeychainActions.purgeTitle`),message:t(`secrets.useKeychainActions.purgeMessage`),confirmLabel:t(`secrets.useKeychainActions.purgeConfirm`),variant:`warning`})&&await d(t(`secrets.useKeychainActions.purgeRefused`),async()=>{await s.mutateAsync({})})},reset:async()=>{await i({title:t(`secrets.useKeychainActions.resetTitle`),message:t(`secrets.useKeychainActions.resetMessage`,{confirmation:`RESET KEYCHAIN`}),confirmLabel:t(`secrets.useKeychainActions.resetConfirm`),validate:e=>e===`RESET KEYCHAIN`?null:t(`secrets.useKeychainActions.resetMismatch`)})===`RESET KEYCHAIN`&&await d(t(`secrets.useKeychainActions.resetRefused`),async()=>{await c.mutateAsync({confirm:de})})},acknowledgeReset:async()=>{await d(t(`secrets.useKeychainActions.dismissFailed`),async()=>{await l.mutateAsync({})})},deleteOrphans:async e=>{await n({title:t(`secrets.useKeychainActions.orphansTitle`,{count:e.length}),message:t(`secrets.useKeychainActions.orphansMessage`),confirmLabel:t(`secrets.useKeychainActions.orphansConfirm`),variant:`danger`})&&await d(t(`secrets.useKeychainActions.orphansRefused`),async()=>{let n=await u.mutateAsync({refs:[...e]});n.kept.length>0&&await r({title:t(`secrets.useKeychainActions.keptTitle`),message:t(`secrets.useKeychainActions.keptMessage`,{deleted:n.deleted.length,kept:n.kept.length})})})}}}o();var yr=`secretsView`;function br(){let[e,t]=mt();return[e.get(yr)===`audit`?`audit`:`values`,n=>{let r=new URLSearchParams(e);n===`values`?r.delete(yr):r.set(yr,n),t(r,{replace:!0})}]}function xr(){let{t:i}=X(),o=Xe({}),s=Me({}),c=ot({limit:500}),l=Pe({}),u=Le(),d=oe(),[f,p]=br(),[m,h]=a(`all`),[g,_]=a(null),v=vr(()=>{o.refetch(),s.refetch(),c.refetch(),l.refetch()}),y=o.data?.keychain.state===`locked`,b=t(()=>(s.data??[]).filter(e=>e.usage===`orphan`).length,[s.data]),x=t(()=>o.data===void 0?[]:Gn({status:o.data,reset:l.data?.reset??null,pendingReentry:l.data?.pendingReentry.length??0,orphans:b}),[o.data,l.data,b]),S={reset:l.data?.reset??null,pendingReentry:l.data?.pendingReentry??[],busy:v.busy,onReset:()=>void v.reset(),onAcknowledgeReset:()=>void v.acknowledgeReset(),onDownload:()=>void v.download(),onRotate:()=>void v.rotate(),onShowOrphans:()=>{h(`orphan`),p(`values`)}},C=async e=>{try{_({entry:e,value:(await u.mutateAsync({ref:e.ref})).value}),s.refetch()}catch(e){await d({title:i(`admin.system.secrets.revealRefused`,`Reveal refused`),message:_t(e),variant:`danger`})}},w=n(()=>_(null),[]);return e(St,{embedded:!0,icon:pe,title:i(`admin.system.secrets.secrets`,`Secrets`),subtitle:i(`admin.system.secrets.passwordsTokensAndKeysEncrypted`,`Passwords, tokens and keys, encrypted in the hub keychain. Values leave the hub only through an audited reveal.`),children:[r(rr,{notices:x,renderAction:e=>Qn(e,S),renderDetail:e=>$n(e,S)}),o.data!==void 0&&r(sr,{status:o.data,busy:v.busy,onDownload:S.onDownload,onRotate:S.onRotate,onPurge:()=>void v.purge()}),e(Be,{value:f,onValueChange:e=>p(e===`audit`?`audit`:`values`),children:[e(De,{children:[r(lt,{value:`values`,children:i(`admin.system.secrets.storedValues`,`Stored values`)}),r(lt,{value:`audit`,children:i(`admin.system.secrets.audit`,`Audit`)})]}),r(Re,{value:`values`,children:r(mr,{secrets:s.data,locked:y,filter:m,onFilterChange:h,onReveal:e=>void C(e),revealing:u.isPending,onDeleteOrphans:e=>void v.deleteOrphans(e),deleting:v.deleting})}),r(Re,{value:`audit`,children:r(Zn,{entries:c.data})})]}),r(ur,{revealed:g,onClose:w})]})}o();function Sr(e){return Object.entries(e).map(([e,t])=>`${e} ${t}`).join(` · `)}function Cr(e){return e.reduce((e,t)=>e+Object.values(t.stores).reduce((e,t)=>e+t,0),0)}function wr(){let{t}=X(),n=j(),i=et(),[o,s]=a(null),[l,u]=a(null),d=async e=>{u(null);try{s(await i.mutateAsync({confirm:e}))}catch(e){u(e instanceof Error?e.message:String(e))}},f=async()=>{o===null||o.status!==`dry-run`||await n({title:t(`systemPage.deletedDevices.confirmTitle`,`Delete the data of deleted devices?`),message:o.devices.map(e=>`#${e.deviceId}: ${Sr(e.stores)}`).join(`
1
+ import{C as e,K as t,R as n,S as r,V as i,Y as a,et as o,o as s,x as c}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{$i as l,$n as u,Ar as d,Co as f,D as p,Da as m,Ea as h,En as g,Gi as _,Ia as v,Lr as y,Ri as b,Tr as x,X as S,Xi as C,_a as w,_n as T,_t as E,at as D,br as O,bt as k,da as A,fo as ee,ht as j,ii as te,io as ne,ir as M,la as re,mi as ie,oi as N,or as ae,pr as P,pt as oe,ri as se,uo as ce,wr as le,xn as ue,xo as F,xt as I,yt as L}from"./player-overlays-qzCoRsrQ.js";import{Ki as de}from"./src-CJoX3s-1.js";import{t as fe}from"./chevron-down-CBb-F8DT.js";import{c as pe}from"./terminal-BncJ-1sF.js";import{t as me}from"./circle-slash-Duh934sZ.js";import{n as he,t as ge}from"./database-zap-DHuELz_w.js";import{t as _e}from"./hard-drive-download-C6N6tovA.js";import{$ as ve,$a as R,$i as z,Am as ye,Gr as be,Ho as xe,Im as B,Jr as V,Nr as Se,Pa as Ce,Qa as we,X as Te,Yr as Ee,Za as H,_i as De,_s as Oe,aa as U,as as ke,au as Ae,cs as je,cu as Me,ds as Ne,du as Pe,ea as W,et as Fe,fs as Ie,fu as Le,gi as Re,gs as ze,hi as Be,hs as Ve,ia as G,is as He,iu as Ue,jr as We,kr as Ge,ls as Ke,lu as qe,mm as Je,ms as Ye,mu as Xe,na as Ze,os as Qe,ou as $e,pc as et,ps as tt,pu as nt,qr as rt,ra as K,sm as it,ss as at,st as q,su as ot,ta as J,us as st,uu as ct,vi as lt,vs as ut,xm as dt,ys as ft}from"./src-Cf1Uvi4o.js";import{i as pt,p as mt}from"./chunk-4ZMWKKQ3-BCeNTgXs.js";import{t as Y}from"./i18n-BHLBFC1-.js";import{t as X}from"./useTranslation-uIxPZ_3N.js";import"./mount-CYNi1aEm.js";import{$t as ht,A as gt,N as _t}from"./index-C1r-vzdu.js";import{t as vt}from"./AdminSectionedPage-3XsaKUPh.js";import{n as yt}from"./authed-media-C-zK1a1B.js";import{t as Z}from"./format-size-DIxKXxtj.js";import{t as bt}from"./StorageLocationsTable-CujqHG2j.js";import{n as xt}from"./InstancesTable-DVnHkIbJ.js";import{t as St}from"./AdminPage-CA4Sxydy.js";function Ct(){return r(St,{embedded:!0,children:r(bt,{})})}o();var wt={settings:{labelKey:`helpers.backupDatabases.settings.label`,descriptionKey:`helpers.backupDatabases.settings.description`,shortKey:`helpers.backupDatabases.settings.short`},events:{labelKey:`helpers.backupDatabases.events.label`,descriptionKey:`helpers.backupDatabases.events.description`,shortKey:`helpers.backupDatabases.events.short`},history:{labelKey:`helpers.backupDatabases.history.label`,descriptionKey:`helpers.backupDatabases.history.description`,shortKey:`helpers.backupDatabases.history.short`}},Tt=Object.keys(wt),Et=[`settings`];function Dt(){return Y.t(`helpers.backupDatabases.notCreated`)}function Ot(e){return Y.t(wt[e].labelKey)}function kt(e){return Y.t(wt[e].shortKey)}function At(e){return Y.t(wt[e].descriptionKey)}function jt(e){let t=new Set(e);return Tt.filter(e=>t.has(e))}function Mt(e){return e!==void 0&&e.length>0?jt(e):Et}function Nt(e){return jt(e)}function Pt(e,t){return t===void 0||!t.answered?`unknown`:t.databases.includes(e)?`present`:`absent`}function Ft(e,t,n){return Pt(e,t)===`absent`&&!n.has(e)}function It(e,t){let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n}function Lt(e){return!e.includes(`settings`)}function Rt(e){return{databases:[...Nt(e)]}}function zt(e,t){return e!==void 0&&e.length>0?jt(e):t!==void 0&&t.length>0?jt(t.map(e=>e.databaseId??`settings`)):Et}function Q({databases:e}){return r(`span`,{className:`text-xs font-medium uppercase tracking-wide text-foreground-muted`,"data-testid":`backup-database-badges`,children:e.map(e=>kt(e)).join(` · `)})}var Bt=[[`backup`,`listDestinations`]],Vt=[`backup`,`listArchives`];function Ht({destinationId:i,restoreSupported:o,onOpenRestoreWizard:c}){let{t:l}=X(),u=s(),d=j(),{data:f,isLoading:p,isError:m}=st({destinationId:i}),h=f??[],g=ke({onSuccess:()=>{u.invalidateQueries({queryKey:[[...Vt]]}),u.invalidateQueries({queryKey:Bt})}}),v=n(async e=>{await d({title:l(`backup.archiveList.deleteThisArchive`,`Delete this archive?`),message:l(`backup.archiveList.permanentlyDeletesAndFrees`,`Permanently deletes "{{value1}}" and frees {{value2}}.`,{value1:e.label??e.id,value2:Z(e.sizeBytes)}),confirmLabel:l(`common.delete`,`Delete`),variant:`danger`})&&g.mutate({destinationId:i,backupId:e.id})},[d,i,g,l]),[y,b]=a(null),x=n(async e=>{b(e.id);try{let t=await yt(Ut(i,e.id)),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=`${e.label??e.id}.tar.gz${e.encryption===void 0?``:`.csbk`}`,document.body.appendChild(r),r.click(),r.remove(),URL.revokeObjectURL(n)}finally{b(null)}},[i]),S=t(()=>[...h].toSorted((e,t)=>t.createdAt-e.createdAt),[h]);return p?r(`div`,{className:`text-xs text-foreground-subtle animate-pulse py-2`,children:l(`backup.archiveList.loadingArchives`,`Loading archives…`)}):m?r(`div`,{className:`text-xs text-danger py-2`,children:l(`backup.archiveList.failedToReadManifestFor`,`Failed to read manifest for this destination`)}):S.length===0?r(`div`,{className:`text-xs text-foreground-subtle italic py-2`,children:l(`backup.archiveList.noArchivesAtThisDestination`,`No archives at this destination yet.`)}):r(V,{columns:[{mobile:`primary`,key:`when`,header:l(`backup.archiveList.when`,`When`),sortValue:e=>e.createdAt,render:e=>r(`span`,{className:`tabular-nums`,children:Wt(e.createdAt)})},{mobile:`detail`,key:`label`,header:l(`backup.archiveList.label`,`Label`),sortValue:e=>e.label??null,render:t=>e(`span`,{className:`inline-flex items-center gap-1`,children:[t.encryption!==void 0&&r(se,{className:`h-3 w-3 text-success`,"aria-label":l(`backup.archiveList.encryptedRestoreNeedsBackupKey`,`encrypted — restore needs backup key {{keyId}}`,{keyId:t.encryption.keyId})}),t.label??r(`span`,{className:`text-foreground-subtle italic`,children:`—`})]})},{mobile:`hidden`,key:`databases`,header:l(`backup.archiveList.databases`,`Databases`),nowrap:!1,notSortableReason:`Database badges`,render:e=>r(Q,{databases:Mt(e.databases)})},{mobile:`hidden`,key:`includes`,header:l(`backup.archiveList.files`,`Files`),nowrap:!1,notSortableReason:`Location list`,render:e=>e.locations.length>0?r(`span`,{className:`text-foreground-subtle`,children:e.locations.join(`, `)}):r(`span`,{className:`text-foreground-subtle italic`,children:l(`common.none`)})},{mobile:`detail`,key:`size`,header:l(`backup.archiveList.size`,`Size`),align:`right`,sortValue:e=>e.sizeBytes,render:e=>r(`span`,{className:`tabular-nums`,children:Z(e.sizeBytes)})},{mobile:`keep`,key:`actions`,header:``,align:`right`,notSortableReason:`Actions`,render:t=>e(`span`,{className:`flex items-center justify-end gap-1`,children:[e(L,{variant:`ghost`,size:`sm`,onClick:()=>{x(t)},disabled:y===t.id,title:l(`backup.archiveList.downloadArchive`,`Download archive`),children:[y===t.id?r(N,{className:`h-3 w-3 animate-spin`}):r(_,{className:`h-3 w-3`}),l(`backup.archiveList.download`,`Download`)]}),o&&c&&e(L,{variant:`ghost`,size:`sm`,onClick:()=>c({destinationId:i,archiveId:t.id}),title:l(`backup.archiveList.restoreFromThisArchive`,`Restore from this archive`),children:[r(P,{className:`h-3 w-3`}),l(`backup.archiveList.restore`,`Restore`)]}),r(Je,{variant:`ghost`,size:`sm`,icon:ue,"aria-label":l(`backup.archiveList.delete`,`Delete {{value1}}`,{value1:t.label??t.id}),disabled:g.isPending,onClick:()=>{v(t)}})]})}],rows:S,rowKey:e=>e.id,minWidthPx:760,emptyMessage:l(`backup.archiveList.noArchivesAtThisDestination`,`No archives at this destination yet.`)})}function Ut(e,t){return D(`/api/backup/download/${encodeURIComponent(e)}/${encodeURIComponent(t)}`)}function Wt(e){return new Date(e).toLocaleString(void 0,{day:`2-digit`,month:`short`,year:`numeric`,hour:`2-digit`,minute:`2-digit`})}o();var Gt=[[`backup`,`listSchedules`]];function Kt({onEdit:i,onOpenRestoreWizard:o}){let{t:c}=X(),{data:l,isLoading:u,isError:d,error:f,refetch:p}=Ye(),m=l??[],h=Ie().data??[],g=t(()=>{let e=new Map;for(let t of h)e.set(t.id,t);return e},[h]),[_,y]=a(null),b=n(e=>{y(t=>t===e?null:e)},[]),x=s(),C=ft(),[w,T]=a({}),[E,D]=a(null),O=n((e,t)=>{T(n=>({...n,[e]:{...n[e],...t}}))},[]),k=t(()=>Jt(m,w),[m,w]),A=k.some(e=>e.retentionCount===null),ee=n(()=>{T({}),D(null)},[]),j=n(()=>{A||k.length===0||(D(null),Promise.all(k.map(e=>C.mutateAsync({...Qt(e.row),enabled:e.enabled,retentionCount:e.retentionCount??e.row.retentionCount}))).then(()=>(T({}),x.invalidateQueries({queryKey:Gt}))).catch(e=>{D(e instanceof Error?e.message:String(e)),x.invalidateQueries({queryKey:Gt})}))},[k,A,C,x]),te=t(()=>Yt({destById:g,expandedId:_,onToggleExpand:b,onEdit:i,draft:w,onDraft:O,saving:C.isPending,onSave:j,onDiscard:ee}),[g,_,b,i,w,O,C.isPending,j,ee]);return u?e(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle animate-pulse`,children:[r(N,{className:`h-3.5 w-3.5 animate-spin`}),c(`backup.backupEntriesTable.loadingBackupEntries`,`Loading backup entries…`)]}):d?r(H,{title:c(`backup.backupEntriesTable.failedToLoadBackupEntries`,`Failed to load backup entries`),message:f instanceof Error?f.message:c(`backup.backupEntriesTable.unknownError`,`Unknown error`),onRetry:()=>void p()}):m.length===0?r(Ce,{icon:v,title:c(`backup.backupEntriesTable.noBackupEntriesYet`,`No backup entries yet`),description:c(`backup.backupEntriesTable.createOneToScheduleBackups`,`Create one to schedule backups across one or more storage locations.`)}):e(`div`,{className:`space-y-2`,children:[r(V,{columns:te,rows:m,rowKey:e=>e.id,minWidthPx:980,maxBodyHeight:Ee,emptyMessage:c(`backup.backupEntriesTable.noBackupEntriesYet`,`No backup entries yet`),onRowClick:e=>i(e),sheetOpenLabel:c(`backup.backupEntriesTable.editEntry`,`Edit entry`),isExpanded:e=>e.id===_,renderExpanded:e=>r(nn,{row:e,destById:g,...o?{onOpenRestoreWizard:o}:{}})}),E!==null&&r(`p`,{role:`alert`,className:`text-xs text-danger`,children:E}),r(S,{pendingCount:k.length,saving:C.isPending,onSave:j,onDiscard:ee,...A?{problem:c(`backup.backupEntriesTable.retentionInvalid`,`Retention must be a whole number of at least 1.`)}:{}})]})}function qt(e){let t=Number.parseInt(e,10);return Number.isNaN(t)||t<1?null:t}function Jt(e,t){let n=[];for(let r of e){let e=t[r.id];if(e===void 0)continue;let i=e.enabled??r.enabled,a=e.retention===void 0?r.retentionCount:qt(e.retention);(i!==r.enabled||a!==r.retentionCount)&&n.push({row:r,enabled:i,retentionCount:a})}return n}function Yt(t){return[{mobile:`keep`,key:`expand`,header:``,width:`w-8`,nowrap:!0,notSortableReason:`Expand control`,render:e=>{let n=t.expandedId===e.id;return r(Je,{variant:`ghost`,size:`sm`,icon:n?fe:h,"aria-label":n?Y.t(`backup.backupEntriesTable.hideArchives`,`Hide archives`):Y.t(`backup.backupEntriesTable.showArchives`,`Show archives`),"aria-expanded":n,onClick:n=>{n.stopPropagation(),t.onToggleExpand(e.id)}})}},{mobile:`primary`,key:`entry`,header:Y.t(`backup.backupEntriesTable.entry`,`Entry`),sortValue:e=>e.label,render:t=>e(`span`,{className:`flex min-w-0 flex-col`,children:[r(`span`,{className:`truncate font-medium text-foreground`,children:t.label||Y.t(`backup.backupEntriesTable.unnamed`,`(unnamed)`)}),t.lastRunAt!==void 0&&r(`span`,{className:`text-[10px] text-foreground-subtle`,children:Y.t(`backup.backupEntriesTable.lastRun`,{when:new Date(t.lastRunAt).toLocaleString()})})]})},{mobile:`keep`,key:`enabled`,header:Y.t(`backup.backupEntriesTable.enabled`,`Enabled`),width:`w-20`,nowrap:!0,sortValue:e=>+!!e.enabled,render:e=>r(`span`,{onClick:e=>e.stopPropagation(),children:r($t,{row:e,checked:t.draft[e.id]?.enabled??e.enabled,disabled:t.saving,onChange:n=>t.onDraft(e.id,{enabled:n})})})},{mobile:`sheet`,key:`databases`,header:Y.t(`backup.backupEntriesTable.backsUp`,`Backs up`),nowrap:!1,notSortableReason:`Database badges`,render:e=>r(Q,{databases:Mt(e.databases)})},{mobile:`sheet`,key:`locations`,header:Y.t(`backup.backupEntriesTable.locations`,`Locations`),nowrap:!1,notSortableReason:`Location chips`,render:e=>r(Xt,{row:e,destById:t.destById})},{mobile:`sheet`,key:`retention`,header:Y.t(`backup.backupEntriesTable.retention`,`Retention`),width:`w-24`,nowrap:!0,sortValue:e=>e.retentionCount,render:e=>r(`span`,{onClick:e=>e.stopPropagation(),children:r(en,{row:e,value:t.draft[e.id]?.retention??String(e.retentionCount),disabled:t.saving,onChange:n=>t.onDraft(e.id,{retention:n}),onSave:t.onSave,onDiscard:t.onDiscard})})},{mobile:`detail`,key:`schedule`,header:Y.t(`backup.backupEntriesTable.schedule`,`Schedule`),width:`w-48`,nowrap:!0,sortValue:e=>e.cron,render:e=>r(Zt,{row:e})},{mobile:`keep`,key:`actions`,header:``,align:`right`,nowrap:!0,notSortableReason:`Actions`,render:e=>r(`span`,{onClick:e=>e.stopPropagation(),children:r(tn,{row:e,onEdit:()=>t.onEdit(e)})})}]}function Xt({row:e,destById:t}){let{t:n}=X();return e.locationIds.length===0?r(`span`,{className:`text-[11px] italic text-danger`,children:n(`backup.backupEntriesTable.noLocations`,`No locations`)}):r(`span`,{className:`flex flex-wrap gap-1`,children:e.locationIds.map(e=>r(`span`,{className:`inline-flex items-center rounded border border-border bg-background px-1.5 py-0.5 text-[10px] text-foreground`,title:e,children:t.get(e)?.displayName??e},e))})}function Zt({row:t}){let{t:n}=X(),i=t.cron.trim().length>0;return e(`span`,{className:`flex flex-row items-center gap-1.5 sm:flex-col sm:items-start sm:gap-0.5`,children:[e(`span`,{className:`inline-flex items-center gap-1`,children:[r(v,{className:`h-3 w-3 text-foreground-subtle`}),r(`span`,{className:`font-mono text-[11px] text-foreground`,children:i?t.cron:n(`backup.backupEntriesTable.manual`,`Manual`)})]}),i&&t.nextRunAt!==void 0&&r(`span`,{className:`text-[10px] text-foreground-subtle`,children:Y.t(`common.nextRun`,{when:new Date(t.nextRunAt).toLocaleString()})})]})}function Qt(e){return{id:e.id,label:e.label,cron:e.cron,locationIds:[...e.locationIds],retentionCount:e.retentionCount,...e.dataSources?{dataSources:[...e.dataSources]}:{},...e.databases?{databases:[...e.databases]}:{}}}function $t({row:e,checked:t,disabled:n,onChange:i}){let{t:a}=X();return r(`label`,{className:`inline-flex cursor-pointer items-center`,children:r(F,{className:`accent-primary`,checked:t,disabled:n,onChange:e=>i(e.target.checked),"aria-label":a(`backup.backupEntriesTable.enable`,`Enable {{value1}}`,{value1:e.label||e.id})})})}function en({row:e,value:t,disabled:n,onChange:i,onSave:a,onDiscard:o}){let{t:s}=X();return r(`div`,{className:`flex items-center gap-1`,children:r(I,{type:`number`,min:1,max:1e3,value:t,disabled:n,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`?a():e.key===`Escape`&&o()},className:`w-16`,"aria-label":s(`backup.backupEntriesTable.retentionFor`,`Retention for {{value1}}`,{value1:e.label||e.id})})})}function tn({row:t,onEdit:n}){let{t:i}=X(),a=dt(),o=s(),c=j(),l=Qe({onSuccess:()=>{o.invalidateQueries({queryKey:Gt})}}),u=ut({onMutate:()=>{o.invalidateQueries({queryKey:[[`backup`,`listRuns`]]})},onSuccess:()=>{o.invalidateQueries({queryKey:[[`backup`,`listArchives`]]}),o.invalidateQueries({queryKey:[[`backup`,`listDestinations`]]}),o.invalidateQueries({queryKey:[[`backup`,`listRuns`]]})}}),f=()=>{t.locationIds.length!==0&&u.mutate({destinations:[...t.locationIds],...t.dataSources&&t.dataSources.length>0?{locations:[...t.dataSources]}:{},label:t.label,retentionCount:t.retentionCount,databases:[...Mt(t.databases)]})},p=async()=>{await c({title:i(`backup.backupEntriesTable.deleteBackupEntry`,`Delete backup entry?`),message:i(`backup.backupEntriesTable.willStopRunningExistingArchives`,`"{{value1}}" will stop running. Existing archives are kept.`,{value1:t.label||t.id}),confirmLabel:i(`common.delete`,`Delete`),variant:`warning`})&&l.mutate({id:t.id})};return e(`span`,{className:`flex items-center justify-end gap-1.5`,children:[e(L,{size:`sm`,type:`button`,onClick:f,disabled:u.isPending||t.locationIds.length===0,title:i(`backup.backupEntriesTable.runThisEntryNow`,`Run this entry now`),children:[u.isPending?r(N,{className:`h-3 w-3 animate-spin`}):r(x,{className:`h-3 w-3`}),a?r(`span`,{className:`sr-only`,children:i(`backup.backupEntriesTable.runNow`,`Run now`)}):i(`backup.backupEntriesTable.runNow`,`Run now`)]}),r(Je,{variant:`ghost`,size:`sm`,icon:d,"aria-label":i(`backup.backupEntriesTable.edit`,`Edit {{value1}}`,{value1:t.label||t.id}),onClick:n}),r(Je,{variant:`ghost`,size:`sm`,icon:ue,"aria-label":i(`backup.backupEntriesTable.delete`,`Delete {{value1}}`,{value1:t.label||t.id}),disabled:l.isPending,onClick:()=>{p()}})]})}function nn({row:t,destById:n,onOpenRestoreWizard:i}){let{t:a}=X();return e(`div`,{className:`space-y-4 rounded-lg border border-border bg-background/30 px-4 py-3`,children:[r(`p`,{className:`text-[11px] font-medium text-foreground-subtle`,children:a(`backup.backupEntriesTable.archivesFor`,{name:t.label||t.id})}),t.locationIds.length===0&&r(`p`,{className:`text-xs italic text-foreground-subtle`,children:a(`backup.backupEntriesTable.thisEntryHasNoLocations`,`This entry has no locations selected.`)}),t.locationIds.map(t=>e(`div`,{className:`space-y-1.5`,children:[r(`div`,{className:`text-[11px] font-medium text-foreground-subtle`,children:n.get(t)?.displayName??t}),r(Ht,{destinationId:t,restoreSupported:n.get(t)?.restoreSupported??!0,...i?{onOpenRestoreWizard:i}:{}})]},t))]})}function rn({selected:t,onChange:n,disabled:i=!1,testId:a=`backup-databases`}){let{t:o}=X(),s=Ne().data,c=t.size>0&&Lt(jt(t)),l=t.size===0?`Pick at least one.`:c?`Snapshots only: configuration and files are not part of this backup.`:null;return r(q,{label:o(`backup.backupDatabasePicker.whatToBackUp`,`What to back up`),required:!0,...l===null?{}:{description:l},children:r(`div`,{className:`divide-y divide-border rounded border border-border bg-background`,"data-testid":a,children:Tt.map(o=>{let c=Pt(o,s),l=i||Ft(o,s,t);return e(`label`,{className:`flex items-start gap-2 px-3 py-2 text-xs ${l?`opacity-60`:`cursor-pointer hover:bg-primary/5`}`,children:[r(F,{checked:t.has(o),disabled:l,onChange:()=>n(It(t,o)),"data-testid":`${a}-${o}`}),e(`span`,{className:`min-w-0 flex-1`,children:[r(`span`,{className:`flex flex-wrap items-center gap-1.5 text-foreground`,children:Ot(o)}),r(`span`,{className:`block text-[11px] text-foreground-subtle`,children:c===`absent`?Dt():At(o)})]})]},o)})})})}o();function an({onClose:t}){let{t:n}=X(),i=s(),[o,c]=a(new Set(Et)),l=ut({onMutate:()=>{i.invalidateQueries({queryKey:[[`backup`,`listRuns`]]})},onSuccess:()=>{i.invalidateQueries({queryKey:[[`backup`,`listArchives`]]}),i.invalidateQueries({queryKey:[[`backup`,`listDestinations`]]}),i.invalidateQueries({queryKey:[[`backup`,`listRuns`]]}),t()}});return r(z,{open:!0,onOpenChange:e=>!e&&t(),children:e(J,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[e(G,{children:[r(U,{children:n(`backup.backupNowDialog.backUpNow`,`Back up now`)}),r(`p`,{className:`text-xs text-foreground-subtle`,children:n(`backup.backupNowDialog.runsOnceAndWritesThe`,`Runs once and writes the archive to every enabled backup location.`)})]}),r(W,{children:e(`div`,{className:`p-4`,children:[r(rn,{selected:o,onChange:c,disabled:l.isPending,testId:`backup-now-databases`}),l.error&&r(`p`,{role:`alert`,className:`pt-2 text-xs text-danger`,children:l.error.message})]})}),e(K,{children:[r(L,{variant:`outline`,size:`sm`,onClick:t,children:n(`common.cancel`,`Cancel`)}),e(L,{size:`sm`,onClick:()=>{o.size!==0&&l.mutate(Rt(o))},disabled:o.size===0||l.isPending,"data-testid":`backup-now-run`,children:[l.isPending?r(N,{className:`h-3.5 w-3.5 animate-spin`}):r(x,{className:`h-3.5 w-3.5`}),n(`backup.backupNowDialog.backUpNow`,`Back up now`)]})]})]})})}o();function on(e){return e===null?`—`:new Date(e).toLocaleString()}function sn(e){let t=new Blob([`${e.secretKey}\n`],{type:`text/plain`}),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=`dominevo-backup-key-${e.keyId}.txt`,r.click(),URL.revokeObjectURL(n)}function cn({revealed:t,onDone:n}){let{t:i}=X(),[o,s]=a(!1),[c,u]=a(!1);return r(z,{open:!0,onOpenChange:e=>!e&&o&&n(),children:e(J,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,className:`border-danger/40`,"aria-labelledby":`backup-key-title`,children:[r(G,{children:r(U,{id:`backup-key-title`,children:i(`backup.encryptionCard.yourKey`,{keyId:t.keyId})})}),e(W,{className:`space-y-3`,children:[e(`p`,{className:`flex items-start gap-2 rounded-md border border-danger/40 bg-danger/10 p-2 text-xs text-foreground`,children:[r(T,{className:`mt-0.5 h-4 w-4 shrink-0 text-danger`}),r(`span`,{children:i(`backup.backupEncryptionCard.thisKeyIsShownOnly`,`This key is shown only once. Dominevo does not keep it — not the hub, not its database, not its backups. Without it, an encrypted backup cannot be restored by anyone, including you. Store it in a password manager or print it, away from this server.`)})]}),r(`div`,{className:`break-all rounded-md border border-border bg-background p-2 font-mono text-xs text-foreground select-all`,children:t.secretKey}),e(`div`,{className:`flex flex-wrap gap-2`,children:[e(L,{size:`sm`,variant:`outline`,onClick:()=>{navigator.clipboard?.writeText(t.secretKey).then(()=>u(!0))},children:[r(l,{className:`mr-1 h-3.5 w-3.5`}),c?i(`backup.backupEncryptionCard.copied`,`Copied`):i(`common.copy`,`Copy`)]}),e(L,{size:`sm`,variant:`outline`,onClick:()=>sn(t),children:[r(_,{className:`mr-1 h-3.5 w-3.5`}),i(`backup.backupEncryptionCard.downloadAsFile`,`Download as file`)]})]}),e(`label`,{className:`flex items-center gap-2 text-xs text-foreground`,children:[r(F,{checked:o,onChange:e=>s(e.target.checked),className:`accent-primary`}),i(`backup.backupEncryptionCard.iHaveStoredThisKey`,`I have stored this key somewhere safe, off this server.`)]})]}),r(K,{children:r(L,{size:`sm`,disabled:!o,onClick:n,children:i(`backup.backupEncryptionCard.iHaveStoredIt`,`I have stored it`)})})]})})}function ln(){let{t}=X(),n=je(),i=Oe(),o=at(),s=j(),[l,u]=a(null),[d,f]=a(null),p=n.data?.enabled??!1,m=n.data?.active??null,h=(n.data?.keys??[]).filter(e=>e.retiredAt!==null),g=async()=>{if(await s({title:p?t(`backup.backupEncryptionCard.replaceTheBackupKey`,`Replace the backup key`):t(`backup.backupEncryptionCard.encryptBackups`,`Encrypt backups`),message:p?t(`backup.backupEncryptionCard.aNewKeyIsGenerated`,`A new key is generated and shown once; new backups are encrypted to it. Older backups keep needing the key they were made with — keep that one too.`):t(`backup.backupEncryptionCard.aBackupKeyIsGenerated`,`A backup key is generated and shown once. Every new backup is encrypted to it, and restoring one will ask for it. Existing backups stay as they are.`),confirmLabel:p?t(`backup.backupEncryptionCard.generateANewKey`,`Generate a new key`):t(`backup.backupEncryptionCard.generateTheKey`,`Generate the key`),variant:`warning`})){f(null);try{let e=await i.mutateAsync({});u({keyId:e.keyId,secretKey:e.secretKey})}catch(e){f(e instanceof Error?e.message:String(e))}}},_=async()=>{if(await s({title:t(`backup.backupEncryptionCard.turnBackupEncryptionOff`,`Turn backup encryption off`),message:t(`backup.backupEncryptionCard.newBackupsWillBeWritten`,`New backups will be written unencrypted. Existing encrypted backups still need their key to be restored.`),confirmLabel:t(`backup.backupEncryptionCard.turnOff`,`Turn off`),variant:`danger`})){f(null);try{await o.mutateAsync({}),n.refetch()}catch(e){f(e instanceof Error?e.message:String(e))}}};return e(`div`,{className:`space-y-2 rounded-lg border border-border bg-surface p-4`,children:[e(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[e(`div`,{className:`flex items-center gap-2`,children:[p?r(se,{className:`h-4 w-4 text-success`}):r(te,{className:`h-4 w-4 text-foreground-subtle`}),r(`h2`,{className:`text-sm font-semibold text-foreground`,children:t(`backup.backupEncryptionCard.encryption`,`Encryption`)}),r(`span`,{className:`text-xs text-foreground-subtle`,children:p&&m!==null?t(`backup.backupEncryptionCard.onKeySince`,`On — key {{keyId}}, since {{value2}}`,{keyId:m.keyId,value2:on(m.createdAt)}):t(`backup.backupEncryptionCard.offBackupsAreNotEncrypted`,`Off — backups are not encrypted`)})]}),r(`div`,{className:`flex gap-2`,children:p?e(c,{children:[r(L,{size:`sm`,variant:`outline`,disabled:i.isPending,onClick:()=>void g(),children:t(`backup.backupEncryptionCard.replaceKey`,`Replace key`)}),r(L,{size:`sm`,variant:`outline`,disabled:o.isPending,onClick:()=>void _(),children:t(`backup.backupEncryptionCard.turnOff`,`Turn off`)})]}):r(L,{size:`sm`,disabled:i.isPending,onClick:()=>void g(),children:t(`backup.backupEncryptionCard.enableEncryption`,`Enable encryption`)})})]}),r(`p`,{className:`text-xs text-foreground-subtle`,children:t(`backup.backupEncryptionCard.archivesAreEncryptedOnThis`,`Archives are encrypted on this server before they reach any destination. The server keeps only a public key, so it can encrypt scheduled backups but cannot decrypt them — only your backup key can. Covers the database snapshot, addon data (HomeKit pairing, Matter fabric, Tailscale state) and TLS.`)}),h.length>0&&e(`div`,{className:`text-xs`,children:[r(`p`,{className:`text-foreground-subtle`,children:t(`backup.backupEncryptionCard.olderKeysBackupsMadeWith`,`Older keys (backups made with them still need them):`)}),r(`ul`,{className:`font-mono text-foreground`,children:h.map(t=>e(`li`,{children:[t.keyId,` · `,on(t.createdAt),` → `,on(t.retiredAt)]},t.keyId))})]}),d!==null&&r(`p`,{className:`text-xs text-danger`,children:d}),l!==null&&r(cn,{revealed:l,onDone:()=>{u(null),n.refetch()}})]})}o();var un=[{id:`manual`,labelKey:`backup.cronEditor.presetManual`,cron:``},{id:`hourly`,labelKey:`backup.cronEditor.presetHourly`,cron:`0 * * * *`,descriptionKey:`backup.cronEditor.presetHourlyDesc`},{id:`every-3h`,labelKey:`backup.cronEditor.preset3h`,cron:`0 */3 * * *`,description:`00:00, 03:00, 06:00, 09:00 …`},{id:`every-6h`,labelKey:`backup.cronEditor.preset6h`,cron:`0 */6 * * *`,description:`00:00, 06:00, 12:00, 18:00`},{id:`daily-3am`,labelKey:`backup.cronEditor.presetDaily`,cron:`0 3 * * *`,descriptionKey:`backup.cronEditor.presetDailyDesc`},{id:`weekly-sun`,labelKey:`backup.cronEditor.presetWeekly`,cron:`0 3 * * 0`,descriptionKey:`backup.cronEditor.presetWeeklyDesc`}];function dn(e){let t=e.trim();for(let e of un)if(e.cron===t)return e.id;return`custom`}function fn({value:t,onChange:n,previewCount:o=5,disabled:s=!1}){let{t:c}=X(),l=dn(t),[u,d]=a(l===`custom`);i(()=>{l!==`custom`&&d(!1)},[l]);let f=hn(t,250),p=Ve({cron:f,count:o},{enabled:f.trim().length>0}),m=p.data??null,h=e=>{d(!1),n(e.cron)},g=u||l===`custom`;return e(`div`,{className:`space-y-3`,children:[e(`div`,{className:`space-y-1`,children:[r(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:c(`backup.cronEditor.schedulePreset`,`Schedule preset`)}),e(`div`,{className:`flex flex-wrap gap-1.5`,children:[un.map(e=>r(L,{variant:`unstyled`,type:`button`,onClick:()=>h(e),disabled:s,className:`rounded border px-2 py-1 text-[11px] transition-colors disabled:opacity-50 `+(!u&&l===e.id?`border-primary bg-primary/10 text-primary`:`border-border bg-background text-foreground-subtle hover:bg-primary/5 hover:text-foreground`),title:e.descriptionKey===void 0?e.description??c(e.labelKey):c(e.descriptionKey),children:c(e.labelKey)},e.id)),r(L,{variant:`unstyled`,type:`button`,onClick:()=>{d(!0),t.trim().length===0&&n(`0 3 * * *`)},disabled:s,className:`rounded border px-2 py-1 text-[11px] transition-colors disabled:opacity-50 `+(g?`border-primary bg-primary/10 text-primary`:`border-border bg-background text-foreground-subtle hover:bg-primary/5 hover:text-foreground`),children:c(`backup.cronEditor.custom`,`Custom…`)})]})]}),g&&e(`div`,{className:`space-y-1`,children:[r(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:c(`backup.cronEditor.cronExpression5FieldPosix`,`Cron expression (5-field POSIX)`)}),r(I,{type:`text`,value:t,onChange:e=>n(e.target.value),disabled:s,placeholder:`0 3 * * *`,spellCheck:!1,className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs font-mono text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-1 focus:ring-primary`}),e(`p`,{className:`text-[10px] text-foreground-subtle`,children:[c(`backup.cronEditor.format`,`Format:`),` `,r(ht,{i18nKey:`backup.cronEditor.formatLine`,components:{code:r(`span`,{className:`font-mono`})}})]})]}),r(pn,{cron:f,preview:m,loading:p.isFetching})]})}function pn({cron:t,preview:n,loading:i}){let{t:a}=X();return i&&n===null?e(`div`,{className:`flex items-center gap-2 rounded border border-border bg-background/40 px-3 py-2 text-[11px] text-foreground-subtle`,children:[r(N,{className:`h-3 w-3 animate-spin`}),a(`backup.cronEditor.validating`,`Validating…`)]}):n===null?null:n.ok?n.nextRuns.length===0?r(`div`,{className:`rounded border border-border bg-background/40 px-3 py-2 text-[11px] text-foreground-subtle`,children:a(`backup.cronEditor.noFutureRunsMatchThis`,`No future runs match this expression.`)}):e(`div`,{className:`space-y-1`,children:[r(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:a(`backup.cronEditor.nextRuns`,`Next runs`)}),r(`ul`,{className:`rounded border border-border bg-background/40 divide-y divide-border`,children:n.nextRuns.map((t,n)=>e(`li`,{className:`flex items-center justify-between px-3 py-1.5 text-[11px]`,children:[r(`span`,{className:`text-foreground tabular-nums`,children:new Date(t).toLocaleString()}),r(`span`,{className:`text-foreground-subtle text-[10px] tabular-nums`,children:mn(t)})]},`${t}-${n}`))})]}):r(`div`,{className:`rounded border border-danger/40 bg-danger/10 px-3 py-2 text-[11px] text-danger`,children:n.error??a(`backup.cronEditor.invalidCronExpression`,`Invalid cron expression`)})}function mn(e){let t=e-Date.now();if(t<=0)return Y.t(`helpers.relativeTime.now`);let n=Math.floor(t/1e3);if(n<60)return Y.t(`helpers.relativeTime.inSeconds`,{count:n});let r=Math.floor(n/60);if(r<60)return Y.t(`helpers.relativeTime.inMinutes`,{count:r});let i=Math.floor(r/60);if(i<24)return Y.t(`helpers.relativeTime.inHours`,{count:i});let a=Math.floor(i/24);return Y.t(`helpers.relativeTime.inDays`,{count:a})}function hn(e,n){let[r,o]=a(e),s=t(()=>e,[e]);return i(()=>{let e=setTimeout(()=>o(s),n);return()=>clearTimeout(e)},[s,n]),r}o();var gn=[[`backup`,`listSchedules`]];function _n({entry:n,onClose:i,onSaved:o}){let{t:c}=X(),l=s(),u=Ie(),d=u.data??[],[f,p]=a(n?.label??``),[m,h]=a(n?.cron??`0 3 * * *`),[g,_]=a(n?.enabled??!0),[y,b]=a(String(n?.retentionCount??7)),[x,S]=a(new Set(n?.locationIds??[])),[C,w]=a(new Set(n===null?Et:Mt(n.databases))),T=ft({onSuccess:()=>{l.invalidateQueries({queryKey:gn}),o()}}),E=e=>{S(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},D=Number.parseInt(y,10),O=t(()=>f.trim().length>0&&x.size>0&&C.size>0&&!Number.isNaN(D)&&D>=1&&D<=1e3,[f,x,C,D]),k=()=>{O&&T.mutate({...n?{id:n.id}:{},label:f.trim(),cron:m.trim(),enabled:g,locationIds:Array.from(x),retentionCount:D,databases:[...Nt(C)]})},A=T.error instanceof Error?T.error.message:null;return r(Fe,{open:!0,onClose:i,title:n?c(`backup.backupEntryModal.editBackupEntry`,`Edit backup entry`):c(`backup.backupEntryModal.newBackupEntry`,`New backup entry`),icon:v,error:A,width:`lg`,testId:`backup-entry-form`,footer:e(L,{size:`sm`,type:`button`,onClick:k,disabled:!O||T.isPending,children:[T.isPending?r(N,{className:`h-3.5 w-3.5 animate-spin`}):null,n?c(`common.save`,`Save`):c(`backup.backupEntryModal.createEntry`,`Create entry`)]}),children:e(`div`,{className:`space-y-4`,children:[r(q,{label:c(`backup.backupEntryModal.name`,`Name`),required:!0,children:r(I,{value:f,onChange:e=>p(e.target.value),placeholder:c(`backup.backupEntryModal.nightlyOffsite`,`Nightly offsite`),autoFocus:!0,"data-testid":`backup-entry-name`})}),e(q,{label:c(`backup.backupEntryModal.locationsSelected`,`Locations ({{value1}} selected)`,{value1:String(x.size)}),required:!0,children:[u.isLoading&&e(`div`,{className:`flex items-center gap-2 px-1 py-2 text-xs text-foreground-subtle`,children:[r(N,{className:`h-3.5 w-3.5 animate-spin`}),c(`backup.backupEntryModal.loadingLocations`,`Loading locations…`)]}),!u.isLoading&&d.length===0&&r(`div`,{className:`rounded border border-border bg-background px-3 py-2 text-xs text-foreground-subtle italic`,children:c(`backup.backupEntryModal.noBackupsStorageLocationsConfigured`,"No `backups` storage locations configured. Add one in Settings → Storage first.")}),d.length>0&&r(`div`,{className:`max-h-52 divide-y divide-border overflow-y-auto rounded border border-border bg-background`,children:d.map(t=>e(`label`,{className:`flex cursor-pointer items-center justify-between px-3 py-2 text-xs hover:bg-primary/5`,children:[e(`div`,{className:`flex items-center gap-2`,children:[r(F,{checked:x.has(t.id),onChange:()=>E(t.id),className:`accent-primary`}),r(`span`,{className:`text-foreground`,children:t.displayName})]}),e(`div`,{className:`flex items-center gap-1.5`,children:[r(`span`,{className:`rounded border border-border bg-surface px-1.5 py-0.5 text-[10px] uppercase tracking-wide text-foreground-subtle`,children:t.kind}),r(`span`,{className:`font-mono text-[10px] text-foreground-subtle`,children:t.id})]})]},t.id))})]}),r(rn,{selected:C,onChange:w,disabled:T.isPending,testId:`backup-entry-databases`}),e(`div`,{className:`grid grid-cols-2 gap-3`,children:[r(q,{label:c(`backup.backupEntryModal.retentionArchivesKept`,`Retention (archives kept)`),required:!0,children:r(I,{type:`number`,min:1,max:1e3,value:y,onChange:e=>b(e.target.value),"data-testid":`backup-entry-retention`})}),r(q,{label:c(`backup.backupEntryModal.enabled`,`Enabled`),description:c(`backup.backupEntryModal.runOnScheduleWhenChecked`,`Run on schedule when checked.`),children:e(`label`,{className:`inline-flex cursor-pointer items-center gap-2 py-1.5 text-xs text-foreground`,children:[r(F,{checked:g,onChange:e=>_(e.target.checked),className:`accent-primary`,"data-testid":`backup-entry-enabled`}),r(`span`,{children:c(`backup.backupEntryModal.runOnSchedule`,`Run on schedule`)})]})})]}),r(q,{label:c(`backup.backupEntryModal.schedule`,`Schedule`),children:r(fn,{value:m,onChange:h,disabled:T.isPending})})]})})}o();var vn=2e3,yn=5e3;function bn(e){return e.state===`queued`||e.state===`running`}function xn(e){if(e.state===`queued`)return{title:Y.t(`backup.backupRunsPanel.cancelQueuedBackupRun`,`Cancel queued backup run?`),message:Y.t(`backup.backupRunsPanel.thisRunHasNotStarted`,`This run has not started. Cancelling removes it from the queue — nothing has been written, nothing is deleted.`),confirmLabel:Y.t(`backup.backupRunsPanel.cancelRun`,`Cancel run`),variant:`warning`};let t=e.completedDestinationIds.length,n=t>0?`${t===1?`The 1 destination`:`The ${t} destinations`} that already completed KEEP${t===1?`S`:``} the archive.`:`No destination has completed yet, so nothing will be kept.`;return{title:Y.t(`backup.backupRunsPanel.stopThisBackupRun`,`Stop this backup run?`),message:Y.t(`backup.backupRunsPanel.theHalfWrittenStagingArchive`,`The half-written staging archive is deleted and the destination currently uploading discards its partial copy. {{keptSentence}}`,{keptSentence:n}),confirmLabel:Y.t(`backup.backupRunsPanel.stopRun`,`Stop run`),variant:`danger`}}function Sn(){let e=j(),[t,i]=a(null),o=tt(void 0,{refetchInterval:e=>(e.state.data??[]).some(bn)?vn:yn}),s=He({onSettled:()=>{i(null),o.refetch()}}),c=n(async t=>{await e(xn(t))&&(i(t.id),s.mutate({runId:t.id}))},[e,s]);return r(Cn,{queryState:o.isError?`error`:o.data===void 0?`pending`:`ready`,runs:o.data??[],cancelingId:t,onCancelRequest:e=>{c(e)},now:Date.now()})}function Cn({queryState:t,runs:n,cancelingId:i,onCancelRequest:a,now:o}){let{t:s}=X(),c=t===`ready`&&n.some(bn),l=n.filter(e=>e.state===`running`),u=n.filter(e=>e.state===`queued`),d=n.filter(e=>!bn(e)),f=[...l,...u,...d];return e(`section`,{className:`rounded-lg border border-border bg-surface`,children:[e(`div`,{className:`flex items-center gap-2 px-3 py-2 border-b border-border`,children:[r(`h2`,{className:`text-xs font-semibold text-foreground`,children:s(`backup.backupRunsPanel.runs`,`Runs`)}),c&&e(`span`,{className:`inline-flex items-center gap-1 text-[10px] font-medium text-primary`,title:s(`backup.backupRunsPanel.aBackupRunIsIn`,`A backup run is in progress`),children:[r(`span`,{className:`h-1.5 w-1.5 rounded-full bg-primary animate-pulse`}),s(`backup.runsPanel.live`)]}),r(`span`,{className:`ml-auto text-[10px] text-foreground-subtle`,children:s(`backup.backupRunsPanel.oneRunExecutesAtA`,`One run executes at a time — queued runs wait in line.`)})]}),t===`pending`&&r(`div`,{className:`px-3 py-2.5 text-xs text-foreground-subtle animate-pulse`,children:s(`backup.backupRunsPanel.checkingForBackupRuns`,`Checking for backup runs…`)}),t===`error`&&r(`div`,{className:`px-3 py-2.5 text-xs text-danger`,children:s(`backup.backupRunsPanel.couldNotReadBackupRuns`,`Could not read backup runs — the orchestrator did not answer.`)}),t===`ready`&&n.length===0&&r(`div`,{className:`px-3 py-2.5 text-xs text-foreground-subtle italic`,children:s(`backup.backupRunsPanel.noBackupRunsYetRuns`,`No backup runs yet. Runs appear here the moment one starts — manual or scheduled.`)}),t===`ready`&&n.length>0&&r(V,{bordered:!1,minWidthPx:720,rows:f,rowKey:e=>e.id,columns:wn({cancelingId:i,onCancelRequest:a,now:o,t:s})})]})}function wn({cancelingId:t,onCancelRequest:n,now:i,t:a}){return[{mobile:`primary`,key:`run`,header:a(`backup.backupRunsPanel.run`,`Run`),render:e=>r(`div`,{className:`text-foreground`,title:e.id,children:e.label??r(`span`,{className:`text-foreground-subtle italic`,children:a(`backup.runsPanel.manual`)})})},{mobile:`keep`,key:`state`,header:a(`backup.backupRunsPanel.state`,`State`),render:t=>e(c,{children:[r(Tn,{run:t}),t.state===`failed`&&t.error!==void 0&&r(`div`,{className:`mt-1 text-[10px] text-danger max-w-56 truncate`,title:t.error,children:t.error})]})},{mobile:`detail`,key:`progress`,header:a(`backup.backupRunsPanel.progress`,`Progress`),nowrap:!1,render:e=>r(En,{run:e})},{mobile:`hidden`,key:`destinations`,header:a(`backup.backupRunsPanel.destinations`,`Destinations`),nowrap:!1,render:e=>r(Dn,{run:e})},{mobile:`detail`,key:`timing`,header:a(`backup.backupRunsPanel.timing`,`Timing`),render:e=>r(`span`,{className:`text-foreground-subtle tabular-nums`,children:r(On,{run:e,now:i})})},{mobile:`keep`,key:`actions`,header:a(`backup.backupRunsPanel.actions`,`Actions`),align:`right`,width:`w-28`,render:i=>bn(i)?e(L,{variant:`unstyled`,onClick:()=>n(i),disabled:t===i.id,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10 disabled:opacity-50`,title:i.state===`queued`?a(`backup.backupRunsPanel.removeThisRunFromThe`,`Remove this run from the queue before it starts`):a(`backup.backupRunsPanel.stopThisRunTheHalf`,`Stop this run — the half-written archive is discarded`),children:[t===i.id?r(N,{className:`h-3 w-3 animate-spin`}):r(ne,{className:`h-3 w-3`}),i.state===`queued`?a(`common.cancel`,`Cancel`):a(`backup.backupRunsPanel.stop`,`Stop`)]}):null}]}function Tn({run:t}){let{t:n}=X();switch(t.state){case`queued`:return e(`span`,{className:`inline-flex items-center gap-1 rounded bg-foreground-subtle/10 px-1.5 py-0.5 text-[10px] font-medium text-foreground-subtle`,children:[r(re,{className:`h-3 w-3`}),n(`backup.backupRunsPanel.queued`,`Queued`)]});case`running`:return e(`span`,{className:`inline-flex items-center gap-1 rounded bg-primary/10 px-1.5 py-0.5 text-[10px] font-medium text-primary`,children:[r(N,{className:`h-3 w-3 animate-spin`}),t.phase===`uploading`?n(`backup.backupRunsPanel.uploading`,`Uploading`):n(`backup.backupRunsPanel.buildingArchive`,`Building archive`)]});case`succeeded`:return e(`span`,{className:`inline-flex items-center gap-1 rounded bg-success/10 px-1.5 py-0.5 text-[10px] font-medium text-success`,children:[r(w,{className:`h-3 w-3`}),n(`backup.backupRunsPanel.succeeded`,`Succeeded`)]});case`failed`:return e(`span`,{className:`inline-flex items-center gap-1 rounded bg-danger/10 px-1.5 py-0.5 text-[10px] font-medium text-danger`,children:[r(A,{className:`h-3 w-3`}),n(`backup.backupRunsPanel.failed`,`Failed`)]});case`cancelled`:return e(`span`,{className:`inline-flex items-center gap-1 rounded bg-amber-500/10 px-1.5 py-0.5 text-[10px] font-medium text-amber-700 dark:text-amber-300`,title:n(`backup.backupRunsPanel.stoppedBeforeCompletingEveryDestination`,`Stopped before completing every destination — not a success`),children:[r(me,{className:`h-3 w-3`}),n(`backup.backupRunsPanel.stopped`,`Stopped`)]})}}function En({run:t}){let{t:n}=X();if(t.state===`queued`)return r(`span`,{className:`text-foreground-subtle`,children:t.queuePosition===void 0?r(`span`,{className:`italic`,children:n(`backup.backupRunsPanel.waitingItsTurn`,`waiting its turn`)}):e(`span`,{className:`inline-flex items-center gap-1`,children:[r(`span`,{className:t.queuePosition===1?`rounded bg-primary/10 px-1.5 py-0.5 text-[10px] font-medium text-primary`:`rounded bg-foreground-subtle/10 px-1.5 py-0.5 text-[10px] font-medium`,children:kn(t.queuePosition)}),n(`backup.backupRunsPanel.inLine`,`in line`)]})});if(t.state===`running`&&t.phase===`building`)return e(`span`,{className:`inline-flex items-center gap-1.5 text-foreground`,children:[r(_e,{className:`h-3 w-3 text-primary`}),r(`span`,{className:`tabular-nums font-medium animate-pulse`,children:Z(t.stagedBytes)}),r(`span`,{className:`text-foreground-subtle`,children:n(`backup.backupRunsPanel.stagedSoFar`,`staged so far`)})]});if(t.state===`running`){let i=t.archiveSizeBytes;return e(`span`,{className:`inline-flex items-center gap-1.5 text-foreground`,children:[r(he,{className:`h-3 w-3 text-primary`}),e(`span`,{className:`tabular-nums font-medium`,children:[Z(t.uploadedBytes),i===void 0?``:` / ${Z(i)}`]}),r(`span`,{className:`text-foreground-subtle`,children:n(`backup.backupRunsPanel.toCurrentDestination`,`to current destination`)})]})}let i=t.archiveSizeBytes??(t.stagedBytes>0?t.stagedBytes:void 0);return i===void 0?r(`span`,{className:`text-foreground-subtle italic`,children:`—`}):r(`span`,{className:`tabular-nums text-foreground`,children:n(`backup.runsPanel.archiveSize`,{size:Z(i)})})}function Dn({run:t}){let{t:n}=X(),i=t.destinationIds.length,a=t.completedDestinationIds.length,o=t.failedDestinationIds.length;return i===0?r(`span`,{className:`text-foreground-subtle italic`,children:n(`backup.backupRunsPanel.notResolvedYet`,`not resolved yet`)}):e(`div`,{className:`flex flex-col gap-0.5`,children:[r(`span`,{className:`text-foreground-subtle`,title:t.destinationIds.join(`, `),children:n(`backup.runsPanel.targets`,{count:i})}),e(`span`,{className:`inline-flex items-center gap-2 text-[10px]`,children:[a>0&&r(`span`,{className:`text-success`,title:n(`backup.backupRunsPanel.keptTheirArchive`,`Kept their archive: {{value1}}`,{value1:t.completedDestinationIds.join(`, `)}),children:n(`backup.runsPanel.completed`,{count:a})}),o>0&&r(`span`,{className:`text-danger`,title:n(`backup.backupRunsPanel.failed2`,`Failed: {{value1}}`,{value1:t.failedDestinationIds.join(`, `)}),children:n(`backup.runsPanel.failedCount`,{count:o})})]})]})}function On({run:t,now:n}){let{t:i}=X();return t.state===`queued`?r(`span`,{children:i(`backup.runsPanel.queuedAgo`,{elapsed:An(n-t.requestedAt)})}):t.startedAt===void 0?r(`span`,{children:`—`}):t.finishedAt===void 0?r(`span`,{children:i(`backup.runsPanel.runningFor`,{elapsed:An(n-t.startedAt)})}):e(`div`,{className:`flex flex-col gap-0.5`,children:[r(`span`,{children:jn(t.finishedAt)}),r(`span`,{className:`text-[10px]`,children:i(`backup.runsPanel.took`,{elapsed:An(t.finishedAt-t.startedAt)})})]})}function kn(e){if(e<=1)return`next`;let t=e%100;if(t>=11&&t<=13)return`${e}th`;switch(e%10){case 1:return`${e}st`;case 2:return`${e}nd`;case 3:return`${e}rd`;default:return`${e}th`}}function An(e){let t=Math.max(0,Math.floor(e/1e3));if(t<60)return`${t}s`;let n=Math.floor(t/60);return n<60?`${n}m ${String(t%60).padStart(2,`0`)}s`:`${Math.floor(n/60)}h ${String(n%60).padStart(2,`0`)}m`}function jn(e){return new Date(e).toLocaleString(void 0,{day:`2-digit`,month:`short`,hour:`2-digit`,minute:`2-digit`})}o();var Mn=[[`backup`,`list`]];function Nn({initialDestinationId:n,initialArchiveId:o,onClose:c,onScheduled:l}){let{t:u}=X(),d=s(),[f,p]=a(n&&o?2:1),[m,h]=a(n),[g,_]=a(o),[v,y]=a(new Set),[b,x]=a(``),{data:S}=Ie(),C=S??[],{data:w,isLoading:T}=st({destinationId:m??``},{enabled:!!m}),E=w??[];i(()=>{if(m!==void 0)return;let e=C.filter(e=>e.restoreSupported);e.length===1&&h(e[0].id)},[m,C]);let{data:D}=Ke({destinationId:m??``,backupId:g??``},{enabled:!!m&&!!g}),O=t(()=>D?.locations??[],[D]);i(()=>{O.length!==0&&y(e=>e.size===0?new Set(O):e)},[O]);let k=ze({onSuccess:()=>{d.invalidateQueries({queryKey:Mn}),l(),c()}}),A=e=>{y(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},j=E.find(e=>e.id===g),te=j?.encryption!==void 0,ne=zt(j?.databases,D?.sqliteSnapshots),M=Lt(ne),re=!!m&&!!g,ie=M||v.size>0,ae=re&&ie&&!k.isPending&&(!te||b.trim().length>0),oe=()=>{!m||!g||k.mutate({destinationId:m,backupId:g,...M?{}:{locations:[...v]},...te?{backupSecretKey:b.trim()}:{}})};return r(z,{open:!0,onOpenChange:e=>!e&&c(),children:e(J,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[e(G,{children:[r(U,{children:u(`backup.restoreWizard.restoreBackup`,`Restore Backup`)}),r(`p`,{className:`text-xs text-foreground-subtle`,children:u(`backup.restoreWizard.stepOf`,{step:f,name:f===1?u(`backup.restoreWizard.pickSource`,`pick source`):f===2?u(`backup.restoreWizard.pickLocations`,`pick locations`):u(`backup.restoreWizard.confirmStep`)})})]}),e(W,{children:[f===1&&r(Pn,{destinations:C,destinationId:m,onPickDestination:e=>{h(e),_(void 0),y(new Set)},archives:E,archivesLoading:T,archiveId:g,onPickArchive:_}),f===2&&r(Fn,{locations:O,picked:v,onToggle:A,databases:ne,snapshotsOnly:M}),f===3&&r(In,{destinationName:C.find(e=>e.id===m)?.displayName??m??``,archive:j,picked:[...v],databases:ne,snapshotsOnly:M}),f===3&&j?.encryption!==void 0&&r(Ln,{keyId:j.encryption.keyId,value:b,onChange:x}),f===3&&k.error&&r(`p`,{role:`alert`,className:`px-4 pb-2 text-xs text-danger`,children:k.error.message})]}),e(K,{className:`justify-between`,children:[r(`div`,{children:f>1&&e(L,{variant:`outline`,size:`sm`,onClick:()=>p(e=>e===3?2:1),children:[r(ee,{className:`h-3 w-3`}),u(`common.back`,`Back`)]})}),e(`div`,{className:`flex items-center gap-2`,children:[r(L,{variant:`outline`,size:`sm`,onClick:c,children:u(`common.cancel`,`Cancel`)}),f<3?e(L,{size:`sm`,disabled:f===1&&!re||f===2&&!ie,onClick:()=>p(e=>e===1?2:3),children:[u(`common.next`,`Next`),r(ce,{className:`h-3 w-3`})]}):e(L,{size:`sm`,onClick:oe,disabled:!ae,children:[k.isPending?r(N,{className:`h-3.5 w-3.5 animate-spin`}):r(P,{className:`h-3.5 w-3.5`}),u(`backup.restoreWizard.scheduleRestore`,`Schedule Restore`)]})]})]})]})})}function Pn({destinations:t,destinationId:n,onPickDestination:i,archives:a,archivesLoading:o,archiveId:s,onPickArchive:c}){let{t:l}=X(),u=t.filter(e=>e.restoreSupported);return e(`div`,{className:`p-4 space-y-3`,children:[e(`div`,{className:`space-y-1.5`,children:[r(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:l(`backup.restoreWizard.destination`,`Destination`)}),r(k,{value:n??``,onChange:e=>i(e.target.value),options:[{value:``,label:l(`backup.restoreWizard.selectDestination`,`Select destination…`)},...u.map(e=>({value:e.id,label:`${e.displayName} (${e.kind})`}))]})]}),e(`div`,{className:`space-y-1.5`,children:[r(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:l(`backup.restoreWizard.archive`,`Archive`)}),!n&&r(`div`,{className:`text-xs text-foreground-subtle italic`,children:l(`backup.restoreWizard.pickADestinationFirst`,`Pick a destination first.`)}),n&&o&&r(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:l(`backup.restoreWizard.readingArchives`,`Reading archives…`)}),n&&!o&&a.length===0&&r(`div`,{className:`text-xs text-foreground-subtle italic`,children:l(`backup.restoreWizard.noArchivesAvailableAtThis`,`No archives available at this destination.`)}),n&&a.length>0&&r(`div`,{className:`rounded border border-border bg-background divide-y divide-border max-h-64 overflow-y-auto`,children:a.map(t=>{let n=s===t.id;return e(`label`,{className:`flex items-center justify-between px-3 py-2 text-xs cursor-pointer ${n?`bg-primary/10`:`hover:bg-primary/5`}`,children:[e(`div`,{className:`flex items-center gap-2`,children:[r(we,{name:`archive`,checked:n,onChange:()=>c(t.id),className:`accent-primary`}),e(`div`,{children:[e(`div`,{className:`flex items-center gap-1 font-medium text-foreground`,children:[t.encryption!==void 0&&r(se,{className:`h-3 w-3 text-success`,"aria-label":l(`backup.restoreWizard.encryptedKey`,`encrypted (key {{keyId}})`,{keyId:t.encryption.keyId})}),t.label??t.id]}),r(`div`,{className:`text-[10px] text-foreground-subtle`,children:new Date(t.createdAt).toLocaleString()}),r(`div`,{className:`pt-1`,children:r(Q,{databases:zt(t.databases,void 0)})})]})]}),r(`span`,{className:`text-[10px] text-foreground-subtle tabular-nums`,children:Z(t.sizeBytes)})]},t.id)})})]})]})}function Fn({locations:t,picked:n,onToggle:i,databases:a,snapshotsOnly:o}){let{t:s}=X();return o?e(`div`,{className:`space-y-3 p-4`,children:[e(`div`,{className:`space-y-1.5`,children:[r(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:s(`backup.restoreWizard.databasesInThisArchive`,`Databases in this archive`)}),r(Q,{databases:a})]}),r(`div`,{className:`rounded border border-info/30 bg-info/10 px-3 py-2 text-[11px] text-info`,children:s(`backup.restoreWizard.snapshotsOnlyRestoringThisArchive`,`Snapshots only: restoring this archive replaces just these databases. It does NOT touch configuration, addons, addon data or certificates.`)})]}):t.length===0?r(`div`,{className:`p-4`,children:r(`div`,{className:`text-xs text-foreground-subtle`,children:s(`backup.restoreWizard.loadingArchiveManifestIfThis`,`Loading archive manifest… If this persists, the archive may predate manifests — restoring will apply everything in the tarball.`)})}):e(`div`,{className:`p-4 space-y-3`,children:[e(`div`,{className:`space-y-1.5`,children:[r(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:s(`backup.restoreWizard.databasesInThisArchive`,`Databases in this archive`)}),r(Q,{databases:a})]}),r(`div`,{className:`rounded border border-warning/30 bg-warning/10 px-3 py-2 text-[11px] text-warning`,children:s(`backup.restoreWizard.selectedEntriesWillOverwriteLive`,`Selected entries will overwrite live data on the next server restart. Unchecked entries stay current.`)}),e(`div`,{className:`space-y-1.5`,children:[r(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:s(`common.apply`,`Apply`)}),r(`div`,{className:`rounded border border-border bg-background divide-y divide-border max-h-64 overflow-y-auto`,children:t.map(t=>e(`label`,{className:`flex items-center gap-2 px-3 py-2 text-xs hover:bg-primary/5 cursor-pointer`,children:[r(F,{checked:n.has(t),onChange:()=>i(t),className:`accent-primary`}),r(`span`,{className:`font-mono text-foreground`,children:t}),r(`span`,{className:`ml-auto text-[10px] text-foreground-subtle`,children:Bn(t)})]},t))})]})]})}function In({destinationName:t,archive:n,picked:i,databases:a,snapshotsOnly:o}){let{t:s}=X();return e(`div`,{className:`p-4 space-y-3 text-xs`,children:[r(`div`,{className:`rounded border border-warning/30 bg-warning/10 px-3 py-2 text-warning`,children:s(`backup.restoreWizard.restoreIsAppliedAtNext`,`Restore is applied at next server boot. Active connections will drop when you restart.`)}),e(`dl`,{className:`space-y-1.5`,children:[r(Rn,{term:`Destination`,value:t}),r(Rn,{term:`Archive`,value:n?.label??n?.id??`—`}),n&&r(Rn,{term:`Created`,value:`${new Date(n.createdAt).toLocaleString()} · ${Z(n.sizeBytes)}`}),e(`div`,{className:`flex justify-between gap-3`,children:[r(`dt`,{className:`text-foreground-subtle`,children:s(`backup.restoreWizard.databases`,`Databases`)}),r(`dd`,{className:`text-right`,children:r(Q,{databases:a})})]}),r(Rn,{term:`Locations`,value:o?`none (configuration is not touched)`:i.length>0?i.join(`, `):`— (full archive)`})]})]})}function Ln({keyId:t,value:n,onChange:i}){let{t:a}=X();return e(`div`,{className:`space-y-1.5 px-4 pb-3`,children:[r(`label`,{htmlFor:`restore-backup-key`,className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:a(`backup.restoreWizard.backupKey`,`Backup key`)}),r(I,{id:`restore-backup-key`,type:`password`,autoComplete:`off`,spellCheck:!1,value:n,onChange:e=>i(e.target.value),placeholder:a(`backup.restoreWizard.dominevoBackupSecretV1`,`dominevo-backup-secret-v1:…`),className:`w-full rounded border border-border bg-background px-2 py-1.5 font-mono text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`}),r(`p`,{className:`text-[11px] text-foreground-subtle`,children:r(ht,{i18nKey:`backup.restoreWizard.encryptedTo`,values:{keyId:t},components:{mono:r(`span`,{className:`font-mono`})}})})]})}function Rn({term:t,value:n}){return e(`div`,{className:`flex justify-between gap-3`,children:[r(`dt`,{className:`text-foreground-subtle`,children:t}),r(`dd`,{className:`text-foreground font-mono text-right truncate`,children:n})]})}var zn={db:`Database`,addons:`Addon configs`,"addons-data":`Addon data`,tls:`TLS certificates`,cache:`Cache`,data:`Top-level data`};function Bn(e){return zn[e]??``}o();function Vn(){let{t}=X(),n=j(),o=xe(),{state:s,openNew:c,openEdit:l,close:u}=ve({editKey:`edit`,newKey:`new`}),d=Ye(),f=d.data??[],[p,m]=a(null),[h,g]=a(!1),[_,v]=a(!1),[y,b]=a(!1),S=s.mode===`edit`?f.find(e=>e.id===s.id)??null:null;i(()=>{s.mode===`edit`&&!d.isLoading&&S===null&&u()},[s.mode,d.isLoading,S,u]);let C=s.mode===`new`||s.mode===`edit`&&S!==null,w=async()=>{await n({title:t(`system.backup.restartServerNow`,`Restart server now?`),message:t(`system.backup.activeConnectionsWillDropAnd`,`Active connections will drop and the apply-backup hook will run before boot.`),confirmLabel:t(`system.backup.restart`,`Restart`),variant:`warning`})&&o.mutate({confirm:!0})};return e(St,{embedded:!0,children:[e(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,"data-testid":`backup-actions`,children:[e(L,{variant:`outline`,size:`sm`,type:`button`,onClick:()=>b(!0),"data-testid":`backup-now`,children:[r(x,{className:`h-3.5 w-3.5`}),t(`system.backup.backUpNow`,`Back up now`)]}),e(L,{variant:`outline`,size:`sm`,type:`button`,onClick:()=>g(!0),children:[r(P,{className:`h-3.5 w-3.5`}),t(`system.backup.restore`,`Restore…`)]}),e(L,{size:`sm`,type:`button`,onClick:c,"data-testid":`backup-new-entry`,children:[r(le,{className:`h-3.5 w-3.5`}),t(`system.backup.newEntry`,`New entry`)]})]}),_&&r(`div`,{className:`rounded-lg border border-warning/30 bg-warning/10 px-3 py-2.5 text-xs text-warning`,children:e(`div`,{className:`flex items-center justify-between gap-3`,children:[e(`div`,{className:`flex items-center gap-2`,children:[r(P,{className:`h-3.5 w-3.5`}),r(`span`,{children:t(`system.backup.restoreScheduledRestartTheServer`,`Restore scheduled. Restart the server to apply.`)})]}),e(L,{size:`sm`,variant:`outline`,type:`button`,onClick:()=>{w()},disabled:o.isPending,children:[o.isPending?r(N,{className:`h-3.5 w-3.5 animate-spin`}):r(P,{className:`h-3.5 w-3.5`}),t(`system.backup.restartNow`,`Restart Now`)]})]})}),r(ln,{}),r(Sn,{}),r(Kt,{onEdit:e=>l(e.id),onOpenRestoreWizard:e=>m(e)}),C&&r(_n,{entry:S,onClose:u,onSaved:u}),y&&r(an,{onClose:()=>b(!1)}),(p||h)&&r(Nn,{...p?{initialDestinationId:p.destinationId,initialArchiveId:p.archiveId}:{},onClose:()=>{m(null),g(!1)},onScheduled:()=>v(!0)})]})}var Hn=[`locked`,`reset`,`shares-backup`,`recovery-key`,`rotation-pending`,`orphans`],Un={"key-missing":`helpers.keychainNotices.lockedKeyMissing`,"wrong-key":`helpers.keychainNotices.lockedWrongKey`,"key-file-unreadable":`helpers.keychainNotices.lockedKeyFileUnreadable`,"store-unavailable":`helpers.keychainNotices.lockedStoreUnavailable`,"not-initialized":`helpers.keychainNotices.lockedNotInitialized`,"decrypt-failed":`helpers.keychainNotices.lockedDecryptFailed`};function Wn(e){let t=Un[e];return t===void 0?e:Y.t(t)}function Gn({status:e,reset:t,pendingReentry:n,orphans:r}){let i=e.keychain.state===`locked`,a=e.keySource??e.configuredSource,o=[];return e.keychain.state===`locked`&&o.push({id:`locked`,tone:`danger`,title:Y.t(`helpers.keychainNotices.locked`,{reason:Wn(e.keychain.reason)})}),t!==null&&t.acknowledgedAt===null&&o.push({id:`reset`,tone:`danger`,title:n>0?Y.t(`helpers.keychainNotices.resetPending`,{count:n}):Y.t(`helpers.keychainNotices.resetDone`)}),a.sharesBackupWithDatabase&&o.push({id:`shares-backup`,tone:`warning`,title:Y.t(`helpers.keychainNotices.sharesBackup`)}),!i&&e.recoveryKeyDownloadedAt===null&&o.push({id:`recovery-key`,tone:`warning`,title:Y.t(`helpers.keychainNotices.recoveryKey`)}),!i&&e.rotationPending&&o.push({id:`rotation-pending`,tone:`info`,title:Y.t(`helpers.keychainNotices.rotationPending`)}),!i&&r>0&&o.push({id:`orphans`,tone:`info`,title:Y.t(`helpers.keychainNotices.orphans`,{count:r})}),[...o].sort((e,t)=>Hn.indexOf(e.id)-Hn.indexOf(t.id))}var Kn={dateStyle:`short`,timeStyle:`short`};function qn(e){return e===null?`—`:new Date(e).toLocaleString(void 0,Kn)}function Jn({value:t,copyValue:n,srLabel:i,maxWidthClass:a,className:o}){let s=n??t;return e(`span`,{className:f(`flex min-w-0 items-center gap-0.5`,a),children:[r(`span`,{className:f(`min-w-0 truncate font-mono`,o),title:s,children:t}),r(Se,{value:s,srLabel:i,className:`h-6 shrink-0 px-1.5`})]})}o();var Yn=new Set([`reveal`,`download-recovery-key`,`rotate-master-key`,`reset`]);function Xn(e){return[{mobile:`detail`,key:`at`,header:e(`system.keychainAuditTable.colWhen`),render:e=>qn(e.at)},{mobile:`primary`,key:`action`,header:e(`system.keychainAuditTable.colAction`),render:e=>r(R,{variant:Yn.has(e.action)?`warning`:`default`,children:e.action})},{mobile:`detail`,key:`actor`,header:e(`system.keychainAuditTable.colActor`),render:e=>r(`span`,{className:`font-mono`,children:e.actor})},{mobile:`detail`,key:`ref`,header:e(`system.keychainAuditTable.colRef`),render:e=>e.ref===null?r(`span`,{className:`text-foreground-subtle`,children:`—`}):r(Jn,{value:e.ref,srLabel:`secret ref`,maxWidthClass:`max-w-[22rem]`})},{mobile:`hidden`,key:`detail`,header:e(`system.keychainAuditTable.colDetail`),render:e=>r(`span`,{className:`text-foreground-muted`,children:e.detail??``})}]}function Zn({entries:n}){let{t:i}=X(),[o,s]=a(0),c=t(()=>Xn(i),[i]);if(n===void 0)return r(`p`,{className:`text-xs text-foreground-subtle`,children:i(`common.loading`,`Loading…`)});let l=Math.max(1,Math.ceil(n.length/25)),u=Math.min(o,l-1),d=u*25,f=n.slice(d,d+25);return e(`div`,{className:`space-y-2`,children:[r(V,{columns:c,rows:f,rowKey:e=>e.id,minWidthPx:760,emptyMessage:i(`secrets.keychainAuditTable.nothingHasBeenAuditedYet`,`Nothing has been audited yet.`)}),n.length>25&&e(`div`,{className:`flex flex-wrap items-center justify-between gap-2 text-[11px] text-foreground-subtle`,children:[r(`span`,{children:i(n.length>=500?`system.keychainAuditTable.rangeRecent`:`system.keychainAuditTable.range`,{from:d+1,to:d+f.length,total:n.length})}),e(`span`,{className:`inline-flex items-center gap-1`,children:[r(L,{size:`sm`,variant:`outline`,"aria-label":i(`secrets.keychainAuditTable.previousPage`,`Previous page`),disabled:u===0,onClick:()=>s(u-1),children:r(m,{className:`h-3.5 w-3.5`,"aria-hidden":!0})}),e(`span`,{className:`tabular-nums`,children:[u+1,` / `,l]}),r(L,{size:`sm`,variant:`outline`,"aria-label":i(`secrets.keychainAuditTable.nextPage`,`Next page`),disabled:u>=l-1,onClick:()=>s(u+1),children:r(h,{className:`h-3.5 w-3.5`,"aria-hidden":!0})})]})]})]})}function Qn(e,t){switch(e){case`locked`:return r(L,{size:`sm`,variant:`danger`,disabled:t.busy,onClick:t.onReset,children:Y.t(`secrets.keychainNoticeContent.resetKeychain`,`Reset keychain`)});case`reset`:return r(L,{size:`sm`,variant:`outline`,disabled:t.busy,onClick:t.onAcknowledgeReset,children:Y.t(`secrets.keychainNoticeContent.dismiss`,`Dismiss`)});case`recovery-key`:return r(L,{size:`sm`,variant:`outline`,disabled:t.busy,onClick:t.onDownload,children:Y.t(`secrets.keychainNoticeContent.download`,`Download`)});case`rotation-pending`:return r(L,{size:`sm`,variant:`outline`,disabled:t.busy,onClick:t.onRotate,children:Y.t(`secrets.keychainNoticeContent.rotate`,`Rotate`)});case`orphans`:return r(L,{size:`sm`,variant:`outline`,onClick:t.onShowOrphans,children:Y.t(`secrets.keychainNoticeContent.review`,`Review`)});case`shares-backup`:return null}}function $n(e,t){switch(e){case`locked`:return r(`p`,{children:Y.t(`secrets.keychainNoticeContent.noValueCanBeRead`,`No value can be read or stored. If the master key is lost for good, Reset archives every stored value and starts a new keychain; every secret field then reads “not set”.`)});case`reset`:return t.reset===null?null:r(er,{reset:t.reset,pending:t.pendingReentry});case`shares-backup`:return r(`p`,{children:r(ht,{i18nKey:`secrets.keychainNoticeContent.backupKeyFile`,components:{code:r(`code`,{className:`font-mono`})}})});case`recovery-key`:return r(`p`,{children:Y.t(`secrets.keychainNoticeContent.withoutACopyOfThe`,`Without a copy of the master key, the stored values cannot be recovered.`)});case`rotation-pending`:return r(`p`,{children:Y.t(`secrets.keychainNoticeContent.theKeychainUnlockedWithA`,`The keychain unlocked with a previous key. Rotate to move onto the configured one.`)});case`orphans`:return null}}function er({reset:t,pending:n}){let{t:i}=X(),a=t.actor===`trigger-file`?i(`secrets.keychainNoticeContent.resetByTrigger`):i(`secrets.keychainNoticeContent.resetByAdmin`,{actor:t.actor});return e(`div`,{className:`space-y-1.5`,children:[r(`p`,{children:i(`secrets.keychainNoticeContent.resetDetail`,{when:qn(t.at),by:a,archived:t.archived})}),n.length>0&&r(`ul`,{className:`max-h-40 space-y-0.5 overflow-y-auto rounded-md border border-border bg-background p-2 font-mono text-[11px] text-foreground`,children:n.map(t=>e(`li`,{className:`break-all`,children:[t.owner,` · `,t.scope,` · `,t.fieldPath]},t.ref))})]})}o();var tr=2,nr={danger:{icon:y,text:`text-danger`,border:`border-danger/40`},warning:{icon:T,text:`text-warning`,border:`border-warning/40`},info:{icon:ie,text:`text-info`,border:`border-border`}};function rr({notices:t,renderAction:n,renderDetail:i}){let{t:o}=X(),[s,c]=a(!1),l=t[0];if(l===void 0)return null;let u=t.length>tr,d=u&&!s?t.slice(0,1):t,p=t.length-d.length;return e(`section`,{"aria-label":o(`secrets.keychainNotices.keychainNotices`,`Keychain notices`),className:f(`rounded-lg border bg-surface`,nr[l.tone].border),children:[r(`ul`,{className:`divide-y divide-border`,children:d.map(e=>r(ir,{notice:e,action:n(e.id),detail:i(e.id)},e.id))}),u&&r(`div`,{className:`border-t border-border px-3 py-1`,children:e(L,{size:`sm`,variant:`ghost`,"aria-expanded":s,onClick:()=>c(e=>!e),children:[r(fe,{className:f(`h-3.5 w-3.5 transition-transform`,s&&`rotate-180`),"aria-hidden":!0}),s?o(`secrets.keychainNotices.showLess`,`Show less`):o(`secrets.keychainNotices.more`,`{{hidden}} more`,{hidden:p})]})})]})}function ir({notice:t,action:n,detail:i}){let{t:o}=X(),[s,c]=a(!1),l=nr[t.tone],u=l.icon,d=i!=null,p=`keychain-notice-${t.id}`;return e(`li`,{className:`px-3 py-2`,children:[e(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center sm:gap-3`,children:[e(`p`,{className:`flex min-w-0 flex-1 items-start gap-2 text-xs text-foreground`,children:[r(u,{className:f(`mt-0.5 h-3.5 w-3.5 shrink-0`,l.text),"aria-hidden":!0}),r(`span`,{className:`min-w-0 break-words`,children:t.title})]}),e(`div`,{className:`flex shrink-0 flex-wrap items-center gap-1.5 pl-5 sm:pl-0`,children:[d&&r(L,{size:`sm`,variant:`ghost`,"aria-expanded":s,"aria-controls":p,onClick:()=>c(e=>!e),children:o(`secrets.keychainNotices.details`,`Details`)}),n]})]}),d&&s&&r(`div`,{id:p,className:`mt-2 pl-5 text-xs text-foreground-muted`,children:i})]})}var ar={"mounted-file":`Mounted key file (/run/secrets)`,"previous-mounted-file":`Previous mounted key file`,platform:`OS keychain`,"default-file":`Default key file (data volume)`},or=8;function sr({status:t,busy:n,onDownload:i,onRotate:a,onPurge:o}){let{t:s}=X(),c=t.keychain.state===`locked`,l=t.keySource??t.configuredSource;return r(be,{headingId:`keychain-status`,title:s(`secrets.keychainStatusCard.keychain`,`Keychain`),icon:pe,actions:e(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[t.retiredWraps>0&&r(L,{size:`sm`,variant:`ghost`,disabled:n||c,onClick:o,children:s(`secrets.keychainStatusCard.purge`,{count:t.retiredWraps})}),r(L,{size:`sm`,variant:`outline`,disabled:n||c,onClick:a,children:s(`secrets.keychainStatusCard.rotateKey`,`Rotate key`)}),r(L,{size:`sm`,variant:`outline`,disabled:n||c,onClick:i,children:s(`secrets.keychainStatusCard.downloadRecoveryKey`,`Download recovery key`)})]}),children:e(`dl`,{className:`${p} grid grid-cols-1 gap-x-6 gap-y-3 sm:grid-cols-2 xl:grid-cols-4`,children:[e(cr,{label:s(`secrets.keychainStatusCard.state`,`State`),children:[c?e(R,{variant:`danger`,className:`gap-1`,children:[r(se,{className:`h-3 w-3`,"aria-hidden":!0}),s(`secrets.keychainStatusCard.locked`,`Locked`)]}):e(R,{variant:`success`,className:`gap-1`,children:[r(u,{className:`h-3 w-3`,"aria-hidden":!0}),s(`secrets.keychainStatusCard.unlocked`,`Unlocked`)]}),r(`span`,{className:`ml-2 text-foreground-subtle`,children:s(`common.stored`,{count:t.secretCount})})]}),e(cr,{label:s(`secrets.keychainStatusCard.keySource`,`Key source`),children:[r(`span`,{className:`block`,children:ar[l.kind]}),l.path!==void 0&&r(Jn,{value:l.path,srLabel:`key path`})]}),r(cr,{label:s(`secrets.keychainStatusCard.fingerprint`,`Fingerprint`),children:t.fingerprint===null?r(`span`,{className:`text-foreground-subtle`,children:`—`}):e(`span`,{className:`inline-flex items-center gap-0.5`,children:[r(`span`,{className:`font-mono`,title:t.fingerprint,children:t.fingerprint.slice(0,or)}),r(Se,{value:t.fingerprint,srLabel:`fingerprint`})]})}),r(cr,{label:s(`secrets.keychainStatusCard.recoveryKey`,`Recovery key`),children:t.recoveryKeyDownloadedAt===null?r(R,{variant:`warning`,children:s(`secrets.keychainStatusCard.notTaken`,`Not taken`)}):r(`span`,{children:s(`secrets.keychainStatusCard.taken`,{when:qn(t.recoveryKeyDownloadedAt)})})})]})})}function cr({label:t,children:n}){return e(`div`,{className:`min-w-0 text-xs`,children:[r(`dt`,{className:`text-foreground-subtle`,children:t}),r(`dd`,{className:`mt-0.5 min-w-0 text-foreground`,children:n})]})}o();var lr=1e3;function ur({revealed:t,onClose:n}){let{t:o}=X(),[s,l]=a(it);i(()=>{if(t===null)return;let e=Date.now();l(it);let r=setTimeout(n,it),i=setInterval(()=>l(Math.max(0,it-(Date.now()-e))),lr);return()=>{clearTimeout(r),clearInterval(i)}},[t,n]);let u=Math.ceil(s/1e3);return r(z,{open:t!==null,onOpenChange:e=>!e&&n(),children:r(J,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,children:t!==null&&e(c,{children:[e(G,{children:[r(U,{className:`break-all`,children:t.entry.fieldPath}),e(Ze,{className:`break-all`,children:[t.entry.owner,` · `,t.entry.scope]})]}),r(W,{children:r(`pre`,{"data-testid":`revealed-value`,className:`whitespace-pre-wrap break-all rounded-md border border-border bg-background p-3 font-mono text-xs text-foreground`,children:t.value})}),e(K,{className:`flex-col items-stretch gap-2 sm:flex-row sm:items-center sm:justify-between`,children:[r(`p`,{className:`text-[11px] text-foreground-subtle`,children:o(`secrets.revealDialog.recorded`,{seconds:u})}),e(`div`,{className:`flex justify-end gap-2`,children:[r(Se,{value:t.value,label:o(`common.copy`,`Copy`),srLabel:`revealed value`}),r(L,{size:`sm`,variant:`outline`,onClick:n,children:o(`secrets.revealDialog.hide`,`Hide`)})]})]})]})})})}var dr={orphan:{labelKey:`secrets.secretsTableState.usageOrphan`,variant:`warning`,hintKey:`secrets.secretsTableState.usageOrphanHint`,rank:0},unknown:{labelKey:`secrets.secretsTableState.usageUnknown`,variant:`default`,hintKey:`secrets.secretsTableState.usageUnknownHint`,rank:1},"in-use":{labelKey:`secrets.secretsTableState.usageInUse`,variant:`success`,hintKey:`secrets.secretsTableState.usageInUseHint`,rank:2}},fr=[{id:`all`,labelKey:`common.all`},{id:`in-use`,labelKey:`secrets.secretsTableState.usageInUse`},{id:`orphan`,labelKey:`secrets.secretsTableState.filterOrphans`},{id:`unknown`,labelKey:`secrets.secretsTableState.usageUnknown`}],pr=`system`;function mr(t){let{t:n}=X(),{secrets:i,filter:a,onFilterChange:o,onDeleteOrphans:s,deleting:c,locked:l}=t;if(i===void 0)return r(`p`,{className:`text-xs text-foreground-subtle`,children:n(`common.loading`,`Loading…`)});let u=e=>e===`all`?i.length:i.filter(t=>t.usage===e).length,d=i.filter(e=>e.usage===`orphan`).map(e=>e.ref),f=a===`all`?i:i.filter(e=>e.usage===a);return e(`div`,{className:`space-y-2`,children:[e(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[r(`div`,{className:`flex flex-wrap gap-1`,role:`group`,"aria-label":n(`secrets.secretsTable.filterByUsage`,`Filter by usage`),children:fr.map(t=>e(L,{size:`sm`,variant:a===t.id?`secondary`:`ghost`,"aria-pressed":a===t.id,className:a===t.id?`ring-1 ring-border`:void 0,onClick:()=>o(t.id),children:[n(t.labelKey),r(`span`,{className:`text-foreground-subtle tabular-nums`,children:u(t.id)})]},t.id))}),d.length>0&&e(L,{size:`sm`,variant:`outline`,className:`ml-auto`,disabled:c||l,onClick:()=>s(d),children:[r(ue,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),n(`secrets.secretsTableState.deleteOrphans`,{count:d.length})]})]}),r(V,{columns:gr(t),rows:f,rowKey:e=>e.ref,minWidthPx:860,maxBodyHeight:Ee,defaultSort:{columnKey:`owner`,dir:`asc`},emptyMessage:i.length===0?n(`secrets.secretsTable.noValueIsStoredIn`,`No value is stored in the keychain yet.`):n(`secrets.secretsTable.noStoredValueMatchesThis`,`No stored value matches this filter.`)})]})}function hr({owner:t}){let{t:n}=X();return e(`span`,{className:`flex items-center gap-2`,children:[r(xt,{addonId:t,fallback:t===pr?M:O,tileClassName:`bg-surface-hover text-foreground-subtle`,size:`sm`}),r(`span`,{className:`font-medium`,children:t===pr?n(`secrets.secretsTable.hubSystem`,`Hub (system)`):t})]})}function gr({locked:t,onReveal:n,revealing:i}){return[{mobile:`primary`,key:`owner`,header:Y.t(`secrets.secretsTable.owner`,`Owner`),render:e=>r(hr,{owner:e.owner}),sortValue:e=>e.owner},{mobile:`hidden`,key:`scope`,header:Y.t(`secrets.secretsTable.scope`,`Scope`),render:e=>r(`span`,{className:`block max-w-[11rem] truncate font-mono`,title:e.scope,children:e.scope}),sortValue:e=>e.scope},{mobile:`detail`,key:`field`,header:Y.t(`secrets.secretsTable.field`,`Field`),render:e=>r(Jn,{value:e.fieldPath,copyValue:e.ref,srLabel:`secret ref`,maxWidthClass:`max-w-[16rem]`}),sortValue:e=>e.fieldPath},{mobile:`hidden`,key:`updated`,header:Y.t(`secrets.secretsTable.updated`,`Updated`),render:e=>qn(e.updatedAt),sortValue:e=>e.updatedAt},{mobile:`hidden`,key:`last-read`,header:Y.t(`secrets.secretsTable.lastRead`,`Last read`),render:e=>qn(e.lastReadAt),sortValue:e=>e.lastReadAt},{mobile:`detail`,key:`status`,header:Y.t(`secrets.secretsTable.status`,`Status`),render:e=>r(R,{variant:dr[e.usage].variant,title:Y.t(dr[e.usage].hintKey),children:Y.t(dr[e.usage].labelKey)}),sortValue:e=>dr[e.usage].rank},{mobile:`keep`,key:`actions`,header:``,align:`right`,notSortableReason:`Actions`,render:a=>e(L,{size:`sm`,variant:`ghost`,disabled:t||i,"aria-label":Y.t(`secrets.secretsTable.reveal`,`Reveal {{fieldPath}}`,{fieldPath:a.fieldPath}),title:t?Y.t(`secrets.secretsTable.theKeychainIsLocked`,`The keychain is locked`):Y.t(`secrets.secretsTable.revealAudited`,`Reveal (audited)`),onClick:()=>n(a),children:[r(b,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),Y.t(`secrets.secretsTable.reveal2`,`Reveal`)]})}]}function _r(e){return e instanceof Error?e.message:String(e)}function vr(e){let{t}=X(),n=j(),r=oe(),i=E(),a=$e(),o=nt(),s=qe(),c=ct(),l=Ue(),u=Ae(),d=async(t,n)=>{try{await n()}catch(e){await r({title:t,message:_r(e),variant:`danger`})}e()};return{busy:a.isPending||o.isPending||s.isPending||c.isPending,deleting:u.isPending,download:async()=>{await n({title:t(`secrets.useKeychainActions.downloadTitle`),message:t(`secrets.useKeychainActions.downloadMessage`),confirmLabel:t(`secrets.useKeychainActions.downloadConfirm`),variant:`warning`})&&await d(t(`secrets.useKeychainActions.downloadRefused`),async()=>{let e=await a.mutateAsync({});await i({title:t(`secrets.useKeychainActions.recoveryTitle`,{fingerprint:e.fingerprint}),message:t(`secrets.useKeychainActions.recoveryMessage`),defaultValue:e.key,readOnly:!0,confirmLabel:t(`secrets.useKeychainActions.recoveryDone`)})})},rotate:async()=>{await n({title:t(`secrets.useKeychainActions.rotateTitle`),message:t(`secrets.useKeychainActions.rotateMessage`),confirmLabel:t(`secrets.useKeychainActions.rotateConfirm`),variant:`warning`})&&await d(t(`secrets.useKeychainActions.rotateRefused`),async()=>{let e=await o.mutateAsync({});await r({title:t(`secrets.useKeychainActions.rotatedTitle`),message:t(`secrets.useKeychainActions.rotatedMessage`,{fingerprint:e.fingerprint})})})},purge:async()=>{await n({title:t(`secrets.useKeychainActions.purgeTitle`),message:t(`secrets.useKeychainActions.purgeMessage`),confirmLabel:t(`secrets.useKeychainActions.purgeConfirm`),variant:`warning`})&&await d(t(`secrets.useKeychainActions.purgeRefused`),async()=>{await s.mutateAsync({})})},reset:async()=>{await i({title:t(`secrets.useKeychainActions.resetTitle`),message:t(`secrets.useKeychainActions.resetMessage`,{confirmation:`RESET KEYCHAIN`}),confirmLabel:t(`secrets.useKeychainActions.resetConfirm`),validate:e=>e===`RESET KEYCHAIN`?null:t(`secrets.useKeychainActions.resetMismatch`)})===`RESET KEYCHAIN`&&await d(t(`secrets.useKeychainActions.resetRefused`),async()=>{await c.mutateAsync({confirm:de})})},acknowledgeReset:async()=>{await d(t(`secrets.useKeychainActions.dismissFailed`),async()=>{await l.mutateAsync({})})},deleteOrphans:async e=>{await n({title:t(`secrets.useKeychainActions.orphansTitle`,{count:e.length}),message:t(`secrets.useKeychainActions.orphansMessage`),confirmLabel:t(`secrets.useKeychainActions.orphansConfirm`),variant:`danger`})&&await d(t(`secrets.useKeychainActions.orphansRefused`),async()=>{let n=await u.mutateAsync({refs:[...e]});n.kept.length>0&&await r({title:t(`secrets.useKeychainActions.keptTitle`),message:t(`secrets.useKeychainActions.keptMessage`,{deleted:n.deleted.length,kept:n.kept.length})})})}}}o();var yr=`secretsView`;function br(){let[e,t]=mt();return[e.get(yr)===`audit`?`audit`:`values`,n=>{let r=new URLSearchParams(e);n===`values`?r.delete(yr):r.set(yr,n),t(r,{replace:!0})}]}function xr(){let{t:i}=X(),o=Xe({}),s=Me({}),c=ot({limit:500}),l=Pe({}),u=Le(),d=oe(),[f,p]=br(),[m,h]=a(`all`),[g,_]=a(null),v=vr(()=>{o.refetch(),s.refetch(),c.refetch(),l.refetch()}),y=o.data?.keychain.state===`locked`,b=t(()=>(s.data??[]).filter(e=>e.usage===`orphan`).length,[s.data]),x=t(()=>o.data===void 0?[]:Gn({status:o.data,reset:l.data?.reset??null,pendingReentry:l.data?.pendingReentry.length??0,orphans:b}),[o.data,l.data,b]),S={reset:l.data?.reset??null,pendingReentry:l.data?.pendingReentry??[],busy:v.busy,onReset:()=>void v.reset(),onAcknowledgeReset:()=>void v.acknowledgeReset(),onDownload:()=>void v.download(),onRotate:()=>void v.rotate(),onShowOrphans:()=>{h(`orphan`),p(`values`)}},C=async e=>{try{_({entry:e,value:(await u.mutateAsync({ref:e.ref})).value}),s.refetch()}catch(e){await d({title:i(`admin.system.secrets.revealRefused`,`Reveal refused`),message:_t(e),variant:`danger`})}},w=n(()=>_(null),[]);return e(St,{embedded:!0,icon:pe,title:i(`admin.system.secrets.secrets`,`Secrets`),subtitle:i(`admin.system.secrets.passwordsTokensAndKeysEncrypted`,`Passwords, tokens and keys, encrypted in the hub keychain. Values leave the hub only through an audited reveal.`),children:[r(rr,{notices:x,renderAction:e=>Qn(e,S),renderDetail:e=>$n(e,S)}),o.data!==void 0&&r(sr,{status:o.data,busy:v.busy,onDownload:S.onDownload,onRotate:S.onRotate,onPurge:()=>void v.purge()}),e(Be,{value:f,onValueChange:e=>p(e===`audit`?`audit`:`values`),children:[e(De,{children:[r(lt,{value:`values`,children:i(`admin.system.secrets.storedValues`,`Stored values`)}),r(lt,{value:`audit`,children:i(`admin.system.secrets.audit`,`Audit`)})]}),r(Re,{value:`values`,children:r(mr,{secrets:s.data,locked:y,filter:m,onFilterChange:h,onReveal:e=>void C(e),revealing:u.isPending,onDeleteOrphans:e=>void v.deleteOrphans(e),deleting:v.deleting})}),r(Re,{value:`audit`,children:r(Zn,{entries:c.data})})]}),r(ur,{revealed:g,onClose:w})]})}o();function Sr(e){return Object.entries(e).map(([e,t])=>`${e} ${t}`).join(` · `)}function Cr(e){return e.reduce((e,t)=>e+Object.values(t.stores).reduce((e,t)=>e+t,0),0)}function wr(){let{t}=X(),n=j(),i=et(),[o,s]=a(null),[l,u]=a(null),d=async e=>{u(null);try{s(await i.mutateAsync({confirm:e}))}catch(e){u(e instanceof Error?e.message:String(e))}},f=async()=>{o===null||o.status!==`dry-run`||await n({title:t(`systemPage.deletedDevices.confirmTitle`,`Delete the data of deleted devices?`),message:o.devices.map(e=>`#${e.deviceId}: ${Sr(e.stores)}`).join(`
2
2
  `),confirmLabel:t(`systemPage.deletedDevices.confirmLabel`,`Delete`),variant:`danger`})&&await d(!0)},p=[{mobile:`primary`,key:`device`,header:t(`systemPage.deletedDevices.device`,`Device`),render:e=>`#${e.deviceId}`},{mobile:`detail`,key:`stores`,header:t(`systemPage.deletedDevices.stores`,`Data held`),nowrap:!1,render:e=>Sr(e.stores)}];return e(`div`,{className:`space-y-4`,"data-testid":`deleted-devices-data`,children:[r(`p`,{className:`text-sm text-foreground-muted`,children:t(`systemPage.deletedDevices.intro`,`Data that still belongs to devices that were deleted before deletions were recorded: footage, events, history and per-addon settings. Scanning deletes nothing; deleting asks first and shows what goes.`)}),e(`div`,{className:`flex flex-wrap items-center gap-2`,children:[e(L,{variant:`outline`,onClick:()=>void d(!1),disabled:i.isPending,"data-testid":`deleted-devices-scan`,children:[i.isPending?r(N,{className:`mr-2 h-4 w-4 animate-spin`}):r(ae,{className:`mr-2 h-4 w-4`}),t(`systemPage.deletedDevices.scan`,`Scan`)]}),o?.status===`dry-run`&&o.devices.length>0?e(L,{variant:`danger`,onClick:()=>void f(),disabled:i.isPending,"data-testid":`deleted-devices-delete`,children:[r(ue,{className:`mr-2 h-4 w-4`}),t(`systemPage.deletedDevices.delete`,`Delete the data of {{count}} devices…`,{count:o.devices.length})]}):null]}),l===null?null:r(`p`,{className:`text-sm text-danger`,children:l}),o?.status===`skipped`?r(`p`,{className:`text-sm text-warning`,"data-testid":`deleted-devices-skipped`,children:t(`systemPage.deletedDevices.skipped`,`Nothing was listed or deleted: the device list could not be trusted ({{reason}}). Try again.`,{reason:o.reason??``})}):null,o!==null&&o.status!==`skipped`?e(c,{children:[r(`p`,{className:`text-sm`,"data-testid":`deleted-devices-summary`,children:o.status===`cleaned`?t(`systemPage.deletedDevices.cleaned`,`Deleted {{rows}} items of {{count}} devices.`,{rows:Cr(o.devices),count:o.devices.length}):t(`systemPage.deletedDevices.found`,`{{count}} deleted devices still hold {{rows}} items.`,{rows:Cr(o.devices),count:o.devices.length})}),r(V,{columns:p,rows:o.devices,rowKey:e=>e.deviceId,emptyMessage:t(`systemPage.deletedDevices.none`,`No data belongs to a deleted device.`)}),o.unreachable.length>0?r(`p`,{className:`text-xs text-foreground-muted`,children:t(`systemPage.deletedDevices.unreachable`,`Not asked (unreachable): {{names}}`,{names:o.unreachable.join(`, `)})}):null]}):null]})}var Tr=`view`,Er=`kinds`,Dr=`deleted-devices`;function Or(){let{t}=X(),[n,i]=mt(),a=n.get(`view`)===`deleted-devices`?Dr:Er;return e(`div`,{className:p,children:[e(`div`,{className:`mb-3 space-y-2`,children:[r(Be,{appearance:`pills`,value:a,onValueChange:e=>{i(t=>{let n=new URLSearchParams(t);return e===`kinds`?n.delete(Tr):n.set(Tr,e),n},{replace:!0})},children:e(De,{className:`flex flex-wrap gap-1`,children:[r(lt,{value:Er,children:t(`systemPage.data.viewKinds`,`Record kinds`)}),r(lt,{value:Dr,children:t(`systemPage.data.viewDeletedDevices`,`Deleted devices`)})]})}),a===`kinds`?r(`p`,{className:`text-xs text-foreground-muted`,children:t(`systemPage.data.recordsUnifiedIntro`,`Every declared record kind on this hub. Entry kinds can be added, edited and deleted; the rest are read-only. Secret fields are redacted.`)}):null]}),r(a===`kinds`?Te:wr,{})]})}function kr(e){let t=[],n=new Map,r=new Set;for(let i of e){if(r.has(i.id))continue;r.add(i.id);let e=n.get(i.group);e===void 0?(t.push(i.group),n.set(i.group,[i])):e.push(i)}return t.map(e=>({group:e,knobs:n.get(e)??[]}))}function Ar(e,t){let n=t.trim(),r=Number(n);return n===``||!Number.isFinite(r)?{ok:!1,reason:`not-a-number`}:Number.isInteger(r)?r===0&&e.zeroMeansForever?{ok:!0,value:r}:e.min!==void 0&&r<e.min?{ok:!1,reason:`below-min`}:e.max!==void 0&&r>e.max?{ok:!1,reason:`above-max`}:{ok:!0,value:r}:{ok:!1,reason:`not-whole`}}function jr(e,t){let n={[e.key]:t};return e.write.method===`updateScopedSettings`?{method:`updateScopedSettings`,input:{addonId:e.write.addonId,cap:e.write.cap,scope:e.write.scope,patch:n}}:e.deviceId===void 0?null:{method:`updateDeviceSettings`,input:{addonId:e.write.addonId,deviceId:e.deviceId,patch:n}}}o();function Mr({knob:t}){let{t:n}=X(),i=B.useUtils(),[o,s]=a(null),[c,l]=a(null),u=B.addonSettings.updateScopedSettings.useMutation({onSuccess:async()=>{s(null),l(null),await i.retentionSource.listRetentionKnobs.invalidate()},onError:e=>l(e.message)}),d=o??(t.value===null?``:String(t.value)),f=o===null?null:Ar(t,o),p=f!==null&&f.ok?jr(t,f.value):null;return r(rt,{label:n(t.labelKey,t.label),children:e(`div`,{className:`flex flex-wrap items-center gap-2`,children:[r(I,{type:`number`,inputMode:`numeric`,className:`w-24`,value:d,min:t.min,max:t.max,"aria-label":n(t.labelKey,t.label),onChange:e=>s(e.target.value)}),r(`span`,{className:`text-foreground-muted text-sm`,children:t.zeroMeansForever&&t.value===0?n(`retention.forever`,`kept forever`):n(`retention.unit.${t.unit}`,t.unit)}),t.scope===`device`?r(`span`,{className:`text-foreground-subtle text-xs`,children:n(`retention.deviceOverridable`,`a device can override this`)}):null,o===null?null:r(L,{size:`sm`,disabled:p===null||u.isPending,onClick:()=>{p===null||p.method!==`updateScopedSettings`||u.mutate(p.input)},children:n(`retention.save`,`Save`)}),f!==null&&!f.ok?r(`span`,{className:`text-danger text-xs`,children:n(`retention.invalid.${f.reason}`,f.reason)}):null,c===null?null:r(`span`,{className:`text-danger text-xs`,children:c})]})})}function Nr(){let{t}=X(),n=ye(`retention-source`),i=B.retentionSource.listRetentionKnobs.useQuery({},{enabled:n===`present`});return n===`pending`||n===`present`&&i.isLoading?e(`div`,{className:`text-foreground-muted flex items-center gap-2 p-4 text-sm`,children:[r(N,{className:`h-4 w-4 animate-spin`}),t(`retention.loading`,`Loading retention…`)]}):n===`unknown`||i.isError?r(H,{title:t(`retention.errorTitle`,`Could not read the retention settings`),message:t(`retention.errorBody`,`The hub did not answer. Try again in a moment.`)}):n===`absent`||i.data===void 0||i.data.length===0?r(Ce,{icon:g,title:t(`retention.emptyTitle`,`No retention settings`),description:t(`retention.emptyBody`,`No addon lists how long it keeps data.`)}):r(`div`,{className:`flex flex-col gap-3`,children:kr(i.data).map(e=>r(be,{headingId:`retention-${e.group}`,title:t(`retention.group.${e.group}`,e.group),icon:g,children:r(`div`,{className:p,children:e.knobs.map(e=>r(Mr,{knob:e},e.id))})},e.group))})}var Pr={applied:`success`,failed:`danger`,blocked:`warning`,held:`warning`,running:`info`,pending:`default`,"skipped-newer":`neutral`},Fr={applied:`migrations.status.applied`,failed:`migrations.status.failed`,blocked:`migrations.status.blocked`,held:`migrations.status.held`,running:`migrations.status.running`,pending:`migrations.status.pending`,"skipped-newer":`migrations.status.skippedNewer`};function Ir({status:e}){let{t}=X();return r(R,{variant:Pr[e],className:`text-[10px]`,children:t(Fr[e])})}var Lr=[`failed`,`blocked`,`held`,`running`,`pending`,`applied`,`skipped-newer`];function Rr(e){return Lr.indexOf(e)}function zr(e,t){let n=new Map(t.map(e=>[e.meta.id,e])),r=new Map;for(let t of e){let e=n.get(t.id)??null;r.set(t.id,{id:t.id,owner:t.owner,status:t.status,meta:t.meta??e?.meta??null,ledger:t,pending:e,database:t.database,seq:t.seq,appliedAt:t.appliedAt,reason:t.reason??e?.reason??null,error:t.error})}for(let e of t)r.has(e.meta.id)||r.set(e.meta.id,{id:e.meta.id,owner:e.meta.owner,status:e.state===`pending`?`pending`:e.state,meta:e.meta,ledger:null,pending:e,database:e.database,seq:e.meta.seq,appliedAt:null,reason:e.reason,error:null});return[...r.values()]}function Br(e){return e.owner===`hub`&&e.meta!==null&&e.meta.bodyKind!==`procedure`}o();var Vr={searchText:e=>[e.id,e.owner,e.meta?.description??``],facetGroups:[{id:`owner`,value:e=>e.owner},{id:`status`,value:e=>e.status}]};function Hr(e){if(e===null)return`—`;let t=new Date(e);return Number.isNaN(t.getTime())?`—`:t.toLocaleString()}function Ur({rows:n,onOpen:i}){let{t:a}=X(),o=Ge(n,Vr),s=t(()=>[{mobile:`primary`,key:`id`,header:a(`migrations.col.id`,`Migration`),sortValue:e=>e.id,render:t=>e(`div`,{className:`min-w-0 max-w-[22rem]`,children:[r(`div`,{className:`truncate font-mono text-xs text-foreground`,title:t.id,children:t.id}),t.meta!==null&&r(`div`,{className:`truncate text-[10px] text-foreground-subtle`,title:t.meta.description,children:t.meta.description})]})},{mobile:`detail`,key:`owner`,header:a(`migrations.col.owner`,`Owner`),sortValue:e=>e.owner,render:e=>e.owner},{mobile:`detail`,key:`status`,header:a(`migrations.col.status`,`Status`),sortValue:e=>Rr(e.status),render:e=>r(Ir,{status:e.status})},{mobile:`hidden`,key:`level`,header:a(`migrations.col.level`,`Level`),sortValue:e=>e.meta?.level??null,render:e=>e.meta?.level??`—`},{mobile:`hidden`,key:`body`,header:a(`migrations.col.body`,`Body`),sortValue:e=>e.meta?.bodyKind??null,render:e=>e.meta?.bodyKind??`—`},{mobile:`hidden`,key:`applied`,header:a(`migrations.col.applied`,`Applied`),sortValue:e=>e.appliedAt,render:e=>r(`span`,{className:`text-foreground-subtle`,children:Hr(e.appliedAt)})}],[a]),c=a(`migrations.label`,`migrations`);return e(`div`,{className:`space-y-3`,children:[r(We,{state:o.state,facets:o.facets,groups:o.groups.map(e=>({...e,label:e.id===`owner`?a(`migrations.col.owner`):a(`migrations.col.status`),...e.id===`status`?{facetLabel:e=>a(Fr[e])}:{}})),labels:{searchPlaceholder:a(`migrations.searchPlaceholder`,`Search migrations`),searchLabel:a(`migrations.searchLabel`,`Search migrations`),facetsLabel:a(`migrations.facetsLabel`,`Filter migrations`),clearLabel:a(`migrations.clearFilters`,`Clear filters`)},onSearch:o.setSearch,onToggleFacet:o.toggleFacet,onToggleGroupFacet:o.toggleGroupFacet,onClear:o.clear}),r(V,{columns:s,rows:o.rows,rowKey:e=>e.id,minWidthPx:820,maxBodyHeight:Ee,defaultSort:{columnKey:`status`,dir:`asc`},pageSize:25,onRowClick:e=>i(e.id),paginationLabels:{navLabel:a(`migrations.pagesLabel`,`Migration pages`),previous:a(`migrations.previousPage`,`Previous`),next:a(`migrations.nextPage`,`Next`),range:(e,t,n)=>a(`migrations.range`,`{{from}}–{{to}} of {{total}}`,{from:e,to:t,total:n})},emptyMessage:o.active?a(`migrations.noMatch`,`No {{label}} match the filters.`,{label:c}):a(`migrations.empty`,`No migrations.`)})]})}function $({label:t,children:n}){return e(`div`,{className:`grid gap-0.5 py-1.5 sm:grid-cols-[10rem_1fr] sm:gap-3`,children:[r(`dt`,{className:`text-xs text-foreground-muted`,children:t}),r(`dd`,{className:`min-w-0 break-words text-sm text-foreground`,children:n})]})}function Wr({value:e}){return e===null?r(`span`,{className:`text-foreground-subtle`,children:`—`}):r(`pre`,{className:`max-h-40 overflow-auto rounded-md bg-surface p-2 font-mono text-xs text-foreground`,children:JSON.stringify(e,null,2)})}function Gr({id:t}){let{t:n}=X(),i=B.migrations.dryRun.useQuery({id:t},{enabled:!1});return e(`div`,{className:`space-y-2`,children:[e(L,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>void i.refetch(),disabled:i.isFetching,children:[i.isFetching&&r(N,{className:`h-3 w-3 animate-spin`,"aria-hidden":!0}),n(`migrations.detail.dryRun`,`Run a dry run`)]}),r(`p`,{className:`text-xs text-foreground-muted`,children:n(`migrations.detail.dryRunHint`,`Runs the migration in a transaction and rolls it back. Nothing is written.`)}),i.isError&&r(H,{title:n(`migrations.detail.dryRunFailed`,`The dry run could not run`),message:i.error.message}),i.data!==void 0&&e(`div`,{className:`space-y-1 text-xs`,"data-testid":`dry-run-result`,children:[r(`div`,{className:`text-foreground`,children:i.data.ok?n(`migrations.detail.dryRunOk`,`Would change {{count}} rows`,{count:i.data.rowsChanged}):i.data.error??n(`migrations.detail.dryRunThrows`,`It would fail`)}),i.data.tables.map(t=>e(`div`,{className:`font-mono text-foreground-muted`,children:[t.table,`: `,t.before,` → `,t.after]},t.table))]})]})}function Kr({row:t,knownIds:n,onOpenRow:i,onClose:a}){let{t:o}=X(),s=r(`span`,{className:`text-foreground-subtle`,children:`—`}),l=t?.meta??null,u=t?.ledger??null;return r(z,{open:t!==null,onOpenChange:e=>!e&&a(),children:r(J,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,children:t!==null&&e(c,{children:[e(G,{children:[r(U,{className:`break-all font-mono text-base`,children:t.id}),r(Ze,{children:l?.description??o(`migrations.detail.noMeta`,`No catalogue on this hub lists this migration.`)})]}),e(W,{children:[e(`dl`,{className:`divide-y divide-border-subtle`,children:[r($,{label:o(`migrations.col.status`,`Status`),children:r(Ir,{status:t.status})}),t.error!==null&&r($,{label:o(`migrations.detail.error`,`Error`),children:r(`span`,{className:`text-danger`,"data-testid":`migration-error`,children:t.error})}),t.reason!==null&&r($,{label:o(`migrations.detail.reason`,`Reason`),children:t.reason}),r($,{label:o(`migrations.col.owner`,`Owner`),children:t.owner}),r($,{label:o(`migrations.col.level`,`Level`),children:l?.level??s}),r($,{label:o(`migrations.col.body`,`Body`),children:l?.bodyKind??s}),e($,{label:o(`migrations.detail.store`,`Store`),children:[l?.store??s,` · `,t.database]}),r($,{label:o(`migrations.detail.scope`,`Scope`),children:l?.scope??s}),r($,{label:o(`migrations.detail.onFailure`,`On failure`),children:l?.onFailure??s}),r($,{label:o(`migrations.detail.seq`,`Sequence in owner`),children:t.seq}),r($,{label:o(`migrations.detail.fixtureMark`,`Fixture mark`),children:l?.fixtureMark??s}),r($,{label:o(`migrations.detail.dependsOn`,`Depends on`),children:l===null||l.dependsOn.length===0?s:r(`div`,{className:`flex flex-wrap gap-1.5`,children:l.dependsOn.map(e=>n.has(e)?r(L,{type:`button`,variant:`outline`,size:`sm`,className:`font-mono text-xs`,onClick:()=>i(e),children:e},e):r(R,{variant:`neutral`,className:`font-mono text-xs`,children:e},e))})}),r($,{label:o(`migrations.col.applied`,`Applied`),children:Hr(t.appliedAt)}),r($,{label:o(`migrations.detail.attempts`,`Attempts`),children:u?.attempts??s}),r($,{label:o(`migrations.detail.codeVersion`,`Code version`),children:u?.codeVersion??s}),r($,{label:o(`migrations.detail.node`,`Node`),children:u?.nodeId??s}),r($,{label:o(`migrations.detail.boot`,`Boot (snapshot id prefix)`),children:r(`span`,{className:`font-mono text-xs`,children:u?.bootId??s})}),r($,{label:o(`migrations.detail.planSummary`,`Rows changed`),children:r(Wr,{value:u?.planSummary??null})}),r($,{label:o(`migrations.detail.progress`,`Progress`),children:r(Wr,{value:u?.progress??null})})]}),Br(t)&&r(Gr,{id:t.id},t.id)]}),r(K,{children:r(L,{type:`button`,variant:`outline`,onClick:a,children:o(`migrations.detail.close`,`Close`)})})]})})})}o();var qr=`migration`;function Jr(){let{t:n}=X(),i=ye(`migrations`),a=i===`present`,o=B.migrations.listLedger.useQuery({},{enabled:a}),s=B.migrations.listPending.useQuery({},{enabled:a}),[c,l]=mt(),u=c.get(qr),d=t(()=>o.data===void 0||s.data===void 0?null:zr(o.data.entries,s.data.pending),[o.data,s.data]),f=t(()=>new Set((d??[]).map(e=>e.id)),[d]),m=d?.find(e=>e.id===u)??null,h=e=>l(t=>{let n=new URLSearchParams(t);return e===null?n.delete(qr):n.set(qr,e),n},{replace:!0}),g;return g=i===`pending`?r(Yr,{label:n(`migrations.loading`,`Loading migrations…`)}):i===`unknown`?r(H,{title:n(`migrations.unknownTitle`,`Could not check the migration ledger`),message:n(`migrations.unknownBody`,`The hub did not answer. Try again in a moment.`)}):i===`absent`?r(Ce,{icon:ge,title:n(`migrations.absentTitle`,`No migration ledger on this hub`),description:n(`migrations.absentBody`,`Nothing on this hub provides the migrations capability.`)}):o.isError||s.isError?r(H,{title:n(`migrations.loadFailed`,`Could not load the migrations`),message:(o.error??s.error)?.message??``}):d===null?r(Yr,{label:n(`migrations.loading`,`Loading migrations…`)}):d.length===0?r(Ce,{icon:ge,title:n(`migrations.empty`,`No migrations.`),description:n(`migrations.emptyBody`,`The ledger and the catalogues are both empty.`)}):r(Ur,{rows:d,onOpen:h}),e(`div`,{className:p,children:[r(`p`,{className:`mb-3 text-xs text-foreground-muted`,children:n(`migrations.intro`,`Every data migration this hub knows: what ran, what is waiting and what failed. Read-only.`)}),g,r(Kr,{row:m,knownIds:f,onOpenRow:h,onClose:()=>h(null)})]})}function Yr({label:t}){return e(`div`,{className:`flex items-center gap-2 py-4 text-xs text-foreground-subtle`,role:`status`,children:[r(N,{className:`h-3.5 w-3.5 animate-spin`,"aria-hidden":!0}),t]})}var Xr={entries:null,"deleted-devices":`deleted-devices`};function Zr(){let{t:e}=X(),t=gt(`/system/data`,{t:e,isAdmin:!0})??{icon:C,title:e(`system.data`,`Data`)},[n]=mt(),i=Xr[n.get(`tab`)??``];if(i!==void 0){let e=new URLSearchParams(n);return e.set(`tab`,`records`),i!==null&&e.set(`view`,i),r(pt,{replace:!0,to:{search:e.toString()}})}return r(vt,{icon:t.icon,title:t.title,defaultSection:`storage`,sectionsLabel:`${t.title} sections`,sections:[{id:`storage`,label:e(`systemPage.data.storage`,`Storage`),content:r(Ct,{})},{id:`records`,label:e(`systemPage.data.records`,`Records`),content:r(Or,{}),ownedParams:[`view`,`recordsOwner`,`recordsKind`,`entryNew`,`entryEdit`]},{id:`retention`,label:e(`systemPage.data.retention`,`Retention`),content:r(Nr,{})},{id:`backup`,label:e(`systemPage.data.backup`,`Backup`),content:r(Vn,{})},{id:`secrets`,label:e(`systemPage.data.secrets`,`Secrets`),content:r(xr,{}),ownedParams:[`secretsView`]},{id:`migrations`,label:e(`systemPage.data.migrations`,`Migrations`),content:r(Jr,{}),ownedParams:[`migration`]}]})}export{Zr as DataPage};