@camstack/addon-admin-ui 1.2.511 → 1.2.512
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.
- package/CHANGELOG.md +11 -0
- package/dist/assets/{AddonAssetIcon-BhmFaWF6.js → AddonAssetIcon-DCKCRhEh.js} +1 -1
- package/dist/assets/{Addons-DaNcypAW.js → Addons-DPAqJ5aW.js} +1 -1
- package/dist/assets/{AdminPage-Cywt1sv5.js → AdminPage-CVSTxsAk.js} +1 -1
- package/dist/assets/{AdminSectionedPage-D8XbpLmz.js → AdminSectionedPage-BG6w5-w1.js} +1 -1
- package/dist/assets/{AiProfiles-qBccFu5d.js → AiProfiles-DR_I4RIr.js} +1 -1
- package/dist/assets/{BrokerEditorDialog-C2p0P4ye.js → BrokerEditorDialog-Dd6KEwRN.js} +1 -1
- package/dist/assets/Build-C8Iyyb5o.js +40 -0
- package/dist/assets/{Calendars-74ckkFP0.js → Calendars-BHqwUpG9.js} +1 -1
- package/dist/assets/{Cluster-1JwXjjed.js → Cluster-DDjN53AW.js} +1 -1
- package/dist/assets/CompositionBlockEditor-B81aTqq3.js +1 -0
- package/dist/assets/{CompositionEditorPage-DE9Rccl2.js → CompositionEditorPage-CbLv15x4.js} +1 -1
- package/dist/assets/{Data-DWYM-kxy.js → Data-CJqiuGjd.js} +1 -1
- package/dist/assets/{DeviceDetail-CVMOCWi5.js → DeviceDetail-DvtPS7Er.js} +1 -1
- package/dist/assets/{DeviceDoActionFields-BDdQwLvn.js → DeviceDoActionFields-DnA_DSYw.js} +1 -1
- package/dist/assets/{Devices-DdCovTvt.js → Devices-B9SE3Rwm.js} +1 -1
- package/dist/assets/{EmbedPlayerPage-BeuVN1QD.js → EmbedPlayerPage-D63WF3oV.js} +1 -1
- package/dist/assets/HelperWizard-BigkVmsB.js +2 -0
- package/dist/assets/{History-DVdEMBYJ.js → History-D0syoHcx.js} +1 -1
- package/dist/assets/{Identity-DNSkhe9x.js → Identity-CElkwZnz.js} +1 -1
- package/dist/assets/{IntegrationDetail-DZttjxiw.js → IntegrationDetail-DZ8ztuOE.js} +1 -1
- package/dist/assets/{IntegrationHub-DqbKVh4N.js → IntegrationHub-DiscqOsj.js} +1 -1
- package/dist/assets/{Integrations-BfgfABQl.js → Integrations-BfCE8MnT.js} +1 -1
- package/dist/assets/{Integrations-BmU9vQlf.js → Integrations-CHguUclI.js} +1 -1
- package/dist/assets/{Library-D268sj-L.js → Library-C2NTg1uA.js} +1 -1
- package/dist/assets/{Locations-D7E3SmAX.js → Locations-DWad73x-.js} +1 -1
- package/dist/assets/{Logs-IXGaCSMo.js → Logs-kEWkWloD.js} +1 -1
- package/dist/assets/{MyAccess-Bred4wkj.js → MyAccess-CS5GrN5k.js} +1 -1
- package/dist/assets/{Network-sb7soD7f.js → Network-DtfAuiol.js} +1 -1
- package/dist/assets/{NodeAddonsSettingsPanel-BswQpSzM.js → NodeAddonsSettingsPanel-lczGJdHs.js} +1 -1
- package/dist/assets/{Notifications-CjXAcavg.js → Notifications-DchKpNOg.js} +1 -1
- package/dist/assets/{Pipeline-DURRCrIJ.js → Pipeline-vgUZsFFP.js} +1 -1
- package/dist/assets/{Recordings-D1a7Ipp3.js → Recordings-CyPYQ20P.js} +1 -1
- package/dist/assets/{ScanNetworkModal-9eawQeIJ.js → ScanNetworkModal-Bg22q8vm.js} +1 -1
- package/dist/assets/{SessionsList-BtpHp2KM.js → SessionsList-CfuTFr66.js} +1 -1
- package/dist/assets/{Showroom-C0KMMGgI.js → Showroom-R3reqgpn.js} +1 -1
- package/dist/assets/{System-Ca9giuGu.js → System-r9rg9iWn.js} +1 -1
- package/dist/assets/{Terminal-Ct5pxKeO.js → Terminal-B5qyGLn1.js} +1 -1
- package/dist/assets/{Viewer-D_HQWvCc.js → Viewer-CLvHpMj8.js} +1 -1
- package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-BTJLKrn5.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-GbWwXkZ2.js} +1 -1
- package/dist/assets/{addon-icons-context-7pMoFmo9.js → addon-icons-context-ClSTx0Nd.js} +1 -1
- package/dist/assets/{assignment-candidates-DctD4-Kk.js → assignment-candidates-B0B3pJGN.js} +1 -1
- package/dist/assets/{authed-media-DyWWajaJ.js → authed-media-Ba0gOxiM.js} +1 -1
- package/dist/assets/{board-model-DKqEIHLh.js → board-model-DcpPhztF.js} +1 -1
- package/dist/assets/{device-integration-icon-Bh0Znsav.js → device-integration-icon-Nwyo5V5H.js} +1 -1
- package/dist/assets/device-picker-model-C44QyL85.js +1 -0
- package/dist/assets/{format-D360_J0N.js → format-u0sqgb1J.js} +1 -1
- package/dist/assets/{hostInit-B2k6yhyi.js → hostInit-VFHoBRCk.js} +1 -1
- package/dist/assets/{i18n-B5uU8u6u.js → i18n-CXGP1uaw.js} +1 -1
- package/dist/assets/{index-DUl9HFmr.css → index-Dep3DVAz.css} +1 -1
- package/dist/assets/{index-CuvJet67.js → index-lH9UKmhf.js} +3 -3
- package/dist/assets/{linked-devices-model-B8JwCaUn.js → linked-devices-model-COUfIEod.js} +1 -1
- package/dist/assets/{location-owned-usage-CVWBPy28.js → location-owned-usage-BmtVONF0.js} +1 -1
- package/dist/assets/{mf-entry-bootstrap-0-56c74718.js → mf-entry-bootstrap-0-556ccfd0.js} +2 -2
- package/dist/assets/mount-C44QyL85.js +1 -0
- package/dist/assets/remoteEntry-De9zVsA0.js +1 -0
- package/dist/assets/{src-vYMgzn3X.js → src-IQsaq5W-.js} +2 -2
- package/dist/assets/{step-inspector-model-BZFtfupM.js → step-inspector-model-CW9NPxgI.js} +1 -1
- package/dist/assets/{use-scenes-feed-CGtWB1L7.js → use-scenes-feed-CQOhXjvP.js} +1 -1
- package/dist/assets/{use-stationary-objects-Cp1KGKmU.js → use-stationary-objects-D9KV1ze2.js} +1 -1
- package/dist/assets/useEventInvalidation-C44QyL85.js +1 -0
- package/dist/assets/{useNodeUrlSelection-BsZGUghh.js → useNodeUrlSelection-CAyN93HW.js} +1 -1
- package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-BQEGoWCP.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-Dyo8T61H.js} +2 -2
- package/dist/index.html +7 -7
- package/dist/server/addon.js +1 -1
- package/package.json +1 -1
- package/dist/assets/Build-DRh7B9_e.js +0 -40
- package/dist/assets/CompositionBlockEditor-CV4xvSqS.js +0 -1
- package/dist/assets/HelperWizard-TPowwspC.js +0 -2
- package/dist/assets/device-picker-model-CreVFMrD.js +0 -1
- package/dist/assets/mount-CreVFMrD.js +0 -1
- package/dist/assets/remoteEntry-BlJC9q2U.js +0 -1
- package/dist/assets/useEventInvalidation-CreVFMrD.js +0 -1
|
@@ -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{D as l,Di as u,Fn as d,Ht as f,In as p,Q as m,Ti as h,Vn as g,Xr as _,Zi as v,di as y,ei as b,fr as x,lr as S,na as C,pi as w,ri as T,st as E,ta as D,ur as O,vn as k,wn as A,yi as j,zt as M}from"./player-overlays-B5FSaids.js";import{n as N,t as P}from"./cloud-upload-BNAApVPM.js";import{t as F}from"./circle-slash-fwUwJ3r8.js";import{t as I}from"./hard-drive-download-PwUdP9sZ.js";import{Bn as L,Cn as R,Er as ee,Rn as te,Sn as z,Su as ne,Tr as re,Un as ie,Vi as ae,Vn as oe,Yl as se,Yr as B,_a as ce,_d as V,_r as le,aa as ue,ca as de,cu as fe,da as pe,dd as me,dr as H,fa as he,fo as ge,fr as _e,ft as ve,ga as ye,gd as be,gr as xe,ha as Se,hr as Ce,ia as we,la as Te,lt as Ee,lu as De,ma as Oe,mt as ke,oa as Ae,ou as je,pa as Me,pr as Ne,pt as Pe,ra as Fe,sa as Ie,su as Le,ua as Re,va as ze,xt as U}from"./src-vYMgzn3X.js";import{t as W}from"./i18n-B5uU8u6u.js";import{t as G}from"./useTranslation-BJr-n0es.js";import"./mount-CreVFMrD.js";import{T as Be,hr as Ve,pr as He,yr as Ue}from"./index-CuvJet67.js";import{t as We}from"./AdminSectionedPage-D8XbpLmz.js";import{t as Ge}from"./AdminPage-Cywt1sv5.js";import{n as Ke}from"./authed-media-DyWWajaJ.js";import{t as K}from"./format-size-DIxKXxtj.js";import{a as qe,c as Je,l as Ye,n as Xe,o as Ze,s as Qe,t as $e,u as et}from"./location-owned-usage-CVWBPy28.js";o();function tt(){let{t:n}=G(),a=s(),o=E(),{data:c,isLoading:l,isError:u}=De({}),d=fe(),f=t(()=>d.data??[],[d.data]),{data:p}=se({},{refetchOnWindowFocus:!1}),m=t(()=>$e(c??[],p?.locations),[c,p?.locations]),{data:h}=Le({},{refetchOnWindowFocus:!1}),g=t(()=>qe(h),[h]),{state:_,openNew:v,openEdit:y,close:b}=ve(),[x,S]=Pe(`type`),C=()=>{S(null),b()},w=e=>{S(e),v()},T=e=>{S(null),y(e.id)},D=c??[],O=_.mode===`edit`?D.find(e=>e.id===_.id)??null:null;i(()=>{_.mode===`new`&&(x===null||x===``)&&(S(null),b())},[_.mode,x,b,S]),i(()=>{_.mode===`edit`&&!l&&O===null&&(S(null),b())},[_.mode,l,O,b,S]),i(()=>{_.mode===`closed`&&x!==null&&S(null)},[_.mode,x,S]);let k=je({onSuccess:()=>{a.invalidateQueries({queryKey:[[`storage`,`listLocations`]]})}}),A=ne({onSuccess:()=>{a.invalidateQueries({queryKey:[[`storage`,`listLocations`]]})}}),j=async(e,t)=>{Ye(t)&&!await o({title:n(`system.storage.disable`,`Disable "{{displayName}}"?`,{displayName:e.displayName}),message:n(`system.storage.nothingIsDeletedSetThe`,`{{consequence}} Nothing is deleted — set the location back to Read-only or Active to bring its footage back.`,{consequence:Je(t).consequence}),confirmLabel:n(`common.disable`,`Disable`),variant:`danger`})||A.mutate(Qe(e,{mode:t}))},M=async e=>{if(await o({title:n(`system.storage.deleteLocation`,`Delete location "{{displayName}}"?`,{displayName:e.displayName}),message:n(`system.storage.thisRemovesTheLocationRecord`,`This removes the location record. Files on disk are not deleted; the underlying directory or remote path stays untouched.`),confirmLabel:n(`common.delete`,`Delete`),variant:`danger`}))try{await k.mutateAsync({id:e.id}),_.mode===`edit`&&_.id===e.id&&C()}catch(t){await o({title:n(`system.storage.deleteAnyway`,`Delete anyway?`),message:n(`system.storage.forcingNote`,{error:t instanceof Error?t.message:String(t)}),confirmLabel:n(`system.storage.forceDelete`,`Force delete`),variant:`danger`})&&k.mutate({id:e.id,force:!0},{onSuccess:()=>{_.mode===`edit`&&_.id===e.id&&C()}})}},N=t(()=>{let e=new Map;for(let t of c??[]){let n=e.get(t.type);n?n.push(t):e.set(t.type,[t])}return e},[c]),P=l||d.isLoading,F=u||d.isError,I=_.mode===`new`&&x!==null&&x!==``,L=_.mode===`edit`&&O!==null;return e(Ge,{embedded:!0,children:[P&&r(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:n(`system.storage.loadingLocations`,`Loading locations…`)}),F&&r(`div`,{className:`text-xs text-danger`,children:n(`system.storage.failedToLoadStorageLocations`,`Failed to load storage locations.`)}),!P&&!F&&e(`div`,{className:`space-y-3`,children:[f.length===0&&r(`div`,{className:`rounded-lg border border-border bg-surface px-3 py-4 text-center text-[11px] text-foreground-subtle italic`,children:n(`system.storage.noStorageLocationsDeclaredBy`,`No storage locations declared by any installed addon.`)}),f.map(e=>r(Xe,{type:e.id,displayName:e.displayName,description:e.description,cardinality:e.cardinality,locations:N.get(e.id)??[],onAdd:w,onEdit:T,onDelete:e=>{M(e)},ownedBytesById:m,drainById:g,onSetMode:(e,t)=>{j(e,t)}},e.id))]}),I&&x!==null&&r(et,{initialType:x,onClose:C,onCreated:()=>{a.invalidateQueries({queryKey:[[`storage`,`listLocations`]]}),C()}}),L&&O!==null&&r(Ze,{location:O,onClose:C,onSaved:()=>{a.invalidateQueries({queryKey:[[`storage`,`listLocations`]]}),C()}})]})}var q={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`}},nt=Object.keys(q),J=[`settings`];function rt(){return W.t(`helpers.backupDatabases.notCreated`)}function it(e){return W.t(q[e].labelKey)}function at(e){return W.t(q[e].shortKey)}function ot(e){return W.t(q[e].descriptionKey)}function Y(e){let t=new Set(e);return nt.filter(e=>t.has(e))}function X(e){return e!==void 0&&e.length>0?Y(e):J}function st(e){return Y(e)}function ct(e,t){return t===void 0||!t.answered?`unknown`:t.databases.includes(e)?`present`:`absent`}function lt(e,t,n){return ct(e,t)===`absent`&&!n.has(e)}function ut(e,t){let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n}function dt(e){return!e.includes(`settings`)}function ft(e){return{databases:[...st(e)]}}function pt(e,t){return e!==void 0&&e.length>0?Y(e):t!==void 0&&t.length>0?Y(t.map(e=>e.databaseId??`settings`)):J}function Z({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=>at(e)).join(` · `)})}o();var mt=[[`backup`,`listDestinations`]],ht=[`backup`,`listArchives`];function gt({destinationId:i,restoreSupported:o,onOpenRestoreWizard:c}){let{t:l}=G(),u=s(),d=E(),{data:p,isLoading:m,isError:h}=Te({destinationId:i}),g=p??[],v=we({onSuccess:()=>{u.invalidateQueries({queryKey:[[...ht]]}),u.invalidateQueries({queryKey:mt})}}),y=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:K(e.sizeBytes)}),confirmLabel:l(`common.delete`,`Delete`),variant:`danger`})&&v.mutate({destinationId:i,backupId:e.id})},[d,i,v,l]),[b,C]=a(null),w=n(async e=>{C(e.id);try{let t=await Ke(_t(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{C(null)}},[i]),T=t(()=>[...g].toSorted((e,t)=>t.createdAt-e.createdAt),[g]);return m?r(`div`,{className:`text-xs text-foreground-subtle animate-pulse py-2`,children:l(`backup.archiveList.loadingArchives`,`Loading archives…`)}):h?r(`div`,{className:`text-xs text-danger py-2`,children:l(`backup.archiveList.failedToReadManifestFor`,`Failed to read manifest for this destination`)}):T.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(z,{columns:[{key:`when`,header:l(`backup.archiveList.when`,`When`),sortValue:e=>e.createdAt,render:e=>r(`span`,{className:`tabular-nums`,children:vt(e.createdAt)})},{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(S,{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:`—`})]})},{key:`databases`,header:l(`backup.archiveList.databases`,`Databases`),nowrap:!1,notSortableReason:`Database badges`,render:e=>r(Z,{databases:X(e.databases)})},{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`)})},{key:`size`,header:l(`backup.archiveList.size`,`Size`),align:`right`,sortValue:e=>e.sizeBytes,render:e=>r(`span`,{className:`tabular-nums`,children:K(e.sizeBytes)})},{key:`actions`,header:``,align:`right`,notSortableReason:`Actions`,render:t=>e(`span`,{className:`flex items-center justify-end gap-1`,children:[e(B,{variant:`ghost`,size:`sm`,onClick:()=>{w(t)},disabled:b===t.id,title:l(`backup.archiveList.downloadArchive`,`Download archive`),children:[b===t.id?r(x,{className:`h-3 w-3 animate-spin`}):r(_,{className:`h-3 w-3`}),l(`backup.archiveList.download`,`Download`)]}),o&&c&&e(B,{variant:`ghost`,size:`sm`,onClick:()=>c({destinationId:i,archiveId:t.id}),title:l(`backup.archiveList.restoreFromThisArchive`,`Restore from this archive`),children:[r(A,{className:`h-3 w-3`}),l(`backup.archiveList.restore`,`Restore`)]}),r(V,{variant:`ghost`,size:`sm`,icon:f,"aria-label":l(`backup.archiveList.delete`,`Delete {{value1}}`,{value1:t.label??t.id}),disabled:v.isPending,onClick:()=>{y(t)}})]})}],rows:T,rowKey:e=>e.id,minWidthPx:760,emptyMessage:l(`backup.archiveList.noArchivesAtThisDestination`,`No archives at this destination yet.`)})}function _t(e,t){return m(`/api/backup/download/${encodeURIComponent(e)}/${encodeURIComponent(t)}`)}function vt(e){return new Date(e).toLocaleString(void 0,{day:`2-digit`,month:`short`,year:`numeric`,hour:`2-digit`,minute:`2-digit`})}o();var yt=[[`backup`,`listSchedules`]];function bt({onEdit:i,onOpenRestoreWizard:o}){let{t:s}=G(),{data:c,isLoading:l,isError:u,error:d,refetch:f}=Me(),p=c??[],m=pe().data??[],h=t(()=>{let e=new Map;for(let t of m)e.set(t.id,t);return e},[m]),[g,_]=a(null),v=n(e=>{_(t=>t===e?null:e)},[]),y=t(()=>xt({destById:h,expandedId:g,onToggleExpand:v,onEdit:i}),[h,g,v,i]);return l?e(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle animate-pulse`,children:[r(x,{className:`h-3.5 w-3.5 animate-spin`}),s(`backup.backupEntriesTable.loadingBackupEntries`,`Loading backup entries…`)]}):u?r(re,{title:s(`backup.backupEntriesTable.failedToLoadBackupEntries`,`Failed to load backup entries`),message:d instanceof Error?d.message:s(`backup.backupEntriesTable.unknownError`,`Unknown error`),onRetry:()=>void f()}):p.length===0?r(ee,{icon:N,title:s(`backup.backupEntriesTable.noBackupEntriesYet`,`No backup entries yet`),description:s(`backup.backupEntriesTable.createOneToScheduleBackups`,`Create one to schedule backups across one or more storage locations.`)}):r(z,{columns:y,rows:p,rowKey:e=>e.id,minWidthPx:980,maxBodyHeight:R,emptyMessage:s(`backup.backupEntriesTable.noBackupEntriesYet`,`No backup entries yet`),onRowClick:e=>i(e),isExpanded:e=>e.id===g,renderExpanded:e=>r(Ot,{row:e,destById:h,...o?{onOpenRestoreWizard:o}:{}})})}function xt(t){return[{key:`expand`,header:``,width:`w-8`,nowrap:!0,notSortableReason:`Expand control`,render:e=>{let n=t.expandedId===e.id;return r(V,{variant:`ghost`,size:`sm`,icon:n?u:h,"aria-label":n?W.t(`backup.backupEntriesTable.hideArchives`,`Hide archives`):W.t(`backup.backupEntriesTable.showArchives`,`Show archives`),"aria-expanded":n,onClick:n=>{n.stopPropagation(),t.onToggleExpand(e.id)}})}},{key:`entry`,header:W.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||W.t(`backup.backupEntriesTable.unnamed`,`(unnamed)`)}),t.lastRunAt!==void 0&&r(`span`,{className:`text-[10px] text-foreground-subtle`,children:W.t(`backup.backupEntriesTable.lastRun`,{when:new Date(t.lastRunAt).toLocaleString()})})]})},{key:`enabled`,header:W.t(`backup.backupEntriesTable.enabled`,`Enabled`),width:`w-20`,nowrap:!0,sortValue:e=>+!!e.enabled,render:e=>r(`span`,{onClick:e=>e.stopPropagation(),children:r(Tt,{row:e})})},{key:`databases`,header:W.t(`backup.backupEntriesTable.backsUp`,`Backs up`),nowrap:!1,notSortableReason:`Database badges`,render:e=>r(Z,{databases:X(e.databases)})},{key:`locations`,header:W.t(`backup.backupEntriesTable.locations`,`Locations`),nowrap:!1,notSortableReason:`Location chips`,render:e=>r(St,{row:e,destById:t.destById})},{key:`retention`,header:W.t(`backup.backupEntriesTable.retention`,`Retention`),width:`w-24`,nowrap:!0,sortValue:e=>e.retentionCount,render:e=>r(`span`,{onClick:e=>e.stopPropagation(),children:r(Et,{row:e})})},{key:`schedule`,header:W.t(`backup.backupEntriesTable.schedule`,`Schedule`),width:`w-48`,nowrap:!0,sortValue:e=>e.cron,render:e=>r(Ct,{row:e})},{key:`actions`,header:``,align:`right`,nowrap:!0,notSortableReason:`Actions`,render:e=>r(`span`,{onClick:e=>e.stopPropagation(),children:r(Dt,{row:e,onEdit:()=>t.onEdit(e)})})}]}function St({row:e,destById:t}){let{t:n}=G();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 Ct({row:t}){let{t:n}=G(),i=t.cron.trim().length>0;return e(`span`,{className:`flex flex-col items-start gap-0.5`,children:[e(`span`,{className:`inline-flex items-center gap-1`,children:[r(N,{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:W.t(`common.nextRun`,{when:new Date(t.nextRunAt).toLocaleString()})})]})}function wt(e){return t(()=>({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]}:{}}),[e])}function Tt({row:e}){let{t}=G(),n=s(),i=ze({onSuccess:()=>{n.invalidateQueries({queryKey:yt})}}),a=wt(e);return r(`label`,{className:`inline-flex cursor-pointer items-center`,children:r(`input`,{type:`checkbox`,className:`accent-primary`,checked:e.enabled,disabled:i.isPending,onChange:e=>i.mutate({...a,enabled:e.target.checked}),"aria-label":t(`backup.backupEntriesTable.enable`,`Enable {{value1}}`,{value1:e.label||e.id})})})}function Et({row:e}){let{t}=G(),n=s(),o=ze({onSuccess:()=>{n.invalidateQueries({queryKey:yt})}}),c=wt(e),[l,u]=a(String(e.retentionCount));return i(()=>{u(String(e.retentionCount))},[e.retentionCount]),r(be,{type:`number`,min:1,max:1e3,value:l,disabled:o.isPending,onChange:e=>u(e.target.value),onBlur:()=>{let t=Number.parseInt(l,10);if(Number.isNaN(t)||t<1){u(String(e.retentionCount));return}t!==e.retentionCount&&o.mutate({...c,enabled:e.enabled,retentionCount:t})},onKeyDown:t=>{t.key===`Enter`&&t.target.blur(),t.key===`Escape`&&u(String(e.retentionCount))},className:`w-16`,"aria-label":t(`backup.backupEntriesTable.retentionFor`,`Retention for {{value1}}`,{value1:e.label||e.id})})}function Dt({row:t,onEdit:n}){let{t:i}=G(),a=s(),o=E(),c=ue({onSuccess:()=>{a.invalidateQueries({queryKey:yt})}}),l=ce({onMutate:()=>{a.invalidateQueries({queryKey:[[`backup`,`listRuns`]]})},onSuccess:()=>{a.invalidateQueries({queryKey:[[`backup`,`listArchives`]]}),a.invalidateQueries({queryKey:[[`backup`,`listDestinations`]]}),a.invalidateQueries({queryKey:[[`backup`,`listRuns`]]})}}),u=()=>{t.locationIds.length!==0&&l.mutate({destinations:[...t.locationIds],...t.dataSources&&t.dataSources.length>0?{locations:[...t.dataSources]}:{},label:t.label,retentionCount:t.retentionCount,databases:[...X(t.databases)]})},d=async()=>{await o({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`})&&c.mutate({id:t.id})};return e(`span`,{className:`flex items-center justify-end gap-1.5`,children:[e(B,{size:`sm`,type:`button`,onClick:u,disabled:l.isPending||t.locationIds.length===0,title:i(`backup.backupEntriesTable.runThisEntryNow`,`Run this entry now`),children:[l.isPending?r(x,{className:`h-3 w-3 animate-spin`}):r(p,{className:`h-3 w-3`}),i(`backup.backupEntriesTable.runNow`,`Run now`)]}),r(V,{variant:`ghost`,size:`sm`,icon:g,"aria-label":i(`backup.backupEntriesTable.edit`,`Edit {{value1}}`,{value1:t.label||t.id}),onClick:n}),r(V,{variant:`ghost`,size:`sm`,icon:f,"aria-label":i(`backup.backupEntriesTable.delete`,`Delete {{value1}}`,{value1:t.label||t.id}),disabled:c.isPending,onClick:()=>{d()}})]})}function Ot({row:t,destById:n,onOpenRestoreWizard:i}){let{t:a}=G();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(gt,{destinationId:t,restoreSupported:n.get(t)?.restoreSupported??!0,...i?{onOpenRestoreWizard:i}:{}})]},t))]})}function kt({selected:t,onChange:n,disabled:i=!1,testId:a=`backup-databases`}){let{t:o}=G(),s=Re().data,c=t.size>0&&dt(Y(t)),l=t.size===0?`Pick at least one.`:c?`Snapshots only: configuration and files are not part of this backup.`:null;return r(U,{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:nt.map(o=>{let c=ct(o,s),l=i||lt(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(ie,{checked:t.has(o),disabled:l,onChange:()=>n(ut(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:it(o)}),r(`span`,{className:`block text-[11px] text-foreground-subtle`,children:c===`absent`?rt():ot(o)})]})]},o)})})})}o();function At({onClose:t}){let{t:n}=G(),i=s(),[o,c]=a(new Set(J)),l=ce({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(H,{open:!0,onOpenChange:e=>!e&&t(),children:e(Ne,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[e(xe,{children:[r(le,{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(_e,{children:e(`div`,{className:`p-4`,children:[r(kt,{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(Ce,{children:[r(B,{variant:`outline`,size:`sm`,onClick:t,children:n(`common.cancel`,`Cancel`)}),e(B,{size:`sm`,onClick:()=>{o.size!==0&&l.mutate(ft(o))},disabled:o.size===0||l.isPending,"data-testid":`backup-now-run`,children:[l.isPending?r(x,{className:`h-3.5 w-3.5 animate-spin`}):r(p,{className:`h-3.5 w-3.5`}),n(`backup.backupNowDialog.backUpNow`,`Back up now`)]})]})]})})}o();function jt(e){return e===null?`—`:new Date(e).toLocaleString()}function Mt(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 Nt({revealed:t,onDone:n}){let{t:i}=G(),[o,s]=a(!1),[c,l]=a(!1);return r(H,{open:!0,onOpenChange:e=>!e&&o&&n(),children:e(Ne,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,className:`border-danger/40`,"aria-labelledby":`backup-key-title`,children:[r(xe,{children:r(le,{id:`backup-key-title`,children:i(`backup.encryptionCard.yourKey`,{keyId:t.keyId})})}),e(_e,{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(M,{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. CamStack 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(B,{size:`sm`,variant:`outline`,onClick:()=>{navigator.clipboard?.writeText(t.secretKey).then(()=>l(!0))},children:[r(T,{className:`mr-1 h-3.5 w-3.5`}),c?i(`backup.backupEncryptionCard.copied`,`Copied`):i(`common.copy`,`Copy`)]}),e(B,{size:`sm`,variant:`outline`,onClick:()=>Mt(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(`input`,{type:`checkbox`,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(Ce,{children:r(B,{size:`sm`,disabled:!o,onClick:n,children:i(`backup.backupEncryptionCard.iHaveStoredIt`,`I have stored it`)})})]})})}function Pt(){let{t}=G(),n=Ie(),i=ye(),o=Ae(),s=E(),[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(S,{className:`h-4 w-4 text-success`}):r(O,{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:jt(m.createdAt)}):t(`backup.backupEncryptionCard.offBackupsAreNotEncrypted`,`Off — backups are not encrypted`)})]}),r(`div`,{className:`flex gap-2`,children:p?e(c,{children:[r(B,{size:`sm`,variant:`outline`,disabled:i.isPending,onClick:()=>void g(),children:t(`backup.backupEncryptionCard.replaceKey`,`Replace key`)}),r(B,{size:`sm`,variant:`outline`,disabled:o.isPending,onClick:()=>void _(),children:t(`backup.backupEncryptionCard.turnOff`,`Turn off`)})]}):r(B,{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, config.yaml, 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,` · `,jt(t.createdAt),` → `,jt(t.retiredAt)]},t.keyId))})]}),d!==null&&r(`p`,{className:`text-xs text-danger`,children:d}),l!==null&&r(Nt,{revealed:l,onDone:()=>{u(null),n.refetch()}})]})}o();var Ft=[{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 It(e){let t=e.trim();for(let e of Ft)if(e.cron===t)return e.id;return`custom`}function Lt({value:t,onChange:n,previewCount:o=5,disabled:s=!1}){let{t:c}=G(),l=It(t),[u,d]=a(l===`custom`);i(()=>{l!==`custom`&&d(!1)},[l]);let f=Bt(t,250),p=Oe({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:[Ft.map(e=>r(`button`,{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(`button`,{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(`input`,{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(He,{i18nKey:`backup.cronEditor.formatLine`,components:{code:r(`span`,{className:`font-mono`})}})]})]}),r(Rt,{cron:f,preview:m,loading:p.isFetching})]})}function Rt({cron:t,preview:n,loading:i}){let{t:a}=G();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(x,{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:zt(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 zt(e){let t=e-Date.now();if(t<=0)return W.t(`helpers.relativeTime.now`);let n=Math.floor(t/1e3);if(n<60)return W.t(`helpers.relativeTime.inSeconds`,{count:n});let r=Math.floor(n/60);if(r<60)return W.t(`helpers.relativeTime.inMinutes`,{count:r});let i=Math.floor(r/60);if(i<24)return W.t(`helpers.relativeTime.inHours`,{count:i});let a=Math.floor(i/24);return W.t(`helpers.relativeTime.inDays`,{count:a})}function Bt(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 Vt=[[`backup`,`listSchedules`]];function Ht({entry:n,onClose:i,onSaved:o}){let{t:c}=G(),l=s(),u=pe(),d=u.data??[],[f,p]=a(n?.label??``),[m,h]=a(n?.cron??`0 3 * * *`),[g,_]=a(n?.enabled??!0),[v,y]=a(String(n?.retentionCount??7)),[b,S]=a(new Set(n?.locationIds??[])),[C,w]=a(new Set(n===null?J:X(n.databases))),T=ze({onSuccess:()=>{l.invalidateQueries({queryKey:Vt}),o()}}),E=e=>{S(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},D=Number.parseInt(v,10),O=t(()=>f.trim().length>0&&b.size>0&&C.size>0&&!Number.isNaN(D)&&D>=1&&D<=1e3,[f,b,C,D]),k=()=>{O&&T.mutate({...n?{id:n.id}:{},label:f.trim(),cron:m.trim(),enabled:g,locationIds:Array.from(b),retentionCount:D,databases:[...st(C)]})},A=T.error instanceof Error?T.error.message:null;return r(ke,{open:!0,onClose:i,title:n?c(`backup.backupEntryModal.editBackupEntry`,`Edit backup entry`):c(`backup.backupEntryModal.newBackupEntry`,`New backup entry`),icon:N,error:A,width:`lg`,testId:`backup-entry-form`,footer:e(B,{size:`sm`,type:`button`,onClick:k,disabled:!O||T.isPending,children:[T.isPending?r(x,{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(U,{label:c(`backup.backupEntryModal.name`,`Name`),required:!0,children:r(be,{value:f,onChange:e=>p(e.target.value),placeholder:c(`backup.backupEntryModal.nightlyOffsite`,`Nightly offsite`),autoFocus:!0,"data-testid":`backup-entry-name`})}),e(U,{label:c(`backup.backupEntryModal.locationsSelected`,`Locations ({{value1}} selected)`,{value1:String(b.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(x,{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(`input`,{type:`checkbox`,checked:b.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(kt,{selected:C,onChange:w,disabled:T.isPending,testId:`backup-entry-databases`}),e(`div`,{className:`grid grid-cols-2 gap-3`,children:[r(U,{label:c(`backup.backupEntryModal.retentionArchivesKept`,`Retention (archives kept)`),required:!0,children:r(be,{type:`number`,min:1,max:1e3,value:v,onChange:e=>y(e.target.value),"data-testid":`backup-entry-retention`})}),r(U,{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(`input`,{type:`checkbox`,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(U,{label:c(`backup.backupEntryModal.schedule`,`Schedule`),children:r(Lt,{value:m,onChange:h,disabled:T.isPending})})]})})}o();var Ut=2e3,Wt=5e3;function Q(e){return e.state===`queued`||e.state===`running`}function Gt(e){if(e.state===`queued`)return{title:W.t(`backup.backupRunsPanel.cancelQueuedBackupRun`,`Cancel queued backup run?`),message:W.t(`backup.backupRunsPanel.thisRunHasNotStarted`,`This run has not started. Cancelling removes it from the queue — nothing has been written, nothing is deleted.`),confirmLabel:W.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:W.t(`backup.backupRunsPanel.stopThisBackupRun`,`Stop this backup run?`),message:W.t(`backup.backupRunsPanel.theHalfWrittenStagingArchive`,`The half-written staging archive is deleted and the destination currently uploading discards its partial copy. {{keptSentence}}`,{keptSentence:n}),confirmLabel:W.t(`backup.backupRunsPanel.stopRun`,`Stop run`),variant:`danger`}}function Kt(){let e=E(),[t,i]=a(null),o=he(void 0,{refetchInterval:e=>(e.state.data??[]).some(Q)?Ut:Wt}),s=Fe({onSettled:()=>{i(null),o.refetch()}}),c=n(async t=>{await e(Gt(t))&&(i(t.id),s.mutate({runId:t.id}))},[e,s]);return r(qt,{queryState:o.isError?`error`:o.data===void 0?`pending`:`ready`,runs:o.data??[],cancelingId:t,onCancelRequest:e=>{c(e)},now:Date.now()})}function qt({queryState:t,runs:n,cancelingId:i,onCancelRequest:a,now:o}){let{t:s}=G(),c=t===`ready`&&n.some(Q),l=n.filter(e=>e.state===`running`),u=n.filter(e=>e.state===`queued`),d=n.filter(e=>!Q(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(`div`,{className:`overflow-x-auto`,children:e(`table`,{className:`w-full text-xs min-w-[720px]`,children:[r(`thead`,{children:e(`tr`,{className:`text-foreground-subtle bg-background/30`,children:[r(`th`,{className:`text-left px-3 py-1.5 font-medium`,children:s(`backup.backupRunsPanel.run`,`Run`)}),r(`th`,{className:`text-left px-3 py-1.5 font-medium`,children:s(`backup.backupRunsPanel.state`,`State`)}),r(`th`,{className:`text-left px-3 py-1.5 font-medium`,children:s(`backup.backupRunsPanel.progress`,`Progress`)}),r(`th`,{className:`text-left px-3 py-1.5 font-medium`,children:s(`backup.backupRunsPanel.destinations`,`Destinations`)}),r(`th`,{className:`text-left px-3 py-1.5 font-medium`,children:s(`backup.backupRunsPanel.timing`,`Timing`)}),r(`th`,{className:`text-right px-3 py-1.5 font-medium w-28`,children:s(`backup.backupRunsPanel.actions`,`Actions`)})]})}),r(`tbody`,{children:f.map(e=>r(Jt,{run:e,canceling:i===e.id,onCancelRequest:a,now:o},e.id))})]})})]})}function Jt({run:t,canceling:n,onCancelRequest:i,now:a}){let{t:o}=G(),s=Q(t);return e(`tr`,{className:`border-t border-border hover:bg-primary/5 align-top`,children:[r(`td`,{className:`px-3 py-2`,children:r(`div`,{className:`text-foreground`,title:t.id,children:t.label??r(`span`,{className:`text-foreground-subtle italic`,children:o(`backup.runsPanel.manual`)})})}),e(`td`,{className:`px-3 py-2`,children:[r(Yt,{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})]}),r(`td`,{className:`px-3 py-2`,children:r(Xt,{run:t})}),r(`td`,{className:`px-3 py-2`,children:r(Zt,{run:t})}),r(`td`,{className:`px-3 py-2 text-foreground-subtle tabular-nums`,children:r(Qt,{run:t,now:a})}),r(`td`,{className:`px-3 py-2`,children:r(`div`,{className:`flex justify-end`,children:s&&e(`button`,{onClick:()=>i(t),disabled:n,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:t.state===`queued`?o(`backup.backupRunsPanel.removeThisRunFromThe`,`Remove this run from the queue before it starts`):o(`backup.backupRunsPanel.stopThisRunTheHalf`,`Stop this run — the half-written archive is discarded`),children:[n?r(x,{className:`h-3 w-3 animate-spin`}):r(v,{className:`h-3 w-3`}),t.state===`queued`?o(`common.cancel`,`Cancel`):o(`backup.backupRunsPanel.stop`,`Stop`)]})})})]})}function Yt({run:t}){let{t:n}=G();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(y,{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(x,{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(j,{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(w,{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(F,{className:`h-3 w-3`}),n(`backup.backupRunsPanel.stopped`,`Stopped`)]})}}function Xt({run:t}){let{t:n}=G();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:$t(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(I,{className:`h-3 w-3 text-primary`}),r(`span`,{className:`tabular-nums font-medium animate-pulse`,children:K(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(P,{className:`h-3 w-3 text-primary`}),e(`span`,{className:`tabular-nums font-medium`,children:[K(t.uploadedBytes),i===void 0?``:` / ${K(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:K(i)})})}function Zt({run:t}){let{t:n}=G(),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 Qt({run:t,now:n}){let{t:i}=G();return t.state===`queued`?r(`span`,{children:i(`backup.runsPanel.queuedAgo`,{elapsed:en(n-t.requestedAt)})}):t.startedAt===void 0?r(`span`,{children:`—`}):t.finishedAt===void 0?r(`span`,{children:i(`backup.runsPanel.runningFor`,{elapsed:en(n-t.startedAt)})}):e(`div`,{className:`flex flex-col gap-0.5`,children:[r(`span`,{children:tn(t.finishedAt)}),r(`span`,{className:`text-[10px]`,children:i(`backup.runsPanel.took`,{elapsed:en(t.finishedAt-t.startedAt)})})]})}function $t(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 en(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 tn(e){return new Date(e).toLocaleString(void 0,{day:`2-digit`,month:`short`,hour:`2-digit`,minute:`2-digit`})}o();var nn=[[`backup`,`list`]];function rn({initialDestinationId:n,initialArchiveId:o,onClose:c,onScheduled:l}){let{t:u}=G(),d=s(),[f,p]=a(n&&o?2:1),[m,h]=a(n),[g,_]=a(o),[v,y]=a(new Set),[b,S]=a(``),{data:w}=pe(),T=w??[],{data:E,isLoading:O}=Te({destinationId:m??``},{enabled:!!m}),k=E??[];i(()=>{if(m!==void 0)return;let e=T.filter(e=>e.restoreSupported);e.length===1&&h(e[0].id)},[m,T]);let{data:j}=de({destinationId:m??``,backupId:g??``},{enabled:!!m&&!!g}),M=t(()=>j?.locations??[],[j]);i(()=>{M.length!==0&&y(e=>e.size===0?new Set(M):e)},[M]);let N=Se({onSuccess:()=>{d.invalidateQueries({queryKey:nn}),l(),c()}}),P=e=>{y(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},F=k.find(e=>e.id===g),I=F?.encryption!==void 0,L=pt(F?.databases,j?.sqliteSnapshots),R=dt(L),ee=!!m&&!!g,te=R||v.size>0,z=ee&&te&&!N.isPending&&(!I||b.trim().length>0),ne=()=>{!m||!g||N.mutate({destinationId:m,backupId:g,...R?{}:{locations:[...v]},...I?{backupSecretKey:b.trim()}:{}})};return r(H,{open:!0,onOpenChange:e=>!e&&c(),children:e(Ne,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[e(xe,{children:[r(le,{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(_e,{children:[f===1&&r(an,{destinations:T,destinationId:m,onPickDestination:e=>{h(e),_(void 0),y(new Set)},archives:k,archivesLoading:O,archiveId:g,onPickArchive:_}),f===2&&r(on,{locations:M,picked:v,onToggle:P,databases:L,snapshotsOnly:R}),f===3&&r(sn,{destinationName:T.find(e=>e.id===m)?.displayName??m??``,archive:F,picked:[...v],databases:L,snapshotsOnly:R}),f===3&&F?.encryption!==void 0&&r(cn,{keyId:F.encryption.keyId,value:b,onChange:S}),f===3&&N.error&&r(`p`,{role:`alert`,className:`px-4 pb-2 text-xs text-danger`,children:N.error.message})]}),e(Ce,{className:`justify-between`,children:[r(`div`,{children:f>1&&e(B,{variant:`outline`,size:`sm`,onClick:()=>p(e=>e===3?2:1),children:[r(C,{className:`h-3 w-3`}),u(`common.back`,`Back`)]})}),e(`div`,{className:`flex items-center gap-2`,children:[r(B,{variant:`outline`,size:`sm`,onClick:c,children:u(`common.cancel`,`Cancel`)}),f<3?e(B,{size:`sm`,disabled:f===1&&!ee||f===2&&!te,onClick:()=>p(e=>e===1?2:3),children:[u(`common.next`,`Next`),r(D,{className:`h-3 w-3`})]}):e(B,{size:`sm`,onClick:ne,disabled:!z,children:[N.isPending?r(x,{className:`h-3.5 w-3.5 animate-spin`}):r(A,{className:`h-3.5 w-3.5`}),u(`backup.restoreWizard.scheduleRestore`,`Schedule Restore`)]})]})]})]})})}function an({destinations:t,destinationId:n,onPickDestination:i,archives:a,archivesLoading:o,archiveId:s,onPickArchive:c}){let{t:l}=G(),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(me,{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(`input`,{type:`radio`,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(S,{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(Z,{databases:pt(t.databases,void 0)})})]})]}),r(`span`,{className:`text-[10px] text-foreground-subtle tabular-nums`,children:K(t.sizeBytes)})]},t.id)})})]})]})}function on({locations:t,picked:n,onToggle:i,databases:a,snapshotsOnly:o}){let{t:s}=G();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(Z,{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(Z,{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(`input`,{type:`checkbox`,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:un(t)})]},t))})]})]})}function sn({destinationName:t,archive:n,picked:i,databases:a,snapshotsOnly:o}){let{t:s}=G();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($,{term:`Destination`,value:t}),r($,{term:`Archive`,value:n?.label??n?.id??`—`}),n&&r($,{term:`Created`,value:`${new Date(n.createdAt).toLocaleString()} · ${K(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(Z,{databases:a})})]}),r($,{term:`Locations`,value:o?`none (configuration is not touched)`:i.length>0?i.join(`, `):`— (full archive)`})]})]})}function cn({keyId:t,value:n,onChange:i}){let{t:a}=G();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(`input`,{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(He,{i18nKey:`backup.restoreWizard.encryptedTo`,values:{keyId:t},components:{mono:r(`span`,{className:`font-mono`})}})})]})}function $({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 ln={db:`Database`,addons:`Addon configs`,"addons-data":`Addon data`,tls:`TLS certificates`,cache:`Cache`,data:`Top-level data`};function un(e){return ln[e]??``}o();function dn(){let{t}=G(),n=E(),o=ae(),{state:s,openNew:c,openEdit:l,close:u}=ve({editKey:`edit`,newKey:`new`}),f=Me(),m=f.data??[],[h,g]=a(null),[_,v]=a(!1),[y,b]=a(!1),[S,C]=a(!1),w=s.mode===`edit`?m.find(e=>e.id===s.id)??null:null;i(()=>{s.mode===`edit`&&!f.isLoading&&w===null&&u()},[s.mode,f.isLoading,w,u]);let T=s.mode===`new`||s.mode===`edit`&&w!==null,D=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(Ge,{embedded:!0,children:[e(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,"data-testid":`backup-actions`,children:[e(B,{variant:`outline`,size:`sm`,type:`button`,onClick:()=>C(!0),"data-testid":`backup-now`,children:[r(p,{className:`h-3.5 w-3.5`}),t(`system.backup.backUpNow`,`Back up now`)]}),e(B,{variant:`outline`,size:`sm`,type:`button`,onClick:()=>v(!0),children:[r(A,{className:`h-3.5 w-3.5`}),t(`system.backup.restore`,`Restore…`)]}),e(B,{size:`sm`,type:`button`,onClick:c,"data-testid":`backup-new-entry`,children:[r(d,{className:`h-3.5 w-3.5`}),t(`system.backup.newEntry`,`New entry`)]})]}),y&&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(A,{className:`h-3.5 w-3.5`}),r(`span`,{children:t(`system.backup.restoreScheduledRestartTheServer`,`Restore scheduled. Restart the server to apply.`)})]}),e(B,{size:`sm`,variant:`outline`,type:`button`,onClick:()=>{D()},disabled:o.isPending,children:[o.isPending?r(x,{className:`h-3.5 w-3.5 animate-spin`}):r(A,{className:`h-3.5 w-3.5`}),t(`system.backup.restartNow`,`Restart Now`)]})]})}),r(Pt,{}),r(Kt,{}),r(bt,{onEdit:e=>l(e.id),onOpenRestoreWizard:e=>g(e)}),T&&r(Ht,{entry:w,onClose:u,onSaved:u}),S&&r(At,{onClose:()=>C(!1)}),(h||_)&&r(rn,{...h?{initialDestinationId:h.destinationId,initialArchiveId:h.archiveId}:{},onClose:()=>{g(null),v(!1)},onScheduled:()=>b(!0)})]})}o();function fn(e){return Object.entries(e).map(([e,t])=>`${e} ${t}`).join(` · `)}function pn(e){return e.reduce((e,t)=>e+Object.values(t.stores).reduce((e,t)=>e+t,0),0)}function mn(){let{t}=G(),n=E(),i=ge(),[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))}},p=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}: ${fn(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{D as l,Di as u,Fn as d,Ht as f,In as p,Q as m,Ti as h,Vn as g,Xr as _,Zi as v,di as y,ei as b,fr as x,lr as S,na as C,pi as w,ri as T,st as E,ta as D,ur as O,vn as k,wn as A,yi as j,zt as M}from"./player-overlays-B5FSaids.js";import{n as N,t as P}from"./cloud-upload-BNAApVPM.js";import{t as F}from"./circle-slash-fwUwJ3r8.js";import{t as I}from"./hard-drive-download-PwUdP9sZ.js";import{Bn as L,Cn as R,Er as ee,Rn as te,Sn as z,Su as ne,Tr as re,Un as ie,Vi as ae,Vn as oe,Yl as se,Yr as B,_a as ce,_d as V,_r as le,aa as ue,ca as de,cu as fe,da as pe,dd as me,dr as H,fa as he,fo as ge,fr as _e,ft as ve,ga as ye,gd as be,gr as xe,ha as Se,hr as Ce,ia as we,la as Te,lt as Ee,lu as De,ma as Oe,mt as ke,oa as Ae,ou as je,pa as Me,pr as Ne,pt as Pe,ra as Fe,sa as Ie,su as Le,ua as Re,va as ze,xt as U}from"./src-IQsaq5W-.js";import{t as W}from"./i18n-CXGP1uaw.js";import{t as G}from"./useTranslation-BJr-n0es.js";import"./mount-C44QyL85.js";import{T as Be,hr as Ve,pr as He,yr as Ue}from"./index-lH9UKmhf.js";import{t as We}from"./AdminSectionedPage-BG6w5-w1.js";import{t as Ge}from"./AdminPage-CVSTxsAk.js";import{n as Ke}from"./authed-media-Ba0gOxiM.js";import{t as K}from"./format-size-DIxKXxtj.js";import{a as qe,c as Je,l as Ye,n as Xe,o as Ze,s as Qe,t as $e,u as et}from"./location-owned-usage-BmtVONF0.js";o();function tt(){let{t:n}=G(),a=s(),o=E(),{data:c,isLoading:l,isError:u}=De({}),d=fe(),f=t(()=>d.data??[],[d.data]),{data:p}=se({},{refetchOnWindowFocus:!1}),m=t(()=>$e(c??[],p?.locations),[c,p?.locations]),{data:h}=Le({},{refetchOnWindowFocus:!1}),g=t(()=>qe(h),[h]),{state:_,openNew:v,openEdit:y,close:b}=ve(),[x,S]=Pe(`type`),C=()=>{S(null),b()},w=e=>{S(e),v()},T=e=>{S(null),y(e.id)},D=c??[],O=_.mode===`edit`?D.find(e=>e.id===_.id)??null:null;i(()=>{_.mode===`new`&&(x===null||x===``)&&(S(null),b())},[_.mode,x,b,S]),i(()=>{_.mode===`edit`&&!l&&O===null&&(S(null),b())},[_.mode,l,O,b,S]),i(()=>{_.mode===`closed`&&x!==null&&S(null)},[_.mode,x,S]);let k=je({onSuccess:()=>{a.invalidateQueries({queryKey:[[`storage`,`listLocations`]]})}}),A=ne({onSuccess:()=>{a.invalidateQueries({queryKey:[[`storage`,`listLocations`]]})}}),j=async(e,t)=>{Ye(t)&&!await o({title:n(`system.storage.disable`,`Disable "{{displayName}}"?`,{displayName:e.displayName}),message:n(`system.storage.nothingIsDeletedSetThe`,`{{consequence}} Nothing is deleted — set the location back to Read-only or Active to bring its footage back.`,{consequence:Je(t).consequence}),confirmLabel:n(`common.disable`,`Disable`),variant:`danger`})||A.mutate(Qe(e,{mode:t}))},M=async e=>{if(await o({title:n(`system.storage.deleteLocation`,`Delete location "{{displayName}}"?`,{displayName:e.displayName}),message:n(`system.storage.thisRemovesTheLocationRecord`,`This removes the location record. Files on disk are not deleted; the underlying directory or remote path stays untouched.`),confirmLabel:n(`common.delete`,`Delete`),variant:`danger`}))try{await k.mutateAsync({id:e.id}),_.mode===`edit`&&_.id===e.id&&C()}catch(t){await o({title:n(`system.storage.deleteAnyway`,`Delete anyway?`),message:n(`system.storage.forcingNote`,{error:t instanceof Error?t.message:String(t)}),confirmLabel:n(`system.storage.forceDelete`,`Force delete`),variant:`danger`})&&k.mutate({id:e.id,force:!0},{onSuccess:()=>{_.mode===`edit`&&_.id===e.id&&C()}})}},N=t(()=>{let e=new Map;for(let t of c??[]){let n=e.get(t.type);n?n.push(t):e.set(t.type,[t])}return e},[c]),P=l||d.isLoading,F=u||d.isError,I=_.mode===`new`&&x!==null&&x!==``,L=_.mode===`edit`&&O!==null;return e(Ge,{embedded:!0,children:[P&&r(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:n(`system.storage.loadingLocations`,`Loading locations…`)}),F&&r(`div`,{className:`text-xs text-danger`,children:n(`system.storage.failedToLoadStorageLocations`,`Failed to load storage locations.`)}),!P&&!F&&e(`div`,{className:`space-y-3`,children:[f.length===0&&r(`div`,{className:`rounded-lg border border-border bg-surface px-3 py-4 text-center text-[11px] text-foreground-subtle italic`,children:n(`system.storage.noStorageLocationsDeclaredBy`,`No storage locations declared by any installed addon.`)}),f.map(e=>r(Xe,{type:e.id,displayName:e.displayName,description:e.description,cardinality:e.cardinality,locations:N.get(e.id)??[],onAdd:w,onEdit:T,onDelete:e=>{M(e)},ownedBytesById:m,drainById:g,onSetMode:(e,t)=>{j(e,t)}},e.id))]}),I&&x!==null&&r(et,{initialType:x,onClose:C,onCreated:()=>{a.invalidateQueries({queryKey:[[`storage`,`listLocations`]]}),C()}}),L&&O!==null&&r(Ze,{location:O,onClose:C,onSaved:()=>{a.invalidateQueries({queryKey:[[`storage`,`listLocations`]]}),C()}})]})}var q={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`}},nt=Object.keys(q),J=[`settings`];function rt(){return W.t(`helpers.backupDatabases.notCreated`)}function it(e){return W.t(q[e].labelKey)}function at(e){return W.t(q[e].shortKey)}function ot(e){return W.t(q[e].descriptionKey)}function Y(e){let t=new Set(e);return nt.filter(e=>t.has(e))}function X(e){return e!==void 0&&e.length>0?Y(e):J}function st(e){return Y(e)}function ct(e,t){return t===void 0||!t.answered?`unknown`:t.databases.includes(e)?`present`:`absent`}function lt(e,t,n){return ct(e,t)===`absent`&&!n.has(e)}function ut(e,t){let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n}function dt(e){return!e.includes(`settings`)}function ft(e){return{databases:[...st(e)]}}function pt(e,t){return e!==void 0&&e.length>0?Y(e):t!==void 0&&t.length>0?Y(t.map(e=>e.databaseId??`settings`)):J}function Z({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=>at(e)).join(` · `)})}o();var mt=[[`backup`,`listDestinations`]],ht=[`backup`,`listArchives`];function gt({destinationId:i,restoreSupported:o,onOpenRestoreWizard:c}){let{t:l}=G(),u=s(),d=E(),{data:p,isLoading:m,isError:h}=Te({destinationId:i}),g=p??[],v=we({onSuccess:()=>{u.invalidateQueries({queryKey:[[...ht]]}),u.invalidateQueries({queryKey:mt})}}),y=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:K(e.sizeBytes)}),confirmLabel:l(`common.delete`,`Delete`),variant:`danger`})&&v.mutate({destinationId:i,backupId:e.id})},[d,i,v,l]),[b,C]=a(null),w=n(async e=>{C(e.id);try{let t=await Ke(_t(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{C(null)}},[i]),T=t(()=>[...g].toSorted((e,t)=>t.createdAt-e.createdAt),[g]);return m?r(`div`,{className:`text-xs text-foreground-subtle animate-pulse py-2`,children:l(`backup.archiveList.loadingArchives`,`Loading archives…`)}):h?r(`div`,{className:`text-xs text-danger py-2`,children:l(`backup.archiveList.failedToReadManifestFor`,`Failed to read manifest for this destination`)}):T.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(z,{columns:[{key:`when`,header:l(`backup.archiveList.when`,`When`),sortValue:e=>e.createdAt,render:e=>r(`span`,{className:`tabular-nums`,children:vt(e.createdAt)})},{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(S,{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:`—`})]})},{key:`databases`,header:l(`backup.archiveList.databases`,`Databases`),nowrap:!1,notSortableReason:`Database badges`,render:e=>r(Z,{databases:X(e.databases)})},{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`)})},{key:`size`,header:l(`backup.archiveList.size`,`Size`),align:`right`,sortValue:e=>e.sizeBytes,render:e=>r(`span`,{className:`tabular-nums`,children:K(e.sizeBytes)})},{key:`actions`,header:``,align:`right`,notSortableReason:`Actions`,render:t=>e(`span`,{className:`flex items-center justify-end gap-1`,children:[e(B,{variant:`ghost`,size:`sm`,onClick:()=>{w(t)},disabled:b===t.id,title:l(`backup.archiveList.downloadArchive`,`Download archive`),children:[b===t.id?r(x,{className:`h-3 w-3 animate-spin`}):r(_,{className:`h-3 w-3`}),l(`backup.archiveList.download`,`Download`)]}),o&&c&&e(B,{variant:`ghost`,size:`sm`,onClick:()=>c({destinationId:i,archiveId:t.id}),title:l(`backup.archiveList.restoreFromThisArchive`,`Restore from this archive`),children:[r(A,{className:`h-3 w-3`}),l(`backup.archiveList.restore`,`Restore`)]}),r(V,{variant:`ghost`,size:`sm`,icon:f,"aria-label":l(`backup.archiveList.delete`,`Delete {{value1}}`,{value1:t.label??t.id}),disabled:v.isPending,onClick:()=>{y(t)}})]})}],rows:T,rowKey:e=>e.id,minWidthPx:760,emptyMessage:l(`backup.archiveList.noArchivesAtThisDestination`,`No archives at this destination yet.`)})}function _t(e,t){return m(`/api/backup/download/${encodeURIComponent(e)}/${encodeURIComponent(t)}`)}function vt(e){return new Date(e).toLocaleString(void 0,{day:`2-digit`,month:`short`,year:`numeric`,hour:`2-digit`,minute:`2-digit`})}o();var yt=[[`backup`,`listSchedules`]];function bt({onEdit:i,onOpenRestoreWizard:o}){let{t:s}=G(),{data:c,isLoading:l,isError:u,error:d,refetch:f}=Me(),p=c??[],m=pe().data??[],h=t(()=>{let e=new Map;for(let t of m)e.set(t.id,t);return e},[m]),[g,_]=a(null),v=n(e=>{_(t=>t===e?null:e)},[]),y=t(()=>xt({destById:h,expandedId:g,onToggleExpand:v,onEdit:i}),[h,g,v,i]);return l?e(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle animate-pulse`,children:[r(x,{className:`h-3.5 w-3.5 animate-spin`}),s(`backup.backupEntriesTable.loadingBackupEntries`,`Loading backup entries…`)]}):u?r(re,{title:s(`backup.backupEntriesTable.failedToLoadBackupEntries`,`Failed to load backup entries`),message:d instanceof Error?d.message:s(`backup.backupEntriesTable.unknownError`,`Unknown error`),onRetry:()=>void f()}):p.length===0?r(ee,{icon:N,title:s(`backup.backupEntriesTable.noBackupEntriesYet`,`No backup entries yet`),description:s(`backup.backupEntriesTable.createOneToScheduleBackups`,`Create one to schedule backups across one or more storage locations.`)}):r(z,{columns:y,rows:p,rowKey:e=>e.id,minWidthPx:980,maxBodyHeight:R,emptyMessage:s(`backup.backupEntriesTable.noBackupEntriesYet`,`No backup entries yet`),onRowClick:e=>i(e),isExpanded:e=>e.id===g,renderExpanded:e=>r(Ot,{row:e,destById:h,...o?{onOpenRestoreWizard:o}:{}})})}function xt(t){return[{key:`expand`,header:``,width:`w-8`,nowrap:!0,notSortableReason:`Expand control`,render:e=>{let n=t.expandedId===e.id;return r(V,{variant:`ghost`,size:`sm`,icon:n?u:h,"aria-label":n?W.t(`backup.backupEntriesTable.hideArchives`,`Hide archives`):W.t(`backup.backupEntriesTable.showArchives`,`Show archives`),"aria-expanded":n,onClick:n=>{n.stopPropagation(),t.onToggleExpand(e.id)}})}},{key:`entry`,header:W.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||W.t(`backup.backupEntriesTable.unnamed`,`(unnamed)`)}),t.lastRunAt!==void 0&&r(`span`,{className:`text-[10px] text-foreground-subtle`,children:W.t(`backup.backupEntriesTable.lastRun`,{when:new Date(t.lastRunAt).toLocaleString()})})]})},{key:`enabled`,header:W.t(`backup.backupEntriesTable.enabled`,`Enabled`),width:`w-20`,nowrap:!0,sortValue:e=>+!!e.enabled,render:e=>r(`span`,{onClick:e=>e.stopPropagation(),children:r(Tt,{row:e})})},{key:`databases`,header:W.t(`backup.backupEntriesTable.backsUp`,`Backs up`),nowrap:!1,notSortableReason:`Database badges`,render:e=>r(Z,{databases:X(e.databases)})},{key:`locations`,header:W.t(`backup.backupEntriesTable.locations`,`Locations`),nowrap:!1,notSortableReason:`Location chips`,render:e=>r(St,{row:e,destById:t.destById})},{key:`retention`,header:W.t(`backup.backupEntriesTable.retention`,`Retention`),width:`w-24`,nowrap:!0,sortValue:e=>e.retentionCount,render:e=>r(`span`,{onClick:e=>e.stopPropagation(),children:r(Et,{row:e})})},{key:`schedule`,header:W.t(`backup.backupEntriesTable.schedule`,`Schedule`),width:`w-48`,nowrap:!0,sortValue:e=>e.cron,render:e=>r(Ct,{row:e})},{key:`actions`,header:``,align:`right`,nowrap:!0,notSortableReason:`Actions`,render:e=>r(`span`,{onClick:e=>e.stopPropagation(),children:r(Dt,{row:e,onEdit:()=>t.onEdit(e)})})}]}function St({row:e,destById:t}){let{t:n}=G();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 Ct({row:t}){let{t:n}=G(),i=t.cron.trim().length>0;return e(`span`,{className:`flex flex-col items-start gap-0.5`,children:[e(`span`,{className:`inline-flex items-center gap-1`,children:[r(N,{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:W.t(`common.nextRun`,{when:new Date(t.nextRunAt).toLocaleString()})})]})}function wt(e){return t(()=>({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]}:{}}),[e])}function Tt({row:e}){let{t}=G(),n=s(),i=ze({onSuccess:()=>{n.invalidateQueries({queryKey:yt})}}),a=wt(e);return r(`label`,{className:`inline-flex cursor-pointer items-center`,children:r(`input`,{type:`checkbox`,className:`accent-primary`,checked:e.enabled,disabled:i.isPending,onChange:e=>i.mutate({...a,enabled:e.target.checked}),"aria-label":t(`backup.backupEntriesTable.enable`,`Enable {{value1}}`,{value1:e.label||e.id})})})}function Et({row:e}){let{t}=G(),n=s(),o=ze({onSuccess:()=>{n.invalidateQueries({queryKey:yt})}}),c=wt(e),[l,u]=a(String(e.retentionCount));return i(()=>{u(String(e.retentionCount))},[e.retentionCount]),r(be,{type:`number`,min:1,max:1e3,value:l,disabled:o.isPending,onChange:e=>u(e.target.value),onBlur:()=>{let t=Number.parseInt(l,10);if(Number.isNaN(t)||t<1){u(String(e.retentionCount));return}t!==e.retentionCount&&o.mutate({...c,enabled:e.enabled,retentionCount:t})},onKeyDown:t=>{t.key===`Enter`&&t.target.blur(),t.key===`Escape`&&u(String(e.retentionCount))},className:`w-16`,"aria-label":t(`backup.backupEntriesTable.retentionFor`,`Retention for {{value1}}`,{value1:e.label||e.id})})}function Dt({row:t,onEdit:n}){let{t:i}=G(),a=s(),o=E(),c=ue({onSuccess:()=>{a.invalidateQueries({queryKey:yt})}}),l=ce({onMutate:()=>{a.invalidateQueries({queryKey:[[`backup`,`listRuns`]]})},onSuccess:()=>{a.invalidateQueries({queryKey:[[`backup`,`listArchives`]]}),a.invalidateQueries({queryKey:[[`backup`,`listDestinations`]]}),a.invalidateQueries({queryKey:[[`backup`,`listRuns`]]})}}),u=()=>{t.locationIds.length!==0&&l.mutate({destinations:[...t.locationIds],...t.dataSources&&t.dataSources.length>0?{locations:[...t.dataSources]}:{},label:t.label,retentionCount:t.retentionCount,databases:[...X(t.databases)]})},d=async()=>{await o({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`})&&c.mutate({id:t.id})};return e(`span`,{className:`flex items-center justify-end gap-1.5`,children:[e(B,{size:`sm`,type:`button`,onClick:u,disabled:l.isPending||t.locationIds.length===0,title:i(`backup.backupEntriesTable.runThisEntryNow`,`Run this entry now`),children:[l.isPending?r(x,{className:`h-3 w-3 animate-spin`}):r(p,{className:`h-3 w-3`}),i(`backup.backupEntriesTable.runNow`,`Run now`)]}),r(V,{variant:`ghost`,size:`sm`,icon:g,"aria-label":i(`backup.backupEntriesTable.edit`,`Edit {{value1}}`,{value1:t.label||t.id}),onClick:n}),r(V,{variant:`ghost`,size:`sm`,icon:f,"aria-label":i(`backup.backupEntriesTable.delete`,`Delete {{value1}}`,{value1:t.label||t.id}),disabled:c.isPending,onClick:()=>{d()}})]})}function Ot({row:t,destById:n,onOpenRestoreWizard:i}){let{t:a}=G();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(gt,{destinationId:t,restoreSupported:n.get(t)?.restoreSupported??!0,...i?{onOpenRestoreWizard:i}:{}})]},t))]})}function kt({selected:t,onChange:n,disabled:i=!1,testId:a=`backup-databases`}){let{t:o}=G(),s=Re().data,c=t.size>0&&dt(Y(t)),l=t.size===0?`Pick at least one.`:c?`Snapshots only: configuration and files are not part of this backup.`:null;return r(U,{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:nt.map(o=>{let c=ct(o,s),l=i||lt(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(ie,{checked:t.has(o),disabled:l,onChange:()=>n(ut(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:it(o)}),r(`span`,{className:`block text-[11px] text-foreground-subtle`,children:c===`absent`?rt():ot(o)})]})]},o)})})})}o();function At({onClose:t}){let{t:n}=G(),i=s(),[o,c]=a(new Set(J)),l=ce({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(H,{open:!0,onOpenChange:e=>!e&&t(),children:e(Ne,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[e(xe,{children:[r(le,{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(_e,{children:e(`div`,{className:`p-4`,children:[r(kt,{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(Ce,{children:[r(B,{variant:`outline`,size:`sm`,onClick:t,children:n(`common.cancel`,`Cancel`)}),e(B,{size:`sm`,onClick:()=>{o.size!==0&&l.mutate(ft(o))},disabled:o.size===0||l.isPending,"data-testid":`backup-now-run`,children:[l.isPending?r(x,{className:`h-3.5 w-3.5 animate-spin`}):r(p,{className:`h-3.5 w-3.5`}),n(`backup.backupNowDialog.backUpNow`,`Back up now`)]})]})]})})}o();function jt(e){return e===null?`—`:new Date(e).toLocaleString()}function Mt(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 Nt({revealed:t,onDone:n}){let{t:i}=G(),[o,s]=a(!1),[c,l]=a(!1);return r(H,{open:!0,onOpenChange:e=>!e&&o&&n(),children:e(Ne,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,className:`border-danger/40`,"aria-labelledby":`backup-key-title`,children:[r(xe,{children:r(le,{id:`backup-key-title`,children:i(`backup.encryptionCard.yourKey`,{keyId:t.keyId})})}),e(_e,{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(M,{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. CamStack 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(B,{size:`sm`,variant:`outline`,onClick:()=>{navigator.clipboard?.writeText(t.secretKey).then(()=>l(!0))},children:[r(T,{className:`mr-1 h-3.5 w-3.5`}),c?i(`backup.backupEncryptionCard.copied`,`Copied`):i(`common.copy`,`Copy`)]}),e(B,{size:`sm`,variant:`outline`,onClick:()=>Mt(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(`input`,{type:`checkbox`,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(Ce,{children:r(B,{size:`sm`,disabled:!o,onClick:n,children:i(`backup.backupEncryptionCard.iHaveStoredIt`,`I have stored it`)})})]})})}function Pt(){let{t}=G(),n=Ie(),i=ye(),o=Ae(),s=E(),[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(S,{className:`h-4 w-4 text-success`}):r(O,{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:jt(m.createdAt)}):t(`backup.backupEncryptionCard.offBackupsAreNotEncrypted`,`Off — backups are not encrypted`)})]}),r(`div`,{className:`flex gap-2`,children:p?e(c,{children:[r(B,{size:`sm`,variant:`outline`,disabled:i.isPending,onClick:()=>void g(),children:t(`backup.backupEncryptionCard.replaceKey`,`Replace key`)}),r(B,{size:`sm`,variant:`outline`,disabled:o.isPending,onClick:()=>void _(),children:t(`backup.backupEncryptionCard.turnOff`,`Turn off`)})]}):r(B,{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, config.yaml, 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,` · `,jt(t.createdAt),` → `,jt(t.retiredAt)]},t.keyId))})]}),d!==null&&r(`p`,{className:`text-xs text-danger`,children:d}),l!==null&&r(Nt,{revealed:l,onDone:()=>{u(null),n.refetch()}})]})}o();var Ft=[{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 It(e){let t=e.trim();for(let e of Ft)if(e.cron===t)return e.id;return`custom`}function Lt({value:t,onChange:n,previewCount:o=5,disabled:s=!1}){let{t:c}=G(),l=It(t),[u,d]=a(l===`custom`);i(()=>{l!==`custom`&&d(!1)},[l]);let f=Bt(t,250),p=Oe({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:[Ft.map(e=>r(`button`,{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(`button`,{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(`input`,{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(He,{i18nKey:`backup.cronEditor.formatLine`,components:{code:r(`span`,{className:`font-mono`})}})]})]}),r(Rt,{cron:f,preview:m,loading:p.isFetching})]})}function Rt({cron:t,preview:n,loading:i}){let{t:a}=G();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(x,{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:zt(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 zt(e){let t=e-Date.now();if(t<=0)return W.t(`helpers.relativeTime.now`);let n=Math.floor(t/1e3);if(n<60)return W.t(`helpers.relativeTime.inSeconds`,{count:n});let r=Math.floor(n/60);if(r<60)return W.t(`helpers.relativeTime.inMinutes`,{count:r});let i=Math.floor(r/60);if(i<24)return W.t(`helpers.relativeTime.inHours`,{count:i});let a=Math.floor(i/24);return W.t(`helpers.relativeTime.inDays`,{count:a})}function Bt(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 Vt=[[`backup`,`listSchedules`]];function Ht({entry:n,onClose:i,onSaved:o}){let{t:c}=G(),l=s(),u=pe(),d=u.data??[],[f,p]=a(n?.label??``),[m,h]=a(n?.cron??`0 3 * * *`),[g,_]=a(n?.enabled??!0),[v,y]=a(String(n?.retentionCount??7)),[b,S]=a(new Set(n?.locationIds??[])),[C,w]=a(new Set(n===null?J:X(n.databases))),T=ze({onSuccess:()=>{l.invalidateQueries({queryKey:Vt}),o()}}),E=e=>{S(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},D=Number.parseInt(v,10),O=t(()=>f.trim().length>0&&b.size>0&&C.size>0&&!Number.isNaN(D)&&D>=1&&D<=1e3,[f,b,C,D]),k=()=>{O&&T.mutate({...n?{id:n.id}:{},label:f.trim(),cron:m.trim(),enabled:g,locationIds:Array.from(b),retentionCount:D,databases:[...st(C)]})},A=T.error instanceof Error?T.error.message:null;return r(ke,{open:!0,onClose:i,title:n?c(`backup.backupEntryModal.editBackupEntry`,`Edit backup entry`):c(`backup.backupEntryModal.newBackupEntry`,`New backup entry`),icon:N,error:A,width:`lg`,testId:`backup-entry-form`,footer:e(B,{size:`sm`,type:`button`,onClick:k,disabled:!O||T.isPending,children:[T.isPending?r(x,{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(U,{label:c(`backup.backupEntryModal.name`,`Name`),required:!0,children:r(be,{value:f,onChange:e=>p(e.target.value),placeholder:c(`backup.backupEntryModal.nightlyOffsite`,`Nightly offsite`),autoFocus:!0,"data-testid":`backup-entry-name`})}),e(U,{label:c(`backup.backupEntryModal.locationsSelected`,`Locations ({{value1}} selected)`,{value1:String(b.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(x,{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(`input`,{type:`checkbox`,checked:b.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(kt,{selected:C,onChange:w,disabled:T.isPending,testId:`backup-entry-databases`}),e(`div`,{className:`grid grid-cols-2 gap-3`,children:[r(U,{label:c(`backup.backupEntryModal.retentionArchivesKept`,`Retention (archives kept)`),required:!0,children:r(be,{type:`number`,min:1,max:1e3,value:v,onChange:e=>y(e.target.value),"data-testid":`backup-entry-retention`})}),r(U,{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(`input`,{type:`checkbox`,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(U,{label:c(`backup.backupEntryModal.schedule`,`Schedule`),children:r(Lt,{value:m,onChange:h,disabled:T.isPending})})]})})}o();var Ut=2e3,Wt=5e3;function Q(e){return e.state===`queued`||e.state===`running`}function Gt(e){if(e.state===`queued`)return{title:W.t(`backup.backupRunsPanel.cancelQueuedBackupRun`,`Cancel queued backup run?`),message:W.t(`backup.backupRunsPanel.thisRunHasNotStarted`,`This run has not started. Cancelling removes it from the queue — nothing has been written, nothing is deleted.`),confirmLabel:W.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:W.t(`backup.backupRunsPanel.stopThisBackupRun`,`Stop this backup run?`),message:W.t(`backup.backupRunsPanel.theHalfWrittenStagingArchive`,`The half-written staging archive is deleted and the destination currently uploading discards its partial copy. {{keptSentence}}`,{keptSentence:n}),confirmLabel:W.t(`backup.backupRunsPanel.stopRun`,`Stop run`),variant:`danger`}}function Kt(){let e=E(),[t,i]=a(null),o=he(void 0,{refetchInterval:e=>(e.state.data??[]).some(Q)?Ut:Wt}),s=Fe({onSettled:()=>{i(null),o.refetch()}}),c=n(async t=>{await e(Gt(t))&&(i(t.id),s.mutate({runId:t.id}))},[e,s]);return r(qt,{queryState:o.isError?`error`:o.data===void 0?`pending`:`ready`,runs:o.data??[],cancelingId:t,onCancelRequest:e=>{c(e)},now:Date.now()})}function qt({queryState:t,runs:n,cancelingId:i,onCancelRequest:a,now:o}){let{t:s}=G(),c=t===`ready`&&n.some(Q),l=n.filter(e=>e.state===`running`),u=n.filter(e=>e.state===`queued`),d=n.filter(e=>!Q(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(`div`,{className:`overflow-x-auto`,children:e(`table`,{className:`w-full text-xs min-w-[720px]`,children:[r(`thead`,{children:e(`tr`,{className:`text-foreground-subtle bg-background/30`,children:[r(`th`,{className:`text-left px-3 py-1.5 font-medium`,children:s(`backup.backupRunsPanel.run`,`Run`)}),r(`th`,{className:`text-left px-3 py-1.5 font-medium`,children:s(`backup.backupRunsPanel.state`,`State`)}),r(`th`,{className:`text-left px-3 py-1.5 font-medium`,children:s(`backup.backupRunsPanel.progress`,`Progress`)}),r(`th`,{className:`text-left px-3 py-1.5 font-medium`,children:s(`backup.backupRunsPanel.destinations`,`Destinations`)}),r(`th`,{className:`text-left px-3 py-1.5 font-medium`,children:s(`backup.backupRunsPanel.timing`,`Timing`)}),r(`th`,{className:`text-right px-3 py-1.5 font-medium w-28`,children:s(`backup.backupRunsPanel.actions`,`Actions`)})]})}),r(`tbody`,{children:f.map(e=>r(Jt,{run:e,canceling:i===e.id,onCancelRequest:a,now:o},e.id))})]})})]})}function Jt({run:t,canceling:n,onCancelRequest:i,now:a}){let{t:o}=G(),s=Q(t);return e(`tr`,{className:`border-t border-border hover:bg-primary/5 align-top`,children:[r(`td`,{className:`px-3 py-2`,children:r(`div`,{className:`text-foreground`,title:t.id,children:t.label??r(`span`,{className:`text-foreground-subtle italic`,children:o(`backup.runsPanel.manual`)})})}),e(`td`,{className:`px-3 py-2`,children:[r(Yt,{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})]}),r(`td`,{className:`px-3 py-2`,children:r(Xt,{run:t})}),r(`td`,{className:`px-3 py-2`,children:r(Zt,{run:t})}),r(`td`,{className:`px-3 py-2 text-foreground-subtle tabular-nums`,children:r(Qt,{run:t,now:a})}),r(`td`,{className:`px-3 py-2`,children:r(`div`,{className:`flex justify-end`,children:s&&e(`button`,{onClick:()=>i(t),disabled:n,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:t.state===`queued`?o(`backup.backupRunsPanel.removeThisRunFromThe`,`Remove this run from the queue before it starts`):o(`backup.backupRunsPanel.stopThisRunTheHalf`,`Stop this run — the half-written archive is discarded`),children:[n?r(x,{className:`h-3 w-3 animate-spin`}):r(v,{className:`h-3 w-3`}),t.state===`queued`?o(`common.cancel`,`Cancel`):o(`backup.backupRunsPanel.stop`,`Stop`)]})})})]})}function Yt({run:t}){let{t:n}=G();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(y,{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(x,{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(j,{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(w,{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(F,{className:`h-3 w-3`}),n(`backup.backupRunsPanel.stopped`,`Stopped`)]})}}function Xt({run:t}){let{t:n}=G();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:$t(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(I,{className:`h-3 w-3 text-primary`}),r(`span`,{className:`tabular-nums font-medium animate-pulse`,children:K(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(P,{className:`h-3 w-3 text-primary`}),e(`span`,{className:`tabular-nums font-medium`,children:[K(t.uploadedBytes),i===void 0?``:` / ${K(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:K(i)})})}function Zt({run:t}){let{t:n}=G(),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 Qt({run:t,now:n}){let{t:i}=G();return t.state===`queued`?r(`span`,{children:i(`backup.runsPanel.queuedAgo`,{elapsed:en(n-t.requestedAt)})}):t.startedAt===void 0?r(`span`,{children:`—`}):t.finishedAt===void 0?r(`span`,{children:i(`backup.runsPanel.runningFor`,{elapsed:en(n-t.startedAt)})}):e(`div`,{className:`flex flex-col gap-0.5`,children:[r(`span`,{children:tn(t.finishedAt)}),r(`span`,{className:`text-[10px]`,children:i(`backup.runsPanel.took`,{elapsed:en(t.finishedAt-t.startedAt)})})]})}function $t(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 en(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 tn(e){return new Date(e).toLocaleString(void 0,{day:`2-digit`,month:`short`,hour:`2-digit`,minute:`2-digit`})}o();var nn=[[`backup`,`list`]];function rn({initialDestinationId:n,initialArchiveId:o,onClose:c,onScheduled:l}){let{t:u}=G(),d=s(),[f,p]=a(n&&o?2:1),[m,h]=a(n),[g,_]=a(o),[v,y]=a(new Set),[b,S]=a(``),{data:w}=pe(),T=w??[],{data:E,isLoading:O}=Te({destinationId:m??``},{enabled:!!m}),k=E??[];i(()=>{if(m!==void 0)return;let e=T.filter(e=>e.restoreSupported);e.length===1&&h(e[0].id)},[m,T]);let{data:j}=de({destinationId:m??``,backupId:g??``},{enabled:!!m&&!!g}),M=t(()=>j?.locations??[],[j]);i(()=>{M.length!==0&&y(e=>e.size===0?new Set(M):e)},[M]);let N=Se({onSuccess:()=>{d.invalidateQueries({queryKey:nn}),l(),c()}}),P=e=>{y(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},F=k.find(e=>e.id===g),I=F?.encryption!==void 0,L=pt(F?.databases,j?.sqliteSnapshots),R=dt(L),ee=!!m&&!!g,te=R||v.size>0,z=ee&&te&&!N.isPending&&(!I||b.trim().length>0),ne=()=>{!m||!g||N.mutate({destinationId:m,backupId:g,...R?{}:{locations:[...v]},...I?{backupSecretKey:b.trim()}:{}})};return r(H,{open:!0,onOpenChange:e=>!e&&c(),children:e(Ne,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[e(xe,{children:[r(le,{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(_e,{children:[f===1&&r(an,{destinations:T,destinationId:m,onPickDestination:e=>{h(e),_(void 0),y(new Set)},archives:k,archivesLoading:O,archiveId:g,onPickArchive:_}),f===2&&r(on,{locations:M,picked:v,onToggle:P,databases:L,snapshotsOnly:R}),f===3&&r(sn,{destinationName:T.find(e=>e.id===m)?.displayName??m??``,archive:F,picked:[...v],databases:L,snapshotsOnly:R}),f===3&&F?.encryption!==void 0&&r(cn,{keyId:F.encryption.keyId,value:b,onChange:S}),f===3&&N.error&&r(`p`,{role:`alert`,className:`px-4 pb-2 text-xs text-danger`,children:N.error.message})]}),e(Ce,{className:`justify-between`,children:[r(`div`,{children:f>1&&e(B,{variant:`outline`,size:`sm`,onClick:()=>p(e=>e===3?2:1),children:[r(C,{className:`h-3 w-3`}),u(`common.back`,`Back`)]})}),e(`div`,{className:`flex items-center gap-2`,children:[r(B,{variant:`outline`,size:`sm`,onClick:c,children:u(`common.cancel`,`Cancel`)}),f<3?e(B,{size:`sm`,disabled:f===1&&!ee||f===2&&!te,onClick:()=>p(e=>e===1?2:3),children:[u(`common.next`,`Next`),r(D,{className:`h-3 w-3`})]}):e(B,{size:`sm`,onClick:ne,disabled:!z,children:[N.isPending?r(x,{className:`h-3.5 w-3.5 animate-spin`}):r(A,{className:`h-3.5 w-3.5`}),u(`backup.restoreWizard.scheduleRestore`,`Schedule Restore`)]})]})]})]})})}function an({destinations:t,destinationId:n,onPickDestination:i,archives:a,archivesLoading:o,archiveId:s,onPickArchive:c}){let{t:l}=G(),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(me,{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(`input`,{type:`radio`,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(S,{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(Z,{databases:pt(t.databases,void 0)})})]})]}),r(`span`,{className:`text-[10px] text-foreground-subtle tabular-nums`,children:K(t.sizeBytes)})]},t.id)})})]})]})}function on({locations:t,picked:n,onToggle:i,databases:a,snapshotsOnly:o}){let{t:s}=G();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(Z,{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(Z,{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(`input`,{type:`checkbox`,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:un(t)})]},t))})]})]})}function sn({destinationName:t,archive:n,picked:i,databases:a,snapshotsOnly:o}){let{t:s}=G();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($,{term:`Destination`,value:t}),r($,{term:`Archive`,value:n?.label??n?.id??`—`}),n&&r($,{term:`Created`,value:`${new Date(n.createdAt).toLocaleString()} · ${K(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(Z,{databases:a})})]}),r($,{term:`Locations`,value:o?`none (configuration is not touched)`:i.length>0?i.join(`, `):`— (full archive)`})]})]})}function cn({keyId:t,value:n,onChange:i}){let{t:a}=G();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(`input`,{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(He,{i18nKey:`backup.restoreWizard.encryptedTo`,values:{keyId:t},components:{mono:r(`span`,{className:`font-mono`})}})})]})}function $({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 ln={db:`Database`,addons:`Addon configs`,"addons-data":`Addon data`,tls:`TLS certificates`,cache:`Cache`,data:`Top-level data`};function un(e){return ln[e]??``}o();function dn(){let{t}=G(),n=E(),o=ae(),{state:s,openNew:c,openEdit:l,close:u}=ve({editKey:`edit`,newKey:`new`}),f=Me(),m=f.data??[],[h,g]=a(null),[_,v]=a(!1),[y,b]=a(!1),[S,C]=a(!1),w=s.mode===`edit`?m.find(e=>e.id===s.id)??null:null;i(()=>{s.mode===`edit`&&!f.isLoading&&w===null&&u()},[s.mode,f.isLoading,w,u]);let T=s.mode===`new`||s.mode===`edit`&&w!==null,D=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(Ge,{embedded:!0,children:[e(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,"data-testid":`backup-actions`,children:[e(B,{variant:`outline`,size:`sm`,type:`button`,onClick:()=>C(!0),"data-testid":`backup-now`,children:[r(p,{className:`h-3.5 w-3.5`}),t(`system.backup.backUpNow`,`Back up now`)]}),e(B,{variant:`outline`,size:`sm`,type:`button`,onClick:()=>v(!0),children:[r(A,{className:`h-3.5 w-3.5`}),t(`system.backup.restore`,`Restore…`)]}),e(B,{size:`sm`,type:`button`,onClick:c,"data-testid":`backup-new-entry`,children:[r(d,{className:`h-3.5 w-3.5`}),t(`system.backup.newEntry`,`New entry`)]})]}),y&&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(A,{className:`h-3.5 w-3.5`}),r(`span`,{children:t(`system.backup.restoreScheduledRestartTheServer`,`Restore scheduled. Restart the server to apply.`)})]}),e(B,{size:`sm`,variant:`outline`,type:`button`,onClick:()=>{D()},disabled:o.isPending,children:[o.isPending?r(x,{className:`h-3.5 w-3.5 animate-spin`}):r(A,{className:`h-3.5 w-3.5`}),t(`system.backup.restartNow`,`Restart Now`)]})]})}),r(Pt,{}),r(Kt,{}),r(bt,{onEdit:e=>l(e.id),onOpenRestoreWizard:e=>g(e)}),T&&r(Ht,{entry:w,onClose:u,onSaved:u}),S&&r(At,{onClose:()=>C(!1)}),(h||_)&&r(rn,{...h?{initialDestinationId:h.destinationId,initialArchiveId:h.archiveId}:{},onClose:()=>{g(null),v(!1)},onScheduled:()=>b(!0)})]})}o();function fn(e){return Object.entries(e).map(([e,t])=>`${e} ${t}`).join(` · `)}function pn(e){return e.reduce((e,t)=>e+Object.values(t.stores).reduce((e,t)=>e+t,0),0)}function mn(){let{t}=G(),n=E(),i=ge(),[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))}},p=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}: ${fn(e.stores)}`).join(`
|
|
2
2
|
`),confirmLabel:t(`systemPage.deletedDevices.confirmLabel`,`Delete`),variant:`danger`})&&await d(!0)},m=[{key:`device`,header:t(`systemPage.deletedDevices.device`,`Device`),render:e=>`#${e.deviceId}`},{key:`stores`,header:t(`systemPage.deletedDevices.stores`,`Data held`),nowrap:!1,render:e=>fn(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(B,{variant:`outline`,onClick:()=>void d(!1),disabled:i.isPending,"data-testid":`deleted-devices-scan`,children:[i.isPending?r(x,{className:`mr-2 h-4 w-4 animate-spin`}):r(k,{className:`mr-2 h-4 w-4`}),t(`systemPage.deletedDevices.scan`,`Scan`)]}),o?.status===`dry-run`&&o.devices.length>0?e(B,{variant:`danger`,onClick:()=>void p(),disabled:i.isPending,"data-testid":`deleted-devices-delete`,children:[r(f,{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:pn(o.devices),count:o.devices.length}):t(`systemPage.deletedDevices.found`,`{{count}} deleted devices still hold {{rows}} items.`,{rows:pn(o.devices),count:o.devices.length})}),r(z,{columns:m,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 hn=`view`,gn=`kinds`,_n=`deleted-devices`;function vn(){let{t}=G(),[n,i]=Ue(),a=n.get(`view`)===`deleted-devices`?_n:gn;return e(`div`,{className:l,children:[e(`div`,{className:`mb-3 space-y-2`,children:[r(te,{appearance:`pills`,value:a,onValueChange:e=>{i(t=>{let n=new URLSearchParams(t);return e===`kinds`?n.delete(hn):n.set(hn,e),n},{replace:!0})},children:e(L,{className:`flex flex-wrap gap-1`,children:[r(oe,{value:gn,children:t(`systemPage.data.viewKinds`,`Record kinds`)}),r(oe,{value:_n,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`?Ee:mn,{})]})}var yn={entries:null,"deleted-devices":`deleted-devices`};function bn(){let{t:e}=G(),t=Be(`/system/data`,{t:e,isAdmin:!0})??{icon:b,title:e(`system.data`,`Data`)},[n]=Ue(),i=yn[n.get(`tab`)??``];if(i!==void 0){let e=new URLSearchParams(n);return e.set(`tab`,`records`),i!==null&&e.set(`view`,i),r(Ve,{replace:!0,to:{search:e.toString()}})}return r(We,{icon:t.icon,title:t.title,defaultSection:`storage`,sectionsLabel:`${t.title} sections`,sections:[{id:`storage`,label:e(`systemPage.data.storage`,`Storage`),content:r(tt,{})},{id:`records`,label:e(`systemPage.data.records`,`Records`),content:r(vn,{}),ownedParams:[`view`,`recordsOwner`,`recordsKind`,`entryNew`,`entryEdit`]},{id:`backup`,label:e(`systemPage.data.backup`,`Backup`),content:r(dn,{})}]})}export{bn as DataPage};
|