@camstack/addon-admin-ui 1.2.672 → 1.2.673
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 +6 -0
- package/dist/assets/{Addons-BEhl3aw7.js → Addons-Dl4Ed0w_.js} +1 -1
- package/dist/assets/{AdminPage-WKFHThAA.js → AdminPage-bLxyruUe.js} +1 -1
- package/dist/assets/{AdminSectionedPage-aE2P4MNm.js → AdminSectionedPage-vnoSnjIu.js} +1 -1
- package/dist/assets/{AiProfiles-seGYRA1N.js → AiProfiles-CUcDrrtc.js} +1 -1
- package/dist/assets/{BootstrapSettingsForm-VkqZ4n9L.js → BootstrapSettingsForm-CpvlarTT.js} +1 -1
- package/dist/assets/{Build-DfuFTfOe.js → Build-BVHmf4sa.js} +1 -1
- package/dist/assets/{Calendars-B5_Iw15u.js → Calendars-WPgNTXpb.js} +1 -1
- package/dist/assets/{CameraGrids-WRpTOdgM.js → CameraGrids-DNVLT_g-.js} +1 -1
- package/dist/assets/{Cluster-H2SeggWn.js → Cluster-DXnmd3TJ.js} +1 -1
- package/dist/assets/{CompositionBlockEditor-D_kgqFjy.js → CompositionBlockEditor-CfazE3Js.js} +1 -1
- package/dist/assets/{CompositionEditorPage-CBnk6Oi4.js → CompositionEditorPage-xZt9xNnb.js} +1 -1
- package/dist/assets/{Data-Bmx_QZ5N.js → Data-CX-UI9DM.js} +1 -1
- package/dist/assets/{DeviceDetail-DPtEEtEu.js → DeviceDetail-bLQrVZ1A.js} +1 -1
- package/dist/assets/{Devices-Bs2smCnE.js → Devices-KEps1UGm.js} +1 -1
- package/dist/assets/{EmbedDevicePage-DtB3fTCS.js → EmbedDevicePage-CXvRePXD.js} +1 -1
- package/dist/assets/{EmbedPlayerPage-BsiMBwWy.js → EmbedPlayerPage-DOewSiDm.js} +1 -1
- package/dist/assets/{History-kgS1nMrV.js → History-DDdKnfJ2.js} +1 -1
- package/dist/assets/{Identity-BaQ05dRz.js → Identity-DEvMFJ8U.js} +1 -1
- package/dist/assets/{InstancesTable-Bm6FGiwJ.js → InstancesTable-Cn1INVUs.js} +1 -1
- package/dist/assets/{IntegrationDetail-ByhHLh3L.js → IntegrationDetail-CeDutRAR.js} +1 -1
- package/dist/assets/{Integrations-esSALn0z.js → Integrations-BNPsvsDG.js} +1 -1
- package/dist/assets/{Integrations-DlQX63NB.js → Integrations-DZ4d7yCu.js} +1 -1
- package/dist/assets/{Library-CWLw_sup.js → Library-DCLUmh7t.js} +1 -1
- package/dist/assets/{Locations-Bo_gdnn6.js → Locations-ejPYyz4D.js} +1 -1
- package/dist/assets/{Logs-DvXNPp-Y.js → Logs-BS4JYpzd.js} +1 -1
- package/dist/assets/{MyAccess-CaEYIf0r.js → MyAccess-CBlNgEUN.js} +1 -1
- package/dist/assets/{Network-BvNO3Og4.js → Network-0wPLfJ0h.js} +1 -1
- package/dist/assets/{NodeAddonsSettingsPanel--3ZSd9Jd.js → NodeAddonsSettingsPanel-Bk2zvhh-.js} +1 -1
- package/dist/assets/{Notifications-C184vu19.js → Notifications-BFiv-KUA.js} +1 -1
- package/dist/assets/{Pipeline-BK7KRS_e.js → Pipeline-CWjfmglV.js} +1 -1
- package/dist/assets/{Recordings-BDIDg5W6.js → Recordings-B_JPtd9_.js} +1 -1
- package/dist/assets/{SessionsList-Bf6Abb3S.js → SessionsList-DMqcS-nT.js} +1 -1
- package/dist/assets/{Showroom-BhyCOwGI.js → Showroom-B1RoJ593.js} +1 -1
- package/dist/assets/{StorageLocationsTable-4_DOpVA_.js → StorageLocationsTable-BU2R2YDl.js} +1 -1
- package/dist/assets/{System-DQLuaJZ4.js → System-9dHx6EzL.js} +1 -1
- package/dist/assets/{Terminal-BPZfBJ19.js → Terminal-B_CcltGA.js} +1 -1
- package/dist/assets/{TrainingProviders-Sb4yaWHO.js → TrainingProviders-BAaea0d6.js} +1 -1
- package/dist/assets/{Viewer-zk7q16mM.js → Viewer-DrgoA7AH.js} +1 -1
- package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-NUohwQsx.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-CoNgx8LV.js} +1 -1
- package/dist/assets/{assignment-candidates-CQzBruHK.js → assignment-candidates-BSCyf2de.js} +1 -1
- package/dist/assets/{authed-media-CdhEKUeH.js → authed-media-CfvJyG-Y.js} +1 -1
- package/dist/assets/{device-detail-ZWsVTFVe.js → device-detail-K5TWmBwE.js} +1 -1
- package/dist/assets/{device-integration-icon-D5moECYy.js → device-integration-icon-W3dt9ax1.js} +1 -1
- package/dist/assets/device-picker-model-BG-DzgSt.js +1 -0
- package/dist/assets/{hostInit-BwafpPpx.js → hostInit-Di5WwrRQ.js} +1 -1
- package/dist/assets/{index-DqWOkhIM.js → index-1bBrNxAK.js} +3 -3
- package/dist/assets/{linked-devices-model-BzwIpwEe.js → linked-devices-model-BbPIMVq4.js} +1 -1
- package/dist/assets/{mf-entry-bootstrap-0-bdd51718.js → mf-entry-bootstrap-0-80086b95.js} +2 -2
- package/dist/assets/mount-BG-DzgSt.js +1 -0
- package/dist/assets/remoteEntry-BusdFyUc.js +1 -0
- package/dist/assets/{src-PRnJiArs.js → src-bJ4Hy4Cl.js} +2 -2
- package/dist/assets/{step-inspector-model-rUzV_fx8.js → step-inspector-model-15-9NhxK.js} +1 -1
- package/dist/assets/{use-scenes-feed-CbvzDtoS.js → use-scenes-feed-O_MsB8FF.js} +1 -1
- package/dist/assets/{use-stationary-objects-BQoGLS7G.js → use-stationary-objects-JZ23WYEp.js} +1 -1
- package/dist/assets/{useAdminDeviceRemoval-BIpZCMvj.js → useAdminDeviceRemoval-DCRpnpY6.js} +1 -1
- package/dist/assets/useEventInvalidation-BG-DzgSt.js +1 -0
- package/dist/assets/{useNodeUrlSelection-CLpo7d-J.js → useNodeUrlSelection-DAnBV8Yi.js} +1 -1
- package/dist/assets/{useTemplateSave-MOGGKDgw.js → useTemplateSave-C4_bd2To.js} +1 -1
- package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-DuSFc1uR.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-DguMkCB-.js} +2 -2
- package/dist/index.html +4 -4
- package/dist/server/addon.js +1 -1
- package/package.json +2 -2
- package/dist/assets/device-picker-model-DugCLTjl.js +0 -1
- package/dist/assets/mount-DugCLTjl.js +0 -1
- package/dist/assets/remoteEntry-CKvAmLfb.js +0 -1
- package/dist/assets/useEventInvalidation-DugCLTjl.js +0 -1
|
@@ -1 +1 @@
|
|
|
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{Fr as l,Ha as u,Li as d,Pa as f,Ua as p,Xt as m,Y as h,Zr as g,aa as _,ct as v,di as y,dt as b,en as x,vt as S,wi as C,wt as w,yi as T}from"./player-overlays-VrMHBBfa.js";import{Ac as E}from"./client-CBrsD14Q.js";import{t as D}from"./scissors-Bbq6WhOK.js";import{$d as O,Ai as k,Ar as A,Ba as j,Cp as M,Ep as N,Eu as P,Fi as F,Gd as ee,Gi as I,Jd as te,Kd as ne,Ni as re,Ns as L,Pi as ie,Qd as ae,Qf as R,Ra as z,Sp as oe,Su as se,Ud as B,Ul as ce,Vl as le,Wd as ue,Wf as V,Xd as de,Yd as fe,Yl as pe,Zd as me,_d as he,ef as ge,fd as _e,gd as ve,hd as ye,ji as be,jr as xe,ki as Se,md as Ce,pd as we,qd as Te,ql as Ee,ta as De,vd as Oe,yd as ke}from"./src-PRnJiArs.js";import{t as H}from"./i18n-BFxrpjSx.js";import{t as U}from"./useTranslation-BJr-n0es.js";import{E as Ae,b as je,li as Me}from"./index-DqWOkhIM.js";import{t as Ne}from"./AdminSectionedPage-aE2P4MNm.js";import{n as Pe}from"./authed-media-CdhEKUeH.js";import{t as W}from"./format-size-DIxKXxtj.js";import{n as Fe,r as Ie,t as Le}from"./StorageLocationsTable-4_DOpVA_.js";o();var Re=[{value:`all`,labelKey:`common.all`},{value:`recording`,labelKey:`recordings.activitySection.domainRecordings`},{value:`events`,labelKey:`common.events`}],ze={recording:`bg-primary/10 text-primary`,events:`bg-violet-500/10 text-violet-400`},Be={columnKey:`at`,dir:`desc`};function Ve(e){return new Date(e).toLocaleString()}function He(){let{t:n,i18n:i}=U(),[o,s]=a(`all`),{data:d,isLoading:f,isError:p}=Ce({},{refetchOnWindowFocus:!1}),{data:h,isLoading:g,isError:_}=Ee({},{refetchOnWindowFocus:!1}),{data:v}=L({isCamera:!0,projection:`slim`}),y=t(()=>{let e=new Map;for(let t of v??[])e.set(t.id,t.name);return e},[v]),b=t(()=>{let e=[...d??[],...h??[]];return(o===`all`?e:e.filter(e=>e.domain===o)).toSorted((e,t)=>t.at-e.at)},[d,h,o]),x=t(()=>{let e=[];return p&&o!==`events`&&e.push(n(`recordings.activitySection.domainRecordings`)),_&&o!==`recording`&&e.push(n(`common.events`)),e},[p,_,o,n]),S=t(()=>new Intl.ListFormat(i.language,{type:`conjunction`}).format(x),[x,i.language]),C=t(()=>[{key:`at`,header:n(`recordings.activitySection.when`,`When`),nowrap:!0,sortValue:e=>e.at,render:e=>r(`span`,{className:`text-foreground-subtle tabular-nums`,children:Ve(e.at)})},{key:`domain`,header:n(`recordings.activitySection.domain`,`Domain`),sortValue:e=>e.domain,render:e=>r(`span`,{className:`inline-flex rounded px-1.5 py-0.5 text-[10px] font-medium ${ze[e.domain]}`,children:e.domain})},{key:`op`,header:n(`recordings.activitySection.operation`,`Operation`),sortValue:e=>e.op,render:e=>r(`span`,{className:`text-foreground`,children:e.op})},{key:`reason`,header:n(`recordings.activitySection.reason`,`Reason`),sortValue:e=>e.reason,render:e=>r(`span`,{className:`text-foreground-subtle`,children:e.reason})},{key:`device`,header:n(`recordings.activitySection.camera`,`Camera`),sortValue:e=>e.deviceId===null?`cluster`:y.get(e.deviceId)??`#${String(e.deviceId)}`,render:e=>e.deviceId===null?r(`span`,{className:`text-foreground-subtle`,children:n(`common.cluster`)}):r(`span`,{className:`text-foreground`,children:y.get(e.deviceId)??`#${String(e.deviceId)}`})},{key:`items`,header:n(`recordings.activitySection.items`,`Items`),align:`right`,nowrap:!0,sortValue:e=>e.itemsAffected,render:e=>r(`span`,{className:`tabular-nums`,children:e.itemsAffected.toLocaleString()})},{key:`bytes`,header:n(`recordings.activitySection.reclaimed`,`Reclaimed`),align:`right`,nowrap:!0,sortValue:e=>e.bytesReclaimed,render:e=>r(`span`,{className:`tabular-nums`,children:e.bytesReclaimed>0?W(e.bytesReclaimed):`—`})}],[y,n]),w=f||g;return e(`div`,{className:`flex flex-col gap-4`,children:[r(`div`,{className:`flex items-center gap-1`,children:Re.map(e=>r(V,{variant:`unstyled`,onClick:()=>s(e.value),className:`rounded px-2 py-1 text-xs font-medium ${o===e.value?`bg-primary/10 text-primary`:`text-foreground-subtle hover:bg-muted`}`,children:n(e.labelKey)},e.value))}),w&&b.length===0?e(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[r(l,{className:`h-4 w-4 animate-spin`}),n(`recordings.activitySection.loadingActivity`,`Loading activity…`)]}):b.length===0?x.length>0?r(I,{icon:m,title:n(`recordings.activitySection.activityCouldNotBeRead`,`Activity could not be read`),description:n(`recordings.activitySection.theOpsLogDidNot`,`The {{value1}} ops log did not answer. This is not "nothing happened" — retry, or check the node that owns it.`,{value1:S})}):r(I,{icon:u,title:n(`recordings.activitySection.noActivityYet`,`No activity yet`),description:n(`recordings.activitySection.pruneDeleteAndRescanOperations`,`Prune, delete and rescan operations across recordings and events show up here.`)}):e(c,{children:[x.length>0&&e(`p`,{className:`flex items-center gap-1.5 text-[11px] text-amber-500`,children:[r(m,{className:`h-3 w-3 shrink-0`}),n(`recordings.activitySection.domainsMissing`,{count:x.length,names:S})]}),r(A,{columns:C,rows:b,rowKey:e=>e.id,minWidthPx:720,maxBodyHeight:xe,defaultSort:Be})]})]})}o();function Ue(){let{t:n}=U(),i=L({isCamera:!0,projection:`slim`}),o=t(()=>(i.data??[]).toSorted((e,t)=>e.name.localeCompare(t.name)),[i.data]),[s,c]=a(null),l=s??o[0]?.id??null;return!i.isLoading&&o.length===0?r(I,{icon:_,title:n(`recordings.cameraRecordingSettingsSection.noCameras`,`No cameras`),description:n(`recordings.cameraRecordingSettingsSection.addACameraFirst`,`Add a camera first.`)}):e(`div`,{className:`space-y-3`,children:[e(`div`,{children:[r(`h2`,{className:`text-sm font-semibold text-foreground`,children:n(`recordings.cameraRecordingSettingsSection.perCameraRecordingRetention`,`Per-camera recording & retention`)}),r(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:n(`recordings.cameraRecordingSettingsSection.recordingModeScheduleBandsAnd`,`Recording mode, schedule bands and the retention policy for one camera — the same controls as the camera's own Recording tab. Retention is one policy over footage and analytics; per-camera event deletion lives on the Events tab.`)})]}),e(`div`,{className:`flex items-center gap-2`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:n(`recordings.cameraRecordingSettingsSection.camera`,`Camera`)}),r(b,{wrapperClassName:`inline-block w-auto`,value:l??``,onChange:e=>c(Number(e.target.value)),children:o.map(e=>r(`option`,{value:e.id,children:e.name},e.id))})]}),l!==null&&r(De,{deviceId:l,children:r(Ae,{deviceId:l,sectionFilter:e=>e.location===`top-tab`&&e.tab===`recording`})},l)]})}function G({types:e}){return r(Le,{kinds:e})}o();var K=`pipeline-analytics`,q=`pipeline-analytics`;function We(e){for(let t of e?.sections??[])for(let e of t.fields??[])if(e.key===`postProcessingNodeId`&&typeof e.value==`string`)return e.value;return`hub`}function Ge(){let{t:n}=U(),i=s(),{nodes:a}=M(),{data:o,isLoading:c}=z({addonId:K,cap:q,scope:`cluster`}),u=We(o),d=j({onSuccess:()=>{i.invalidateQueries({queryKey:[[`addonSettings`,`getScopedSettings`]]})}}),f=t(()=>{let e=a.filter(e=>e.isOnline).map(e=>e.id);return[...new Set([`hub`,u,...e])].filter(Boolean)},[a,u]);return e(`div`,{className:`flex flex-col gap-6`,children:[e(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[r(`h3`,{className:`text-sm font-semibold text-foreground`,children:n(`pipeline.clusterEventsTab.postProcessingNode`,`Post-processing node`)}),r(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:n(`pipeline.clusterEventsTab.theSingleNodeThatRuns`,`The single node that runs detection post-processing (events, media, audio & motion). Every other node stays inert — no multi-node balancing. Takes effect on addon restart.`)}),e(`div`,{className:`mt-3 flex items-center gap-2`,children:[c?r(l,{className:`h-4 w-4 animate-spin text-foreground-subtle`}):r(b,{wrapperClassName:`inline-block w-auto`,value:u,onChange:e=>{e.target.value!==u&&d.mutate({addonId:K,cap:q,scope:`cluster`,patch:{postProcessingNodeId:e.target.value}})},disabled:d.isPending,children:f.map(e=>r(`option`,{value:e,children:e===`hub`?n(`pipeline.clusterEventsTab.hubDefault`,`hub (default)`):e},e))}),d.isPending&&r(l,{className:`h-4 w-4 animate-spin text-primary`})]})]}),e(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[r(`h3`,{className:`mb-1 text-sm font-semibold text-foreground`,children:n(`pipeline.clusterEventsTab.eventsFolder`,`Events folder`)}),r(`p`,{className:`mb-3 text-[11px] text-foreground-subtle`,children:n(`pipeline.clusterEventsTab.whereEventCropsFullFrames`,`Where event crops / full frames are stored. A single folder — no collection / equal-splitting.`)}),r(G,{types:[`eventMedia`]})]})]})}o();var Ke=[[`pipelineAnalytics`]],qe=1440*60*1e3;function Je(e,t){return t.get(e)??H.t(`recordings.eventsManagementSection.removedCamera`,{id:String(e)})}var Ye=[{days:1},{days:7},{days:30},{days:90}];function Xe(){let{t:i}=U(),o=s(),c=v(),[u,d]=a(30),[f,p]=a(null),{data:m,isLoading:g}=ce({},{refetchOnWindowFocus:!1}),{data:_}=L({isCamera:!0,projection:`slim`}),y=t(()=>{let e=new Map;for(let t of _??[])e.set(t.id,t.name);return e},[_]),S=n(()=>{o.invalidateQueries({queryKey:Ke})},[o]),w=pe({onSuccess:S}),T=le(),E=n(async()=>{await c({title:i(`recordings.eventsManagementSection.pruneTitle`,{count:u}),message:i(`recordings.eventsManagementSection.permanentlyDeletesEveryEventMotion`,`Permanently deletes every event (motion / object / audio) older than the cutoff across all cameras, and their media. This cannot be undone.`),confirmLabel:i(`recordings.eventsManagementSection.pruneEvents`,`Prune events`),variant:`danger`})&&w.mutate({olderThanMs:Date.now()-u*qe,reason:`retention`})},[c,w,u,i]),O=n(async e=>{let t=Je(e.deviceId,y);if(await c({title:i(`recordings.eventsManagementSection.deleteAllEventsFor`,`Delete all events for {{label}}?`,{label:t}),message:i(`recordings.eventsManagementSection.deleteRowsMessage`,{count:e.rows,size:W(e.bytes)}),confirmLabel:i(`recordings.eventsManagementSection.deleteEvents`,`Delete events`),variant:`danger`})){p(null);try{let n=await T.mutateAsync({deviceId:e.deviceId});S();let r=n.motion+n.object+n.audio;if(r===0&&e.bytes>0){p(`0 events deleted for ${t}. Media still listed (${W(e.bytes)}) — those blobs are not event rows; use Management → Count leftovers or Disk reconcile.`);return}p(`Deleted ${String(r)} event${r===1?``:`s`} for ${t}.`)}catch(e){p(e instanceof Error?e.message:String(e))}}},[c,T,y,S,i]),k=t(()=>[{key:`camera`,header:i(`recordings.eventsManagementSection.camera`,`Camera`),render:e=>r(`span`,{className:`text-foreground`,children:Je(e.deviceId,y)})},{key:`rows`,header:i(`recordings.eventsManagementSection.events`,`Events`),align:`right`,nowrap:!0,render:e=>r(`span`,{className:`tabular-nums`,children:e.rows.toLocaleString()})},{key:`bytes`,header:i(`recordings.eventsManagementSection.media`,`Media`),align:`right`,nowrap:!0,render:e=>r(`span`,{className:`tabular-nums`,children:W(e.bytes)})},{key:`actions`,header:``,align:`right`,render:t=>e(V,{variant:`unstyled`,onClick:()=>{O(t)},disabled:T.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10 disabled:opacity-50`,title:i(`recordings.eventsManagementSection.deleteAllEventsForThis`,`Delete all events for this camera`),children:[r(x,{className:`h-3 w-3`}),i(`common.delete`,`Delete`)]})}],[y,O,T.isPending,i]);return g&&!m?e(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[r(l,{className:`h-4 w-4 animate-spin`}),i(`recordings.eventsManagementSection.loadingEventStoreFootprint`,`Loading event-store footprint…`)]}):m?e(`div`,{className:`flex flex-col gap-6`,children:[e(`section`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2`,children:[r(h,{label:i(`recordings.eventsManagementSection.totalEvents`,`Total events`),icon:r(C,{className:`h-3 w-3`}),footer:`across ${String(m.devices.length)} camera${m.devices.length===1?``:`s`}`,children:m.totalRows.toLocaleString()}),r(h,{label:i(`recordings.eventsManagementSection.eventMediaOnDisk`,`Event media on disk`),children:W(m.totalBytes)})]}),e(`section`,{className:`flex flex-wrap items-center gap-2 text-xs`,children:[r(`span`,{className:`text-foreground-subtle`,children:i(`recordings.eventsManagementSection.pruneEventsOlderThan`,`Prune events older than`)}),r(b,{wrapperClassName:`inline-block w-auto`,value:u,onChange:e=>d(Number(e.target.value)),children:Ye.map(e=>r(`option`,{value:e.days,children:i(`recordings.eventsManagementSection.ageDays`,{count:e.days})},e.days))}),e(V,{variant:`unstyled`,onClick:()=>{E()},disabled:w.isPending,className:`inline-flex items-center gap-1 rounded border border-border px-2 py-1 text-xs font-medium text-foreground-subtle hover:bg-warning/10 hover:text-warning disabled:opacity-50`,children:[w.isPending?r(l,{className:`h-3 w-3 animate-spin`}):r(D,{className:`h-3 w-3`}),i(`recordings.eventsManagementSection.pruneNow`,`Prune now`)]})]}),m.devices.length===0?r(I,{icon:C,title:i(`recordings.eventsManagementSection.noStoredEvents`,`No stored events`),description:i(`recordings.eventsManagementSection.noCameraHasPersistedEvents`,`No camera has persisted events yet.`)}):r(A,{columns:k,rows:[...m.devices],rowKey:e=>e.deviceId,minWidthPx:480}),f===null?null:r(`p`,{className:f.startsWith(`Deleted `)?`text-[11px] text-foreground-subtle`:`text-[11px] text-destructive`,children:f})]}):r(I,{icon:C,title:i(`recordings.eventsManagementSection.noEventData`,`No event data`),description:i(`recordings.eventsManagementSection.pipelineAnalyticsHasNotReported`,`Pipeline analytics has not reported any event-store footprint yet.`)})}function Ze(){let{t}=U();return e(`div`,{className:`flex flex-col gap-8`,children:[e(`div`,{children:[r(`h2`,{className:`text-sm font-semibold text-foreground`,children:t(`recordings.eventsSection.eventStore`,`Event store`)}),r(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:t(`recordings.eventsSection.whatTheDurableEventStore`,`What the durable event store occupies, per camera, with fleet-wide prune-by-age and delete-all-events.`)}),r(`div`,{className:`mt-3`,children:r(Xe,{})})]}),e(`div`,{children:[r(`h2`,{className:`text-sm font-semibold text-foreground`,children:t(`recordings.eventsSection.postProcessingNodeFolders`,`Post-processing node & folders`)}),r(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:t(`recordings.eventsSection.theSingleNodeThatWrites`,`The single node that writes event crops, and the storage location they land in.`)}),r(`div`,{className:`mt-3`,children:r(Ge,{})})]})]})}function Qe(e){let t=[];return e.timelapse?t.push(`timelapse ${String(e.timelapse.everyMs/1e3)}s`):(t.push(`${String(e.speed??1)}×`),e.includeAudio&&t.push(`+ audio`)),t.join(` `)}function $e(e){return new Date(e).toLocaleString(void 0,{day:`2-digit`,month:`short`,hour:`2-digit`,minute:`2-digit`})}function et(e,t){let n=Math.max(0,Math.round((t-e)/1e3)),r=Math.floor(n/3600),i=Math.floor(n%3600/60),a=n%60,o=r>0?`${String(r)}:${String(i).padStart(2,`0`)}:${String(a).padStart(2,`0`)}`:`${String(i)}:${String(a).padStart(2,`0`)}`;return`${$e(e)} · ${o}`}function tt(e,t){let n=e-t;if(n<=0)return H.t(`helpers.exportFormat.expired`);let r=Math.floor(n/6e4);if(r<60)return H.t(`helpers.exportFormat.inMinutes`,{n:String(r)});let i=Math.floor(r/60);return i<24?H.t(`helpers.exportFormat.inHours`,{n:String(i)}):H.t(`helpers.exportFormat.inDays`,{n:String(Math.floor(i/24))})}function nt(e,t,n,r){return e.map(e=>{if(e.state===`expired`||e.state===`deleted`)return e;let i=r.get(e.id);if(i)return{...e,state:`failed`,error:i.error,progressPct:null};let a=n.get(e.id);if(a)return{...e,state:`ready`,fileBytes:a.fileBytes,progressPct:100};let o=t.get(e.id);return o&&(e.state===`queued`||e.state===`rendering`)?{...e,state:`rendering`,progressPct:o.progressPct}:e})}o();var rt=[`high`,`mid`,`low`],it=[{value:1,labelKey:`recordings.newExportModal.speedRealTime`},{value:2,labelKey:null},{value:4,labelKey:null},{value:8,labelKey:null},{value:16,labelKey:null}],at=10080*60*1e3;function ot(e){let t=new Date(Date.now()-e*6e4),n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}T${n(t.getHours())}:${n(t.getMinutes())}`}function st({onClose:n,onCreated:i}){let{t:o}=U(),s=L({isCamera:!0,projection:`slim`}),c=t(()=>(s.data??[]).toSorted((e,t)=>e.name.localeCompare(t.name)),[s.data]),[l,u]=a(``),[d,f]=a(`high`),[m,h]=a(ot(60)),[g,_]=a(ot(0)),[v,x]=a(1),[S,C]=a(!0),[w,T]=a(``),[E,D]=a(null),O=l===``?c[0]?.id??null:l,A=new Date(m).getTime(),j=new Date(g).getTime(),M=Number.isFinite(A)&&Number.isFinite(j)&&A<j,N=he({onSuccess:()=>{i(),n()},onError:e=>D(e instanceof Error?e.message:String(e))});return r(Se,{open:!0,onOpenChange:e=>!e&&n(),children:e(be,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[r(ie,{children:e(F,{className:`flex items-center gap-1.5`,children:[r(y,{className:`h-3.5 w-3.5`}),o(`recordings.newExportModal.newExport`,`New export`)]})}),e(k,{className:`space-y-3`,children:[e(`div`,{className:`grid grid-cols-2 gap-3`,children:[e(`div`,{className:`space-y-1`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:o(`recordings.newExportModal.camera`,`Camera`)}),r(b,{value:O??``,onChange:e=>u(Number(e.target.value)),className:`w-full`,children:c.map(e=>r(`option`,{value:e.id,children:e.name},e.id))})]}),e(`div`,{className:`space-y-1`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:o(`recordings.newExportModal.profile`,`Profile`)}),r(b,{value:d,onChange:e=>f(e.target.value),className:`w-full`,children:rt.map(e=>r(`option`,{value:e,children:e},e))})]})]}),e(`div`,{className:`grid grid-cols-2 gap-3`,children:[e(`div`,{className:`space-y-1`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:o(`recordings.newExportModal.from`,`From`)}),r(R,{type:`datetime-local`,value:m,onChange:e=>h(e.target.value),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground`})]}),e(`div`,{className:`space-y-1`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:o(`recordings.newExportModal.to`,`To`)}),r(R,{type:`datetime-local`,value:g,onChange:e=>_(e.target.value),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground`})]})]}),e(`div`,{className:`grid grid-cols-2 gap-3`,children:[e(`div`,{className:`space-y-1`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:o(`recordings.newExportModal.speed`,`Speed`)}),r(b,{value:v,onChange:e=>x(Number(e.target.value)),className:`w-full`,children:it.map(e=>r(`option`,{value:e.value,children:e.labelKey===null?`${e.value}×`:o(e.labelKey)},e.value))})]}),e(`div`,{className:`space-y-1`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:o(`recordings.newExportModal.titleOptional`,`Title (optional)`)}),r(R,{type:`text`,value:w,onChange:e=>T(e.target.value),placeholder:o(`recordings.newExportModal.eGCourierAtThe`,`e.g. courier at the gate`),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground placeholder:text-foreground-subtle`})]})]}),e(`label`,{className:`flex items-center gap-2 text-xs text-foreground cursor-pointer`,children:[r(p,{checked:S,disabled:v!==1,onChange:e=>C(e.target.checked),className:`accent-primary`}),o(v===1?`recordings.newExportModal.includeAudio`:`recordings.newExportModal.includeAudioRealtimeOnly`)]}),!M&&r(`p`,{className:`text-[11px] text-danger`,children:o(`recordings.newExportModal.fromMustBeBeforeTo`,`"From" must be before "To".`)}),E&&r(`p`,{className:`text-[11px] text-danger`,children:E})]}),e(re,{children:[r(V,{variant:`outline`,size:`sm`,onClick:n,children:o(`common.cancel`,`Cancel`)}),r(V,{size:`sm`,onClick:()=>{if(O===null||!M)return;D(null);let e=w.trim();N.mutate({deviceId:O,profile:d,fromMs:A,toMs:j,options:{includeAudio:S,maxLifeMs:at,deleteAfterDownload:!1,...v===1?{}:{speed:v},...e.length>0?{title:e}:{}}})},disabled:O===null||!M||N.isPending,children:N.isPending?o(`recordings.newExportModal.queuing`,`Queuing…`):o(`recordings.newExportModal.createExport`,`Create export`)})]})]})})}o();var ct=[[`recordingExport`]],lt={queued:{cls:`bg-muted text-foreground-subtle`,labelKey:`recordings.exportsSection.queued`},rendering:{cls:`bg-primary/10 text-primary`,labelKey:`recordings.exportsSection.rendering`,spin:!0},ready:{cls:`bg-success/10 text-success`,labelKey:`recordings.exportsSection.ready`},failed:{cls:`bg-danger/10 text-danger`,labelKey:`recordings.exportsSection.failed`},expired:{cls:`bg-muted text-foreground-subtle`,labelKey:`recordings.exportsSection.expired`},deleted:{cls:`bg-muted text-foreground-subtle`,labelKey:`recordings.exportsSection.deleted`}};function ut(){let{data:e,isLoading:n}=ke({},{refetchOnWindowFocus:!1,refetchInterval:e=>(e.state.data??[]).some(e=>e.state===`queued`||e.state===`rendering`)?3e3:!1}),{map:r}=N(E.RecordingExportProgress,e=>e.exportId),{map:i}=N(E.RecordingExportCompleted,e=>e.exportId),{map:a}=N(E.RecordingExportFailed,e=>e.exportId);return{rows:t(()=>nt(e??[],r,i,a),[e,r,i,a]),isLoading:n}}function dt(e){let[t,n]=a(()=>Date.now());return i(()=>{let t=setInterval(()=>n(Date.now()),e);return()=>clearInterval(t)},[e]),t}function ft(){let{t:i}=U(),o=s(),[c,u]=a(!1),f=()=>{o.invalidateQueries({queryKey:[[`recordingExport`,`listExports`]]})},p=v(),m=S().trpcClient,h=dt(6e4),{rows:g,isLoading:_}=ut(),{data:b}=L({isCamera:!0,projection:`slim`}),C=t(()=>{let e=new Map;for(let t of b??[])e.set(t.id,t.name);return e},[b]),w=n(()=>{o.invalidateQueries({queryKey:ct})},[o]),E=ve({onSuccess:w}),D=Oe({onSuccess:w}),[O,k]=a(null),j=n(async e=>{k(e.id);try{let{url:t}=await m.recordingExport.getDownloadUrl.query({exportId:e.id}),n=await Pe(t),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`${e.options.title??e.id}.mp4`,document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(r),w()}finally{k(null)}},[m,w]),M=n(async e=>{await p({title:i(`recordings.exportsSection.cancelThisExport`,`Cancel this export?`),message:i(`recordings.exportsSection.stopsTheRenderThePartial`,`Stops the render. The partial file is discarded.`),confirmLabel:i(`recordings.exportsSection.cancelExport`,`Cancel export`),variant:`danger`})&&E.mutate({exportId:e.id})},[p,E,i]),N=n(async e=>{await p({title:i(`recordings.exportsSection.deleteThisExport`,`Delete this export?`),message:i(`recordings.exportsSection.permanentlyRemovesTheRenderedFile`,`Permanently removes the rendered file and its history row.`),confirmLabel:i(`common.delete`,`Delete`),variant:`danger`})&&D.mutate({exportId:e.id})},[p,D,i]),P=t(()=>[{key:`camera`,header:i(`recordings.exportsSection.camera`,`Camera`),render:e=>r(`span`,{className:`text-foreground`,children:C.get(e.deviceId)??`#${String(e.deviceId)}`})},{key:`range`,header:i(`recordings.exportsSection.range`,`Range`),nowrap:!0,render:e=>r(`span`,{className:`tabular-nums`,children:et(e.fromMs,e.toMs)})},{key:`variant`,header:i(`recordings.exportsSection.variant`,`Variant`),render:e=>r(`span`,{className:`text-foreground-subtle`,children:Qe(e.options)})},{key:`state`,header:i(`recordings.exportsSection.state`,`State`),render:t=>{let n=lt[t.state];return e(`span`,{className:`inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] font-medium ${n.cls}`,children:[n.spin&&r(l,{className:`h-2.5 w-2.5 animate-spin`}),i(n.labelKey),t.state===`rendering`&&t.progressPct!==null&&e(`span`,{className:`tabular-nums`,children:[t.progressPct,`%`]})]})}},{key:`expiry`,header:i(`recordings.exportsSection.expires`,`Expires`),nowrap:!0,render:e=>e.state===`deleted`?r(`span`,{className:`text-foreground-subtle`,children:`—`}):r(`span`,{className:`text-foreground-subtle tabular-nums`,children:tt(e.expiresAt,h)})},{key:`size`,header:i(`recordings.exportsSection.size`,`Size`),align:`right`,nowrap:!0,render:e=>r(`span`,{className:`tabular-nums`,children:e.fileBytes===null?`—`:W(e.fileBytes)})},{key:`actions`,header:``,align:`right`,render:t=>{let n=t.state===`ready`,a=t.state===`queued`||t.state===`rendering`,o=t.state!==`deleted`;return e(`div`,{className:`flex items-center justify-end gap-1`,children:[n&&e(V,{variant:`unstyled`,onClick:()=>{j(t)},disabled:O===t.id,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-foreground-subtle hover:bg-primary/10 hover:text-foreground disabled:opacity-50`,title:i(`recordings.exportsSection.downloadMp4`,`Download MP4`),children:[O===t.id?r(l,{className:`h-3 w-3 animate-spin`}):r(T,{className:`h-3 w-3`}),i(`recordings.exportsSection.download`,`Download`)]}),a&&e(V,{variant:`unstyled`,onClick:()=>{M(t)},disabled:E.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-foreground-subtle hover:bg-amber-500/10 hover:text-amber-500 disabled:opacity-50`,title:i(`recordings.exportsSection.cancelRender`,`Cancel render`),children:[r(d,{className:`h-3 w-3`}),i(`common.cancel`,`Cancel`)]}),o&&r(V,{variant:`unstyled`,onClick:()=>{N(t)},disabled:D.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10 disabled:opacity-50`,title:i(`recordings.exportsSection.deleteExport`,`Delete export`),children:r(x,{className:`h-3 w-3`})})]})}}],[C,h,O,E.isPending,D.isPending,j,M,N,i]);return _&&g.length===0?e(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[r(l,{className:`h-4 w-4 animate-spin`}),i(`recordings.exportsSection.loadingExports`,`Loading exports…`)]}):e(`div`,{className:`space-y-3`,children:[r(`div`,{className:`flex justify-end`,children:e(V,{variant:`unstyled`,onClick:()=>u(!0),className:`inline-flex items-center gap-1.5 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground`,children:[r(y,{className:`h-3.5 w-3.5`}),i(`recordings.exportsSection.newExport`,`New export`)]})}),g.length===0?r(I,{icon:y,title:i(`recordings.exportsSection.noExportsYet`,`No exports yet`),description:i(`recordings.exportsSection.createOneHereNewExport`,`Create one here (New export) or from a camera's timeline in the viewer. Rendered clips show up here to download or manage.`)}):r(A,{columns:P,rows:g,rowKey:e=>e.id,minWidthPx:720}),c&&r(st,{onClose:()=>u(!1),onCreated:f})]})}var pt=`inline-flex w-fit items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-[11px] font-medium border border-border text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50`;o();var mt=`storage-migration`,ht=new Set([`orphans`,`debug-media`,`ghost-ledger`]);function gt(e){return[`${e.orphansReclaimed} orphan rows (${W(e.orphanBytesReclaimed)})`,e.includeDebugMedia?`${e.debugMediaReclaimed} debug files (${W(e.debugMediaBytesReclaimed)})`:null,`${e.ghostsForgotten} ghost rows (${W(e.ghostBytesForgotten)})`].filter(e=>e!==null).join(` · `)}function _t(){let{t:e}=U(),t=oe(mt);return t===`pending`?null:t===`unknown`?r(`p`,{className:`py-2 text-xs text-foreground-subtle`,children:e(`recordings.cleanupSection.couldNotCheckWhetherStorage`,`Could not check whether storage cleanup is installed on this hub.`)}):t===`present`?r(vt,{}):null}function vt(){let{t}=U(),n=v(),[i,o]=a(!1),[s,c]=a(null),u=Te({},{refetchInterval:2e3}),d=u.data??null,f=d!==null&&ht.has(d.phase),m=ne(),h=ee(),g=async()=>{if(await n({title:t(`recordings.cleanupSection.runStorageCleanup`,`Run storage cleanup?`),message:i?t(`recordings.cleanupSection.reclaimsLeftoverAnalyticsRowsAnd`,`Reclaims leftover analytics rows and files, debug stills/filmstrips, and ghost footage rows on frozen locations. Safe to re-run.`):t(`recordings.cleanupSection.reclaimsLeftoverAnalyticsRowsAnd2`,`Reclaims leftover analytics rows and files, and ghost footage rows on frozen locations. Debug stills are left alone. Safe to re-run.`),confirmLabel:t(`recordings.cleanupSection.runCleanup`,`Run cleanup`),variant:`danger`})){c(null);try{await m.mutateAsync({includeDebugMedia:i}),await u.refetch()}catch(e){c(e instanceof Error?e.message:String(e))}}},_=async()=>{if(d&&await n({title:t(`recordings.cleanupSection.cancelCleanup`,`Cancel cleanup?`),message:t(`recordings.cleanupSection.stopsAfterTheCurrentStep`,`Stops after the current step. Work already done stays done.`),confirmLabel:t(`recordings.cleanupSection.cancelCleanup2`,`Cancel cleanup`),variant:`danger`}))try{await h.mutateAsync({jobId:d.jobId}),await u.refetch()}catch{}};return e(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[r(`h2`,{className:`text-sm font-semibold text-foreground`,children:t(`recordings.cleanupSection.cleanup`,`Cleanup`)}),r(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:t(`recordings.cleanupSection.onePassOverLeftoverAnalytics`,`One pass over leftover analytics (database + files) and ghost footage rows on frozen locations. Does not time out — progress updates here until it finishes.`)}),e(`label`,{className:`mt-3 flex items-start gap-2 text-[11px] text-foreground`,children:[r(p,{checked:i,disabled:f,onChange:e=>{o(e.target.checked)},className:`mt-0.5 h-3.5 w-3.5 accent-primary`}),r(`span`,{children:t(`recordings.cleanupSection.alsoRemoveDebugMediaMotion`,`Also remove debug media (motion stills and track filmstrips)`)})]}),e(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[e(V,{variant:`unstyled`,type:`button`,disabled:f||m.isPending,onClick:()=>{g()},className:pt,children:[(f||m.isPending)&&r(l,{className:`h-3 w-3 animate-spin`}),r(x,{className:`h-3 w-3`}),t(`recordings.cleanupSection.runCleanup`,`Run cleanup`)]}),f&&r(V,{variant:`unstyled`,type:`button`,onClick:()=>{_()},className:`inline-flex items-center gap-1 rounded border border-border px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10`,children:t(`common.cancel`,`Cancel`)})]}),s&&r(`p`,{className:`mt-2 text-[11px] text-danger`,children:s}),d&&e(`div`,{className:`mt-3 space-y-1 rounded-md border border-border px-2.5 py-2`,children:[e(`p`,{className:`text-xs text-foreground`,children:[t(`recordings.cleanupSection.phase`,`Phase:`),` `,r(`span`,{className:`font-medium`,children:d.phase}),f&&r(l,{className:`ml-2 inline h-3 w-3 animate-spin text-primary`})]}),d.detail&&r(`p`,{className:`text-[11px] text-foreground-subtle`,children:d.detail}),r(`p`,{className:`text-[11px] text-foreground-subtle`,children:gt(d)}),d.error&&r(`p`,{className:`text-[11px] text-danger`,children:d.error})]})]})}o();var yt=2e3;function bt(){let{t}=U(),n=v(),a=s(),o=P(),c=se(void 0,{refetchInterval:e=>e.state.data?.state===`running`?yt:!1}),u=c.data,d=u?.state===`running`,f=d||o.isPending;i(()=>{u?.state!==`done`||u.finishedAtMs===null||(a.invalidateQueries({queryKey:[[`recording`]]}),a.invalidateQueries({queryKey:[[`pipelineAnalytics`]]}))},[u?.state,u?.finishedAtMs,a]);let p=async()=>{await n({title:t(`recordings.diskReconcileSection.reconcileStorageFromDisk`,`Reconcile storage from disk?`),message:t(`recordings.diskReconcileSection.makesTheDatabaseMatchThe`,`Makes the database match the filesystem: recordings index, tracks, events and media whose files are gone. Favourited tracks without files are deleted. Snapshot-less motion/audio events are deleted. Enrolled identities stay. This cannot be undone.`),confirmLabel:t(`recordings.diskReconcileSection.reconcile`,`Reconcile`),variant:`warning`})&&(await o.mutateAsync(),await c.refetch())},m=d?u.total>0?`Reconciling ${String(u.completed)}/${String(u.total)}…`:`Reconciling…`:o.isPending?`Reconciling…`:`Reconcile from disk`;return e(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[r(`h3`,{className:`text-sm font-semibold text-foreground`,children:t(`recordings.diskReconcileSection.diskReconcile`,`Disk reconcile`)}),r(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:t(`recordings.diskReconcileSection.deletesDatabaseRowsWhoseFiles`,`Deletes database rows whose files are gone. Enrolled identities stay.`)}),e(`div`,{className:`mt-3 flex flex-col gap-2`,children:[e(V,{variant:`unstyled`,type:`button`,onClick:()=>void p(),disabled:f,className:`inline-flex w-fit items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-[11px] font-medium border border-border text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50`,children:[f?r(l,{className:`h-3.5 w-3.5 animate-spin`}):r(g,{className:`h-3.5 w-3.5`}),m]}),u?.state===`done`?e(`p`,{className:`text-[11px] text-foreground-subtle`,children:[t(`recordings.diskReconcileSection.lastRun`,`Last run:`),` `,t(`recordings.diskReconcileSection.summary`,{completed:String(u.completed),tracks:String(u.tracks),events:String(u.events),media:String(u.mediaDropped)}),u.failed.length>0?t(`recordings.diskReconcileSection.failed`,`, {{value1}} failed ({{value2}})`,{value1:String(u.failed.length),value2:u.failed.join(`, `)}):``,`.`]}):null,u?.state===`error`&&u.error!==null?e(`p`,{className:`text-[11px] text-destructive`,children:[t(`recordings.diskReconcileSection.reconcileFailed`,`Reconcile failed:`),` `,u.error]}):null]})]})}var J=1e3,Y=60*J,X=60*Y;function Z(e){return e.toLocaleString(`en-US`)}function xt(e){if(!Number.isFinite(e)||e<0)return`—`;if(e>=X){let t=Math.floor(e/X),n=Math.round(e%X/Y);return`${t.toString()}h ${n.toString()}m`}if(e>=Y){let t=Math.floor(e/Y),n=Math.round(e%Y/J);return`${t.toString()}m ${n.toString()}s`}return`${Math.max(0,Math.round(e/J)).toString()}s`}function St(e){let t=Math.max(0,e.observedAt-e.startedAt),n=e.filesTotal===null?`${Z(e.filesMoved)} files`:`${Z(e.filesMoved)} / ${Z(e.filesTotal)} files`,r=e.filesTotal===null||e.filesTotal===0?null:Math.min(1,e.filesMoved/e.filesTotal),i=t>0&&e.filesMoved>0,a=i?`${W(e.bytesMoved/t*J)}/s`:null,o=e.filesTotal===null?null:e.filesTotal-e.filesMoved,s=!i||o===null||o<=0?null:`~${xt(o*t/e.filesMoved)} left`;return{counted:n,fraction:r,moved:`${W(e.bytesMoved)} moved`,rate:a,eta:s}}function Ct(e){let t=St(e);return[t.counted,t.moved,t.rate,t.eta].filter(e=>e!==null).join(` · `)}o();var wt=`storage-migration`,Q=[{id:`recordings`,labelKey:`recordings.storageMigrationSection.classRecordings`,locationType:`recordings`},{id:`recordingsLow`,labelKey:`recordings.storageMigrationSection.classRecordingsLow`,locationType:`recordingsLow`},{id:`eventMedia`,labelKey:`recordings.storageMigrationSection.classEventMedia`,locationType:`eventMedia`}],Tt=new Set([`planning`,`sealing`,`pausing`,`moving`,`draining`,`verifying`,`repointing`,`refreshing`,`resuming`]);function Et(){let{t}=U(),n=oe(wt);return n===`pending`?e(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[r(l,{className:`h-4 w-4 animate-spin`}),t(`migration.storageMigrationSection.checkingWhetherStorageMigrationIs`,`Checking whether storage migration is installed…`)]}):n===`unknown`?r(I,{icon:m,title:t(`migration.storageMigrationSection.couldnTCheckWhetherStorage`,`Couldn't check whether storage migration is installed`),description:t(`migration.storageMigrationSection.theCapabilityRegistryDidNot`,`The capability registry did not answer, so this panel has nothing to report either way — it is not a statement that the capability is missing. Reload to ask again.`)}):n===`absent`?r(I,{icon:f,title:t(`migration.storageMigrationSection.storageMigrationNotInstalled`,`Storage migration not installed`),description:t(`migration.storageMigrationSection.theCapabilityRegistryAnsweredNo`,`The capability registry answered: no addon in this cluster provides storage-migration. Once one is deployed, this panel moves recordings, low-res recordings and event media to new storage locations in one coordinated, verified operation.`)}):r(Dt,{})}function Dt(){let{t:n}=U(),i=v(),{data:o}=B({}),[s,c]=a({}),[u,d]=a({}),[p,m]=a(null),[h,g]=a(null),_=t(()=>{let e=new Map;for(let t of o??[]){let n=e.get(t.type);n?n.push(t):e.set(t.type,[t])}return e},[o]),y=t(()=>{let e=new Map;for(let t of o??[]){if(t.enabled===!1)continue;let n=e.get(t.type);n?n.push(t.id):e.set(t.type,[t.id])}let t=new Map;for(let[n,r]of e)r.length===1&&t.set(n,r[0]);return t},[o]),x=ge({},{refetchInterval:2e3}),S=x.data??null,C=S!==null&&Tt.has(S.phase),T=t(()=>{let e={};for(let t of Q){let n=s[t.id];n&&(e[t.id]=n)}return Object.keys(e).length>0?e:void 0},[s]),E=t(()=>{let e={};for(let t of Q){if(!s[t.id])continue;let n=u[t.id]??y.get(t.locationType);n&&(e[t.id]=n)}return Object.keys(e).length>0?e:void 0},[s,u,y]),D=t(()=>({destinations:T??{},...E?{sources:E}:{}}),[T,E]),k=me(D,{enabled:!1,retry:!1}),A=O(),j=ue(),M=async()=>{if(!T)return;g(null);let e=await k.refetch();if(e.error){g(e.error instanceof Error?e.error.message:String(e.error));return}m(e.data??null)},N=async()=>{if(T&&await i({title:n(`migration.storageMigrationSection.startStorageMigration`,`Start storage migration?`),message:n(`migration.storageMigrationSection.copiesTheSelectedClassesFrom`,`Copies the selected classes from the chosen source to the destination, verifies, then either makes the destination the default (if the source was) or disables the source. Safe to re-run if interrupted.`),confirmLabel:n(`migration.storageMigrationSection.startMigration`,`Start migration`),variant:`danger`})){g(null);try{await A.mutateAsync(D),m(null),await x.refetch()}catch(e){g(e instanceof Error?e.message:String(e))}}},P=async()=>{if(S&&await i({title:n(`migration.storageMigrationSection.cancelMigration`,`Cancel migration?`),message:n(`migration.storageMigrationSection.stopsTheInProgressMigration`,`Stops the in-progress migration. Data already moved and verified stays at the destination; anything already repointed is not reverted.`),confirmLabel:n(`migration.storageMigrationSection.cancelMigration2`,`Cancel migration`),variant:`danger`}))try{await j.mutateAsync({jobId:S.jobId}),await x.refetch()}catch{}};return e(`div`,{className:`flex flex-col gap-6`,children:[e(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[e(`h3`,{className:`flex items-center gap-1.5 text-sm font-semibold text-foreground`,children:[r(f,{className:`h-3.5 w-3.5`}),n(`migration.storageMigrationSection.storageMigration`,`Storage migration`)]}),r(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:n(`migration.storageMigrationSection.moveRecordingsLowResRecordings`,`Move recordings, low-res recordings and/or event media from one location to another: copies via the recorder / pipeline-analytics movers, verifies, then either repoints the default (when the source was the default) or disables the source (when it was not). Skip a class with an empty destination.`)}),r(`div`,{className:`mt-3 grid grid-cols-1 gap-3 sm:grid-cols-3`,children:Q.map(t=>{let i=_.get(t.locationType)??[],a=y.get(t.locationType)??``;return e(`div`,{className:`space-y-2`,children:[r(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:n(t.labelKey)}),e(`div`,{className:`space-y-1`,children:[r(`label`,{htmlFor:`migration-from-${t.id}`,className:`text-[10px] text-foreground-subtle`,children:n(`recordings.storageMigrationSection.classFrom`,{label:n(t.labelKey)})}),r(b,{id:`migration-from-${t.id}`,value:u[t.id]??a,onChange:e=>{let n=e.target.value;d(e=>({...e,[t.id]:n}))},disabled:C,className:`w-full`,children:i.map(t=>e(`option`,{value:t.id,children:[t.displayName,t.enabled===!1?` (${n(`recordings.storageMigrationSection.readOnly`)})`:``]},t.id))})]}),e(`div`,{className:`space-y-1`,children:[r(`label`,{htmlFor:`migration-dest-${t.id}`,className:`text-[10px] text-foreground-subtle`,children:n(`recordings.storageMigrationSection.classTo`,{label:n(t.labelKey)})}),e(b,{id:`migration-dest-${t.id}`,value:s[t.id]??``,onChange:e=>{let n=e.target.value;c(e=>({...e,[t.id]:n}))},disabled:C,className:`w-full`,children:[r(`option`,{value:``,children:n(`migration.storageMigrationSection.skip`,`— skip —`)}),i.map(e=>r(`option`,{value:e.id,children:e.displayName},e.id))]})]})]},t.id)})}),h&&r(`p`,{className:`mt-2 text-[11px] text-danger`,children:h}),e(`div`,{className:`mt-3 flex items-center gap-2`,children:[e(V,{variant:`unstyled`,type:`button`,onClick:()=>{M()},disabled:!T||k.isFetching||C,className:`inline-flex items-center gap-1.5 rounded border border-border px-2.5 py-1.5 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover disabled:opacity-50`,children:[k.isFetching&&r(l,{className:`h-3 w-3 animate-spin`}),n(`migration.storageMigrationSection.plan`,`Plan`)]}),e(V,{variant:`unstyled`,type:`button`,onClick:()=>{N()},disabled:!T||A.isPending||C,className:`inline-flex items-center gap-1.5 rounded bg-primary px-2.5 py-1.5 text-xs font-medium text-primary-foreground disabled:opacity-50`,children:[A.isPending&&r(l,{className:`h-3 w-3 animate-spin`}),n(`migration.storageMigrationSection.startMigration`,`Start migration`)]})]}),p&&r(`div`,{className:`mt-3 divide-y divide-border rounded-md border border-border`,children:p.moves.length===0?r(`p`,{className:`px-2.5 py-1.5 text-[11px] text-foreground-subtle`,children:n(`migration.storageMigrationSection.nothingToMoveSelectedDestinations`,`Nothing to move — selected destinations match the current defaults.`)}):p.moves.map(t=>e(`div`,{className:`px-2.5 py-1.5 text-[11px] text-foreground`,children:[t.storageClass,`: `,t.fromLocationId,` → `,t.toLocationId]},`${t.storageClass}-${t.toLocationId}`))}),S&&e(`div`,{className:`mt-4 border-t border-border pt-3`,children:[e(`div`,{className:`flex items-center justify-between`,children:[r(`h4`,{className:`text-xs font-semibold text-foreground`,children:n(`migration.storageMigrationSection.migrationStatus`,`Migration status`)}),C&&e(V,{variant:`unstyled`,type:`button`,onClick:()=>{P()},className:`inline-flex items-center gap-1 rounded border border-border px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10`,children:[r(w,{className:`h-3 w-3`}),n(`common.cancel`,`Cancel`)]})]}),e(`p`,{className:`mt-1 text-xs text-foreground`,children:[n(`migration.storageMigrationSection.phase`,`Phase:`),` `,r(`span`,{className:`font-medium`,children:S.phase}),C&&r(l,{className:`ml-2 inline h-3 w-3 animate-spin text-primary`})]}),S.error&&r(`p`,{className:`mt-1 text-[11px] text-danger`,children:S.error}),S.pausedParticipants.length>0&&e(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:[n(`migration.storageMigrationSection.paused`,`Paused:`),` `,S.pausedParticipants.join(`, `)]}),r(`div`,{className:`mt-2 divide-y divide-border rounded-md border border-border`,children:S.moves.map(e=>r(Ot,{move:e},`${e.storageClass}-${e.fromLocationId}`))})]}),r(kt,{})]}),r(At,{running:C}),r(Mt,{})]})}function Ot({move:t}){let{t:n}=U(),i=t.progress===null?null:St(t.progress);return e(`div`,{className:`px-2.5 py-1.5 text-[11px]`,children:[e(`div`,{className:`flex items-center justify-between`,children:[e(`span`,{className:`text-foreground`,children:[t.storageClass,`: `,t.fromLocationId,` → `,t.toLocationId]}),e(`span`,{className:`text-foreground-subtle`,children:[t.state??n(`common.pending`),t.error?` (${t.error})`:``]})]}),t.progress!==null&&e(`div`,{className:`mt-1 space-y-1`,children:[i!==null&&i.fraction!==null&&r(`div`,{className:`h-1 w-full overflow-hidden rounded bg-border`,children:r(`div`,{className:`h-full bg-primary`,style:{width:`${(i.fraction*100).toFixed(1)}%`}})}),r(`p`,{className:`text-[10px] text-foreground-subtle`,children:Ct(t.progress)})]})]})}function kt(){let{t}=U(),{data:n}=fe({});return!n||n.length===0?null:e(`div`,{className:`mt-4 border-t border-border pt-3`,children:[r(`h4`,{className:`text-xs font-semibold text-foreground`,children:t(`migration.storageMigrationSection.migrationHistory`,`Migration history`)}),r(`div`,{className:`mt-2 divide-y divide-border rounded-md border border-border`,children:n.map(t=>e(`div`,{className:`px-2.5 py-1.5 text-[11px] text-foreground-subtle`,children:[r(`span`,{className:`font-medium text-foreground`,children:t.phase}),` · `,Object.entries(t.destinations).filter(e=>typeof e[1]==`string`).map(([e,t])=>`${e} → ${t}`).join(`, `),` · `,new Date(t.startedAt).toLocaleString()]},t.jobId))})]})}function At({running:t}){let{t:n}=U(),i=v(),o=ae({},{staleTime:1/0,refetchOnWindowFocus:!1}),s=te(),[c,l]=a(null),u=o.data??[];if(u.length===0)return null;let d=async e=>{if(await i({title:n(`migration.storageMigrationSection.drainRemaining`,`Drain remaining {{storageClass}}?`,{storageClass:e.storageClass}),message:`Moves what is still on ${e.fromLocationId} to ${e.toLocationId}. Nothing is paused and no default is changed — this is the second half of a migration, run on its own. It is resumable: cancelling leaves everything readable from both locations.`,confirmLabel:n(`migration.storageMigrationSection.drainRemaining2`,`Drain remaining`),variant:`danger`})){l(null);try{await s.mutateAsync({classes:[e.storageClass]}),await o.refetch()}catch(e){l(e instanceof Error?e.message:String(e))}}};return e(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[e(`div`,{className:`flex items-start justify-between gap-2`,children:[r(`h3`,{className:`text-sm font-semibold text-foreground`,children:n(`migration.storageMigrationSection.leftOnTheOldLocation`,`Left on the old location`)}),e(`div`,{className:`flex shrink-0 items-center gap-2`,children:[r(`span`,{className:`text-[10px] text-foreground-subtle`,children:o.dataUpdatedAt>0?n(`migration.storageMigrationSection.measured`,`Measured {{value1}}`,{value1:new Date(o.dataUpdatedAt).toLocaleTimeString()}):n(`migration.storageMigrationSection.measuredNever`,`Measured — never`)}),r(V,{variant:`unstyled`,type:`button`,onClick:()=>{o.refetch()},disabled:o.isFetching,className:`rounded border border-border px-2 py-1 text-[10px] font-medium text-foreground-subtle hover:bg-surface-hover hover:text-foreground disabled:opacity-50`,children:o.isFetching?n(`migration.storageMigrationSection.counting`,`Counting…`):n(`common.refresh`,`Refresh`)})]})]}),r(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:n(`migration.storageMigrationSection.aMigrationRepointsFirstAnd`,`A migration repoints first and drains behind. If the drain was cancelled, failed, or was interrupted by a restart, the data below is still on the source — readable, but not where the defaults now point. Draining moves it; it changes no default and pauses nothing.`)}),r(`p`,{className:`mt-1 text-[10px] text-foreground-subtle`,children:n(`migration.storageMigrationSection.thisCountIsTakenOn`,`This count is taken on demand: measuring it walks the whole media collection, so it is not refreshed on a timer. Press Refresh after a drain finishes.`)}),c&&r(`p`,{className:`mt-2 text-[11px] text-danger`,children:c}),r(`div`,{className:`mt-2 divide-y divide-border rounded-md border border-border`,children:u.map(i=>e(`div`,{className:`flex items-center justify-between gap-2 px-2.5 py-1.5 text-[11px]`,children:[e(`span`,{className:`text-foreground`,children:[i.storageClass,`: `,i.fromLocationId,` → `,i.toLocationId,r(`span`,{className:`ml-2 text-foreground-subtle`,children:jt(i)})]}),r(V,{variant:`unstyled`,type:`button`,onClick:()=>{d(i)},disabled:t||s.isPending,className:`shrink-0 rounded border border-border px-2 py-1 text-[10px] font-medium text-foreground-subtle hover:bg-surface-hover hover:text-foreground disabled:opacity-50`,children:n(`migration.storageMigrationSection.drainRemaining2`,`Drain remaining`)})]},`${i.storageClass}-${i.fromLocationId}`))})]})}function jt(e){if(e.items===null)return H.t(`recordings.storageMigrationSection.residueUnknown`);let t=e.items.toLocaleString(`en-US`);return e.bytes===null?H.t(`recordings.storageMigrationSection.residueRows`,{count:e.items,items:t}):H.t(`recordings.storageMigrationSection.residueSegments`,{count:e.items,items:t,size:W(e.bytes)})}function Mt(){let{t}=U(),{data:n}=de({},{refetchInterval:2e3}),i=(n??[]).filter(e=>e.migrationJobId===null&&e.job.state===`running`);return i.length===0?null:e(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[r(`h3`,{className:`text-sm font-semibold text-foreground`,children:t(`migration.storageMigrationSection.moversRunningOutsideAMigration`,`Movers running outside a migration`)}),r(`div`,{className:`mt-2 divide-y divide-border rounded-md border border-border`,children:i.map(t=>e(`div`,{className:`px-2.5 py-1.5 text-[11px]`,children:[e(`div`,{className:`text-foreground`,children:[t.lane,`: `,t.job.fromLocationId,` → `,t.job.toLocationId]}),r(`p`,{className:`mt-1 text-[10px] text-foreground-subtle`,children:Ct({filesMoved:t.job.filesMoved,filesTotal:t.job.filesTotal,bytesMoved:t.job.bytesMoved,startedAt:t.job.startedAt,observedAt:t.observedAt})})]},t.job.jobId))})]})}function Nt(){let{t}=U();return e(`div`,{className:`flex flex-col gap-4`,children:[r(_t,{}),r(bt,{}),e(`section`,{children:[r(`h2`,{className:`text-sm font-semibold text-foreground`,children:t(`recordings.recordingsManagementSection.moveStorage`,`Move storage`)}),r(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:t(`recordings.recordingsManagementSection.copyRecordingsLowResRecordings`,`Copy recordings, low-res recordings or event media to a new location, verify, then repoint the default. Applies to every camera.`)}),r(`div`,{className:`mt-3`,children:r(Et,{})})]})]})}o();var Pt=`recorder`,Ft=`recording`;function It(e,t,n){for(let n of e?.sections??[])for(let e of n.fields??[])if(e.key===t&&typeof e.value==`string`)return e.value;return n}function Lt(){let{t:n}=U(),i=s(),{nodes:a}=M(),{data:o,isLoading:c}=z({addonId:Pt,cap:Ft,scope:`cluster`}),u=It(o,`recordingNodeId`,`hub`),d=j({onSuccess:()=>{i.invalidateQueries({queryKey:[[`addonSettings`,`getScopedSettings`]]})}}),f=t(()=>{let e=a.filter(e=>e.isOnline).map(e=>e.id);return[...new Set([`hub`,u,...e])].filter(Boolean)},[a,u]);return e(`div`,{className:`flex flex-col gap-6`,children:[e(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[r(`h3`,{className:`text-sm font-semibold text-foreground`,children:n(`pipeline.clusterRecordingTab.recordingNode`,`Recording node`)}),r(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:n(`pipeline.clusterRecordingTab.theSingleNodeThatRecords`,`The single node that records (continuous & events) and serves playback. Every other node stays inert — no multi-node balancing. Takes effect on addon restart.`)}),e(`div`,{className:`mt-3 flex items-center gap-2`,children:[c?r(l,{className:`h-4 w-4 animate-spin text-foreground-subtle`}):r(b,{wrapperClassName:`inline-block w-auto`,value:u,onChange:e=>{e.target.value!==u&&d.mutate({addonId:Pt,cap:Ft,scope:`cluster`,patch:{recordingNodeId:e.target.value}})},disabled:d.isPending,children:f.map(e=>r(`option`,{value:e,children:e===`hub`?n(`pipeline.clusterRecordingTab.hubDefault`,`hub (default)`):e},e))}),d.isPending&&r(l,{className:`h-4 w-4 animate-spin text-primary`})]}),u!==`hub`&&r(`p`,{className:`mt-2 text-[11px] text-amber-500`,children:r(Me,{i18nKey:`pipeline.clusterRecordingTab.hubOnlyNote`,values:{node:u},components:{b:r(`span`,{className:`font-medium`})}})})]}),e(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[r(`h3`,{className:`mb-1 text-sm font-semibold text-foreground`,children:n(`pipeline.clusterRecordingTab.recordingsFolders`,`Recordings folders`)}),r(`p`,{className:`mb-3 text-[11px] text-foreground-subtle`,children:n(`pipeline.clusterRecordingTab.whereRecordingsAreStoredMulti`,`Where recordings are stored. Multi-location collections — segments are split across the locations of a type. Add a location to grow capacity; mark one default per type.`)}),r(G,{types:[`recordings`,`recordingsLow`]})]})]})}function Rt(e){return e.locationIds!==void 0&&e.locationIds.length>0?e.locationIds:e.locationId===null?[]:[e.locationId]}function zt(e,t){let n=Rt(e);return n.length===0?H.t(`helpers.cameraDisk.defaultRoot`):n.map(e=>t.get(e)??e).join(` + `)}function Bt(e,t,n){if(e.length===0)return null;let r=e[0];if(e.length===1&&r!==void 0)return{label:zt(r,t),exact:!0};if(n===null)return null;let i=e.find(e=>Rt(e).includes(n));return i===void 0?null:{label:zt(i,t),exact:!1}}o();var Vt=[[`recording`]],Ht=[{value:`retention`,labelKey:`recordings.storageSection.pruneRetention`},{value:`quota`,labelKey:`recordings.storageSection.pruneQuota`},{value:`operator`,labelKey:`recordings.storageSection.pruneOperator`}],Ut={ok:`bg-primary`,warn:`bg-amber-500`,critical:`bg-danger`},Wt={ok:`text-foreground-subtle`,warn:`text-amber-500`,critical:`text-danger`};function $(e){return`${String(Math.round(e*100))}%`}function Gt(e){return e==null?`—`:new Date(e).toLocaleString()}function Kt(e,t){let n=e.locationIds??(e.locationId===null?[]:[e.locationId]),r=n.map(e=>t.get(e)).filter(e=>e!==void 0);return r.length>0?r.join(` + `):e.root===void 0?n.length>0?n.join(` + `):H.t(`recordings.storageSection.defaultRoot`):e.root}function qt(){let{t:i}=U(),o=s(),c=v(),[u,d]=a(`retention`),{data:f,isLoading:p}=we({},{refetchOnWindowFocus:!1}),{data:m}=L({isCamera:!0,projection:`slim`}),{data:_}=B({}),y=t(()=>{let e=new Map;for(let t of m??[])e.set(t.id,t.name);return e},[m]),S=t(()=>{let e=new Map;for(let t of _??[])e.set(t.id,t.displayName);return e},[_]),C=t(()=>{let e=_??[];return e.find(e=>e.type===`recordings`&&e.enabled!==!1)?.id??e.find(e=>e.type===`recordings`)?.id??null},[_]),w=t(()=>f?.locations??[],[f?.locations]),T=t(()=>Bt(w,S,C),[w,S,C]),E=t(()=>Ie(w),[w]),O=n(()=>{o.invalidateQueries({queryKey:Vt})},[o]),k=ye({onSuccess:O}),j=_e({onSuccess:O}),M=n(async e=>{await c({title:i(`recordings.storageSection.prune`,`Prune {{label}}?`,{label:y.get(e.deviceId)??`#${String(e.deviceId)}`}),message:i(`recordings.storageSection.appliesTheRetentionPolicyNow`,`Applies the retention policy now (reason: {{reason}}). Footage beyond the policy is permanently deleted.`,{reason:u}),confirmLabel:i(`recordings.storageSection.pruneNow`,`Prune now`),variant:`danger`})&&k.mutate({deviceId:e.deviceId,reason:u})},[c,k,u,y,i]),N=n(async e=>{await c({title:i(`recordings.storageSection.deleteAllFootageFor`,`Delete all footage for {{label}}?`,{label:y.get(e.deviceId)??`#${String(e.deviceId)}`}),message:i(`recordings.storageSection.permanentlyDeletesOfRecordedFootage`,`Permanently deletes {{value1}} of recorded footage for this camera. This cannot be undone.`,{value1:W(e.usedBytes)}),confirmLabel:i(`recordings.storageSection.delete`,`Delete {{value1}}`,{value1:W(e.usedBytes)}),variant:`danger`})&&j.mutate({deviceId:e.deviceId})},[c,j,y,i]),P=t(()=>[{key:`camera`,header:i(`recordings.storageSection.camera`,`Camera`),render:e=>r(`span`,{className:`text-foreground`,children:y.get(e.deviceId)??`#${String(e.deviceId)}`})},{key:`disk`,header:i(`recordings.storageSection.disk`,`Disk`),nowrap:!0,render:()=>T===null?r(`span`,{className:`text-foreground-subtle`,children:`—`}):e(`span`,{className:T.exact?`text-foreground`:`text-foreground-subtle`,title:T.exact?i(`recordings.storageSection.theOnlyRecordingsVolumeOn`,`The only recordings volume on this node — this camera can only be here.`):i(`recordings.storageSection.theRecordingsDefaultThisNode`,`The recordings DEFAULT. This node has several recordings volumes and the per-camera placement is not reported by recording.getStorageUsage, so this is where footage lands by default rather than a per-camera fact.`),children:[T.label,!T.exact&&r(`span`,{className:`ml-1 text-foreground-subtle`,children:i(`recordings.storageSection.default`,`(default)`)})]})},{key:`used`,header:i(`recordings.storageSection.used`,`Used`),align:`right`,nowrap:!0,render:e=>r(`span`,{className:`tabular-nums`,children:W(e.usedBytes)})},{key:`oldest`,header:i(`recordings.storageSection.oldestFootage`,`Oldest footage`),align:`right`,nowrap:!0,render:e=>r(`span`,{className:`tabular-nums text-foreground-subtle`,title:i(`recordings.storageSection.theOldestSegmentTheArchive`,`The oldest segment the ARCHIVE holds for this camera — the per-camera answer to 'is retention actually holding?'.`),children:Gt(e.oldestMs)})},{key:`actions`,header:``,align:`right`,render:t=>e(`div`,{className:`flex items-center justify-end gap-1`,children:[e(V,{variant:`unstyled`,onClick:()=>{M(t)},disabled:k.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-foreground-subtle hover:bg-amber-500/10 hover:text-amber-500 disabled:opacity-50`,title:i(`recordings.storageSection.applyRetentionPolicyNow`,`Apply retention policy now`),children:[r(D,{className:`h-3 w-3`}),i(`recordings.storageSection.prune2`,`Prune`)]}),e(V,{variant:`unstyled`,onClick:()=>{N(t)},disabled:j.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10 disabled:opacity-50`,title:i(`recordings.storageSection.deleteAllFootage`,`Delete all footage`),children:[r(x,{className:`h-3 w-3`}),i(`common.delete`,`Delete`)]})]})}],[y,T,M,N,k.isPending,j.isPending,i]);if(p&&!f)return e(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[r(l,{className:`h-4 w-4 animate-spin`}),i(`recordings.storageSection.loadingStorageUsage`,`Loading storage usage…`)]});if(!f)return r(I,{icon:g,title:i(`recordings.storageSection.noStorageData`,`No storage data`),description:i(`recordings.storageSection.theRecordingNodeHasNot`,`The recording node has not reported any storage usage yet.`)});let F=f.devices.length;return e(`div`,{className:`flex flex-col gap-6`,children:[e(`section`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:[r(h,{label:i(`recordings.storageSection.totalUsed`,`Total used`),icon:r(g,{className:`h-3 w-3`}),footer:`${String(F)} camera${F===1?``:`s`} on ${f.nodeId}`,children:W(f.totalUsedBytes)}),E!==null&&E.severity!==null&&r(h,{label:i(`recordings.storageSection.freeOnRecordingsVolumes`,`Free on recordings volumes`),icon:r(g,{className:`h-3 w-3`}),footer:`across ${String(E.knownVolumes)} volume${E.knownVolumes===1?``:`s`} of ${W(E.totalBytes)}`+(E.unknownVolumes>0?` · ${String(E.unknownVolumes)} did not report capacity`:``),children:r(`span`,{className:`tabular-nums ${Wt[E.severity]}`,children:W(E.freeBytes)})}),w.map(t=>{let n=Fe(t),a=t.locationId??t.root??`default`;return r(h,{label:i(`recordings.storageSection.disk2`,`Disk: {{label}}`,{label:Kt(t,S)}),footer:n===null?`${W(t.usedBytes)} of recordings · volume capacity unknown`:`${W(n.freeBytes)} free of ${W(n.totalBytes)} · ${W(t.usedBytes)} recordings (${$(n.recordingsFraction)})`,children:n===null?r(`span`,{className:`tabular-nums`,children:W(t.usedBytes)}):e(`div`,{className:`flex items-center gap-2`,title:i(`recordings.storageSection.volumeFillEverythingOnThe`,`Volume fill — everything on the disk, not only recordings. Warn at 85%, critical at 95%.`),children:[r(`div`,{className:`h-2 flex-1 overflow-hidden rounded bg-muted`,children:r(`div`,{className:`h-full rounded ${Ut[n.severity]}`,style:{width:$(n.fraction)}})}),r(`span`,{className:`tabular-nums text-xs ${Wt[n.severity]}`,children:$(n.fraction)})]})},a)})]}),e(`section`,{className:`flex items-center gap-2 text-xs`,children:[r(`label`,{htmlFor:`prune-reason`,className:`text-foreground-subtle`,children:i(`recordings.storageSection.pruneReason`,`Prune reason`)}),r(b,{wrapperClassName:`inline-block w-auto`,id:`prune-reason`,value:u,onChange:e=>{let t=Ht.find(t=>t.value===e.target.value);t&&d(t.value)},children:Ht.map(e=>r(`option`,{value:e.value,children:i(e.labelKey)},e.value))})]}),F===0?r(I,{icon:g,title:f.devicesRead===`unavailable`?i(`recordings.storageSection.perCameraUsageUnavailable`,`Per-camera usage unavailable`):i(`recordings.storageSection.noRecordedFootage`,`No recorded footage`),description:f.devicesRead===`unavailable`?i(`recordings.storageSection.thisRecordingNodeHasNo`,`This recording node has no footage ledger, so it refused to answer the per-camera table rather than report what it happens to hold in memory. The disk totals above are unaffected.`):i(`recordings.storageSection.noCameraHasRecordedFootage`,`No camera has recorded footage on this node yet.`)}):r(A,{columns:P,rows:[...f.devices],rowKey:e=>e.deviceId,minWidthPx:480})]})}function Jt(){let{t}=U();return e(`div`,{className:`flex flex-col gap-8`,children:[e(`div`,{children:[r(`h2`,{className:`text-sm font-semibold text-foreground`,children:t(`recordings.recordingsStorageSection.footageOnDisk`,`Footage on disk`)}),r(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:t(`recordings.recordingsStorageSection.whatRecordedFootageOccupiesPer`,`What recorded footage occupies, per camera and per volume, with prune-by-policy and delete-all-footage.`)}),r(`div`,{className:`mt-3`,children:r(qt,{})})]}),e(`div`,{children:[r(`h2`,{className:`text-sm font-semibold text-foreground`,children:t(`recordings.recordingsStorageSection.recordingNodeFolders`,`Recording node & folders`)}),r(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:t(`recordings.recordingsStorageSection.theSingleNodeThatRecords`,`The single node that records and serves playback, and the storage locations footage is written to.`)}),r(`div`,{className:`mt-3`,children:r(Lt,{})})]})]})}function Yt(){let{t:e}=U(),t=je(`/recordings`,{t:e,isAdmin:!0})??{icon:y,title:e(`nav.recordings`,`Recordings`)};return r(Ne,{icon:t.icon,title:t.title,subtitle:e(`recordings.recordedFootageAndTheDurable`,`Recorded footage and the durable event store — what each occupies, where it is written, and the operations that move or reconcile both.`),defaultSection:`storage`,sectionsLabel:`${t.title} sections`,sections:[{id:`storage`,label:e(`recordings.recordings`,`Recordings`),content:r(Jt,{})},{id:`events`,label:e(`recordings.events`,`Events`),content:r(Ze,{})},{id:`cameras`,label:e(`recordings.cameras`,`Cameras`),content:r(Ue,{})},{id:`exports`,label:e(`recordings.export`,`Export`),content:r(ft,{})},{id:`activity`,label:e(`recordings.activity`,`Activity`),content:r(He,{})},{id:`management`,label:e(`recordings.management`,`Management`),content:r(Nt,{})}]})}export{Yt as RecordingsPage};
|
|
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{Fr as l,Ha as u,Li as d,Pa as f,Ua as p,Xt as m,Y as h,Zr as g,aa as _,ct as v,di as y,dt as b,en as x,vt as S,wi as C,wt as w,yi as T}from"./player-overlays-VrMHBBfa.js";import{Ac as E}from"./client-CBrsD14Q.js";import{t as D}from"./scissors-Bbq6WhOK.js";import{$d as O,Ai as k,Ar as A,Ba as j,Cp as M,Ep as N,Eu as P,Fi as F,Gd as ee,Gi as I,Jd as te,Kd as ne,Ni as re,Ns as L,Pi as ie,Qd as ae,Qf as R,Ra as z,Sp as oe,Su as se,Ud as B,Ul as ce,Vl as le,Wd as ue,Wf as V,Xd as de,Yd as fe,Yl as pe,Zd as me,_d as he,ef as ge,fd as _e,gd as ve,hd as ye,ji as be,jr as xe,ki as Se,md as Ce,pd as we,qd as Te,ql as Ee,ta as De,vd as Oe,yd as ke}from"./src-bJ4Hy4Cl.js";import{t as H}from"./i18n-BFxrpjSx.js";import{t as U}from"./useTranslation-BJr-n0es.js";import{E as Ae,b as je,li as Me}from"./index-1bBrNxAK.js";import{t as Ne}from"./AdminSectionedPage-vnoSnjIu.js";import{n as Pe}from"./authed-media-CfvJyG-Y.js";import{t as W}from"./format-size-DIxKXxtj.js";import{n as Fe,r as Ie,t as Le}from"./StorageLocationsTable-BU2R2YDl.js";o();var Re=[{value:`all`,labelKey:`common.all`},{value:`recording`,labelKey:`recordings.activitySection.domainRecordings`},{value:`events`,labelKey:`common.events`}],ze={recording:`bg-primary/10 text-primary`,events:`bg-violet-500/10 text-violet-400`},Be={columnKey:`at`,dir:`desc`};function Ve(e){return new Date(e).toLocaleString()}function He(){let{t:n,i18n:i}=U(),[o,s]=a(`all`),{data:d,isLoading:f,isError:p}=Ce({},{refetchOnWindowFocus:!1}),{data:h,isLoading:g,isError:_}=Ee({},{refetchOnWindowFocus:!1}),{data:v}=L({isCamera:!0,projection:`slim`}),y=t(()=>{let e=new Map;for(let t of v??[])e.set(t.id,t.name);return e},[v]),b=t(()=>{let e=[...d??[],...h??[]];return(o===`all`?e:e.filter(e=>e.domain===o)).toSorted((e,t)=>t.at-e.at)},[d,h,o]),x=t(()=>{let e=[];return p&&o!==`events`&&e.push(n(`recordings.activitySection.domainRecordings`)),_&&o!==`recording`&&e.push(n(`common.events`)),e},[p,_,o,n]),S=t(()=>new Intl.ListFormat(i.language,{type:`conjunction`}).format(x),[x,i.language]),C=t(()=>[{key:`at`,header:n(`recordings.activitySection.when`,`When`),nowrap:!0,sortValue:e=>e.at,render:e=>r(`span`,{className:`text-foreground-subtle tabular-nums`,children:Ve(e.at)})},{key:`domain`,header:n(`recordings.activitySection.domain`,`Domain`),sortValue:e=>e.domain,render:e=>r(`span`,{className:`inline-flex rounded px-1.5 py-0.5 text-[10px] font-medium ${ze[e.domain]}`,children:e.domain})},{key:`op`,header:n(`recordings.activitySection.operation`,`Operation`),sortValue:e=>e.op,render:e=>r(`span`,{className:`text-foreground`,children:e.op})},{key:`reason`,header:n(`recordings.activitySection.reason`,`Reason`),sortValue:e=>e.reason,render:e=>r(`span`,{className:`text-foreground-subtle`,children:e.reason})},{key:`device`,header:n(`recordings.activitySection.camera`,`Camera`),sortValue:e=>e.deviceId===null?`cluster`:y.get(e.deviceId)??`#${String(e.deviceId)}`,render:e=>e.deviceId===null?r(`span`,{className:`text-foreground-subtle`,children:n(`common.cluster`)}):r(`span`,{className:`text-foreground`,children:y.get(e.deviceId)??`#${String(e.deviceId)}`})},{key:`items`,header:n(`recordings.activitySection.items`,`Items`),align:`right`,nowrap:!0,sortValue:e=>e.itemsAffected,render:e=>r(`span`,{className:`tabular-nums`,children:e.itemsAffected.toLocaleString()})},{key:`bytes`,header:n(`recordings.activitySection.reclaimed`,`Reclaimed`),align:`right`,nowrap:!0,sortValue:e=>e.bytesReclaimed,render:e=>r(`span`,{className:`tabular-nums`,children:e.bytesReclaimed>0?W(e.bytesReclaimed):`—`})}],[y,n]),w=f||g;return e(`div`,{className:`flex flex-col gap-4`,children:[r(`div`,{className:`flex items-center gap-1`,children:Re.map(e=>r(V,{variant:`unstyled`,onClick:()=>s(e.value),className:`rounded px-2 py-1 text-xs font-medium ${o===e.value?`bg-primary/10 text-primary`:`text-foreground-subtle hover:bg-muted`}`,children:n(e.labelKey)},e.value))}),w&&b.length===0?e(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[r(l,{className:`h-4 w-4 animate-spin`}),n(`recordings.activitySection.loadingActivity`,`Loading activity…`)]}):b.length===0?x.length>0?r(I,{icon:m,title:n(`recordings.activitySection.activityCouldNotBeRead`,`Activity could not be read`),description:n(`recordings.activitySection.theOpsLogDidNot`,`The {{value1}} ops log did not answer. This is not "nothing happened" — retry, or check the node that owns it.`,{value1:S})}):r(I,{icon:u,title:n(`recordings.activitySection.noActivityYet`,`No activity yet`),description:n(`recordings.activitySection.pruneDeleteAndRescanOperations`,`Prune, delete and rescan operations across recordings and events show up here.`)}):e(c,{children:[x.length>0&&e(`p`,{className:`flex items-center gap-1.5 text-[11px] text-amber-500`,children:[r(m,{className:`h-3 w-3 shrink-0`}),n(`recordings.activitySection.domainsMissing`,{count:x.length,names:S})]}),r(A,{columns:C,rows:b,rowKey:e=>e.id,minWidthPx:720,maxBodyHeight:xe,defaultSort:Be})]})]})}o();function Ue(){let{t:n}=U(),i=L({isCamera:!0,projection:`slim`}),o=t(()=>(i.data??[]).toSorted((e,t)=>e.name.localeCompare(t.name)),[i.data]),[s,c]=a(null),l=s??o[0]?.id??null;return!i.isLoading&&o.length===0?r(I,{icon:_,title:n(`recordings.cameraRecordingSettingsSection.noCameras`,`No cameras`),description:n(`recordings.cameraRecordingSettingsSection.addACameraFirst`,`Add a camera first.`)}):e(`div`,{className:`space-y-3`,children:[e(`div`,{children:[r(`h2`,{className:`text-sm font-semibold text-foreground`,children:n(`recordings.cameraRecordingSettingsSection.perCameraRecordingRetention`,`Per-camera recording & retention`)}),r(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:n(`recordings.cameraRecordingSettingsSection.recordingModeScheduleBandsAnd`,`Recording mode, schedule bands and the retention policy for one camera — the same controls as the camera's own Recording tab. Retention is one policy over footage and analytics; per-camera event deletion lives on the Events tab.`)})]}),e(`div`,{className:`flex items-center gap-2`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:n(`recordings.cameraRecordingSettingsSection.camera`,`Camera`)}),r(b,{wrapperClassName:`inline-block w-auto`,value:l??``,onChange:e=>c(Number(e.target.value)),children:o.map(e=>r(`option`,{value:e.id,children:e.name},e.id))})]}),l!==null&&r(De,{deviceId:l,children:r(Ae,{deviceId:l,sectionFilter:e=>e.location===`top-tab`&&e.tab===`recording`})},l)]})}function G({types:e}){return r(Le,{kinds:e})}o();var K=`pipeline-analytics`,q=`pipeline-analytics`;function We(e){for(let t of e?.sections??[])for(let e of t.fields??[])if(e.key===`postProcessingNodeId`&&typeof e.value==`string`)return e.value;return`hub`}function Ge(){let{t:n}=U(),i=s(),{nodes:a}=M(),{data:o,isLoading:c}=z({addonId:K,cap:q,scope:`cluster`}),u=We(o),d=j({onSuccess:()=>{i.invalidateQueries({queryKey:[[`addonSettings`,`getScopedSettings`]]})}}),f=t(()=>{let e=a.filter(e=>e.isOnline).map(e=>e.id);return[...new Set([`hub`,u,...e])].filter(Boolean)},[a,u]);return e(`div`,{className:`flex flex-col gap-6`,children:[e(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[r(`h3`,{className:`text-sm font-semibold text-foreground`,children:n(`pipeline.clusterEventsTab.postProcessingNode`,`Post-processing node`)}),r(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:n(`pipeline.clusterEventsTab.theSingleNodeThatRuns`,`The single node that runs detection post-processing (events, media, audio & motion). Every other node stays inert — no multi-node balancing. Takes effect on addon restart.`)}),e(`div`,{className:`mt-3 flex items-center gap-2`,children:[c?r(l,{className:`h-4 w-4 animate-spin text-foreground-subtle`}):r(b,{wrapperClassName:`inline-block w-auto`,value:u,onChange:e=>{e.target.value!==u&&d.mutate({addonId:K,cap:q,scope:`cluster`,patch:{postProcessingNodeId:e.target.value}})},disabled:d.isPending,children:f.map(e=>r(`option`,{value:e,children:e===`hub`?n(`pipeline.clusterEventsTab.hubDefault`,`hub (default)`):e},e))}),d.isPending&&r(l,{className:`h-4 w-4 animate-spin text-primary`})]})]}),e(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[r(`h3`,{className:`mb-1 text-sm font-semibold text-foreground`,children:n(`pipeline.clusterEventsTab.eventsFolder`,`Events folder`)}),r(`p`,{className:`mb-3 text-[11px] text-foreground-subtle`,children:n(`pipeline.clusterEventsTab.whereEventCropsFullFrames`,`Where event crops / full frames are stored. A single folder — no collection / equal-splitting.`)}),r(G,{types:[`eventMedia`]})]})]})}o();var Ke=[[`pipelineAnalytics`]],qe=1440*60*1e3;function Je(e,t){return t.get(e)??H.t(`recordings.eventsManagementSection.removedCamera`,{id:String(e)})}var Ye=[{days:1},{days:7},{days:30},{days:90}];function Xe(){let{t:i}=U(),o=s(),c=v(),[u,d]=a(30),[f,p]=a(null),{data:m,isLoading:g}=ce({},{refetchOnWindowFocus:!1}),{data:_}=L({isCamera:!0,projection:`slim`}),y=t(()=>{let e=new Map;for(let t of _??[])e.set(t.id,t.name);return e},[_]),S=n(()=>{o.invalidateQueries({queryKey:Ke})},[o]),w=pe({onSuccess:S}),T=le(),E=n(async()=>{await c({title:i(`recordings.eventsManagementSection.pruneTitle`,{count:u}),message:i(`recordings.eventsManagementSection.permanentlyDeletesEveryEventMotion`,`Permanently deletes every event (motion / object / audio) older than the cutoff across all cameras, and their media. This cannot be undone.`),confirmLabel:i(`recordings.eventsManagementSection.pruneEvents`,`Prune events`),variant:`danger`})&&w.mutate({olderThanMs:Date.now()-u*qe,reason:`retention`})},[c,w,u,i]),O=n(async e=>{let t=Je(e.deviceId,y);if(await c({title:i(`recordings.eventsManagementSection.deleteAllEventsFor`,`Delete all events for {{label}}?`,{label:t}),message:i(`recordings.eventsManagementSection.deleteRowsMessage`,{count:e.rows,size:W(e.bytes)}),confirmLabel:i(`recordings.eventsManagementSection.deleteEvents`,`Delete events`),variant:`danger`})){p(null);try{let n=await T.mutateAsync({deviceId:e.deviceId});S();let r=n.motion+n.object+n.audio;if(r===0&&e.bytes>0){p(`0 events deleted for ${t}. Media still listed (${W(e.bytes)}) — those blobs are not event rows; use Management → Count leftovers or Disk reconcile.`);return}p(`Deleted ${String(r)} event${r===1?``:`s`} for ${t}.`)}catch(e){p(e instanceof Error?e.message:String(e))}}},[c,T,y,S,i]),k=t(()=>[{key:`camera`,header:i(`recordings.eventsManagementSection.camera`,`Camera`),render:e=>r(`span`,{className:`text-foreground`,children:Je(e.deviceId,y)})},{key:`rows`,header:i(`recordings.eventsManagementSection.events`,`Events`),align:`right`,nowrap:!0,render:e=>r(`span`,{className:`tabular-nums`,children:e.rows.toLocaleString()})},{key:`bytes`,header:i(`recordings.eventsManagementSection.media`,`Media`),align:`right`,nowrap:!0,render:e=>r(`span`,{className:`tabular-nums`,children:W(e.bytes)})},{key:`actions`,header:``,align:`right`,render:t=>e(V,{variant:`unstyled`,onClick:()=>{O(t)},disabled:T.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10 disabled:opacity-50`,title:i(`recordings.eventsManagementSection.deleteAllEventsForThis`,`Delete all events for this camera`),children:[r(x,{className:`h-3 w-3`}),i(`common.delete`,`Delete`)]})}],[y,O,T.isPending,i]);return g&&!m?e(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[r(l,{className:`h-4 w-4 animate-spin`}),i(`recordings.eventsManagementSection.loadingEventStoreFootprint`,`Loading event-store footprint…`)]}):m?e(`div`,{className:`flex flex-col gap-6`,children:[e(`section`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2`,children:[r(h,{label:i(`recordings.eventsManagementSection.totalEvents`,`Total events`),icon:r(C,{className:`h-3 w-3`}),footer:`across ${String(m.devices.length)} camera${m.devices.length===1?``:`s`}`,children:m.totalRows.toLocaleString()}),r(h,{label:i(`recordings.eventsManagementSection.eventMediaOnDisk`,`Event media on disk`),children:W(m.totalBytes)})]}),e(`section`,{className:`flex flex-wrap items-center gap-2 text-xs`,children:[r(`span`,{className:`text-foreground-subtle`,children:i(`recordings.eventsManagementSection.pruneEventsOlderThan`,`Prune events older than`)}),r(b,{wrapperClassName:`inline-block w-auto`,value:u,onChange:e=>d(Number(e.target.value)),children:Ye.map(e=>r(`option`,{value:e.days,children:i(`recordings.eventsManagementSection.ageDays`,{count:e.days})},e.days))}),e(V,{variant:`unstyled`,onClick:()=>{E()},disabled:w.isPending,className:`inline-flex items-center gap-1 rounded border border-border px-2 py-1 text-xs font-medium text-foreground-subtle hover:bg-warning/10 hover:text-warning disabled:opacity-50`,children:[w.isPending?r(l,{className:`h-3 w-3 animate-spin`}):r(D,{className:`h-3 w-3`}),i(`recordings.eventsManagementSection.pruneNow`,`Prune now`)]})]}),m.devices.length===0?r(I,{icon:C,title:i(`recordings.eventsManagementSection.noStoredEvents`,`No stored events`),description:i(`recordings.eventsManagementSection.noCameraHasPersistedEvents`,`No camera has persisted events yet.`)}):r(A,{columns:k,rows:[...m.devices],rowKey:e=>e.deviceId,minWidthPx:480}),f===null?null:r(`p`,{className:f.startsWith(`Deleted `)?`text-[11px] text-foreground-subtle`:`text-[11px] text-destructive`,children:f})]}):r(I,{icon:C,title:i(`recordings.eventsManagementSection.noEventData`,`No event data`),description:i(`recordings.eventsManagementSection.pipelineAnalyticsHasNotReported`,`Pipeline analytics has not reported any event-store footprint yet.`)})}function Ze(){let{t}=U();return e(`div`,{className:`flex flex-col gap-8`,children:[e(`div`,{children:[r(`h2`,{className:`text-sm font-semibold text-foreground`,children:t(`recordings.eventsSection.eventStore`,`Event store`)}),r(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:t(`recordings.eventsSection.whatTheDurableEventStore`,`What the durable event store occupies, per camera, with fleet-wide prune-by-age and delete-all-events.`)}),r(`div`,{className:`mt-3`,children:r(Xe,{})})]}),e(`div`,{children:[r(`h2`,{className:`text-sm font-semibold text-foreground`,children:t(`recordings.eventsSection.postProcessingNodeFolders`,`Post-processing node & folders`)}),r(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:t(`recordings.eventsSection.theSingleNodeThatWrites`,`The single node that writes event crops, and the storage location they land in.`)}),r(`div`,{className:`mt-3`,children:r(Ge,{})})]})]})}function Qe(e){let t=[];return e.timelapse?t.push(`timelapse ${String(e.timelapse.everyMs/1e3)}s`):(t.push(`${String(e.speed??1)}×`),e.includeAudio&&t.push(`+ audio`)),t.join(` `)}function $e(e){return new Date(e).toLocaleString(void 0,{day:`2-digit`,month:`short`,hour:`2-digit`,minute:`2-digit`})}function et(e,t){let n=Math.max(0,Math.round((t-e)/1e3)),r=Math.floor(n/3600),i=Math.floor(n%3600/60),a=n%60,o=r>0?`${String(r)}:${String(i).padStart(2,`0`)}:${String(a).padStart(2,`0`)}`:`${String(i)}:${String(a).padStart(2,`0`)}`;return`${$e(e)} · ${o}`}function tt(e,t){let n=e-t;if(n<=0)return H.t(`helpers.exportFormat.expired`);let r=Math.floor(n/6e4);if(r<60)return H.t(`helpers.exportFormat.inMinutes`,{n:String(r)});let i=Math.floor(r/60);return i<24?H.t(`helpers.exportFormat.inHours`,{n:String(i)}):H.t(`helpers.exportFormat.inDays`,{n:String(Math.floor(i/24))})}function nt(e,t,n,r){return e.map(e=>{if(e.state===`expired`||e.state===`deleted`)return e;let i=r.get(e.id);if(i)return{...e,state:`failed`,error:i.error,progressPct:null};let a=n.get(e.id);if(a)return{...e,state:`ready`,fileBytes:a.fileBytes,progressPct:100};let o=t.get(e.id);return o&&(e.state===`queued`||e.state===`rendering`)?{...e,state:`rendering`,progressPct:o.progressPct}:e})}o();var rt=[`high`,`mid`,`low`],it=[{value:1,labelKey:`recordings.newExportModal.speedRealTime`},{value:2,labelKey:null},{value:4,labelKey:null},{value:8,labelKey:null},{value:16,labelKey:null}],at=10080*60*1e3;function ot(e){let t=new Date(Date.now()-e*6e4),n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}T${n(t.getHours())}:${n(t.getMinutes())}`}function st({onClose:n,onCreated:i}){let{t:o}=U(),s=L({isCamera:!0,projection:`slim`}),c=t(()=>(s.data??[]).toSorted((e,t)=>e.name.localeCompare(t.name)),[s.data]),[l,u]=a(``),[d,f]=a(`high`),[m,h]=a(ot(60)),[g,_]=a(ot(0)),[v,x]=a(1),[S,C]=a(!0),[w,T]=a(``),[E,D]=a(null),O=l===``?c[0]?.id??null:l,A=new Date(m).getTime(),j=new Date(g).getTime(),M=Number.isFinite(A)&&Number.isFinite(j)&&A<j,N=he({onSuccess:()=>{i(),n()},onError:e=>D(e instanceof Error?e.message:String(e))});return r(Se,{open:!0,onOpenChange:e=>!e&&n(),children:e(be,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[r(ie,{children:e(F,{className:`flex items-center gap-1.5`,children:[r(y,{className:`h-3.5 w-3.5`}),o(`recordings.newExportModal.newExport`,`New export`)]})}),e(k,{className:`space-y-3`,children:[e(`div`,{className:`grid grid-cols-2 gap-3`,children:[e(`div`,{className:`space-y-1`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:o(`recordings.newExportModal.camera`,`Camera`)}),r(b,{value:O??``,onChange:e=>u(Number(e.target.value)),className:`w-full`,children:c.map(e=>r(`option`,{value:e.id,children:e.name},e.id))})]}),e(`div`,{className:`space-y-1`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:o(`recordings.newExportModal.profile`,`Profile`)}),r(b,{value:d,onChange:e=>f(e.target.value),className:`w-full`,children:rt.map(e=>r(`option`,{value:e,children:e},e))})]})]}),e(`div`,{className:`grid grid-cols-2 gap-3`,children:[e(`div`,{className:`space-y-1`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:o(`recordings.newExportModal.from`,`From`)}),r(R,{type:`datetime-local`,value:m,onChange:e=>h(e.target.value),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground`})]}),e(`div`,{className:`space-y-1`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:o(`recordings.newExportModal.to`,`To`)}),r(R,{type:`datetime-local`,value:g,onChange:e=>_(e.target.value),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground`})]})]}),e(`div`,{className:`grid grid-cols-2 gap-3`,children:[e(`div`,{className:`space-y-1`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:o(`recordings.newExportModal.speed`,`Speed`)}),r(b,{value:v,onChange:e=>x(Number(e.target.value)),className:`w-full`,children:it.map(e=>r(`option`,{value:e.value,children:e.labelKey===null?`${e.value}×`:o(e.labelKey)},e.value))})]}),e(`div`,{className:`space-y-1`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:o(`recordings.newExportModal.titleOptional`,`Title (optional)`)}),r(R,{type:`text`,value:w,onChange:e=>T(e.target.value),placeholder:o(`recordings.newExportModal.eGCourierAtThe`,`e.g. courier at the gate`),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground placeholder:text-foreground-subtle`})]})]}),e(`label`,{className:`flex items-center gap-2 text-xs text-foreground cursor-pointer`,children:[r(p,{checked:S,disabled:v!==1,onChange:e=>C(e.target.checked),className:`accent-primary`}),o(v===1?`recordings.newExportModal.includeAudio`:`recordings.newExportModal.includeAudioRealtimeOnly`)]}),!M&&r(`p`,{className:`text-[11px] text-danger`,children:o(`recordings.newExportModal.fromMustBeBeforeTo`,`"From" must be before "To".`)}),E&&r(`p`,{className:`text-[11px] text-danger`,children:E})]}),e(re,{children:[r(V,{variant:`outline`,size:`sm`,onClick:n,children:o(`common.cancel`,`Cancel`)}),r(V,{size:`sm`,onClick:()=>{if(O===null||!M)return;D(null);let e=w.trim();N.mutate({deviceId:O,profile:d,fromMs:A,toMs:j,options:{includeAudio:S,maxLifeMs:at,deleteAfterDownload:!1,...v===1?{}:{speed:v},...e.length>0?{title:e}:{}}})},disabled:O===null||!M||N.isPending,children:N.isPending?o(`recordings.newExportModal.queuing`,`Queuing…`):o(`recordings.newExportModal.createExport`,`Create export`)})]})]})})}o();var ct=[[`recordingExport`]],lt={queued:{cls:`bg-muted text-foreground-subtle`,labelKey:`recordings.exportsSection.queued`},rendering:{cls:`bg-primary/10 text-primary`,labelKey:`recordings.exportsSection.rendering`,spin:!0},ready:{cls:`bg-success/10 text-success`,labelKey:`recordings.exportsSection.ready`},failed:{cls:`bg-danger/10 text-danger`,labelKey:`recordings.exportsSection.failed`},expired:{cls:`bg-muted text-foreground-subtle`,labelKey:`recordings.exportsSection.expired`},deleted:{cls:`bg-muted text-foreground-subtle`,labelKey:`recordings.exportsSection.deleted`}};function ut(){let{data:e,isLoading:n}=ke({},{refetchOnWindowFocus:!1,refetchInterval:e=>(e.state.data??[]).some(e=>e.state===`queued`||e.state===`rendering`)?3e3:!1}),{map:r}=N(E.RecordingExportProgress,e=>e.exportId),{map:i}=N(E.RecordingExportCompleted,e=>e.exportId),{map:a}=N(E.RecordingExportFailed,e=>e.exportId);return{rows:t(()=>nt(e??[],r,i,a),[e,r,i,a]),isLoading:n}}function dt(e){let[t,n]=a(()=>Date.now());return i(()=>{let t=setInterval(()=>n(Date.now()),e);return()=>clearInterval(t)},[e]),t}function ft(){let{t:i}=U(),o=s(),[c,u]=a(!1),f=()=>{o.invalidateQueries({queryKey:[[`recordingExport`,`listExports`]]})},p=v(),m=S().trpcClient,h=dt(6e4),{rows:g,isLoading:_}=ut(),{data:b}=L({isCamera:!0,projection:`slim`}),C=t(()=>{let e=new Map;for(let t of b??[])e.set(t.id,t.name);return e},[b]),w=n(()=>{o.invalidateQueries({queryKey:ct})},[o]),E=ve({onSuccess:w}),D=Oe({onSuccess:w}),[O,k]=a(null),j=n(async e=>{k(e.id);try{let{url:t}=await m.recordingExport.getDownloadUrl.query({exportId:e.id}),n=await Pe(t),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`${e.options.title??e.id}.mp4`,document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(r),w()}finally{k(null)}},[m,w]),M=n(async e=>{await p({title:i(`recordings.exportsSection.cancelThisExport`,`Cancel this export?`),message:i(`recordings.exportsSection.stopsTheRenderThePartial`,`Stops the render. The partial file is discarded.`),confirmLabel:i(`recordings.exportsSection.cancelExport`,`Cancel export`),variant:`danger`})&&E.mutate({exportId:e.id})},[p,E,i]),N=n(async e=>{await p({title:i(`recordings.exportsSection.deleteThisExport`,`Delete this export?`),message:i(`recordings.exportsSection.permanentlyRemovesTheRenderedFile`,`Permanently removes the rendered file and its history row.`),confirmLabel:i(`common.delete`,`Delete`),variant:`danger`})&&D.mutate({exportId:e.id})},[p,D,i]),P=t(()=>[{key:`camera`,header:i(`recordings.exportsSection.camera`,`Camera`),render:e=>r(`span`,{className:`text-foreground`,children:C.get(e.deviceId)??`#${String(e.deviceId)}`})},{key:`range`,header:i(`recordings.exportsSection.range`,`Range`),nowrap:!0,render:e=>r(`span`,{className:`tabular-nums`,children:et(e.fromMs,e.toMs)})},{key:`variant`,header:i(`recordings.exportsSection.variant`,`Variant`),render:e=>r(`span`,{className:`text-foreground-subtle`,children:Qe(e.options)})},{key:`state`,header:i(`recordings.exportsSection.state`,`State`),render:t=>{let n=lt[t.state];return e(`span`,{className:`inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] font-medium ${n.cls}`,children:[n.spin&&r(l,{className:`h-2.5 w-2.5 animate-spin`}),i(n.labelKey),t.state===`rendering`&&t.progressPct!==null&&e(`span`,{className:`tabular-nums`,children:[t.progressPct,`%`]})]})}},{key:`expiry`,header:i(`recordings.exportsSection.expires`,`Expires`),nowrap:!0,render:e=>e.state===`deleted`?r(`span`,{className:`text-foreground-subtle`,children:`—`}):r(`span`,{className:`text-foreground-subtle tabular-nums`,children:tt(e.expiresAt,h)})},{key:`size`,header:i(`recordings.exportsSection.size`,`Size`),align:`right`,nowrap:!0,render:e=>r(`span`,{className:`tabular-nums`,children:e.fileBytes===null?`—`:W(e.fileBytes)})},{key:`actions`,header:``,align:`right`,render:t=>{let n=t.state===`ready`,a=t.state===`queued`||t.state===`rendering`,o=t.state!==`deleted`;return e(`div`,{className:`flex items-center justify-end gap-1`,children:[n&&e(V,{variant:`unstyled`,onClick:()=>{j(t)},disabled:O===t.id,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-foreground-subtle hover:bg-primary/10 hover:text-foreground disabled:opacity-50`,title:i(`recordings.exportsSection.downloadMp4`,`Download MP4`),children:[O===t.id?r(l,{className:`h-3 w-3 animate-spin`}):r(T,{className:`h-3 w-3`}),i(`recordings.exportsSection.download`,`Download`)]}),a&&e(V,{variant:`unstyled`,onClick:()=>{M(t)},disabled:E.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-foreground-subtle hover:bg-amber-500/10 hover:text-amber-500 disabled:opacity-50`,title:i(`recordings.exportsSection.cancelRender`,`Cancel render`),children:[r(d,{className:`h-3 w-3`}),i(`common.cancel`,`Cancel`)]}),o&&r(V,{variant:`unstyled`,onClick:()=>{N(t)},disabled:D.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10 disabled:opacity-50`,title:i(`recordings.exportsSection.deleteExport`,`Delete export`),children:r(x,{className:`h-3 w-3`})})]})}}],[C,h,O,E.isPending,D.isPending,j,M,N,i]);return _&&g.length===0?e(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[r(l,{className:`h-4 w-4 animate-spin`}),i(`recordings.exportsSection.loadingExports`,`Loading exports…`)]}):e(`div`,{className:`space-y-3`,children:[r(`div`,{className:`flex justify-end`,children:e(V,{variant:`unstyled`,onClick:()=>u(!0),className:`inline-flex items-center gap-1.5 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground`,children:[r(y,{className:`h-3.5 w-3.5`}),i(`recordings.exportsSection.newExport`,`New export`)]})}),g.length===0?r(I,{icon:y,title:i(`recordings.exportsSection.noExportsYet`,`No exports yet`),description:i(`recordings.exportsSection.createOneHereNewExport`,`Create one here (New export) or from a camera's timeline in the viewer. Rendered clips show up here to download or manage.`)}):r(A,{columns:P,rows:g,rowKey:e=>e.id,minWidthPx:720}),c&&r(st,{onClose:()=>u(!1),onCreated:f})]})}var pt=`inline-flex w-fit items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-[11px] font-medium border border-border text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50`;o();var mt=`storage-migration`,ht=new Set([`orphans`,`debug-media`,`ghost-ledger`]);function gt(e){return[`${e.orphansReclaimed} orphan rows (${W(e.orphanBytesReclaimed)})`,e.includeDebugMedia?`${e.debugMediaReclaimed} debug files (${W(e.debugMediaBytesReclaimed)})`:null,`${e.ghostsForgotten} ghost rows (${W(e.ghostBytesForgotten)})`].filter(e=>e!==null).join(` · `)}function _t(){let{t:e}=U(),t=oe(mt);return t===`pending`?null:t===`unknown`?r(`p`,{className:`py-2 text-xs text-foreground-subtle`,children:e(`recordings.cleanupSection.couldNotCheckWhetherStorage`,`Could not check whether storage cleanup is installed on this hub.`)}):t===`present`?r(vt,{}):null}function vt(){let{t}=U(),n=v(),[i,o]=a(!1),[s,c]=a(null),u=Te({},{refetchInterval:2e3}),d=u.data??null,f=d!==null&&ht.has(d.phase),m=ne(),h=ee(),g=async()=>{if(await n({title:t(`recordings.cleanupSection.runStorageCleanup`,`Run storage cleanup?`),message:i?t(`recordings.cleanupSection.reclaimsLeftoverAnalyticsRowsAnd`,`Reclaims leftover analytics rows and files, debug stills/filmstrips, and ghost footage rows on frozen locations. Safe to re-run.`):t(`recordings.cleanupSection.reclaimsLeftoverAnalyticsRowsAnd2`,`Reclaims leftover analytics rows and files, and ghost footage rows on frozen locations. Debug stills are left alone. Safe to re-run.`),confirmLabel:t(`recordings.cleanupSection.runCleanup`,`Run cleanup`),variant:`danger`})){c(null);try{await m.mutateAsync({includeDebugMedia:i}),await u.refetch()}catch(e){c(e instanceof Error?e.message:String(e))}}},_=async()=>{if(d&&await n({title:t(`recordings.cleanupSection.cancelCleanup`,`Cancel cleanup?`),message:t(`recordings.cleanupSection.stopsAfterTheCurrentStep`,`Stops after the current step. Work already done stays done.`),confirmLabel:t(`recordings.cleanupSection.cancelCleanup2`,`Cancel cleanup`),variant:`danger`}))try{await h.mutateAsync({jobId:d.jobId}),await u.refetch()}catch{}};return e(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[r(`h2`,{className:`text-sm font-semibold text-foreground`,children:t(`recordings.cleanupSection.cleanup`,`Cleanup`)}),r(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:t(`recordings.cleanupSection.onePassOverLeftoverAnalytics`,`One pass over leftover analytics (database + files) and ghost footage rows on frozen locations. Does not time out — progress updates here until it finishes.`)}),e(`label`,{className:`mt-3 flex items-start gap-2 text-[11px] text-foreground`,children:[r(p,{checked:i,disabled:f,onChange:e=>{o(e.target.checked)},className:`mt-0.5 h-3.5 w-3.5 accent-primary`}),r(`span`,{children:t(`recordings.cleanupSection.alsoRemoveDebugMediaMotion`,`Also remove debug media (motion stills and track filmstrips)`)})]}),e(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[e(V,{variant:`unstyled`,type:`button`,disabled:f||m.isPending,onClick:()=>{g()},className:pt,children:[(f||m.isPending)&&r(l,{className:`h-3 w-3 animate-spin`}),r(x,{className:`h-3 w-3`}),t(`recordings.cleanupSection.runCleanup`,`Run cleanup`)]}),f&&r(V,{variant:`unstyled`,type:`button`,onClick:()=>{_()},className:`inline-flex items-center gap-1 rounded border border-border px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10`,children:t(`common.cancel`,`Cancel`)})]}),s&&r(`p`,{className:`mt-2 text-[11px] text-danger`,children:s}),d&&e(`div`,{className:`mt-3 space-y-1 rounded-md border border-border px-2.5 py-2`,children:[e(`p`,{className:`text-xs text-foreground`,children:[t(`recordings.cleanupSection.phase`,`Phase:`),` `,r(`span`,{className:`font-medium`,children:d.phase}),f&&r(l,{className:`ml-2 inline h-3 w-3 animate-spin text-primary`})]}),d.detail&&r(`p`,{className:`text-[11px] text-foreground-subtle`,children:d.detail}),r(`p`,{className:`text-[11px] text-foreground-subtle`,children:gt(d)}),d.error&&r(`p`,{className:`text-[11px] text-danger`,children:d.error})]})]})}o();var yt=2e3;function bt(){let{t}=U(),n=v(),a=s(),o=P(),c=se(void 0,{refetchInterval:e=>e.state.data?.state===`running`?yt:!1}),u=c.data,d=u?.state===`running`,f=d||o.isPending;i(()=>{u?.state!==`done`||u.finishedAtMs===null||(a.invalidateQueries({queryKey:[[`recording`]]}),a.invalidateQueries({queryKey:[[`pipelineAnalytics`]]}))},[u?.state,u?.finishedAtMs,a]);let p=async()=>{await n({title:t(`recordings.diskReconcileSection.reconcileStorageFromDisk`,`Reconcile storage from disk?`),message:t(`recordings.diskReconcileSection.makesTheDatabaseMatchThe`,`Makes the database match the filesystem: recordings index, tracks, events and media whose files are gone. Favourited tracks without files are deleted. Snapshot-less motion/audio events are deleted. Enrolled identities stay. This cannot be undone.`),confirmLabel:t(`recordings.diskReconcileSection.reconcile`,`Reconcile`),variant:`warning`})&&(await o.mutateAsync(),await c.refetch())},m=d?u.total>0?`Reconciling ${String(u.completed)}/${String(u.total)}…`:`Reconciling…`:o.isPending?`Reconciling…`:`Reconcile from disk`;return e(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[r(`h3`,{className:`text-sm font-semibold text-foreground`,children:t(`recordings.diskReconcileSection.diskReconcile`,`Disk reconcile`)}),r(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:t(`recordings.diskReconcileSection.deletesDatabaseRowsWhoseFiles`,`Deletes database rows whose files are gone. Enrolled identities stay.`)}),e(`div`,{className:`mt-3 flex flex-col gap-2`,children:[e(V,{variant:`unstyled`,type:`button`,onClick:()=>void p(),disabled:f,className:`inline-flex w-fit items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-[11px] font-medium border border-border text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50`,children:[f?r(l,{className:`h-3.5 w-3.5 animate-spin`}):r(g,{className:`h-3.5 w-3.5`}),m]}),u?.state===`done`?e(`p`,{className:`text-[11px] text-foreground-subtle`,children:[t(`recordings.diskReconcileSection.lastRun`,`Last run:`),` `,t(`recordings.diskReconcileSection.summary`,{completed:String(u.completed),tracks:String(u.tracks),events:String(u.events),media:String(u.mediaDropped)}),u.failed.length>0?t(`recordings.diskReconcileSection.failed`,`, {{value1}} failed ({{value2}})`,{value1:String(u.failed.length),value2:u.failed.join(`, `)}):``,`.`]}):null,u?.state===`error`&&u.error!==null?e(`p`,{className:`text-[11px] text-destructive`,children:[t(`recordings.diskReconcileSection.reconcileFailed`,`Reconcile failed:`),` `,u.error]}):null]})]})}var J=1e3,Y=60*J,X=60*Y;function Z(e){return e.toLocaleString(`en-US`)}function xt(e){if(!Number.isFinite(e)||e<0)return`—`;if(e>=X){let t=Math.floor(e/X),n=Math.round(e%X/Y);return`${t.toString()}h ${n.toString()}m`}if(e>=Y){let t=Math.floor(e/Y),n=Math.round(e%Y/J);return`${t.toString()}m ${n.toString()}s`}return`${Math.max(0,Math.round(e/J)).toString()}s`}function St(e){let t=Math.max(0,e.observedAt-e.startedAt),n=e.filesTotal===null?`${Z(e.filesMoved)} files`:`${Z(e.filesMoved)} / ${Z(e.filesTotal)} files`,r=e.filesTotal===null||e.filesTotal===0?null:Math.min(1,e.filesMoved/e.filesTotal),i=t>0&&e.filesMoved>0,a=i?`${W(e.bytesMoved/t*J)}/s`:null,o=e.filesTotal===null?null:e.filesTotal-e.filesMoved,s=!i||o===null||o<=0?null:`~${xt(o*t/e.filesMoved)} left`;return{counted:n,fraction:r,moved:`${W(e.bytesMoved)} moved`,rate:a,eta:s}}function Ct(e){let t=St(e);return[t.counted,t.moved,t.rate,t.eta].filter(e=>e!==null).join(` · `)}o();var wt=`storage-migration`,Q=[{id:`recordings`,labelKey:`recordings.storageMigrationSection.classRecordings`,locationType:`recordings`},{id:`recordingsLow`,labelKey:`recordings.storageMigrationSection.classRecordingsLow`,locationType:`recordingsLow`},{id:`eventMedia`,labelKey:`recordings.storageMigrationSection.classEventMedia`,locationType:`eventMedia`}],Tt=new Set([`planning`,`sealing`,`pausing`,`moving`,`draining`,`verifying`,`repointing`,`refreshing`,`resuming`]);function Et(){let{t}=U(),n=oe(wt);return n===`pending`?e(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[r(l,{className:`h-4 w-4 animate-spin`}),t(`migration.storageMigrationSection.checkingWhetherStorageMigrationIs`,`Checking whether storage migration is installed…`)]}):n===`unknown`?r(I,{icon:m,title:t(`migration.storageMigrationSection.couldnTCheckWhetherStorage`,`Couldn't check whether storage migration is installed`),description:t(`migration.storageMigrationSection.theCapabilityRegistryDidNot`,`The capability registry did not answer, so this panel has nothing to report either way — it is not a statement that the capability is missing. Reload to ask again.`)}):n===`absent`?r(I,{icon:f,title:t(`migration.storageMigrationSection.storageMigrationNotInstalled`,`Storage migration not installed`),description:t(`migration.storageMigrationSection.theCapabilityRegistryAnsweredNo`,`The capability registry answered: no addon in this cluster provides storage-migration. Once one is deployed, this panel moves recordings, low-res recordings and event media to new storage locations in one coordinated, verified operation.`)}):r(Dt,{})}function Dt(){let{t:n}=U(),i=v(),{data:o}=B({}),[s,c]=a({}),[u,d]=a({}),[p,m]=a(null),[h,g]=a(null),_=t(()=>{let e=new Map;for(let t of o??[]){let n=e.get(t.type);n?n.push(t):e.set(t.type,[t])}return e},[o]),y=t(()=>{let e=new Map;for(let t of o??[]){if(t.enabled===!1)continue;let n=e.get(t.type);n?n.push(t.id):e.set(t.type,[t.id])}let t=new Map;for(let[n,r]of e)r.length===1&&t.set(n,r[0]);return t},[o]),x=ge({},{refetchInterval:2e3}),S=x.data??null,C=S!==null&&Tt.has(S.phase),T=t(()=>{let e={};for(let t of Q){let n=s[t.id];n&&(e[t.id]=n)}return Object.keys(e).length>0?e:void 0},[s]),E=t(()=>{let e={};for(let t of Q){if(!s[t.id])continue;let n=u[t.id]??y.get(t.locationType);n&&(e[t.id]=n)}return Object.keys(e).length>0?e:void 0},[s,u,y]),D=t(()=>({destinations:T??{},...E?{sources:E}:{}}),[T,E]),k=me(D,{enabled:!1,retry:!1}),A=O(),j=ue(),M=async()=>{if(!T)return;g(null);let e=await k.refetch();if(e.error){g(e.error instanceof Error?e.error.message:String(e.error));return}m(e.data??null)},N=async()=>{if(T&&await i({title:n(`migration.storageMigrationSection.startStorageMigration`,`Start storage migration?`),message:n(`migration.storageMigrationSection.copiesTheSelectedClassesFrom`,`Copies the selected classes from the chosen source to the destination, verifies, then either makes the destination the default (if the source was) or disables the source. Safe to re-run if interrupted.`),confirmLabel:n(`migration.storageMigrationSection.startMigration`,`Start migration`),variant:`danger`})){g(null);try{await A.mutateAsync(D),m(null),await x.refetch()}catch(e){g(e instanceof Error?e.message:String(e))}}},P=async()=>{if(S&&await i({title:n(`migration.storageMigrationSection.cancelMigration`,`Cancel migration?`),message:n(`migration.storageMigrationSection.stopsTheInProgressMigration`,`Stops the in-progress migration. Data already moved and verified stays at the destination; anything already repointed is not reverted.`),confirmLabel:n(`migration.storageMigrationSection.cancelMigration2`,`Cancel migration`),variant:`danger`}))try{await j.mutateAsync({jobId:S.jobId}),await x.refetch()}catch{}};return e(`div`,{className:`flex flex-col gap-6`,children:[e(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[e(`h3`,{className:`flex items-center gap-1.5 text-sm font-semibold text-foreground`,children:[r(f,{className:`h-3.5 w-3.5`}),n(`migration.storageMigrationSection.storageMigration`,`Storage migration`)]}),r(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:n(`migration.storageMigrationSection.moveRecordingsLowResRecordings`,`Move recordings, low-res recordings and/or event media from one location to another: copies via the recorder / pipeline-analytics movers, verifies, then either repoints the default (when the source was the default) or disables the source (when it was not). Skip a class with an empty destination.`)}),r(`div`,{className:`mt-3 grid grid-cols-1 gap-3 sm:grid-cols-3`,children:Q.map(t=>{let i=_.get(t.locationType)??[],a=y.get(t.locationType)??``;return e(`div`,{className:`space-y-2`,children:[r(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:n(t.labelKey)}),e(`div`,{className:`space-y-1`,children:[r(`label`,{htmlFor:`migration-from-${t.id}`,className:`text-[10px] text-foreground-subtle`,children:n(`recordings.storageMigrationSection.classFrom`,{label:n(t.labelKey)})}),r(b,{id:`migration-from-${t.id}`,value:u[t.id]??a,onChange:e=>{let n=e.target.value;d(e=>({...e,[t.id]:n}))},disabled:C,className:`w-full`,children:i.map(t=>e(`option`,{value:t.id,children:[t.displayName,t.enabled===!1?` (${n(`recordings.storageMigrationSection.readOnly`)})`:``]},t.id))})]}),e(`div`,{className:`space-y-1`,children:[r(`label`,{htmlFor:`migration-dest-${t.id}`,className:`text-[10px] text-foreground-subtle`,children:n(`recordings.storageMigrationSection.classTo`,{label:n(t.labelKey)})}),e(b,{id:`migration-dest-${t.id}`,value:s[t.id]??``,onChange:e=>{let n=e.target.value;c(e=>({...e,[t.id]:n}))},disabled:C,className:`w-full`,children:[r(`option`,{value:``,children:n(`migration.storageMigrationSection.skip`,`— skip —`)}),i.map(e=>r(`option`,{value:e.id,children:e.displayName},e.id))]})]})]},t.id)})}),h&&r(`p`,{className:`mt-2 text-[11px] text-danger`,children:h}),e(`div`,{className:`mt-3 flex items-center gap-2`,children:[e(V,{variant:`unstyled`,type:`button`,onClick:()=>{M()},disabled:!T||k.isFetching||C,className:`inline-flex items-center gap-1.5 rounded border border-border px-2.5 py-1.5 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover disabled:opacity-50`,children:[k.isFetching&&r(l,{className:`h-3 w-3 animate-spin`}),n(`migration.storageMigrationSection.plan`,`Plan`)]}),e(V,{variant:`unstyled`,type:`button`,onClick:()=>{N()},disabled:!T||A.isPending||C,className:`inline-flex items-center gap-1.5 rounded bg-primary px-2.5 py-1.5 text-xs font-medium text-primary-foreground disabled:opacity-50`,children:[A.isPending&&r(l,{className:`h-3 w-3 animate-spin`}),n(`migration.storageMigrationSection.startMigration`,`Start migration`)]})]}),p&&r(`div`,{className:`mt-3 divide-y divide-border rounded-md border border-border`,children:p.moves.length===0?r(`p`,{className:`px-2.5 py-1.5 text-[11px] text-foreground-subtle`,children:n(`migration.storageMigrationSection.nothingToMoveSelectedDestinations`,`Nothing to move — selected destinations match the current defaults.`)}):p.moves.map(t=>e(`div`,{className:`px-2.5 py-1.5 text-[11px] text-foreground`,children:[t.storageClass,`: `,t.fromLocationId,` → `,t.toLocationId]},`${t.storageClass}-${t.toLocationId}`))}),S&&e(`div`,{className:`mt-4 border-t border-border pt-3`,children:[e(`div`,{className:`flex items-center justify-between`,children:[r(`h4`,{className:`text-xs font-semibold text-foreground`,children:n(`migration.storageMigrationSection.migrationStatus`,`Migration status`)}),C&&e(V,{variant:`unstyled`,type:`button`,onClick:()=>{P()},className:`inline-flex items-center gap-1 rounded border border-border px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10`,children:[r(w,{className:`h-3 w-3`}),n(`common.cancel`,`Cancel`)]})]}),e(`p`,{className:`mt-1 text-xs text-foreground`,children:[n(`migration.storageMigrationSection.phase`,`Phase:`),` `,r(`span`,{className:`font-medium`,children:S.phase}),C&&r(l,{className:`ml-2 inline h-3 w-3 animate-spin text-primary`})]}),S.error&&r(`p`,{className:`mt-1 text-[11px] text-danger`,children:S.error}),S.pausedParticipants.length>0&&e(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:[n(`migration.storageMigrationSection.paused`,`Paused:`),` `,S.pausedParticipants.join(`, `)]}),r(`div`,{className:`mt-2 divide-y divide-border rounded-md border border-border`,children:S.moves.map(e=>r(Ot,{move:e},`${e.storageClass}-${e.fromLocationId}`))})]}),r(kt,{})]}),r(At,{running:C}),r(Mt,{})]})}function Ot({move:t}){let{t:n}=U(),i=t.progress===null?null:St(t.progress);return e(`div`,{className:`px-2.5 py-1.5 text-[11px]`,children:[e(`div`,{className:`flex items-center justify-between`,children:[e(`span`,{className:`text-foreground`,children:[t.storageClass,`: `,t.fromLocationId,` → `,t.toLocationId]}),e(`span`,{className:`text-foreground-subtle`,children:[t.state??n(`common.pending`),t.error?` (${t.error})`:``]})]}),t.progress!==null&&e(`div`,{className:`mt-1 space-y-1`,children:[i!==null&&i.fraction!==null&&r(`div`,{className:`h-1 w-full overflow-hidden rounded bg-border`,children:r(`div`,{className:`h-full bg-primary`,style:{width:`${(i.fraction*100).toFixed(1)}%`}})}),r(`p`,{className:`text-[10px] text-foreground-subtle`,children:Ct(t.progress)})]})]})}function kt(){let{t}=U(),{data:n}=fe({});return!n||n.length===0?null:e(`div`,{className:`mt-4 border-t border-border pt-3`,children:[r(`h4`,{className:`text-xs font-semibold text-foreground`,children:t(`migration.storageMigrationSection.migrationHistory`,`Migration history`)}),r(`div`,{className:`mt-2 divide-y divide-border rounded-md border border-border`,children:n.map(t=>e(`div`,{className:`px-2.5 py-1.5 text-[11px] text-foreground-subtle`,children:[r(`span`,{className:`font-medium text-foreground`,children:t.phase}),` · `,Object.entries(t.destinations).filter(e=>typeof e[1]==`string`).map(([e,t])=>`${e} → ${t}`).join(`, `),` · `,new Date(t.startedAt).toLocaleString()]},t.jobId))})]})}function At({running:t}){let{t:n}=U(),i=v(),o=ae({},{staleTime:1/0,refetchOnWindowFocus:!1}),s=te(),[c,l]=a(null),u=o.data??[];if(u.length===0)return null;let d=async e=>{if(await i({title:n(`migration.storageMigrationSection.drainRemaining`,`Drain remaining {{storageClass}}?`,{storageClass:e.storageClass}),message:`Moves what is still on ${e.fromLocationId} to ${e.toLocationId}. Nothing is paused and no default is changed — this is the second half of a migration, run on its own. It is resumable: cancelling leaves everything readable from both locations.`,confirmLabel:n(`migration.storageMigrationSection.drainRemaining2`,`Drain remaining`),variant:`danger`})){l(null);try{await s.mutateAsync({classes:[e.storageClass]}),await o.refetch()}catch(e){l(e instanceof Error?e.message:String(e))}}};return e(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[e(`div`,{className:`flex items-start justify-between gap-2`,children:[r(`h3`,{className:`text-sm font-semibold text-foreground`,children:n(`migration.storageMigrationSection.leftOnTheOldLocation`,`Left on the old location`)}),e(`div`,{className:`flex shrink-0 items-center gap-2`,children:[r(`span`,{className:`text-[10px] text-foreground-subtle`,children:o.dataUpdatedAt>0?n(`migration.storageMigrationSection.measured`,`Measured {{value1}}`,{value1:new Date(o.dataUpdatedAt).toLocaleTimeString()}):n(`migration.storageMigrationSection.measuredNever`,`Measured — never`)}),r(V,{variant:`unstyled`,type:`button`,onClick:()=>{o.refetch()},disabled:o.isFetching,className:`rounded border border-border px-2 py-1 text-[10px] font-medium text-foreground-subtle hover:bg-surface-hover hover:text-foreground disabled:opacity-50`,children:o.isFetching?n(`migration.storageMigrationSection.counting`,`Counting…`):n(`common.refresh`,`Refresh`)})]})]}),r(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:n(`migration.storageMigrationSection.aMigrationRepointsFirstAnd`,`A migration repoints first and drains behind. If the drain was cancelled, failed, or was interrupted by a restart, the data below is still on the source — readable, but not where the defaults now point. Draining moves it; it changes no default and pauses nothing.`)}),r(`p`,{className:`mt-1 text-[10px] text-foreground-subtle`,children:n(`migration.storageMigrationSection.thisCountIsTakenOn`,`This count is taken on demand: measuring it walks the whole media collection, so it is not refreshed on a timer. Press Refresh after a drain finishes.`)}),c&&r(`p`,{className:`mt-2 text-[11px] text-danger`,children:c}),r(`div`,{className:`mt-2 divide-y divide-border rounded-md border border-border`,children:u.map(i=>e(`div`,{className:`flex items-center justify-between gap-2 px-2.5 py-1.5 text-[11px]`,children:[e(`span`,{className:`text-foreground`,children:[i.storageClass,`: `,i.fromLocationId,` → `,i.toLocationId,r(`span`,{className:`ml-2 text-foreground-subtle`,children:jt(i)})]}),r(V,{variant:`unstyled`,type:`button`,onClick:()=>{d(i)},disabled:t||s.isPending,className:`shrink-0 rounded border border-border px-2 py-1 text-[10px] font-medium text-foreground-subtle hover:bg-surface-hover hover:text-foreground disabled:opacity-50`,children:n(`migration.storageMigrationSection.drainRemaining2`,`Drain remaining`)})]},`${i.storageClass}-${i.fromLocationId}`))})]})}function jt(e){if(e.items===null)return H.t(`recordings.storageMigrationSection.residueUnknown`);let t=e.items.toLocaleString(`en-US`);return e.bytes===null?H.t(`recordings.storageMigrationSection.residueRows`,{count:e.items,items:t}):H.t(`recordings.storageMigrationSection.residueSegments`,{count:e.items,items:t,size:W(e.bytes)})}function Mt(){let{t}=U(),{data:n}=de({},{refetchInterval:2e3}),i=(n??[]).filter(e=>e.migrationJobId===null&&e.job.state===`running`);return i.length===0?null:e(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[r(`h3`,{className:`text-sm font-semibold text-foreground`,children:t(`migration.storageMigrationSection.moversRunningOutsideAMigration`,`Movers running outside a migration`)}),r(`div`,{className:`mt-2 divide-y divide-border rounded-md border border-border`,children:i.map(t=>e(`div`,{className:`px-2.5 py-1.5 text-[11px]`,children:[e(`div`,{className:`text-foreground`,children:[t.lane,`: `,t.job.fromLocationId,` → `,t.job.toLocationId]}),r(`p`,{className:`mt-1 text-[10px] text-foreground-subtle`,children:Ct({filesMoved:t.job.filesMoved,filesTotal:t.job.filesTotal,bytesMoved:t.job.bytesMoved,startedAt:t.job.startedAt,observedAt:t.observedAt})})]},t.job.jobId))})]})}function Nt(){let{t}=U();return e(`div`,{className:`flex flex-col gap-4`,children:[r(_t,{}),r(bt,{}),e(`section`,{children:[r(`h2`,{className:`text-sm font-semibold text-foreground`,children:t(`recordings.recordingsManagementSection.moveStorage`,`Move storage`)}),r(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:t(`recordings.recordingsManagementSection.copyRecordingsLowResRecordings`,`Copy recordings, low-res recordings or event media to a new location, verify, then repoint the default. Applies to every camera.`)}),r(`div`,{className:`mt-3`,children:r(Et,{})})]})]})}o();var Pt=`recorder`,Ft=`recording`;function It(e,t,n){for(let n of e?.sections??[])for(let e of n.fields??[])if(e.key===t&&typeof e.value==`string`)return e.value;return n}function Lt(){let{t:n}=U(),i=s(),{nodes:a}=M(),{data:o,isLoading:c}=z({addonId:Pt,cap:Ft,scope:`cluster`}),u=It(o,`recordingNodeId`,`hub`),d=j({onSuccess:()=>{i.invalidateQueries({queryKey:[[`addonSettings`,`getScopedSettings`]]})}}),f=t(()=>{let e=a.filter(e=>e.isOnline).map(e=>e.id);return[...new Set([`hub`,u,...e])].filter(Boolean)},[a,u]);return e(`div`,{className:`flex flex-col gap-6`,children:[e(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[r(`h3`,{className:`text-sm font-semibold text-foreground`,children:n(`pipeline.clusterRecordingTab.recordingNode`,`Recording node`)}),r(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:n(`pipeline.clusterRecordingTab.theSingleNodeThatRecords`,`The single node that records (continuous & events) and serves playback. Every other node stays inert — no multi-node balancing. Takes effect on addon restart.`)}),e(`div`,{className:`mt-3 flex items-center gap-2`,children:[c?r(l,{className:`h-4 w-4 animate-spin text-foreground-subtle`}):r(b,{wrapperClassName:`inline-block w-auto`,value:u,onChange:e=>{e.target.value!==u&&d.mutate({addonId:Pt,cap:Ft,scope:`cluster`,patch:{recordingNodeId:e.target.value}})},disabled:d.isPending,children:f.map(e=>r(`option`,{value:e,children:e===`hub`?n(`pipeline.clusterRecordingTab.hubDefault`,`hub (default)`):e},e))}),d.isPending&&r(l,{className:`h-4 w-4 animate-spin text-primary`})]}),u!==`hub`&&r(`p`,{className:`mt-2 text-[11px] text-amber-500`,children:r(Me,{i18nKey:`pipeline.clusterRecordingTab.hubOnlyNote`,values:{node:u},components:{b:r(`span`,{className:`font-medium`})}})})]}),e(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[r(`h3`,{className:`mb-1 text-sm font-semibold text-foreground`,children:n(`pipeline.clusterRecordingTab.recordingsFolders`,`Recordings folders`)}),r(`p`,{className:`mb-3 text-[11px] text-foreground-subtle`,children:n(`pipeline.clusterRecordingTab.whereRecordingsAreStoredMulti`,`Where recordings are stored. Multi-location collections — segments are split across the locations of a type. Add a location to grow capacity; mark one default per type.`)}),r(G,{types:[`recordings`,`recordingsLow`]})]})]})}function Rt(e){return e.locationIds!==void 0&&e.locationIds.length>0?e.locationIds:e.locationId===null?[]:[e.locationId]}function zt(e,t){let n=Rt(e);return n.length===0?H.t(`helpers.cameraDisk.defaultRoot`):n.map(e=>t.get(e)??e).join(` + `)}function Bt(e,t,n){if(e.length===0)return null;let r=e[0];if(e.length===1&&r!==void 0)return{label:zt(r,t),exact:!0};if(n===null)return null;let i=e.find(e=>Rt(e).includes(n));return i===void 0?null:{label:zt(i,t),exact:!1}}o();var Vt=[[`recording`]],Ht=[{value:`retention`,labelKey:`recordings.storageSection.pruneRetention`},{value:`quota`,labelKey:`recordings.storageSection.pruneQuota`},{value:`operator`,labelKey:`recordings.storageSection.pruneOperator`}],Ut={ok:`bg-primary`,warn:`bg-amber-500`,critical:`bg-danger`},Wt={ok:`text-foreground-subtle`,warn:`text-amber-500`,critical:`text-danger`};function $(e){return`${String(Math.round(e*100))}%`}function Gt(e){return e==null?`—`:new Date(e).toLocaleString()}function Kt(e,t){let n=e.locationIds??(e.locationId===null?[]:[e.locationId]),r=n.map(e=>t.get(e)).filter(e=>e!==void 0);return r.length>0?r.join(` + `):e.root===void 0?n.length>0?n.join(` + `):H.t(`recordings.storageSection.defaultRoot`):e.root}function qt(){let{t:i}=U(),o=s(),c=v(),[u,d]=a(`retention`),{data:f,isLoading:p}=we({},{refetchOnWindowFocus:!1}),{data:m}=L({isCamera:!0,projection:`slim`}),{data:_}=B({}),y=t(()=>{let e=new Map;for(let t of m??[])e.set(t.id,t.name);return e},[m]),S=t(()=>{let e=new Map;for(let t of _??[])e.set(t.id,t.displayName);return e},[_]),C=t(()=>{let e=_??[];return e.find(e=>e.type===`recordings`&&e.enabled!==!1)?.id??e.find(e=>e.type===`recordings`)?.id??null},[_]),w=t(()=>f?.locations??[],[f?.locations]),T=t(()=>Bt(w,S,C),[w,S,C]),E=t(()=>Ie(w),[w]),O=n(()=>{o.invalidateQueries({queryKey:Vt})},[o]),k=ye({onSuccess:O}),j=_e({onSuccess:O}),M=n(async e=>{await c({title:i(`recordings.storageSection.prune`,`Prune {{label}}?`,{label:y.get(e.deviceId)??`#${String(e.deviceId)}`}),message:i(`recordings.storageSection.appliesTheRetentionPolicyNow`,`Applies the retention policy now (reason: {{reason}}). Footage beyond the policy is permanently deleted.`,{reason:u}),confirmLabel:i(`recordings.storageSection.pruneNow`,`Prune now`),variant:`danger`})&&k.mutate({deviceId:e.deviceId,reason:u})},[c,k,u,y,i]),N=n(async e=>{await c({title:i(`recordings.storageSection.deleteAllFootageFor`,`Delete all footage for {{label}}?`,{label:y.get(e.deviceId)??`#${String(e.deviceId)}`}),message:i(`recordings.storageSection.permanentlyDeletesOfRecordedFootage`,`Permanently deletes {{value1}} of recorded footage for this camera. This cannot be undone.`,{value1:W(e.usedBytes)}),confirmLabel:i(`recordings.storageSection.delete`,`Delete {{value1}}`,{value1:W(e.usedBytes)}),variant:`danger`})&&j.mutate({deviceId:e.deviceId})},[c,j,y,i]),P=t(()=>[{key:`camera`,header:i(`recordings.storageSection.camera`,`Camera`),render:e=>r(`span`,{className:`text-foreground`,children:y.get(e.deviceId)??`#${String(e.deviceId)}`})},{key:`disk`,header:i(`recordings.storageSection.disk`,`Disk`),nowrap:!0,render:()=>T===null?r(`span`,{className:`text-foreground-subtle`,children:`—`}):e(`span`,{className:T.exact?`text-foreground`:`text-foreground-subtle`,title:T.exact?i(`recordings.storageSection.theOnlyRecordingsVolumeOn`,`The only recordings volume on this node — this camera can only be here.`):i(`recordings.storageSection.theRecordingsDefaultThisNode`,`The recordings DEFAULT. This node has several recordings volumes and the per-camera placement is not reported by recording.getStorageUsage, so this is where footage lands by default rather than a per-camera fact.`),children:[T.label,!T.exact&&r(`span`,{className:`ml-1 text-foreground-subtle`,children:i(`recordings.storageSection.default`,`(default)`)})]})},{key:`used`,header:i(`recordings.storageSection.used`,`Used`),align:`right`,nowrap:!0,render:e=>r(`span`,{className:`tabular-nums`,children:W(e.usedBytes)})},{key:`oldest`,header:i(`recordings.storageSection.oldestFootage`,`Oldest footage`),align:`right`,nowrap:!0,render:e=>r(`span`,{className:`tabular-nums text-foreground-subtle`,title:i(`recordings.storageSection.theOldestSegmentTheArchive`,`The oldest segment the ARCHIVE holds for this camera — the per-camera answer to 'is retention actually holding?'.`),children:Gt(e.oldestMs)})},{key:`actions`,header:``,align:`right`,render:t=>e(`div`,{className:`flex items-center justify-end gap-1`,children:[e(V,{variant:`unstyled`,onClick:()=>{M(t)},disabled:k.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-foreground-subtle hover:bg-amber-500/10 hover:text-amber-500 disabled:opacity-50`,title:i(`recordings.storageSection.applyRetentionPolicyNow`,`Apply retention policy now`),children:[r(D,{className:`h-3 w-3`}),i(`recordings.storageSection.prune2`,`Prune`)]}),e(V,{variant:`unstyled`,onClick:()=>{N(t)},disabled:j.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10 disabled:opacity-50`,title:i(`recordings.storageSection.deleteAllFootage`,`Delete all footage`),children:[r(x,{className:`h-3 w-3`}),i(`common.delete`,`Delete`)]})]})}],[y,T,M,N,k.isPending,j.isPending,i]);if(p&&!f)return e(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[r(l,{className:`h-4 w-4 animate-spin`}),i(`recordings.storageSection.loadingStorageUsage`,`Loading storage usage…`)]});if(!f)return r(I,{icon:g,title:i(`recordings.storageSection.noStorageData`,`No storage data`),description:i(`recordings.storageSection.theRecordingNodeHasNot`,`The recording node has not reported any storage usage yet.`)});let F=f.devices.length;return e(`div`,{className:`flex flex-col gap-6`,children:[e(`section`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:[r(h,{label:i(`recordings.storageSection.totalUsed`,`Total used`),icon:r(g,{className:`h-3 w-3`}),footer:`${String(F)} camera${F===1?``:`s`} on ${f.nodeId}`,children:W(f.totalUsedBytes)}),E!==null&&E.severity!==null&&r(h,{label:i(`recordings.storageSection.freeOnRecordingsVolumes`,`Free on recordings volumes`),icon:r(g,{className:`h-3 w-3`}),footer:`across ${String(E.knownVolumes)} volume${E.knownVolumes===1?``:`s`} of ${W(E.totalBytes)}`+(E.unknownVolumes>0?` · ${String(E.unknownVolumes)} did not report capacity`:``),children:r(`span`,{className:`tabular-nums ${Wt[E.severity]}`,children:W(E.freeBytes)})}),w.map(t=>{let n=Fe(t),a=t.locationId??t.root??`default`;return r(h,{label:i(`recordings.storageSection.disk2`,`Disk: {{label}}`,{label:Kt(t,S)}),footer:n===null?`${W(t.usedBytes)} of recordings · volume capacity unknown`:`${W(n.freeBytes)} free of ${W(n.totalBytes)} · ${W(t.usedBytes)} recordings (${$(n.recordingsFraction)})`,children:n===null?r(`span`,{className:`tabular-nums`,children:W(t.usedBytes)}):e(`div`,{className:`flex items-center gap-2`,title:i(`recordings.storageSection.volumeFillEverythingOnThe`,`Volume fill — everything on the disk, not only recordings. Warn at 85%, critical at 95%.`),children:[r(`div`,{className:`h-2 flex-1 overflow-hidden rounded bg-muted`,children:r(`div`,{className:`h-full rounded ${Ut[n.severity]}`,style:{width:$(n.fraction)}})}),r(`span`,{className:`tabular-nums text-xs ${Wt[n.severity]}`,children:$(n.fraction)})]})},a)})]}),e(`section`,{className:`flex items-center gap-2 text-xs`,children:[r(`label`,{htmlFor:`prune-reason`,className:`text-foreground-subtle`,children:i(`recordings.storageSection.pruneReason`,`Prune reason`)}),r(b,{wrapperClassName:`inline-block w-auto`,id:`prune-reason`,value:u,onChange:e=>{let t=Ht.find(t=>t.value===e.target.value);t&&d(t.value)},children:Ht.map(e=>r(`option`,{value:e.value,children:i(e.labelKey)},e.value))})]}),F===0?r(I,{icon:g,title:f.devicesRead===`unavailable`?i(`recordings.storageSection.perCameraUsageUnavailable`,`Per-camera usage unavailable`):i(`recordings.storageSection.noRecordedFootage`,`No recorded footage`),description:f.devicesRead===`unavailable`?i(`recordings.storageSection.thisRecordingNodeHasNo`,`This recording node has no footage ledger, so it refused to answer the per-camera table rather than report what it happens to hold in memory. The disk totals above are unaffected.`):i(`recordings.storageSection.noCameraHasRecordedFootage`,`No camera has recorded footage on this node yet.`)}):r(A,{columns:P,rows:[...f.devices],rowKey:e=>e.deviceId,minWidthPx:480})]})}function Jt(){let{t}=U();return e(`div`,{className:`flex flex-col gap-8`,children:[e(`div`,{children:[r(`h2`,{className:`text-sm font-semibold text-foreground`,children:t(`recordings.recordingsStorageSection.footageOnDisk`,`Footage on disk`)}),r(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:t(`recordings.recordingsStorageSection.whatRecordedFootageOccupiesPer`,`What recorded footage occupies, per camera and per volume, with prune-by-policy and delete-all-footage.`)}),r(`div`,{className:`mt-3`,children:r(qt,{})})]}),e(`div`,{children:[r(`h2`,{className:`text-sm font-semibold text-foreground`,children:t(`recordings.recordingsStorageSection.recordingNodeFolders`,`Recording node & folders`)}),r(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:t(`recordings.recordingsStorageSection.theSingleNodeThatRecords`,`The single node that records and serves playback, and the storage locations footage is written to.`)}),r(`div`,{className:`mt-3`,children:r(Lt,{})})]})]})}function Yt(){let{t:e}=U(),t=je(`/recordings`,{t:e,isAdmin:!0})??{icon:y,title:e(`nav.recordings`,`Recordings`)};return r(Ne,{icon:t.icon,title:t.title,subtitle:e(`recordings.recordedFootageAndTheDurable`,`Recorded footage and the durable event store — what each occupies, where it is written, and the operations that move or reconcile both.`),defaultSection:`storage`,sectionsLabel:`${t.title} sections`,sections:[{id:`storage`,label:e(`recordings.recordings`,`Recordings`),content:r(Jt,{})},{id:`events`,label:e(`recordings.events`,`Events`),content:r(Ze,{})},{id:`cameras`,label:e(`recordings.cameras`,`Cameras`),content:r(Ue,{})},{id:`exports`,label:e(`recordings.export`,`Export`),content:r(ft,{})},{id:`activity`,label:e(`recordings.activity`,`Activity`),content:r(He,{})},{id:`management`,label:e(`recordings.management`,`Management`),content:r(Nt,{})}]})}export{Yt as RecordingsPage};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{C as e,K as t,S as n,V as r,Y as i,et as a}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 o,Fr as s,Ga as c,Mn as l,Nn as u,Ua as d,Ui as f,Za as p,ct as m,dt as h,en as g,pi as ee,ut as _,wt as v}from"./player-overlays-VrMHBBfa.js";import{js as y}from"./client-CBrsD14Q.js";import{a as b,i as x,l as S,o as C}from"./terminal-DU-tvcEm.js";import{$f as w,Ai as T,Ar as E,Fi as D,Jr as te,Kr as O,Li as ne,Ni as k,Ns as re,Op as A,Or as j,Pi as M,Qf as N,Ri as ie,Sr as P,Wf as F,X as I,Y as L,Yr as R,br as z,et as ae,fa as B,ft as V,jf as H,ji as U,jr as oe,ki as W,la as se,ma as G,ri as K,tt as ce,xr as le}from"./src-
|
|
1
|
+
import{C as e,K as t,S as n,V as r,Y as i,et as a}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 o,Fr as s,Ga as c,Mn as l,Nn as u,Ua as d,Ui as f,Za as p,ct as m,dt as h,en as g,pi as ee,ut as _,wt as v}from"./player-overlays-VrMHBBfa.js";import{js as y}from"./client-CBrsD14Q.js";import{a as b,i as x,l as S,o as C}from"./terminal-DU-tvcEm.js";import{$f as w,Ai as T,Ar as E,Fi as D,Jr as te,Kr as O,Li as ne,Ni as k,Ns as re,Op as A,Or as j,Pi as M,Qf as N,Ri as ie,Sr as P,Wf as F,X as I,Y as L,Yr as R,br as z,et as ae,fa as B,ft as V,jf as H,ji as U,jr as oe,ki as W,la as se,ma as G,ri as K,tt as ce,xr as le}from"./src-bJ4Hy4Cl.js";import{t as q}from"./i18n-BFxrpjSx.js";import{t as J}from"./useTranslation-BJr-n0es.js";import{F as ue,i as de,li as fe}from"./index-1bBrNxAK.js";a();function Y({id:t,title:r,icon:i,description:a,actions:s,tone:l=`default`,notice:u=null,onDismissNotice:d,children:f}){return n(j,{headingId:`access-${t}`,title:r,icon:i,actions:s,testId:`access-${t}`,children:e(`div`,{className:`${o} space-y-3`,children:[n(`div`,{className:c(`text-[11px] leading-relaxed`,l===`danger`?`rounded-md border border-danger/30 bg-danger/5 px-3 py-2 text-foreground`:`text-foreground-subtle`),children:a}),u!==null&&n(X,{notice:u,onDismiss:d}),f]})})}var pe={success:{icon:f,line:`border-success/30 text-foreground`,mark:`text-success`},danger:{icon:x,line:`border-danger/40 text-danger`,mark:`text-danger`}};function X({notice:t,onDismiss:r}){let{t:i}=J(),a=pe[t.tone],o=a.icon;return e(`div`,{role:t.tone===`danger`?`alert`:`status`,className:c(`flex items-start gap-2 rounded-md border bg-surface px-3 py-2 text-[11px]`,a.line),children:[n(o,{className:c(`mt-0.5 h-3.5 w-3.5 shrink-0`,a.mark),"aria-hidden":!0}),n(`span`,{className:`min-w-0 flex-1`,children:t.message}),r!==void 0&&n(w,{type:`button`,variant:`ghost`,size:`sm`,icon:v,"aria-label":i(`access.accessSection.dismiss`,`Dismiss`),onClick:r,className:`-my-1 h-5 w-5`})]})}function me(){let{data:e}=H();return t(()=>{let t=new Map;for(let n of e??[])t.set(n.id,n.username);return t},[e])}function he(e,t=null){return e===null?t:{tone:`danger`,message:e}}var ge={active:`access.credentialColumns.statusActive`,expired:`access.credentialColumns.statusExpired`,revoked:`access.credentialColumns.statusRevoked`,current:`access.credentialColumns.statusCurrent`};function _e(e){return q.t(ge[e])}var ve={active:`success`,expired:`warning`,revoked:`default`,current:`info`},ye={current:0,active:1,expired:2,revoked:3};function be(e,t){if(e===null)return t;let n=new Date(e);return Number.isNaN(n.getTime())?`—`:n.toLocaleString()}function xe({status:e}){return n(G,{variant:ve[e],className:`text-[10px]`,children:_e(e)})}function Se({row:t,action:r}){if(!r.isAvailable(t))return null;let i=r.icon,a=r.busyId===t.id;return e(F,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>r.onRun(t),disabled:r.disabled,"aria-label":q.t(`access.credentialColumns.actionOn`,{action:r.label,name:t.name}),className:r.tone===`neutral`?void 0:`text-danger hover:bg-danger/10`,children:[a?n(s,{className:`h-3 w-3 animate-spin`,"aria-hidden":!0}):n(i,{className:`h-3 w-3`,"aria-hidden":!0}),r.label]})}function Ce(t){return[{key:`name`,header:q.t(`access.credentialColumns.name`,`Name`),sortValue:e=>e.name.toLowerCase(),render:t=>e(`div`,{className:`min-w-0 max-w-[18rem]`,children:[n(`div`,{className:`truncate font-medium text-foreground`,title:t.name,children:t.name}),t.detail!==null&&n(`div`,{className:`truncate font-mono text-[10px] text-foreground-subtle`,title:t.detail,children:t.detail})]})},t.hideOwner?null:{key:`owner`,header:q.t(`access.credentialColumns.owner`,`Owner`),sortValue:e=>e.ownerName.toLowerCase(),render:e=>e.ownerName},{key:`kind`,header:q.t(`access.credentialColumns.kindScope`,`Kind / scope`),sortValue:e=>e.kind.toLowerCase(),nowrap:!1,render:t=>e(`div`,{className:`min-w-[8rem] max-w-[16rem]`,children:[n(`div`,{className:`text-foreground`,children:t.kind}),t.scope!==null&&n(`div`,{className:`line-clamp-2 text-[10px] text-foreground-subtle`,title:t.scope,children:t.scope})]})},{key:`status`,header:q.t(`access.credentialColumns.status`,`Status`),sortValue:e=>ye[e.status],render:e=>n(xe,{status:e.status})},{key:`created`,header:q.t(`access.credentialColumns.created`,`Created`),sortValue:e=>e.createdAt,render:e=>n(`span`,{className:`text-foreground-subtle`,children:be(e.createdAt,`—`)})},{key:`lastUsed`,header:q.t(`access.credentialColumns.lastUsed`,`Last used`),sortValue:e=>e.lastUsedAt,render:e=>n(`span`,{className:`text-foreground-subtle`,children:be(e.lastUsedAt,q.t(`access.credentialColumns.never`))})},{key:`expires`,header:q.t(`access.credentialColumns.expires`,`Expires`),sortValue:e=>e.expiresAt,render:e=>n(`span`,{className:`text-foreground-subtle`,children:be(e.expiresAt,t.expiresNone)})},t.action===null?null:{key:`actions`,header:``,align:`right`,notSortableReason:q.t(`access.credentialColumns.actionsHeader`),render:e=>n(`div`,{className:`flex items-center justify-end gap-1`,children:[...t.extraActions??[],t.action].map(t=>t===null?null:n(Se,{row:e,action:t},t.label))})}].filter(e=>e!==null)}a();var Z=6,we={"current-session":`access.bulk.skipCurrentSession`,"not-active":`access.bulk.skipNotActive`};function Te(e){let t=we[e];return t===void 0?e:q.t(t)}function Ee(e,t){return q.t(t.key,{count:e})}function Q(e,t){return q.t(`access.bulk.countOf`,{count:e,noun:Ee(e,t)})}function De(e){let t=new Map;for(let n of e)t.set(n.status,(t.get(n.status)??0)+1);return[...t.entries()].map(([e,t])=>q.t(`access.bulk.statusCount`,{count:t,status:_e(e).toLowerCase()})).join(`, `)}function Oe(e,t){let n=e.slice(0,Z).map(e=>`• ${e.name} — ${e.ownerName}`),r=e.length>Z?[q.t(`access.bulk.previewMore`,{count:e.length-Z})]:[];return[q.t(`access.bulk.previewIntro`,{what:Q(e.length,t),breakdown:De(e)}),``,...n,...r].join(`
|
|
2
2
|
`)}async function ke(e,t,n){let r=String(t.length),i=await e({title:q.t(`access.bulk.confirmTitle`,{what:Q(t.length,n)}),message:Oe(t,n),label:q.t(`access.bulk.confirmLabel`,{expected:r}),placeholder:r,confirmLabel:q.t(`access.bulk.confirmButton`,{expected:r}),variant:`danger`,validate:e=>e.trim()===r?null:q.t(`access.bulk.confirmMismatch`,{expected:r,noun:Ee(2,n)})});return i!==null&&i.trim()===r}function Ae(e,t){let n=_(),r=A.auth.revokeCredentials.useMutation(),[a,o]=i(null);return{run:async i=>{if(i.length===0||!await ke(n,i,e))return!1;o(null);try{let t=await r.mutateAsync({ids:i.map(e=>e.id),confirmCount:i.length}),n=t.skipped.map(e=>Te(e.reason));return o({tone:`success`,message:n.length>0?q.t(`access.bulk.revokedSkipped`,{what:Q(t.revoked.length,e),count:n.length,reasons:[...new Set(n)].join(`, `)}):q.t(`access.bulk.revoked`,{what:Q(t.revoked.length,e)})}),!0}catch(e){return o({tone:`danger`,message:q.t(`access.bulk.revokeFailed`,{error:e instanceof Error?e.message:q.t(`access.bulk.requestFailed`)})}),!1}finally{t()}},busy:r.isPending,outcome:a,dismiss:()=>o(null)}}function je(e,t,n){let r=_(),[a,o]=i(!1),[s,c]=i(null);return{run:async i=>{if(i.length===0||!await ke(r,i,e))return!1;c(null),o(!0);let a=[],s=0;for(let e of i)try{await t(e.id),s+=1}catch(t){a.push(`${e.name}: ${t instanceof Error?t.message:q.t(`access.bulk.requestFailed`)}`)}return o(!1),n(),a.length===0?(c({tone:`success`,message:q.t(`access.bulk.revoked`,{what:Q(s,e)})}),!0):(c({tone:`danger`,message:q.t(a.length>3?`access.bulk.eachPartialMore`:`access.bulk.eachPartial`,{what:Q(s,e),count:a.length,details:a.slice(0,3).join(`; `)})}),s>0)},busy:a,outcome:s,dismiss:()=>c(null)}}a();var Me={searchText:e=>[e.name,e.detail??``,e.ownerName,e.kind,e.scope??``],facetGroups:[{id:`status`,value:e=>e.status},{id:`owner`,value:e=>e.ownerName},{id:`kind`,value:e=>e.kind}]},Ne={status:`access.credentialTable.groupStatus`,owner:`access.credentialTable.groupOwner`,kind:`access.credentialTable.groupKind`},Pe=e=>e.status!==`current`,Fe=[`active`,`current`];function Ie({rows:r,label:a,isLoading:o,loadError:c,emptyText:l,hideOwner:u=!1,expiresNone:d,action:f,extraActions:p,bulk:m,defaultStatus:h=Fe}){let{t:g}=J(),[ee]=i(()=>h.length===0?{search:``,facets:[]}:{search:``,facets:[],groups:{status:[...h]}}),_=z(r,Me,ee),[v,y]=i(()=>new Set),b=d??g(`access.credentialColumns.never`),x=t(()=>Ce({hideOwner:u,expiresNone:b,action:f??null,...p===void 0?{}:{extraActions:p}}),[u,b,f,p,g]),S=t(()=>m===void 0?()=>!1:e=>Pe(e)&&m.isSelectable(e),[m]),C=t(()=>_.rows.filter(e=>v.has(e.id)&&S(e)),[_.rows,v,S]);return o?e(`div`,{className:`flex items-center gap-2 py-4 text-xs text-foreground-subtle`,children:[n(s,{className:`h-3.5 w-3.5 animate-spin`,"aria-hidden":!0}),g(`access.credentialTable.loading`,{label:a})]}):c===null?e(`div`,{className:`space-y-3`,children:[n(le,{state:_.state,facets:_.facets,groups:_.groups.filter(e=>!(u&&e.id===`owner`)).map(e=>({...e,label:Ne[e.id]===void 0?e.id:g(Ne[e.id]),...e.id===`status`?{facetLabel:e=>_e(e)}:{}})),labels:{searchPlaceholder:g(`access.credentialTable.searchPlaceholder`,{label:a}),searchLabel:g(`access.credentialTable.searchLabel`,{label:a}),facetsLabel:g(`access.credentialTable.facetsLabel`,{label:a}),clearLabel:g(`access.credentialTable.clearFilters`)},onSearch:_.setSearch,onToggleFacet:_.toggleFacet,onToggleGroupFacet:_.toggleGroupFacet,onClear:_.clear}),m!==void 0&&n(Le,{bulk:m,shown:_.rows.filter(S),targets:C,onSelect:y}),n(E,{columns:x,rows:_.rows,rowKey:e=>e.id,minWidthPx:u?760:860,maxBodyHeight:oe,defaultSort:{columnKey:`created`,dir:`desc`},pageSize:25,paginationLabels:{navLabel:g(`access.credentialTable.pagesLabel`,{label:a}),previous:g(`access.credentialTable.previousPage`),next:g(`access.credentialTable.nextPage`),range:(e,t,n)=>g(`access.credentialTable.range`,{from:e,to:t,total:n})},emptyMessage:_.active?g(`access.credentialTable.noMatchTheFilters`,`No {{label}} match the filters.`,{label:a}):l,rowClassName:e=>e.status===`revoked`||e.status===`expired`?`opacity-70`:void 0,...m===void 0?{}:{selection:{selected:v,onChange:y,isSelectable:S,rowLabel:e=>g(`access.credentialTable.rowLabel`,{name:e.name,owner:e.ownerName}),pageLabel:g(`access.credentialTable.pageLabel`,{noun:Ee(1,m.noun)})}}})]}):n(B,{title:g(`access.credentialTable.couldNotLoad`,`Could not load {{label}}`,{label:a}),message:c})}function Le({bulk:t,shown:r,targets:i,onSelect:a}){let{t:o}=J(),{revoke:c,noun:l}=t,u=(t.quickSelect??[]).map(e=>({...e,rows:r.filter(e.match)})).filter(e=>e.rows.length>0),d=async()=>{await c.run(i)&&a(new Set)};return e(`div`,{className:`flex flex-wrap items-center gap-2`,"data-testid":`bulk-bar`,children:[r.length>0&&n(F,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>a(new Set(r.map(e=>e.id))),children:o(`access.credentialTable.selectAllShown`,{count:r.length})}),u.map(t=>e(F,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>a(new Set(t.rows.map(e=>e.id))),children:[t.label,` (`,String(t.rows.length),`)`]},t.label)),i.length>0&&e(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[n(`span`,{className:`text-[11px] tabular-nums text-foreground`,"aria-live":`polite`,children:o(`access.credentialTable.selectedLabel`,{what:Q(i.length,l)})}),e(F,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>a(new Set),children:[n(v,{className:`h-3 w-3`,"aria-hidden":!0}),o(`access.credentialTable.clearSelection`,`Clear selection`)]}),e(F,{type:`button`,variant:`danger`,size:`sm`,disabled:c.busy,onClick:()=>void d(),children:[c.busy?n(s,{className:`h-3 w-3 animate-spin`,"aria-hidden":!0}):n(g,{className:`h-3 w-3`,"aria-hidden":!0}),o(`access.credentialTable.revoke`,{what:Q(i.length,l)})]})]})]})}var Re=(e,t)=>t===null?`—`:e.get(t)??t;function ze(e,t){return e!=null&&e<=t?`expired`:`active`}function Be(e,t,n){return{id:e.id,name:n.client(e.client),detail:e.ip,ownerId:e.userId,ownerName:Re(t,e.userId),kind:n.method(e.method),scope:null,status:e.current?`current`:`active`,createdAt:e.createdAt,lastUsedAt:e.lastUsedAt,expiresAt:e.expiresAt}}function Ve(e,t){return{id:e.id,name:e.integrationId,detail:null,ownerId:e.userId,ownerName:e.username,kind:e.integrationId,scope:t,status:e.revokedAt===null?`active`:`revoked`,createdAt:e.createdAt,lastUsedAt:e.lastUsedAt,expiresAt:null}}var He=`All permissions`,Ue=`View link`,We=`Scoped`,Ge={"grid-view":`Grid`,"events-view":`Events`};function Ke(e,t){return e.map(e=>t.get(e)??`#${String(e)}`).join(`, `)}function qe(e){return e!==`*`&&e.type===`share-view`&&`grant`in e}function Je(e,t,n){return e===`*`?He:qe(e)?`${`${Ge[e.grant.kind]} view${e.grant.talk===!0?` + talk`:``}`}: ${Ke(e.grant.deviceIds,t)}`:n(e)}function Ye(e){return e.includes(`*`)?He:e.some(qe)?Ue:We}function Xe(e,t,n,r){return{id:e.id,name:e.label,detail:null,ownerId:e.subjectId,ownerName:Re(t,e.subjectId),kind:Ye(e.scopes),scope:n,status:e.revokedAt===null?ze(e.expiresAt,r):`revoked`,createdAt:e.createdAt,lastUsedAt:e.lastUsedAt,expiresAt:e.expiresAt}}function Ze(e){return`${e.provider}\u0000${e.subject}`}function Qe(e,t){return{id:Ze(e),name:e.label??e.subject,detail:e.issuer,ownerId:e.userId,ownerName:Re(t,e.userId),kind:e.provider,scope:null,status:`active`,createdAt:e.linkedAt,lastUsedAt:null,expiresAt:null}}var $e=40,et=[{test:/Electron\//,name:`CamStack desktop`},{test:/Edg(e|A|iOS)?\//,name:`Edge`},{test:/OPR\/|Opera/,name:`Opera`},{test:/Firefox\/|FxiOS\//,name:`Firefox`},{test:/Chrome\/|CriOS\//,name:`Chrome`},{test:/Version\/[\d.]+.*Safari\//,name:`Safari`}],tt=[{test:/iPhone/,name:`iPhone`},{test:/iPad/,name:`iPad`},{test:/Android/,name:`Android`},{test:/Mac OS X|Macintosh/,name:`macOS`},{test:/Windows/,name:`Windows`},{test:/CrOS/,name:`ChromeOS`},{test:/Linux/,name:`Linux`}],nt=[{test:/CFNetwork\/.*Darwin\//,name:`CamStack app on iOS`},{test:/^okhttp\//i,name:`CamStack app on Android`},{test:/^(node|undici)\b/i,name:`Script (Node.js)`},{test:/^curl\//i,name:`curl`}];function rt(e,t){return e.find(e=>e.test.test(t))?.name??null}function it(e){return e.length<=$e?e:`${e.slice(0,$e)}…`}function at(e){if(e===null||e.trim().length===0)return{label:q.t(`helpers.sessionClient.unknownDevice`),raw:null};let t=e.trim(),n=rt(nt,t);if(n!==null)return{label:n,raw:t};let r=rt(et,t),i=rt(tt,t);return r!==null&&i!==null?{label:q.t(`helpers.sessionClient.browserOnSystem`,{browser:r,system:i}),raw:t}:r===null?{label:it(t),raw:t}:{label:r,raw:t}}var ot={password:`helpers.sessionClient.method.password`,passkey:`helpers.sessionClient.method.passkey`,sso:`helpers.sessionClient.method.sso`,handoff:`helpers.sessionClient.method.handoff`,"cli-approval":`helpers.sessionClient.method.cliApproval`,exchange:`helpers.sessionClient.method.exchange`};function st(e){let t=ot[e];return t===void 0?e:q.t(t)}function ct(e){if(e==null)return`—`;let t=new Date(e);return Number.isNaN(t.getTime())?`—`:t.toLocaleString()}function lt({token:t,label:r,onClose:i}){let{t:a}=J();return n(W,{open:!0,onOpenChange:e=>!e&&i(),children:e(U,{width:`md`,scroll:`body`,children:[n(M,{children:n(D,{children:a(`auth.tokenModals.token`,`Token: {{label}}`,{label:r})})}),e(T,{className:`space-y-3`,children:[n(`div`,{className:`rounded-md border border-warning/30 bg-warning/10 px-3 py-2 text-xs text-warning`,children:a(`auth.tokenModals.copyThisTokenNowOnce`,`Copy this token now. Once you close this dialog the secret cannot be displayed again.`)}),n(`div`,{className:`select-all break-all rounded-md border border-border bg-background p-2 font-mono text-[11px] text-foreground`,children:t})]}),e(k,{children:[n(P,{value:t,label:a(`common.copy`,`Copy`),srLabel:`token`}),n(F,{type:`button`,variant:`primary`,size:`sm`,onClick:i,children:a(`auth.tokenModals.done`,`Done`)})]})]})})}var ut={token:`newToken`,scoped:`newScoped`,admin:`newAdmin`};a();var dt=80,$=86400,ft=[{value:`1`,seconds:$},{value:`7`,seconds:7*$},{value:`30`,seconds:30*$},{value:`90`,seconds:90*$},{value:`never`,seconds:`never`}],pt=[y.Camera],mt=64,ht={type:`capability`,target:``,access:[`view`,`create`]};function gt({open:a,users:o,onClose:c,onSubmit:f,submitting:m,formError:g,awaitingProof:_}){let{t:v}=J(),y=p(),{user:b}=ue(),x=b?.isAdmin===!0,C=x?null:b?.scopes??[],[w,T]=i(`scopes`),[E,D]=i(b?.id??``),[k,re]=i(``),[A,j]=i([ht]),[M,P]=i([]),[z,ae]=i(`grid-view`),[B,V]=i(!1),[H,U]=i(`30`);r(()=>{a||(T(`scopes`),D(b?.id??``),re(``),j([ht]),P([]),ae(`grid-view`),V(!1),U(`30`))},[a,b?.id]),r(()=>{w!==`view-link`&&H===`never`&&U(`30`)},[w,H]);let oe=t(()=>ft.filter(e=>e.seconds!==`never`||w===`view-link`).map(e=>({value:e.value,label:e.seconds===`never`?v(`access.createTokenModal.never`,`Never (until revoked)`):v(`access.createTokenModal.days`,{count:Number(e.value)})})),[w,v]),W=k.trim(),G=w===`scopes`?I(A,y):null,le=[...M],q=ft.find(e=>e.value===H)?.seconds??30*$,de=()=>w===`all`?[`*`]:w===`view-link`?[{type:`share-view`,grant:{kind:z,deviceIds:le,...B?{talk:!0}:{}}}]:A,Y=W.length>0&&W.length<=dt&&!m&&!_&&(w===`all`?x:w===`view-link`?le.length>0:A.length>0&&G===null),pe=()=>{if(!Y)return;let e=x&&w!==`all`&&E!==``&&E!==b?.id;f({scopes:de(),expiresIn:q,label:W,...e?{subjectId:E}:{}})},X=w===`all`,me=X?u:l;return n(ce,{open:a,onClose:c,title:v(`access.createTokenModal.createToken`,`Create token`),icon:X?u:S,error:g,width:`md`,testId:`create-token-dialog`,footer:e(F,{type:`button`,variant:X?`danger`:`primary`,size:`sm`,onClick:pe,disabled:!Y,"data-testid":`create-token-submit`,children:[m||_?n(s,{className:`h-3.5 w-3.5 animate-spin`,"aria-hidden":!0}):n(me,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),v(`access.createTokenModal.issueToken`,`Issue token`)]}),children:e(`div`,{className:`space-y-3`,children:[e(`div`,{className:`space-y-1`,children:[n(K,{children:v(`access.createTokenModal.whatItMayDo`,`What it may do`)}),n(O,{appearance:`pills`,value:w,onValueChange:e=>{(e===`scopes`||e===`view-link`||e===`all`)&&T(e)},children:e(te,{"aria-label":v(`access.createTokenModal.whatItMayDo`,`What it may do`),children:[e(R,{value:`scopes`,"data-testid":`token-reach-scopes`,children:[n(l,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),v(`access.createTokenModal.reachScopes`,`Scopes`)]}),e(R,{value:`view-link`,"data-testid":`token-reach-view-link`,children:[n(ee,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),v(`access.createTokenModal.reachViewLink`,`View link`)]}),x?e(R,{value:`all`,"data-testid":`token-reach-all`,children:[n(u,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),v(`access.createTokenModal.reachAll`,`All permissions`)]}):null]})})]}),X?n(`div`,{className:`space-y-1 rounded-md border border-danger/30 bg-danger/5 px-3 py-2 text-[11px] leading-relaxed text-foreground`,"data-testid":`admin-token-warning`,children:n(`p`,{children:n(fe,{i18nKey:`auth.adminTokenNoticeShort`,components:{strong:n(`strong`,{})}})})}):null,x&&w!==`all`&&o.length>1?e(`div`,{className:`space-y-1`,children:[n(K,{htmlFor:`token-user`,children:v(`access.createTokenModal.onBehalfOfUser`,`On behalf of user`)}),n(h,{id:`token-user`,value:E,onChange:e=>D(e.target.value),options:o.map(e=>({value:e.id,label:e.username}))})]}):null,e(`div`,{className:`space-y-1`,children:[n(K,{htmlFor:`token-name`,children:v(`access.createTokenModal.label`,`Label`)}),n(N,{id:`token-name`,value:k,maxLength:dt,required:!0,onChange:e=>re(e.target.value),placeholder:w===`view-link`?`kitchen-wall`:`nightly-backup`,autoFocus:!0})]}),w===`scopes`?e(`div`,{className:`space-y-1`,children:[n(K,{children:v(`access.createTokenModal.scopes`,`Scopes`)}),n(L,{value:A,onChange:j,clampToParent:C}),G&&n(`p`,{className:`text-[10px] text-danger`,children:G}),n(`p`,{className:`text-[10px] text-foreground-subtle`,children:v(`access.createTokenModal.eachScopePicksACap`,`Each scope picks a (cap or addon) target + one or more access flavours. The token can access ONLY what's listed.`)})]}):null,w===`view-link`?e(`div`,{className:`space-y-2`,"data-testid":`token-view-link`,children:[e(`div`,{className:`space-y-1`,children:[n(K,{htmlFor:`token-view-cameras`,children:v(`access.createTokenModal.cameras`,`Cameras`)}),n(se,{id:`token-view-cameras`,multiple:!0,pick:`device`,noun:`camera`,fixedTypes:pt,maxItems:mt,recentKey:`token-view-cameras`,testId:`token-view-cameras`,value:ie(M),onChange:e=>P(ne(e))})]}),e(`div`,{className:`space-y-1`,children:[n(K,{htmlFor:`token-view-kind`,children:v(`access.createTokenModal.viewKind`,`Shows`)}),n(h,{id:`token-view-kind`,value:z,onChange:e=>ae(e.target.value===`events-view`?`events-view`:`grid-view`),options:[{value:`grid-view`,label:v(`access.createTokenModal.viewGrid`,`Live grid`)},{value:`events-view`,label:v(`access.createTokenModal.viewEvents`,`Events`)}]})]}),z===`grid-view`?e(`label`,{className:`flex items-start gap-2 text-sm text-foreground`,children:[n(d,{className:`mt-0.5`,checked:B,onChange:e=>V(e.target.checked),"data-testid":`token-view-talk`}),n(`span`,{children:v(`access.createTokenModal.talk`,`Allow talk-back on these cameras`)})]}):null]}):null,e(`div`,{className:`space-y-1`,children:[n(K,{htmlFor:`token-lifetime`,children:v(`access.createTokenModal.expires`,`Expires after`)}),n(h,{id:`token-lifetime`,value:H,onChange:e=>U(e.target.value),options:oe})]})]})})}a();var _t={key:`access.nouns.token`};function vt(e){return typeof e==`object`&&!!e&&`kind`in e}function yt(e,t){let n=e.access===void 0?``:` [${e.access.join(`, `)}]`;return e.type===`device`?`device:[${vt(e.selector)?V(e.selector,t):`?`}]${n}`:e.type===`addon-routes`?`${t(`access.tokensSection.everyAddonRoutes`,`every addon's routes`)}${n}`:`${e.type}:${e.target??``}${n}`}function bt({headerOwnsCreate:a=!1,createRequested:o=!1,onCreateConsumed:s,ownOnly:c=!1}){let{t:l}=J(),u=p(),{user:d}=ue(),f=m(),h=A.useUtils(),ee=me(),{data:_}=H(),v=t(()=>_??[],[_]),{data:y}=re({}),b=t(()=>{let e=new Map;for(let t of y??[])e.set(t.id,t.name);return e},[y]),x=A.auth.listTokens.useQuery(void 0),{requestProof:C,dialog:w}=de(`Creating a token with all permissions`),{state:T,openNew:E,close:D}=ae({newKey:ut.token}),[te,O]=i(null),[ne,k]=i(null),[j,M]=i(!1),[N,ie]=i(null),[P,I]=i(null);r(()=>{o&&(E(),s?.())},[o,E,s]);let L=()=>{h.auth.listTokens.invalidate(),h.auth.listAuthAudit.invalidate()},R=A.auth.mintToken.useMutation({onSuccess:({token:e,record:t})=>{L(),D(),k(null),M(!1),ie({token:e,label:t.label})},onError:e=>{k(`Create failed: ${e.message}`),M(!1)}}),z=A.auth.revokeToken.useMutation({onSuccess:()=>{I(null),L()},onError:e=>{I(null),O(`Revoke failed: ${e.message}`)}}),B=Ae(_t,L),V=Date.now(),U=(x.data??[]).filter(e=>!c||e.subjectId===d?.id).map(e=>Xe(e,ee,e.scopes.includes(`*`)?null:e.scopes.map(e=>Je(e,b,e=>yt(e,u))).join(`, `),V)),oe=async e=>{await f({title:l(`access.tokensSection.revoke`,`Revoke "{{name}}"?`,{name:e.name}),message:e.kind===`All permissions`?l(`access.tokensSection.everyScriptUsingItLoses`,`Every script using it loses access immediately. This cannot be undone.`):l(`access.tokensSection.stopsWorking`,`Whoever holds it loses access immediately. This cannot be undone.`),confirmLabel:l(`access.tokensSection.revoke2`,`Revoke`),variant:`danger`})&&(O(null),I(e.id),z.mutate({id:e.id}))},W=e=>{(async()=>{O(null),k(null);let t;if(e.scopes.includes(`*`)){M(!0);let e=await C();if(M(!1),e===null)return;t=e}R.mutate({scopes:[...e.scopes],expiresIn:e.expiresIn,label:e.label,...e.subjectId===void 0?{}:{subjectId:e.subjectId},...t===void 0?{}:{reauthToken:t}})})()};return e(`div`,{"data-testid":`tokens`,children:[w,n(Y,{notice:he(te,B.outcome),onDismissNotice:()=>{O(null),B.dismiss()},id:c?`my-tokens`:`tokens`,title:c?l(`access.tokensSection.myTokens`,`My tokens`):l(`access.tokensSection.tokens`,`Tokens`),icon:S,actions:a?void 0:e(F,{size:`sm`,type:`button`,"data-testid":`tokens-new`,onClick:E,children:[n(S,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),l(`system.access.newToken`,`New token`)]}),description:l(`access.tokensSection.oneFormat`,`Every token is its scopes: a few permissions for a script, all permissions for an admin script, or a view of some cameras for a share link. Revoking one stops it on its next use.`),children:n(Ie,{rows:U,label:l(`common.tokensLabel`),isLoading:x.isLoading,loadError:x.isError?x.error?.message??`Request failed`:null,emptyText:l(`access.tokensSection.noTokens`,`No tokens.`),action:{label:l(`access.tokensSection.revoke2`,`Revoke`),icon:g,isAvailable:e=>e.status===`active`,onRun:e=>void oe(e),busyId:P,disabled:B.busy||P!==null},...d?.isAdmin===!0?{bulk:{revoke:B,noun:_t,isSelectable:e=>e.status===`active`}}:{}})}),n(gt,{open:T.mode===`new`,users:v.map(e=>({id:e.id,username:e.username})),onClose:()=>{D(),k(null),M(!1)},submitting:R.isPending,formError:ne,awaitingProof:j,onSubmit:W}),N&&n(lt,{token:N.token,label:N.label,onClose:()=>ie(null)})]})}var xt=864e5,St={qr:`QR (by an admin)`,self:`Self-enrolled`},Ct={ios:`iOS`,android:`Android`,web:`Web`,other:`Other`};function wt(e){return e.status===`revoked`}function Tt(e){return e.status!==`revoked`}function Et(e,t=`—`){if(e===null)return t;let n=new Date(e);return Number.isNaN(n.getTime())?t:n.toLocaleString()}function Dt(e,t){return e===null||Number.isNaN(e)?null:Math.floor((e-t)/xt)}function Ot(e,t){let n=Dt(e,t);return n===null?`unknown`:n<0?`expired`:n<30?`soon`:`ok`}function kt(e,t){let n=Dt(e,t);return n===null?q.t(`helpers.certificateModel.unknown`):n===0?q.t(`helpers.certificateModel.today`):n>0?q.t(`helpers.certificateModel.inDays`,{count:n}):q.t(`helpers.certificateModel.daysAgo`,{count:-n})}function At(e){if(e===null)return null;let t=Date.parse(e);return Number.isNaN(t)?null:t}function jt(e){return e===null||e.length===0?`—`:e.length<=17?e:`${e.slice(0,8)}…${e.slice(-8)}`}function Mt(e){return e.length<=10?e:`${e.slice(0,10)}…`}function Nt(e){if(!e.online)return{allowed:!1,reason:q.t(`helpers.certificateModel.nodeOffline`)};if(e.isHub&&e.https.kind===`served`){if(e.https.status.mode===`uploaded`)return{allowed:!1,reason:q.t(`helpers.certificateModel.uploadedCert`)};if(e.https.status.mode===`disabled`)return{allowed:!1,reason:q.t(`helpers.certificateModel.tlsDisabled`)}}return{allowed:!0,reason:null}}var Pt={prepare:`helpers.certificateModel.stage.prepare`,issue:`helpers.certificateModel.stage.issue`,install:`helpers.certificateModel.stage.install`,reconnect:`helpers.certificateModel.stage.reconnect`,confirm:`helpers.certificateModel.stage.confirm`};function Ft(e){if(e.ok)return{tone:`success`,message:q.t(`helpers.certificateModel.renewed`,{nodeId:e.nodeId,serial:Mt(e.newSerial)})};let t=e.keptPreviousLeaf?q.t(`helpers.certificateModel.keptPrevious`):q.t(`helpers.certificateModel.maybeNoCert`);return{tone:`danger`,message:q.t(`helpers.certificateModel.renewalFailed`,{nodeId:e.nodeId,stage:q.t(Pt[e.stage]),reason:e.reason,kept:t})}}function It(e,t){let n=Math.max(0,e-t),r=Math.ceil(n/1e3),i=Math.floor(r/60),a=r%60;return{expired:n===0,label:`${String(i)}:${String(a).padStart(2,`0`)}`}}var Lt=11;function Rt(e,t){let n=e.slice(0,Lt);return t===null?n:`${n} · ${t}`}function zt(e){return{id:e.id,name:e.deviceName,detail:Rt(e.fingerprint,e.lastUsedFrom),ownerId:e.userId,ownerName:e.username??e.userId,kind:Ct[e.platform],scope:St[e.enrolledVia],status:e.status,createdAt:e.issuedAt,lastUsedAt:e.lastUsedAt,expiresAt:e.expiresAt}}function Bt(e,t){return{id:e.id,name:e.deviceName,detail:null,ownerId:null,ownerName:t,kind:Ct[e.platform],scope:null,status:e.status,createdAt:e.issuedAt,lastUsedAt:e.lastUsedAt,expiresAt:e.expiresAt}}function Vt({sessions:t,isLoading:r,loadError:i,emptyText:a,onRevoke:o,revokingId:c}){let{t:l}=J();return r?e(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[n(s,{className:`h-3.5 w-3.5 animate-spin`}),l(`auth.sessionsList.loadingSessions`,`Loading sessions…`)]}):i===null?t.length===0?n(`div`,{className:`rounded border border-dashed border-border px-3 py-4 text-xs text-foreground-subtle text-center`,children:a}):n(`ul`,{className:`divide-y divide-border rounded-md border border-border`,children:t.map(e=>n(Ht,{session:e,revoking:c===e.id,onRevoke:()=>o(e)},e.id))}):e(`div`,{className:`text-[11px] text-danger`,children:[l(`auth.sessionsList.couldNotLoadSessions`,`Could not load sessions:`),` `,i]})}function Ht({session:t,revoking:r,onRevoke:i}){let{t:a}=J(),o=at(t.client);return e(`li`,{"data-testid":`session-row`,className:`flex items-start gap-3 px-3 py-2 text-xs`,children:[n(b,{className:`h-3.5 w-3.5 mt-0.5 shrink-0 text-foreground-subtle`}),e(`div`,{className:`flex-1 min-w-0 space-y-0.5`,children:[e(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[n(`span`,{className:`font-medium text-foreground truncate`,title:o.raw??void 0,children:o.label}),t.current&&n(`span`,{className:`rounded bg-primary/10 px-1.5 py-0.5 text-[10px] font-medium text-primary`,children:a(`auth.sessionsList.thisDevice`,`This device`)})]}),e(`div`,{className:`flex flex-wrap gap-x-3 text-[11px] text-foreground-subtle`,children:[n(`span`,{children:st(t.method)}),n(`span`,{className:`font-mono`,children:t.ip??a(`auth.sessionsList.ipUnknown`,`IP unknown`)}),n(`span`,{children:a(`auth.sessionsList.lastActive`,{when:ct(t.lastUsedAt)})}),n(`span`,{children:a(`auth.sessionsList.expires`,{when:ct(t.expiresAt)})})]})]}),!t.current&&e(F,{variant:`unstyled`,onClick:i,disabled:r,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] text-danger hover:bg-danger/10 disabled:opacity-50`,children:[r?n(s,{className:`h-3 w-3 animate-spin`}):n(C,{className:`h-3 w-3`}),a(`auth.sessionsList.signOut`,`Sign out`)]})]})}export{Be as C,Y as D,je as E,he as O,Ve as S,Ae as T,at as _,Tt as a,Ze as b,kt as c,Et as d,Nt as f,ut as g,bt as h,wt as i,me as k,Ft as l,Mt as m,zt as n,It as o,jt as p,Bt as r,At as s,Vt as t,Ot as u,st as v,Ie as w,Qe as x,ct as y};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as e,S as t,Y as n,et as r}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Ua as i,Wa as a,dt as o}from"./player-overlays-VrMHBBfa.js";import{Qf as s,Wf as c,_ as l,ni as u,q as d}from"./src-PRnJiArs.js";import{Mt as f,W as p,tt as m}from"./index-DqWOkhIM.js";r();function h({title:n,children:r}){return e(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[t(`div`,{className:`border-b border-border px-4 py-2.5`,children:t(`h2`,{className:`text-xs font-semibold text-foreground uppercase tracking-wider`,children:n})}),t(`div`,{className:`p-4`,children:r})]})}function g({name:n,cssVar:r,hex:i}){return e(`div`,{className:`flex flex-col items-center gap-1.5`,children:[t(`div`,{className:`h-10 w-10 rounded-lg border border-border shadow-inner`,style:{backgroundColor:r?`var(${r})`:i}}),t(`span`,{className:`text-[10px] text-foreground-subtle text-center leading-tight`,children:n})]})}var _={sections:[{id:`demo`,title:`Demo Fields`,columns:2,fields:[{key:`name`,type:`text`,label:`Name`,placeholder:`Enter name`},{key:`count`,type:`number`,label:`Count`,min:0,max:100,unit:`items`},{key:`enabled`,type:`boolean`,label:`Enabled`},{key:`mode`,type:`select`,label:`Mode`,options:[{value:`a`,label:`Alpha`},{value:`b`,label:`Beta`}]},{key:`tags`,type:`tags`,label:`Tags`,span:2,suggestions:[`camera`,`zone`,`alert`]},{key:`confidence`,type:`slider`,label:`Confidence`,min:0,max:100,step:5,unit:`%`,span:2},{key:`info`,type:`info`,label:`Note`,content:`This is an informational message for the user.`,variant:`info`}]}]};function v(){let[r,v]=n(!1),[b,x]=n(null),[S,C]=n({name:`Example`,count:10,enabled:!0,mode:`a`,tags:[`camera`],confidence:60});return e(`div`,{className:`p-6 space-y-6 max-w-5xl mx-auto`,children:[e(`div`,{className:`mb-6`,children:[t(`h1`,{className:`text-xl font-bold text-foreground`,children:`Component Showroom`}),t(`p`,{className:`text-sm text-foreground-subtle mt-1`,children:`All UI components at a glance`})]}),t(h,{title:`Typography`,children:e(`div`,{className:`space-y-3`,children:[t(`h1`,{className:`text-2xl font-bold text-foreground`,children:`Heading 1 — Display title`}),t(`h2`,{className:`text-xl font-semibold text-foreground`,children:`Heading 2 — Section title`}),t(`h3`,{className:`text-base font-semibold text-foreground`,children:`Heading 3 — Card title`}),t(`h4`,{className:`text-sm font-semibold text-foreground`,children:`Heading 4 — Sub-section`}),t(`p`,{className:`text-sm text-foreground`,children:`Body text — Regular paragraph content goes here. It uses the foreground color.`}),t(`p`,{className:`text-sm text-foreground-subtle`,children:`Subtle text — Secondary/descriptive text with reduced emphasis.`}),t(`p`,{className:`text-xs text-foreground-subtle uppercase tracking-wider font-semibold`,children:`Label / Caption`}),t(`p`,{className:`text-xs text-foreground-disabled`,children:`Disabled / placeholder text`})]})}),t(h,{title:`Colors`,children:e(`div`,{className:`flex flex-wrap gap-4`,children:[t(g,{name:`primary`,cssVar:`--color-primary`}),t(g,{name:`background`,cssVar:`--color-background`}),t(g,{name:`surface`,cssVar:`--color-surface`}),t(g,{name:`foreground`,cssVar:`--color-foreground`}),t(g,{name:`success`,cssVar:`--color-success`}),t(g,{name:`warning`,cssVar:`--color-warning`}),t(g,{name:`danger`,cssVar:`--color-danger`}),t(g,{name:`info`,cssVar:`--color-info`}),t(g,{name:`border`,cssVar:`--color-border`}),t(`div`,{className:`w-px`}),t(g,{name:`onvif`,hex:`#3b82f6`}),t(g,{name:`hikvision`,hex:`#a855f7`}),t(g,{name:`reolink`,hex:`#06b6d4`}),t(g,{name:`ha`,hex:`#22d3ee`}),t(g,{name:`rtsp`,hex:`#78716c`})]})}),t(h,{title:`Buttons`,children:e(`div`,{className:`flex flex-wrap gap-3`,children:[t(c,{variant:`unstyled`,className:`inline-flex items-center gap-1.5 rounded-md bg-primary px-4 py-2 text-sm font-medium text-white hover:opacity-90 transition-opacity`,children:`Primary`}),t(c,{variant:`unstyled`,className:`inline-flex items-center gap-1.5 rounded-md border border-border bg-surface px-4 py-2 text-sm font-medium text-foreground hover:bg-surface-hover transition-colors`,children:`Secondary`}),t(c,{variant:`unstyled`,className:`inline-flex items-center gap-1.5 rounded-md border border-danger/40 bg-danger/10 px-4 py-2 text-sm font-medium text-danger hover:bg-danger/20 transition-colors`,children:`Danger`}),t(c,{variant:`unstyled`,disabled:!0,className:`inline-flex items-center gap-1.5 rounded-md bg-primary px-4 py-2 text-sm font-medium text-white opacity-40 cursor-not-allowed`,children:`Disabled`}),t(c,{variant:`unstyled`,className:`inline-flex items-center gap-1.5 rounded-md border border-warning/40 bg-warning/10 px-4 py-2 text-sm font-medium text-warning hover:bg-warning/20 transition-colors`,children:`Warning`}),t(c,{variant:`unstyled`,className:`inline-flex items-center gap-1.5 rounded-md border border-success/40 bg-success/10 px-4 py-2 text-sm font-medium text-success hover:bg-success/20 transition-colors`,children:`Success`})]})}),t(h,{title:`Inputs`,children:e(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[e(`div`,{children:[t(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Text input`}),t(s,{type:`text`,className:`w-full rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground outline-none focus:border-primary focus:ring-1 focus:ring-primary/30`,placeholder:`Type something...`})]}),e(`div`,{children:[t(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Number input`}),t(s,{type:`number`,className:`w-full rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground outline-none focus:border-primary focus:ring-1 focus:ring-primary/30`,placeholder:`0`})]}),e(`div`,{children:[t(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Password input`}),t(s,{type:`password`,className:`w-full rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground outline-none focus:border-primary focus:ring-1 focus:ring-primary/30`,placeholder:`••••••••`})]}),e(`div`,{children:[t(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Select`}),e(o,{className:`w-full`,children:[t(`option`,{children:`Option A`}),t(`option`,{children:`Option B`}),t(`option`,{children:`Option C`})]})]}),e(`div`,{className:`md:col-span-2`,children:[t(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Textarea`}),t(u,{className:`w-full rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground outline-none focus:border-primary focus:ring-1 focus:ring-primary/30 resize-y min-h-[60px]`,placeholder:`Enter multi-line text...`,rows:3})]}),t(`div`,{children:e(`label`,{className:`flex items-center gap-2 cursor-pointer select-none`,children:[t(i,{className:`h-3.5 w-3.5 rounded border-border accent-primary`,defaultChecked:!0}),t(`span`,{className:`text-xs font-medium text-foreground`,children:`Checkbox (checked)`})]})}),t(`div`,{children:e(`div`,{className:`flex items-center justify-between`,children:[t(`span`,{className:`text-xs font-medium text-foreground`,children:`Toggle switch`}),t(y,{})]})}),e(`div`,{children:[t(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Slider`}),t(a,{className:`w-full h-1 accent-primary cursor-pointer`,min:0,max:100,defaultValue:60})]}),e(`div`,{children:[t(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Tags example`}),t(`div`,{className:`flex flex-wrap gap-1.5 rounded-md border border-border bg-background px-2 py-1.5 min-h-[38px]`,children:[`camera`,`zone`,`alert`].map(e=>t(`span`,{className:`inline-flex items-center gap-1 rounded-md bg-primary/10 px-1.5 py-0.5 text-xs text-primary`,children:e},e))})]})]})}),e(h,{title:`ConditionKindPicker`,children:[e(`div`,{className:`flex flex-wrap items-center gap-3`,children:[t(c,{variant:`outline`,onClick:()=>v(!0),children:`Add a condition`}),t(`span`,{className:`text-xs text-foreground-subtle`,children:b??`Nothing picked`})]}),t(l,{open:r,onOpenChange:v,title:`Add a condition`,context:`trigger`,underNot:!1,treeFull:!1,recentKey:`showroom`,textsOf:e=>({label:e,description:`A ${e} row`,example:e}),categoryLabelOf:e=>e,reasonOf:e=>e,onPick:e=>{x(e),v(!1)}})]}),t(h,{title:`Badges`,children:e(`div`,{className:`space-y-3`,children:[e(`div`,{children:[t(`p`,{className:`text-xs text-foreground-subtle mb-2`,children:`StatusBadge`}),t(`div`,{className:`flex flex-wrap gap-2`,children:[`running`,`stopped`,`error`,`online`,`offline`,`idle`].map(e=>t(d,{status:e},e))})]}),e(`div`,{children:[t(`p`,{className:`text-xs text-foreground-subtle mb-2`,children:`CapabilityBadges`}),t(p,{capabilities:[`streaming`,`detection`,`recording`,`audio`]})]})]})}),t(h,{title:`Cards`,children:e(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[e(`div`,{className:`rounded-lg bg-surface p-4`,children:[t(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Surface card`}),t(`p`,{className:`text-xs text-foreground-subtle`,children:"Uses `bg-surface`. Default card background."})]}),e(`div`,{className:`rounded-lg border border-border bg-surface p-4`,children:[t(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Bordered card`}),t(`p`,{className:`text-xs text-foreground-subtle`,children:"Uses `border border-border bg-surface`."})]}),e(`div`,{className:`rounded-lg border border-primary/30 bg-primary/5 p-4`,children:[t(`h3`,{className:`text-sm font-semibold text-primary mb-1`,children:`Accent card`}),t(`p`,{className:`text-xs text-foreground-subtle`,children:`Highlighted with primary color.`})]}),e(`div`,{className:`rounded-lg bg-background p-4`,children:[t(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Background card`}),t(`p`,{className:`text-xs text-foreground-subtle`,children:"Uses `bg-background`. Inset card."})]})]})}),t(h,{title:`Provider Icons`,children:t(`div`,{className:`flex flex-wrap gap-4`,children:[`onvif`,`hikvision`,`reolink`,`homeassistant`,`rtsp`,`onvif`].map(e=>t(m,{type:e,size:`lg`,showLabel:!0},e))})}),e(h,{title:`Form Builder Demo`,children:[t(f,{schema:_,values:S,onChange:C}),e(`details`,{className:`mt-3`,children:[t(`summary`,{className:`text-[10px] text-foreground-subtle cursor-pointer hover:text-foreground`,children:`View current values`}),t(`pre`,{className:`mt-2 rounded-md bg-background p-3 text-[10px] text-foreground-subtle overflow-auto`,children:JSON.stringify(S,null,2)})]})]}),t(h,{title:`Info Boxes`,children:t(`div`,{className:`space-y-2`,children:[{variant:`info`,label:`Info`,content:`This is an informational message. Use it for tips and hints.`},{variant:`warning`,label:`Warning`,content:`This action may have side effects. Proceed with caution.`},{variant:`success`,label:`Success`,content:`Operation completed successfully. All systems are green.`},{variant:`danger`,label:`Danger`,content:`This operation is irreversible. Data will be permanently deleted.`}].map(({variant:n,label:r,content:i})=>{let a={info:{border:`border-info`,bg:`bg-info/5`,text:`text-info`},warning:{border:`border-warning`,bg:`bg-warning/5`,text:`text-warning`},success:{border:`border-success`,bg:`bg-success/5`,text:`text-success`},danger:{border:`border-danger`,bg:`bg-danger/5`,text:`text-danger`}}[n];return e(`div`,{className:`rounded-md border-l-4 px-3 py-2.5 ${a.border} ${a.bg}`,children:[t(`p`,{className:`text-xs font-semibold mb-0.5 ${a.text}`,children:r}),t(`p`,{className:`text-xs text-foreground-subtle leading-relaxed`,children:i})]},n)})})})]})}function y(){let[e,r]=n(!0);return t(c,{variant:`unstyled`,type:`button`,role:`switch`,"aria-checked":e,onClick:()=>r(e=>!e),className:[`relative inline-flex h-4 w-8 shrink-0 items-center rounded-full transition-colors duration-150 cursor-pointer`,e?`bg-primary`:`bg-foreground-subtle/30`].join(` `),children:t(`span`,{className:[`inline-block h-3 w-3 rounded-full bg-white shadow transition-transform duration-150`,e?`translate-x-4`:`translate-x-0.5`].join(` `)})})}export{v as ShowroomPage};
|
|
1
|
+
import{C as e,S as t,Y as n,et as r}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Ua as i,Wa as a,dt as o}from"./player-overlays-VrMHBBfa.js";import{Qf as s,Wf as c,_ as l,ni as u,q as d}from"./src-bJ4Hy4Cl.js";import{Mt as f,W as p,tt as m}from"./index-1bBrNxAK.js";r();function h({title:n,children:r}){return e(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[t(`div`,{className:`border-b border-border px-4 py-2.5`,children:t(`h2`,{className:`text-xs font-semibold text-foreground uppercase tracking-wider`,children:n})}),t(`div`,{className:`p-4`,children:r})]})}function g({name:n,cssVar:r,hex:i}){return e(`div`,{className:`flex flex-col items-center gap-1.5`,children:[t(`div`,{className:`h-10 w-10 rounded-lg border border-border shadow-inner`,style:{backgroundColor:r?`var(${r})`:i}}),t(`span`,{className:`text-[10px] text-foreground-subtle text-center leading-tight`,children:n})]})}var _={sections:[{id:`demo`,title:`Demo Fields`,columns:2,fields:[{key:`name`,type:`text`,label:`Name`,placeholder:`Enter name`},{key:`count`,type:`number`,label:`Count`,min:0,max:100,unit:`items`},{key:`enabled`,type:`boolean`,label:`Enabled`},{key:`mode`,type:`select`,label:`Mode`,options:[{value:`a`,label:`Alpha`},{value:`b`,label:`Beta`}]},{key:`tags`,type:`tags`,label:`Tags`,span:2,suggestions:[`camera`,`zone`,`alert`]},{key:`confidence`,type:`slider`,label:`Confidence`,min:0,max:100,step:5,unit:`%`,span:2},{key:`info`,type:`info`,label:`Note`,content:`This is an informational message for the user.`,variant:`info`}]}]};function v(){let[r,v]=n(!1),[b,x]=n(null),[S,C]=n({name:`Example`,count:10,enabled:!0,mode:`a`,tags:[`camera`],confidence:60});return e(`div`,{className:`p-6 space-y-6 max-w-5xl mx-auto`,children:[e(`div`,{className:`mb-6`,children:[t(`h1`,{className:`text-xl font-bold text-foreground`,children:`Component Showroom`}),t(`p`,{className:`text-sm text-foreground-subtle mt-1`,children:`All UI components at a glance`})]}),t(h,{title:`Typography`,children:e(`div`,{className:`space-y-3`,children:[t(`h1`,{className:`text-2xl font-bold text-foreground`,children:`Heading 1 — Display title`}),t(`h2`,{className:`text-xl font-semibold text-foreground`,children:`Heading 2 — Section title`}),t(`h3`,{className:`text-base font-semibold text-foreground`,children:`Heading 3 — Card title`}),t(`h4`,{className:`text-sm font-semibold text-foreground`,children:`Heading 4 — Sub-section`}),t(`p`,{className:`text-sm text-foreground`,children:`Body text — Regular paragraph content goes here. It uses the foreground color.`}),t(`p`,{className:`text-sm text-foreground-subtle`,children:`Subtle text — Secondary/descriptive text with reduced emphasis.`}),t(`p`,{className:`text-xs text-foreground-subtle uppercase tracking-wider font-semibold`,children:`Label / Caption`}),t(`p`,{className:`text-xs text-foreground-disabled`,children:`Disabled / placeholder text`})]})}),t(h,{title:`Colors`,children:e(`div`,{className:`flex flex-wrap gap-4`,children:[t(g,{name:`primary`,cssVar:`--color-primary`}),t(g,{name:`background`,cssVar:`--color-background`}),t(g,{name:`surface`,cssVar:`--color-surface`}),t(g,{name:`foreground`,cssVar:`--color-foreground`}),t(g,{name:`success`,cssVar:`--color-success`}),t(g,{name:`warning`,cssVar:`--color-warning`}),t(g,{name:`danger`,cssVar:`--color-danger`}),t(g,{name:`info`,cssVar:`--color-info`}),t(g,{name:`border`,cssVar:`--color-border`}),t(`div`,{className:`w-px`}),t(g,{name:`onvif`,hex:`#3b82f6`}),t(g,{name:`hikvision`,hex:`#a855f7`}),t(g,{name:`reolink`,hex:`#06b6d4`}),t(g,{name:`ha`,hex:`#22d3ee`}),t(g,{name:`rtsp`,hex:`#78716c`})]})}),t(h,{title:`Buttons`,children:e(`div`,{className:`flex flex-wrap gap-3`,children:[t(c,{variant:`unstyled`,className:`inline-flex items-center gap-1.5 rounded-md bg-primary px-4 py-2 text-sm font-medium text-white hover:opacity-90 transition-opacity`,children:`Primary`}),t(c,{variant:`unstyled`,className:`inline-flex items-center gap-1.5 rounded-md border border-border bg-surface px-4 py-2 text-sm font-medium text-foreground hover:bg-surface-hover transition-colors`,children:`Secondary`}),t(c,{variant:`unstyled`,className:`inline-flex items-center gap-1.5 rounded-md border border-danger/40 bg-danger/10 px-4 py-2 text-sm font-medium text-danger hover:bg-danger/20 transition-colors`,children:`Danger`}),t(c,{variant:`unstyled`,disabled:!0,className:`inline-flex items-center gap-1.5 rounded-md bg-primary px-4 py-2 text-sm font-medium text-white opacity-40 cursor-not-allowed`,children:`Disabled`}),t(c,{variant:`unstyled`,className:`inline-flex items-center gap-1.5 rounded-md border border-warning/40 bg-warning/10 px-4 py-2 text-sm font-medium text-warning hover:bg-warning/20 transition-colors`,children:`Warning`}),t(c,{variant:`unstyled`,className:`inline-flex items-center gap-1.5 rounded-md border border-success/40 bg-success/10 px-4 py-2 text-sm font-medium text-success hover:bg-success/20 transition-colors`,children:`Success`})]})}),t(h,{title:`Inputs`,children:e(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[e(`div`,{children:[t(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Text input`}),t(s,{type:`text`,className:`w-full rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground outline-none focus:border-primary focus:ring-1 focus:ring-primary/30`,placeholder:`Type something...`})]}),e(`div`,{children:[t(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Number input`}),t(s,{type:`number`,className:`w-full rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground outline-none focus:border-primary focus:ring-1 focus:ring-primary/30`,placeholder:`0`})]}),e(`div`,{children:[t(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Password input`}),t(s,{type:`password`,className:`w-full rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground outline-none focus:border-primary focus:ring-1 focus:ring-primary/30`,placeholder:`••••••••`})]}),e(`div`,{children:[t(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Select`}),e(o,{className:`w-full`,children:[t(`option`,{children:`Option A`}),t(`option`,{children:`Option B`}),t(`option`,{children:`Option C`})]})]}),e(`div`,{className:`md:col-span-2`,children:[t(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Textarea`}),t(u,{className:`w-full rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground outline-none focus:border-primary focus:ring-1 focus:ring-primary/30 resize-y min-h-[60px]`,placeholder:`Enter multi-line text...`,rows:3})]}),t(`div`,{children:e(`label`,{className:`flex items-center gap-2 cursor-pointer select-none`,children:[t(i,{className:`h-3.5 w-3.5 rounded border-border accent-primary`,defaultChecked:!0}),t(`span`,{className:`text-xs font-medium text-foreground`,children:`Checkbox (checked)`})]})}),t(`div`,{children:e(`div`,{className:`flex items-center justify-between`,children:[t(`span`,{className:`text-xs font-medium text-foreground`,children:`Toggle switch`}),t(y,{})]})}),e(`div`,{children:[t(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Slider`}),t(a,{className:`w-full h-1 accent-primary cursor-pointer`,min:0,max:100,defaultValue:60})]}),e(`div`,{children:[t(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Tags example`}),t(`div`,{className:`flex flex-wrap gap-1.5 rounded-md border border-border bg-background px-2 py-1.5 min-h-[38px]`,children:[`camera`,`zone`,`alert`].map(e=>t(`span`,{className:`inline-flex items-center gap-1 rounded-md bg-primary/10 px-1.5 py-0.5 text-xs text-primary`,children:e},e))})]})]})}),e(h,{title:`ConditionKindPicker`,children:[e(`div`,{className:`flex flex-wrap items-center gap-3`,children:[t(c,{variant:`outline`,onClick:()=>v(!0),children:`Add a condition`}),t(`span`,{className:`text-xs text-foreground-subtle`,children:b??`Nothing picked`})]}),t(l,{open:r,onOpenChange:v,title:`Add a condition`,context:`trigger`,underNot:!1,treeFull:!1,recentKey:`showroom`,textsOf:e=>({label:e,description:`A ${e} row`,example:e}),categoryLabelOf:e=>e,reasonOf:e=>e,onPick:e=>{x(e),v(!1)}})]}),t(h,{title:`Badges`,children:e(`div`,{className:`space-y-3`,children:[e(`div`,{children:[t(`p`,{className:`text-xs text-foreground-subtle mb-2`,children:`StatusBadge`}),t(`div`,{className:`flex flex-wrap gap-2`,children:[`running`,`stopped`,`error`,`online`,`offline`,`idle`].map(e=>t(d,{status:e},e))})]}),e(`div`,{children:[t(`p`,{className:`text-xs text-foreground-subtle mb-2`,children:`CapabilityBadges`}),t(p,{capabilities:[`streaming`,`detection`,`recording`,`audio`]})]})]})}),t(h,{title:`Cards`,children:e(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[e(`div`,{className:`rounded-lg bg-surface p-4`,children:[t(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Surface card`}),t(`p`,{className:`text-xs text-foreground-subtle`,children:"Uses `bg-surface`. Default card background."})]}),e(`div`,{className:`rounded-lg border border-border bg-surface p-4`,children:[t(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Bordered card`}),t(`p`,{className:`text-xs text-foreground-subtle`,children:"Uses `border border-border bg-surface`."})]}),e(`div`,{className:`rounded-lg border border-primary/30 bg-primary/5 p-4`,children:[t(`h3`,{className:`text-sm font-semibold text-primary mb-1`,children:`Accent card`}),t(`p`,{className:`text-xs text-foreground-subtle`,children:`Highlighted with primary color.`})]}),e(`div`,{className:`rounded-lg bg-background p-4`,children:[t(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Background card`}),t(`p`,{className:`text-xs text-foreground-subtle`,children:"Uses `bg-background`. Inset card."})]})]})}),t(h,{title:`Provider Icons`,children:t(`div`,{className:`flex flex-wrap gap-4`,children:[`onvif`,`hikvision`,`reolink`,`homeassistant`,`rtsp`,`onvif`].map(e=>t(m,{type:e,size:`lg`,showLabel:!0},e))})}),e(h,{title:`Form Builder Demo`,children:[t(f,{schema:_,values:S,onChange:C}),e(`details`,{className:`mt-3`,children:[t(`summary`,{className:`text-[10px] text-foreground-subtle cursor-pointer hover:text-foreground`,children:`View current values`}),t(`pre`,{className:`mt-2 rounded-md bg-background p-3 text-[10px] text-foreground-subtle overflow-auto`,children:JSON.stringify(S,null,2)})]})]}),t(h,{title:`Info Boxes`,children:t(`div`,{className:`space-y-2`,children:[{variant:`info`,label:`Info`,content:`This is an informational message. Use it for tips and hints.`},{variant:`warning`,label:`Warning`,content:`This action may have side effects. Proceed with caution.`},{variant:`success`,label:`Success`,content:`Operation completed successfully. All systems are green.`},{variant:`danger`,label:`Danger`,content:`This operation is irreversible. Data will be permanently deleted.`}].map(({variant:n,label:r,content:i})=>{let a={info:{border:`border-info`,bg:`bg-info/5`,text:`text-info`},warning:{border:`border-warning`,bg:`bg-warning/5`,text:`text-warning`},success:{border:`border-success`,bg:`bg-success/5`,text:`text-success`},danger:{border:`border-danger`,bg:`bg-danger/5`,text:`text-danger`}}[n];return e(`div`,{className:`rounded-md border-l-4 px-3 py-2.5 ${a.border} ${a.bg}`,children:[t(`p`,{className:`text-xs font-semibold mb-0.5 ${a.text}`,children:r}),t(`p`,{className:`text-xs text-foreground-subtle leading-relaxed`,children:i})]},n)})})})]})}function y(){let[e,r]=n(!0);return t(c,{variant:`unstyled`,type:`button`,role:`switch`,"aria-checked":e,onClick:()=>r(e=>!e),className:[`relative inline-flex h-4 w-8 shrink-0 items-center rounded-full transition-colors duration-150 cursor-pointer`,e?`bg-primary`:`bg-foreground-subtle/30`].join(` `),children:t(`span`,{className:[`inline-block h-3 w-3 rounded-full bg-white shadow transition-transform duration-150`,e?`translate-x-4`:`translate-x-0.5`].join(` `)})})}export{v as ShowroomPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as e,K as t,S as n,V as r,Y as i,et as a,o}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Fr as s,Zr as c,ct as l,er as u,jn as d,mi as f,wt as p}from"./player-overlays-VrMHBBfa.js";import{$s as m}from"./client-CBrsD14Q.js";import{t as h}from"./chevron-down-CBb-F8DT.js";import{t as g}from"./archive-ChKlYFY2.js";import{t as _}from"./eraser-B3lnG9yK.js";import{t as v}from"./hard-drive-download-C6N6tovA.js";import{$f as y,Ha as b,Hd as x,Lc as S,Ud as C,Vd as w,Wf as T,ma as ee,pd as te}from"./src-PRnJiArs.js";import{t as E}from"./i18n-BFxrpjSx.js";import{t as D}from"./useTranslation-BJr-n0es.js";import{kt as O,pt as k}from"./index-DqWOkhIM.js";import{t as A}from"./format-size-DIxKXxtj.js";import{t as ne}from"./InstancesTable-Bm6FGiwJ.js";a();var re=`forceDeleteLocation`;function ie({row:e}){let{t}=D(),r=l(),i=o(),a=b(),s=async()=>{if(await r({title:t(`system.storage.forceDeleteTitle`,`Force delete "{{name}}"?`,{name:e.name}),message:t(`system.storage.forceDeleteNote`,`Removes the record only, without checking what is on the location. Anything still stored there becomes unreachable — index rows naming it stop resolving, and playback of those segments goes silently black rather than erroring.`),confirmLabel:t(`system.storage.forceDelete`,`Force delete`),variant:`danger`}))try{await a.mutateAsync({addonId:e.addonId,action:re,input:{id:e.id}}),await i.invalidateQueries({queryKey:[k]}),await i.invalidateQueries({queryKey:[[`storage`,`listLocations`]]})}catch(n){O({title:t(`providerInstances.deleteFailed`,`Could not delete`),message:`${e.name}: ${n instanceof Error?n.message:String(n)}`,severity:`critical`})}};return n(y,{icon:d,variant:`ghost`,size:`sm`,disabled:a.isPending,"aria-label":t(`system.storage.forceDeleteRow`,`Force delete {{name}}`,{name:e.name}),onClick:()=>void s()})}function ae(e){return`${(e/1024**3).toFixed(e>=100*1024**3?0:1)} GB`}function oe(e){return new Date(e).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`})}function se({drain:t}){let{t:r}=D();if(t.kind===`idle`)return null;if(t.kind===`unreported`)return n(`span`,{"data-testid":`drain-unreported`,className:`text-[10px] text-foreground-subtle`,title:r(`storage.drainProgressLine.thisLocationIsDrainingThe`,`This location is draining. The hub has not reported how much is left yet — either the drain has just been set, or this hub predates the drain-progress report.`),children:r(`storage.drainProgressLine.drainingRemainingNotReportedYet`,`Draining · remaining not reported yet`)});if(t.kind===`drained`)return n(`span`,{"data-testid":`drain-done`,className:`text-[10px] text-success`,title:r(`storage.drainProgressLine.everythingThatWasHereHas`,`Everything that was here has been moved. The location is still in drain mode — it receives no new writes until you change that.`),children:r(`storage.drainProgressLine.drainedNothingLeftToMove`,`Drained · nothing left to move`)});let i=t.drainedFraction===null?null:Math.round(t.drainedFraction*100);return e(`span`,{"data-testid":`drain-progress`,className:`flex items-center gap-1.5 text-[10px] text-foreground-subtle tabular-nums`,children:[i!==null&&n(`span`,{"data-testid":`drain-bar`,className:`inline-block h-1 w-10 rounded-full bg-border overflow-hidden`,role:`progressbar`,"aria-label":r(`storage.drainProgressLine.drainProgress`,`Drain progress`),"aria-valuenow":i,"aria-valuemin":0,"aria-valuemax":100,children:n(`span`,{className:`block h-full bg-warning`,style:{width:`${i}%`}})}),e(`span`,{children:[r(`storage.drainProgressLine.left`,{size:ae(t.bytesRemaining)}),i!==null&&` · ${r(`storage.drainProgressLine.moved`,{percent:i})}`]}),t.estimatedEmptyAtMs===null?n(`span`,{"data-testid":`drain-eta-absent`,title:r(`storage.drainProgressLine.theDrainIsPacedBy`,`The drain is paced by how fast this class of data is still growing, and that has not been observed yet. There is no date to give.`),children:r(`storage.drainProgressLine.emptyTimeNotKnownYet`,`· empty time not known yet`)}):e(`span`,{"data-testid":`drain-eta`,children:[`·`,` `,r(`storage.drainProgressLine.empty`,{when:oe(t.estimatedEmptyAtMs)})]})]})}var j=[`ok`,`warn`,`critical`];function M(e){return e>=.95?`critical`:e>=.85?`warn`:`ok`}function N(e){return Math.min(1,Math.max(0,e))}function P(e){let{availableBytes:t,totalBytes:n}=e;if(n===null||n<=0||t===null)return null;let r=N((n-t)/n);return{fraction:r,severity:M(r),recordingsFraction:N(e.usedBytes/n),freeBytes:t,totalBytes:n}}function ce(e){if(e.length===0)return null;let t=0,n=0,r=0,i=0,a=null;for(let o of e){let e=P(o);if(e===null){n+=1;continue}t+=1,r+=e.totalBytes,i+=e.freeBytes,(a===null||j.indexOf(e.severity)>j.indexOf(a))&&(a=e.severity)}return{knownVolumes:t,unknownVolumes:n,totalBytes:r,freeBytes:i,severity:a}}function F(e){return Math.min(1,Math.max(0,e))}function I(e){return Math.round(F(e)*1e3)/10}function L(e){return`${String(Math.round(F(e)*100))}%`}function le(e,t,n={}){let{totalBytes:r,availableBytes:i}=e;if(r===null||r<=0||i===null){let e=n.ownedBytes===void 0||n.ownedBytes===null||!Number.isFinite(n.ownedBytes)||n.ownedBytes<0?null:A(n.ownedBytes);return{kind:`unknown`,owned:e,summary:e===null?E.t(`helpers.locationCapacityBar.unknownSummary`):E.t(`helpers.locationCapacityBar.unknownSummaryOwned`,{size:e})}}let a=Math.min(Math.max(i,0),r),o=r-a,s=t===null||t<=0?0:t,c=Math.min(s,a),l=s>a,u=a-c,d=n.ownedBytes,f=d==null||!Number.isFinite(d)||d<0?null:Math.min(d,o),p=o-(f??0),m=P({usedBytes:f??o,availableBytes:a,totalBytes:r}),h=m===null?F(o/r):m.fraction,g=m===null?M(h):m.severity,_=f===null?null:m===null?F(f/r):m.recordingsFraction,v=n.cap??null,y=v===null?null:F((c+v.bytes)/r),b=v!==null&&f!==null&&f>v.bytes,x={total:A(r),freeTotal:A(a),freeTotalPercent:L(a/r),used:A(p),usedPercent:L(p/r),free:A(u),freePercent:L(u/r),reserve:s===0?null:E.t(`helpers.locationCapacityBar.reserveKept`,{size:A(s)}),owned:f===null||_===null?null:E.t(`helpers.locationCapacityBar.ownedOfRecordings`,{size:A(f),percent:L(_)}),cap:v===null?null:v.reason===`drain`?E.t(`helpers.locationCapacityBar.capDrain`,{size:A(v.bytes)}):E.t(`helpers.locationCapacityBar.capCap`,{size:A(v.bytes)})},S=[E.t(`helpers.locationCapacityBar.summaryFree`,{free:x.freeTotal,total:x.total,percent:x.freeTotalPercent}),x.owned===null?null:E.t(`helpers.locationCapacityBar.summaryOwned`,{owned:x.owned}),x.reserve===null?null:l?E.t(`helpers.locationCapacityBar.summaryReserveShort`,{reserve:x.reserve}):x.reserve,x.cap===null?null:b?E.t(`helpers.locationCapacityBar.summaryCapBelow`,{cap:x.cap}):x.cap].filter(e=>e!==null).join(` · `),C=[];return c>0&&C.push({segment:`reserve`,label:E.t(`helpers.locationCapacityBar.legendKeptFree`),value:A(s),alarming:l}),x.owned!==null&&C.push({segment:`owned`,label:E.t(`helpers.locationCapacityBar.legendCamstack`),value:x.owned,alarming:!1}),C.push({segment:`used`,label:f===null?E.t(`helpers.locationCapacityBar.legendUsed`):E.t(`helpers.locationCapacityBar.legendOtherData`),value:`${x.used} (${x.usedPercent})`,alarming:g===`critical`}),C.push({segment:`free`,label:E.t(`helpers.locationCapacityBar.legendFree`),value:`${x.free} (${x.freePercent})`,alarming:l}),v!==null&&C.push({segment:`cap`,label:v.reason===`drain`?E.t(`helpers.locationCapacityBar.legendDrainTarget`):E.t(`helpers.locationCapacityBar.legendCap`),value:E.t(`helpers.locationCapacityBar.legendCapValue`,{size:A(v.bytes)}),alarming:b}),{kind:`known`,severity:g,legend:C,segments:{reservePercent:I(c/r),ownedPercent:f===null?null:I(f/r),usedPercent:I(p/r),freePercent:I(u/r),capPercent:y===null?null:I(y)},labels:x,reserveExceedsFree:l,capBelowOwned:b,summary:S}}function R(e){return m(e)}function z(e){return e===`active`}var B=[{mode:`active`,get label(){return E.t(`helpers.locationMode.activeLabel`)},get consequence(){return E.t(`helpers.locationMode.activeConsequence`)},requiresConfirmation:!1},{mode:`readonly`,get label(){return E.t(`helpers.locationMode.readonlyLabel`)},get consequence(){return E.t(`helpers.locationMode.readonlyConsequence`)},requiresConfirmation:!1},{mode:`drain`,get label(){return E.t(`helpers.locationMode.drainLabel`)},get consequence(){return E.t(`helpers.locationMode.drainConsequence`)},requiresConfirmation:!1},{mode:`disabled`,get label(){return E.t(`helpers.locationMode.disabledLabel`)},get consequence(){return E.t(`helpers.locationMode.disabledConsequence`)},requiresConfirmation:!0}];function V(e){return B.find(t=>t.mode===e)??B[0]}function ue(e){return V(e).requiresConfirmation}var de=`Blocked: this is the last location of its type still accepting writes — new data would have nowhere to go.`;function H(e,t,n){return z(n)||!z(R(e))||t.some(t=>t.id!==e.id&&z(R(t)))?{blocked:!1,reason:``}:{blocked:!0,reason:de}}function fe(e,t){return{active:H(e,t,`active`).reason,readonly:H(e,t,`readonly`).reason,drain:H(e,t,`drain`).reason,disabled:H(e,t,`disabled`).reason}}var pe=1024**3;function U(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function me(e){let t=U(e.minFreeGb);if(t!==null)return{unit:`gb`,value:t};let n=U(e.minFreePercent);return n===null?{unit:`percent`,value:null}:{unit:`percent`,value:n}}function he(e,t,n=10){if(e.unit===`gb`&&e.value!==null)return e.value*pe;let r=e.value??n;return t===null||t<=0?null:t*Math.min(100,Math.max(0,r))/100}function ge(e,t){let n=U(e.maxUsedGb);return n===null||n<0?null:{bytes:n*pe,reason:t===`drain`?`drain`:`legacy`}}var W={ok:`bg-primary`,warn:`bg-warning`,critical:`bg-danger`},G={reserve:`bg-danger/40`,owned:`bg-foreground/50`,free:`bg-border`,cap:`bg-foreground`};function _e(e,t){return e===`used`?W[t]:G[e]}function K({location:t,ownedBytes:r}){let{t:i}=D(),a=t.capacity??null,o=he(me(t.config),a?.totalBytes??null),s=le({totalBytes:a?.totalBytes??null,availableBytes:a?.availableBytes??null},o,{ownedBytes:r??null,cap:ge(t.config,R(t))});return s.kind===`unknown`?n(`div`,{className:`text-[10px] text-foreground-subtle italic`,title:s.summary,children:s.owned===null?i(`storage.locationCapacityBar.capacityUnknown`,`Capacity unknown`):i(`storage.locationCapacityBar.capacityUnknownCamstackHolds`,`Capacity unknown · CamStack holds {{owned}}`,{owned:s.owned})}):e(`div`,{className:`mt-1 space-y-1`,title:s.summary,children:[e(`div`,{className:`relative flex h-2 w-full max-w-md overflow-hidden rounded-full bg-border`,children:[s.segments.reservePercent>0&&n(`div`,{className:G.reserve,style:{width:`${String(s.segments.reservePercent)}%`}}),s.segments.ownedPercent!==null&&n(`div`,{className:G.owned,style:{width:`${String(s.segments.ownedPercent)}%`}}),n(`div`,{className:W[s.severity],style:{width:`${String(s.segments.usedPercent)}%`}}),n(`div`,{className:G.free,style:{width:`${String(s.segments.freePercent)}%`}}),s.segments.capPercent!==null&&n(`div`,{className:`absolute inset-y-0 w-px ${s.capBelowOwned?`bg-danger`:G.cap}`,style:{left:`${String(s.segments.capPercent)}%`}})]}),n(`ul`,{className:`flex flex-wrap items-center gap-x-3 gap-y-0.5`,children:s.legend.map(t=>e(`li`,{className:`flex items-center gap-1`,children:[n(`span`,{"aria-hidden":`true`,className:`inline-block h-2 w-2 shrink-0 rounded-sm ${_e(t.segment,s.severity)}`}),e(`span`,{className:`text-[10px] tabular-nums ${t.alarming?`text-danger`:`text-foreground-subtle`}`,children:[t.label,` `,t.value]})]},t.segment))})]})}var ve={eventMedia:[`events`],recordingsLow:[`low`],recordings:[`high`,`mid`]},ye={eventMedia:`pipeline-analytics`,recordingsLow:`recorder`,recordings:`recorder`},be=`storage.discardLocation`,q=`storage.discardLocationStatus`,xe=`storage.discardLocationCancel`;function Se(e){return ve[e]??null}function Ce(e){return ye[e]??null}function we(e){return!z(R(e))}function Te(e,t){return Se(e.type)===null||!we(e)?!1:t.some(t=>t.id!==e.id&&z(R(t)))}var Ee=new Set([`idle`,`scanning`,`wiping-fs`,`wiping-db`,`cascading`,`complete`,`cancelled`,`error`]);function J(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function Y(e){return typeof e==`string`?e:null}function X(e){if(typeof e!=`object`||!e)return null;let t=e;if(typeof t.running!=`boolean`)return null;let n=t.phase;if(typeof n!=`string`||!Ee.has(n))return null;let r=J(t.camerasTotal),i=J(t.camerasDone),a=J(t.foldersRemoved),o=J(t.dbRowsDeleted),s=J(t.ownersCascaded);return r===null||i===null||a===null||o===null||s===null?null:{running:t.running,locationId:Y(t.locationId),jobId:Y(t.jobId),phase:n,camerasTotal:r,camerasDone:i,foldersRemoved:a,dbRowsDeleted:o,ownersCascaded:s,detail:Y(t.detail)??``,startedAtMs:J(t.startedAtMs),finishedAtMs:J(t.finishedAtMs),error:Y(t.error)}}function De(e){if(e.phase===`complete`)return 100;if(e.phase===`cancelled`||e.phase===`error`||e.phase===`idle`)return e.camerasTotal>0?Math.min(99,Math.round(e.camerasDone/e.camerasTotal*100)):0;if(e.camerasTotal>0){let t=e.camerasDone/e.camerasTotal*85;return e.phase===`wiping-db`?Math.min(95,Math.round(t+8)):e.phase===`cascading`?Math.min(99,Math.round(t+12)):Math.min(85,Math.round(t))}return e.phase===`scanning`?2:5}var Oe=2e3;function ke({location:e,siblings:t}){return Te(e,t)?n(Ae,{location:e}):null}function Ae({location:t}){let{t:a}=D(),o=l(),c=b(),u=Ce(t.type),[d,f]=i(null),[m,h]=i(null),[g,v]=i(!1);if(r(()=>{if(u===null)return;let e=!1,t=async()=>{try{let t=await c.mutateAsync({addonId:u,action:q,input:{}});if(e)return;f(X(t))}catch{}};t();let n=setInterval(()=>void t(),Oe);return()=>{e=!0,clearInterval(n)}},[u,t.id]),u===null)return null;let y=d!==null&&d.locationId===t.id,x=y&&d.running,S=y&&d.phase!==`idle`,C=async()=>{if(await o({title:a(`storage.locationDiscardControl.discardLeftoversOn`,`Discard leftovers on "{{displayName}}"?`,{displayName:t.displayName}),message:a(`storage.locationDiscardControl.permanentlyDeletesLeftoverFilesAnd`,`Permanently deletes leftover files and records on this location. Other locations are not affected. This cannot be undone and may take hours.`),confirmLabel:a(`storage.locationDiscardControl.discardLeftovers`,`Discard leftovers`),variant:`danger`})){h(null),v(!0);try{await c.mutateAsync({addonId:u,action:be,input:{locationId:t.id}}),f(X(await c.mutateAsync({addonId:u,action:q,input:{}})))}catch(e){h(e instanceof Error?e.message:String(e))}finally{v(!1)}}},w=async()=>{try{await c.mutateAsync({addonId:u,action:xe,input:{}})}catch(e){h(e instanceof Error?e.message:String(e))}};return e(`div`,{className:`flex flex-col gap-1 min-w-[9rem] max-w-[16rem]`,children:[x?e(T,{variant:`unstyled`,type:`button`,onClick:()=>void w(),className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger border border-danger/40 hover:bg-danger/10`,children:[n(p,{className:`h-3 w-3`}),a(`common.cancel`,`Cancel`)]}):e(T,{variant:`unstyled`,type:`button`,onClick:()=>void C(),disabled:g,title:a(`storage.locationDiscardControl.permanentlyDeleteLeftoverFilesOn`,`Permanently delete leftover files on this location. Other locations are not affected.`),className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger border border-danger/40 hover:bg-danger/10 disabled:opacity-50`,children:[g?n(s,{className:`h-3 w-3 animate-spin`}):n(_,{className:`h-3 w-3`}),a(`storage.locationDiscardControl.discardLeftovers`,`Discard leftovers`)]}),S&&d!==null&&e(`div`,{className:`space-y-0.5`,children:[n(`div`,{className:`h-1 rounded bg-border overflow-hidden`,children:n(`div`,{className:`h-full bg-primary transition-[width] duration-300`,style:{width:`${De(d)}%`}})}),e(`p`,{className:`text-[10px] text-foreground-subtle leading-tight`,children:[d.phase,d.camerasTotal>0?` · ${a(`storage.locationDiscardControl.camsProgress`,{done:d.camerasDone,total:d.camerasTotal})}`:``,d.dbRowsDeleted>0?` · ${a(`storage.locationDiscardControl.rowsDeleted`,{count:d.dbRowsDeleted})}`:``,d.detail?` · ${d.detail}`:``]})]}),(m||y&&d?.error)&&n(`p`,{className:`text-[10px] text-danger leading-tight`,children:m??d?.error})]})}a();var Z={active:u,readonly:g,drain:v,disabled:f},je={active:`border-success/30 text-success hover:bg-success/10`,readonly:`border-border text-foreground-subtle hover:text-foreground hover:bg-primary/10`,drain:`border-warning/40 text-warning hover:bg-warning/10`,disabled:`border-danger/40 text-danger hover:bg-danger/10`};function Me({mode:t,open:r,onToggle:i}){let{t:a}=D(),o=V(t),s=Z[t];return e(T,{variant:`unstyled`,type:`button`,"aria-expanded":r,"aria-label":a(`storage.locationModeSelector.locationState`,`Location state`),onClick:i,title:o.consequence,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium border ${je[t]}`,children:[n(s,{className:`h-3 w-3`}),o.label,n(h,{className:`h-3 w-3 ${r?`rotate-180`:``}`})]})}function Ne({mode:t,blockedReasons:i,onSelect:a,onDismiss:o}){let{t:s}=D();return r(()=>{let e=e=>{e.key===`Escape`&&o()};return window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`keydown`,e)}},[o]),e(`div`,{className:`w-full basis-full rounded-lg border border-border bg-background p-1`,role:`group`,"aria-label":s(`storage.locationModeSelector.locationStateChoices`,`Location state choices`),children:[e(`div`,{className:`flex items-center justify-between px-2 py-1`,children:[n(`span`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:s(`storage.locationModeSelector.locationState`,`Location state`)}),n(T,{variant:`unstyled`,type:`button`,"aria-label":s(`storage.locationModeSelector.closeLocationStateChoices`,`Close location state choices`),onClick:o,className:`text-foreground-subtle hover:text-foreground`,children:n(p,{className:`h-3 w-3`})})]}),B.map(r=>{let c=i[r.mode],l=c!==``,u=Z[r.mode],d=r.mode===t;return e(T,{variant:`unstyled`,type:`button`,role:`radio`,"aria-checked":d,"aria-label":r.label,disabled:l,onClick:()=>{l||(o(),d||a(r.mode))},className:`flex w-full flex-col items-start gap-0.5 rounded px-2 py-1.5 text-left ${l?`cursor-not-allowed opacity-60`:d?`bg-primary/10`:`hover:bg-primary/5`}`,children:[e(`span`,{className:`flex items-center gap-1.5 text-[11px] font-medium text-foreground`,children:[n(u,{className:`h-3 w-3`}),r.label,d&&n(`span`,{className:`text-[9px] uppercase text-primary`,children:s(`common.current`)})]}),n(`span`,{className:`text-[10px] leading-snug text-foreground-subtle`,children:r.consequence}),l&&n(`span`,{className:`text-[10px] leading-snug text-warning`,children:c})]},r.mode)})]})}function Pe(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Q(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function Fe(e){if(!Pe(e))return null;let t=e.locationId;if(typeof t!=`string`||t.length===0)return null;let n=Q(e.startedAtMs),r=Q(e.startBytes),i=Q(e.bytesRemaining);return n===null||r===null||i===null||typeof e.drained!=`boolean`?null:{locationId:t,startedAtMs:n,startBytes:r,bytesRemaining:i,drained:e.drained,estimatedEmptyAtMs:Q(e.estimatedEmptyAtMs)}}function Ie(e){let t=new Map;if(!Array.isArray(e))return t;for(let n of e){let e=Fe(n);e!==null&&t.set(e.locationId,e)}return t}function Le(e){if(e.startBytes<=0||e.bytesRemaining>e.startBytes)return null;let t=e.startBytes-e.bytesRemaining;return Math.min(1,Math.max(0,t/e.startBytes))}function Re(e,t){return e?t===void 0?{kind:`unreported`}:t.drained||t.bytesRemaining<=0?{kind:`drained`}:{kind:`draining`,bytesRemaining:t.bytesRemaining,drainedFraction:Le(t),estimatedEmptyAtMs:t.estimatedEmptyAtMs}:{kind:`idle`}}function ze(e){return e.mode===`drain`?!0:e.config.readOnly===!0}var Be=[`recordings`,`recordingsLow`];function Ve(e){return e.locationIds!==void 0&&e.locationIds.length>0?e.locationIds:e.locationId===null?[]:[e.locationId]}function He(e,t){if(t===void 0||!Be.includes(e.type))return null;let n=t.find(t=>Ve(t).includes(e.id));return n===void 0||!Number.isFinite(n.usedBytes)||n.usedBytes<0?null:n.usedBytes}function Ue(e,t){let n=new Map;for(let r of e){let e=He(r,t);e!==null&&n.set(r.id,e)}return n}a();var We=[];function $(){let e=C({}),n=te({},{refetchOnWindowFocus:!1}),r=w({},{refetchOnWindowFocus:!1}),i=e.data??We,a=t(()=>Ue(i,n.data?.locations),[i,n.data?.locations]),o=t(()=>Ie(r.data),[r.data]);return t(()=>({locations:i,ownedBytesById:a,drainOf:e=>Re(ze(e),o.get(e.id))}),[i,a,o])}a();function Ge({row:t}){let{t:r}=D(),a=l(),s=o(),c=$(),[u,d]=i(!1),f=S({onSuccess:()=>{s.invalidateQueries({queryKey:[k]}),s.invalidateQueries({queryKey:[[`storage`,`listLocations`]]}),d(!1)},onError:e=>O({title:r(`system.storage.modeFailed`,`Could not change the state`),message:`${t.name}: ${e.message}`,severity:`critical`})}),p=c.locations.find(e=>e.id===t.id);if(p===void 0)return null;let m=c.locations.filter(e=>e.type===p.type),h=R(p),g=c.drainOf(p),_=async e=>{ue(e)&&!await a({title:r(`system.storage.disable`,`Disable "{{displayName}}"?`,{displayName:p.displayName}),message:r(`system.storage.nothingIsDeletedSetThe`,`{{consequence}} Nothing is deleted — set the location back to Read-only or Active to bring its footage back.`,{consequence:V(e).consequence}),confirmLabel:r(`common.disable`,`Disable`),variant:`danger`})||f.mutate({addonId:t.addonId,id:t.id,values:{mode:e}})};return e(`div`,{className:`flex flex-wrap items-start gap-x-3 gap-y-2 rounded-lg border border-border bg-surface p-3`,children:[e(`div`,{className:`min-w-0 flex-1 basis-60`,children:[n(K,{location:p,ownedBytes:c.ownedBytesById.get(p.id)??null}),g.kind!==`idle`&&n(se,{drain:g})]}),e(`div`,{className:`flex flex-wrap items-center gap-1`,children:[n(ke,{location:p,siblings:m}),n(Me,{mode:h,open:u,onToggle:()=>d(e=>!e)})]}),u&&n(Ne,{mode:h,blockedReasons:fe(p,m),onSelect:e=>void _(e),onDismiss:()=>d(!1)})]})}function Ke({row:t}){let r=$();if(t.kind!==`instance`)return null;let i=r.locations.find(e=>e.id===t.id);if(i===void 0)return null;let a=r.drainOf(i);return e(`div`,{className:`min-w-48`,children:[n(K,{location:i,ownedBytes:r.ownedBytesById.get(i.id)??null}),a.kind!==`idle`&&n(se,{drain:a})]})}function qe({row:e}){let t=$();if(e.kind!==`instance`)return null;let r=t.locations.find(t=>t.id===e.id);if(r===void 0)return null;let i=R(r);return n(ee,{variant:i===`active`?`success`:i===`disabled`?`danger`:`default`,children:V(i).label})}function Je(e){return[{key:`capacity`,header:e.capacity,notSortableReason:e.capacity,render:e=>n(Ke,{row:e})},{key:`mode`,header:e.mode,nowrap:!0,notSortableReason:e.mode,render:e=>n(qe,{row:e})}]}function Ye(e,t,n){return!(n===`single`||t.length<=1||z(R(e))&&t.filter(e=>z(R(e))).length<=1)}a();var Xe=`storage`;function Ze({kinds:e}){let{t:r}=D(),{locations:i}=$(),a=x({}).data,o=e=>{let t=i.find(t=>t.id===e.id),n=a?.find(e=>e.id===t?.type);return t===void 0||n===void 0?!1:Ye(t,i.filter(e=>e.type===t.type),n.cardinality)},s=t(()=>Je({capacity:r(`system.storage.colCapacity`,`Capacity`),mode:r(`system.storage.colMode`,`State`)}),[r]),l=t(()=>e===void 0?void 0:t=>t.kind===`instance`&&t.kindId!==void 0&&e.includes(t.kindId),[e]);return n(ne,{functionCap:Xe,icon:c,title:r(`system.storage.title`,`Storage locations`),subtitle:r(`system.storage.subtitle`,`Where recordings, event media, artifacts and backups are kept. Each location is one kind on one provider; the state decides whether it takes writes, is only read, drains or is left alone.`),emptyTitle:r(`system.storage.emptyTitle`,`No storage locations yet`),emptyDescription:r(`system.storage.noStorageLocationsDeclaredBy`,`No storage locations declared by any installed addon.`),addLabel:r(`system.storage.addLocation`,`Add location`),extraColumns:s,lead:e=>n(Ge,{row:e}),canDelete:o,rowActions:e=>o(e)?n(ie,{row:e}):null,...l===void 0?{}:{rowFilter:l}})}export{P as n,ce as r,Ze as t};
|
|
1
|
+
import{C as e,K as t,S as n,V as r,Y as i,et as a,o}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Fr as s,Zr as c,ct as l,er as u,jn as d,mi as f,wt as p}from"./player-overlays-VrMHBBfa.js";import{$s as m}from"./client-CBrsD14Q.js";import{t as h}from"./chevron-down-CBb-F8DT.js";import{t as g}from"./archive-ChKlYFY2.js";import{t as _}from"./eraser-B3lnG9yK.js";import{t as v}from"./hard-drive-download-C6N6tovA.js";import{$f as y,Ha as b,Hd as x,Lc as S,Ud as C,Vd as w,Wf as T,ma as ee,pd as te}from"./src-bJ4Hy4Cl.js";import{t as E}from"./i18n-BFxrpjSx.js";import{t as D}from"./useTranslation-BJr-n0es.js";import{kt as O,pt as k}from"./index-1bBrNxAK.js";import{t as A}from"./format-size-DIxKXxtj.js";import{t as ne}from"./InstancesTable-Cn1INVUs.js";a();var re=`forceDeleteLocation`;function ie({row:e}){let{t}=D(),r=l(),i=o(),a=b(),s=async()=>{if(await r({title:t(`system.storage.forceDeleteTitle`,`Force delete "{{name}}"?`,{name:e.name}),message:t(`system.storage.forceDeleteNote`,`Removes the record only, without checking what is on the location. Anything still stored there becomes unreachable — index rows naming it stop resolving, and playback of those segments goes silently black rather than erroring.`),confirmLabel:t(`system.storage.forceDelete`,`Force delete`),variant:`danger`}))try{await a.mutateAsync({addonId:e.addonId,action:re,input:{id:e.id}}),await i.invalidateQueries({queryKey:[k]}),await i.invalidateQueries({queryKey:[[`storage`,`listLocations`]]})}catch(n){O({title:t(`providerInstances.deleteFailed`,`Could not delete`),message:`${e.name}: ${n instanceof Error?n.message:String(n)}`,severity:`critical`})}};return n(y,{icon:d,variant:`ghost`,size:`sm`,disabled:a.isPending,"aria-label":t(`system.storage.forceDeleteRow`,`Force delete {{name}}`,{name:e.name}),onClick:()=>void s()})}function ae(e){return`${(e/1024**3).toFixed(e>=100*1024**3?0:1)} GB`}function oe(e){return new Date(e).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`})}function se({drain:t}){let{t:r}=D();if(t.kind===`idle`)return null;if(t.kind===`unreported`)return n(`span`,{"data-testid":`drain-unreported`,className:`text-[10px] text-foreground-subtle`,title:r(`storage.drainProgressLine.thisLocationIsDrainingThe`,`This location is draining. The hub has not reported how much is left yet — either the drain has just been set, or this hub predates the drain-progress report.`),children:r(`storage.drainProgressLine.drainingRemainingNotReportedYet`,`Draining · remaining not reported yet`)});if(t.kind===`drained`)return n(`span`,{"data-testid":`drain-done`,className:`text-[10px] text-success`,title:r(`storage.drainProgressLine.everythingThatWasHereHas`,`Everything that was here has been moved. The location is still in drain mode — it receives no new writes until you change that.`),children:r(`storage.drainProgressLine.drainedNothingLeftToMove`,`Drained · nothing left to move`)});let i=t.drainedFraction===null?null:Math.round(t.drainedFraction*100);return e(`span`,{"data-testid":`drain-progress`,className:`flex items-center gap-1.5 text-[10px] text-foreground-subtle tabular-nums`,children:[i!==null&&n(`span`,{"data-testid":`drain-bar`,className:`inline-block h-1 w-10 rounded-full bg-border overflow-hidden`,role:`progressbar`,"aria-label":r(`storage.drainProgressLine.drainProgress`,`Drain progress`),"aria-valuenow":i,"aria-valuemin":0,"aria-valuemax":100,children:n(`span`,{className:`block h-full bg-warning`,style:{width:`${i}%`}})}),e(`span`,{children:[r(`storage.drainProgressLine.left`,{size:ae(t.bytesRemaining)}),i!==null&&` · ${r(`storage.drainProgressLine.moved`,{percent:i})}`]}),t.estimatedEmptyAtMs===null?n(`span`,{"data-testid":`drain-eta-absent`,title:r(`storage.drainProgressLine.theDrainIsPacedBy`,`The drain is paced by how fast this class of data is still growing, and that has not been observed yet. There is no date to give.`),children:r(`storage.drainProgressLine.emptyTimeNotKnownYet`,`· empty time not known yet`)}):e(`span`,{"data-testid":`drain-eta`,children:[`·`,` `,r(`storage.drainProgressLine.empty`,{when:oe(t.estimatedEmptyAtMs)})]})]})}var j=[`ok`,`warn`,`critical`];function M(e){return e>=.95?`critical`:e>=.85?`warn`:`ok`}function N(e){return Math.min(1,Math.max(0,e))}function P(e){let{availableBytes:t,totalBytes:n}=e;if(n===null||n<=0||t===null)return null;let r=N((n-t)/n);return{fraction:r,severity:M(r),recordingsFraction:N(e.usedBytes/n),freeBytes:t,totalBytes:n}}function ce(e){if(e.length===0)return null;let t=0,n=0,r=0,i=0,a=null;for(let o of e){let e=P(o);if(e===null){n+=1;continue}t+=1,r+=e.totalBytes,i+=e.freeBytes,(a===null||j.indexOf(e.severity)>j.indexOf(a))&&(a=e.severity)}return{knownVolumes:t,unknownVolumes:n,totalBytes:r,freeBytes:i,severity:a}}function F(e){return Math.min(1,Math.max(0,e))}function I(e){return Math.round(F(e)*1e3)/10}function L(e){return`${String(Math.round(F(e)*100))}%`}function le(e,t,n={}){let{totalBytes:r,availableBytes:i}=e;if(r===null||r<=0||i===null){let e=n.ownedBytes===void 0||n.ownedBytes===null||!Number.isFinite(n.ownedBytes)||n.ownedBytes<0?null:A(n.ownedBytes);return{kind:`unknown`,owned:e,summary:e===null?E.t(`helpers.locationCapacityBar.unknownSummary`):E.t(`helpers.locationCapacityBar.unknownSummaryOwned`,{size:e})}}let a=Math.min(Math.max(i,0),r),o=r-a,s=t===null||t<=0?0:t,c=Math.min(s,a),l=s>a,u=a-c,d=n.ownedBytes,f=d==null||!Number.isFinite(d)||d<0?null:Math.min(d,o),p=o-(f??0),m=P({usedBytes:f??o,availableBytes:a,totalBytes:r}),h=m===null?F(o/r):m.fraction,g=m===null?M(h):m.severity,_=f===null?null:m===null?F(f/r):m.recordingsFraction,v=n.cap??null,y=v===null?null:F((c+v.bytes)/r),b=v!==null&&f!==null&&f>v.bytes,x={total:A(r),freeTotal:A(a),freeTotalPercent:L(a/r),used:A(p),usedPercent:L(p/r),free:A(u),freePercent:L(u/r),reserve:s===0?null:E.t(`helpers.locationCapacityBar.reserveKept`,{size:A(s)}),owned:f===null||_===null?null:E.t(`helpers.locationCapacityBar.ownedOfRecordings`,{size:A(f),percent:L(_)}),cap:v===null?null:v.reason===`drain`?E.t(`helpers.locationCapacityBar.capDrain`,{size:A(v.bytes)}):E.t(`helpers.locationCapacityBar.capCap`,{size:A(v.bytes)})},S=[E.t(`helpers.locationCapacityBar.summaryFree`,{free:x.freeTotal,total:x.total,percent:x.freeTotalPercent}),x.owned===null?null:E.t(`helpers.locationCapacityBar.summaryOwned`,{owned:x.owned}),x.reserve===null?null:l?E.t(`helpers.locationCapacityBar.summaryReserveShort`,{reserve:x.reserve}):x.reserve,x.cap===null?null:b?E.t(`helpers.locationCapacityBar.summaryCapBelow`,{cap:x.cap}):x.cap].filter(e=>e!==null).join(` · `),C=[];return c>0&&C.push({segment:`reserve`,label:E.t(`helpers.locationCapacityBar.legendKeptFree`),value:A(s),alarming:l}),x.owned!==null&&C.push({segment:`owned`,label:E.t(`helpers.locationCapacityBar.legendCamstack`),value:x.owned,alarming:!1}),C.push({segment:`used`,label:f===null?E.t(`helpers.locationCapacityBar.legendUsed`):E.t(`helpers.locationCapacityBar.legendOtherData`),value:`${x.used} (${x.usedPercent})`,alarming:g===`critical`}),C.push({segment:`free`,label:E.t(`helpers.locationCapacityBar.legendFree`),value:`${x.free} (${x.freePercent})`,alarming:l}),v!==null&&C.push({segment:`cap`,label:v.reason===`drain`?E.t(`helpers.locationCapacityBar.legendDrainTarget`):E.t(`helpers.locationCapacityBar.legendCap`),value:E.t(`helpers.locationCapacityBar.legendCapValue`,{size:A(v.bytes)}),alarming:b}),{kind:`known`,severity:g,legend:C,segments:{reservePercent:I(c/r),ownedPercent:f===null?null:I(f/r),usedPercent:I(p/r),freePercent:I(u/r),capPercent:y===null?null:I(y)},labels:x,reserveExceedsFree:l,capBelowOwned:b,summary:S}}function R(e){return m(e)}function z(e){return e===`active`}var B=[{mode:`active`,get label(){return E.t(`helpers.locationMode.activeLabel`)},get consequence(){return E.t(`helpers.locationMode.activeConsequence`)},requiresConfirmation:!1},{mode:`readonly`,get label(){return E.t(`helpers.locationMode.readonlyLabel`)},get consequence(){return E.t(`helpers.locationMode.readonlyConsequence`)},requiresConfirmation:!1},{mode:`drain`,get label(){return E.t(`helpers.locationMode.drainLabel`)},get consequence(){return E.t(`helpers.locationMode.drainConsequence`)},requiresConfirmation:!1},{mode:`disabled`,get label(){return E.t(`helpers.locationMode.disabledLabel`)},get consequence(){return E.t(`helpers.locationMode.disabledConsequence`)},requiresConfirmation:!0}];function V(e){return B.find(t=>t.mode===e)??B[0]}function ue(e){return V(e).requiresConfirmation}var de=`Blocked: this is the last location of its type still accepting writes — new data would have nowhere to go.`;function H(e,t,n){return z(n)||!z(R(e))||t.some(t=>t.id!==e.id&&z(R(t)))?{blocked:!1,reason:``}:{blocked:!0,reason:de}}function fe(e,t){return{active:H(e,t,`active`).reason,readonly:H(e,t,`readonly`).reason,drain:H(e,t,`drain`).reason,disabled:H(e,t,`disabled`).reason}}var pe=1024**3;function U(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function me(e){let t=U(e.minFreeGb);if(t!==null)return{unit:`gb`,value:t};let n=U(e.minFreePercent);return n===null?{unit:`percent`,value:null}:{unit:`percent`,value:n}}function he(e,t,n=10){if(e.unit===`gb`&&e.value!==null)return e.value*pe;let r=e.value??n;return t===null||t<=0?null:t*Math.min(100,Math.max(0,r))/100}function ge(e,t){let n=U(e.maxUsedGb);return n===null||n<0?null:{bytes:n*pe,reason:t===`drain`?`drain`:`legacy`}}var W={ok:`bg-primary`,warn:`bg-warning`,critical:`bg-danger`},G={reserve:`bg-danger/40`,owned:`bg-foreground/50`,free:`bg-border`,cap:`bg-foreground`};function _e(e,t){return e===`used`?W[t]:G[e]}function K({location:t,ownedBytes:r}){let{t:i}=D(),a=t.capacity??null,o=he(me(t.config),a?.totalBytes??null),s=le({totalBytes:a?.totalBytes??null,availableBytes:a?.availableBytes??null},o,{ownedBytes:r??null,cap:ge(t.config,R(t))});return s.kind===`unknown`?n(`div`,{className:`text-[10px] text-foreground-subtle italic`,title:s.summary,children:s.owned===null?i(`storage.locationCapacityBar.capacityUnknown`,`Capacity unknown`):i(`storage.locationCapacityBar.capacityUnknownCamstackHolds`,`Capacity unknown · CamStack holds {{owned}}`,{owned:s.owned})}):e(`div`,{className:`mt-1 space-y-1`,title:s.summary,children:[e(`div`,{className:`relative flex h-2 w-full max-w-md overflow-hidden rounded-full bg-border`,children:[s.segments.reservePercent>0&&n(`div`,{className:G.reserve,style:{width:`${String(s.segments.reservePercent)}%`}}),s.segments.ownedPercent!==null&&n(`div`,{className:G.owned,style:{width:`${String(s.segments.ownedPercent)}%`}}),n(`div`,{className:W[s.severity],style:{width:`${String(s.segments.usedPercent)}%`}}),n(`div`,{className:G.free,style:{width:`${String(s.segments.freePercent)}%`}}),s.segments.capPercent!==null&&n(`div`,{className:`absolute inset-y-0 w-px ${s.capBelowOwned?`bg-danger`:G.cap}`,style:{left:`${String(s.segments.capPercent)}%`}})]}),n(`ul`,{className:`flex flex-wrap items-center gap-x-3 gap-y-0.5`,children:s.legend.map(t=>e(`li`,{className:`flex items-center gap-1`,children:[n(`span`,{"aria-hidden":`true`,className:`inline-block h-2 w-2 shrink-0 rounded-sm ${_e(t.segment,s.severity)}`}),e(`span`,{className:`text-[10px] tabular-nums ${t.alarming?`text-danger`:`text-foreground-subtle`}`,children:[t.label,` `,t.value]})]},t.segment))})]})}var ve={eventMedia:[`events`],recordingsLow:[`low`],recordings:[`high`,`mid`]},ye={eventMedia:`pipeline-analytics`,recordingsLow:`recorder`,recordings:`recorder`},be=`storage.discardLocation`,q=`storage.discardLocationStatus`,xe=`storage.discardLocationCancel`;function Se(e){return ve[e]??null}function Ce(e){return ye[e]??null}function we(e){return!z(R(e))}function Te(e,t){return Se(e.type)===null||!we(e)?!1:t.some(t=>t.id!==e.id&&z(R(t)))}var Ee=new Set([`idle`,`scanning`,`wiping-fs`,`wiping-db`,`cascading`,`complete`,`cancelled`,`error`]);function J(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function Y(e){return typeof e==`string`?e:null}function X(e){if(typeof e!=`object`||!e)return null;let t=e;if(typeof t.running!=`boolean`)return null;let n=t.phase;if(typeof n!=`string`||!Ee.has(n))return null;let r=J(t.camerasTotal),i=J(t.camerasDone),a=J(t.foldersRemoved),o=J(t.dbRowsDeleted),s=J(t.ownersCascaded);return r===null||i===null||a===null||o===null||s===null?null:{running:t.running,locationId:Y(t.locationId),jobId:Y(t.jobId),phase:n,camerasTotal:r,camerasDone:i,foldersRemoved:a,dbRowsDeleted:o,ownersCascaded:s,detail:Y(t.detail)??``,startedAtMs:J(t.startedAtMs),finishedAtMs:J(t.finishedAtMs),error:Y(t.error)}}function De(e){if(e.phase===`complete`)return 100;if(e.phase===`cancelled`||e.phase===`error`||e.phase===`idle`)return e.camerasTotal>0?Math.min(99,Math.round(e.camerasDone/e.camerasTotal*100)):0;if(e.camerasTotal>0){let t=e.camerasDone/e.camerasTotal*85;return e.phase===`wiping-db`?Math.min(95,Math.round(t+8)):e.phase===`cascading`?Math.min(99,Math.round(t+12)):Math.min(85,Math.round(t))}return e.phase===`scanning`?2:5}var Oe=2e3;function ke({location:e,siblings:t}){return Te(e,t)?n(Ae,{location:e}):null}function Ae({location:t}){let{t:a}=D(),o=l(),c=b(),u=Ce(t.type),[d,f]=i(null),[m,h]=i(null),[g,v]=i(!1);if(r(()=>{if(u===null)return;let e=!1,t=async()=>{try{let t=await c.mutateAsync({addonId:u,action:q,input:{}});if(e)return;f(X(t))}catch{}};t();let n=setInterval(()=>void t(),Oe);return()=>{e=!0,clearInterval(n)}},[u,t.id]),u===null)return null;let y=d!==null&&d.locationId===t.id,x=y&&d.running,S=y&&d.phase!==`idle`,C=async()=>{if(await o({title:a(`storage.locationDiscardControl.discardLeftoversOn`,`Discard leftovers on "{{displayName}}"?`,{displayName:t.displayName}),message:a(`storage.locationDiscardControl.permanentlyDeletesLeftoverFilesAnd`,`Permanently deletes leftover files and records on this location. Other locations are not affected. This cannot be undone and may take hours.`),confirmLabel:a(`storage.locationDiscardControl.discardLeftovers`,`Discard leftovers`),variant:`danger`})){h(null),v(!0);try{await c.mutateAsync({addonId:u,action:be,input:{locationId:t.id}}),f(X(await c.mutateAsync({addonId:u,action:q,input:{}})))}catch(e){h(e instanceof Error?e.message:String(e))}finally{v(!1)}}},w=async()=>{try{await c.mutateAsync({addonId:u,action:xe,input:{}})}catch(e){h(e instanceof Error?e.message:String(e))}};return e(`div`,{className:`flex flex-col gap-1 min-w-[9rem] max-w-[16rem]`,children:[x?e(T,{variant:`unstyled`,type:`button`,onClick:()=>void w(),className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger border border-danger/40 hover:bg-danger/10`,children:[n(p,{className:`h-3 w-3`}),a(`common.cancel`,`Cancel`)]}):e(T,{variant:`unstyled`,type:`button`,onClick:()=>void C(),disabled:g,title:a(`storage.locationDiscardControl.permanentlyDeleteLeftoverFilesOn`,`Permanently delete leftover files on this location. Other locations are not affected.`),className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger border border-danger/40 hover:bg-danger/10 disabled:opacity-50`,children:[g?n(s,{className:`h-3 w-3 animate-spin`}):n(_,{className:`h-3 w-3`}),a(`storage.locationDiscardControl.discardLeftovers`,`Discard leftovers`)]}),S&&d!==null&&e(`div`,{className:`space-y-0.5`,children:[n(`div`,{className:`h-1 rounded bg-border overflow-hidden`,children:n(`div`,{className:`h-full bg-primary transition-[width] duration-300`,style:{width:`${De(d)}%`}})}),e(`p`,{className:`text-[10px] text-foreground-subtle leading-tight`,children:[d.phase,d.camerasTotal>0?` · ${a(`storage.locationDiscardControl.camsProgress`,{done:d.camerasDone,total:d.camerasTotal})}`:``,d.dbRowsDeleted>0?` · ${a(`storage.locationDiscardControl.rowsDeleted`,{count:d.dbRowsDeleted})}`:``,d.detail?` · ${d.detail}`:``]})]}),(m||y&&d?.error)&&n(`p`,{className:`text-[10px] text-danger leading-tight`,children:m??d?.error})]})}a();var Z={active:u,readonly:g,drain:v,disabled:f},je={active:`border-success/30 text-success hover:bg-success/10`,readonly:`border-border text-foreground-subtle hover:text-foreground hover:bg-primary/10`,drain:`border-warning/40 text-warning hover:bg-warning/10`,disabled:`border-danger/40 text-danger hover:bg-danger/10`};function Me({mode:t,open:r,onToggle:i}){let{t:a}=D(),o=V(t),s=Z[t];return e(T,{variant:`unstyled`,type:`button`,"aria-expanded":r,"aria-label":a(`storage.locationModeSelector.locationState`,`Location state`),onClick:i,title:o.consequence,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium border ${je[t]}`,children:[n(s,{className:`h-3 w-3`}),o.label,n(h,{className:`h-3 w-3 ${r?`rotate-180`:``}`})]})}function Ne({mode:t,blockedReasons:i,onSelect:a,onDismiss:o}){let{t:s}=D();return r(()=>{let e=e=>{e.key===`Escape`&&o()};return window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`keydown`,e)}},[o]),e(`div`,{className:`w-full basis-full rounded-lg border border-border bg-background p-1`,role:`group`,"aria-label":s(`storage.locationModeSelector.locationStateChoices`,`Location state choices`),children:[e(`div`,{className:`flex items-center justify-between px-2 py-1`,children:[n(`span`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:s(`storage.locationModeSelector.locationState`,`Location state`)}),n(T,{variant:`unstyled`,type:`button`,"aria-label":s(`storage.locationModeSelector.closeLocationStateChoices`,`Close location state choices`),onClick:o,className:`text-foreground-subtle hover:text-foreground`,children:n(p,{className:`h-3 w-3`})})]}),B.map(r=>{let c=i[r.mode],l=c!==``,u=Z[r.mode],d=r.mode===t;return e(T,{variant:`unstyled`,type:`button`,role:`radio`,"aria-checked":d,"aria-label":r.label,disabled:l,onClick:()=>{l||(o(),d||a(r.mode))},className:`flex w-full flex-col items-start gap-0.5 rounded px-2 py-1.5 text-left ${l?`cursor-not-allowed opacity-60`:d?`bg-primary/10`:`hover:bg-primary/5`}`,children:[e(`span`,{className:`flex items-center gap-1.5 text-[11px] font-medium text-foreground`,children:[n(u,{className:`h-3 w-3`}),r.label,d&&n(`span`,{className:`text-[9px] uppercase text-primary`,children:s(`common.current`)})]}),n(`span`,{className:`text-[10px] leading-snug text-foreground-subtle`,children:r.consequence}),l&&n(`span`,{className:`text-[10px] leading-snug text-warning`,children:c})]},r.mode)})]})}function Pe(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Q(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function Fe(e){if(!Pe(e))return null;let t=e.locationId;if(typeof t!=`string`||t.length===0)return null;let n=Q(e.startedAtMs),r=Q(e.startBytes),i=Q(e.bytesRemaining);return n===null||r===null||i===null||typeof e.drained!=`boolean`?null:{locationId:t,startedAtMs:n,startBytes:r,bytesRemaining:i,drained:e.drained,estimatedEmptyAtMs:Q(e.estimatedEmptyAtMs)}}function Ie(e){let t=new Map;if(!Array.isArray(e))return t;for(let n of e){let e=Fe(n);e!==null&&t.set(e.locationId,e)}return t}function Le(e){if(e.startBytes<=0||e.bytesRemaining>e.startBytes)return null;let t=e.startBytes-e.bytesRemaining;return Math.min(1,Math.max(0,t/e.startBytes))}function Re(e,t){return e?t===void 0?{kind:`unreported`}:t.drained||t.bytesRemaining<=0?{kind:`drained`}:{kind:`draining`,bytesRemaining:t.bytesRemaining,drainedFraction:Le(t),estimatedEmptyAtMs:t.estimatedEmptyAtMs}:{kind:`idle`}}function ze(e){return e.mode===`drain`?!0:e.config.readOnly===!0}var Be=[`recordings`,`recordingsLow`];function Ve(e){return e.locationIds!==void 0&&e.locationIds.length>0?e.locationIds:e.locationId===null?[]:[e.locationId]}function He(e,t){if(t===void 0||!Be.includes(e.type))return null;let n=t.find(t=>Ve(t).includes(e.id));return n===void 0||!Number.isFinite(n.usedBytes)||n.usedBytes<0?null:n.usedBytes}function Ue(e,t){let n=new Map;for(let r of e){let e=He(r,t);e!==null&&n.set(r.id,e)}return n}a();var We=[];function $(){let e=C({}),n=te({},{refetchOnWindowFocus:!1}),r=w({},{refetchOnWindowFocus:!1}),i=e.data??We,a=t(()=>Ue(i,n.data?.locations),[i,n.data?.locations]),o=t(()=>Ie(r.data),[r.data]);return t(()=>({locations:i,ownedBytesById:a,drainOf:e=>Re(ze(e),o.get(e.id))}),[i,a,o])}a();function Ge({row:t}){let{t:r}=D(),a=l(),s=o(),c=$(),[u,d]=i(!1),f=S({onSuccess:()=>{s.invalidateQueries({queryKey:[k]}),s.invalidateQueries({queryKey:[[`storage`,`listLocations`]]}),d(!1)},onError:e=>O({title:r(`system.storage.modeFailed`,`Could not change the state`),message:`${t.name}: ${e.message}`,severity:`critical`})}),p=c.locations.find(e=>e.id===t.id);if(p===void 0)return null;let m=c.locations.filter(e=>e.type===p.type),h=R(p),g=c.drainOf(p),_=async e=>{ue(e)&&!await a({title:r(`system.storage.disable`,`Disable "{{displayName}}"?`,{displayName:p.displayName}),message:r(`system.storage.nothingIsDeletedSetThe`,`{{consequence}} Nothing is deleted — set the location back to Read-only or Active to bring its footage back.`,{consequence:V(e).consequence}),confirmLabel:r(`common.disable`,`Disable`),variant:`danger`})||f.mutate({addonId:t.addonId,id:t.id,values:{mode:e}})};return e(`div`,{className:`flex flex-wrap items-start gap-x-3 gap-y-2 rounded-lg border border-border bg-surface p-3`,children:[e(`div`,{className:`min-w-0 flex-1 basis-60`,children:[n(K,{location:p,ownedBytes:c.ownedBytesById.get(p.id)??null}),g.kind!==`idle`&&n(se,{drain:g})]}),e(`div`,{className:`flex flex-wrap items-center gap-1`,children:[n(ke,{location:p,siblings:m}),n(Me,{mode:h,open:u,onToggle:()=>d(e=>!e)})]}),u&&n(Ne,{mode:h,blockedReasons:fe(p,m),onSelect:e=>void _(e),onDismiss:()=>d(!1)})]})}function Ke({row:t}){let r=$();if(t.kind!==`instance`)return null;let i=r.locations.find(e=>e.id===t.id);if(i===void 0)return null;let a=r.drainOf(i);return e(`div`,{className:`min-w-48`,children:[n(K,{location:i,ownedBytes:r.ownedBytesById.get(i.id)??null}),a.kind!==`idle`&&n(se,{drain:a})]})}function qe({row:e}){let t=$();if(e.kind!==`instance`)return null;let r=t.locations.find(t=>t.id===e.id);if(r===void 0)return null;let i=R(r);return n(ee,{variant:i===`active`?`success`:i===`disabled`?`danger`:`default`,children:V(i).label})}function Je(e){return[{key:`capacity`,header:e.capacity,notSortableReason:e.capacity,render:e=>n(Ke,{row:e})},{key:`mode`,header:e.mode,nowrap:!0,notSortableReason:e.mode,render:e=>n(qe,{row:e})}]}function Ye(e,t,n){return!(n===`single`||t.length<=1||z(R(e))&&t.filter(e=>z(R(e))).length<=1)}a();var Xe=`storage`;function Ze({kinds:e}){let{t:r}=D(),{locations:i}=$(),a=x({}).data,o=e=>{let t=i.find(t=>t.id===e.id),n=a?.find(e=>e.id===t?.type);return t===void 0||n===void 0?!1:Ye(t,i.filter(e=>e.type===t.type),n.cardinality)},s=t(()=>Je({capacity:r(`system.storage.colCapacity`,`Capacity`),mode:r(`system.storage.colMode`,`State`)}),[r]),l=t(()=>e===void 0?void 0:t=>t.kind===`instance`&&t.kindId!==void 0&&e.includes(t.kindId),[e]);return n(ne,{functionCap:Xe,icon:c,title:r(`system.storage.title`,`Storage locations`),subtitle:r(`system.storage.subtitle`,`Where recordings, event media, artifacts and backups are kept. Each location is one kind on one provider; the state decides whether it takes writes, is only read, drains or is left alone.`),emptyTitle:r(`system.storage.emptyTitle`,`No storage locations yet`),emptyDescription:r(`system.storage.noStorageLocationsDeclaredBy`,`No storage locations declared by any installed addon.`),addLabel:r(`system.storage.addLocation`,`Add location`),extraColumns:s,lead:e=>n(Ge,{row:e}),canDelete:o,rowActions:e=>o(e)?n(ie,{row:e}):null,...l===void 0?{}:{rowFilter:l}})}export{P as n,ce as r,Ze as t};
|