@dominevo/addon-admin-ui 0.1.1 → 0.1.3
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 +16 -0
- package/dist/assets/{Addons-DXj_703d.js → Addons-CpGBhr79.js} +1 -1
- package/dist/assets/{AdminPage-CA4Sxydy.js → AdminPage-B35tMynm.js} +1 -1
- package/dist/assets/{AdminSectionedPage-3XsaKUPh.js → AdminSectionedPage-RkQwEpsd.js} +1 -1
- package/dist/assets/{AiProfiles-BPuugVHP.js → AiProfiles-DXGNZOrG.js} +1 -1
- package/dist/assets/{Archive-Cs7NaNc_.js → Archive-DzwbviB7.js} +1 -1
- package/dist/assets/{BootstrapSettingsForm-B7n4Tn8W.js → BootstrapSettingsForm-rb7h24St.js} +1 -1
- package/dist/assets/{Build-D7v3yZ31.js → Build-B_K5vb1t.js} +1 -1
- package/dist/assets/{Calendars-5ikY87Kt.js → Calendars-BG_DXgqB.js} +1 -1
- package/dist/assets/{Cluster-CMcu7Iqn.js → Cluster-2e-1VXUZ.js} +1 -1
- package/dist/assets/{CompositionBlockEditor-BP9BOpRr.js → CompositionBlockEditor-DqEQH8XZ.js} +1 -1
- package/dist/assets/{CompositionEditorPage-D_4Dx_8C.js → CompositionEditorPage-CgCRQbi2.js} +1 -1
- package/dist/assets/{Data-Dlx9uZ0Q.js → Data-U9aDnpkV.js} +1 -1
- package/dist/assets/{DeviceDetail-DJXx7Dh3.js → DeviceDetail-BLqSn8fF.js} +1 -1
- package/dist/assets/{Devices-DJd001mb.js → Devices-ZWTiajGA.js} +1 -1
- package/dist/assets/{EmbedDevicePage-Cxe3_S-n.js → EmbedDevicePage-WrtMODXs.js} +1 -1
- package/dist/assets/{EmbedPlayerPage-BKq1BRg_.js → EmbedPlayerPage-B230r_Ap.js} +1 -1
- package/dist/assets/{FormBuilder-BjcOGVVa.js → FormBuilder-BB51iHrB.js} +1 -1
- package/dist/assets/{History-CqTLHyoj.js → History-B69xY-Vn.js} +1 -1
- package/dist/assets/Identity-DrmPc3tf.js +1 -0
- package/dist/assets/{InstancesTable-DVnHkIbJ.js → InstancesTable-2NB3K6Bc.js} +1 -1
- package/dist/assets/{IntegrationDetail-BlopkLuy.js → IntegrationDetail-B5OYMOWk.js} +1 -1
- package/dist/assets/{Integrations-C8TECl9Z.js → Integrations-C7ImeOVN.js} +1 -1
- package/dist/assets/{Integrations-BOr-rN3Z.js → Integrations-y6KQI_YG.js} +1 -1
- package/dist/assets/{Jobs-DnObAnQR.js → Jobs-C0DpPNi0.js} +1 -1
- package/dist/assets/{Library-sG9Ie6Ay.js → Library-Dn9F2bob.js} +1 -1
- package/dist/assets/{Locations-Dh63x-8T.js → Locations-tcBTN0CL.js} +1 -1
- package/dist/assets/{Logs-B3LPrdqh.js → Logs-Ddwn_Is0.js} +1 -1
- package/dist/assets/{MaskShapeCanvas-T6ZNfW4J.js → MaskShapeCanvas-B5mehyBe.js} +1 -1
- package/dist/assets/{MotionZonesSettings-B5KDfHoK.js → MotionZonesSettings-jMkiUUQz.js} +1 -1
- package/dist/assets/{MyAccess-WIUGe7rE.js → MyAccess-C0OQAAby.js} +1 -1
- package/dist/assets/{Network--neqNeoA.js → Network-Cu87Zl0W.js} +1 -1
- package/dist/assets/{NewExportModal-D64AhGe8.js → NewExportModal-DEpoqntE.js} +1 -1
- package/dist/assets/{NodeAddonsSettingsPanel-Bc_UiSsk.js → NodeAddonsSettingsPanel-Bgq8ERZo.js} +1 -1
- package/dist/assets/{Notifications-I66jIXko.js → Notifications-kCFGMKK7.js} +1 -1
- package/dist/assets/{Pipeline-DX80qRVf.js → Pipeline-B-k1j81-.js} +1 -1
- package/dist/assets/{PrivacyMaskSettings-CERwQtiu.js → PrivacyMaskSettings-C4XdrpKI.js} +1 -1
- package/dist/assets/{SceneMonitorEditor-DxTYd8U2.js → SceneMonitorEditor-3kjADoN0.js} +1 -1
- package/dist/assets/SessionsList-DJEvmfQv.js +2 -0
- package/dist/assets/{Showroom-Dkom3it5.js → Showroom-DW6kJtdV.js} +1 -1
- package/dist/assets/{StorageLocationsTable-CujqHG2j.js → StorageLocationsTable-BpamO2AO.js} +1 -1
- package/dist/assets/{System-PnjU9olQ.js → System-PBIGeygM.js} +1 -1
- package/dist/assets/{TemplateEditorDialog-B_8g2CrL.js → TemplateEditorDialog-nX5amI-o.js} +1 -1
- package/dist/assets/{Terminal-BVqOTvEA.js → Terminal-Bqc_BiMO.js} +1 -1
- package/dist/assets/{TrainingProviders-5e1QS5zN.js → TrainingProviders-BaGY_fsT.js} +1 -1
- package/dist/assets/{Viewer-CyLueECm.js → Viewer-K9pbFfye.js} +1 -1
- package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-Cc7iYWcG.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-Iu6fLdXX.js} +1 -1
- package/dist/assets/{ai-page.helpers-CiDsxXp3.js → ai-page.helpers-CH0oD27E.js} +1 -1
- package/dist/assets/{assignment-candidates-BfhoJg-T.js → assignment-candidates-CutnM30g.js} +1 -1
- package/dist/assets/{auth-context-CkfOTCG-.js → auth-context-CbKbPGVG.js} +1 -1
- package/dist/assets/{authed-media-C-zK1a1B.js → authed-media-DDyQ4EVl.js} +1 -1
- package/dist/assets/{board-model-BvqJSvTB.js → board-model-BJOCdYZi.js} +1 -1
- package/dist/assets/{broker-oauth-popup-B_GRcwxo.js → broker-oauth-popup-Bc0452mf.js} +1 -1
- package/dist/assets/{camera-block-model-QrJ_0XZY.js → camera-block-model-Cg9j-LS6.js} +1 -1
- package/dist/assets/{device-integration-icon-D9fVWv4K.js → device-integration-icon-DBlkZ4N3.js} +1 -1
- package/dist/assets/device-picker-model-CzwyZiSZ.js +1 -0
- package/dist/assets/{dist-2ETbjdqB.js → dist-DMgC_62x.js} +1 -1
- package/dist/assets/{dist-B0ixn42U.js → dist-DUZyedAc.js} +3 -3
- package/dist/assets/{format-D43HvBR0.js → format-M1wlEHJl.js} +1 -1
- package/dist/assets/{hostInit-BjOFEl3v.js → hostInit-CiMa3W47.js} +1 -1
- package/dist/assets/i18n-kurEJu5K.js +1 -0
- package/dist/assets/{icons-CNI0rnl8.js → icons-nvRYK39P.js} +1 -1
- package/dist/assets/{index-C1r-vzdu.js → index-uhNZQRiY.js} +3 -3
- package/dist/assets/{linked-devices-model-Dl4vHeXt.js → linked-devices-model-B5XyFLX2.js} +1 -1
- package/dist/assets/{mf-entry-bootstrap-0-64d22ef4.js → mf-entry-bootstrap-0-3b94fe74.js} +2 -2
- package/dist/assets/mount-CzwyZiSZ.js +1 -0
- package/dist/assets/{notification-rule-status-T3SwZb2I.js → notification-rule-status-JiMjbzwM.js} +1 -1
- package/dist/assets/{player-overlays-qzCoRsrQ.js → player-overlays-Cs69NgAR.js} +1 -1
- package/dist/assets/remoteEntry-C4IaCrn1.js +1 -0
- package/dist/assets/{src-CJoX3s-1.js → src-BwDSKCnh.js} +3 -3
- package/dist/assets/{src-Cf1Uvi4o.js → src-DWGf7c88.js} +4 -4
- package/dist/assets/{sso-popup-CPavla3I.js → sso-popup-DVrI_KPY.js} +1 -1
- package/dist/assets/{step-inspector-model-CMrG9Xaa.js → step-inspector-model-BMwzbdW5.js} +1 -1
- package/dist/assets/{use-scenes-feed-CosaOMpn.js → use-scenes-feed-BTeaS3CE.js} +1 -1
- package/dist/assets/{useAdminDeviceRemoval-bOibMOT6.js → useAdminDeviceRemoval-y6kJG-64.js} +1 -1
- package/dist/assets/{useDevice-JbC1lVOL.js → useDevice-BfL2Lixa.js} +1 -1
- package/dist/assets/useEventInvalidation-CzwyZiSZ.js +1 -0
- package/dist/assets/{useFaultTypeOptions-BCjpEaI1.js → useFaultTypeOptions-DJb6ajuT.js} +1 -1
- package/dist/assets/{useNodeUrlSelection-DBU1LRHP.js → useNodeUrlSelection-Dn1QMWS7.js} +1 -1
- package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-BZ1YRJXZ.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-BZVxl24K.js} +2 -2
- package/dist/index.html +12 -12
- package/dist/server/addon.js +1 -1
- package/package.json +2 -2
- package/dist/assets/Identity-CELdhZ4o.js +0 -1
- package/dist/assets/SessionsList-BoOCsi8N.js +0 -2
- package/dist/assets/device-picker-model-CYNi1aEm.js +0 -1
- package/dist/assets/i18n-BHLBFC1-.js +0 -1
- package/dist/assets/mount-CYNi1aEm.js +0 -1
- package/dist/assets/remoteEntry-Dc97BJQ9.js +0 -1
- package/dist/assets/useEventInvalidation-CYNi1aEm.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as e,J as t,K as n,R as r,S as i,V as a,Y as o,a as s,et as c,o as l,x as u}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{$i as d,Dt as f,Ea as p,Fn as m,Gi as h,Gt as g,Ii as _,Kt as v,Nn as y,Oa as b,Oi as x,Pa as S,Pn as C,Si as w,So as T,Tr as E,W as ee,Xi as D,_i as O,_n as k,_t as A,at as j,bo as M,bt as N,do as P,gi as F,hr as I,ht as L,ii as R,it as te,kn as z,la as ne,mi as re,nt as B,oi as V,or as ie,pn as ae,pt as oe,t as se,xn as ce,xo as le,xt as ue,yn as de,yt as H,z as fe,za as pe,zt as me}from"./player-overlays-qzCoRsrQ.js";import{Nc as he,Yl as ge,bt as _e,fl as ve,ki as ye,pl as U}from"./src-CJoX3s-1.js";import{t as be}from"./chevron-down-CBb-F8DT.js";import{g as xe}from"./terminal-BncJ-1sF.js";import{n as Se,r as Ce,t as we}from"./scissors-DpiKUioV.js";import{t as W}from"./square-check-big-DAcFGNUN.js";import{$a as G,$i as Te,$u as Ee,Aa as De,Af as Oe,Am as ke,Ar as Ae,Bu as je,Da as Me,Dr as Ne,Ea as Pe,Fm as Fe,Fr as Ie,Gr as Le,Io as Re,Ir as ze,It as Be,Ja as Ve,Jr as He,Mc as Ue,Oa as We,Od as Ge,Of as Ke,Pa as qe,Pd as Je,Pi as Ye,Q as Xe,Qi as Ze,Qu as Qe,Rr as $e,Ta as et,Va as tt,Yr as nt,Za as K,Zu as rt,_i as it,_p as at,aa as ot,ad as st,am as ct,cd as lt,cp as ut,d as dt,dm as ft,dp as pt,ea as mt,ed as ht,em as gt,fm as _t,fp as vt,gi as yt,gp as bt,hi as xt,hp as St,ia as Ct,id as wt,jf as Tt,ka as Et,kf as Dt,lp as Ot,mm as kt,mp as At,nd as jt,oa as Mt,od as Nt,om as Pt,op as Ft,pm as It,pp as Lt,qi as Rt,rd as zt,sd as Bt,sp as Vt,ta as Ht,td as Ut,tm as Wt,up as Gt,vi as Kt,vr as qt,wd as Jt,xm as Yt,zd as Xt,zr as Zt}from"./src-Cf1Uvi4o.js";import{r as Qt,t as $t}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare__react_mf_2_dom__loadShare__.js-BPba2g2p.js";import{c as en,l as tn,n as nn,p as rn}from"./chunk-4ZMWKKQ3-BCeNTgXs.js";import{t as q}from"./i18n-BHLBFC1-.js";import{t as J}from"./useTranslation-uIxPZ_3N.js";import"./mount-CYNi1aEm.js";import{$t as an,J as on,P as sn,Y as cn,en as ln,in as un,nn as dn,rn as fn,tn as pn}from"./index-C1r-vzdu.js";import{t as mn}from"./AdminSectionedPage-3XsaKUPh.js";import{a as hn,d as gn,f as _n,i as vn,m as yn,n as bn,o as xn,p as Sn,r as Cn,s as wn,t as Tn,u as En}from"./NewExportModal-D64AhGe8.js";import{a as Dn,i as On,r as kn,t as An}from"./authed-media-C-zK1a1B.js";import{t as Y}from"./format-size-DIxKXxtj.js";import{a as jn,i as Mn,n as Nn,o as Pn,r as Fn,s as In,t as Ln}from"./StorageLocationsTable-CujqHG2j.js";c();var Rn={info:0,warning:1,critical:2},zn={"motion-without-detections":`motion`,"detections-under-floor":`detection`,"inference-too-slow":`detection`,"frames-shed":`detection`,"inference-device-unusable":`detection`};function Bn(e){return{id:`op:${e.id}`,at:e.at,source:`operation`,severity:`info`,fn:e.domain===`recording`?`recording`:`events`,deviceId:e.deviceId,title:`${e.op} · ${e.reason}`,detail:e.detail}}function Vn(e,t){return{id:`finding:${e.id}`,at:t,source:`finding`,severity:e.severity,fn:zn[e.kind],deviceId:e.subject.type===`camera`?e.subject.deviceId:null,title:e.what,detail:e.action}}function Hn(e,t){return e.filter(e=>t.deviceId===null||e.deviceId===t.deviceId).filter(e=>t.fn===null||e.fn===t.fn).filter(e=>t.minSeverity===null||Rn[e.severity]>=Rn[t.minSeverity]).toSorted((e,t)=>t.at-e.at)}var Un=``,Wn=[`recording`,`events`,`detection`,`motion`],Gn=[`info`,`warning`,`critical`];function Kn({data:t,deviceId:r}){let{t:a}=J(),s=Oe({},{refetchOnWindowFocus:!1}),c=zt({},{refetchOnWindowFocus:!1}),[l,u]=o(Un),[d,f]=o(Un),[p,m]=o(Un),h=n(()=>{let e=[...s.data??[],...c.data??[]].map(Bn),n=t.digestAtMs??0,r=(t.findings??[]).map(e=>Vn(e,n));return[...e,...r]},[s.data,c.data,t.findings,t.digestAtMs]),g=n(()=>({deviceId:r??(l===Un?null:Number(l)),fn:Wn.find(e=>e===d)??null,minSeverity:Gn.find(e=>e===p)??null}),[r,l,d,p]),_=n(()=>Hn(h,g),[h,g]),v=n(()=>new Map(t.cameras.map(e=>[e.id,e.name])),[t.cameras]),y=[];s.isError&&y.push(a(`archive.activity.footageLog`,`footage`)),c.isError&&y.push(a(`archive.activity.eventLog`,`event`));let b=n(()=>[{mobile:`detail`,key:`at`,header:a(`archive.activity.when`,`When`),nowrap:!0,sortValue:e=>e.at,render:e=>i(`span`,{className:`tabular-nums text-foreground-subtle`,children:e.at===0?`—`:new Date(e.at).toLocaleString()})},{mobile:`detail`,key:`severity`,header:a(`archive.activity.severity`,`Severity`),nowrap:!0,sortValue:e=>e.severity,render:e=>i(`span`,{className:qn[e.severity],children:a(`archive.severity.${e.severity}`,e.severity)})},{mobile:`detail`,key:`camera`,header:a(`archive.activity.camera`,`Camera`),sortValue:e=>e.deviceId===null?``:v.get(e.deviceId)??`#${String(e.deviceId)}`,render:e=>i(`span`,{className:`text-foreground`,children:e.deviceId===null?a(`archive.activity.cluster`,`Cluster`):v.get(e.deviceId)??`#${String(e.deviceId)}`})},{mobile:`primary`,key:`what`,header:a(`archive.activity.what`,`What`),render:t=>e(`div`,{className:`flex flex-col`,children:[i(`span`,{className:`text-foreground`,children:t.title}),t.detail!==null&&i(`span`,{className:`text-[11px] text-foreground-subtle`,children:t.detail})]})}],[a,v]);return e(`div`,{className:`flex flex-col gap-3`,"data-testid":`archive-activity`,children:[e(`div`,{className:`flex flex-wrap items-center gap-2`,children:[r===void 0&&e(N,{wrapperClassName:`inline-block w-auto`,value:l,onChange:e=>u(e.target.value),"aria-label":a(`archive.activity.filterCamera`,`Camera`),children:[i(`option`,{value:Un,children:a(`archive.activity.allCameras`,`All cameras`)}),t.cameras.map(e=>i(`option`,{value:String(e.id),children:e.name},e.id))]}),e(N,{wrapperClassName:`inline-block w-auto`,value:d,onChange:e=>f(e.target.value),"aria-label":a(`archive.activity.filterFunction`,`Function`),children:[i(`option`,{value:Un,children:a(`archive.activity.allFunctions`,`All functions`)}),Wn.map(e=>i(`option`,{value:e,children:a(`archive.function.${e}`,e)},e))]}),e(N,{wrapperClassName:`inline-block w-auto`,value:p,onChange:e=>m(e.target.value),"aria-label":a(`archive.activity.filterSeverity`,`Severity`),children:[i(`option`,{value:Un,children:a(`archive.activity.allSeverities`,`Any severity`)}),Gn.map(e=>i(`option`,{value:e,children:a(`archive.activity.atLeast`,`At least {{severity}}`,{severity:a(`archive.severity.${e}`,e)})},e))]})]}),y.length>0&&i(K,{variant:`warning`,message:a(`archive.activity.logUnread`,`The {{names}} log did not answer. This is not "nothing happened".`,{names:y.join(` / `)})}),_.length===0&&y.length===0?i(qe,{icon:M,title:a(`archive.activity.none`,`No activity`),description:a(`archive.activity.noneHint`,`Pruning, deletion and health findings show up here.`)}):i(He,{columns:b,rows:_,rowKey:e=>e.id,minWidthPx:640,maxBodyHeight:nt,pageSize:25})]})}var qn={info:`text-foreground-subtle`,warning:`text-warning`,critical:`text-danger`},Jn={recording:`recording`,motion:null,detection:`object-detection`,"event-media":`event-saving`},Yn={"motion-without-detections":`motion`,"detections-under-floor":`detection`,"inference-too-slow":`detection`,"frames-shed":`detection`,"inference-device-unusable":null},Xn={recording:`recording`,motion:null,detection:`detection`,"event-media":null},Zn=[`recording`,`motion`,`detection`,`event-media`];function Qn(e,t){switch(e){case`recording`:return t.recording===null?null:t.recording.active?`ok`:`warning`;case`motion`:return t.motion===null?null:t.motion.enabled?`ok`:`off`;case`detection`:return t.detection===null?null:`ok`;case`event-media`:return`ok`}}function $n(e){return e.some(e=>e.severity===`critical`)?`critical`:e.some(e=>e.severity===`warning`)?`warning`:`ok`}function er(e,t){return Zn.map(n=>{let r=t.filter(e=>Yn[e.kind]===n);if(e===void 0)return{fn:n,state:r.length>0?$n(r):`unknown`,findings:r};let i=Jn[n];if(i!==null&&e.switchedOff.includes(i))return{fn:n,state:`off`,findings:r};let a=Xn[n];return a!==null&&e.degraded.some(e=>e.stage===a)?{fn:n,state:r.length>0?$n(r):`unknown`,findings:r}:r.length>0?{fn:n,state:$n(r),findings:r}:n===`recording`&&e.recording?.mode===`off`?{fn:n,state:`off`,findings:r}:{fn:n,state:Qn(n,e)??`unknown`,findings:r}})}var tr=`recording`;function nr(e,t){return(e??[]).filter(e=>e.subject.type===`camera`&&e.subject.deviceId===t)}function rr(e){return e.filter(e=>e.severity!==`info`).length}function ir(e,t){return e===void 0?`unknown`:e.switchedOff.includes(tr)||e.recording?.mode===`off`?`off`:e.degraded.some(e=>e.stage===`recording`||e.stage===`switches`)||e.recording===null?`unknown`:t>0||!e.recording.active?`degraded`:`recording`}function ar(e){let t=new Map((e.footage??[]).map(e=>[e.deviceId,e])),n=new Map((e.events??[]).map(e=>[e.deviceId,e])),r=new Map((e.statuses??[]).map(e=>[e.deviceId,e]));return e.cameras.map(i=>{let a=rr(nr(e.findings,i.id)),o=r.get(i.id),s=t.get(i.id),c=n.get(i.id);return{deviceId:i.id,name:i.name,mode:o?.recording?.mode??null,state:ir(o,a),warnings:a,footageBytes:e.footage===null?null:s?.usedBytes??0,oldestMs:s?.oldestMs??null,eventRows:e.events===null?null:c?.rows??0,eventBytes:e.events===null?null:c?.bytes??0}})}function or(e){let t=t=>e.filter(e=>e.state===t).length;return{recording:t(`recording`),degraded:t(`degraded`),off:t(`off`),unknown:t(`unknown`),warnings:e.reduce((e,t)=>e+t.warnings,0)}}var sr={ok:`success`,off:`default`,warning:`warning`,critical:`danger`,unknown:`default`};function cr(e,t){return e.statuses?.find(e=>e.deviceId===t)}function lr({data:t,deviceId:n}){let{t:r}=J(),a=er(cr(t,n),nr(t.findings,n));return e(`div`,{className:`flex flex-col gap-4`,"data-testid":`archive-health`,children:[t.findings===null&&i(`p`,{className:`text-[11px] text-foreground-subtle`,children:r(`archive.health.noDigest`,`The health digest has not run yet — findings are not available.`)}),i(`ul`,{className:`flex flex-col divide-y divide-border rounded-lg border border-border bg-surface`,children:a.map(t=>e(`li`,{className:`flex flex-col gap-1 p-3`,children:[e(`div`,{className:`flex items-center justify-between gap-2`,children:[i(`span`,{className:`text-sm font-medium text-foreground`,children:r(`archive.function.${t.fn}`,t.fn)}),i(G,{variant:sr[t.state],children:r(`archive.functionState.${t.state}`,t.state)})]}),t.findings.map(t=>e(`div`,{className:`text-[11px] text-foreground-subtle`,children:[i(`span`,{className:`text-foreground`,children:t.what}),` — `,t.action]},t.id))]},t.fn))}),e(`div`,{className:`flex flex-col gap-2`,children:[e(`div`,{className:`flex items-center justify-between gap-2`,children:[i(`h3`,{className:`text-sm font-semibold text-foreground`,children:r(`archive.health.logs`,`Camera log`)}),i(nn,{className:`text-xs text-primary hover:underline`,to:`/system/logs?deviceId=${String(n)}`,children:r(`archive.health.openLogs`,`Open in Logs`)})]}),i(`div`,{className:`overflow-hidden rounded-lg border border-border bg-surface`,children:i(qt,{deviceId:n,limit:100,maxHeight:`max-h-80`,showFilters:!0})})]})]})}Qt();function ur(e){let t=e.subLabel??e.label;if(t!==void 0)return t;let n=e.audioLabels?.[0]?.label;return n!==void 0&&n.length>0?n:void 0}var dr=720*60*60*1e3;function fr(e){let t=[];for(let n of e)t.push(...n);return t}function pr(e,t){let n=[...e];return n.sort((e,n)=>t===`importance`?n.importance-e.importance:n.timestamp-e.timestamp),n}function mr(e,t){return e.filter(e=>!(e.importance<t.minImportance||t.cameras.size>0&&!t.cameras.has(e.deviceId)||t.classes.size>0&&!t.classes.has(e.className)))}function hr(e,t){return`${String(e)}:${t}`}function gr(e,t){let n=new Map,r=new Set;for(let i of e){let e=hr(i.deviceId,i.trackId);if(!t.has(e)||r.has(e))continue;r.add(e);let a=n.get(i.deviceId);a?a.push(i.trackId):n.set(i.deviceId,[i.trackId])}return n}function _r(e,t){return{since:e.fromMs??t-dr,until:e.toMs??t}}var vr=typeof Qe==`function`,yr=`Track deletion arrives with the next server update`;function br(){return{mutateAsync:async()=>{throw Error(`deleteTracks unavailable`)},isPending:!1}}var xr=vr?Qe:br;c();var Sr=3e4,Cr=[];function wr(e){let t=me(),r=e.deviceIds.length>0,i=[...e.deviceIds].sort((e,t)=>e-t),{data:a,isLoading:o}=s({queryKey:[`events-feed`,i,e.since,e.until,e.minImportance??null,e.classFilter??null],enabled:r,staleTime:Sr,refetchInterval:Sr,queryFn:async()=>(await t.trpcClient.pipelineAnalytics.getKeyEventsBatch.query({deviceIds:i,since:e.since,until:e.until,limit:200,...e.minImportance===void 0?{}:{minImportance:e.minImportance},...e.classFilter===void 0?{}:{classFilter:e.classFilter}})).map(e=>e.events.map(t=>({...t,deviceId:e.deviceId})))});return{rows:n(()=>pr(fr(a??Cr),`importance`),[a]),isLoading:r&&o}}c();var Tr=[`events-feed`],Er=2e3;function Dr(e){let n=l(),i=e?.paused===!0,s=t(n);s.current=n;let c=t(i);c.current=i;let[u,d]=o(!1),f=r(()=>{s.current.invalidateQueries({queryKey:Tr})},[]),p=t(void 0);p.current||=yn({delayMs:Er,invalidate:()=>{c.current?d(!0):f()}}),a(()=>()=>p.current?.cancel(),[]),a(()=>{i||!u||(d(!1),f())},[i,u,f]);let m=r(()=>{d(!1),f()},[f]);return Fe(ge.PipelineAnalyticsDetectionEvent,()=>{p.current?.trigger()}),Fe(ge.PipelineAnalyticsTrackEnded,()=>{p.current?.trigger()}),{pending:u,refreshNow:m}}c();function Or(e){let t=new Map;for(let n of e)t.set(n,(t.get(n)??0)+1);return[...t.entries()].sort((e,t)=>t[1]-e[1]||e[0].localeCompare(t[0])).map(([e])=>e)}function kr({classes:e,hidden:t,onChange:r}){let{t:a}=J(),o=n(()=>Or(e).map(e=>({id:e,label:e})),[e]);return o.length<2?null:i(Ae,{chips:o,off:t,onChange:r,allLabel:a(`detectionIntelligence.eventClassChips.all`,`All classes`),ariaLabel:a(`detectionIntelligence.eventClassChips.label`,`Classes`),testId:`event-class-chips`})}var Ar=[0,1,2],jr=`dominevo.archive.eventRowSize`,Mr={0:`w-[72px]`,1:`w-28`,2:`w-40`};function Nr(e){return e===1||e===2?e:0}c();function Pr({groups:t,selected:r,onChange:a,loading:s=!1}){let{t:c}=J(),l=Ne(),[u,d]=o(!1),[f,m]=o(``),[h,g]=o(new Set),_=f.trim().toLowerCase(),v=e=>_.length===0||ct(e,c).toLowerCase().includes(_),y=n(()=>t.map(e=>({macro:e.macro,subs:e.subs.filter(t=>v(t)||v(e.macro))})).filter(e=>v(e.macro)||e.subs.length>0),[t,_]),b=e=>g(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),x=e=>{let t=new Set(r),n=r.has(e.macro.kind)&&e.subs.every(e=>r.has(e.kind)),i=[e.macro.kind,...e.subs.map(e=>e.kind)];if(n)for(let e of i)t.delete(e);else for(let e of i)t.add(e);a(t)},S=e=>{let t=new Set(r);t.has(e)?t.delete(e):t.add(e),a(t)},C=()=>a(new Set),w=r.size;return e(`div`,{className:`relative`,children:[e(H,{variant:`unstyled`,type:`button`,onClick:()=>d(e=>!e),className:`flex items-center gap-1 rounded-md px-2.5 py-1 text-xs transition-colors ${w>0?`bg-primary/12 text-primary font-medium`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:[i(z,{className:`h-3.5 w-3.5`}),w>0?c(`detectionIntelligence.eventKindFilter.kinds`,`Kinds ({{value1}})`,{value1:String(w)}):c(`detectionIntelligence.eventKindFilter.kinds2`,`Kinds`),i(be,{className:`h-3 w-3`})]}),u&&e(`div`,{className:`absolute z-20 mt-1 max-h-80 w-64 overflow-auto rounded-md border border-border bg-surface p-2 shadow-lg`,children:[e(`div`,{className:`mb-2 flex items-center gap-1 rounded border border-border px-1.5`,children:[i(ie,{className:`h-3.5 w-3.5 text-foreground-subtle`}),i(ue,{type:`text`,value:f,onChange:e=>m(e.target.value),placeholder:c(`detectionIntelligence.eventKindFilter.searchKinds`,`Search kinds…`),className:`w-full bg-transparent py-1 text-xs outline-none`}),w>0&&i(H,{variant:`unstyled`,type:`button`,onClick:C,className:`text-[10px] text-foreground-subtle hover:text-foreground`,children:c(`detectionIntelligence.eventKindFilter.clear`,`Clear`)})]}),y.length===0&&i(`div`,{className:`px-1 py-2 text-[11px] text-foreground-subtle`,children:s?c(`detectionIntelligence.eventKindFilter.loadingKinds`,`Loading kinds…`):_.length>0?c(`detectionIntelligence.eventKindFilter.noKindMatchesThatSearch`,`No kind matches that search.`):c(`detectionIntelligence.eventKindFilter.theseCamerasAdvertiseNoEvent`,`These cameras advertise no event kinds.`)}),y.map(t=>{let n=Pt(t.macro.iconId),a=h.has(t.macro.kind)||_.length>0,o=r.has(t.macro.kind);return e(`div`,{className:`mb-0.5`,children:[e(`div`,{className:`flex items-center gap-1`,children:[t.subs.length>0?i(H,{variant:`unstyled`,type:`button`,onClick:()=>b(t.macro.kind),className:`text-foreground-subtle hover:text-foreground`,"aria-label":c(`detectionIntelligence.eventKindFilter.expand`,`Expand`),children:i(a?be:p,{className:`h-3 w-3`})}):i(`span`,{className:`w-3`}),e(`label`,{className:`flex flex-1 cursor-pointer items-center gap-1.5 rounded px-1 py-0.5 text-xs hover:bg-surface-hover`,children:[i(le,{checked:o,onChange:()=>x(t),className:`accent-primary`}),i(n,{className:`h-3.5 w-3.5`,style:{color:l(t.macro.kind)}}),i(`span`,{className:`font-medium`,children:ct(t.macro,c)})]})]}),a&&t.subs.map(t=>{let n=Pt(t.iconId);return e(`label`,{className:`ml-5 flex cursor-pointer items-center gap-1.5 rounded px-1 py-0.5 text-xs hover:bg-surface-hover`,children:[i(le,{checked:r.has(t.kind),onChange:()=>S(t.kind),className:`accent-primary`}),i(n,{className:`h-3.5 w-3.5`,style:{color:l(t.kind)}}),i(`span`,{children:ct(t,c)})]},t.kind)})]},t.macro.kind)})]})]})}function Fr(e,t){let n=new Map;for(let r of e)if(!(t.size>0&&!t.has(r.deviceId)))for(let e of r.kinds)n.has(e.kind)||n.set(e.kind,e);return n}function Ir(e,t){return{...t,kind:e,labelKey:`eventKind.${e}`,label:e.charAt(0).toUpperCase()+e.slice(1),iconId:e,parentKind:null,level:`macro`}}var Lr=new Set([`detection`,`package`]);function Rr(e,t){return[...Fr(e,t).values()].filter(e=>e.parentKind===null&&Lr.has(e.category)).sort((e,t)=>e.label.localeCompare(t.label))}function zr(e,t){let n=Fr(e,t),r=new Map,i=new Map;for(let e of n.values()){if(e.parentKind===null){i.set(e.kind,e);continue}let t=r.get(e.parentKind);t===void 0?r.set(e.parentKind,[e]):t.push(e)}for(let[e,t]of r){if(i.has(e))continue;let n=t[0];n!==void 0&&i.set(e,Ir(e,n))}return[...i.values()].map(e=>({macro:e,subs:[...r.get(e.kind)??[]].sort((e,t)=>e.label.localeCompare(t.label))})).sort((e,t)=>e.macro.label.localeCompare(t.macro.label))}c();var Br=1400,Vr=`Admin-gated URL — opens only inside an authenticated session`;function Hr({label:t,value:n,title:s}){let{t:c}=J(),[l,u]=o(!1),f=A();return a(()=>{if(!l)return;let e=setTimeout(()=>u(!1),Br);return()=>clearTimeout(e)},[l]),e(H,{variant:`unstyled`,type:`button`,onClick:r(()=>{(async()=>{try{await navigator.clipboard.writeText(n),u(!0)}catch{await f({title:c(`detectionIntelligence.copyUrlChips.copyTheMediaUrl`,`Copy the media URL`),message:c(`detectionIntelligence.copyUrlChips.clipboardAccessWasRefusedSelect`,`Clipboard access was refused. Select the URL below and copy it manually.`),label:c(`detectionIntelligence.copyUrlChips.url`,`{{label}} URL`,{label:t}),defaultValue:n,readOnly:!0,cancelLabel:c(`common.close`,`Close`)})}})()},[n,t,f,c]),title:s,"aria-label":c(`detectionIntelligence.copyUrlChips.copyUrl`,`Copy {{label}} URL`,{label:t}),className:`flex min-w-0 items-center gap-1 rounded border px-1.5 py-0.5 text-[10px] font-medium transition-colors ${l?`border-success/40 bg-success/10 text-success`:`border-border text-foreground-subtle hover:border-primary hover:text-foreground`}`,children:[i(l?b:d,{className:`h-2.5 w-2.5 shrink-0`}),i(`span`,{className:`truncate`,children:l?c(`detectionIntelligence.copyUrlChips.copied`,`Copied`):t})]})}function Ur({localUrl:t,publicUrl:n}){let{t:r}=J();return e(`div`,{className:`flex flex-wrap gap-1`,children:[i(Hr,{label:r(`detectionIntelligence.copyUrlChips.local`,`Local`),value:t,title:r(`detectionIntelligence.copyUrlChips.copyLanUrl`,`Copy LAN URL — {{AUTH_HINT}}`,{AUTH_HINT:Vr})}),n&&i(Hr,{label:r(`detectionIntelligence.copyUrlChips.public`,`Public`),value:n,title:r(`detectionIntelligence.copyUrlChips.copyPublicUrl`,`Copy public URL — {{AUTH_HINT}}`,{AUTH_HINT:Vr})})]})}var Wr={firstFrame:`First frame (track start)`,lastFrame:`Last frame (track end)`,thumbnail:`Best detection`,thumbnailSmall:`Best detection (480)`,snapshot:`Snapshot`,keyFrame:`Key frame (native-res)`,keyFrameSmall:`Key frame (960)`,crop:`Object crop`,fullFrame:`Full frame`,fullFrameBoxed:`Full frame (boxed)`,faceCrop:`Face crop`,plateCrop:`Plate crop`,confirmationCrop:`Confirmation crop (what the gate saw)`,debugCrop:`Debug crop (why this decision)`,sceneFrame:`Scene frame (clean)`,lastSceneFrame:`Last frame (clean)`};function Gr(e){return e in Wr}function Kr(e){return Gr(e)?Wr[e]:e}function qr(e,t){return`${e}${t}`}var Jr=[`native`,`raster`,`standin`];function Yr(e){return Jr.some(t=>t===e)}function Xr(e){return e===`standin`?{label:q.t(`helpers.mediaProvenance.standin.label`),title:q.t(`helpers.mediaProvenance.standin.title`),tone:`warning`}:{label:q.t(`helpers.mediaProvenance.raster.label`),title:q.t(`helpers.mediaProvenance.raster.title`),tone:`info`}}function Zr(e){return e===`standin`?Xr(`standin`):e===`raster`?Xr(`raster`):null}var Qr={"no-key-frame":`helpers.mediaProvenance.miss.noKeyFrame`,"no-best-seen-bbox":`helpers.mediaProvenance.miss.noBestSeenBbox`,"derive-returned-null":`helpers.mediaProvenance.miss.deriveReturnedNull`,"derive-threw":`helpers.mediaProvenance.miss.deriveThrew`,"derive-not-wired":`helpers.mediaProvenance.miss.deriveNotWired`,"no-media-store":`helpers.mediaProvenance.miss.noMediaStore`,"no-thumbnail":`helpers.mediaProvenance.miss.noThumbnail`,"standin-tile":`helpers.mediaProvenance.miss.standinTile`,"raster-tile":`helpers.mediaProvenance.miss.rasterTile`,"native-tile":`helpers.mediaProvenance.miss.nativeTile`};function $r(e){if(e===void 0)return null;let t=e.trim();if(t.length===0)return null;let n=t.split(/\s+/),r=n[0]??t,i=[];for(let e of n.slice(1)){let t=e.indexOf(`=`);t===-1?i.push({key:e,value:null}):i.push({key:e.slice(0,t),value:e.slice(t+1)})}let a=Qr[r];return{sentence:a===void 0?r:q.t(a),detail:i,raw:t}}c();var ei=3e4;function ti(e){let[t,n]=o(null),s=r(e=>{n(t=>t??e)},[]);return a(()=>{e||n(null)},[e]),{publicOrigin:t,probes:e?i(ni,{onOrigin:s}):null}}function ni({onOrigin:e}){let{data:t}=Re({capName:`network-access`});return i(u,{children:(t??[]).map(t=>i(ri,{addonId:t.addonId,onOrigin:e},t.addonId))})}function ri({addonId:e,onOrigin:t}){let{data:n}=je({addonId:e},{refetchInterval:ei,retry:!1});return a(()=>{let e=n?ye.safeParse(n):null,r=e?.success?e.data.endpoint?.url:void 0;if(r)try{t(new URL(r).origin)}catch{}},[n,t]),null}var ii=typeof lt==`function`,ai=`Track flags arrive with the next server update`;function oi(){return{mutateAsync:async()=>{throw Error(`setTrackFlags unavailable`)},isPending:!1}}var si=ii?lt:oi;function ci(e){if(typeof e!=`object`||!e||!(`trackId`in e)||!(`markForTrain`in e)||!(`debug`in e)||!(`favourited`in e))return null;let{trackId:t,markForTrain:n,debug:r,favourited:i}=e;return typeof t!=`string`||typeof n!=`boolean`||typeof r!=`boolean`||typeof i!=`boolean`?null:{trackId:t,markForTrain:n,debug:r,favourited:i}}c();function li({label:t,hint:n,checked:r,disabled:a,title:o,icon:s,onToggle:c}){return e(H,{variant:`unstyled`,type:`button`,role:`switch`,"aria-checked":r,"aria-label":t,disabled:a,title:o,onClick:c,className:`flex w-full items-center gap-2 rounded-md border px-2 py-1.5 text-left transition-colors disabled:opacity-50 ${r?`border-primary bg-primary/10`:`border-border bg-surface hover:bg-surface-hover`}`,children:[i(`span`,{className:r?`text-primary`:`text-foreground-subtle`,children:s}),e(`span`,{className:`min-w-0 flex-1`,children:[i(`span`,{className:`block text-[11px] font-medium text-foreground`,children:t}),i(`span`,{className:`block text-[10px] text-foreground-subtle`,children:n})]}),i(`span`,{"aria-hidden":`true`,className:`h-4 w-7 shrink-0 rounded-full p-0.5 transition-colors ${r?`bg-primary`:`bg-border`}`,children:i(`span`,{className:`block h-3 w-3 rounded-full bg-white transition-transform ${r?`translate-x-3`:``}`})})]})}function ui({deviceId:t,trackId:n,markForTrain:r,debug:a,favourited:s,onChange:c}){let{t:l}=J(),u=si(),d=oe(),[f,p]=o(null),m=f?.markForTrain??r===!0,h=f?.debug??a===!0,g=f?.favourited??s===!0,_=!ii||u.isPending,v=ii?void 0:ai,b=e=>{_||(async()=>{try{let r=ci(await u.mutateAsync({deviceId:t,trackId:n,flags:e}));if(!r)return;p(r),c?.(r)}catch(e){let t=e instanceof Error?e.message:``;await d({title:l(`detectionIntelligence.trackFlagToggles.couldNotUpdateThisTrack`,`Could not update this track`),message:t===``?l(`detectionIntelligence.trackFlagToggles.couldNotUpdateThisTrack2`,`Could not update this track. Check the server logs.`):t,variant:`danger`})}})()};return e(`div`,{className:`grid gap-1.5 sm:grid-cols-2`,children:[i(li,{label:l(`detectionIntelligence.trackFlagToggles.markForTraining`,`Mark for training`),hint:l(`detectionIntelligence.trackFlagToggles.keepsThisTrackAndIts`,`Keeps this track and its media past retention`),checked:m,disabled:_,...v===void 0?{}:{title:v},icon:i(x,{className:`h-4 w-4`}),onToggle:()=>b({markForTrain:!m})}),i(li,{label:l(`detectionIntelligence.trackFlagToggles.debug`,`Debug`),hint:l(`detectionIntelligence.trackFlagToggles.flagThisTrackForDiagnostic`,`Flag this track for diagnostic attention`),checked:h,disabled:_,...v===void 0?{}:{title:v},icon:i(pe,{className:`h-4 w-4`}),onToggle:()=>b({debug:!h})}),i(li,{label:l(`detectionIntelligence.trackFlagToggles.favourited`,`Favourited`),hint:l(`detectionIntelligence.trackFlagToggles.keepsThisTrackAndIts`,`Keeps this track and its media past retention`),checked:g,disabled:_,...v===void 0?{}:{title:v},icon:i(y,{className:`h-4 w-4`}),onToggle:()=>b({favourited:!g})})]})}function di(e){let t=e.deviceKey===void 0?e.nodeId:`${e.nodeId} · ${e.deviceKey}`;return e.modelId===void 0?t:`${t} (${e.modelId})`}function fi(e){let t=e?.openedPlacement,n=e?.closedPlacement;if(t!==void 0&&n!==void 0){let e=di(t),r=di(n);return e===r?[{kind:`detected`,value:e}]:[{kind:`opened`,value:e},{kind:`closed`,value:r}]}return t===void 0?n===void 0?[]:[{kind:`closed`,value:di(n)}]:[{kind:`opened`,value:di(t)}]}var pi=100,mi={polyline:``,points:[],snapshots:[],start:null,end:null,peakBox:null},hi=e=>e<0?0:e>1?1:e,gi=e=>Math.round(e*100)/100;function _i(e,t,n){if(e.length===0||t===null)return mi;let{width:r,height:i}=t;if(!Number.isFinite(r)||!Number.isFinite(i)||r<=0||i<=0)return mi;let a=_e(e.map(e=>({x:e.x/r,y:e.y/i,w:e.bbox.w/r,h:e.bbox.h/i})),n?.maxPoints===void 0?void 0:{maxPoints:n.maxPoints}).nodes.map(e=>({x:gi(e.x*pi),y:gi(e.y*pi)})),o=a[0]??null,s=a[a.length-1]??null,c=a.length>=2?a.map(e=>`${e.x},${e.y}`).join(` `):``,l=(n?.snapshots??[]).map(e=>({x:gi(hi(e.x/r)*pi),y:gi(hi(e.y/i)*pi),mediaId:e.mediaId})),u=null,d=-1;for(let t of e){let e=hi(t.bbox.w/r)*hi(t.bbox.h/i);e>d&&(d=e,u=t)}return{polyline:c,points:a,snapshots:l,start:o,end:s,peakBox:u?{x:gi(hi(u.bbox.x/r)*pi),y:gi(hi(u.bbox.y/i)*pi),w:gi(hi(u.bbox.w/r)*pi),h:gi(hi(u.bbox.h/i)*pi)}:null}}c();var vi=15e3,yi=te();function bi({url:e,label:t}){let{src:n,failed:r}=Dn(e);return n===null?i(`div`,{className:`flex h-full w-full items-center justify-center bg-surface-hover`,children:r?i(O,{className:`h-4 w-4 text-foreground-subtle opacity-60`}):i(V,{className:`h-4 w-4 animate-spin text-foreground-subtle opacity-70`})}):i(`img`,{src:n,alt:t,className:`h-full w-full object-cover`})}var xi=new Set([`firstFrame`,`lastFrame`,`thumbnail`,`snapshot`]),Si=new Set([`keyFrame`,`fullFrame`,`fullFrameBoxed`,`firstFrame`,`lastFrame`,`thumbnail`,`snapshot`,`sceneFrame`,`lastSceneFrame`]);function Ci(e){let[t,n]=o(null);return a(()=>{if(n(null),!e)return;let t=!1,r=new Image;return r.onload=()=>{t||n({width:r.naturalWidth,height:r.naturalHeight})},r.src=e,()=>{t=!0,r.onload=null}},[e]),t}function wi({overlay:t,onPickSnapshot:n}){let{t:r}=J();return!t.polyline&&!t.peakBox&&t.snapshots.length===0?null:e(`svg`,{viewBox:`0 0 100 100`,preserveAspectRatio:`none`,className:`pointer-events-none absolute inset-0 h-full w-full`,children:[t.peakBox&&i(`rect`,{x:t.peakBox.x,y:t.peakBox.y,width:t.peakBox.w,height:t.peakBox.h,fill:`none`,stroke:`var(--color-warning)`,strokeWidth:2,vectorEffect:`non-scaling-stroke`,rx:1}),t.polyline&&i(`polyline`,{points:t.polyline,fill:`none`,stroke:`var(--color-info)`,strokeWidth:2,strokeLinejoin:`round`,strokeLinecap:`round`,strokeOpacity:.85,vectorEffect:`non-scaling-stroke`}),t.points.map((e,t)=>i(`circle`,{cx:e.x,cy:e.y,r:1,fill:`var(--color-info)`,fillOpacity:.6,vectorEffect:`non-scaling-stroke`},`${String(e.x)}-${String(e.y)}-${String(t)}`)),t.snapshots.map((e,t)=>i(`circle`,{cx:e.x,cy:e.y,r:1.9,fill:`var(--color-info)`,fillOpacity:.95,stroke:`var(--color-background)`,strokeWidth:.7,vectorEffect:`non-scaling-stroke`,className:n?`pointer-events-auto cursor-pointer`:void 0,onClick:n?t=>{t.stopPropagation(),n(e.mediaId)}:void 0,children:i(`title`,{children:r(`detectionIntelligence.eventDetailPanel.snapshotCheckpointClickToView`,`Snapshot checkpoint — click to view this frame`)})},`snap-${String(e.mediaId)}-${String(t)}`)),t.start&&i(`circle`,{cx:t.start.x,cy:t.start.y,r:2.4,fill:`var(--color-success)`,stroke:`var(--color-background)`,strokeWidth:.6,vectorEffect:`non-scaling-stroke`}),t.end&&i(`circle`,{cx:t.end.x,cy:t.end.y,r:2.4,fill:`var(--color-danger)`,stroke:`var(--color-background)`,strokeWidth:.6,vectorEffect:`non-scaling-stroke`})]})}function X({label:t,value:n,mono:r,wrap:a}){return e(`div`,{className:`flex items-baseline justify-between gap-3 border-b border-border/60 py-1.5 last:border-0`,children:[i(`span`,{className:`shrink-0 text-[11px] uppercase tracking-wide text-foreground-subtle`,children:t}),i(`span`,{className:`min-w-0 ${a?`break-words`:`truncate`} text-right text-xs font-medium text-foreground ${r?`font-mono text-[11px]`:``}`,title:n,children:n})]})}function Ti({row:t,cameraName:s,deleteAvailable:c,onClose:l,onDeleted:d,onFlagsChanged:f}){let{t:p}=J(),m=me(),h=oe(),g=L(),v=xr(),y=t!==null,b=t?.deviceId??0,x=t?.trackId??``,S=t?.timestamp??0,C=t?.windowMs??0,{data:w}=ht({deviceId:b,trackId:x},{enabled:y}),{data:T}=wt({trackId:x,deviceId:b},{enabled:y}),E=w?.bestEventId===void 0?void 0:Number(w.bestEventId),{data:D}=jt({ownerType:`object`,eventId:E??0,deviceId:b},{enabled:y&&E!==void 0&&Number.isFinite(E)}),{data:k}=Wt({deviceId:b},{enabled:y}),A=(k??[]).find(e=>e.addonId!==void 0)?.addonId,{data:j}=gt({deviceId:b,since:S-vi,until:S+C+vi,provider:A??``},{enabled:y&&A!==void 0}),[M,N]=o(null),[P,F]=o(!1),{publicOrigin:I,probes:R}=ti(y);a(()=>{N(null)},[b,x]);let te=n(()=>{let e=T??[],t=D??[];return e.find(e=>e.kind===`keyFrame`)||t.find(e=>e.kind===`fullFrameBoxed`)||([...t,...e].find(e=>e.kind===`crop`)??null)},[T,D]),z=M??te,ne=Dn(z?z.url:void 0),re=n(()=>{let e=new Set,t=[];for(let n of[...D??[],...T??[]])e.has(n.mediaId)||(e.add(n.mediaId),t.push(n));return t},[D,T]),B=n(()=>re.find(e=>xi.has(e.kind))??null,[re]),ie=Ci(Dn(B?B.url:void 0).src),ae=n(()=>_i(w?.positions??[],ie,{snapshots:(w?.snapshots??[]).map(e=>({x:e.position.x,y:e.position.y,mediaId:e.mediaId}))}),[w?.positions,w?.snapshots,ie]),se=r(e=>{let t=re.find(t=>t.mediaId===e);t&&N(t)},[re]);if(t===null)return null;let le=ne.src,ue=z?.kind,de=ue!==void 0&&Si.has(ue)&&ie!==null&&(w?.positions.length??0)>=2,fe=j&&j.length>0?j[0]:null,pe=()=>{fe&&(F(!0),(async()=>{try{let e=await m.trpcClient.videoclips.getClipPlayback.query({deviceId:t.deviceId,clipId:fe.id});window.open(e.playbackUrl,`_blank`,`noopener`)}catch{h({title:p(`detectionIntelligence.eventDetailPanel.clipUnavailable`,`Clip unavailable`),message:p(`detectionIntelligence.eventDetailPanel.couldNotResolveClipPlayback`,`Could not resolve clip playback. Check the server logs.`),variant:`warning`})}finally{F(!1)}})())},he=()=>{!c||v.isPending||(async()=>{if(await g({title:p(`detectionIntelligence.eventDetailPanel.deleteTrack`,`Delete track`),message:p(`detectionIntelligence.eventDetailPanel.deleteThisTrackAndEvery`,`Delete this track and every image and clip captured for it? This cannot be undone.`),confirmLabel:p(`common.delete`,`Delete`),variant:`danger`}))try{await v.mutateAsync({deviceId:t.deviceId,trackIds:[t.trackId]}),d()}catch{await h({title:p(`detectionIntelligence.eventDetailPanel.deleteFailed`,`Delete failed`),message:p(`detectionIntelligence.eventDetailPanel.failedToDeleteThisTrack`,`Failed to delete this track. Check the server logs.`),variant:`danger`})}})()},ge=Math.round(t.importance*100),_e=w?.importanceReason?`${String(ge)}% · ${w.importanceReason}`:`${String(ge)}%`,ve=w?.zonesVisited&&w.zonesVisited.length>0?w.zonesVisited.join(`, `):`—`,ye=w?.audioLabels&&w.audioLabels.length>0?w.audioLabels:t.audioLabels&&t.audioLabels.length>0?t.audioLabels:void 0,U=ye===void 0?`—`:ye.map(e=>`${e.label} ×${String(e.count)} (${String(Math.round(e.peakScore*100))}%)`).join(` · `),be=w?ee(w.totalDistance,void 0):`—`,xe=$r(w?.previewMissReason),Se=_n(w?w.firstSeen:S),Ce=w?_n(w.lastSeen):`—`,we=fi(w),W={detected:p(`detectionIntelligence.eventDetailPanel.detectedOn`,`Detected on`),opened:p(`detectionIntelligence.eventDetailPanel.openedOn`,`Opened on`),closed:p(`detectionIntelligence.eventDetailPanel.closedOn`,`Closed on`)};return i(Te,{open:!0,onOpenChange:e=>!e&&l(),children:e(Ht,{width:`lg`,placement:`sheet-on-mobile`,"aria-label":p(`detectionIntelligence.eventDetailPanel.eventDetail`,`Event detail`),className:`flex h-[92dvh] flex-col gap-0 overflow-hidden p-0 bottom-0 left-0 right-0 top-auto w-full max-w-full translate-x-0 translate-y-0 rounded-b-none md:bottom-auto md:left-1/2 md:right-auto md:top-1/2 md:h-auto md:w-[calc(100vw-2rem)] md:max-w-xl md:-translate-x-1/2 md:-translate-y-1/2 md:rounded-lg md:max-h-[calc(100dvh-2rem)]`,children:[i(`header`,{className:`flex shrink-0 items-start gap-2 border-b border-border py-3 pl-4 pr-10`,children:e(`div`,{className:`min-w-0`,children:[e(`div`,{className:`truncate text-sm font-semibold text-foreground`,children:[t.className,ur(t)?e(`span`,{className:`text-foreground-subtle`,children:[` · `,ur(t)]}):null]}),i(`div`,{className:`mt-0.5 truncate text-[11px] text-foreground-subtle`,children:s})]})}),e(`div`,{className:`min-h-0 flex-1 space-y-3 overflow-y-auto overscroll-contain px-4 py-3`,children:[le?i(`div`,{className:`overflow-hidden rounded-lg border border-border bg-background`,children:i(vn,{src:le,alt:p(`detectionIntelligence.eventDetailPanel.keyFrameFrom`,`Key frame from {{cameraName}}`,{cameraName:s}),fit:`natural`,className:`w-full`,overlay:de?i(wi,{overlay:ae,onPickSnapshot:se}):void 0})}):i(`div`,{className:`flex aspect-video w-full flex-col items-center justify-center gap-1.5 rounded-lg border border-border bg-surface-hover text-foreground-subtle`,children:ne.failed?e(u,{children:[i(O,{className:`h-8 w-8 opacity-60`}),i(`span`,{className:`text-[11px]`,children:p(`detectionIntelligence.eventDetailPanel.keyFrameMediaUnavailable`,`Key-frame media unavailable`)})]}):i(V,{className:`h-6 w-6 animate-spin opacity-70`})}),re.length>0&&i(`div`,{className:`-mx-1 flex gap-2 overflow-x-auto px-1 pb-1`,children:re.map(t=>{let n=Kr(t.kind),r=qr(yi,t.url),a=I?qr(I,t.url):null;return e(`figure`,{className:`flex w-32 shrink-0 flex-col gap-1`,children:[i(H,{variant:`unstyled`,type:`button`,onClick:()=>N(t),className:`relative h-16 w-full overflow-hidden rounded border border-border hover:border-primary`,title:`${n} · ${_n(t.timestamp)}`,children:i(bi,{url:t.url,label:n})}),e(`figcaption`,{className:`min-w-0 px-0.5`,children:[i(`div`,{className:`truncate text-[10px] font-medium leading-tight text-foreground`,title:n,children:n}),i(`div`,{className:`text-[10px] leading-tight text-foreground-subtle`,title:_n(t.timestamp),children:En(t.timestamp)})]}),i(Ur,{localUrl:r,publicUrl:a})]},t.mediaId)})}),R,fe&&e(H,{variant:`secondary`,onClick:pe,disabled:P,children:[P?i(V,{className:`h-3.5 w-3.5 animate-spin`}):i(_,{className:`h-3.5 w-3.5`}),` `,p(`detectionIntelligence.eventDetailPanel.viewClip`,`View clip`)]}),i(ui,{deviceId:t.deviceId,trackId:t.trackId,...(w?.markForTrain??t.markForTrain)===void 0?{}:{markForTrain:w?.markForTrain??t.markForTrain},...(w?.debug??t.debug)===void 0?{}:{debug:w?.debug??t.debug},...(w?.favourited??t.favourited)===void 0?{}:{favourited:w?.favourited??t.favourited},onChange:f}),xe!==null&&e(`div`,{className:`rounded-lg border border-warning/40 bg-warning/8 px-3 py-2`,children:[i(`p`,{className:`text-[11px] font-semibold uppercase tracking-wide text-foreground-subtle`,children:p(`detectionIntelligence.eventDetailPanel.bestShot`,`Best shot`)}),i(`p`,{className:`mt-0.5 text-xs text-foreground`,children:xe.sentence}),i(`code`,{className:`mt-1 block break-all font-mono text-[10px] text-foreground-subtle`,children:xe.raw})]}),e(`div`,{className:`rounded-lg border border-border bg-surface px-3 py-1`,children:[i(X,{label:p(`detectionIntelligence.eventDetailPanel.camera`,`Camera`),value:s}),we.map(e=>i(X,{label:W[e.kind],value:e.value,mono:!0,wrap:!0},e.kind)),i(X,{label:p(`detectionIntelligence.eventDetailPanel.class`,`Class`),value:t.className}),i(X,{label:p(`detectionIntelligence.eventDetailPanel.label`,`Label`),value:t.label??`—`}),i(X,{label:p(`detectionIntelligence.eventDetailPanel.subLabel`,`Sub-label`),value:t.subLabel??`—`}),i(X,{label:p(`detectionIntelligence.eventDetailPanel.importance`,`Importance`),value:_e}),i(X,{label:p(`detectionIntelligence.eventDetailPanel.zonesVisited`,`Zones visited`),value:ve}),i(X,{label:p(`detectionIntelligence.eventDetailPanel.audioHeard`,`Audio heard`),value:U}),i(X,{label:p(`detectionIntelligence.eventDetailPanel.totalDistance`,`Total distance`),value:be}),i(X,{label:p(`detectionIntelligence.eventDetailPanel.firstSeen`,`First seen`),value:Se}),i(X,{label:p(`detectionIntelligence.eventDetailPanel.lastSeen`,`Last seen`),value:Ce}),i(X,{label:p(`detectionIntelligence.eventDetailPanel.track`,`Track`),value:t.trackId,mono:!0})]})]}),i(`footer`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-border px-4 py-3 pb-[max(0.75rem,env(safe-area-inset-bottom))]`,children:i(`span`,{title:c?void 0:yr,children:e(H,{variant:`secondary`,onClick:he,disabled:!c||v.isPending,children:[v.isPending?i(V,{className:`h-3.5 w-3.5 animate-spin`}):i(ce,{className:`h-3.5 w-3.5`}),` `,p(`detectionIntelligence.eventDetailPanel.deleteTrack`,`Delete track`)]})})})]})})}function Ei(e){if(e===void 0||!Number.isFinite(e)||e<=0)return``;let t=e/1e3;if(t<60)return`${ee(t,void 0)}s`;let n=Math.floor(t/60),r=Math.round(t%60);return`${String(n)}m ${String(r).padStart(2,`0`)}s`}function Di({row:t,cameraName:n,nowMs:r,onOpenDetail:a,selected:o=!1,onToggleSelect:s,score:c,provenance:l,footer:u}){let{t:d}=J(),f=Dn(t.mediaId===void 0?On(`track`,t.trackId):kn(t.mediaId)),p=Math.round(t.importance*100),m=c===void 0?void 0:Math.round(c*100),h=Ei(t.windowMs),g=()=>a(t),_=Zr(l);return e(`div`,{className:`relative flex flex-col rounded-md border bg-surface overflow-hidden ${o?`border-primary ring-1 ring-primary`:`border-border`}`,children:[e(`div`,{className:`aspect-video relative overflow-hidden bg-surface-hover`,children:[f.src?i(`img`,{src:f.src,alt:d(`detectionIntelligence.eventCard.eventFrom`,`Event from {{cameraName}}`,{cameraName:n}),onClick:g,className:`h-full w-full cursor-zoom-in object-cover`}):i(H,{variant:`unstyled`,type:`button`,onClick:g,className:`flex h-full w-full flex-col items-center justify-center gap-1 bg-surface-hover text-foreground-subtle`,title:f.failed?d(`detectionIntelligence.eventCard.keyEventMediaUnavailable`,`Key-event media unavailable`):d(`detectionIntelligence.eventCard.noKeyEventMedia`,`No key-event media`),children:i(O,{className:`h-6 w-6 opacity-60`})}),s&&i(H,{variant:`unstyled`,type:`button`,onClick:e=>{e.stopPropagation(),s(hr(t.deviceId,t.trackId))},className:`absolute left-0 top-0 z-10 rounded-br-md bg-black/50 p-1.5 text-white hover:bg-black/70`,"aria-label":o?d(`detectionIntelligence.eventCard.deselect`,`Deselect`):d(`detectionIntelligence.eventCard.select`,`Select`),children:o?i(W,{className:`h-4 w-4 text-primary`}):i(C,{className:`h-4 w-4`})}),m!==void 0&&e(`span`,{className:`absolute left-1 top-1 z-10 rounded bg-primary/85 px-1.5 py-0.5 text-[10px] font-semibold text-white tabular-nums`,title:d(`detectionIntelligence.eventCard.clipSemanticMatchScore`,`CLIP semantic-match score`),children:[String(m),`%`]}),p>0&&i(`span`,{className:`absolute right-1 top-1 z-10 rounded bg-black/60 px-1.5 py-0.5 text-[10px] font-semibold text-white`,children:String(p)}),_!==null&&i(`span`,{className:`absolute bottom-1 right-1 z-10 rounded px-1.5 py-0.5 text-[10px] font-semibold text-white ${_.tone===`warning`?`bg-warning/90`:`bg-black/70`}`,title:_.title,children:_.label}),(t.markForTrain===!0||t.retrainStatus===`trained`||t.debug===!0||t.favourited===!0)&&e(`span`,{className:`absolute bottom-1 left-1 z-10 flex gap-1`,children:[t.markForTrain===!0&&i(`span`,{className:`rounded bg-primary/85 p-0.5 text-white`,title:d(`detectionIntelligence.eventCard.markedForTraining`,`Marked for training`),"aria-label":d(`detectionIntelligence.eventCard.markedForTraining`,`Marked for training`),children:i(x,{className:`h-3 w-3`})}),t.retrainStatus===`trained`&&t.markForTrain!==!0&&i(`span`,{className:`rounded bg-success/85 p-0.5 text-white`,title:d(`detectionIntelligence.eventCard.trainingComplete`,`Training complete`),"aria-label":d(`detectionIntelligence.eventCard.trainingComplete`,`Training complete`),"data-testid":`retrain-status-trained`,children:i(b,{className:`h-3 w-3`})}),t.debug===!0&&i(`span`,{className:`rounded bg-black/70 p-0.5 text-white`,title:d(`detectionIntelligence.eventCard.flaggedForDebug`,`Flagged for debug`),"aria-label":d(`detectionIntelligence.eventCard.flaggedForDebug`,`Flagged for debug`),children:i(pe,{className:`h-3 w-3`})}),t.favourited===!0&&i(`span`,{className:`rounded bg-primary/85 p-0.5 text-white`,title:d(`detectionIntelligence.eventCard.favourited`,`Favourited`),"aria-label":d(`detectionIntelligence.eventCard.favourited`,`Favourited`),children:i(y,{className:`h-3 w-3`})})]})]}),e(H,{variant:`unstyled`,type:`button`,onClick:g,className:`min-w-0 px-2 py-1.5 text-left space-y-0.5`,children:[e(`p`,{className:`text-[11px] font-medium text-foreground truncate`,title:t.className,children:[t.className,ur(t)?e(`span`,{className:`text-foreground-subtle`,children:[` · `,ur(t)]}):null]}),i(`p`,{className:`text-[10px] text-foreground-subtle truncate`,title:n,children:n}),e(`div`,{className:`flex items-center justify-between gap-2`,children:[i(`span`,{className:`text-[10px] text-foreground-subtle truncate`,children:gn(t.timestamp,r)}),h&&i(`span`,{className:`text-[10px] text-foreground-subtle shrink-0`,children:h})]})]}),u!==void 0&&i(`div`,{className:`px-2 pb-1.5`,children:u})]})}function Oi({row:t,onSeek:n,onOpenDetail:r,size:a=0,onToggleSelect:o,selected:s=!1}){let{t:c}=J(),l=Dn(t.mediaId===void 0?On(`track`,t.trackId):kn(t.mediaId)),u=Math.round(t.importance*100),d=ur(t),f=new Date(t.timestamp).toLocaleTimeString();return e(`div`,{className:`flex w-full items-center gap-2 rounded-md border bg-surface hover:bg-surface-hover ${s?`border-primary ring-1 ring-primary`:`border-border`}`,"data-testid":`event-row`,children:[o&&i(le,{className:`ml-2 shrink-0`,checked:s,onChange:()=>o(hr(t.deviceId,t.trackId)),"aria-label":c(`detectionIntelligence.eventRow.select`,`Select {{className}} at {{time}}`,{className:t.className,time:f})}),i(H,{variant:`unstyled`,type:`button`,onClick:()=>r(t),className:`aspect-video ${Mr[a]} shrink-0 overflow-hidden rounded-l-md bg-surface-hover`,"aria-label":c(`detectionIntelligence.eventRow.openDetail`,`Open event details`),children:l.src?i(`img`,{src:l.src,alt:``,className:`h-full w-full object-cover`}):i(`span`,{className:`flex h-full w-full items-center justify-center text-foreground-subtle`,children:i(O,{className:`h-4 w-4 opacity-60`})})}),e(H,{variant:`unstyled`,type:`button`,onClick:()=>n(t.timestamp),className:`flex min-w-0 flex-1 items-center gap-2 py-1 pr-2 text-left`,"aria-label":c(`detectionIntelligence.eventRow.seek`,`Play {{className}} at {{time}}`,{className:t.className,time:f}),children:[e(`span`,{className:`min-w-0 flex-1`,children:[e(`span`,{className:`block truncate text-[12px] font-medium text-foreground`,children:[t.className,d?e(`span`,{className:`text-foreground-subtle`,children:[` · `,d]}):null]}),i(`span`,{className:`block text-[11px] tabular-nums text-foreground-subtle`,children:f})]}),u>0&&i(`span`,{className:`shrink-0 rounded bg-surface-hover px-1.5 py-0.5 text-[10px] font-semibold tabular-nums text-foreground-muted`,children:String(u)})]}),e(`div`,{className:`flex shrink-0 items-center gap-0.5 pr-1`,children:[i(ki,{icon:re,label:c(`detectionIntelligence.eventRow.details`,`Details`),onClick:()=>r(t)}),i(ki,{icon:E,label:c(`detectionIntelligence.eventRow.play`,`Play`),onClick:()=>n(t.timestamp)})]})]})}function ki({icon:t,label:n,onClick:r}){return e(ft,{children:[i(It,{children:i(kt,{variant:`ghost`,size:`sm`,icon:t,"aria-label":n,onClick:r})}),i(_t,{children:n})]})}var Ai=120*1e3;function ji(e,t,n=Ai){let r=[...e].sort((e,n)=>t(n)-t(e)),i=[];for(let e of r){let r=i[i.length-1],a=t(e);r!==void 0&&r.fromMs-a<=n?(r.events.push(e),r.fromMs=a):i.push({fromMs:a,toMs:a,events:[e]})}return i}c();function Mi(){let[e,n]=o(!1),i=t(null),[s,c]=o(0),l=r(e=>{i.current!==e&&(i.current=e,c(e=>e+1))},[]);return a(()=>{let e=i.current;if(!e||typeof IntersectionObserver>`u`){n(!1);return}let t=new IntersectionObserver(e=>{let t=e[e.length-1];t&&n(!t.isIntersecting)},{rootMargin:`64px 0px 0px 0px`,threshold:0});return t.observe(e),()=>t.disconnect()},[s]),{ref:l,scrolledPast:e}}c();var Ni=[`events-feed`],Pi=60,Fi=[{value:`importance`,labelKey:`detectionIntelligence.eventsSection.sortImportance`,icon:Ce},{value:`time`,labelKey:`detectionIntelligence.eventsSection.sortRecent`,icon:ne}];function Ii({deviceId:t,onSeek:r,window:s,rowFilter:c,onListChange:d,layout:f=`cards`,toolbarTarget:p}={}){let{t:m}=J(),h=l(),_=oe(),v=L(),[y,b]=o(xn),[x,S]=o(new Set),[C,w]=o(new Set),[E,ee]=o(new Set),[D,O]=Be({storageKey:jr,options:Ar,defaultSize:0}),k=Nr(D),[A,j]=o(0),[N,P]=o(`time`),[I,R]=o(new Set),[te,z]=o(null),[ne,re]=o(()=>Date.now());a(()=>{let e=setInterval(()=>re(Date.now()),6e4);return()=>clearInterval(e)},[]);let B=n(()=>_r({fromMs:y.fromMs,toMs:y.toMs},ne),[y.fromMs,y.toMs,ne]),ie=s?.since??B.since,ae=s?.until??B.until,se=Mi(),{pending:ue,refreshNow:de}=Dr({paused:te!==null||I.size>0||se.scrolledPast}),{data:fe=[]}=Ue({isCamera:!0,projection:`slim`}),pe=n(()=>t===void 0?fe:fe.filter(e=>e.id===t),[fe,t]),me=n(()=>pe.map(e=>e.id),[pe]),{data:he,isLoading:ge}=Ut({deviceIds:me},{enabled:me.length>0,staleTime:5*6e4}),_e=n(()=>zr(he??[],x),[he,x]),ve=xr(),ye=ve.isPending,{rows:U,isLoading:be}=wr({deviceIds:me,since:ie,until:ae,minImportance:A>0?A:void 0,classFilter:C.size===1?[...C][0]:void 0}),xe=n(()=>{let e=new Map;for(let t of pe??[])e.set(t.id,t.name);return e},[pe]),Ce=e=>xe.get(e)??m(`detectionIntelligence.cameraFallback`,{id:String(e)}),we=n(()=>wn(U).map(e=>({id:e,name:Ce(e)})).sort((e,t)=>e.name.localeCompare(t.name)),[U,xe]),W=n(()=>pr(mr(U,{cameras:x,classes:C,minImportance:A}).filter(e=>!E.has(e.className)&&(c===void 0||c(e))),N),[U,x,C,E,A,N,c]),G=n(()=>U.map(e=>e.className),[U]),Te=C.size>0||E.size>0||A>0;a(()=>{d?.({rows:W,narrowed:Te})},[W,Te,d]);let Ee=bn(W,Pi,n(()=>JSON.stringify([[...x].sort((e,t)=>e-t),[...C].sort(),[...E].sort(),A,N,ie,ae]),[x,C,E,A,N,ie,ae])),De=()=>{h.invalidateQueries({queryKey:Ni})},Oe=()=>R(new Set),ke=W.map(e=>hr(e.deviceId,e.trackId)),Ae=ke.length>0&&ke.every(e=>I.has(e)),je=()=>R(Ae?new Set:new Set(ke));function Me(e){R(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}function Ne(){if(I.size===0||!vr)return;let e=gr(U,I),t=[...e.values()].reduce((e,t)=>e+t.length,0);t!==0&&(async()=>{await v({title:m(`detectionIntelligence.eventsSection.deleteTitle`,{count:t}),message:m(`detectionIntelligence.eventsSection.deleteMessage`,{count:t}),confirmLabel:m(`common.delete`,`Delete`),variant:`danger`})&&Pe(e)})()}function Pe(e){let t=[...e];Promise.allSettled(t.map(([e,t])=>ve.mutateAsync({deviceId:e,trackIds:t}))).then(e=>{De();let n=[],r=new Set;if(e.forEach((e,i)=>{let a=t[i];if(!a)return;let[o,s]=a;if(e.status===`fulfilled`)for(let e of s)r.add(hr(o,e));else n.push(o)}),R(e=>{let t=new Set(e);for(let e of r)t.delete(e);return t}),n.length>0){let e=n.map(e=>Ce(e)).join(`, `);_({title:m(`detectionIntelligence.eventsSection.someTracksWereNotDeleted`,`Some tracks were not deleted`),message:m(`detectionIntelligence.eventsSection.failedToDeleteTracksOn`,`Failed to delete tracks on: {{names}}. They remain selected — retry, or check the server logs.`,{names:e}),variant:`danger`})}})}let Fe=n(()=>ji(Ee.pageItems,e=>e.timestamp),[Ee.pageItems]),Ie=W.length!==U.length,Le=t=>i(Di,{row:t,cameraName:Ce(t.deviceId),nowMs:ne,selected:I.has(hr(t.deviceId,t.trackId)),onToggleSelect:Me,onOpenDetail:z,footer:r===void 0?void 0:e(H,{variant:`ghost`,onClick:()=>r(t.timestamp),children:[i(Se,{className:`h-3.5 w-3.5`}),m(`detectionIntelligence.eventsSection.showInReview`,`Show in Review`)]})},hr(t.deviceId,t.trackId)),Re=f===`rows`&&r!==void 0,ze=e=>Re?i(Oi,{row:e,onSeek:r,onOpenDetail:z,size:k,selected:I.has(hr(e.deviceId,e.trackId)),onToggleSelect:Me},hr(e.deviceId,e.trackId)):Le(e),Ve=e=>Re?i(`div`,{className:`flex flex-col gap-1`,"data-testid":`events-grid`,children:e.map(ze)}):i(Xe,{status:`ready`,testId:`events-grid`,children:e.map(ze)}),He=e(`div`,{className:p===void 0?`flex flex-wrap items-center gap-1.5`:`contents`,children:[s===void 0&&i(hn,{onChange:b}),t===void 0&&i(Sn,{cameras:we,selected:x,onChange:S}),i(Pr,{groups:_e,selected:C,onChange:w,loading:ge}),Re&&i(kr,{classes:G,hidden:E,onChange:ee}),e(`label`,{className:`flex items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[i(`span`,{children:m(`detectionIntelligence.eventsSection.minScore`,`Min score`)}),i(T,{min:0,max:1,step:.05,value:A,onChange:e=>j(Number(e.target.value)),className:`h-1 w-24 cursor-pointer accent-primary`,"aria-label":m(`detectionIntelligence.eventsSection.minimumImportance`,`Minimum importance`)}),i(`span`,{className:`w-6 tabular-nums text-foreground`,children:Math.round(A*100)})]}),i(`div`,{className:`flex items-center gap-1 rounded-md border border-border p-0.5`,children:Fi.map(t=>{let n=t.icon;return e(`button`,{type:`button`,onClick:()=>P(t.value),className:`flex items-center gap-1 rounded px-2 py-1 text-[11px] transition-colors ${N===t.value?`bg-primary/12 text-primary font-medium`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:[i(n,{className:`h-3.5 w-3.5`}),` `,m(t.labelKey)]},t.value)})}),!be&&i(`span`,{className:`ml-auto text-[10px] text-foreground-subtle`,children:Ie?m(`detectionIntelligence.eventsSection.ofEvents`,`{{value1}} of {{value2}} events`,{value1:String(W.length),value2:String(U.length)}):m(`detectionIntelligence.eventsSection.eventCount`,{count:W.length})})]});return e(`div`,{className:`relative space-y-3`,children:[p===void 0?He:p!==null&&$t(He,p),I.size>0&&e(`div`,{className:`flex flex-wrap items-center gap-2 rounded-md border border-primary/40 bg-primary/8 px-3 py-2`,children:[i(`span`,{className:`text-xs font-medium text-foreground`,children:m(`common.selectedCount`,{count:I.size})}),e(`div`,{className:`ml-auto flex flex-wrap items-center gap-1.5`,children:[i(`span`,{title:vr?void 0:`Track deletion arrives with the next server update`,children:e(H,{variant:`secondary`,onClick:Ne,disabled:!vr||ye,children:[ye?i(V,{className:`h-3.5 w-3.5 animate-spin`}):i(ce,{className:`h-3.5 w-3.5`}),` `,m(`common.delete`,`Delete`)]})}),i(H,{variant:`ghost`,onClick:Oe,disabled:ye,children:i(g,{className:`h-3.5 w-3.5`})})]})]}),ue&&i(`div`,{className:`sticky top-2 z-20 flex justify-center`,children:i(`button`,{type:`button`,onClick:de,className:`rounded-full border border-primary/40 bg-surface px-3 py-1 text-[11px] font-medium text-primary shadow-sm hover:bg-primary/10`,children:m(`detectionIntelligence.eventsSection.newEventsRefresh`,`New events — refresh`)})}),be?i(Xe,{status:`pending`,pendingMessage:`Loading events…`,testId:`events-grid`}):W.length===0?i(qe,{icon:M,title:Ie?m(`detectionIntelligence.eventsSection.nothingMatchesTheFilter`,`Nothing matches the filter`):m(`detectionIntelligence.eventsSection.noKeyEventsInThis`,`No key events in this window`),description:Ie?m(`detectionIntelligence.eventsSection.widenTheDateRangeClear`,`Widen the date range, clear cameras or kinds, or lower the min score.`):m(`detectionIntelligence.eventsSection.capturedTracksAppearHereWhen`,`Captured tracks appear here when the pipeline scores a key event.`)}):e(u,{children:[i(`div`,{ref:se.ref,"aria-hidden":!0,className:`h-0`}),Re&&e(`div`,{className:`flex flex-wrap items-center gap-3`,children:[e(`label`,{className:`flex items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[i(le,{checked:Ae,onChange:je,"data-testid":`event-rows-select-all`}),i(`span`,{children:m(`detectionIntelligence.eventsSection.selectAll`,`Select all ({{count}})`,{count:W.length})})]}),e(`label`,{className:`flex items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[i(F,{className:`h-3.5 w-3.5`}),i(`span`,{children:m(`detectionIntelligence.eventsSection.rowSize`,`Size`)}),i(T,{min:0,max:Ar.length-1,step:1,value:k,onChange:e=>O(Number(e.target.value)),className:`h-1 w-24 cursor-pointer accent-primary`,"data-testid":`event-row-size`,"aria-label":m(`detectionIntelligence.eventsSection.rowSizeLabel`,`Event row size`)})]})]}),!Re&&t!==void 0&&N===`time`?Fe.map(t=>e(`div`,{className:`space-y-1.5`,children:[i(`div`,{className:`text-[11px] font-medium text-foreground-subtle`,children:m(`detectionIntelligence.eventsSection.clusterHeading`,{count:t.events.length,time:new Date(t.toMs).toLocaleString()})}),Ve(t.events)]},t.toMs)):Ve(Ee.pageItems),i(Cn,{currentPage:Ee.page,totalItems:Ee.totalItems,pageSize:Ee.pageSize,onPageChange:Ee.setPage,itemNoun:`events`})]}),te&&i(Ti,{row:te,cameraName:Ce(te.deviceId),deleteAvailable:vr,onClose:()=>z(null),onDeleted:()=>{De(),z(null)},onFlagsChanged:e=>{z(t=>t&&t.trackId===e.trackId?{...t,markForTrain:e.markForTrain,debug:e.debug,favourited:e.favourited}:t)}})]})}var Li={zone:null,identity:`any`,debug:!1};function Ri(e){return new Map(e.map(e=>[e.trackId,e]))}function zi(e){let t=new Set;for(let n of e)for(let e of n.zoneNames??[])t.add(e);return[...t].sort((e,t)=>e.localeCompare(t))}function Bi(e,t){if(t===`any`)return!0;let n=e.classes??[];return t===`face`?e.hasFace===!0||n.includes(`face`):n.includes(`plate`)}function Vi(e,t){return n=>{if(e.debug&&n.debug!==!0)return!1;if(e.zone===null&&e.identity===`any`)return!0;let r=t.get(n.trackId);return r===void 0?!0:e.zone!==null&&!(r.zoneNames??[]).includes(e.zone)?!1:Bi(r,e.identity)}}function Hi(e){return e.zone!==null||e.identity!==`any`}function Ui(e,t,n){return Hi(t)?e.filter(e=>!n.has(e.trackId)).length:0}function Wi(e){return e.map(e=>({atMs:e.timestamp,kind:e.className===`audio`?`audio`:`object`}))}var Gi=`/addon/training`;function Ki(){let{t}=J(),n=tn();return e(Et,{className:`flex flex-col gap-3 border-border bg-surface p-3 sm:flex-row sm:items-center sm:gap-4`,"data-testid":`events-feed-retrain-cta`,children:[e(`div`,{className:`flex min-w-0 flex-1 items-start gap-2.5`,children:[i(x,{className:`mt-0.5 h-4 w-4 shrink-0 text-primary`,"aria-hidden":!0}),e(`div`,{className:`min-w-0 space-y-0.5`,children:[i(`p`,{className:`text-xs font-medium text-foreground`,children:t(`detectionIntelligence.retrainTabCallout.trainingFromThisFeed`,`Training from this feed`)}),i(`p`,{className:`${fe} leading-relaxed`,children:t(`detectionIntelligence.retrainTabCallout.markATrackWithThe`,`Mark a track with the graduation-cap control on its card. On Training you correct frames, build collections, and start cloud fine-tunes.`)})]})]}),i(H,{variant:`outline`,size:`sm`,className:`shrink-0 self-start sm:self-center`,onClick:()=>n(Gi),children:t(`detectionIntelligence.retrainTabCallout.openTraining`,`Open Training`)})]})}c();var qi=[he.Camera],Ji=50,Yi=350,Xi=[{value:`loose`,labelKey:`detectionIntelligence.semanticEventSearch.looseLabel`,titleKey:`detectionIntelligence.semanticEventSearch.looseTitle`},{value:`balanced`,labelKey:`detectionIntelligence.semanticEventSearch.balancedLabel`,titleKey:`detectionIntelligence.semanticEventSearch.balancedTitle`},{value:`strict`,labelKey:`detectionIntelligence.semanticEventSearch.strictLabel`,titleKey:`detectionIntelligence.semanticEventSearch.strictTitle`}];function Zi(e){let t=String(e.id);return{id:t,trackId:e.trackId??t,deviceId:e.deviceId,timestamp:e.timestamp,className:e.className,label:e.label,subLabel:e.subLabel,importance:e.importance??0,bestEventId:t,mediaId:e.keyFrameMediaId??e.mediaId,windowMs:void 0}}function Qi({deviceId:r}){let s=t(null);f(s);let{t:c}=J(),[l,u]=o(``),[d,p]=o(`loose`),[m,h]=o(null),[_,v]=o(null),y=r??_,[b,x]=o(null),S=Rt(l,Yi).trim(),C=S.length>0,[w,T]=o(()=>Date.now());a(()=>{let e=setInterval(()=>T(Date.now()),6e4);return()=>clearInterval(e)},[]);let{data:E=[]}=Ue({isCamera:!0,projection:`slim`}),ee=n(()=>{let e=new Map;for(let t of E)e.set(t.id,t.name);return e},[E]),D=e=>ee.get(e)??c(`detectionIntelligence.cameraFallback`,{id:String(e)}),O=n(()=>E.map(e=>e.id),[E]),{data:k}=Ut({deviceIds:O},{enabled:O.length>0,staleTime:5*6e4}),A=n(()=>Rr(k??[],new Set(y===null?[]:[y])),[k,y]);a(()=>{m!==null&&(A.some(e=>e.kind===m)||h(null))},[A,m]);let{data:j,isFetching:M,isError:N,error:P}=Bt({text:S,strictness:d,limit:Ji,classFilter:m??void 0,deviceId:y??void 0},{enabled:C}),F=n(()=>[...j??[]].sort((e,t)=>t.score-e.score).map(e=>({...Zi(e),score:e.score})),[j]);function I(e){h(t=>t===e?null:e)}return e(`div`,{className:`space-y-3`,children:[e(`div`,{className:`rounded-lg border border-border bg-surface p-3 space-y-3`,children:[e(`div`,{className:`flex flex-wrap items-center gap-2`,children:[e(`div`,{className:`relative min-w-[16rem] flex-1`,children:[i(ie,{className:`pointer-events-none absolute left-2.5 top-1/2 h-4 w-4 -translate-y-1/2 text-foreground-subtle`}),i(ue,{ref:s,type:`text`,value:l,onChange:e=>u(e.target.value),placeholder:c(`detectionIntelligence.semanticEventSearch.semanticSearchDescribeWhatYou`,`Semantic search — describe what you're looking for…`),className:`h-9 w-full rounded-md border border-border bg-background pl-8 pr-8 text-sm text-foreground placeholder:text-foreground-subtle focus:border-primary focus:outline-none focus:ring-1 focus:ring-primary`,"aria-label":c(`detectionIntelligence.semanticEventSearch.semanticEventSearch`,`Semantic event search`)}),l&&i(`button`,{type:`button`,onClick:()=>u(``),className:`absolute right-2 top-1/2 -translate-y-1/2 rounded p-0.5 text-foreground-subtle hover:bg-surface-hover hover:text-foreground`,"aria-label":c(`detectionIntelligence.semanticEventSearch.clearSearch`,`Clear search`),children:i(g,{className:`h-3.5 w-3.5`})})]}),M&&C&&i(V,{className:`h-4 w-4 shrink-0 animate-spin text-foreground-subtle`})]}),e(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2`,children:[i(`div`,{className:`flex items-center gap-1`,children:A.map(e=>i(`button`,{type:`button`,onClick:()=>I(e.kind),className:`rounded-md px-2.5 py-1 text-xs transition-colors ${m===e.kind?`bg-primary/12 text-primary font-medium`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:ct(e)},e.kind))}),r===void 0&&e(`div`,{className:`flex items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[i(`span`,{children:c(`detectionIntelligence.semanticEventSearch.camera`,`Camera`)}),i(Ve,{pick:`device`,noun:`camera`,fixedTypes:qi,recentKey:`semantic-event-search-camera`,placeholder:c(`detectionIntelligence.semanticEventSearch.all`,`All`),value:y===null?null:{deviceId:y},onChange:e=>v(e===null?null:e.deviceId)})]}),e(`div`,{className:`flex items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[i(`span`,{children:c(`detectionIntelligence.semanticEventSearch.match`,`Match`)}),i(`div`,{className:`flex items-center gap-1 rounded-md border border-border p-0.5`,children:Xi.map(e=>i(`button`,{type:`button`,onClick:()=>p(e.value),className:`rounded px-2 py-1 text-[11px] transition-colors ${d===e.value?`bg-primary/12 text-primary font-medium`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,title:c(e.titleKey),children:c(e.labelKey)},e.value))})]}),C&&!M&&!N&&i(`span`,{className:`ml-auto text-[10px] text-foreground-subtle`,children:c(`common.matches`,{count:F.length})})]})]}),C&&e(`div`,{className:`space-y-3`,children:[N&&e(`p`,{className:`py-4 text-xs text-danger`,children:[c(`detectionIntelligence.semanticEventSearch.searchFailed`,`Search failed:`),` `,P instanceof Error?P.message:c(`detectionIntelligence.semanticEventSearch.unknownError`,`unknown error`),`. Check that the CLIP embedding step is enabled.`]}),!N&&M&&F.length===0&&i(Xe,{status:`pending`,pendingMessage:`Searching…`,testId:`semantic-events-grid`}),!N&&!M&&F.length===0&&i(Xe,{status:`empty`,emptyMessage:c(`detectionIntelligence.semanticEventSearch.noSemanticMatchesForTry`,`No semantic matches for “{{debounced}}”. Try a looser match threshold or a different phrasing.`,{debounced:S}),testId:`semantic-events-grid`}),!N&&F.length>0&&i(Xe,{status:`ready`,testId:`semantic-events-grid`,children:F.map(e=>i(Di,{row:e,cameraName:D(e.deviceId),nowMs:w,score:e.score,onOpenDetail:x},e.id))})]}),b&&i(Ti,{row:b,cameraName:D(b.deviceId),deleteAvailable:vr,onClose:()=>x(null),onDeleted:()=>x(null)})]})}c();function $i(e,t){let n=Math.max(0,Math.round((e-t)/6e4));if(n<1)return q.t(`helpers.relativeTime.justNow`);if(n<60)return`${String(n)}m`;let r=Math.floor(n/60);return`${String(r)}h ${String(n%60)}m`}function ea({row:t,cameraName:n,nowMs:r}){let{t:a}=J(),o=Dn(t.keyFrameMediaId===void 0?void 0:kn(t.keyFrameMediaId));return e(`div`,{className:`flex flex-col overflow-hidden rounded-md border border-border bg-surface`,children:[e(`div`,{className:`relative aspect-video overflow-hidden bg-surface-hover`,children:[o.src?i(`img`,{src:o.src,alt:a(`detectionIntelligence.stationarySection.parkedOn`,`Parked {{className}} on {{cameraName}}`,{className:t.className,cameraName:n}),className:`h-full w-full object-cover`}):i(`div`,{className:`flex h-full w-full items-center justify-center text-foreground-subtle`,children:i(m,{className:`h-6 w-6`})}),i(`span`,{className:`absolute left-1 top-1 rounded bg-black/60 px-1.5 py-0.5 text-[10px] font-medium capitalize text-white`,children:t.label??t.className})]}),e(`div`,{className:`flex flex-col gap-0.5 p-1.5`,children:[i(`span`,{className:`truncate text-[11px] text-foreground`,children:n}),i(`span`,{className:`text-[10px] text-foreground-subtle`,children:a(`common.parkedSince`,{since:$i(r,t.becameStationaryAt)})})]})]})}function ta({deviceId:t}={}){let{t:r}=J(),[a,s]=o(!1),c=Date.now(),{data:l=[]}=Ue({isCamera:!0,projection:`slim`}),u=n(()=>t===void 0?l.map(e=>e.id):[t],[l,t]),d=n(()=>{let e=new Map;for(let t of l)e.set(t.id,t.name);return e},[l]),{rows:f,unreadableCount:h}=cn(u);return f.length===0&&h===0?null:e(`div`,{className:`rounded-md border border-border bg-surface/40`,children:[e(H,{variant:`unstyled`,type:`button`,onClick:()=>s(e=>!e),className:`flex w-full items-center gap-2 px-3 py-2 text-left`,children:[i(a?be:p,{className:`h-4 w-4 text-foreground-subtle`}),i(m,{className:`h-4 w-4 text-foreground-subtle`}),i(`span`,{className:`text-sm font-semibold text-foreground`,children:r(`detectionIntelligence.stationarySection.stationary`,`Stationary`)}),i(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-[10px] font-medium text-foreground-subtle`,children:f.length}),i(`span`,{className:`ml-2 text-[11px] text-foreground-subtle`,children:r(`detectionIntelligence.stationarySection.parkedObjectsKeptOutOf`,`Parked objects — kept out of the event feed`)}),h>0?i(`span`,{className:`ml-2 text-[11px] text-warning`,children:r(`detectionIntelligence.stationarySection.unreadable`,{count:h})}):null]}),a&&i(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(9rem,1fr))] gap-2 p-3 pt-0`,children:f.map(e=>i(ea,{row:e,cameraName:d.get(e.deviceId)??`Camera #${String(e.deviceId)}`,nowMs:c},e.id))})]})}var na={status:`debug.tape.status`,promote:`debug.tape.promote`,list:`debug.tape.list`,tracks:`debug.tape.tracks`,review:`debug.tape.review`,release:`debug.tape.release`,remove:`debug.tape.delete`},ra={setRelation:`debug.gt.setRelation`,setPurity:`debug.gt.setPurity`,list:`debug.gt.list`},ia=j(`/addon/pipeline-analytics/tape-export`),aa=10*6e4;function oa(e){return`${ia}?tapeId=${encodeURIComponent(e)}`}var sa=`The server answered in a shape this build does not understand.`;function ca(e){return e instanceof Error?e.message:q.t(`helpers.eventsDebugTapes.actionFailed`)}function Z(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Q(e,t){let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:null}function la(e,t){if(!(t in e))return;let n=e[t];return n===null?null:typeof n==`number`&&Number.isFinite(n)?n:void 0}function $(e,t){let n=e[t];return typeof n==`string`?n:null}function ua(e,t){let n=e[t];return typeof n==`boolean`?n:null}function da(e,t){if(!Array.isArray(e))return null;let n=[];for(let r of e){let e=t(r);if(e===null)return null;n.push(e)}return n}function fa(e){return e===`off`||e===`recording`||e===`refused`||e===`failing`||e===`unknown`}function pa(e){if(!Z(e))return null;let t=Q(e,`deviceId`),n=e.state,r=Q(e,`gapsSinceArmed`),i=la(e,`segmentsHeld`),a=la(e,`bytesLastHour`),o=la(e,`bytesHeld`);if(t===null||!fa(n)||r===null||i===void 0||a===void 0||o===void 0)return null;let s=$(e,`reason`),c=Q(e,`segmentOriginMs`),l=Q(e,`framesPerMin`),u=Q(e,`heldFromMs`),d=Q(e,`heldToMs`),f=$(e,`shelfError`);return{deviceId:t,state:n,gapsSinceArmed:r,segmentsHeld:i,bytesLastHour:a,bytesHeld:o,...s===null?{}:{reason:s},...c===null?{}:{segmentOriginMs:c},...l===null?{}:{framesPerMin:l},...u===null?{}:{heldFromMs:u},...d===null?{}:{heldToMs:d},...f===null?{}:{shelfError:f}}}function ma(e){return Z(e)?da(e.cameras,pa):null}function ha(e){if(!Z(e))return null;let t=$(e,`id`),n=Q(e,`deviceId`),r=$(e,`scenario`),i=e.lighting,a=Q(e,`fromMs`),o=Q(e,`toMs`),s=e.state,c=Q(e,`frames`),l=Q(e,`gaps`),u=Q(e,`bytes`),d=ua(e,`reviewed`),f=ua(e,`released`),p=da(e.tracks,e=>typeof e==`string`?e:null),m=Q(e,`tracksStillStored`);return t===null||n===null||r===null||i!==`day`&&i!==`ir`||a===null||o===null||s!==`complete`&&s!==`incomplete`||c===null||l===null||u===null||d===null||f===null||p===null||m===null?null:{id:t,deviceId:n,scenario:r,note:$(e,`note`),lighting:i,fromMs:a,toMs:o,state:s,frames:c,gaps:l,bytes:u,reviewed:d,released:f,tracks:p,tracksStillStored:m}}function ga(e){return Z(e)?da(e.tapes,ha):null}function _a(e){if(!Z(e))return null;let t=$(e,`trackId`),n=Q(e,`firstT`),r=Q(e,`lastT`),i=Q(e,`boundFrames`),a=$(e,`cls`),o=ua(e,`stillStored`);return t===null||n===null||r===null||i===null||a===null||o===null?null:{trackId:t,firstT:n,lastT:r,boundFrames:i,cls:a,stillStored:o}}function va(e){if(!Z(e))return null;let t=$(e,`tapeId`),n=Q(e,`deviceId`),r=Q(e,`fromMs`),i=Q(e,`toMs`),a=ua(e,`reviewed`),o=da(e.lanes,_a);return t===null||n===null||r===null||i===null||a===null||o===null?null:{tapeId:t,deviceId:n,fromMs:r,toMs:i,reviewed:a,lanes:o}}function ya(e){if(!Z(e))return null;if(e.ok===!1){let t=$(e,`reason`),n=$(e,`detail`);return t===null||n===null?null:{ok:!1,reason:t,detail:n}}if(e.ok!==!0)return null;let t=$(e,`tapeId`),n=e.state,r=Q(e,`frames`),i=Q(e,`gaps`),a=Q(e,`pinnedTracks`),o=Q(e,`bytes`);return t===null||n!==`complete`&&n!==`incomplete`||r===null||i===null||a===null||o===null?null:{ok:!0,tapeId:t,state:n,frames:r,gaps:i,pinnedTracks:a,bytes:o}}function ba(e){if(!Z(e))return null;let t=e.status;if(t===`released`){let n=Q(e,`unpinned`),r=ua(e,`pinsSettled`);return n===null||r===null?null:{status:t,unpinned:n,pinsSettled:r}}if(t===`already-released`||t===`not-found`)return{status:t};if(t===`unavailable`){let n=$(e,`reason`);return n===null?null:{status:t,reason:n}}return null}function xa(e){if(!Z(e))return null;let t=e.status;if(t===`deleted`||t===`pins-owed`||t===`not-found`)return{status:t};if(t===`unavailable`){let n=$(e,`reason`);return n===null?null:{status:t,reason:n}}return null}function Sa(e){switch(e.status){case`released`:case`deleted`:return null;case`already-released`:return q.t(`helpers.eventsDebugTapes.alreadyReleased`);case`not-found`:return q.t(`helpers.eventsDebugTapes.notFound`);case`pins-owed`:return q.t(`helpers.eventsDebugTapes.pinsOwed`);case`unavailable`:return q.t(`helpers.eventsDebugTapes.unavailable`,{reason:e.reason})}}function Ca(e){if(!Z(e))return null;let t=$(e,`leftTrackId`),n=$(e,`rightTrackId`),r=e.relation,i=e.presence;return t===null||n===null||r!==`same-subject`&&r!==`different-subjects`?null:{leftTrackId:t,rightTrackId:n,relation:r,presence:i===`continuous`?`continuous`:null}}function wa(e){if(!Z(e))return null;let t=$(e,`sourceTrackId`),n=e.purity;return t===null||n!==`mixed`&&n!==`not-a-subject`?null:{sourceTrackId:t,purity:n,switchAtMs:Q(e,`switchAtMs`)}}function Ta(e){if(!Z(e))return null;let t=da(e.relations,Ca),n=da(e.purities,wa),r=ua(e,`truncated`);return t===null||n===null||r===null?null:{relations:t,purities:n,truncated:r}}function Ea(e){if(!e.truncated)return null;let t=e.relations.length+e.purities.length;return q.t(`helpers.eventsDebugTapes.truncatedMarks`,{count:t})}function Da(e){return e.filter(e=>e.segmentsHeld===null||e.segmentsHeld>0).map(e=>({deviceId:e.deviceId,segmentsUnknown:e.segmentsHeld===null}))}function Oa(e){return e.slice(1).map((t,n)=>({trackId:e[n]??t,otherTrackId:t}))}function ka(e){return e.flatMap((t,n)=>e.slice(n+1).map(e=>({trackId:t,otherTrackId:e})))}function Aa(e,t){let n=[];for(let r of t.relations){let t=r.leftTrackId===e?r.rightTrackId:r.rightTrackId===e?r.leftTrackId:null;if(t===null)continue;let i=r.relation===`same-subject`?`same as`:`different from`;n.push(`${i} ${t}${r.presence===`continuous`?` (continuous)`:``}`)}for(let r of t.purities)r.sourceTrackId===e&&n.push(r.purity===`not-a-subject`?`not a subject`:r.switchAtMs===null?`mixed`:`mixed at switch`);return n}function ja(e){switch(e.state){case`off`:return q.t(`helpers.eventsDebugTapes.statusOff`);case`recording`:return q.t(`helpers.eventsDebugTapes.statusRecording`);case`refused`:return q.t(`helpers.eventsDebugTapes.statusRefused`,{reason:e.reason??q.t(`helpers.eventsDebugTapes.unknownReason`)});case`failing`:return q.t(`helpers.eventsDebugTapes.statusFailing`,{reason:e.reason??q.t(`helpers.eventsDebugTapes.unknownReason`)});case`unknown`:return q.t(`helpers.eventsDebugTapes.statusUnknown`,{reason:e.reason??q.t(`helpers.eventsDebugTapes.unknownReason`)})}}var Ma={"window-too-long":`A promoted window is at most 30 minutes.`,"window-in-future":`The window ends in the future.`,"window-not-recorded":`No segment covers that window — the camera was not recording then, or it is older than 24 h.`,"invalid-scenario":`The scenario must be a slug: lowercase letters, digits and dashes, 3–64 characters.`,"promotion-budget":`A promotion budget is full (60 tapes, 1 GiB, 3 000 pinned tracks). Release or delete a tape already committed as a case first.`,"empty-window":`No frame was recorded in that window.`,"shelf-unreadable":`The camera's recorded segments could not be listed, so the window cannot be proven whole.`,"not-post-processing-node":`This node does not post-process frames, so it records no tracking tapes.`,"artifacts-elsewhere":`The artifacts storage location is on another node; tapes are recorded only where it lives.`,"tapes-not-started":`The tape recorder has not started on this node (or failed to).`};function Na(e,t){let n=Ma[e]??`Refused (${e}).`;return t.length>0?`${n} ${t}`:n}function Pa(e){if(e.length===0)return null;let t=new Date(e).getTime();return Number.isFinite(t)?t:null}function Fa(e){return e<1024*1024?q.t(`helpers.eventsDebugTapes.sizeKb`,{value:(e/1024).toFixed(0)}):q.t(`helpers.eventsDebugTapes.sizeMb`,{value:(e/1024/1024).toFixed(1)})}function Ia(e){return e===null?`unknown`:Fa(e)}function La(e){return e===null?`unknown`:String(e)}function Ra(e,t){let n=t.trim();return e===404?q.t(`helpers.eventsDebugTapes.exportUnknown`):e===503?n.length>0?n:q.t(`helpers.eventsDebugTapes.tapesUnavailable`):e===500?n.length>0?n:q.t(`helpers.eventsDebugTapes.exportUnreadable`):q.t(`helpers.eventsDebugTapes.downloadFailed`,{status:e})}c();function za({cameras:t,call:n,onPromoted:r}){let{t:a}=J(),[s,c]=o(``),[l,u]=o(``),[d,f]=o(``),[p,m]=o(``),[h,g]=o(``),[_,v]=o(`auto`),[y,b]=o(!1),[x,S]=o(null),C=async()=>{let e=Number.parseInt(s===``?t[0]?.value??``:s,10),i=Pa(l),a=Pa(d);if(!Number.isFinite(e)||i===null||a===null){S(`Pick a camera and both ends of the window.`);return}b(!0),S(null);try{let t=ya(await n(na.promote,{deviceId:e,fromMs:i,toMs:a,scenario:p,...h.trim().length>0?{note:h.trim()}:{},..._===`day`||_===`ir`?{lighting:_}:{}}));t===null?S(sa):t.ok?(S(`Promoted ${t.tapeId}: ${String(t.frames)} frames, ${Fa(t.bytes)}, ${String(t.pinnedTracks)} tracks pinned`+(t.state===`incomplete`?` — incomplete (it has gaps) and cannot become a case.`:`.`)),r()):S(Na(t.reason,t.detail))}catch(e){S(ca(e))}finally{b(!1)}};return e(`div`,{className:`flex flex-wrap items-end gap-2 rounded-md border border-border px-3 py-2`,children:[i(`div`,{className:`w-40`,children:i(N,{value:s,options:[...t],onChange:e=>c(e.target.value),"aria-label":a(`eventsDebugTapesPromoteForm.camera`,`Camera`)})}),i(ue,{type:`datetime-local`,"aria-label":a(`eventsDebugTapesPromoteForm.from`,`From`),value:l,onChange:e=>u(e.target.value),className:`w-48`}),i(ue,{type:`datetime-local`,"aria-label":a(`eventsDebugTapesPromoteForm.to`,`To`),value:d,onChange:e=>f(e.target.value),className:`w-48`}),i(ue,{"aria-label":a(`eventsDebugTapesPromoteForm.scenario`,`Scenario`),placeholder:`101-door-groups`,value:p,onChange:e=>m(e.target.value),className:`w-44`}),i(ue,{"aria-label":a(`eventsDebugTapesPromoteForm.note`,`Note`),placeholder:a(`eventsDebugTapesPromoteForm.optionalNote`,`optional note`),value:h,onChange:e=>g(e.target.value),className:`w-52`}),i(`div`,{className:`w-28`,children:i(N,{value:_,"aria-label":a(`eventsDebugTapesPromoteForm.lighting`,`Lighting`),options:[{value:`auto`,label:a(`eventsDebugTapesPromoteForm.lightingAuto`,`Lighting: auto`)},{value:`day`,label:a(`eventsDebugTapes.dayMode`)},{value:`ir`,label:`IR`}],onChange:e=>v(e.target.value)})}),e(H,{onClick:()=>void C(),disabled:y||t.length===0,children:[y?i(V,{className:`h-3.5 w-3.5 animate-spin`}):null,` `,a(`eventsDebugTapes.promoteWindow`)]}),i(`p`,{className:`w-full text-xs text-foreground-subtle`,children:a(`eventsDebugTapesPromoteForm.aPromotedTapeMayBe`,`A promoted tape may be shared as a test case — keep the scenario slug and note free of names or other personal data.`)}),x!==null&&i(`p`,{className:`w-full text-xs text-foreground`,children:x})]})}var Ba=`pipeline-analytics`,Va=`debug.listTracks`,Ha=`debug.analyze`,Ua=j(`/addon/pipeline-analytics/debug-export`);function Wa(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ga(e,t){let n=e[t];return typeof n==`string`?n:null}function Ka(e,t){let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:null}function qa(e,t){let n=e[t];return typeof n==`boolean`?n:null}function Ja(e){return e===`error`||e===`warn`||e===`info`}function Ya(e){if(!Wa(e))return null;let t=Ga(e,`code`),n=Ga(e,`detail`),r=e.severity;return t===null||n===null||!Ja(r)?null:{code:t,severity:r,detail:n}}function Xa(e){if(!Wa(e))return null;let t=Ga(e,`trackId`),n=Ka(e,`deviceId`),r=Ga(e,`className`),i=Ka(e,`firstSeen`),a=Ka(e,`lastSeen`),o=Ka(e,`durationMs`),s=qa(e,`active`);if(t===null||n===null||r===null||i===null||a===null||o===null||s===null)return null;let c=Ga(e,`label`),l=Ga(e,`subLabel`),u=Ga(e,`previewMissReason`),d=qa(e,`markForTrain`),f=qa(e,`favourited`);return{trackId:t,deviceId:n,className:r,...c===null?{}:{label:c},...l===null?{}:{subLabel:l},firstSeen:i,lastSeen:a,durationMs:o,active:s,timestamp:i,windowMs:o,importance:Ka(e,`importance`)??0,bestEventId:Ga(e,`bestEventId`)??``,...d===null?{}:{markForTrain:d},...f===null?{}:{favourited:f},debug:!0,...u===null||u.length===0?{}:{previewMissReason:u}}}function Za(e){let t=Xa(e);if(t===null||!Wa(e))return null;let n=Ka(e,`mediaCount`),r=Ka(e,`eventCount`),i=Ka(e,`positionCount`);if(n===null||r===null||i===null)return null;let a=e.mediaKinds,o=e.findings;if(!Array.isArray(a)||!Array.isArray(o))return null;let s=a.filter(e=>typeof e==`string`),c=[];for(let e of o){let t=Ya(e);t!==null&&c.push(t)}let l=e.thumbnailProvenance;return{...t,mediaCount:n,mediaKinds:s,eventCount:r,positionCount:i,findings:c,...Yr(l)?{thumbnailProvenance:l}:{}}}function Qa(e){if(!Wa(e))return null;let t=qa(e,`truncated`),n=e.tracks;if(t===null||!Array.isArray(n))return null;let r=[];for(let e of n){let t=Xa(e);if(t===null)return null;r.push(t)}return{tracks:r,truncated:t}}function $a(e){if(!Wa(e))return null;let t=e.reports,n=e.vanished;if(!Array.isArray(t)||!Array.isArray(n))return null;let r=[];for(let e of t){let t=Za(e);if(t===null)return null;r.push(t)}return{reports:r,vanished:n.filter(e=>typeof e==`string`)}}var eo={MEDIA_EVICTED_OR_NEVER:`no media`,MISSING_KEYFRAME:`no keyframe`,MISSING_FIRSTFRAME:`no first frame`,MISSING_LASTFRAME:`no last frame`,MISSING_THUMBNAIL:`no thumbnail`,MISSING_BEST_CROP:`no crop`,SHORT_TRACK:`very short`,ZERO_EVENTS:`no events`,ZERO_POSITIONS:`no trajectory`,NO_PERIODIC_SNAPSHOTS:`no snapshots`,LASTFRAME_STALE:`stale last frame`,MEDIA_STOPPED_EARLY:`media stopped early`,NO_BEST_EVENT:`no best event`,LOW_BEST_SCORE:`low score`,UNSCORED_LABEL:`unscored label`,BEST_SHOT_STANDIN:`stand-in best shot`,BEST_SHOT_RASTER:`low-res best shot`};function to(e){return eo[e]??e}var no={error:0,warn:1,info:2};function ro(e){return e.toSorted((e,t)=>no[e.severity]-no[t.severity]||e.code.localeCompare(t.code))}function io(e){return e.length===0?Ua:`${Ua}?deviceIds=${e.join(`,`)}`}function ao(e){if(e<1e4)return`${ee(e/1e3,void 0)}s`;let t=Math.round(e/1e3);if(t<60)return`${String(t)}s`;let n=Math.floor(t/60);return`${String(n)}m ${String(t%60).padStart(2,`0`)}s`}function oo(e,t){return`${String(e)}:${t}`}function so(e,t){let n=[],r=new Set;for(let i of e){let e=oo(i.deviceId,i.trackId);!t.has(e)||r.has(e)||(r.add(e),n.push({deviceId:i.deviceId,trackId:i.trackId}))}return n}c();function co({tapeId:t,call:n,onClose:r,onChanged:a}){let{t:c}=J(),l=s({queryKey:[`events-debug`,`tapes`,`tracks`,t],queryFn:async()=>va(await n(na.tracks,{tapeId:t}))}),u=l.data??null,d=s({queryKey:[`events-debug`,`tapes`,`marks`,t],enabled:u!==null,queryFn:async()=>u===null?null:Ta(await n(ra.list,{deviceId:u.deviceId,since:u.fromMs-aa,until:u.toMs+aa,limit:5e3}))}),[f,p]=o([]),[m,h]=o(``),[g,_]=o(null),v=e=>p(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]),y=async e=>{_(null);try{for(let[t,r]of e)await n(t,r);p([]),await d.refetch(),a()}catch(e){_(ca(e))}};if(u===null)return l.isLoading?i(`p`,{className:`text-xs`,children:c(`eventsDebugTapesReview.loadingTheTape`,`Loading the tape…`)}):i(K,{message:sa});let b=u.deviceId,x=(e,t)=>y(e.map(e=>[ra.setRelation,{deviceId:b,...e,relation:t}])),S=e=>{let t=Number.parseFloat(m),n=e===`mixed`&&Number.isFinite(t)?u.fromMs+t*1e3:void 0;return y(f.map(t=>[ra.setPurity,{deviceId:b,trackId:t,purity:e,...n===void 0?{}:{switchAtMs:Math.round(n)}}]))},C=d.data==null?null:Ea(d.data);return e(`div`,{className:`space-y-2 rounded-md border border-primary/40 px-3 py-2`,children:[e(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[i(`span`,{className:`text-xs font-medium`,children:c(`eventsDebugTapes.reviewLanes`,{id:u.tapeId,count:u.lanes.length})}),i(H,{disabled:f.length<2,onClick:()=>void x(Oa(f),`same-subject`),children:c(`eventsDebugTapesReview.sameSubject`,`Same subject`)}),i(H,{variant:`secondary`,disabled:f.length<2,onClick:()=>void x(ka(f),`different-subjects`),children:c(`eventsDebugTapesReview.differentSubjects`,`Different subjects`)}),i(ue,{"aria-label":c(`eventsDebugTapesReview.changedAtSFromTape`,`Changed at (s from tape start)`),placeholder:c(`eventsDebugTapesReview.changedAtS`,`changed at s`),value:m,onChange:e=>h(e.target.value),className:`w-28`}),i(H,{variant:`secondary`,disabled:f.length!==1,onClick:()=>void S(`mixed`),children:c(`eventsDebugTapesReview.mixed`,`Mixed`)}),i(H,{variant:`secondary`,disabled:f.length===0,onClick:()=>void S(`not-a-subject`),children:c(`eventsDebugTapesReview.notASubject`,`Not a subject`)}),i(H,{variant:u.reviewed?`secondary`:`primary`,onClick:()=>void y([[na.review,{tapeId:u.tapeId,reviewed:!u.reviewed}]]).then(()=>l.refetch()),children:u.reviewed?c(`eventsDebugTapesReview.markNotReviewed`,`Mark not reviewed`):c(`eventsDebugTapesReview.markReviewed`,`Mark reviewed`)}),i(H,{variant:`ghost`,onClick:r,children:c(`common.close`,`Close`)})]}),g!==null&&i(K,{message:g}),C!==null&&i(K,{variant:`warning`,message:C}),i(`ul`,{className:`space-y-1`,children:u.lanes.toSorted((e,t)=>e.firstT-t.firstT).map(e=>i(lo,{lane:e,marks:d.data===null||d.data===void 0?[]:Aa(e.trackId,d.data),selected:f.includes(e.trackId),onToggle:()=>v(e.trackId)},e.trackId))})]})}function lo({lane:t,marks:n,selected:r,onToggle:a}){let{t:o}=J(),{src:s}=Dn(t.stillStored?On(`track`,t.trackId):void 0);return e(`li`,{className:`flex items-center gap-2 text-xs`,children:[i(le,{"aria-label":o(`eventsDebugTapesReview.select`,`select {{trackId}}`,{trackId:t.trackId}),checked:r,onChange:a}),s===null?i(`div`,{className:`h-10 w-10 rounded bg-surface-hover`}):i(`img`,{src:s,alt:t.trackId,className:`h-10 w-10 rounded object-cover`}),i(`span`,{className:`font-mono`,children:t.trackId}),i(`span`,{children:t.cls}),i(`span`,{className:`text-foreground-subtle`,children:o(`eventsDebugTapes.laneFrames`,{range:`${ao(t.firstT)} → ${ao(t.lastT)}`,count:t.boundFrames})}),!t.stillStored&&i(`span`,{className:`text-foreground-subtle`,children:o(`eventsDebugTapesReview.notStoredMarkedThroughThe`,`not stored — marked through the tape`)}),n.map(e=>i(G,{variant:`info`,children:e},e))]})}c();var uo=`dominevo_admin_token`;function fo(){let e=me();return(t,n)=>e.trpcClient.addons.custom.mutate({addonId:Ba,action:t,input:n})}async function po(e,t){let n=localStorage.getItem(uo),r={};n!==null&&(r.Authorization=`Bearer ${n}`);let i=await fetch(oa(e),{headers:r});if(!i.ok){let e=await i.text().catch(()=>``);throw Error(Ra(i.status,e))}let a=await i.blob(),o=i.headers.get(`content-disposition`),s=(o===null?null:/filename="?([^";]+)"?/i.exec(o))?.[1]?.trim()??t,c=URL.createObjectURL(a),l=document.createElement(`a`);l.href=c,l.download=s,l.click(),setTimeout(()=>URL.revokeObjectURL(c),6e4)}function mo(){let{t:e}=J(),[t,n]=o(!1);return i(Ye,{expanded:t,onExpandedChange:n,header:i(`span`,{className:`text-sm font-medium text-foreground`,children:e(`eventsDebugTapes.trackingTapes`,`Tracking tapes`)}),children:i(go,{})})}function ho({tape:t,onReview:n,onDownload:r,onRelease:a,onRemove:o,onError:s}){let{t:c}=J(),l=Yt(),u=L(),d=c(`eventsDebugTapes.review`,`Review {{scenario}}`,{scenario:t.scenario});if(l){let l=async(e,t,n,r)=>{if(await u({title:e,message:t,confirmLabel:n,variant:`warning`}))try{await r()}catch(e){s(ca(e))}};return e(`div`,{className:`flex items-center justify-end gap-1`,children:[i(H,{variant:`secondary`,"aria-label":d,onClick:n,children:c(`eventsDebugTapes.review2`,`Review`)}),i(Ie,{items:[{id:`download`,label:c(`eventsDebugTapes.download`,`Download {{scenario}}`,{scenario:t.scenario}),icon:h,onClick:r},{id:`release`,label:c(`eventsDebugTapes.release`,`Release`),icon:R,disabled:t.released,onClick:()=>void l(c(`eventsDebugTapes.release2`,`Release {{scenario}}?`,{scenario:t.scenario}),c(`eventsDebugTapes.releasingReturnsThisTapeS`,`Releasing returns this tape's pinned tracks to ordinary retention — they can be pruned from then on. The promoted bundle itself is kept until deleted.`),c(`eventsDebugTapes.release`,`Release`),a)},{id:`delete`,label:c(`common.delete`,`Delete`),icon:ce,danger:!0,separatorBefore:!0,onClick:()=>void l(c(`eventsDebugTapes.delete`,`Delete {{scenario}}?`,{scenario:t.scenario}),c(`eventsDebugTapes.deletingRemovesThePromotedBundle`,`Deleting removes the promoted bundle and its index row for good. Its tracks' pins are released first — this cannot be undone.`),c(`common.delete`,`Delete`),o)}]})]})}return e(`div`,{className:`flex items-center justify-end gap-1`,children:[i(H,{variant:`secondary`,"aria-label":c(`eventsDebugTapes.review`,`Review {{scenario}}`,{scenario:t.scenario}),onClick:()=>n(),children:c(`eventsDebugTapes.review2`,`Review`)}),i(H,{variant:`ghost`,"aria-label":c(`eventsDebugTapes.download`,`Download {{scenario}}`,{scenario:t.scenario}),onClick:()=>r(),children:i(h,{className:`h-3.5 w-3.5`})}),i(ze,{label:c(`eventsDebugTapes.release`,`Release`),icon:R,title:c(`eventsDebugTapes.release2`,`Release {{scenario}}?`,{scenario:t.scenario}),description:c(`eventsDebugTapes.releasingReturnsThisTapeS`,`Releasing returns this tape's pinned tracks to ordinary retention — they can be pruned from then on. The promoted bundle itself is kept until deleted.`),confirmLabel:c(`eventsDebugTapes.release`,`Release`),triggerVariant:`ghost`,confirmVariant:`danger`,disabled:t.released,action:()=>a()}),i(ze,{label:c(`common.delete`,`Delete`),icon:ce,title:c(`eventsDebugTapes.delete`,`Delete {{scenario}}?`,{scenario:t.scenario}),description:c(`eventsDebugTapes.deletingRemovesThePromotedBundle`,`Deleting removes the promoted bundle and its index row for good. Its tracks' pins are released first — this cannot be undone.`),confirmLabel:c(`common.delete`,`Delete`),triggerVariant:`ghost`,confirmVariant:`danger`,action:()=>o()})]})}function go(){let{t}=J(),r=fo(),a=Ue({isCamera:!0,projection:`slim`}),c=n(()=>{let e=new Map;for(let t of a.data??[])e.set(t.id,t.name);return n=>e.get(n)??t(`cameraLoad.deviceLabel`,{deviceId:n})},[a.data,t]),l=s({queryKey:[`events-debug`,`tapes`,`status`],queryFn:async()=>ma(await r(na.status,{}))}),d=s({queryKey:[`events-debug`,`tapes`,`list`],queryFn:async()=>ga(await r(na.list,{}))}),[f,p]=o(null),[m,h]=o(null),g=async e=>{h(null);try{await po(e.id,`${e.scenario}.tape-bundle.json.gz`)}catch(e){h(ca(e))}},_=async e=>{let t=ba(await r(na.release,{tapeId:e.id}));if(t===null)throw Error(sa);let n=Sa(t);if(n!==null)throw Error(n);await d.refetch()},v=async e=>{let t=xa(await r(na.remove,{tapeId:e.id}));if(t===null)throw Error(sa);let n=Sa(t);if(n!==null)throw Error(n);await d.refetch()};return e(`div`,{className:`space-y-3`,children:[i(`p`,{className:`text-xs text-foreground-subtle`,children:i(an,{i18nKey:`eventsDebugTapes.intro`,components:{b:i(`strong`,{}),code:i(`code`,{})}})}),m!==null&&i(K,{message:m}),l.isLoading&&i(`p`,{className:`text-xs text-foreground-subtle`,children:t(`eventsDebugTapes.loadingCameraStatus`,`Loading camera status…`)}),l.data===null&&i(K,{message:`The server answered in a shape this build does not understand.`}),i(He,{rows:l.data??[],rowKey:e=>e.deviceId,columns:[{mobile:`primary`,key:`camera`,header:t(`eventsDebugTapes.camera`,`Camera`),render:e=>c(e.deviceId)},{mobile:`keep`,key:`state`,header:t(`eventsDebugTapes.state`,`State`),render:e=>i(G,{variant:e.state===`recording`?`success`:e.state===`off`?`default`:e.state===`unknown`?`warning`:`danger`,children:ja(e)})},{mobile:`keep`,key:`framesPerMin`,header:t(`eventsDebugTapes.framesMin`,`Frames/min`),render:e=>e.framesPerMin===void 0?`—`:String(Math.round(e.framesPerMin))},{mobile:`hidden`,key:`lastHour`,header:t(`eventsDebugTapes.lastHour`,`Last hour`),render:e=>i(`span`,{title:e.shelfError,children:Ia(e.bytesLastHour)})},{mobile:`detail`,key:`held`,header:t(`eventsDebugTapes.held`,`Held`),render:e=>i(`span`,{title:e.shelfError,children:t(`eventsDebugTapes.segsHeld`,{count:La(e.segmentsHeld),size:Ia(e.bytesHeld)})})},{mobile:`hidden`,key:`gaps`,header:t(`eventsDebugTapes.gaps`,`Gaps`),render:e=>String(e.gapsSinceArmed)}]}),i(za,{cameras:Da(l.data??[]).map(e=>({value:String(e.deviceId),label:e.segmentsUnknown?t(`eventsDebugTapes.segmentsUnknown`,`{{value1}} (segments unknown)`,{value1:c(e.deviceId)}):c(e.deviceId)})),call:r,onPromoted:()=>void d.refetch()}),d.isLoading&&i(`p`,{className:`text-xs text-foreground-subtle`,children:t(`eventsDebugTapes.loadingPromotedTapes`,`Loading promoted tapes…`)}),d.data===null&&i(K,{message:`The server answered in a shape this build does not understand.`}),i(He,{minWidthPx:720,rows:d.data??[],rowKey:e=>e.id,columns:[{mobile:`primary`,key:`scenario`,header:t(`eventsDebugTapes.scenario`,`Scenario`),render:e=>e.scenario},{mobile:`detail`,key:`camera`,header:t(`eventsDebugTapes.camera`,`Camera`),render:e=>c(e.deviceId)},{mobile:`hidden`,key:`window`,header:t(`eventsDebugTapes.window`,`Window`),render:e=>`${new Date(e.fromMs).toLocaleString()} · ${ao(e.toMs-e.fromMs)} · ${e.lighting}`},{mobile:`detail`,key:`state`,header:t(`eventsDebugTapes.state`,`State`),render:n=>e(u,{children:[i(G,{variant:n.state===`complete`?`success`:`warning`,children:n.state}),` `,n.reviewed&&i(G,{variant:`info`,children:t(`eventsDebugTapes.reviewed`)}),` `,n.released&&i(G,{children:t(`eventsDebugTapes.released`)})]})},{mobile:`hidden`,key:`tracks`,header:t(`eventsDebugTapes.tracks`,`Tracks`),render:e=>t(`eventsDebugTapes.storedOf`,{stored:String(e.tracksStillStored),total:String(e.tracks.length)})},{mobile:`keep`,key:`actions`,header:``,align:`right`,render:e=>i(ho,{tape:e,onReview:()=>p(e.id),onDownload:()=>void g(e),onRelease:()=>_(e),onRemove:()=>v(e),onError:h})}]}),f!==null&&i(co,{tapeId:f,call:r,onClose:()=>p(null),onChanged:()=>void d.refetch()})]})}c();var _o=`all`,vo=`The server answered in a shape this build does not understand.`,yo={error:`danger`,warn:`warning`,info:`info`};function bo({findings:e}){let{t}=J();return e.length===0?i(G,{variant:`success`,children:t(`eventsDebug.noAnomalyFound`,`no anomaly found`)}):i(`div`,{className:`flex flex-wrap gap-1`,children:ro(e).map(e=>i(G,{variant:yo[e.severity],title:e.detail,children:to(e.code)},e.code))})}function xo({track:t,report:n,analyzing:r}){let{t:a}=J(),o=$r(n?.previewMissReason??t.previewMissReason);return e(`div`,{className:`space-y-1 border-t border-border pt-1.5`,children:[n===void 0?i(`span`,{className:`text-[10px] text-foreground-subtle`,children:r?a(`eventsDebug.analysing`,`analysing…`):a(`eventsDebug.notAnalysed`,`not analysed`)}):e(u,{children:[i(bo,{findings:n.findings}),i(`p`,{className:`text-[10px] text-foreground-subtle`,title:n.mediaKinds.length>0?n.mediaKinds.join(`, `):a(`eventsDebug.noMediaOfAnyKind`,`no media of any kind`),children:a(`eventsDebug.reportCounts`,{media:String(n.mediaCount),events:String(n.eventCount),positions:String(n.positionCount)})})]}),o!==null&&i(`p`,{className:`text-[10px] text-foreground-subtle`,title:o.raw,children:o.sentence})]})}function So({deviceId:t}={}){let{t:r}=J(),a=me(),[c,l]=o(_o),u=t===void 0?c:String(t),[d,f]=o(!1),[p,m]=o(null),[_,v]=o(new Set),[x,S]=o(null),[C,w]=o(null),[T,E]=o(null),[ee,D]=o([]),O=si(),k=Ue({isCamera:!0,projection:`slim`}),A=n(()=>[{value:_o,label:r(`eventsDebug.allCameras`,`All cameras`)},...(k.data??[]).map(e=>({value:String(e.id),label:e.name}))],[k.data,r]),j=n(()=>{let e=new Map;for(let t of k.data??[])e.set(t.id,t.name);return e},[k.data]),M=e=>j.get(e)??r(`eventsDebug.cameraFallback`,{deviceId:e}),P=n(()=>u===_o?[]:[Number.parseInt(u,10)],[u]),F=s({queryKey:[`events-debug`,`list`,P],queryFn:async()=>Qa(await a.trpcClient.addons.custom.mutate({addonId:Ba,action:Va,input:P.length===0?{}:{deviceIds:P}}))}),L=n(()=>(F.data?.tracks??[]).map(e=>e.trackId),[F.data]),R=s({queryKey:[`events-debug`,`analyze`,L],enabled:L.length>0,queryFn:async()=>$a(await a.trpcClient.addons.custom.mutate({addonId:Ba,action:Ha,input:{trackIds:L}}))}),te=n(()=>{let e=new Map;for(let t of R.data?.reports??[])e.set(t.trackId,t);return e},[R.data]),z=F.data?.tracks??[],ne=F.data===null||R.data===null,re=()=>{F.refetch(),R.refetch()},B=e=>{v(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},ie=()=>{v(new Set(z.map(e=>oo(e.deviceId,e.trackId))))},oe=()=>v(new Set),se=async(e,t)=>{let n=e===`analyzed`?{debug:!1}:{favourited:!0},r=0,i=[];for(let e of t)try{await O.mutateAsync({deviceId:e.deviceId,trackId:e.trackId,flags:n}),r+=1}catch{i.push(e.trackId)}return{applied:r,refused:i}},ce=e=>{if(!ii||C!==null)return;let t=so(z,_);t.length!==0&&(w(e),E(null),(async()=>{let n=await se(e,t);w(null);let r=new Set(n.refused);v(new Set(t.filter(e=>r.has(e.trackId)).map(e=>oo(e.deviceId,e.trackId)))),e===`analyzed`&&D(t.filter(e=>!r.has(e.trackId))),n.refused.length>0&&E(`${String(n.refused.length)} of ${String(t.length)} were refused by the server and are still selected. Check the hub log.`),F.refetch()})())},le=()=>{let e=ee;e.length===0||C!==null||(w(`analyzed`),E(null),(async()=>{for(let t of e)try{await O.mutateAsync({deviceId:t.deviceId,trackId:t.trackId,flags:{debug:!0}})}catch{E(`Some tracks could not be re-marked. Refresh and try again.`)}w(null),D([]),F.refetch()})())},ue=async()=>{f(!0),m(null);try{await An(io(P),`dominevo-debug.zip`)}catch(e){m(e instanceof Error?e.message:`Export failed.`)}finally{f(!1)}},de=C!==null;return e(`section`,{className:`space-y-3`,children:[e(`div`,{className:`flex flex-wrap items-center gap-2`,children:[t===void 0&&i(`div`,{className:`w-44`,children:i(N,{value:u,options:A,onChange:e=>l(e.target.value)})}),e(H,{variant:`secondary`,onClick:re,disabled:F.isFetching,children:[F.isFetching?i(V,{className:`h-3.5 w-3.5 animate-spin`}):i(I,{className:`h-3.5 w-3.5`}),r(`common.refresh`,`Refresh`)]}),e(H,{onClick:()=>void ue(),disabled:d||z.length===0,children:[d?i(V,{className:`h-3.5 w-3.5 animate-spin`}):i(h,{className:`h-3.5 w-3.5`}),r(`eventsDebug.exportAll`,{count:String(z.length)})]}),z.length>0&&_.size<z.length&&i(H,{variant:`ghost`,onClick:ie,children:r(`eventsDebug.selectAll`,`Select all`)})]}),i(`p`,{className:`text-xs text-foreground-subtle`,children:i(an,{i18nKey:`eventsDebug.debugMarkNote`,components:{code:i(`code`,{}),strong:i(`strong`,{})}})}),i(mo,{}),F.isError&&i(K,{message:r(`eventsDebug.couldNotLoadTheMarked`,`Could not load the marked tracks.`)}),ne&&!F.isError&&i(K,{message:vo}),p!==null&&i(K,{message:p}),T!==null&&i(K,{message:T}),F.data?.truncated===!0&&i(K,{message:r(`eventsDebug.aCameraFilledThePer`,`A camera filled the per-camera cap — some marked tracks are not listed. Un-mark a few, or filter to one camera.`)}),(R.data?.vanished.length??0)>0&&i(`p`,{className:`text-xs text-foreground-subtle`,children:r(`eventsDebug.vanished`,{count:String(R.data?.vanished.length)})}),_.size>0&&e(`div`,{className:`flex flex-wrap items-center gap-2 rounded-md border border-primary/40 bg-primary/8 px-3 py-2`,children:[i(`span`,{className:`text-xs font-medium text-foreground`,children:r(`common.selectedCount`,{count:_.size})}),e(`div`,{className:`ml-auto flex flex-wrap items-center gap-1.5`,children:[i(`span`,{title:ii?void 0:`Track flags arrive with the next server update`,children:e(H,{variant:`secondary`,onClick:()=>ce(`keep`),disabled:!ii||de,children:[C===`keep`?i(V,{className:`h-3.5 w-3.5 animate-spin`}):i(y,{className:`h-3.5 w-3.5`}),` `,r(`eventsDebug.keep`,`Keep`)]})}),i(`span`,{title:ii?void 0:`Track flags arrive with the next server update`,children:e(H,{onClick:()=>ce(`analyzed`),disabled:!ii||de,children:[C===`analyzed`?i(V,{className:`h-3.5 w-3.5 animate-spin`}):i(b,{className:`h-3.5 w-3.5`}),` `,r(`eventsDebug.analyzed`,`Analyzed`)]})}),i(H,{variant:`ghost`,onClick:oe,disabled:de,children:i(g,{className:`h-3.5 w-3.5`})})]})]}),ee.length>0&&e(`div`,{className:`flex flex-wrap items-center gap-2 rounded-md border border-border bg-surface px-3 py-2`,children:[i(`span`,{className:`text-xs text-foreground`,children:r(`eventsDebug.markedAnalyzed`,{count:String(ee.length)})}),e(H,{variant:`ghost`,onClick:le,disabled:de,children:[i(ae,{className:`h-3.5 w-3.5`}),` `,r(`eventsDebug.undo`)]}),i(H,{variant:`ghost`,onClick:()=>D([]),disabled:de,children:i(g,{className:`h-3.5 w-3.5`})})]}),F.isLoading?i(Xe,{status:`pending`,pendingMessage:`Loading…`,testId:`debug-tracks-grid`}):z.length===0?i(qe,{icon:pe,title:r(`eventsDebug.noTrackIsMarkedFor`,`No track is marked for debug`),description:r(`eventsDebug.markOneFromATrack`,`Mark one from a track's actions on the Feed to see it here.`)}):i(Xe,{status:`ready`,testId:`debug-tracks-grid`,children:z.map(e=>{let t=te.get(e.trackId);return i(Di,{row:e,cameraName:M(e.deviceId),nowMs:e.lastSeen,selected:_.has(oo(e.deviceId,e.trackId)),onToggleSelect:B,onOpenDetail:S,...t?.thumbnailProvenance===void 0?{}:{provenance:t.thumbnailProvenance},footer:i(xo,{track:e,report:t,analyzing:R.isFetching})},oo(e.deviceId,e.trackId))})}),x&&i(Ti,{row:x,cameraName:M(x.deviceId),deleteAvailable:vr,onClose:()=>S(null),onDeleted:()=>{S(null),F.refetch()},onFlagsChanged:e=>{e.debug||(S(null),F.refetch())}})]})}c();function Co({deviceId:t,debug:n}){let{t:r}=J(),[a,s]=o(!1);return i(Ye,{expanded:a||n,onExpandedChange:s,header:e(`span`,{className:`flex items-center gap-2 text-sm font-medium text-foreground`,children:[i(ie,{className:`h-3.5 w-3.5`}),r(`archive.review.tools`,`Search, parked objects and debug`)]}),children:e(`div`,{className:`flex flex-col gap-3`,"data-testid":`archive-review-tools`,children:[i(Ki,{}),i(Qi,{deviceId:t}),i(ta,{deviceId:t}),n&&i(So,{deviceId:t})]})})}var wo=``;function To(e){return e===`any`||e===`face`||e===`plate`}function Eo({filters:t,zones:n,onChange:r,unchecked:a=0}){let{t:o}=J();return e(`div`,{className:`contents`,"data-testid":`archive-review-filters`,children:[n.length>0&&e(N,{wrapperClassName:`inline-block w-auto`,"aria-label":o(`archive.review.zone`,`Zone`),value:t.zone??wo,onChange:e=>r({...t,zone:e.target.value===wo?null:e.target.value}),children:[i(`option`,{value:wo,children:o(`archive.review.allZones`,`All zones`)}),n.map(e=>i(`option`,{value:e,children:e},e))]}),e(N,{wrapperClassName:`inline-block w-auto`,"aria-label":o(`archive.review.identity`,`Face or plate`),value:t.identity,onChange:e=>{let n=e.target.value;To(n)&&r({...t,identity:n})},children:[i(`option`,{value:`any`,children:o(`archive.review.identityAny`,`Any subject`)}),i(`option`,{value:`face`,children:o(`archive.review.identityFace`,`With a face`)}),i(`option`,{value:`plate`,children:o(`archive.review.identityPlate`,`With a plate`)})]}),e(`label`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[i(le,{checked:t.debug,onChange:e=>r({...t,debug:e.target.checked})}),o(`archive.camera.debugFilter`,`Debug-marked tracks only`)]}),a>0&&i(`span`,{className:`text-[11px] text-warning`,"data-testid":`archive-review-unchecked`,children:o(`archive.review.unchecked`,`Events not checked by this filter: {{count}}`,{count:a})})]})}c();function Do(){let e=Date.now(),t=new Date(e);return t.setHours(0,0,0,0),{fromMs:t.getTime(),toMs:e}}var Oo=[];function ko({deviceId:e}){return i(tt,{deviceId:e,children:i(De,{children:i(Mt,{children:i(se,{children:i(dt,{children:i(Ao,{deviceId:e},e)})})})})})}function Ao({deviceId:t}){let{t:a}=J(),[s,c]=o(Do),[l,u]=o(Li),[d,f]=o(null),[p,m]=o(void 0),[h,g]=o(null),[_,v]=o(!1),[y,b]=o(null),[x,S]=o(null),[C,w]=o(`high`),[T,E]=o(null),[ee,D]=o(null),O=Wt({deviceId:t}),k=n(()=>Pe(O.data??[]),[O.data]),A=y??Me(k,`recorder`),j=A===null||A===`recorder`,M=Zt(t,j?null:A,s),P=st({deviceId:t,since:s.fromMs,until:s.toMs,limit:200,projection:`slim`}),F=P.data??Oo,I=n(()=>zi(F),[F]),L=n(()=>Ri(F),[F]),R=n(()=>Vi(l,L),[l,L]),te=Hi(l)||l.debug,z=n(()=>d===null?0:Ui(d.rows,l,L),[d,l,L]),ne=n(()=>d!==null&&(d.narrowed||te)?Wi(d.rows):void 0,[d,te]),re=n(()=>({since:s.fromMs,until:s.toMs}),[s]),B=r(e=>c(e),[]),V=r(e=>{if(E(null),j){S(null),m(t=>({atMs:e,nonce:(t?.nonce??0)+1}));return}let t=et(M.clips,e);t===null&&E(e),S(t)},[j,M.clips]),ie=r((e,t)=>{if(b(e),E(null),e===`recorder`){S(null),m(e=>({atMs:t.timeRange.startMs,nonce:(e?.nonce??0)+1}));return}S(t)},[]),ae=O.status===`pending`?i(`span`,{className:`text-[11px] text-foreground-subtle`,role:`status`,children:a(`archive.review.sourcesLoading`,`Loading sources…`)}):O.status===`error`?i(`span`,{className:`text-[11px] text-danger`,role:`alert`,children:a(`archive.review.sourcesFailed`,`Sources could not be read — {{reason}}`,{reason:O.error?.message??a(`archive.review.noReason`,`no reason given`)})}):null,oe=P.status===`error`?i(`span`,{className:`text-[11px] text-danger`,role:`alert`,"data-testid":`archive-review-tracks-failed`,children:a(`archive.review.tracksFailed`,`Track facts could not be read — {{reason}}`,{reason:P.error?.message??a(`archive.review.noReason`,`no reason given`)})}):null,se=ae??(k.length>1?i(N,{wrapperClassName:`inline-block w-auto`,"aria-label":a(`archive.review.source`,`Source`),value:A??``,onChange:e=>{b(e.target.value),S(null),E(null)},children:k.map(e=>i(`option`,{value:e.value,children:e.label},e.value))}):null);return e(`div`,{className:`grid grid-cols-1 gap-3 lg:grid-cols-[minmax(0,calc(40vh*16/9))_minmax(20rem,1fr)]`,children:[i(`div`,{className:`order-1 flex min-w-0 flex-col gap-2 lg:order-none lg:col-start-1 lg:row-start-1`,children:i(`div`,{className:`mx-auto aspect-video w-full max-w-[calc(40vh*16/9)] overflow-hidden rounded-lg border border-border bg-black`,"data-testid":`archive-review-player`,children:i(on,{deviceId:t})})}),e(`div`,{className:`order-3 flex min-w-0 flex-col gap-2 lg:order-none lg:col-start-2 lg:row-start-1 lg:max-h-[40vh] lg:overflow-y-auto`,"data-testid":`archive-review-events`,children:[T!==null&&i(K,{variant:`warning`,message:a(`archive.review.noClipAt`,`This source holds no clip at {{time}}. Pick another source or another moment.`,{time:new Date(T).toLocaleTimeString()})}),x!==null&&A!==null&&i(We,{deviceId:t,clip:x,profile:C,onProfileChange:w}),i(Ii,{deviceId:t,window:re,rowFilter:R,onListChange:f,onSeek:V,layout:`rows`,toolbarTarget:ee})]}),i(`div`,{className:`order-2 flex min-w-0 flex-col gap-2 lg:order-none lg:col-span-2 lg:row-start-2`,children:i(Ze,{deviceId:t,seekTo:p,onExportRange:(e,t)=>{v(!1),g({fromMs:e,toMs:t})},onViewChange:B,densityPoints:ne,toolbar:e(`div`,{className:`contents`,"data-testid":`archive-review-bar`,children:[se,_&&e(`span`,{className:`text-[11px] text-success`,role:`status`,children:[a(`archive.review.exportQueued`,`Export queued.`),` `,i(nn,{to:un(t),className:`font-medium underline`,children:a(`archive.review.openExports`,`Open Library → Exports`)})]}),i(`span`,{ref:D,className:`contents`}),i(Eo,{filters:l,zones:I,onChange:u,unchecked:z}),oe]}),lanes:i($e,{deviceId:t,options:k,view:s,selectedProvider:A,onPickClip:ie})})}),i(`div`,{className:`order-4 min-w-0 lg:order-none lg:col-span-2 lg:row-start-3`,children:i(Co,{deviceId:t,debug:l.debug})}),h!==null&&i(Tn,{onClose:()=>g(null),onCreated:()=>{g(null),v(!0)},initialDeviceId:t,initialRange:h})]})}function jo({deviceId:e}){return i(tt,{deviceId:e,children:i(sn,{deviceId:e,sectionFilter:e=>e.location===`top-tab`&&e.tab===`recording`})},e)}function Mo(e){return e.locationIds!==void 0&&e.locationIds.length>0?e.locationIds:e.locationId===null?[]:[e.locationId]}function No(e,t){let n=Mo(e);return n.length===0?q.t(`helpers.cameraDisk.defaultRoot`):n.map(e=>t.get(e)??e).join(` + `)}function Po(e,t,n){if(e.length===0)return null;let r=e[0];if(e.length===1&&r!==void 0)return{label:No(r,t),exact:!0};if(n===null)return null;let i=e.find(e=>Mo(e).includes(n));return i===void 0?null:{label:No(i,t),exact:!1}}c();var Fo=[{value:`retention`,labelKey:`recordings.storageSection.pruneRetention`},{value:`quota`,labelKey:`recordings.storageSection.pruneQuota`},{value:`operator`,labelKey:`recordings.storageSection.pruneOperator`}],Io=`—`;function Lo({data:t,row:a}){let{t:s}=J(),c=L(),u=l(),[d,f]=o(`retention`),p=Ft({}).data,m=r(()=>{u.invalidateQueries({queryKey:[[`recording`]]}),u.invalidateQueries({queryKey:[[`recordingArchive`]]}),u.invalidateQueries({queryKey:[[`pipelineAnalytics`]]})},[u]),h=Tt({onSuccess:m}),g=Ke({onSuccess:m}),_=rt({onSuccess:m}),v=n(()=>{let e=new Map((p??[]).map(e=>[e.id,e.displayName])),n=(p??[]).filter(e=>e.type===`recordings`),r=(n.find(e=>U(e)===`active`)??n[0])?.id??null;return Po(t.usage?.locations??[],e,r)},[p,t.usage?.locations]),y=r(async(e,t,n,r)=>c({title:e,message:t,confirmLabel:n,variant:`danger`,action:r}),[c]),b=async()=>{await y(s(`archive.space.pruneTitle`,`Apply retention to {{name}}?`,{name:a.name}),s(`archive.space.pruneMessage`,`Footage beyond the retention policy is permanently deleted.`),s(`archive.space.pruneNow`,`Prune now`),()=>h.mutateAsync({deviceId:a.deviceId,reason:d}))},x=async()=>{await y(s(`archive.space.deleteFootageTitle`,`Delete all footage for {{name}}?`,{name:a.name}),s(`archive.space.deleteFootageMessage`,`Permanently deletes {{size}} of recorded footage. This cannot be undone.`,{size:a.footageBytes===null?Io:Y(a.footageBytes)}),s(`archive.space.deleteFootage`,`Delete footage`),()=>g.mutateAsync({deviceId:a.deviceId}))},S=async()=>{await y(s(`archive.space.deleteEventsTitle`,`Delete all events for {{name}}?`,{name:a.name}),s(`archive.space.deleteEventsMessage`,`Permanently deletes the events and their media. This cannot be undone.`),s(`archive.space.deleteEvents`,`Delete events`),()=>_.mutateAsync({deviceId:a.deviceId}))};return e(`div`,{className:`flex flex-col gap-4`,"data-testid":`archive-space`,children:[e(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-3`,children:[i(B,{label:s(`archive.space.footage`,`Footage`),icon:i(w,{className:`h-3.5 w-3.5`}),footer:v===null?s(`archive.space.diskUnknown`,`Disk not reported`):v.exact?v.label:s(`archive.space.diskDefault`,`{{label}} (default)`,{label:v.label}),children:a.footageBytes===null?Io:Y(a.footageBytes)}),i(B,{label:s(`archive.space.events`,`Event storage`),footer:a.eventRows===null?void 0:s(`archive.space.eventRows`,`{{count}} events`,{count:a.eventRows}),children:a.eventBytes===null?Io:Y(a.eventBytes)}),i(B,{label:s(`archive.space.oldest`,`Oldest footage`),children:a.oldestMs===null?Io:new Date(a.oldestMs).toLocaleDateString()})]}),e(`div`,{className:`flex flex-col gap-2 rounded-lg border border-danger/40 p-3`,children:[i(`h3`,{className:`text-sm font-semibold text-danger`,children:s(`archive.space.danger`,`Danger zone`)}),e(`div`,{className:`flex flex-wrap items-center gap-2 text-xs`,children:[i(`span`,{className:`text-foreground-subtle`,children:s(`recordings.storageSection.pruneReason`,`Prune reason`)}),i(N,{wrapperClassName:`inline-block w-auto`,value:d,"aria-label":s(`recordings.storageSection.pruneReason`,`Prune reason`),onChange:e=>{let t=Fo.find(t=>t.value===e.target.value);t&&f(t.value)},children:Fo.map(e=>i(`option`,{value:e.value,children:s(e.labelKey)},e.value))})]}),e(`div`,{className:`flex flex-wrap gap-2`,children:[e(H,{variant:`secondary`,onClick:()=>void b(),disabled:h.isPending,children:[i(we,{className:`h-3.5 w-3.5`}),s(`archive.space.applyRetention`,`Apply retention now`)]}),e(H,{variant:`secondary`,onClick:()=>void x(),disabled:g.isPending,children:[i(ce,{className:`h-3.5 w-3.5`}),s(`archive.space.deleteFootage`,`Delete footage`)]}),e(H,{variant:`secondary`,onClick:()=>void S(),disabled:_.isPending,children:[i(ce,{className:`h-3.5 w-3.5`}),s(`archive.space.deleteEvents`,`Delete events`)]})]})]})]})}c();var Ro=[he.Camera],zo=[`review`,`health`,`settings`];function Bo(e){return zo.some(t=>t===e)}function Vo({data:t}){let{t:n}=J(),[a,o]=rn(),s=a.get(ln),c=a.get(dn),l=Bo(c)?c:`review`,u=s===null?t.cameras[0]?.id??null:Number(s),d=r((e,t)=>{o(n=>{let r=new URLSearchParams(n);return r.set(e,t),r},{replace:!0})},[o]);if(u===null||!Number.isFinite(u))return i(qe,{icon:S,title:n(`archive.camera.none`,`No cameras yet`),description:n(`archive.camera.noneHint`,`Cameras appear here once one is added.`)});let f=t.rows.find(e=>e.deviceId===u),p=er(cr(t,u),nr(t.findings,u));return e(`div`,{className:`flex flex-col gap-3`,"data-testid":`archive-camera-section`,children:[e(`div`,{className:`flex flex-wrap items-center gap-2`,children:[i(Ve,{pick:`device`,noun:`camera`,fixedTypes:Ro,recentKey:`archive-camera`,testId:`archive-camera`,clearable:!1,className:`w-auto min-w-48`,value:{deviceId:u},onChange:e=>{e!==null&&d(ln,String(e.deviceId))}}),p.map(t=>e(G,{variant:sr[t.state],children:[n(`archive.function.${t.fn}`,t.fn),` · `,n(`archive.functionState.${t.state}`,t.state)]},t.fn))]}),!t.isLoading&&f===void 0?i(qe,{icon:S,title:n(`archive.camera.unknown`,`Camera not found`),description:n(`archive.camera.unknownHint`,`This camera is not in the Archive. Pick one from the overview.`)}):e(xt,{appearance:`pills`,value:l,onValueChange:e=>d(dn,e),className:`flex flex-col gap-3`,children:[e(it,{"aria-label":n(`archive.camera.sections`,`Camera sections`),children:[i(Kt,{value:`review`,children:n(`archive.camera.review`,`Review`)}),i(Kt,{value:`health`,children:n(`archive.camera.healthSpace`,`Health & space`)}),i(Kt,{value:`settings`,children:n(`archive.camera.settings`,`Settings`)})]}),i(yt,{value:`review`,children:i(ko,{deviceId:u})}),i(yt,{value:`health`,children:e(`div`,{className:`flex flex-col gap-6`,children:[i(lr,{data:t,deviceId:u}),i(Kn,{data:t,deviceId:u}),f!==void 0&&i(Lo,{data:t,row:f})]})}),i(yt,{value:`settings`,children:i(jo,{deviceId:u})})]})]})}c();var Ho={recording:`success`,off:`default`,degraded:`warning`,unknown:`default`},Uo=`—`;function Wo({rows:t,isLoading:r}){let{t:a}=J(),o=tn(),s=n(()=>[{mobile:`primary`,key:`camera`,header:a(`archive.table.camera`,`Camera`),sortValue:e=>e.name,render:e=>i(`span`,{className:`font-medium text-foreground`,children:e.name})},{mobile:`detail`,key:`mode`,header:a(`archive.table.mode`,`Recording`),sortValue:e=>e.mode??``,render:e=>i(`span`,{className:`text-foreground-subtle`,children:e.mode===null?Uo:a(`archive.mode.${e.mode}`,e.mode)})},{mobile:`detail`,key:`status`,header:a(`archive.table.status`,`Status`),sortValue:e=>e.state,render:t=>e(`span`,{className:`inline-flex items-center gap-1.5`,children:[i(G,{variant:Ho[t.state],children:a(`archive.state.${t.state}`,t.state)}),t.warnings>0&&i(G,{variant:`warning`,children:a(`archive.table.warnings`,`{{count}} warning`,{count:t.warnings})})]})},{mobile:`keep`,key:`footage`,header:a(`archive.table.footage`,`Footage`),align:`right`,nowrap:!0,sortValue:e=>e.footageBytes,render:e=>i(`span`,{className:`tabular-nums`,children:e.footageBytes===null?Uo:Y(e.footageBytes)})},{mobile:`hidden`,key:`events`,header:a(`archive.table.events`,`Events`),align:`right`,nowrap:!0,sortValue:e=>e.eventRows,render:e=>i(`span`,{className:`tabular-nums`,children:e.eventRows===null||e.eventBytes===null?Uo:`${e.eventRows.toLocaleString()} · ${Y(e.eventBytes)}`})},{mobile:`hidden`,key:`oldest`,header:a(`archive.table.oldest`,`Oldest footage`),align:`right`,nowrap:!0,sortValue:e=>e.oldestMs,render:e=>i(`span`,{className:`tabular-nums text-foreground-subtle`,children:e.oldestMs===null?Uo:new Date(e.oldestMs).toLocaleDateString()})}],[a]);return!r&&t.length===0?i(qe,{icon:S,title:a(`archive.table.noCameras`,`No cameras`),description:a(`archive.table.addACamera`,`Add a camera first.`)}):i(He,{columns:s,rows:t,rowKey:e=>e.deviceId,onRowClick:e=>o(fn(e.deviceId)),minWidthPx:720,maxBodyHeight:nt,defaultSort:{columnKey:`camera`,dir:`asc`}})}var Go=1440*60*1e3;function Ko(e){if(e.footageBytes===null||e.oldestMs===null)return null;let t=e.nowMs-e.oldestMs;return t<Go?null:e.footageBytes/(t/Go)}function qo(e,t){return e===null||t===null||t<=0?null:e/t}function Jo(e){let t=null;for(let n of e)n.oldestMs!==null&&(t===null||n.oldestMs<t)&&(t=n.oldestMs);return t}c();var Yo=`—`;function Xo({data:t}){let{t:r}=J(),{usage:a,footprint:o,rows:s,totals:c}=t,l=a!==null&&a.devicesRead!==`unavailable`,u=n(()=>Ko({footageBytes:l?a.totalUsedBytes:null,oldestMs:Jo(s),nowMs:Date.now()}),[l,a,s]),d=qo(n(()=>{let e=In(a?.locations??[]);return e===null||e.knownVolumes===0?null:e.freeBytes},[a?.locations]),u);return e(`div`,{className:`grid grid-cols-2 gap-3 lg:grid-cols-5`,"data-testid":`archive-key-numbers`,children:[i(B,{label:r(`archive.keyNumbers.footage`,`Footage`),icon:i(w,{className:`h-3.5 w-3.5`}),footer:l?void 0:r(`archive.keyNumbers.footageUnread`,`The recorder did not answer`),children:l?Y(a.totalUsedBytes):Yo}),i(B,{label:r(`archive.keyNumbers.eventStorage`,`Event storage`),icon:i(D,{className:`h-3.5 w-3.5`}),footer:o===null?r(`archive.keyNumbers.eventsUnread`,`The event store did not answer`):r(`archive.keyNumbers.eventRows`,`{{count}} events`,{count:o.totalRows}),children:o===null?Yo:Y(o.totalBytes)}),i(B,{label:r(`archive.keyNumbers.growth`,`Growth per day`),icon:i(de,{className:`h-3.5 w-3.5`}),footer:u===null?r(`archive.keyNumbers.growthUnknown`,`Needs a day of footage`):d===null?r(`archive.keyNumbers.daysUnknown`,`Free space unknown`):r(`archive.keyNumbers.daysLeft`,`{{days}} days of space left`,{days:Math.floor(d)}),children:u===null?Yo:Y(u)}),i(B,{label:r(`archive.keyNumbers.cameras`,`Cameras`),icon:i(S,{className:`h-3.5 w-3.5`}),footer:r(`archive.keyNumbers.cameraStates`,`{{degraded}} degraded · {{off}} off`,{degraded:c.degraded,off:c.off}),children:r(`archive.keyNumbers.recordingOf`,`{{recording}} of {{total}} recording`,{recording:c.recording,total:s.length})}),i(B,{label:r(`archive.keyNumbers.warnings`,`Open warnings`),icon:i(k,{className:`h-3.5 w-3.5`}),footer:t.findings===null?r(`archive.keyNumbers.digestPending`,`No health digest yet`):void 0,children:t.findings===null?Yo:String(c.warnings)})]})}c();var Zo={active:`success`,readonly:`default`,drain:`warning`,disabled:`danger`};function Qo(){let{t}=J(),n=Nn(),[r,a]=o(null);return n.locations.length===0?i(qe,{icon:w,title:t(`archive.storage.none`,`No storage locations`),description:t(`archive.storage.noneHint`,`Add a location to start storing footage and events.`)}):e(u,{children:[i(`div`,{className:`grid grid-cols-1 gap-3 md:grid-cols-2 xl:grid-cols-3`,"data-testid":`archive-storage-cards`,children:n.locations.map(r=>{let o=jn(r);return e(`div`,{className:`flex flex-col gap-2 rounded-lg border border-border bg-surface p-3`,children:[e(`div`,{className:`flex items-start justify-between gap-2`,children:[e(`div`,{className:`min-w-0`,children:[i(`div`,{className:`truncate text-sm font-medium text-foreground`,children:r.displayName}),e(`div`,{className:`text-[11px] text-foreground-subtle`,children:[r.type,r.nodeId===void 0?``:` · ${r.nodeId}`]})]}),i(G,{variant:Zo[o],children:Mn(o).label})]}),i(Fn,{location:r,ownedBytes:n.ownedBytesById.get(r.id)??null}),i(Pn,{drain:n.drainOf(r)}),e(`div`,{className:`flex items-center justify-between gap-2`,children:[i(`span`,{className:`text-[11px] text-foreground-subtle`,children:o===`active`?t(`archive.storage.writing`,`Taking new writes`):t(`archive.storage.notWriting`,`Not taking new writes`)}),i(H,{variant:`ghost`,onClick:()=>a(r),children:t(`archive.storage.manage`,`Manage`)})]})]},r.id)})}),r!==null&&i(Te,{open:!0,onOpenChange:e=>!e&&a(null),children:e(Ht,{width:`xl`,placement:`sheet-on-mobile`,scroll:`body`,children:[i(Ct,{children:i(ot,{children:r.displayName})}),i(mt,{children:i(Ln,{kinds:[r.type]})})]})})]})}c();var $o=1440*60*1e3,es=[1,7,30,90],ts=30;function ns(){let{t}=J(),n=L(),a=l(),[s,c]=o(ts),u=Nt({onSuccess:()=>{a.invalidateQueries({queryKey:[[`pipelineAnalytics`]]})}}),d=r(async()=>{await n({title:t(`recordings.eventsManagementSection.pruneTitle`,{count:s}),message:t(`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:t(`recordings.eventsManagementSection.pruneEvents`,`Prune events`),variant:`danger`})&&u.mutate({olderThanMs:Date.now()-s*$o,reason:`retention`})},[n,u,s,t]);return e(`section`,{className:`flex flex-wrap items-center gap-2 text-xs`,"data-testid":`prune-events-by-age`,children:[i(`span`,{className:`text-foreground-subtle`,children:t(`recordings.eventsManagementSection.pruneEventsOlderThan`,`Prune events older than`)}),i(N,{wrapperClassName:`inline-block w-auto`,value:s,onChange:e=>c(Number(e.target.value)),"aria-label":t(`recordings.eventsManagementSection.pruneEventsOlderThan`,`Prune events older than`),children:es.map(e=>i(`option`,{value:e,children:t(`recordings.eventsManagementSection.ageDays`,{count:e})},e))}),e(H,{variant:`secondary`,onClick:()=>void d(),disabled:u.isPending,children:[u.isPending?i(V,{className:`h-3 w-3 animate-spin`}):i(we,{className:`h-3 w-3`}),t(`recordings.eventsManagementSection.pruneNow`,`Prune now`)]})]})}var rs=`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`;c();var is=`storage-migration`,as=new Set([`orphans`,`debug-media`,`ghost-ledger`]);function os(e){return[`${e.orphansReclaimed} orphan rows (${Y(e.orphanBytesReclaimed)})`,e.includeDebugMedia?`${e.debugMediaReclaimed} debug files (${Y(e.debugMediaBytesReclaimed)})`:null,`${e.ghostsForgotten} ghost rows (${Y(e.ghostBytesForgotten)})`].filter(e=>e!==null).join(` · `)}function ss(){let{t:e}=J(),t=ke(is);return t===`pending`?null:t===`unknown`?i(`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`?i(cs,{}):null}function cs(){let{t}=J(),n=L(),[r,a]=o(!1),[s,c]=o(null),l=Gt({},{refetchInterval:2e3}),u=l.data??null,d=u!==null&&as.has(u.phase),f=Ot(),p=ut(),m=async()=>{if(await n({title:t(`recordings.cleanupSection.runStorageCleanup`,`Run storage cleanup?`),message:r?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 f.mutateAsync({includeDebugMedia:r}),await l.refetch()}catch(e){c(e instanceof Error?e.message:String(e))}}},h=async()=>{if(u&&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 p.mutateAsync({jobId:u.jobId}),await l.refetch()}catch{}};return e(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[i(`h2`,{className:`text-sm font-semibold text-foreground`,children:t(`recordings.cleanupSection.cleanup`,`Cleanup`)}),i(`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:[i(le,{checked:r,disabled:d,onChange:e=>{a(e.target.checked)},className:`mt-0.5 h-3.5 w-3.5 accent-primary`}),i(`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(H,{variant:`unstyled`,type:`button`,disabled:d||f.isPending,onClick:()=>{m()},className:rs,children:[(d||f.isPending)&&i(V,{className:`h-3 w-3 animate-spin`}),i(ce,{className:`h-3 w-3`}),t(`recordings.cleanupSection.runCleanup`,`Run cleanup`)]}),d&&i(H,{variant:`unstyled`,type:`button`,onClick:()=>{h()},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&&i(`p`,{className:`mt-2 text-[11px] text-danger`,children:s}),u&&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:`),` `,i(`span`,{className:`font-medium`,children:u.phase}),d&&i(V,{className:`ml-2 inline h-3 w-3 animate-spin text-primary`})]}),u.detail&&i(`p`,{className:`text-[11px] text-foreground-subtle`,children:u.detail}),i(`p`,{className:`text-[11px] text-foreground-subtle`,children:os(u)}),u.error&&i(`p`,{className:`text-[11px] text-danger`,children:u.error})]})]})}c();var ls=2e3;function us(){let{t}=J(),n=L(),r=l(),o=Xt(),s=Je(void 0,{refetchInterval:e=>e.state.data?.state===`running`?ls:!1}),c=s.data,u=c?.state===`running`,d=u||o.isPending;a(()=>{c?.state!==`done`||c.finishedAtMs===null||(r.invalidateQueries({queryKey:[[`recording`]]}),r.invalidateQueries({queryKey:[[`pipelineAnalytics`]]}))},[c?.state,c?.finishedAtMs,r]);let f=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 s.refetch())},p=u?c.total>0?`Reconciling ${String(c.completed)}/${String(c.total)}…`:`Reconciling…`:o.isPending?`Reconciling…`:`Reconcile from disk`;return e(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[i(`h3`,{className:`text-sm font-semibold text-foreground`,children:t(`recordings.diskReconcileSection.diskReconcile`,`Disk reconcile`)}),i(`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(H,{variant:`unstyled`,type:`button`,onClick:()=>void f(),disabled:d,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:[d?i(V,{className:`h-3.5 w-3.5 animate-spin`}):i(w,{className:`h-3.5 w-3.5`}),p]}),c?.state===`done`?e(`p`,{className:`text-[11px] text-foreground-subtle`,children:[t(`recordings.diskReconcileSection.lastRun`,`Last run:`),` `,t(`recordings.diskReconcileSection.summary`,{completed:String(c.completed),tracks:String(c.tracks),events:String(c.events),media:String(c.mediaDropped)}),c.failed.length>0?t(`recordings.diskReconcileSection.failed`,`, {{value1}} failed ({{value2}})`,{value1:String(c.failed.length),value2:c.failed.join(`, `)}):``,`.`]}):null,c?.state===`error`&&c.error!==null?e(`p`,{className:`text-[11px] text-destructive`,children:[t(`recordings.diskReconcileSection.reconcileFailed`,`Reconcile failed:`),` `,c.error]}):null]})]})}var ds=1e3,fs=60*ds,ps=60*fs;function ms(e){return e.toLocaleString(`en-US`)}function hs(e){if(!Number.isFinite(e)||e<0)return`—`;if(e>=ps){let t=Math.floor(e/ps),n=Math.round(e%ps/fs);return`${t.toString()}h ${n.toString()}m`}if(e>=fs){let t=Math.floor(e/fs),n=Math.round(e%fs/ds);return`${t.toString()}m ${n.toString()}s`}return`${Math.max(0,Math.round(e/ds)).toString()}s`}function gs(e){let t=Math.max(0,e.observedAt-e.startedAt),n=e.filesTotal===null?`${ms(e.filesMoved)} files`:`${ms(e.filesMoved)} / ${ms(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?`${Y(e.bytesMoved/t*ds)}/s`:null,o=e.filesTotal===null?null:e.filesTotal-e.filesMoved,s=!i||o===null||o<=0?null:`~${hs(o*t/e.filesMoved)} left`;return{counted:n,fraction:r,moved:`${Y(e.bytesMoved)} moved`,rate:a,eta:s}}function _s(e){let t=gs(e);return[t.counted,t.moved,t.rate,t.eta].filter(e=>e!==null).join(` · `)}c();var vs=`storage-migration`,ys=[{id:`recordings`,labelKey:`recordings.storageMigrationSection.classRecordings`,locationType:`recordings`},{id:`recordingsLow`,labelKey:`recordings.storageMigrationSection.classRecordingsLow`,locationType:`recordingsLow`},{id:`eventMedia`,labelKey:`recordings.storageMigrationSection.classEventMedia`,locationType:`eventMedia`}],bs=new Set([`planning`,`sealing`,`pausing`,`moving`,`draining`,`verifying`,`repointing`,`refreshing`,`resuming`]);function xs(){let{t}=J(),n=ke(vs);return n===`pending`?e(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[i(V,{className:`h-4 w-4 animate-spin`}),t(`migration.storageMigrationSection.checkingWhetherStorageMigrationIs`,`Checking whether storage migration is installed…`)]}):n===`unknown`?i(qe,{icon:k,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`?i(qe,{icon:P,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.`)}):i(Ss,{})}function Ss(){let{t}=J(),r=L(),{data:a}=Ft({}),[s,c]=o({}),[l,u]=o({}),[d,f]=o(null),[p,m]=o(null),h=n(()=>{let e=new Map;for(let t of a??[]){let n=e.get(t.type);n?n.push(t):e.set(t.type,[t])}return e},[a]),_=n(()=>{let e=new Map;for(let t of a??[]){if(!ve(t))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},[a]),v=at({},{refetchInterval:2e3}),y=v.data??null,b=y!==null&&bs.has(y.phase),x=n(()=>{let e={};for(let t of ys){let n=s[t.id];n&&(e[t.id]=n)}return Object.keys(e).length>0?e:void 0},[s]),S=n(()=>{let e={};for(let t of ys){if(!s[t.id])continue;let n=l[t.id]??_.get(t.locationType);n&&(e[t.id]=n)}return Object.keys(e).length>0?e:void 0},[s,l,_]),C=n(()=>({destinations:x??{},...S?{sources:S}:{}}),[x,S]),w=At(C,{enabled:!1,retry:!1}),T=bt(),E=Vt(),ee=async()=>{if(!x)return;m(null);let e=await w.refetch();if(e.error){m(e.error instanceof Error?e.error.message:String(e.error));return}f(e.data??null)},D=async()=>{if(x&&await r({title:t(`migration.storageMigrationSection.startStorageMigration`,`Start storage migration?`),message:t(`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:t(`migration.storageMigrationSection.startMigration`,`Start migration`),variant:`danger`})){m(null);try{await T.mutateAsync(C),f(null),await v.refetch()}catch(e){m(e instanceof Error?e.message:String(e))}}},O=async()=>{if(y&&await r({title:t(`migration.storageMigrationSection.cancelMigration`,`Cancel migration?`),message:t(`migration.storageMigrationSection.stopsTheInProgressMigration`,`Stops the in-progress migration. Data already moved and verified stays at the destination; anything already repointed is not reverted.`),confirmLabel:t(`migration.storageMigrationSection.cancelMigration2`,`Cancel migration`),variant:`danger`}))try{await E.mutateAsync({jobId:y.jobId}),await v.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:[i(P,{className:`h-3.5 w-3.5`}),t(`migration.storageMigrationSection.storageMigration`,`Storage migration`)]}),i(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:t(`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.`)}),i(`div`,{className:`mt-3 grid grid-cols-1 gap-3 sm:grid-cols-3`,children:ys.map(n=>{let r=h.get(n.locationType)??[],a=_.get(n.locationType)??``;return e(`div`,{className:`space-y-2`,children:[i(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:t(n.labelKey)}),e(`div`,{className:`space-y-1`,children:[i(`label`,{htmlFor:`migration-from-${n.id}`,className:`text-[10px] text-foreground-subtle`,children:t(`recordings.storageMigrationSection.classFrom`,{label:t(n.labelKey)})}),i(N,{id:`migration-from-${n.id}`,value:l[n.id]??a,onChange:e=>{let t=e.target.value;u(e=>({...e,[n.id]:t}))},disabled:b,className:`w-full`,children:r.map(n=>e(`option`,{value:n.id,children:[n.displayName,ve(n)?``:` (${t(`recordings.storageMigrationSection.readOnly`)})`]},n.id))})]}),e(`div`,{className:`space-y-1`,children:[i(`label`,{htmlFor:`migration-dest-${n.id}`,className:`text-[10px] text-foreground-subtle`,children:t(`recordings.storageMigrationSection.classTo`,{label:t(n.labelKey)})}),e(N,{id:`migration-dest-${n.id}`,value:s[n.id]??``,onChange:e=>{let t=e.target.value;c(e=>({...e,[n.id]:t}))},disabled:b,className:`w-full`,children:[i(`option`,{value:``,children:t(`migration.storageMigrationSection.skip`,`— skip —`)}),r.map(e=>i(`option`,{value:e.id,children:e.displayName},e.id))]})]})]},n.id)})}),p&&i(`p`,{className:`mt-2 text-[11px] text-danger`,children:p}),e(`div`,{className:`mt-3 flex items-center gap-2`,children:[e(H,{variant:`unstyled`,type:`button`,onClick:()=>{ee()},disabled:!x||w.isFetching||b,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:[w.isFetching&&i(V,{className:`h-3 w-3 animate-spin`}),t(`migration.storageMigrationSection.plan`,`Plan`)]}),e(H,{variant:`unstyled`,type:`button`,onClick:()=>{D()},disabled:!x||T.isPending||b,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:[T.isPending&&i(V,{className:`h-3 w-3 animate-spin`}),t(`migration.storageMigrationSection.startMigration`,`Start migration`)]})]}),d&&i(`div`,{className:`mt-3 divide-y divide-border rounded-md border border-border`,children:d.moves.length===0?i(`p`,{className:`px-2.5 py-1.5 text-[11px] text-foreground-subtle`,children:t(`migration.storageMigrationSection.nothingToMoveSelectedDestinations`,`Nothing to move — selected destinations match the current defaults.`)}):d.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}`))}),y&&e(`div`,{className:`mt-4 border-t border-border pt-3`,children:[e(`div`,{className:`flex items-center justify-between`,children:[i(`h4`,{className:`text-xs font-semibold text-foreground`,children:t(`migration.storageMigrationSection.migrationStatus`,`Migration status`)}),b&&e(H,{variant:`unstyled`,type:`button`,onClick:()=>{O()},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:[i(g,{className:`h-3 w-3`}),t(`common.cancel`,`Cancel`)]})]}),e(`p`,{className:`mt-1 text-xs text-foreground`,children:[t(`migration.storageMigrationSection.phase`,`Phase:`),` `,i(`span`,{className:`font-medium`,children:y.phase}),b&&i(V,{className:`ml-2 inline h-3 w-3 animate-spin text-primary`})]}),y.error&&i(`p`,{className:`mt-1 text-[11px] text-danger`,children:y.error}),y.pausedParticipants.length>0&&e(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:[t(`migration.storageMigrationSection.paused`,`Paused:`),` `,y.pausedParticipants.join(`, `)]}),i(`div`,{className:`mt-2 divide-y divide-border rounded-md border border-border`,children:y.moves.map(e=>i(Cs,{move:e},`${e.storageClass}-${e.fromLocationId}`))})]}),i(ws,{})]}),i(Ts,{running:b}),i(Ds,{})]})}function Cs({move:t}){let{t:n}=J(),r=t.progress===null?null:gs(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:[r!==null&&r.fraction!==null&&i(`div`,{className:`h-1 w-full overflow-hidden rounded bg-border`,children:i(`div`,{className:`h-full bg-primary`,style:{width:`${(r.fraction*100).toFixed(1)}%`}})}),i(`p`,{className:`text-[10px] text-foreground-subtle`,children:_s(t.progress)})]})]})}function ws(){let{t}=J(),{data:n}=vt({});return!n||n.length===0?null:e(`div`,{className:`mt-4 border-t border-border pt-3`,children:[i(`h4`,{className:`text-xs font-semibold text-foreground`,children:t(`migration.storageMigrationSection.migrationHistory`,`Migration history`)}),i(`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:[i(`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 Ts({running:t}){let{t:n}=J(),r=L(),a=St({},{staleTime:1/0,refetchOnWindowFocus:!1}),s=pt(),[c,l]=o(null),u=a.data??[];if(u.length===0)return null;let d=async e=>{if(await r({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 a.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:[i(`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:[i(`span`,{className:`text-[10px] text-foreground-subtle`,children:a.dataUpdatedAt>0?n(`migration.storageMigrationSection.measured`,`Measured {{value1}}`,{value1:new Date(a.dataUpdatedAt).toLocaleTimeString()}):n(`migration.storageMigrationSection.measuredNever`,`Measured — never`)}),i(H,{variant:`unstyled`,type:`button`,onClick:()=>{a.refetch()},disabled:a.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:a.isFetching?n(`migration.storageMigrationSection.counting`,`Counting…`):n(`common.refresh`,`Refresh`)})]})]}),i(`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.`)}),i(`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&&i(`p`,{className:`mt-2 text-[11px] text-danger`,children:c}),i(`div`,{className:`mt-2 divide-y divide-border rounded-md border border-border`,children:u.map(r=>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:[r.storageClass,`: `,r.fromLocationId,` → `,r.toLocationId,i(`span`,{className:`ml-2 text-foreground-subtle`,children:Es(r)})]}),i(H,{variant:`unstyled`,type:`button`,onClick:()=>{d(r)},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`)})]},`${r.storageClass}-${r.fromLocationId}`))})]})}function Es(e){if(e.items===null)return q.t(`recordings.storageMigrationSection.residueUnknown`);let t=e.items.toLocaleString(`en-US`);return e.bytes===null?q.t(`recordings.storageMigrationSection.residueRows`,{count:e.items,items:t}):q.t(`recordings.storageMigrationSection.residueSegments`,{count:e.items,items:t,size:Y(e.bytes)})}function Ds(){let{t}=J(),{data:n}=Lt({},{refetchInterval:2e3}),r=(n??[]).filter(e=>e.migrationJobId===null&&e.job.state===`running`);return r.length===0?null:e(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[i(`h3`,{className:`text-sm font-semibold text-foreground`,children:t(`migration.storageMigrationSection.moversRunningOutsideAMigration`,`Movers running outside a migration`)}),i(`div`,{className:`mt-2 divide-y divide-border rounded-md border border-border`,children:r.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]}),i(`p`,{className:`mt-1 text-[10px] text-foreground-subtle`,children:_s({filesMoved:t.job.filesMoved,filesTotal:t.job.filesTotal,bytesMoved:t.job.bytesMoved,startedAt:t.job.startedAt,observedAt:t.observedAt})})]},t.job.jobId))})]})}c();function Os({openOnMount:t}){let{t:n}=J(),[r,s]=o(t);return a(()=>{t&&s(!0)},[t]),i(Ye,{expanded:r,onExpandedChange:s,header:e(`span`,{className:`flex items-center gap-2 text-sm font-medium text-foreground`,children:[i(v,{className:`h-3.5 w-3.5`}),n(`archive.tools.title`,`Tools`),i(`span`,{className:`text-[11px] font-normal text-foreground-subtle`,children:n(`archive.tools.subtitle`,`Storage migration, prune events, cleanup, reconcile from disk`)})]}),children:e(`div`,{className:`flex flex-col gap-6`,"data-testid":`archive-tools`,children:[e(`section`,{className:`flex flex-col gap-2`,children:[i(`h3`,{className:`text-sm font-semibold text-foreground`,children:n(`archive.tools.migration`,`Move storage`)}),i(`p`,{className:`text-[11px] text-foreground-subtle`,children:n(`archive.tools.migrationHint`,`Copy footage, low-res footage or event media to a new location, verify, then repoint the default. Applies to every camera.`)}),i(xs,{})]}),e(`section`,{className:`flex flex-col gap-2`,children:[i(`h3`,{className:`text-sm font-semibold text-foreground`,children:n(`archive.tools.pruneEvents`,`Prune old events`)}),i(ns,{})]}),i(ss,{}),i(us,{})]})})}c();function ks({data:t}){let{t:n}=J(),{hash:r}=en();return a(()=>{r.length>1&&document.getElementById(r.slice(1))?.scrollIntoView({block:`start`})},[r]),e(`div`,{className:`flex flex-col gap-4`,children:[i(Xo,{data:t}),i(Le,{headingId:`archive-storage`,title:n(`archive.section.storage`,`Storage`),icon:w,children:i(`div`,{className:`p-3`,children:i(Qo,{})})}),i(Le,{headingId:`archive-cameras`,title:n(`archive.section.cameras`,`Cameras`),icon:S,children:i(Wo,{rows:t.rows,isLoading:t.isLoading})}),i(`div`,{id:`activity`,children:i(Le,{headingId:`archive-activity`,title:n(`archive.section.activity`,`Activity & health`),icon:M,children:i(`div`,{className:`p-3`,children:i(Kn,{data:t})})})}),i(`div`,{id:`tools`,children:i(Os,{openOnMount:r===`#tools`})})]})}c();function As(){let e=Ue({isCamera:!0,projection:`slim`}),t=Dt({},{refetchOnWindowFocus:!1}),r=Ee({},{refetchOnWindowFocus:!1}),i=Jt({},{refetchOnWindowFocus:!1}),a=Ge({history:1},{refetchOnWindowFocus:!1}),o=n(()=>(e.data??[]).map(e=>({id:e.id,name:e.name})).toSorted((e,t)=>e.name.localeCompare(t.name)),[e.data]),s=t.data??null,c=s!==null&&s.devicesRead!==`unavailable`,l=r.data??null,u=i.data??null,d=a.data?.latest??null,f=d===null?null:d.findings,p=n(()=>ar({cameras:o,footage:c?s.devices:null,events:l===null?null:l.devices,statuses:u,findings:f}),[o,c,s,l,u,f]);return{cameras:o,rows:p,totals:n(()=>or(p),[p]),usage:s,footprint:l,statuses:u,findings:f,digestAtMs:d===null?null:d.generatedAt,isLoading:e.isLoading||t.isLoading||r.isLoading}}function js(){let{t:e}=J(),t=As();return i(mn,{icon:xe,title:e(`nav.archive`,`Archive`),subtitle:e(`archive.subtitle`,`Recorded footage and captured events — what they occupy, where they are written, and how each camera is doing.`),paramName:pn,defaultSection:`overview`,sectionsLabel:e(`archive.sections`,`Archive sections`),sections:[{id:`overview`,label:e(`archive.section.overview`,`Overview`),content:i(ks,{data:t})},{id:`cameras`,label:e(`archive.section.cameras`,`Cameras`),ownedParams:[ln,dn],content:i(Vo,{data:t})}]})}export{js as ArchivePage};
|
|
1
|
+
import{C as e,J as t,K as n,R as r,S as i,V as a,Y as o,a as s,et as c,o as l,x as u}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{$i as d,Dt as f,Ea as p,Fn as m,Gi as h,Gt as g,Ii as _,Kt as v,Nn as y,Oa as b,Oi as x,Pa as S,Pn as C,Si as w,So as T,Tr as E,W as ee,Xi as D,_i as O,_n as k,_t as A,at as j,bo as M,bt as N,do as P,gi as F,hr as I,ht as L,ii as R,it as te,kn as z,la as ne,mi as re,nt as B,oi as V,or as ie,pn as ae,pt as oe,t as se,xn as ce,xo as le,xt as ue,yn as de,yt as H,z as fe,za as pe,zt as me}from"./player-overlays-Cs69NgAR.js";import{Nc as he,Yl as ge,bt as _e,fl as ve,ki as ye,pl as U}from"./src-BwDSKCnh.js";import{t as be}from"./chevron-down-CBb-F8DT.js";import{g as xe}from"./terminal-BncJ-1sF.js";import{n as Se,r as Ce,t as we}from"./scissors-DpiKUioV.js";import{t as W}from"./square-check-big-DAcFGNUN.js";import{$a as G,$i as Te,$u as Ee,Aa as De,Af as Oe,Am as ke,Ar as Ae,Bu as je,Da as Me,Dr as Ne,Ea as Pe,Fm as Fe,Fr as Ie,Gr as Le,Io as Re,Ir as ze,It as Be,Ja as Ve,Jr as He,Mc as Ue,Oa as We,Od as Ge,Of as Ke,Pa as qe,Pd as Je,Pi as Ye,Q as Xe,Qi as Ze,Qu as Qe,Rr as $e,Ta as et,Va as tt,Yr as nt,Za as K,Zu as rt,_i as it,_p as at,aa as ot,ad as st,am as ct,cd as lt,cp as ut,d as dt,dm as ft,dp as pt,ea as mt,ed as ht,em as gt,fm as _t,fp as vt,gi as yt,gp as bt,hi as xt,hp as St,ia as Ct,id as wt,jf as Tt,ka as Et,kf as Dt,lp as Ot,mm as kt,mp as At,nd as jt,oa as Mt,od as Nt,om as Pt,op as Ft,pm as It,pp as Lt,qi as Rt,rd as zt,sd as Bt,sp as Vt,ta as Ht,td as Ut,tm as Wt,up as Gt,vi as Kt,vr as qt,wd as Jt,xm as Yt,zd as Xt,zr as Zt}from"./src-DWGf7c88.js";import{r as Qt,t as $t}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare__react_mf_2_dom__loadShare__.js-BPba2g2p.js";import{c as en,l as tn,n as nn,p as rn}from"./chunk-4ZMWKKQ3-BCeNTgXs.js";import{t as q}from"./i18n-kurEJu5K.js";import{t as J}from"./useTranslation-uIxPZ_3N.js";import"./mount-CzwyZiSZ.js";import{$t as an,J as on,P as sn,Y as cn,en as ln,in as un,nn as dn,rn as fn,tn as pn}from"./index-uhNZQRiY.js";import{t as mn}from"./AdminSectionedPage-RkQwEpsd.js";import{a as hn,d as gn,f as _n,i as vn,m as yn,n as bn,o as xn,p as Sn,r as Cn,s as wn,t as Tn,u as En}from"./NewExportModal-DEpoqntE.js";import{a as Dn,i as On,r as kn,t as An}from"./authed-media-DDyQ4EVl.js";import{t as Y}from"./format-size-DIxKXxtj.js";import{a as jn,i as Mn,n as Nn,o as Pn,r as Fn,s as In,t as Ln}from"./StorageLocationsTable-BpamO2AO.js";c();var Rn={info:0,warning:1,critical:2},zn={"motion-without-detections":`motion`,"detections-under-floor":`detection`,"inference-too-slow":`detection`,"frames-shed":`detection`,"inference-device-unusable":`detection`};function Bn(e){return{id:`op:${e.id}`,at:e.at,source:`operation`,severity:`info`,fn:e.domain===`recording`?`recording`:`events`,deviceId:e.deviceId,title:`${e.op} · ${e.reason}`,detail:e.detail}}function Vn(e,t){return{id:`finding:${e.id}`,at:t,source:`finding`,severity:e.severity,fn:zn[e.kind],deviceId:e.subject.type===`camera`?e.subject.deviceId:null,title:e.what,detail:e.action}}function Hn(e,t){return e.filter(e=>t.deviceId===null||e.deviceId===t.deviceId).filter(e=>t.fn===null||e.fn===t.fn).filter(e=>t.minSeverity===null||Rn[e.severity]>=Rn[t.minSeverity]).toSorted((e,t)=>t.at-e.at)}var Un=``,Wn=[`recording`,`events`,`detection`,`motion`],Gn=[`info`,`warning`,`critical`];function Kn({data:t,deviceId:r}){let{t:a}=J(),s=Oe({},{refetchOnWindowFocus:!1}),c=zt({},{refetchOnWindowFocus:!1}),[l,u]=o(Un),[d,f]=o(Un),[p,m]=o(Un),h=n(()=>{let e=[...s.data??[],...c.data??[]].map(Bn),n=t.digestAtMs??0,r=(t.findings??[]).map(e=>Vn(e,n));return[...e,...r]},[s.data,c.data,t.findings,t.digestAtMs]),g=n(()=>({deviceId:r??(l===Un?null:Number(l)),fn:Wn.find(e=>e===d)??null,minSeverity:Gn.find(e=>e===p)??null}),[r,l,d,p]),_=n(()=>Hn(h,g),[h,g]),v=n(()=>new Map(t.cameras.map(e=>[e.id,e.name])),[t.cameras]),y=[];s.isError&&y.push(a(`archive.activity.footageLog`,`footage`)),c.isError&&y.push(a(`archive.activity.eventLog`,`event`));let b=n(()=>[{mobile:`detail`,key:`at`,header:a(`archive.activity.when`,`When`),nowrap:!0,sortValue:e=>e.at,render:e=>i(`span`,{className:`tabular-nums text-foreground-subtle`,children:e.at===0?`—`:new Date(e.at).toLocaleString()})},{mobile:`detail`,key:`severity`,header:a(`archive.activity.severity`,`Severity`),nowrap:!0,sortValue:e=>e.severity,render:e=>i(`span`,{className:qn[e.severity],children:a(`archive.severity.${e.severity}`,e.severity)})},{mobile:`detail`,key:`camera`,header:a(`archive.activity.camera`,`Camera`),sortValue:e=>e.deviceId===null?``:v.get(e.deviceId)??`#${String(e.deviceId)}`,render:e=>i(`span`,{className:`text-foreground`,children:e.deviceId===null?a(`archive.activity.cluster`,`Cluster`):v.get(e.deviceId)??`#${String(e.deviceId)}`})},{mobile:`primary`,key:`what`,header:a(`archive.activity.what`,`What`),render:t=>e(`div`,{className:`flex flex-col`,children:[i(`span`,{className:`text-foreground`,children:t.title}),t.detail!==null&&i(`span`,{className:`text-[11px] text-foreground-subtle`,children:t.detail})]})}],[a,v]);return e(`div`,{className:`flex flex-col gap-3`,"data-testid":`archive-activity`,children:[e(`div`,{className:`flex flex-wrap items-center gap-2`,children:[r===void 0&&e(N,{wrapperClassName:`inline-block w-auto`,value:l,onChange:e=>u(e.target.value),"aria-label":a(`archive.activity.filterCamera`,`Camera`),children:[i(`option`,{value:Un,children:a(`archive.activity.allCameras`,`All cameras`)}),t.cameras.map(e=>i(`option`,{value:String(e.id),children:e.name},e.id))]}),e(N,{wrapperClassName:`inline-block w-auto`,value:d,onChange:e=>f(e.target.value),"aria-label":a(`archive.activity.filterFunction`,`Function`),children:[i(`option`,{value:Un,children:a(`archive.activity.allFunctions`,`All functions`)}),Wn.map(e=>i(`option`,{value:e,children:a(`archive.function.${e}`,e)},e))]}),e(N,{wrapperClassName:`inline-block w-auto`,value:p,onChange:e=>m(e.target.value),"aria-label":a(`archive.activity.filterSeverity`,`Severity`),children:[i(`option`,{value:Un,children:a(`archive.activity.allSeverities`,`Any severity`)}),Gn.map(e=>i(`option`,{value:e,children:a(`archive.activity.atLeast`,`At least {{severity}}`,{severity:a(`archive.severity.${e}`,e)})},e))]})]}),y.length>0&&i(K,{variant:`warning`,message:a(`archive.activity.logUnread`,`The {{names}} log did not answer. This is not "nothing happened".`,{names:y.join(` / `)})}),_.length===0&&y.length===0?i(qe,{icon:M,title:a(`archive.activity.none`,`No activity`),description:a(`archive.activity.noneHint`,`Pruning, deletion and health findings show up here.`)}):i(He,{columns:b,rows:_,rowKey:e=>e.id,minWidthPx:640,maxBodyHeight:nt,pageSize:25})]})}var qn={info:`text-foreground-subtle`,warning:`text-warning`,critical:`text-danger`},Jn={recording:`recording`,motion:null,detection:`object-detection`,"event-media":`event-saving`},Yn={"motion-without-detections":`motion`,"detections-under-floor":`detection`,"inference-too-slow":`detection`,"frames-shed":`detection`,"inference-device-unusable":null},Xn={recording:`recording`,motion:null,detection:`detection`,"event-media":null},Zn=[`recording`,`motion`,`detection`,`event-media`];function Qn(e,t){switch(e){case`recording`:return t.recording===null?null:t.recording.active?`ok`:`warning`;case`motion`:return t.motion===null?null:t.motion.enabled?`ok`:`off`;case`detection`:return t.detection===null?null:`ok`;case`event-media`:return`ok`}}function $n(e){return e.some(e=>e.severity===`critical`)?`critical`:e.some(e=>e.severity===`warning`)?`warning`:`ok`}function er(e,t){return Zn.map(n=>{let r=t.filter(e=>Yn[e.kind]===n);if(e===void 0)return{fn:n,state:r.length>0?$n(r):`unknown`,findings:r};let i=Jn[n];if(i!==null&&e.switchedOff.includes(i))return{fn:n,state:`off`,findings:r};let a=Xn[n];return a!==null&&e.degraded.some(e=>e.stage===a)?{fn:n,state:r.length>0?$n(r):`unknown`,findings:r}:r.length>0?{fn:n,state:$n(r),findings:r}:n===`recording`&&e.recording?.mode===`off`?{fn:n,state:`off`,findings:r}:{fn:n,state:Qn(n,e)??`unknown`,findings:r}})}var tr=`recording`;function nr(e,t){return(e??[]).filter(e=>e.subject.type===`camera`&&e.subject.deviceId===t)}function rr(e){return e.filter(e=>e.severity!==`info`).length}function ir(e,t){return e===void 0?`unknown`:e.switchedOff.includes(tr)||e.recording?.mode===`off`?`off`:e.degraded.some(e=>e.stage===`recording`||e.stage===`switches`)||e.recording===null?`unknown`:t>0||!e.recording.active?`degraded`:`recording`}function ar(e){let t=new Map((e.footage??[]).map(e=>[e.deviceId,e])),n=new Map((e.events??[]).map(e=>[e.deviceId,e])),r=new Map((e.statuses??[]).map(e=>[e.deviceId,e]));return e.cameras.map(i=>{let a=rr(nr(e.findings,i.id)),o=r.get(i.id),s=t.get(i.id),c=n.get(i.id);return{deviceId:i.id,name:i.name,mode:o?.recording?.mode??null,state:ir(o,a),warnings:a,footageBytes:e.footage===null?null:s?.usedBytes??0,oldestMs:s?.oldestMs??null,eventRows:e.events===null?null:c?.rows??0,eventBytes:e.events===null?null:c?.bytes??0}})}function or(e){let t=t=>e.filter(e=>e.state===t).length;return{recording:t(`recording`),degraded:t(`degraded`),off:t(`off`),unknown:t(`unknown`),warnings:e.reduce((e,t)=>e+t.warnings,0)}}var sr={ok:`success`,off:`default`,warning:`warning`,critical:`danger`,unknown:`default`};function cr(e,t){return e.statuses?.find(e=>e.deviceId===t)}function lr({data:t,deviceId:n}){let{t:r}=J(),a=er(cr(t,n),nr(t.findings,n));return e(`div`,{className:`flex flex-col gap-4`,"data-testid":`archive-health`,children:[t.findings===null&&i(`p`,{className:`text-[11px] text-foreground-subtle`,children:r(`archive.health.noDigest`,`The health digest has not run yet — findings are not available.`)}),i(`ul`,{className:`flex flex-col divide-y divide-border rounded-lg border border-border bg-surface`,children:a.map(t=>e(`li`,{className:`flex flex-col gap-1 p-3`,children:[e(`div`,{className:`flex items-center justify-between gap-2`,children:[i(`span`,{className:`text-sm font-medium text-foreground`,children:r(`archive.function.${t.fn}`,t.fn)}),i(G,{variant:sr[t.state],children:r(`archive.functionState.${t.state}`,t.state)})]}),t.findings.map(t=>e(`div`,{className:`text-[11px] text-foreground-subtle`,children:[i(`span`,{className:`text-foreground`,children:t.what}),` — `,t.action]},t.id))]},t.fn))}),e(`div`,{className:`flex flex-col gap-2`,children:[e(`div`,{className:`flex items-center justify-between gap-2`,children:[i(`h3`,{className:`text-sm font-semibold text-foreground`,children:r(`archive.health.logs`,`Camera log`)}),i(nn,{className:`text-xs text-primary hover:underline`,to:`/system/logs?deviceId=${String(n)}`,children:r(`archive.health.openLogs`,`Open in Logs`)})]}),i(`div`,{className:`overflow-hidden rounded-lg border border-border bg-surface`,children:i(qt,{deviceId:n,limit:100,maxHeight:`max-h-80`,showFilters:!0})})]})]})}Qt();function ur(e){let t=e.subLabel??e.label;if(t!==void 0)return t;let n=e.audioLabels?.[0]?.label;return n!==void 0&&n.length>0?n:void 0}var dr=720*60*60*1e3;function fr(e){let t=[];for(let n of e)t.push(...n);return t}function pr(e,t){let n=[...e];return n.sort((e,n)=>t===`importance`?n.importance-e.importance:n.timestamp-e.timestamp),n}function mr(e,t){return e.filter(e=>!(e.importance<t.minImportance||t.cameras.size>0&&!t.cameras.has(e.deviceId)||t.classes.size>0&&!t.classes.has(e.className)))}function hr(e,t){return`${String(e)}:${t}`}function gr(e,t){let n=new Map,r=new Set;for(let i of e){let e=hr(i.deviceId,i.trackId);if(!t.has(e)||r.has(e))continue;r.add(e);let a=n.get(i.deviceId);a?a.push(i.trackId):n.set(i.deviceId,[i.trackId])}return n}function _r(e,t){return{since:e.fromMs??t-dr,until:e.toMs??t}}var vr=typeof Qe==`function`,yr=`Track deletion arrives with the next server update`;function br(){return{mutateAsync:async()=>{throw Error(`deleteTracks unavailable`)},isPending:!1}}var xr=vr?Qe:br;c();var Sr=3e4,Cr=[];function wr(e){let t=me(),r=e.deviceIds.length>0,i=[...e.deviceIds].sort((e,t)=>e-t),{data:a,isLoading:o}=s({queryKey:[`events-feed`,i,e.since,e.until,e.minImportance??null,e.classFilter??null],enabled:r,staleTime:Sr,refetchInterval:Sr,queryFn:async()=>(await t.trpcClient.pipelineAnalytics.getKeyEventsBatch.query({deviceIds:i,since:e.since,until:e.until,limit:200,...e.minImportance===void 0?{}:{minImportance:e.minImportance},...e.classFilter===void 0?{}:{classFilter:e.classFilter}})).map(e=>e.events.map(t=>({...t,deviceId:e.deviceId})))});return{rows:n(()=>pr(fr(a??Cr),`importance`),[a]),isLoading:r&&o}}c();var Tr=[`events-feed`],Er=2e3;function Dr(e){let n=l(),i=e?.paused===!0,s=t(n);s.current=n;let c=t(i);c.current=i;let[u,d]=o(!1),f=r(()=>{s.current.invalidateQueries({queryKey:Tr})},[]),p=t(void 0);p.current||=yn({delayMs:Er,invalidate:()=>{c.current?d(!0):f()}}),a(()=>()=>p.current?.cancel(),[]),a(()=>{i||!u||(d(!1),f())},[i,u,f]);let m=r(()=>{d(!1),f()},[f]);return Fe(ge.PipelineAnalyticsDetectionEvent,()=>{p.current?.trigger()}),Fe(ge.PipelineAnalyticsTrackEnded,()=>{p.current?.trigger()}),{pending:u,refreshNow:m}}c();function Or(e){let t=new Map;for(let n of e)t.set(n,(t.get(n)??0)+1);return[...t.entries()].sort((e,t)=>t[1]-e[1]||e[0].localeCompare(t[0])).map(([e])=>e)}function kr({classes:e,hidden:t,onChange:r}){let{t:a}=J(),o=n(()=>Or(e).map(e=>({id:e,label:e})),[e]);return o.length<2?null:i(Ae,{chips:o,off:t,onChange:r,allLabel:a(`detectionIntelligence.eventClassChips.all`,`All classes`),ariaLabel:a(`detectionIntelligence.eventClassChips.label`,`Classes`),testId:`event-class-chips`})}var Ar=[0,1,2],jr=`dominevo.archive.eventRowSize`,Mr={0:`w-[72px]`,1:`w-28`,2:`w-40`};function Nr(e){return e===1||e===2?e:0}c();function Pr({groups:t,selected:r,onChange:a,loading:s=!1}){let{t:c}=J(),l=Ne(),[u,d]=o(!1),[f,m]=o(``),[h,g]=o(new Set),_=f.trim().toLowerCase(),v=e=>_.length===0||ct(e,c).toLowerCase().includes(_),y=n(()=>t.map(e=>({macro:e.macro,subs:e.subs.filter(t=>v(t)||v(e.macro))})).filter(e=>v(e.macro)||e.subs.length>0),[t,_]),b=e=>g(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),x=e=>{let t=new Set(r),n=r.has(e.macro.kind)&&e.subs.every(e=>r.has(e.kind)),i=[e.macro.kind,...e.subs.map(e=>e.kind)];if(n)for(let e of i)t.delete(e);else for(let e of i)t.add(e);a(t)},S=e=>{let t=new Set(r);t.has(e)?t.delete(e):t.add(e),a(t)},C=()=>a(new Set),w=r.size;return e(`div`,{className:`relative`,children:[e(H,{variant:`unstyled`,type:`button`,onClick:()=>d(e=>!e),className:`flex items-center gap-1 rounded-md px-2.5 py-1 text-xs transition-colors ${w>0?`bg-primary/12 text-primary font-medium`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:[i(z,{className:`h-3.5 w-3.5`}),w>0?c(`detectionIntelligence.eventKindFilter.kinds`,`Kinds ({{value1}})`,{value1:String(w)}):c(`detectionIntelligence.eventKindFilter.kinds2`,`Kinds`),i(be,{className:`h-3 w-3`})]}),u&&e(`div`,{className:`absolute z-20 mt-1 max-h-80 w-64 overflow-auto rounded-md border border-border bg-surface p-2 shadow-lg`,children:[e(`div`,{className:`mb-2 flex items-center gap-1 rounded border border-border px-1.5`,children:[i(ie,{className:`h-3.5 w-3.5 text-foreground-subtle`}),i(ue,{type:`text`,value:f,onChange:e=>m(e.target.value),placeholder:c(`detectionIntelligence.eventKindFilter.searchKinds`,`Search kinds…`),className:`w-full bg-transparent py-1 text-xs outline-none`}),w>0&&i(H,{variant:`unstyled`,type:`button`,onClick:C,className:`text-[10px] text-foreground-subtle hover:text-foreground`,children:c(`detectionIntelligence.eventKindFilter.clear`,`Clear`)})]}),y.length===0&&i(`div`,{className:`px-1 py-2 text-[11px] text-foreground-subtle`,children:s?c(`detectionIntelligence.eventKindFilter.loadingKinds`,`Loading kinds…`):_.length>0?c(`detectionIntelligence.eventKindFilter.noKindMatchesThatSearch`,`No kind matches that search.`):c(`detectionIntelligence.eventKindFilter.theseCamerasAdvertiseNoEvent`,`These cameras advertise no event kinds.`)}),y.map(t=>{let n=Pt(t.macro.iconId),a=h.has(t.macro.kind)||_.length>0,o=r.has(t.macro.kind);return e(`div`,{className:`mb-0.5`,children:[e(`div`,{className:`flex items-center gap-1`,children:[t.subs.length>0?i(H,{variant:`unstyled`,type:`button`,onClick:()=>b(t.macro.kind),className:`text-foreground-subtle hover:text-foreground`,"aria-label":c(`detectionIntelligence.eventKindFilter.expand`,`Expand`),children:i(a?be:p,{className:`h-3 w-3`})}):i(`span`,{className:`w-3`}),e(`label`,{className:`flex flex-1 cursor-pointer items-center gap-1.5 rounded px-1 py-0.5 text-xs hover:bg-surface-hover`,children:[i(le,{checked:o,onChange:()=>x(t),className:`accent-primary`}),i(n,{className:`h-3.5 w-3.5`,style:{color:l(t.macro.kind)}}),i(`span`,{className:`font-medium`,children:ct(t.macro,c)})]})]}),a&&t.subs.map(t=>{let n=Pt(t.iconId);return e(`label`,{className:`ml-5 flex cursor-pointer items-center gap-1.5 rounded px-1 py-0.5 text-xs hover:bg-surface-hover`,children:[i(le,{checked:r.has(t.kind),onChange:()=>S(t.kind),className:`accent-primary`}),i(n,{className:`h-3.5 w-3.5`,style:{color:l(t.kind)}}),i(`span`,{children:ct(t,c)})]},t.kind)})]},t.macro.kind)})]})]})}function Fr(e,t){let n=new Map;for(let r of e)if(!(t.size>0&&!t.has(r.deviceId)))for(let e of r.kinds)n.has(e.kind)||n.set(e.kind,e);return n}function Ir(e,t){return{...t,kind:e,labelKey:`eventKind.${e}`,label:e.charAt(0).toUpperCase()+e.slice(1),iconId:e,parentKind:null,level:`macro`}}var Lr=new Set([`detection`,`package`]);function Rr(e,t){return[...Fr(e,t).values()].filter(e=>e.parentKind===null&&Lr.has(e.category)).sort((e,t)=>e.label.localeCompare(t.label))}function zr(e,t){let n=Fr(e,t),r=new Map,i=new Map;for(let e of n.values()){if(e.parentKind===null){i.set(e.kind,e);continue}let t=r.get(e.parentKind);t===void 0?r.set(e.parentKind,[e]):t.push(e)}for(let[e,t]of r){if(i.has(e))continue;let n=t[0];n!==void 0&&i.set(e,Ir(e,n))}return[...i.values()].map(e=>({macro:e,subs:[...r.get(e.kind)??[]].sort((e,t)=>e.label.localeCompare(t.label))})).sort((e,t)=>e.macro.label.localeCompare(t.macro.label))}c();var Br=1400,Vr=`Admin-gated URL — opens only inside an authenticated session`;function Hr({label:t,value:n,title:s}){let{t:c}=J(),[l,u]=o(!1),f=A();return a(()=>{if(!l)return;let e=setTimeout(()=>u(!1),Br);return()=>clearTimeout(e)},[l]),e(H,{variant:`unstyled`,type:`button`,onClick:r(()=>{(async()=>{try{await navigator.clipboard.writeText(n),u(!0)}catch{await f({title:c(`detectionIntelligence.copyUrlChips.copyTheMediaUrl`,`Copy the media URL`),message:c(`detectionIntelligence.copyUrlChips.clipboardAccessWasRefusedSelect`,`Clipboard access was refused. Select the URL below and copy it manually.`),label:c(`detectionIntelligence.copyUrlChips.url`,`{{label}} URL`,{label:t}),defaultValue:n,readOnly:!0,cancelLabel:c(`common.close`,`Close`)})}})()},[n,t,f,c]),title:s,"aria-label":c(`detectionIntelligence.copyUrlChips.copyUrl`,`Copy {{label}} URL`,{label:t}),className:`flex min-w-0 items-center gap-1 rounded border px-1.5 py-0.5 text-[10px] font-medium transition-colors ${l?`border-success/40 bg-success/10 text-success`:`border-border text-foreground-subtle hover:border-primary hover:text-foreground`}`,children:[i(l?b:d,{className:`h-2.5 w-2.5 shrink-0`}),i(`span`,{className:`truncate`,children:l?c(`detectionIntelligence.copyUrlChips.copied`,`Copied`):t})]})}function Ur({localUrl:t,publicUrl:n}){let{t:r}=J();return e(`div`,{className:`flex flex-wrap gap-1`,children:[i(Hr,{label:r(`detectionIntelligence.copyUrlChips.local`,`Local`),value:t,title:r(`detectionIntelligence.copyUrlChips.copyLanUrl`,`Copy LAN URL — {{AUTH_HINT}}`,{AUTH_HINT:Vr})}),n&&i(Hr,{label:r(`detectionIntelligence.copyUrlChips.public`,`Public`),value:n,title:r(`detectionIntelligence.copyUrlChips.copyPublicUrl`,`Copy public URL — {{AUTH_HINT}}`,{AUTH_HINT:Vr})})]})}var Wr={firstFrame:`First frame (track start)`,lastFrame:`Last frame (track end)`,thumbnail:`Best detection`,thumbnailSmall:`Best detection (480)`,snapshot:`Snapshot`,keyFrame:`Key frame (native-res)`,keyFrameSmall:`Key frame (960)`,crop:`Object crop`,fullFrame:`Full frame`,fullFrameBoxed:`Full frame (boxed)`,faceCrop:`Face crop`,plateCrop:`Plate crop`,confirmationCrop:`Confirmation crop (what the gate saw)`,debugCrop:`Debug crop (why this decision)`,sceneFrame:`Scene frame (clean)`,lastSceneFrame:`Last frame (clean)`};function Gr(e){return e in Wr}function Kr(e){return Gr(e)?Wr[e]:e}function qr(e,t){return`${e}${t}`}var Jr=[`native`,`raster`,`standin`];function Yr(e){return Jr.some(t=>t===e)}function Xr(e){return e===`standin`?{label:q.t(`helpers.mediaProvenance.standin.label`),title:q.t(`helpers.mediaProvenance.standin.title`),tone:`warning`}:{label:q.t(`helpers.mediaProvenance.raster.label`),title:q.t(`helpers.mediaProvenance.raster.title`),tone:`info`}}function Zr(e){return e===`standin`?Xr(`standin`):e===`raster`?Xr(`raster`):null}var Qr={"no-key-frame":`helpers.mediaProvenance.miss.noKeyFrame`,"no-best-seen-bbox":`helpers.mediaProvenance.miss.noBestSeenBbox`,"derive-returned-null":`helpers.mediaProvenance.miss.deriveReturnedNull`,"derive-threw":`helpers.mediaProvenance.miss.deriveThrew`,"derive-not-wired":`helpers.mediaProvenance.miss.deriveNotWired`,"no-media-store":`helpers.mediaProvenance.miss.noMediaStore`,"no-thumbnail":`helpers.mediaProvenance.miss.noThumbnail`,"standin-tile":`helpers.mediaProvenance.miss.standinTile`,"raster-tile":`helpers.mediaProvenance.miss.rasterTile`,"native-tile":`helpers.mediaProvenance.miss.nativeTile`};function $r(e){if(e===void 0)return null;let t=e.trim();if(t.length===0)return null;let n=t.split(/\s+/),r=n[0]??t,i=[];for(let e of n.slice(1)){let t=e.indexOf(`=`);t===-1?i.push({key:e,value:null}):i.push({key:e.slice(0,t),value:e.slice(t+1)})}let a=Qr[r];return{sentence:a===void 0?r:q.t(a),detail:i,raw:t}}c();var ei=3e4;function ti(e){let[t,n]=o(null),s=r(e=>{n(t=>t??e)},[]);return a(()=>{e||n(null)},[e]),{publicOrigin:t,probes:e?i(ni,{onOrigin:s}):null}}function ni({onOrigin:e}){let{data:t}=Re({capName:`network-access`});return i(u,{children:(t??[]).map(t=>i(ri,{addonId:t.addonId,onOrigin:e},t.addonId))})}function ri({addonId:e,onOrigin:t}){let{data:n}=je({addonId:e},{refetchInterval:ei,retry:!1});return a(()=>{let e=n?ye.safeParse(n):null,r=e?.success?e.data.endpoint?.url:void 0;if(r)try{t(new URL(r).origin)}catch{}},[n,t]),null}var ii=typeof lt==`function`,ai=`Track flags arrive with the next server update`;function oi(){return{mutateAsync:async()=>{throw Error(`setTrackFlags unavailable`)},isPending:!1}}var si=ii?lt:oi;function ci(e){if(typeof e!=`object`||!e||!(`trackId`in e)||!(`markForTrain`in e)||!(`debug`in e)||!(`favourited`in e))return null;let{trackId:t,markForTrain:n,debug:r,favourited:i}=e;return typeof t!=`string`||typeof n!=`boolean`||typeof r!=`boolean`||typeof i!=`boolean`?null:{trackId:t,markForTrain:n,debug:r,favourited:i}}c();function li({label:t,hint:n,checked:r,disabled:a,title:o,icon:s,onToggle:c}){return e(H,{variant:`unstyled`,type:`button`,role:`switch`,"aria-checked":r,"aria-label":t,disabled:a,title:o,onClick:c,className:`flex w-full items-center gap-2 rounded-md border px-2 py-1.5 text-left transition-colors disabled:opacity-50 ${r?`border-primary bg-primary/10`:`border-border bg-surface hover:bg-surface-hover`}`,children:[i(`span`,{className:r?`text-primary`:`text-foreground-subtle`,children:s}),e(`span`,{className:`min-w-0 flex-1`,children:[i(`span`,{className:`block text-[11px] font-medium text-foreground`,children:t}),i(`span`,{className:`block text-[10px] text-foreground-subtle`,children:n})]}),i(`span`,{"aria-hidden":`true`,className:`h-4 w-7 shrink-0 rounded-full p-0.5 transition-colors ${r?`bg-primary`:`bg-border`}`,children:i(`span`,{className:`block h-3 w-3 rounded-full bg-white transition-transform ${r?`translate-x-3`:``}`})})]})}function ui({deviceId:t,trackId:n,markForTrain:r,debug:a,favourited:s,onChange:c}){let{t:l}=J(),u=si(),d=oe(),[f,p]=o(null),m=f?.markForTrain??r===!0,h=f?.debug??a===!0,g=f?.favourited??s===!0,_=!ii||u.isPending,v=ii?void 0:ai,b=e=>{_||(async()=>{try{let r=ci(await u.mutateAsync({deviceId:t,trackId:n,flags:e}));if(!r)return;p(r),c?.(r)}catch(e){let t=e instanceof Error?e.message:``;await d({title:l(`detectionIntelligence.trackFlagToggles.couldNotUpdateThisTrack`,`Could not update this track`),message:t===``?l(`detectionIntelligence.trackFlagToggles.couldNotUpdateThisTrack2`,`Could not update this track. Check the server logs.`):t,variant:`danger`})}})()};return e(`div`,{className:`grid gap-1.5 sm:grid-cols-2`,children:[i(li,{label:l(`detectionIntelligence.trackFlagToggles.markForTraining`,`Mark for training`),hint:l(`detectionIntelligence.trackFlagToggles.keepsThisTrackAndIts`,`Keeps this track and its media past retention`),checked:m,disabled:_,...v===void 0?{}:{title:v},icon:i(x,{className:`h-4 w-4`}),onToggle:()=>b({markForTrain:!m})}),i(li,{label:l(`detectionIntelligence.trackFlagToggles.debug`,`Debug`),hint:l(`detectionIntelligence.trackFlagToggles.flagThisTrackForDiagnostic`,`Flag this track for diagnostic attention`),checked:h,disabled:_,...v===void 0?{}:{title:v},icon:i(pe,{className:`h-4 w-4`}),onToggle:()=>b({debug:!h})}),i(li,{label:l(`detectionIntelligence.trackFlagToggles.favourited`,`Favourited`),hint:l(`detectionIntelligence.trackFlagToggles.keepsThisTrackAndIts`,`Keeps this track and its media past retention`),checked:g,disabled:_,...v===void 0?{}:{title:v},icon:i(y,{className:`h-4 w-4`}),onToggle:()=>b({favourited:!g})})]})}function di(e){let t=e.deviceKey===void 0?e.nodeId:`${e.nodeId} · ${e.deviceKey}`;return e.modelId===void 0?t:`${t} (${e.modelId})`}function fi(e){let t=e?.openedPlacement,n=e?.closedPlacement;if(t!==void 0&&n!==void 0){let e=di(t),r=di(n);return e===r?[{kind:`detected`,value:e}]:[{kind:`opened`,value:e},{kind:`closed`,value:r}]}return t===void 0?n===void 0?[]:[{kind:`closed`,value:di(n)}]:[{kind:`opened`,value:di(t)}]}var pi=100,mi={polyline:``,points:[],snapshots:[],start:null,end:null,peakBox:null},hi=e=>e<0?0:e>1?1:e,gi=e=>Math.round(e*100)/100;function _i(e,t,n){if(e.length===0||t===null)return mi;let{width:r,height:i}=t;if(!Number.isFinite(r)||!Number.isFinite(i)||r<=0||i<=0)return mi;let a=_e(e.map(e=>({x:e.x/r,y:e.y/i,w:e.bbox.w/r,h:e.bbox.h/i})),n?.maxPoints===void 0?void 0:{maxPoints:n.maxPoints}).nodes.map(e=>({x:gi(e.x*pi),y:gi(e.y*pi)})),o=a[0]??null,s=a[a.length-1]??null,c=a.length>=2?a.map(e=>`${e.x},${e.y}`).join(` `):``,l=(n?.snapshots??[]).map(e=>({x:gi(hi(e.x/r)*pi),y:gi(hi(e.y/i)*pi),mediaId:e.mediaId})),u=null,d=-1;for(let t of e){let e=hi(t.bbox.w/r)*hi(t.bbox.h/i);e>d&&(d=e,u=t)}return{polyline:c,points:a,snapshots:l,start:o,end:s,peakBox:u?{x:gi(hi(u.bbox.x/r)*pi),y:gi(hi(u.bbox.y/i)*pi),w:gi(hi(u.bbox.w/r)*pi),h:gi(hi(u.bbox.h/i)*pi)}:null}}c();var vi=15e3,yi=te();function bi({url:e,label:t}){let{src:n,failed:r}=Dn(e);return n===null?i(`div`,{className:`flex h-full w-full items-center justify-center bg-surface-hover`,children:r?i(O,{className:`h-4 w-4 text-foreground-subtle opacity-60`}):i(V,{className:`h-4 w-4 animate-spin text-foreground-subtle opacity-70`})}):i(`img`,{src:n,alt:t,className:`h-full w-full object-cover`})}var xi=new Set([`firstFrame`,`lastFrame`,`thumbnail`,`snapshot`]),Si=new Set([`keyFrame`,`fullFrame`,`fullFrameBoxed`,`firstFrame`,`lastFrame`,`thumbnail`,`snapshot`,`sceneFrame`,`lastSceneFrame`]);function Ci(e){let[t,n]=o(null);return a(()=>{if(n(null),!e)return;let t=!1,r=new Image;return r.onload=()=>{t||n({width:r.naturalWidth,height:r.naturalHeight})},r.src=e,()=>{t=!0,r.onload=null}},[e]),t}function wi({overlay:t,onPickSnapshot:n}){let{t:r}=J();return!t.polyline&&!t.peakBox&&t.snapshots.length===0?null:e(`svg`,{viewBox:`0 0 100 100`,preserveAspectRatio:`none`,className:`pointer-events-none absolute inset-0 h-full w-full`,children:[t.peakBox&&i(`rect`,{x:t.peakBox.x,y:t.peakBox.y,width:t.peakBox.w,height:t.peakBox.h,fill:`none`,stroke:`var(--color-warning)`,strokeWidth:2,vectorEffect:`non-scaling-stroke`,rx:1}),t.polyline&&i(`polyline`,{points:t.polyline,fill:`none`,stroke:`var(--color-info)`,strokeWidth:2,strokeLinejoin:`round`,strokeLinecap:`round`,strokeOpacity:.85,vectorEffect:`non-scaling-stroke`}),t.points.map((e,t)=>i(`circle`,{cx:e.x,cy:e.y,r:1,fill:`var(--color-info)`,fillOpacity:.6,vectorEffect:`non-scaling-stroke`},`${String(e.x)}-${String(e.y)}-${String(t)}`)),t.snapshots.map((e,t)=>i(`circle`,{cx:e.x,cy:e.y,r:1.9,fill:`var(--color-info)`,fillOpacity:.95,stroke:`var(--color-background)`,strokeWidth:.7,vectorEffect:`non-scaling-stroke`,className:n?`pointer-events-auto cursor-pointer`:void 0,onClick:n?t=>{t.stopPropagation(),n(e.mediaId)}:void 0,children:i(`title`,{children:r(`detectionIntelligence.eventDetailPanel.snapshotCheckpointClickToView`,`Snapshot checkpoint — click to view this frame`)})},`snap-${String(e.mediaId)}-${String(t)}`)),t.start&&i(`circle`,{cx:t.start.x,cy:t.start.y,r:2.4,fill:`var(--color-success)`,stroke:`var(--color-background)`,strokeWidth:.6,vectorEffect:`non-scaling-stroke`}),t.end&&i(`circle`,{cx:t.end.x,cy:t.end.y,r:2.4,fill:`var(--color-danger)`,stroke:`var(--color-background)`,strokeWidth:.6,vectorEffect:`non-scaling-stroke`})]})}function X({label:t,value:n,mono:r,wrap:a}){return e(`div`,{className:`flex items-baseline justify-between gap-3 border-b border-border/60 py-1.5 last:border-0`,children:[i(`span`,{className:`shrink-0 text-[11px] uppercase tracking-wide text-foreground-subtle`,children:t}),i(`span`,{className:`min-w-0 ${a?`break-words`:`truncate`} text-right text-xs font-medium text-foreground ${r?`font-mono text-[11px]`:``}`,title:n,children:n})]})}function Ti({row:t,cameraName:s,deleteAvailable:c,onClose:l,onDeleted:d,onFlagsChanged:f}){let{t:p}=J(),m=me(),h=oe(),g=L(),v=xr(),y=t!==null,b=t?.deviceId??0,x=t?.trackId??``,S=t?.timestamp??0,C=t?.windowMs??0,{data:w}=ht({deviceId:b,trackId:x},{enabled:y}),{data:T}=wt({trackId:x,deviceId:b},{enabled:y}),E=w?.bestEventId===void 0?void 0:Number(w.bestEventId),{data:D}=jt({ownerType:`object`,eventId:E??0,deviceId:b},{enabled:y&&E!==void 0&&Number.isFinite(E)}),{data:k}=Wt({deviceId:b},{enabled:y}),A=(k??[]).find(e=>e.addonId!==void 0)?.addonId,{data:j}=gt({deviceId:b,since:S-vi,until:S+C+vi,provider:A??``},{enabled:y&&A!==void 0}),[M,N]=o(null),[P,F]=o(!1),{publicOrigin:I,probes:R}=ti(y);a(()=>{N(null)},[b,x]);let te=n(()=>{let e=T??[],t=D??[];return e.find(e=>e.kind===`keyFrame`)||t.find(e=>e.kind===`fullFrameBoxed`)||([...t,...e].find(e=>e.kind===`crop`)??null)},[T,D]),z=M??te,ne=Dn(z?z.url:void 0),re=n(()=>{let e=new Set,t=[];for(let n of[...D??[],...T??[]])e.has(n.mediaId)||(e.add(n.mediaId),t.push(n));return t},[D,T]),B=n(()=>re.find(e=>xi.has(e.kind))??null,[re]),ie=Ci(Dn(B?B.url:void 0).src),ae=n(()=>_i(w?.positions??[],ie,{snapshots:(w?.snapshots??[]).map(e=>({x:e.position.x,y:e.position.y,mediaId:e.mediaId}))}),[w?.positions,w?.snapshots,ie]),se=r(e=>{let t=re.find(t=>t.mediaId===e);t&&N(t)},[re]);if(t===null)return null;let le=ne.src,ue=z?.kind,de=ue!==void 0&&Si.has(ue)&&ie!==null&&(w?.positions.length??0)>=2,fe=j&&j.length>0?j[0]:null,pe=()=>{fe&&(F(!0),(async()=>{try{let e=await m.trpcClient.videoclips.getClipPlayback.query({deviceId:t.deviceId,clipId:fe.id});window.open(e.playbackUrl,`_blank`,`noopener`)}catch{h({title:p(`detectionIntelligence.eventDetailPanel.clipUnavailable`,`Clip unavailable`),message:p(`detectionIntelligence.eventDetailPanel.couldNotResolveClipPlayback`,`Could not resolve clip playback. Check the server logs.`),variant:`warning`})}finally{F(!1)}})())},he=()=>{!c||v.isPending||(async()=>{if(await g({title:p(`detectionIntelligence.eventDetailPanel.deleteTrack`,`Delete track`),message:p(`detectionIntelligence.eventDetailPanel.deleteThisTrackAndEvery`,`Delete this track and every image and clip captured for it? This cannot be undone.`),confirmLabel:p(`common.delete`,`Delete`),variant:`danger`}))try{await v.mutateAsync({deviceId:t.deviceId,trackIds:[t.trackId]}),d()}catch{await h({title:p(`detectionIntelligence.eventDetailPanel.deleteFailed`,`Delete failed`),message:p(`detectionIntelligence.eventDetailPanel.failedToDeleteThisTrack`,`Failed to delete this track. Check the server logs.`),variant:`danger`})}})()},ge=Math.round(t.importance*100),_e=w?.importanceReason?`${String(ge)}% · ${w.importanceReason}`:`${String(ge)}%`,ve=w?.zonesVisited&&w.zonesVisited.length>0?w.zonesVisited.join(`, `):`—`,ye=w?.audioLabels&&w.audioLabels.length>0?w.audioLabels:t.audioLabels&&t.audioLabels.length>0?t.audioLabels:void 0,U=ye===void 0?`—`:ye.map(e=>`${e.label} ×${String(e.count)} (${String(Math.round(e.peakScore*100))}%)`).join(` · `),be=w?ee(w.totalDistance,void 0):`—`,xe=$r(w?.previewMissReason),Se=_n(w?w.firstSeen:S),Ce=w?_n(w.lastSeen):`—`,we=fi(w),W={detected:p(`detectionIntelligence.eventDetailPanel.detectedOn`,`Detected on`),opened:p(`detectionIntelligence.eventDetailPanel.openedOn`,`Opened on`),closed:p(`detectionIntelligence.eventDetailPanel.closedOn`,`Closed on`)};return i(Te,{open:!0,onOpenChange:e=>!e&&l(),children:e(Ht,{width:`lg`,placement:`sheet-on-mobile`,"aria-label":p(`detectionIntelligence.eventDetailPanel.eventDetail`,`Event detail`),className:`flex h-[92dvh] flex-col gap-0 overflow-hidden p-0 bottom-0 left-0 right-0 top-auto w-full max-w-full translate-x-0 translate-y-0 rounded-b-none md:bottom-auto md:left-1/2 md:right-auto md:top-1/2 md:h-auto md:w-[calc(100vw-2rem)] md:max-w-xl md:-translate-x-1/2 md:-translate-y-1/2 md:rounded-lg md:max-h-[calc(100dvh-2rem)]`,children:[i(`header`,{className:`flex shrink-0 items-start gap-2 border-b border-border py-3 pl-4 pr-10`,children:e(`div`,{className:`min-w-0`,children:[e(`div`,{className:`truncate text-sm font-semibold text-foreground`,children:[t.className,ur(t)?e(`span`,{className:`text-foreground-subtle`,children:[` · `,ur(t)]}):null]}),i(`div`,{className:`mt-0.5 truncate text-[11px] text-foreground-subtle`,children:s})]})}),e(`div`,{className:`min-h-0 flex-1 space-y-3 overflow-y-auto overscroll-contain px-4 py-3`,children:[le?i(`div`,{className:`overflow-hidden rounded-lg border border-border bg-background`,children:i(vn,{src:le,alt:p(`detectionIntelligence.eventDetailPanel.keyFrameFrom`,`Key frame from {{cameraName}}`,{cameraName:s}),fit:`natural`,className:`w-full`,overlay:de?i(wi,{overlay:ae,onPickSnapshot:se}):void 0})}):i(`div`,{className:`flex aspect-video w-full flex-col items-center justify-center gap-1.5 rounded-lg border border-border bg-surface-hover text-foreground-subtle`,children:ne.failed?e(u,{children:[i(O,{className:`h-8 w-8 opacity-60`}),i(`span`,{className:`text-[11px]`,children:p(`detectionIntelligence.eventDetailPanel.keyFrameMediaUnavailable`,`Key-frame media unavailable`)})]}):i(V,{className:`h-6 w-6 animate-spin opacity-70`})}),re.length>0&&i(`div`,{className:`-mx-1 flex gap-2 overflow-x-auto px-1 pb-1`,children:re.map(t=>{let n=Kr(t.kind),r=qr(yi,t.url),a=I?qr(I,t.url):null;return e(`figure`,{className:`flex w-32 shrink-0 flex-col gap-1`,children:[i(H,{variant:`unstyled`,type:`button`,onClick:()=>N(t),className:`relative h-16 w-full overflow-hidden rounded border border-border hover:border-primary`,title:`${n} · ${_n(t.timestamp)}`,children:i(bi,{url:t.url,label:n})}),e(`figcaption`,{className:`min-w-0 px-0.5`,children:[i(`div`,{className:`truncate text-[10px] font-medium leading-tight text-foreground`,title:n,children:n}),i(`div`,{className:`text-[10px] leading-tight text-foreground-subtle`,title:_n(t.timestamp),children:En(t.timestamp)})]}),i(Ur,{localUrl:r,publicUrl:a})]},t.mediaId)})}),R,fe&&e(H,{variant:`secondary`,onClick:pe,disabled:P,children:[P?i(V,{className:`h-3.5 w-3.5 animate-spin`}):i(_,{className:`h-3.5 w-3.5`}),` `,p(`detectionIntelligence.eventDetailPanel.viewClip`,`View clip`)]}),i(ui,{deviceId:t.deviceId,trackId:t.trackId,...(w?.markForTrain??t.markForTrain)===void 0?{}:{markForTrain:w?.markForTrain??t.markForTrain},...(w?.debug??t.debug)===void 0?{}:{debug:w?.debug??t.debug},...(w?.favourited??t.favourited)===void 0?{}:{favourited:w?.favourited??t.favourited},onChange:f}),xe!==null&&e(`div`,{className:`rounded-lg border border-warning/40 bg-warning/8 px-3 py-2`,children:[i(`p`,{className:`text-[11px] font-semibold uppercase tracking-wide text-foreground-subtle`,children:p(`detectionIntelligence.eventDetailPanel.bestShot`,`Best shot`)}),i(`p`,{className:`mt-0.5 text-xs text-foreground`,children:xe.sentence}),i(`code`,{className:`mt-1 block break-all font-mono text-[10px] text-foreground-subtle`,children:xe.raw})]}),e(`div`,{className:`rounded-lg border border-border bg-surface px-3 py-1`,children:[i(X,{label:p(`detectionIntelligence.eventDetailPanel.camera`,`Camera`),value:s}),we.map(e=>i(X,{label:W[e.kind],value:e.value,mono:!0,wrap:!0},e.kind)),i(X,{label:p(`detectionIntelligence.eventDetailPanel.class`,`Class`),value:t.className}),i(X,{label:p(`detectionIntelligence.eventDetailPanel.label`,`Label`),value:t.label??`—`}),i(X,{label:p(`detectionIntelligence.eventDetailPanel.subLabel`,`Sub-label`),value:t.subLabel??`—`}),i(X,{label:p(`detectionIntelligence.eventDetailPanel.importance`,`Importance`),value:_e}),i(X,{label:p(`detectionIntelligence.eventDetailPanel.zonesVisited`,`Zones visited`),value:ve}),i(X,{label:p(`detectionIntelligence.eventDetailPanel.audioHeard`,`Audio heard`),value:U}),i(X,{label:p(`detectionIntelligence.eventDetailPanel.totalDistance`,`Total distance`),value:be}),i(X,{label:p(`detectionIntelligence.eventDetailPanel.firstSeen`,`First seen`),value:Se}),i(X,{label:p(`detectionIntelligence.eventDetailPanel.lastSeen`,`Last seen`),value:Ce}),i(X,{label:p(`detectionIntelligence.eventDetailPanel.track`,`Track`),value:t.trackId,mono:!0})]})]}),i(`footer`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-border px-4 py-3 pb-[max(0.75rem,env(safe-area-inset-bottom))]`,children:i(`span`,{title:c?void 0:yr,children:e(H,{variant:`secondary`,onClick:he,disabled:!c||v.isPending,children:[v.isPending?i(V,{className:`h-3.5 w-3.5 animate-spin`}):i(ce,{className:`h-3.5 w-3.5`}),` `,p(`detectionIntelligence.eventDetailPanel.deleteTrack`,`Delete track`)]})})})]})})}function Ei(e){if(e===void 0||!Number.isFinite(e)||e<=0)return``;let t=e/1e3;if(t<60)return`${ee(t,void 0)}s`;let n=Math.floor(t/60),r=Math.round(t%60);return`${String(n)}m ${String(r).padStart(2,`0`)}s`}function Di({row:t,cameraName:n,nowMs:r,onOpenDetail:a,selected:o=!1,onToggleSelect:s,score:c,provenance:l,footer:u}){let{t:d}=J(),f=Dn(t.mediaId===void 0?On(`track`,t.trackId):kn(t.mediaId)),p=Math.round(t.importance*100),m=c===void 0?void 0:Math.round(c*100),h=Ei(t.windowMs),g=()=>a(t),_=Zr(l);return e(`div`,{className:`relative flex flex-col rounded-md border bg-surface overflow-hidden ${o?`border-primary ring-1 ring-primary`:`border-border`}`,children:[e(`div`,{className:`aspect-video relative overflow-hidden bg-surface-hover`,children:[f.src?i(`img`,{src:f.src,alt:d(`detectionIntelligence.eventCard.eventFrom`,`Event from {{cameraName}}`,{cameraName:n}),onClick:g,className:`h-full w-full cursor-zoom-in object-cover`}):i(H,{variant:`unstyled`,type:`button`,onClick:g,className:`flex h-full w-full flex-col items-center justify-center gap-1 bg-surface-hover text-foreground-subtle`,title:f.failed?d(`detectionIntelligence.eventCard.keyEventMediaUnavailable`,`Key-event media unavailable`):d(`detectionIntelligence.eventCard.noKeyEventMedia`,`No key-event media`),children:i(O,{className:`h-6 w-6 opacity-60`})}),s&&i(H,{variant:`unstyled`,type:`button`,onClick:e=>{e.stopPropagation(),s(hr(t.deviceId,t.trackId))},className:`absolute left-0 top-0 z-10 rounded-br-md bg-black/50 p-1.5 text-white hover:bg-black/70`,"aria-label":o?d(`detectionIntelligence.eventCard.deselect`,`Deselect`):d(`detectionIntelligence.eventCard.select`,`Select`),children:o?i(W,{className:`h-4 w-4 text-primary`}):i(C,{className:`h-4 w-4`})}),m!==void 0&&e(`span`,{className:`absolute left-1 top-1 z-10 rounded bg-primary/85 px-1.5 py-0.5 text-[10px] font-semibold text-white tabular-nums`,title:d(`detectionIntelligence.eventCard.clipSemanticMatchScore`,`CLIP semantic-match score`),children:[String(m),`%`]}),p>0&&i(`span`,{className:`absolute right-1 top-1 z-10 rounded bg-black/60 px-1.5 py-0.5 text-[10px] font-semibold text-white`,children:String(p)}),_!==null&&i(`span`,{className:`absolute bottom-1 right-1 z-10 rounded px-1.5 py-0.5 text-[10px] font-semibold text-white ${_.tone===`warning`?`bg-warning/90`:`bg-black/70`}`,title:_.title,children:_.label}),(t.markForTrain===!0||t.retrainStatus===`trained`||t.debug===!0||t.favourited===!0)&&e(`span`,{className:`absolute bottom-1 left-1 z-10 flex gap-1`,children:[t.markForTrain===!0&&i(`span`,{className:`rounded bg-primary/85 p-0.5 text-white`,title:d(`detectionIntelligence.eventCard.markedForTraining`,`Marked for training`),"aria-label":d(`detectionIntelligence.eventCard.markedForTraining`,`Marked for training`),children:i(x,{className:`h-3 w-3`})}),t.retrainStatus===`trained`&&t.markForTrain!==!0&&i(`span`,{className:`rounded bg-success/85 p-0.5 text-white`,title:d(`detectionIntelligence.eventCard.trainingComplete`,`Training complete`),"aria-label":d(`detectionIntelligence.eventCard.trainingComplete`,`Training complete`),"data-testid":`retrain-status-trained`,children:i(b,{className:`h-3 w-3`})}),t.debug===!0&&i(`span`,{className:`rounded bg-black/70 p-0.5 text-white`,title:d(`detectionIntelligence.eventCard.flaggedForDebug`,`Flagged for debug`),"aria-label":d(`detectionIntelligence.eventCard.flaggedForDebug`,`Flagged for debug`),children:i(pe,{className:`h-3 w-3`})}),t.favourited===!0&&i(`span`,{className:`rounded bg-primary/85 p-0.5 text-white`,title:d(`detectionIntelligence.eventCard.favourited`,`Favourited`),"aria-label":d(`detectionIntelligence.eventCard.favourited`,`Favourited`),children:i(y,{className:`h-3 w-3`})})]})]}),e(H,{variant:`unstyled`,type:`button`,onClick:g,className:`min-w-0 px-2 py-1.5 text-left space-y-0.5`,children:[e(`p`,{className:`text-[11px] font-medium text-foreground truncate`,title:t.className,children:[t.className,ur(t)?e(`span`,{className:`text-foreground-subtle`,children:[` · `,ur(t)]}):null]}),i(`p`,{className:`text-[10px] text-foreground-subtle truncate`,title:n,children:n}),e(`div`,{className:`flex items-center justify-between gap-2`,children:[i(`span`,{className:`text-[10px] text-foreground-subtle truncate`,children:gn(t.timestamp,r)}),h&&i(`span`,{className:`text-[10px] text-foreground-subtle shrink-0`,children:h})]})]}),u!==void 0&&i(`div`,{className:`px-2 pb-1.5`,children:u})]})}function Oi({row:t,onSeek:n,onOpenDetail:r,size:a=0,onToggleSelect:o,selected:s=!1}){let{t:c}=J(),l=Dn(t.mediaId===void 0?On(`track`,t.trackId):kn(t.mediaId)),u=Math.round(t.importance*100),d=ur(t),f=new Date(t.timestamp).toLocaleTimeString();return e(`div`,{className:`flex w-full items-center gap-2 rounded-md border bg-surface hover:bg-surface-hover ${s?`border-primary ring-1 ring-primary`:`border-border`}`,"data-testid":`event-row`,children:[o&&i(le,{className:`ml-2 shrink-0`,checked:s,onChange:()=>o(hr(t.deviceId,t.trackId)),"aria-label":c(`detectionIntelligence.eventRow.select`,`Select {{className}} at {{time}}`,{className:t.className,time:f})}),i(H,{variant:`unstyled`,type:`button`,onClick:()=>r(t),className:`aspect-video ${Mr[a]} shrink-0 overflow-hidden rounded-l-md bg-surface-hover`,"aria-label":c(`detectionIntelligence.eventRow.openDetail`,`Open event details`),children:l.src?i(`img`,{src:l.src,alt:``,className:`h-full w-full object-cover`}):i(`span`,{className:`flex h-full w-full items-center justify-center text-foreground-subtle`,children:i(O,{className:`h-4 w-4 opacity-60`})})}),e(H,{variant:`unstyled`,type:`button`,onClick:()=>n(t.timestamp),className:`flex min-w-0 flex-1 items-center gap-2 py-1 pr-2 text-left`,"aria-label":c(`detectionIntelligence.eventRow.seek`,`Play {{className}} at {{time}}`,{className:t.className,time:f}),children:[e(`span`,{className:`min-w-0 flex-1`,children:[e(`span`,{className:`block truncate text-[12px] font-medium text-foreground`,children:[t.className,d?e(`span`,{className:`text-foreground-subtle`,children:[` · `,d]}):null]}),i(`span`,{className:`block text-[11px] tabular-nums text-foreground-subtle`,children:f})]}),u>0&&i(`span`,{className:`shrink-0 rounded bg-surface-hover px-1.5 py-0.5 text-[10px] font-semibold tabular-nums text-foreground-muted`,children:String(u)})]}),e(`div`,{className:`flex shrink-0 items-center gap-0.5 pr-1`,children:[i(ki,{icon:re,label:c(`detectionIntelligence.eventRow.details`,`Details`),onClick:()=>r(t)}),i(ki,{icon:E,label:c(`detectionIntelligence.eventRow.play`,`Play`),onClick:()=>n(t.timestamp)})]})]})}function ki({icon:t,label:n,onClick:r}){return e(ft,{children:[i(It,{children:i(kt,{variant:`ghost`,size:`sm`,icon:t,"aria-label":n,onClick:r})}),i(_t,{children:n})]})}var Ai=120*1e3;function ji(e,t,n=Ai){let r=[...e].sort((e,n)=>t(n)-t(e)),i=[];for(let e of r){let r=i[i.length-1],a=t(e);r!==void 0&&r.fromMs-a<=n?(r.events.push(e),r.fromMs=a):i.push({fromMs:a,toMs:a,events:[e]})}return i}c();function Mi(){let[e,n]=o(!1),i=t(null),[s,c]=o(0),l=r(e=>{i.current!==e&&(i.current=e,c(e=>e+1))},[]);return a(()=>{let e=i.current;if(!e||typeof IntersectionObserver>`u`){n(!1);return}let t=new IntersectionObserver(e=>{let t=e[e.length-1];t&&n(!t.isIntersecting)},{rootMargin:`64px 0px 0px 0px`,threshold:0});return t.observe(e),()=>t.disconnect()},[s]),{ref:l,scrolledPast:e}}c();var Ni=[`events-feed`],Pi=60,Fi=[{value:`importance`,labelKey:`detectionIntelligence.eventsSection.sortImportance`,icon:Ce},{value:`time`,labelKey:`detectionIntelligence.eventsSection.sortRecent`,icon:ne}];function Ii({deviceId:t,onSeek:r,window:s,rowFilter:c,onListChange:d,layout:f=`cards`,toolbarTarget:p}={}){let{t:m}=J(),h=l(),_=oe(),v=L(),[y,b]=o(xn),[x,S]=o(new Set),[C,w]=o(new Set),[E,ee]=o(new Set),[D,O]=Be({storageKey:jr,options:Ar,defaultSize:0}),k=Nr(D),[A,j]=o(0),[N,P]=o(`time`),[I,R]=o(new Set),[te,z]=o(null),[ne,re]=o(()=>Date.now());a(()=>{let e=setInterval(()=>re(Date.now()),6e4);return()=>clearInterval(e)},[]);let B=n(()=>_r({fromMs:y.fromMs,toMs:y.toMs},ne),[y.fromMs,y.toMs,ne]),ie=s?.since??B.since,ae=s?.until??B.until,se=Mi(),{pending:ue,refreshNow:de}=Dr({paused:te!==null||I.size>0||se.scrolledPast}),{data:fe=[]}=Ue({isCamera:!0,projection:`slim`}),pe=n(()=>t===void 0?fe:fe.filter(e=>e.id===t),[fe,t]),me=n(()=>pe.map(e=>e.id),[pe]),{data:he,isLoading:ge}=Ut({deviceIds:me},{enabled:me.length>0,staleTime:5*6e4}),_e=n(()=>zr(he??[],x),[he,x]),ve=xr(),ye=ve.isPending,{rows:U,isLoading:be}=wr({deviceIds:me,since:ie,until:ae,minImportance:A>0?A:void 0,classFilter:C.size===1?[...C][0]:void 0}),xe=n(()=>{let e=new Map;for(let t of pe??[])e.set(t.id,t.name);return e},[pe]),Ce=e=>xe.get(e)??m(`detectionIntelligence.cameraFallback`,{id:String(e)}),we=n(()=>wn(U).map(e=>({id:e,name:Ce(e)})).sort((e,t)=>e.name.localeCompare(t.name)),[U,xe]),W=n(()=>pr(mr(U,{cameras:x,classes:C,minImportance:A}).filter(e=>!E.has(e.className)&&(c===void 0||c(e))),N),[U,x,C,E,A,N,c]),G=n(()=>U.map(e=>e.className),[U]),Te=C.size>0||E.size>0||A>0;a(()=>{d?.({rows:W,narrowed:Te})},[W,Te,d]);let Ee=bn(W,Pi,n(()=>JSON.stringify([[...x].sort((e,t)=>e-t),[...C].sort(),[...E].sort(),A,N,ie,ae]),[x,C,E,A,N,ie,ae])),De=()=>{h.invalidateQueries({queryKey:Ni})},Oe=()=>R(new Set),ke=W.map(e=>hr(e.deviceId,e.trackId)),Ae=ke.length>0&&ke.every(e=>I.has(e)),je=()=>R(Ae?new Set:new Set(ke));function Me(e){R(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}function Ne(){if(I.size===0||!vr)return;let e=gr(U,I),t=[...e.values()].reduce((e,t)=>e+t.length,0);t!==0&&(async()=>{await v({title:m(`detectionIntelligence.eventsSection.deleteTitle`,{count:t}),message:m(`detectionIntelligence.eventsSection.deleteMessage`,{count:t}),confirmLabel:m(`common.delete`,`Delete`),variant:`danger`})&&Pe(e)})()}function Pe(e){let t=[...e];Promise.allSettled(t.map(([e,t])=>ve.mutateAsync({deviceId:e,trackIds:t}))).then(e=>{De();let n=[],r=new Set;if(e.forEach((e,i)=>{let a=t[i];if(!a)return;let[o,s]=a;if(e.status===`fulfilled`)for(let e of s)r.add(hr(o,e));else n.push(o)}),R(e=>{let t=new Set(e);for(let e of r)t.delete(e);return t}),n.length>0){let e=n.map(e=>Ce(e)).join(`, `);_({title:m(`detectionIntelligence.eventsSection.someTracksWereNotDeleted`,`Some tracks were not deleted`),message:m(`detectionIntelligence.eventsSection.failedToDeleteTracksOn`,`Failed to delete tracks on: {{names}}. They remain selected — retry, or check the server logs.`,{names:e}),variant:`danger`})}})}let Fe=n(()=>ji(Ee.pageItems,e=>e.timestamp),[Ee.pageItems]),Ie=W.length!==U.length,Le=t=>i(Di,{row:t,cameraName:Ce(t.deviceId),nowMs:ne,selected:I.has(hr(t.deviceId,t.trackId)),onToggleSelect:Me,onOpenDetail:z,footer:r===void 0?void 0:e(H,{variant:`ghost`,onClick:()=>r(t.timestamp),children:[i(Se,{className:`h-3.5 w-3.5`}),m(`detectionIntelligence.eventsSection.showInReview`,`Show in Review`)]})},hr(t.deviceId,t.trackId)),Re=f===`rows`&&r!==void 0,ze=e=>Re?i(Oi,{row:e,onSeek:r,onOpenDetail:z,size:k,selected:I.has(hr(e.deviceId,e.trackId)),onToggleSelect:Me},hr(e.deviceId,e.trackId)):Le(e),Ve=e=>Re?i(`div`,{className:`flex flex-col gap-1`,"data-testid":`events-grid`,children:e.map(ze)}):i(Xe,{status:`ready`,testId:`events-grid`,children:e.map(ze)}),He=e(`div`,{className:p===void 0?`flex flex-wrap items-center gap-1.5`:`contents`,children:[s===void 0&&i(hn,{onChange:b}),t===void 0&&i(Sn,{cameras:we,selected:x,onChange:S}),i(Pr,{groups:_e,selected:C,onChange:w,loading:ge}),Re&&i(kr,{classes:G,hidden:E,onChange:ee}),e(`label`,{className:`flex items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[i(`span`,{children:m(`detectionIntelligence.eventsSection.minScore`,`Min score`)}),i(T,{min:0,max:1,step:.05,value:A,onChange:e=>j(Number(e.target.value)),className:`h-1 w-24 cursor-pointer accent-primary`,"aria-label":m(`detectionIntelligence.eventsSection.minimumImportance`,`Minimum importance`)}),i(`span`,{className:`w-6 tabular-nums text-foreground`,children:Math.round(A*100)})]}),i(`div`,{className:`flex items-center gap-1 rounded-md border border-border p-0.5`,children:Fi.map(t=>{let n=t.icon;return e(`button`,{type:`button`,onClick:()=>P(t.value),className:`flex items-center gap-1 rounded px-2 py-1 text-[11px] transition-colors ${N===t.value?`bg-primary/12 text-primary font-medium`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:[i(n,{className:`h-3.5 w-3.5`}),` `,m(t.labelKey)]},t.value)})}),!be&&i(`span`,{className:`ml-auto text-[10px] text-foreground-subtle`,children:Ie?m(`detectionIntelligence.eventsSection.ofEvents`,`{{value1}} of {{value2}} events`,{value1:String(W.length),value2:String(U.length)}):m(`detectionIntelligence.eventsSection.eventCount`,{count:W.length})})]});return e(`div`,{className:`relative space-y-3`,children:[p===void 0?He:p!==null&&$t(He,p),I.size>0&&e(`div`,{className:`flex flex-wrap items-center gap-2 rounded-md border border-primary/40 bg-primary/8 px-3 py-2`,children:[i(`span`,{className:`text-xs font-medium text-foreground`,children:m(`common.selectedCount`,{count:I.size})}),e(`div`,{className:`ml-auto flex flex-wrap items-center gap-1.5`,children:[i(`span`,{title:vr?void 0:`Track deletion arrives with the next server update`,children:e(H,{variant:`secondary`,onClick:Ne,disabled:!vr||ye,children:[ye?i(V,{className:`h-3.5 w-3.5 animate-spin`}):i(ce,{className:`h-3.5 w-3.5`}),` `,m(`common.delete`,`Delete`)]})}),i(H,{variant:`ghost`,onClick:Oe,disabled:ye,children:i(g,{className:`h-3.5 w-3.5`})})]})]}),ue&&i(`div`,{className:`sticky top-2 z-20 flex justify-center`,children:i(`button`,{type:`button`,onClick:de,className:`rounded-full border border-primary/40 bg-surface px-3 py-1 text-[11px] font-medium text-primary shadow-sm hover:bg-primary/10`,children:m(`detectionIntelligence.eventsSection.newEventsRefresh`,`New events — refresh`)})}),be?i(Xe,{status:`pending`,pendingMessage:`Loading events…`,testId:`events-grid`}):W.length===0?i(qe,{icon:M,title:Ie?m(`detectionIntelligence.eventsSection.nothingMatchesTheFilter`,`Nothing matches the filter`):m(`detectionIntelligence.eventsSection.noKeyEventsInThis`,`No key events in this window`),description:Ie?m(`detectionIntelligence.eventsSection.widenTheDateRangeClear`,`Widen the date range, clear cameras or kinds, or lower the min score.`):m(`detectionIntelligence.eventsSection.capturedTracksAppearHereWhen`,`Captured tracks appear here when the pipeline scores a key event.`)}):e(u,{children:[i(`div`,{ref:se.ref,"aria-hidden":!0,className:`h-0`}),Re&&e(`div`,{className:`flex flex-wrap items-center gap-3`,children:[e(`label`,{className:`flex items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[i(le,{checked:Ae,onChange:je,"data-testid":`event-rows-select-all`}),i(`span`,{children:m(`detectionIntelligence.eventsSection.selectAll`,`Select all ({{count}})`,{count:W.length})})]}),e(`label`,{className:`flex items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[i(F,{className:`h-3.5 w-3.5`}),i(`span`,{children:m(`detectionIntelligence.eventsSection.rowSize`,`Size`)}),i(T,{min:0,max:Ar.length-1,step:1,value:k,onChange:e=>O(Number(e.target.value)),className:`h-1 w-24 cursor-pointer accent-primary`,"data-testid":`event-row-size`,"aria-label":m(`detectionIntelligence.eventsSection.rowSizeLabel`,`Event row size`)})]})]}),!Re&&t!==void 0&&N===`time`?Fe.map(t=>e(`div`,{className:`space-y-1.5`,children:[i(`div`,{className:`text-[11px] font-medium text-foreground-subtle`,children:m(`detectionIntelligence.eventsSection.clusterHeading`,{count:t.events.length,time:new Date(t.toMs).toLocaleString()})}),Ve(t.events)]},t.toMs)):Ve(Ee.pageItems),i(Cn,{currentPage:Ee.page,totalItems:Ee.totalItems,pageSize:Ee.pageSize,onPageChange:Ee.setPage,itemNoun:`events`})]}),te&&i(Ti,{row:te,cameraName:Ce(te.deviceId),deleteAvailable:vr,onClose:()=>z(null),onDeleted:()=>{De(),z(null)},onFlagsChanged:e=>{z(t=>t&&t.trackId===e.trackId?{...t,markForTrain:e.markForTrain,debug:e.debug,favourited:e.favourited}:t)}})]})}var Li={zone:null,identity:`any`,debug:!1};function Ri(e){return new Map(e.map(e=>[e.trackId,e]))}function zi(e){let t=new Set;for(let n of e)for(let e of n.zoneNames??[])t.add(e);return[...t].sort((e,t)=>e.localeCompare(t))}function Bi(e,t){if(t===`any`)return!0;let n=e.classes??[];return t===`face`?e.hasFace===!0||n.includes(`face`):n.includes(`plate`)}function Vi(e,t){return n=>{if(e.debug&&n.debug!==!0)return!1;if(e.zone===null&&e.identity===`any`)return!0;let r=t.get(n.trackId);return r===void 0?!0:e.zone!==null&&!(r.zoneNames??[]).includes(e.zone)?!1:Bi(r,e.identity)}}function Hi(e){return e.zone!==null||e.identity!==`any`}function Ui(e,t,n){return Hi(t)?e.filter(e=>!n.has(e.trackId)).length:0}function Wi(e){return e.map(e=>({atMs:e.timestamp,kind:e.className===`audio`?`audio`:`object`}))}var Gi=`/addon/training`;function Ki(){let{t}=J(),n=tn();return e(Et,{className:`flex flex-col gap-3 border-border bg-surface p-3 sm:flex-row sm:items-center sm:gap-4`,"data-testid":`events-feed-retrain-cta`,children:[e(`div`,{className:`flex min-w-0 flex-1 items-start gap-2.5`,children:[i(x,{className:`mt-0.5 h-4 w-4 shrink-0 text-primary`,"aria-hidden":!0}),e(`div`,{className:`min-w-0 space-y-0.5`,children:[i(`p`,{className:`text-xs font-medium text-foreground`,children:t(`detectionIntelligence.retrainTabCallout.trainingFromThisFeed`,`Training from this feed`)}),i(`p`,{className:`${fe} leading-relaxed`,children:t(`detectionIntelligence.retrainTabCallout.markATrackWithThe`,`Mark a track with the graduation-cap control on its card. On Training you correct frames, build collections, and start cloud fine-tunes.`)})]})]}),i(H,{variant:`outline`,size:`sm`,className:`shrink-0 self-start sm:self-center`,onClick:()=>n(Gi),children:t(`detectionIntelligence.retrainTabCallout.openTraining`,`Open Training`)})]})}c();var qi=[he.Camera],Ji=50,Yi=350,Xi=[{value:`loose`,labelKey:`detectionIntelligence.semanticEventSearch.looseLabel`,titleKey:`detectionIntelligence.semanticEventSearch.looseTitle`},{value:`balanced`,labelKey:`detectionIntelligence.semanticEventSearch.balancedLabel`,titleKey:`detectionIntelligence.semanticEventSearch.balancedTitle`},{value:`strict`,labelKey:`detectionIntelligence.semanticEventSearch.strictLabel`,titleKey:`detectionIntelligence.semanticEventSearch.strictTitle`}];function Zi(e){let t=String(e.id);return{id:t,trackId:e.trackId??t,deviceId:e.deviceId,timestamp:e.timestamp,className:e.className,label:e.label,subLabel:e.subLabel,importance:e.importance??0,bestEventId:t,mediaId:e.keyFrameMediaId??e.mediaId,windowMs:void 0}}function Qi({deviceId:r}){let s=t(null);f(s);let{t:c}=J(),[l,u]=o(``),[d,p]=o(`loose`),[m,h]=o(null),[_,v]=o(null),y=r??_,[b,x]=o(null),S=Rt(l,Yi).trim(),C=S.length>0,[w,T]=o(()=>Date.now());a(()=>{let e=setInterval(()=>T(Date.now()),6e4);return()=>clearInterval(e)},[]);let{data:E=[]}=Ue({isCamera:!0,projection:`slim`}),ee=n(()=>{let e=new Map;for(let t of E)e.set(t.id,t.name);return e},[E]),D=e=>ee.get(e)??c(`detectionIntelligence.cameraFallback`,{id:String(e)}),O=n(()=>E.map(e=>e.id),[E]),{data:k}=Ut({deviceIds:O},{enabled:O.length>0,staleTime:5*6e4}),A=n(()=>Rr(k??[],new Set(y===null?[]:[y])),[k,y]);a(()=>{m!==null&&(A.some(e=>e.kind===m)||h(null))},[A,m]);let{data:j,isFetching:M,isError:N,error:P}=Bt({text:S,strictness:d,limit:Ji,classFilter:m??void 0,deviceId:y??void 0},{enabled:C}),F=n(()=>[...j??[]].sort((e,t)=>t.score-e.score).map(e=>({...Zi(e),score:e.score})),[j]);function I(e){h(t=>t===e?null:e)}return e(`div`,{className:`space-y-3`,children:[e(`div`,{className:`rounded-lg border border-border bg-surface p-3 space-y-3`,children:[e(`div`,{className:`flex flex-wrap items-center gap-2`,children:[e(`div`,{className:`relative min-w-[16rem] flex-1`,children:[i(ie,{className:`pointer-events-none absolute left-2.5 top-1/2 h-4 w-4 -translate-y-1/2 text-foreground-subtle`}),i(ue,{ref:s,type:`text`,value:l,onChange:e=>u(e.target.value),placeholder:c(`detectionIntelligence.semanticEventSearch.semanticSearchDescribeWhatYou`,`Semantic search — describe what you're looking for…`),className:`h-9 w-full rounded-md border border-border bg-background pl-8 pr-8 text-sm text-foreground placeholder:text-foreground-subtle focus:border-primary focus:outline-none focus:ring-1 focus:ring-primary`,"aria-label":c(`detectionIntelligence.semanticEventSearch.semanticEventSearch`,`Semantic event search`)}),l&&i(`button`,{type:`button`,onClick:()=>u(``),className:`absolute right-2 top-1/2 -translate-y-1/2 rounded p-0.5 text-foreground-subtle hover:bg-surface-hover hover:text-foreground`,"aria-label":c(`detectionIntelligence.semanticEventSearch.clearSearch`,`Clear search`),children:i(g,{className:`h-3.5 w-3.5`})})]}),M&&C&&i(V,{className:`h-4 w-4 shrink-0 animate-spin text-foreground-subtle`})]}),e(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2`,children:[i(`div`,{className:`flex items-center gap-1`,children:A.map(e=>i(`button`,{type:`button`,onClick:()=>I(e.kind),className:`rounded-md px-2.5 py-1 text-xs transition-colors ${m===e.kind?`bg-primary/12 text-primary font-medium`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:ct(e)},e.kind))}),r===void 0&&e(`div`,{className:`flex items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[i(`span`,{children:c(`detectionIntelligence.semanticEventSearch.camera`,`Camera`)}),i(Ve,{pick:`device`,noun:`camera`,fixedTypes:qi,recentKey:`semantic-event-search-camera`,placeholder:c(`detectionIntelligence.semanticEventSearch.all`,`All`),value:y===null?null:{deviceId:y},onChange:e=>v(e===null?null:e.deviceId)})]}),e(`div`,{className:`flex items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[i(`span`,{children:c(`detectionIntelligence.semanticEventSearch.match`,`Match`)}),i(`div`,{className:`flex items-center gap-1 rounded-md border border-border p-0.5`,children:Xi.map(e=>i(`button`,{type:`button`,onClick:()=>p(e.value),className:`rounded px-2 py-1 text-[11px] transition-colors ${d===e.value?`bg-primary/12 text-primary font-medium`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,title:c(e.titleKey),children:c(e.labelKey)},e.value))})]}),C&&!M&&!N&&i(`span`,{className:`ml-auto text-[10px] text-foreground-subtle`,children:c(`common.matches`,{count:F.length})})]})]}),C&&e(`div`,{className:`space-y-3`,children:[N&&e(`p`,{className:`py-4 text-xs text-danger`,children:[c(`detectionIntelligence.semanticEventSearch.searchFailed`,`Search failed:`),` `,P instanceof Error?P.message:c(`detectionIntelligence.semanticEventSearch.unknownError`,`unknown error`),`. Check that the CLIP embedding step is enabled.`]}),!N&&M&&F.length===0&&i(Xe,{status:`pending`,pendingMessage:`Searching…`,testId:`semantic-events-grid`}),!N&&!M&&F.length===0&&i(Xe,{status:`empty`,emptyMessage:c(`detectionIntelligence.semanticEventSearch.noSemanticMatchesForTry`,`No semantic matches for “{{debounced}}”. Try a looser match threshold or a different phrasing.`,{debounced:S}),testId:`semantic-events-grid`}),!N&&F.length>0&&i(Xe,{status:`ready`,testId:`semantic-events-grid`,children:F.map(e=>i(Di,{row:e,cameraName:D(e.deviceId),nowMs:w,score:e.score,onOpenDetail:x},e.id))})]}),b&&i(Ti,{row:b,cameraName:D(b.deviceId),deleteAvailable:vr,onClose:()=>x(null),onDeleted:()=>x(null)})]})}c();function $i(e,t){let n=Math.max(0,Math.round((e-t)/6e4));if(n<1)return q.t(`helpers.relativeTime.justNow`);if(n<60)return`${String(n)}m`;let r=Math.floor(n/60);return`${String(r)}h ${String(n%60)}m`}function ea({row:t,cameraName:n,nowMs:r}){let{t:a}=J(),o=Dn(t.keyFrameMediaId===void 0?void 0:kn(t.keyFrameMediaId));return e(`div`,{className:`flex flex-col overflow-hidden rounded-md border border-border bg-surface`,children:[e(`div`,{className:`relative aspect-video overflow-hidden bg-surface-hover`,children:[o.src?i(`img`,{src:o.src,alt:a(`detectionIntelligence.stationarySection.parkedOn`,`Parked {{className}} on {{cameraName}}`,{className:t.className,cameraName:n}),className:`h-full w-full object-cover`}):i(`div`,{className:`flex h-full w-full items-center justify-center text-foreground-subtle`,children:i(m,{className:`h-6 w-6`})}),i(`span`,{className:`absolute left-1 top-1 rounded bg-black/60 px-1.5 py-0.5 text-[10px] font-medium capitalize text-white`,children:t.label??t.className})]}),e(`div`,{className:`flex flex-col gap-0.5 p-1.5`,children:[i(`span`,{className:`truncate text-[11px] text-foreground`,children:n}),i(`span`,{className:`text-[10px] text-foreground-subtle`,children:a(`common.parkedSince`,{since:$i(r,t.becameStationaryAt)})})]})]})}function ta({deviceId:t}={}){let{t:r}=J(),[a,s]=o(!1),c=Date.now(),{data:l=[]}=Ue({isCamera:!0,projection:`slim`}),u=n(()=>t===void 0?l.map(e=>e.id):[t],[l,t]),d=n(()=>{let e=new Map;for(let t of l)e.set(t.id,t.name);return e},[l]),{rows:f,unreadableCount:h}=cn(u);return f.length===0&&h===0?null:e(`div`,{className:`rounded-md border border-border bg-surface/40`,children:[e(H,{variant:`unstyled`,type:`button`,onClick:()=>s(e=>!e),className:`flex w-full items-center gap-2 px-3 py-2 text-left`,children:[i(a?be:p,{className:`h-4 w-4 text-foreground-subtle`}),i(m,{className:`h-4 w-4 text-foreground-subtle`}),i(`span`,{className:`text-sm font-semibold text-foreground`,children:r(`detectionIntelligence.stationarySection.stationary`,`Stationary`)}),i(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-[10px] font-medium text-foreground-subtle`,children:f.length}),i(`span`,{className:`ml-2 text-[11px] text-foreground-subtle`,children:r(`detectionIntelligence.stationarySection.parkedObjectsKeptOutOf`,`Parked objects — kept out of the event feed`)}),h>0?i(`span`,{className:`ml-2 text-[11px] text-warning`,children:r(`detectionIntelligence.stationarySection.unreadable`,{count:h})}):null]}),a&&i(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(9rem,1fr))] gap-2 p-3 pt-0`,children:f.map(e=>i(ea,{row:e,cameraName:d.get(e.deviceId)??`Camera #${String(e.deviceId)}`,nowMs:c},e.id))})]})}var na={status:`debug.tape.status`,promote:`debug.tape.promote`,list:`debug.tape.list`,tracks:`debug.tape.tracks`,review:`debug.tape.review`,release:`debug.tape.release`,remove:`debug.tape.delete`},ra={setRelation:`debug.gt.setRelation`,setPurity:`debug.gt.setPurity`,list:`debug.gt.list`},ia=j(`/addon/pipeline-analytics/tape-export`),aa=10*6e4;function oa(e){return`${ia}?tapeId=${encodeURIComponent(e)}`}var sa=`The server answered in a shape this build does not understand.`;function ca(e){return e instanceof Error?e.message:q.t(`helpers.eventsDebugTapes.actionFailed`)}function Z(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Q(e,t){let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:null}function la(e,t){if(!(t in e))return;let n=e[t];return n===null?null:typeof n==`number`&&Number.isFinite(n)?n:void 0}function $(e,t){let n=e[t];return typeof n==`string`?n:null}function ua(e,t){let n=e[t];return typeof n==`boolean`?n:null}function da(e,t){if(!Array.isArray(e))return null;let n=[];for(let r of e){let e=t(r);if(e===null)return null;n.push(e)}return n}function fa(e){return e===`off`||e===`recording`||e===`refused`||e===`failing`||e===`unknown`}function pa(e){if(!Z(e))return null;let t=Q(e,`deviceId`),n=e.state,r=Q(e,`gapsSinceArmed`),i=la(e,`segmentsHeld`),a=la(e,`bytesLastHour`),o=la(e,`bytesHeld`);if(t===null||!fa(n)||r===null||i===void 0||a===void 0||o===void 0)return null;let s=$(e,`reason`),c=Q(e,`segmentOriginMs`),l=Q(e,`framesPerMin`),u=Q(e,`heldFromMs`),d=Q(e,`heldToMs`),f=$(e,`shelfError`);return{deviceId:t,state:n,gapsSinceArmed:r,segmentsHeld:i,bytesLastHour:a,bytesHeld:o,...s===null?{}:{reason:s},...c===null?{}:{segmentOriginMs:c},...l===null?{}:{framesPerMin:l},...u===null?{}:{heldFromMs:u},...d===null?{}:{heldToMs:d},...f===null?{}:{shelfError:f}}}function ma(e){return Z(e)?da(e.cameras,pa):null}function ha(e){if(!Z(e))return null;let t=$(e,`id`),n=Q(e,`deviceId`),r=$(e,`scenario`),i=e.lighting,a=Q(e,`fromMs`),o=Q(e,`toMs`),s=e.state,c=Q(e,`frames`),l=Q(e,`gaps`),u=Q(e,`bytes`),d=ua(e,`reviewed`),f=ua(e,`released`),p=da(e.tracks,e=>typeof e==`string`?e:null),m=Q(e,`tracksStillStored`);return t===null||n===null||r===null||i!==`day`&&i!==`ir`||a===null||o===null||s!==`complete`&&s!==`incomplete`||c===null||l===null||u===null||d===null||f===null||p===null||m===null?null:{id:t,deviceId:n,scenario:r,note:$(e,`note`),lighting:i,fromMs:a,toMs:o,state:s,frames:c,gaps:l,bytes:u,reviewed:d,released:f,tracks:p,tracksStillStored:m}}function ga(e){return Z(e)?da(e.tapes,ha):null}function _a(e){if(!Z(e))return null;let t=$(e,`trackId`),n=Q(e,`firstT`),r=Q(e,`lastT`),i=Q(e,`boundFrames`),a=$(e,`cls`),o=ua(e,`stillStored`);return t===null||n===null||r===null||i===null||a===null||o===null?null:{trackId:t,firstT:n,lastT:r,boundFrames:i,cls:a,stillStored:o}}function va(e){if(!Z(e))return null;let t=$(e,`tapeId`),n=Q(e,`deviceId`),r=Q(e,`fromMs`),i=Q(e,`toMs`),a=ua(e,`reviewed`),o=da(e.lanes,_a);return t===null||n===null||r===null||i===null||a===null||o===null?null:{tapeId:t,deviceId:n,fromMs:r,toMs:i,reviewed:a,lanes:o}}function ya(e){if(!Z(e))return null;if(e.ok===!1){let t=$(e,`reason`),n=$(e,`detail`);return t===null||n===null?null:{ok:!1,reason:t,detail:n}}if(e.ok!==!0)return null;let t=$(e,`tapeId`),n=e.state,r=Q(e,`frames`),i=Q(e,`gaps`),a=Q(e,`pinnedTracks`),o=Q(e,`bytes`);return t===null||n!==`complete`&&n!==`incomplete`||r===null||i===null||a===null||o===null?null:{ok:!0,tapeId:t,state:n,frames:r,gaps:i,pinnedTracks:a,bytes:o}}function ba(e){if(!Z(e))return null;let t=e.status;if(t===`released`){let n=Q(e,`unpinned`),r=ua(e,`pinsSettled`);return n===null||r===null?null:{status:t,unpinned:n,pinsSettled:r}}if(t===`already-released`||t===`not-found`)return{status:t};if(t===`unavailable`){let n=$(e,`reason`);return n===null?null:{status:t,reason:n}}return null}function xa(e){if(!Z(e))return null;let t=e.status;if(t===`deleted`||t===`pins-owed`||t===`not-found`)return{status:t};if(t===`unavailable`){let n=$(e,`reason`);return n===null?null:{status:t,reason:n}}return null}function Sa(e){switch(e.status){case`released`:case`deleted`:return null;case`already-released`:return q.t(`helpers.eventsDebugTapes.alreadyReleased`);case`not-found`:return q.t(`helpers.eventsDebugTapes.notFound`);case`pins-owed`:return q.t(`helpers.eventsDebugTapes.pinsOwed`);case`unavailable`:return q.t(`helpers.eventsDebugTapes.unavailable`,{reason:e.reason})}}function Ca(e){if(!Z(e))return null;let t=$(e,`leftTrackId`),n=$(e,`rightTrackId`),r=e.relation,i=e.presence;return t===null||n===null||r!==`same-subject`&&r!==`different-subjects`?null:{leftTrackId:t,rightTrackId:n,relation:r,presence:i===`continuous`?`continuous`:null}}function wa(e){if(!Z(e))return null;let t=$(e,`sourceTrackId`),n=e.purity;return t===null||n!==`mixed`&&n!==`not-a-subject`?null:{sourceTrackId:t,purity:n,switchAtMs:Q(e,`switchAtMs`)}}function Ta(e){if(!Z(e))return null;let t=da(e.relations,Ca),n=da(e.purities,wa),r=ua(e,`truncated`);return t===null||n===null||r===null?null:{relations:t,purities:n,truncated:r}}function Ea(e){if(!e.truncated)return null;let t=e.relations.length+e.purities.length;return q.t(`helpers.eventsDebugTapes.truncatedMarks`,{count:t})}function Da(e){return e.filter(e=>e.segmentsHeld===null||e.segmentsHeld>0).map(e=>({deviceId:e.deviceId,segmentsUnknown:e.segmentsHeld===null}))}function Oa(e){return e.slice(1).map((t,n)=>({trackId:e[n]??t,otherTrackId:t}))}function ka(e){return e.flatMap((t,n)=>e.slice(n+1).map(e=>({trackId:t,otherTrackId:e})))}function Aa(e,t){let n=[];for(let r of t.relations){let t=r.leftTrackId===e?r.rightTrackId:r.rightTrackId===e?r.leftTrackId:null;if(t===null)continue;let i=r.relation===`same-subject`?`same as`:`different from`;n.push(`${i} ${t}${r.presence===`continuous`?` (continuous)`:``}`)}for(let r of t.purities)r.sourceTrackId===e&&n.push(r.purity===`not-a-subject`?`not a subject`:r.switchAtMs===null?`mixed`:`mixed at switch`);return n}function ja(e){switch(e.state){case`off`:return q.t(`helpers.eventsDebugTapes.statusOff`);case`recording`:return q.t(`helpers.eventsDebugTapes.statusRecording`);case`refused`:return q.t(`helpers.eventsDebugTapes.statusRefused`,{reason:e.reason??q.t(`helpers.eventsDebugTapes.unknownReason`)});case`failing`:return q.t(`helpers.eventsDebugTapes.statusFailing`,{reason:e.reason??q.t(`helpers.eventsDebugTapes.unknownReason`)});case`unknown`:return q.t(`helpers.eventsDebugTapes.statusUnknown`,{reason:e.reason??q.t(`helpers.eventsDebugTapes.unknownReason`)})}}var Ma={"window-too-long":`A promoted window is at most 30 minutes.`,"window-in-future":`The window ends in the future.`,"window-not-recorded":`No segment covers that window — the camera was not recording then, or it is older than 24 h.`,"invalid-scenario":`The scenario must be a slug: lowercase letters, digits and dashes, 3–64 characters.`,"promotion-budget":`A promotion budget is full (60 tapes, 1 GiB, 3 000 pinned tracks). Release or delete a tape already committed as a case first.`,"empty-window":`No frame was recorded in that window.`,"shelf-unreadable":`The camera's recorded segments could not be listed, so the window cannot be proven whole.`,"not-post-processing-node":`This node does not post-process frames, so it records no tracking tapes.`,"artifacts-elsewhere":`The artifacts storage location is on another node; tapes are recorded only where it lives.`,"tapes-not-started":`The tape recorder has not started on this node (or failed to).`};function Na(e,t){let n=Ma[e]??`Refused (${e}).`;return t.length>0?`${n} ${t}`:n}function Pa(e){if(e.length===0)return null;let t=new Date(e).getTime();return Number.isFinite(t)?t:null}function Fa(e){return e<1024*1024?q.t(`helpers.eventsDebugTapes.sizeKb`,{value:(e/1024).toFixed(0)}):q.t(`helpers.eventsDebugTapes.sizeMb`,{value:(e/1024/1024).toFixed(1)})}function Ia(e){return e===null?`unknown`:Fa(e)}function La(e){return e===null?`unknown`:String(e)}function Ra(e,t){let n=t.trim();return e===404?q.t(`helpers.eventsDebugTapes.exportUnknown`):e===503?n.length>0?n:q.t(`helpers.eventsDebugTapes.tapesUnavailable`):e===500?n.length>0?n:q.t(`helpers.eventsDebugTapes.exportUnreadable`):q.t(`helpers.eventsDebugTapes.downloadFailed`,{status:e})}c();function za({cameras:t,call:n,onPromoted:r}){let{t:a}=J(),[s,c]=o(``),[l,u]=o(``),[d,f]=o(``),[p,m]=o(``),[h,g]=o(``),[_,v]=o(`auto`),[y,b]=o(!1),[x,S]=o(null),C=async()=>{let e=Number.parseInt(s===``?t[0]?.value??``:s,10),i=Pa(l),a=Pa(d);if(!Number.isFinite(e)||i===null||a===null){S(`Pick a camera and both ends of the window.`);return}b(!0),S(null);try{let t=ya(await n(na.promote,{deviceId:e,fromMs:i,toMs:a,scenario:p,...h.trim().length>0?{note:h.trim()}:{},..._===`day`||_===`ir`?{lighting:_}:{}}));t===null?S(sa):t.ok?(S(`Promoted ${t.tapeId}: ${String(t.frames)} frames, ${Fa(t.bytes)}, ${String(t.pinnedTracks)} tracks pinned`+(t.state===`incomplete`?` — incomplete (it has gaps) and cannot become a case.`:`.`)),r()):S(Na(t.reason,t.detail))}catch(e){S(ca(e))}finally{b(!1)}};return e(`div`,{className:`flex flex-wrap items-end gap-2 rounded-md border border-border px-3 py-2`,children:[i(`div`,{className:`w-40`,children:i(N,{value:s,options:[...t],onChange:e=>c(e.target.value),"aria-label":a(`eventsDebugTapesPromoteForm.camera`,`Camera`)})}),i(ue,{type:`datetime-local`,"aria-label":a(`eventsDebugTapesPromoteForm.from`,`From`),value:l,onChange:e=>u(e.target.value),className:`w-48`}),i(ue,{type:`datetime-local`,"aria-label":a(`eventsDebugTapesPromoteForm.to`,`To`),value:d,onChange:e=>f(e.target.value),className:`w-48`}),i(ue,{"aria-label":a(`eventsDebugTapesPromoteForm.scenario`,`Scenario`),placeholder:`101-door-groups`,value:p,onChange:e=>m(e.target.value),className:`w-44`}),i(ue,{"aria-label":a(`eventsDebugTapesPromoteForm.note`,`Note`),placeholder:a(`eventsDebugTapesPromoteForm.optionalNote`,`optional note`),value:h,onChange:e=>g(e.target.value),className:`w-52`}),i(`div`,{className:`w-28`,children:i(N,{value:_,"aria-label":a(`eventsDebugTapesPromoteForm.lighting`,`Lighting`),options:[{value:`auto`,label:a(`eventsDebugTapesPromoteForm.lightingAuto`,`Lighting: auto`)},{value:`day`,label:a(`eventsDebugTapes.dayMode`)},{value:`ir`,label:`IR`}],onChange:e=>v(e.target.value)})}),e(H,{onClick:()=>void C(),disabled:y||t.length===0,children:[y?i(V,{className:`h-3.5 w-3.5 animate-spin`}):null,` `,a(`eventsDebugTapes.promoteWindow`)]}),i(`p`,{className:`w-full text-xs text-foreground-subtle`,children:a(`eventsDebugTapesPromoteForm.aPromotedTapeMayBe`,`A promoted tape may be shared as a test case — keep the scenario slug and note free of names or other personal data.`)}),x!==null&&i(`p`,{className:`w-full text-xs text-foreground`,children:x})]})}var Ba=`pipeline-analytics`,Va=`debug.listTracks`,Ha=`debug.analyze`,Ua=j(`/addon/pipeline-analytics/debug-export`);function Wa(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ga(e,t){let n=e[t];return typeof n==`string`?n:null}function Ka(e,t){let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:null}function qa(e,t){let n=e[t];return typeof n==`boolean`?n:null}function Ja(e){return e===`error`||e===`warn`||e===`info`}function Ya(e){if(!Wa(e))return null;let t=Ga(e,`code`),n=Ga(e,`detail`),r=e.severity;return t===null||n===null||!Ja(r)?null:{code:t,severity:r,detail:n}}function Xa(e){if(!Wa(e))return null;let t=Ga(e,`trackId`),n=Ka(e,`deviceId`),r=Ga(e,`className`),i=Ka(e,`firstSeen`),a=Ka(e,`lastSeen`),o=Ka(e,`durationMs`),s=qa(e,`active`);if(t===null||n===null||r===null||i===null||a===null||o===null||s===null)return null;let c=Ga(e,`label`),l=Ga(e,`subLabel`),u=Ga(e,`previewMissReason`),d=qa(e,`markForTrain`),f=qa(e,`favourited`);return{trackId:t,deviceId:n,className:r,...c===null?{}:{label:c},...l===null?{}:{subLabel:l},firstSeen:i,lastSeen:a,durationMs:o,active:s,timestamp:i,windowMs:o,importance:Ka(e,`importance`)??0,bestEventId:Ga(e,`bestEventId`)??``,...d===null?{}:{markForTrain:d},...f===null?{}:{favourited:f},debug:!0,...u===null||u.length===0?{}:{previewMissReason:u}}}function Za(e){let t=Xa(e);if(t===null||!Wa(e))return null;let n=Ka(e,`mediaCount`),r=Ka(e,`eventCount`),i=Ka(e,`positionCount`);if(n===null||r===null||i===null)return null;let a=e.mediaKinds,o=e.findings;if(!Array.isArray(a)||!Array.isArray(o))return null;let s=a.filter(e=>typeof e==`string`),c=[];for(let e of o){let t=Ya(e);t!==null&&c.push(t)}let l=e.thumbnailProvenance;return{...t,mediaCount:n,mediaKinds:s,eventCount:r,positionCount:i,findings:c,...Yr(l)?{thumbnailProvenance:l}:{}}}function Qa(e){if(!Wa(e))return null;let t=qa(e,`truncated`),n=e.tracks;if(t===null||!Array.isArray(n))return null;let r=[];for(let e of n){let t=Xa(e);if(t===null)return null;r.push(t)}return{tracks:r,truncated:t}}function $a(e){if(!Wa(e))return null;let t=e.reports,n=e.vanished;if(!Array.isArray(t)||!Array.isArray(n))return null;let r=[];for(let e of t){let t=Za(e);if(t===null)return null;r.push(t)}return{reports:r,vanished:n.filter(e=>typeof e==`string`)}}var eo={MEDIA_EVICTED_OR_NEVER:`no media`,MISSING_KEYFRAME:`no keyframe`,MISSING_FIRSTFRAME:`no first frame`,MISSING_LASTFRAME:`no last frame`,MISSING_THUMBNAIL:`no thumbnail`,MISSING_BEST_CROP:`no crop`,SHORT_TRACK:`very short`,ZERO_EVENTS:`no events`,ZERO_POSITIONS:`no trajectory`,NO_PERIODIC_SNAPSHOTS:`no snapshots`,LASTFRAME_STALE:`stale last frame`,MEDIA_STOPPED_EARLY:`media stopped early`,NO_BEST_EVENT:`no best event`,LOW_BEST_SCORE:`low score`,UNSCORED_LABEL:`unscored label`,BEST_SHOT_STANDIN:`stand-in best shot`,BEST_SHOT_RASTER:`low-res best shot`};function to(e){return eo[e]??e}var no={error:0,warn:1,info:2};function ro(e){return e.toSorted((e,t)=>no[e.severity]-no[t.severity]||e.code.localeCompare(t.code))}function io(e){return e.length===0?Ua:`${Ua}?deviceIds=${e.join(`,`)}`}function ao(e){if(e<1e4)return`${ee(e/1e3,void 0)}s`;let t=Math.round(e/1e3);if(t<60)return`${String(t)}s`;let n=Math.floor(t/60);return`${String(n)}m ${String(t%60).padStart(2,`0`)}s`}function oo(e,t){return`${String(e)}:${t}`}function so(e,t){let n=[],r=new Set;for(let i of e){let e=oo(i.deviceId,i.trackId);!t.has(e)||r.has(e)||(r.add(e),n.push({deviceId:i.deviceId,trackId:i.trackId}))}return n}c();function co({tapeId:t,call:n,onClose:r,onChanged:a}){let{t:c}=J(),l=s({queryKey:[`events-debug`,`tapes`,`tracks`,t],queryFn:async()=>va(await n(na.tracks,{tapeId:t}))}),u=l.data??null,d=s({queryKey:[`events-debug`,`tapes`,`marks`,t],enabled:u!==null,queryFn:async()=>u===null?null:Ta(await n(ra.list,{deviceId:u.deviceId,since:u.fromMs-aa,until:u.toMs+aa,limit:5e3}))}),[f,p]=o([]),[m,h]=o(``),[g,_]=o(null),v=e=>p(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]),y=async e=>{_(null);try{for(let[t,r]of e)await n(t,r);p([]),await d.refetch(),a()}catch(e){_(ca(e))}};if(u===null)return l.isLoading?i(`p`,{className:`text-xs`,children:c(`eventsDebugTapesReview.loadingTheTape`,`Loading the tape…`)}):i(K,{message:sa});let b=u.deviceId,x=(e,t)=>y(e.map(e=>[ra.setRelation,{deviceId:b,...e,relation:t}])),S=e=>{let t=Number.parseFloat(m),n=e===`mixed`&&Number.isFinite(t)?u.fromMs+t*1e3:void 0;return y(f.map(t=>[ra.setPurity,{deviceId:b,trackId:t,purity:e,...n===void 0?{}:{switchAtMs:Math.round(n)}}]))},C=d.data==null?null:Ea(d.data);return e(`div`,{className:`space-y-2 rounded-md border border-primary/40 px-3 py-2`,children:[e(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[i(`span`,{className:`text-xs font-medium`,children:c(`eventsDebugTapes.reviewLanes`,{id:u.tapeId,count:u.lanes.length})}),i(H,{disabled:f.length<2,onClick:()=>void x(Oa(f),`same-subject`),children:c(`eventsDebugTapesReview.sameSubject`,`Same subject`)}),i(H,{variant:`secondary`,disabled:f.length<2,onClick:()=>void x(ka(f),`different-subjects`),children:c(`eventsDebugTapesReview.differentSubjects`,`Different subjects`)}),i(ue,{"aria-label":c(`eventsDebugTapesReview.changedAtSFromTape`,`Changed at (s from tape start)`),placeholder:c(`eventsDebugTapesReview.changedAtS`,`changed at s`),value:m,onChange:e=>h(e.target.value),className:`w-28`}),i(H,{variant:`secondary`,disabled:f.length!==1,onClick:()=>void S(`mixed`),children:c(`eventsDebugTapesReview.mixed`,`Mixed`)}),i(H,{variant:`secondary`,disabled:f.length===0,onClick:()=>void S(`not-a-subject`),children:c(`eventsDebugTapesReview.notASubject`,`Not a subject`)}),i(H,{variant:u.reviewed?`secondary`:`primary`,onClick:()=>void y([[na.review,{tapeId:u.tapeId,reviewed:!u.reviewed}]]).then(()=>l.refetch()),children:u.reviewed?c(`eventsDebugTapesReview.markNotReviewed`,`Mark not reviewed`):c(`eventsDebugTapesReview.markReviewed`,`Mark reviewed`)}),i(H,{variant:`ghost`,onClick:r,children:c(`common.close`,`Close`)})]}),g!==null&&i(K,{message:g}),C!==null&&i(K,{variant:`warning`,message:C}),i(`ul`,{className:`space-y-1`,children:u.lanes.toSorted((e,t)=>e.firstT-t.firstT).map(e=>i(lo,{lane:e,marks:d.data===null||d.data===void 0?[]:Aa(e.trackId,d.data),selected:f.includes(e.trackId),onToggle:()=>v(e.trackId)},e.trackId))})]})}function lo({lane:t,marks:n,selected:r,onToggle:a}){let{t:o}=J(),{src:s}=Dn(t.stillStored?On(`track`,t.trackId):void 0);return e(`li`,{className:`flex items-center gap-2 text-xs`,children:[i(le,{"aria-label":o(`eventsDebugTapesReview.select`,`select {{trackId}}`,{trackId:t.trackId}),checked:r,onChange:a}),s===null?i(`div`,{className:`h-10 w-10 rounded bg-surface-hover`}):i(`img`,{src:s,alt:t.trackId,className:`h-10 w-10 rounded object-cover`}),i(`span`,{className:`font-mono`,children:t.trackId}),i(`span`,{children:t.cls}),i(`span`,{className:`text-foreground-subtle`,children:o(`eventsDebugTapes.laneFrames`,{range:`${ao(t.firstT)} → ${ao(t.lastT)}`,count:t.boundFrames})}),!t.stillStored&&i(`span`,{className:`text-foreground-subtle`,children:o(`eventsDebugTapesReview.notStoredMarkedThroughThe`,`not stored — marked through the tape`)}),n.map(e=>i(G,{variant:`info`,children:e},e))]})}c();var uo=`dominevo_admin_token`;function fo(){let e=me();return(t,n)=>e.trpcClient.addons.custom.mutate({addonId:Ba,action:t,input:n})}async function po(e,t){let n=localStorage.getItem(uo),r={};n!==null&&(r.Authorization=`Bearer ${n}`);let i=await fetch(oa(e),{headers:r});if(!i.ok){let e=await i.text().catch(()=>``);throw Error(Ra(i.status,e))}let a=await i.blob(),o=i.headers.get(`content-disposition`),s=(o===null?null:/filename="?([^";]+)"?/i.exec(o))?.[1]?.trim()??t,c=URL.createObjectURL(a),l=document.createElement(`a`);l.href=c,l.download=s,l.click(),setTimeout(()=>URL.revokeObjectURL(c),6e4)}function mo(){let{t:e}=J(),[t,n]=o(!1);return i(Ye,{expanded:t,onExpandedChange:n,header:i(`span`,{className:`text-sm font-medium text-foreground`,children:e(`eventsDebugTapes.trackingTapes`,`Tracking tapes`)}),children:i(go,{})})}function ho({tape:t,onReview:n,onDownload:r,onRelease:a,onRemove:o,onError:s}){let{t:c}=J(),l=Yt(),u=L(),d=c(`eventsDebugTapes.review`,`Review {{scenario}}`,{scenario:t.scenario});if(l){let l=async(e,t,n,r)=>{if(await u({title:e,message:t,confirmLabel:n,variant:`warning`}))try{await r()}catch(e){s(ca(e))}};return e(`div`,{className:`flex items-center justify-end gap-1`,children:[i(H,{variant:`secondary`,"aria-label":d,onClick:n,children:c(`eventsDebugTapes.review2`,`Review`)}),i(Ie,{items:[{id:`download`,label:c(`eventsDebugTapes.download`,`Download {{scenario}}`,{scenario:t.scenario}),icon:h,onClick:r},{id:`release`,label:c(`eventsDebugTapes.release`,`Release`),icon:R,disabled:t.released,onClick:()=>void l(c(`eventsDebugTapes.release2`,`Release {{scenario}}?`,{scenario:t.scenario}),c(`eventsDebugTapes.releasingReturnsThisTapeS`,`Releasing returns this tape's pinned tracks to ordinary retention — they can be pruned from then on. The promoted bundle itself is kept until deleted.`),c(`eventsDebugTapes.release`,`Release`),a)},{id:`delete`,label:c(`common.delete`,`Delete`),icon:ce,danger:!0,separatorBefore:!0,onClick:()=>void l(c(`eventsDebugTapes.delete`,`Delete {{scenario}}?`,{scenario:t.scenario}),c(`eventsDebugTapes.deletingRemovesThePromotedBundle`,`Deleting removes the promoted bundle and its index row for good. Its tracks' pins are released first — this cannot be undone.`),c(`common.delete`,`Delete`),o)}]})]})}return e(`div`,{className:`flex items-center justify-end gap-1`,children:[i(H,{variant:`secondary`,"aria-label":c(`eventsDebugTapes.review`,`Review {{scenario}}`,{scenario:t.scenario}),onClick:()=>n(),children:c(`eventsDebugTapes.review2`,`Review`)}),i(H,{variant:`ghost`,"aria-label":c(`eventsDebugTapes.download`,`Download {{scenario}}`,{scenario:t.scenario}),onClick:()=>r(),children:i(h,{className:`h-3.5 w-3.5`})}),i(ze,{label:c(`eventsDebugTapes.release`,`Release`),icon:R,title:c(`eventsDebugTapes.release2`,`Release {{scenario}}?`,{scenario:t.scenario}),description:c(`eventsDebugTapes.releasingReturnsThisTapeS`,`Releasing returns this tape's pinned tracks to ordinary retention — they can be pruned from then on. The promoted bundle itself is kept until deleted.`),confirmLabel:c(`eventsDebugTapes.release`,`Release`),triggerVariant:`ghost`,confirmVariant:`danger`,disabled:t.released,action:()=>a()}),i(ze,{label:c(`common.delete`,`Delete`),icon:ce,title:c(`eventsDebugTapes.delete`,`Delete {{scenario}}?`,{scenario:t.scenario}),description:c(`eventsDebugTapes.deletingRemovesThePromotedBundle`,`Deleting removes the promoted bundle and its index row for good. Its tracks' pins are released first — this cannot be undone.`),confirmLabel:c(`common.delete`,`Delete`),triggerVariant:`ghost`,confirmVariant:`danger`,action:()=>o()})]})}function go(){let{t}=J(),r=fo(),a=Ue({isCamera:!0,projection:`slim`}),c=n(()=>{let e=new Map;for(let t of a.data??[])e.set(t.id,t.name);return n=>e.get(n)??t(`cameraLoad.deviceLabel`,{deviceId:n})},[a.data,t]),l=s({queryKey:[`events-debug`,`tapes`,`status`],queryFn:async()=>ma(await r(na.status,{}))}),d=s({queryKey:[`events-debug`,`tapes`,`list`],queryFn:async()=>ga(await r(na.list,{}))}),[f,p]=o(null),[m,h]=o(null),g=async e=>{h(null);try{await po(e.id,`${e.scenario}.tape-bundle.json.gz`)}catch(e){h(ca(e))}},_=async e=>{let t=ba(await r(na.release,{tapeId:e.id}));if(t===null)throw Error(sa);let n=Sa(t);if(n!==null)throw Error(n);await d.refetch()},v=async e=>{let t=xa(await r(na.remove,{tapeId:e.id}));if(t===null)throw Error(sa);let n=Sa(t);if(n!==null)throw Error(n);await d.refetch()};return e(`div`,{className:`space-y-3`,children:[i(`p`,{className:`text-xs text-foreground-subtle`,children:i(an,{i18nKey:`eventsDebugTapes.intro`,components:{b:i(`strong`,{}),code:i(`code`,{})}})}),m!==null&&i(K,{message:m}),l.isLoading&&i(`p`,{className:`text-xs text-foreground-subtle`,children:t(`eventsDebugTapes.loadingCameraStatus`,`Loading camera status…`)}),l.data===null&&i(K,{message:`The server answered in a shape this build does not understand.`}),i(He,{rows:l.data??[],rowKey:e=>e.deviceId,columns:[{mobile:`primary`,key:`camera`,header:t(`eventsDebugTapes.camera`,`Camera`),render:e=>c(e.deviceId)},{mobile:`keep`,key:`state`,header:t(`eventsDebugTapes.state`,`State`),render:e=>i(G,{variant:e.state===`recording`?`success`:e.state===`off`?`default`:e.state===`unknown`?`warning`:`danger`,children:ja(e)})},{mobile:`keep`,key:`framesPerMin`,header:t(`eventsDebugTapes.framesMin`,`Frames/min`),render:e=>e.framesPerMin===void 0?`—`:String(Math.round(e.framesPerMin))},{mobile:`hidden`,key:`lastHour`,header:t(`eventsDebugTapes.lastHour`,`Last hour`),render:e=>i(`span`,{title:e.shelfError,children:Ia(e.bytesLastHour)})},{mobile:`detail`,key:`held`,header:t(`eventsDebugTapes.held`,`Held`),render:e=>i(`span`,{title:e.shelfError,children:t(`eventsDebugTapes.segsHeld`,{count:La(e.segmentsHeld),size:Ia(e.bytesHeld)})})},{mobile:`hidden`,key:`gaps`,header:t(`eventsDebugTapes.gaps`,`Gaps`),render:e=>String(e.gapsSinceArmed)}]}),i(za,{cameras:Da(l.data??[]).map(e=>({value:String(e.deviceId),label:e.segmentsUnknown?t(`eventsDebugTapes.segmentsUnknown`,`{{value1}} (segments unknown)`,{value1:c(e.deviceId)}):c(e.deviceId)})),call:r,onPromoted:()=>void d.refetch()}),d.isLoading&&i(`p`,{className:`text-xs text-foreground-subtle`,children:t(`eventsDebugTapes.loadingPromotedTapes`,`Loading promoted tapes…`)}),d.data===null&&i(K,{message:`The server answered in a shape this build does not understand.`}),i(He,{minWidthPx:720,rows:d.data??[],rowKey:e=>e.id,columns:[{mobile:`primary`,key:`scenario`,header:t(`eventsDebugTapes.scenario`,`Scenario`),render:e=>e.scenario},{mobile:`detail`,key:`camera`,header:t(`eventsDebugTapes.camera`,`Camera`),render:e=>c(e.deviceId)},{mobile:`hidden`,key:`window`,header:t(`eventsDebugTapes.window`,`Window`),render:e=>`${new Date(e.fromMs).toLocaleString()} · ${ao(e.toMs-e.fromMs)} · ${e.lighting}`},{mobile:`detail`,key:`state`,header:t(`eventsDebugTapes.state`,`State`),render:n=>e(u,{children:[i(G,{variant:n.state===`complete`?`success`:`warning`,children:n.state}),` `,n.reviewed&&i(G,{variant:`info`,children:t(`eventsDebugTapes.reviewed`)}),` `,n.released&&i(G,{children:t(`eventsDebugTapes.released`)})]})},{mobile:`hidden`,key:`tracks`,header:t(`eventsDebugTapes.tracks`,`Tracks`),render:e=>t(`eventsDebugTapes.storedOf`,{stored:String(e.tracksStillStored),total:String(e.tracks.length)})},{mobile:`keep`,key:`actions`,header:``,align:`right`,render:e=>i(ho,{tape:e,onReview:()=>p(e.id),onDownload:()=>void g(e),onRelease:()=>_(e),onRemove:()=>v(e),onError:h})}]}),f!==null&&i(co,{tapeId:f,call:r,onClose:()=>p(null),onChanged:()=>void d.refetch()})]})}c();var _o=`all`,vo=`The server answered in a shape this build does not understand.`,yo={error:`danger`,warn:`warning`,info:`info`};function bo({findings:e}){let{t}=J();return e.length===0?i(G,{variant:`success`,children:t(`eventsDebug.noAnomalyFound`,`no anomaly found`)}):i(`div`,{className:`flex flex-wrap gap-1`,children:ro(e).map(e=>i(G,{variant:yo[e.severity],title:e.detail,children:to(e.code)},e.code))})}function xo({track:t,report:n,analyzing:r}){let{t:a}=J(),o=$r(n?.previewMissReason??t.previewMissReason);return e(`div`,{className:`space-y-1 border-t border-border pt-1.5`,children:[n===void 0?i(`span`,{className:`text-[10px] text-foreground-subtle`,children:r?a(`eventsDebug.analysing`,`analysing…`):a(`eventsDebug.notAnalysed`,`not analysed`)}):e(u,{children:[i(bo,{findings:n.findings}),i(`p`,{className:`text-[10px] text-foreground-subtle`,title:n.mediaKinds.length>0?n.mediaKinds.join(`, `):a(`eventsDebug.noMediaOfAnyKind`,`no media of any kind`),children:a(`eventsDebug.reportCounts`,{media:String(n.mediaCount),events:String(n.eventCount),positions:String(n.positionCount)})})]}),o!==null&&i(`p`,{className:`text-[10px] text-foreground-subtle`,title:o.raw,children:o.sentence})]})}function So({deviceId:t}={}){let{t:r}=J(),a=me(),[c,l]=o(_o),u=t===void 0?c:String(t),[d,f]=o(!1),[p,m]=o(null),[_,v]=o(new Set),[x,S]=o(null),[C,w]=o(null),[T,E]=o(null),[ee,D]=o([]),O=si(),k=Ue({isCamera:!0,projection:`slim`}),A=n(()=>[{value:_o,label:r(`eventsDebug.allCameras`,`All cameras`)},...(k.data??[]).map(e=>({value:String(e.id),label:e.name}))],[k.data,r]),j=n(()=>{let e=new Map;for(let t of k.data??[])e.set(t.id,t.name);return e},[k.data]),M=e=>j.get(e)??r(`eventsDebug.cameraFallback`,{deviceId:e}),P=n(()=>u===_o?[]:[Number.parseInt(u,10)],[u]),F=s({queryKey:[`events-debug`,`list`,P],queryFn:async()=>Qa(await a.trpcClient.addons.custom.mutate({addonId:Ba,action:Va,input:P.length===0?{}:{deviceIds:P}}))}),L=n(()=>(F.data?.tracks??[]).map(e=>e.trackId),[F.data]),R=s({queryKey:[`events-debug`,`analyze`,L],enabled:L.length>0,queryFn:async()=>$a(await a.trpcClient.addons.custom.mutate({addonId:Ba,action:Ha,input:{trackIds:L}}))}),te=n(()=>{let e=new Map;for(let t of R.data?.reports??[])e.set(t.trackId,t);return e},[R.data]),z=F.data?.tracks??[],ne=F.data===null||R.data===null,re=()=>{F.refetch(),R.refetch()},B=e=>{v(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},ie=()=>{v(new Set(z.map(e=>oo(e.deviceId,e.trackId))))},oe=()=>v(new Set),se=async(e,t)=>{let n=e===`analyzed`?{debug:!1}:{favourited:!0},r=0,i=[];for(let e of t)try{await O.mutateAsync({deviceId:e.deviceId,trackId:e.trackId,flags:n}),r+=1}catch{i.push(e.trackId)}return{applied:r,refused:i}},ce=e=>{if(!ii||C!==null)return;let t=so(z,_);t.length!==0&&(w(e),E(null),(async()=>{let n=await se(e,t);w(null);let r=new Set(n.refused);v(new Set(t.filter(e=>r.has(e.trackId)).map(e=>oo(e.deviceId,e.trackId)))),e===`analyzed`&&D(t.filter(e=>!r.has(e.trackId))),n.refused.length>0&&E(`${String(n.refused.length)} of ${String(t.length)} were refused by the server and are still selected. Check the hub log.`),F.refetch()})())},le=()=>{let e=ee;e.length===0||C!==null||(w(`analyzed`),E(null),(async()=>{for(let t of e)try{await O.mutateAsync({deviceId:t.deviceId,trackId:t.trackId,flags:{debug:!0}})}catch{E(`Some tracks could not be re-marked. Refresh and try again.`)}w(null),D([]),F.refetch()})())},ue=async()=>{f(!0),m(null);try{await An(io(P),`dominevo-debug.zip`)}catch(e){m(e instanceof Error?e.message:`Export failed.`)}finally{f(!1)}},de=C!==null;return e(`section`,{className:`space-y-3`,children:[e(`div`,{className:`flex flex-wrap items-center gap-2`,children:[t===void 0&&i(`div`,{className:`w-44`,children:i(N,{value:u,options:A,onChange:e=>l(e.target.value)})}),e(H,{variant:`secondary`,onClick:re,disabled:F.isFetching,children:[F.isFetching?i(V,{className:`h-3.5 w-3.5 animate-spin`}):i(I,{className:`h-3.5 w-3.5`}),r(`common.refresh`,`Refresh`)]}),e(H,{onClick:()=>void ue(),disabled:d||z.length===0,children:[d?i(V,{className:`h-3.5 w-3.5 animate-spin`}):i(h,{className:`h-3.5 w-3.5`}),r(`eventsDebug.exportAll`,{count:String(z.length)})]}),z.length>0&&_.size<z.length&&i(H,{variant:`ghost`,onClick:ie,children:r(`eventsDebug.selectAll`,`Select all`)})]}),i(`p`,{className:`text-xs text-foreground-subtle`,children:i(an,{i18nKey:`eventsDebug.debugMarkNote`,components:{code:i(`code`,{}),strong:i(`strong`,{})}})}),i(mo,{}),F.isError&&i(K,{message:r(`eventsDebug.couldNotLoadTheMarked`,`Could not load the marked tracks.`)}),ne&&!F.isError&&i(K,{message:vo}),p!==null&&i(K,{message:p}),T!==null&&i(K,{message:T}),F.data?.truncated===!0&&i(K,{message:r(`eventsDebug.aCameraFilledThePer`,`A camera filled the per-camera cap — some marked tracks are not listed. Un-mark a few, or filter to one camera.`)}),(R.data?.vanished.length??0)>0&&i(`p`,{className:`text-xs text-foreground-subtle`,children:r(`eventsDebug.vanished`,{count:String(R.data?.vanished.length)})}),_.size>0&&e(`div`,{className:`flex flex-wrap items-center gap-2 rounded-md border border-primary/40 bg-primary/8 px-3 py-2`,children:[i(`span`,{className:`text-xs font-medium text-foreground`,children:r(`common.selectedCount`,{count:_.size})}),e(`div`,{className:`ml-auto flex flex-wrap items-center gap-1.5`,children:[i(`span`,{title:ii?void 0:`Track flags arrive with the next server update`,children:e(H,{variant:`secondary`,onClick:()=>ce(`keep`),disabled:!ii||de,children:[C===`keep`?i(V,{className:`h-3.5 w-3.5 animate-spin`}):i(y,{className:`h-3.5 w-3.5`}),` `,r(`eventsDebug.keep`,`Keep`)]})}),i(`span`,{title:ii?void 0:`Track flags arrive with the next server update`,children:e(H,{onClick:()=>ce(`analyzed`),disabled:!ii||de,children:[C===`analyzed`?i(V,{className:`h-3.5 w-3.5 animate-spin`}):i(b,{className:`h-3.5 w-3.5`}),` `,r(`eventsDebug.analyzed`,`Analyzed`)]})}),i(H,{variant:`ghost`,onClick:oe,disabled:de,children:i(g,{className:`h-3.5 w-3.5`})})]})]}),ee.length>0&&e(`div`,{className:`flex flex-wrap items-center gap-2 rounded-md border border-border bg-surface px-3 py-2`,children:[i(`span`,{className:`text-xs text-foreground`,children:r(`eventsDebug.markedAnalyzed`,{count:String(ee.length)})}),e(H,{variant:`ghost`,onClick:le,disabled:de,children:[i(ae,{className:`h-3.5 w-3.5`}),` `,r(`eventsDebug.undo`)]}),i(H,{variant:`ghost`,onClick:()=>D([]),disabled:de,children:i(g,{className:`h-3.5 w-3.5`})})]}),F.isLoading?i(Xe,{status:`pending`,pendingMessage:`Loading…`,testId:`debug-tracks-grid`}):z.length===0?i(qe,{icon:pe,title:r(`eventsDebug.noTrackIsMarkedFor`,`No track is marked for debug`),description:r(`eventsDebug.markOneFromATrack`,`Mark one from a track's actions on the Feed to see it here.`)}):i(Xe,{status:`ready`,testId:`debug-tracks-grid`,children:z.map(e=>{let t=te.get(e.trackId);return i(Di,{row:e,cameraName:M(e.deviceId),nowMs:e.lastSeen,selected:_.has(oo(e.deviceId,e.trackId)),onToggleSelect:B,onOpenDetail:S,...t?.thumbnailProvenance===void 0?{}:{provenance:t.thumbnailProvenance},footer:i(xo,{track:e,report:t,analyzing:R.isFetching})},oo(e.deviceId,e.trackId))})}),x&&i(Ti,{row:x,cameraName:M(x.deviceId),deleteAvailable:vr,onClose:()=>S(null),onDeleted:()=>{S(null),F.refetch()},onFlagsChanged:e=>{e.debug||(S(null),F.refetch())}})]})}c();function Co({deviceId:t,debug:n}){let{t:r}=J(),[a,s]=o(!1);return i(Ye,{expanded:a||n,onExpandedChange:s,header:e(`span`,{className:`flex items-center gap-2 text-sm font-medium text-foreground`,children:[i(ie,{className:`h-3.5 w-3.5`}),r(`archive.review.tools`,`Search, parked objects and debug`)]}),children:e(`div`,{className:`flex flex-col gap-3`,"data-testid":`archive-review-tools`,children:[i(Ki,{}),i(Qi,{deviceId:t}),i(ta,{deviceId:t}),n&&i(So,{deviceId:t})]})})}var wo=``;function To(e){return e===`any`||e===`face`||e===`plate`}function Eo({filters:t,zones:n,onChange:r,unchecked:a=0}){let{t:o}=J();return e(`div`,{className:`contents`,"data-testid":`archive-review-filters`,children:[n.length>0&&e(N,{wrapperClassName:`inline-block w-auto`,"aria-label":o(`archive.review.zone`,`Zone`),value:t.zone??wo,onChange:e=>r({...t,zone:e.target.value===wo?null:e.target.value}),children:[i(`option`,{value:wo,children:o(`archive.review.allZones`,`All zones`)}),n.map(e=>i(`option`,{value:e,children:e},e))]}),e(N,{wrapperClassName:`inline-block w-auto`,"aria-label":o(`archive.review.identity`,`Face or plate`),value:t.identity,onChange:e=>{let n=e.target.value;To(n)&&r({...t,identity:n})},children:[i(`option`,{value:`any`,children:o(`archive.review.identityAny`,`Any subject`)}),i(`option`,{value:`face`,children:o(`archive.review.identityFace`,`With a face`)}),i(`option`,{value:`plate`,children:o(`archive.review.identityPlate`,`With a plate`)})]}),e(`label`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[i(le,{checked:t.debug,onChange:e=>r({...t,debug:e.target.checked})}),o(`archive.camera.debugFilter`,`Debug-marked tracks only`)]}),a>0&&i(`span`,{className:`text-[11px] text-warning`,"data-testid":`archive-review-unchecked`,children:o(`archive.review.unchecked`,`Events not checked by this filter: {{count}}`,{count:a})})]})}c();function Do(){let e=Date.now(),t=new Date(e);return t.setHours(0,0,0,0),{fromMs:t.getTime(),toMs:e}}var Oo=[];function ko({deviceId:e}){return i(tt,{deviceId:e,children:i(De,{children:i(Mt,{children:i(se,{children:i(dt,{children:i(Ao,{deviceId:e},e)})})})})})}function Ao({deviceId:t}){let{t:a}=J(),[s,c]=o(Do),[l,u]=o(Li),[d,f]=o(null),[p,m]=o(void 0),[h,g]=o(null),[_,v]=o(!1),[y,b]=o(null),[x,S]=o(null),[C,w]=o(`high`),[T,E]=o(null),[ee,D]=o(null),O=Wt({deviceId:t}),k=n(()=>Pe(O.data??[]),[O.data]),A=y??Me(k,`recorder`),j=A===null||A===`recorder`,M=Zt(t,j?null:A,s),P=st({deviceId:t,since:s.fromMs,until:s.toMs,limit:200,projection:`slim`}),F=P.data??Oo,I=n(()=>zi(F),[F]),L=n(()=>Ri(F),[F]),R=n(()=>Vi(l,L),[l,L]),te=Hi(l)||l.debug,z=n(()=>d===null?0:Ui(d.rows,l,L),[d,l,L]),ne=n(()=>d!==null&&(d.narrowed||te)?Wi(d.rows):void 0,[d,te]),re=n(()=>({since:s.fromMs,until:s.toMs}),[s]),B=r(e=>c(e),[]),V=r(e=>{if(E(null),j){S(null),m(t=>({atMs:e,nonce:(t?.nonce??0)+1}));return}let t=et(M.clips,e);t===null&&E(e),S(t)},[j,M.clips]),ie=r((e,t)=>{if(b(e),E(null),e===`recorder`){S(null),m(e=>({atMs:t.timeRange.startMs,nonce:(e?.nonce??0)+1}));return}S(t)},[]),ae=O.status===`pending`?i(`span`,{className:`text-[11px] text-foreground-subtle`,role:`status`,children:a(`archive.review.sourcesLoading`,`Loading sources…`)}):O.status===`error`?i(`span`,{className:`text-[11px] text-danger`,role:`alert`,children:a(`archive.review.sourcesFailed`,`Sources could not be read — {{reason}}`,{reason:O.error?.message??a(`archive.review.noReason`,`no reason given`)})}):null,oe=P.status===`error`?i(`span`,{className:`text-[11px] text-danger`,role:`alert`,"data-testid":`archive-review-tracks-failed`,children:a(`archive.review.tracksFailed`,`Track facts could not be read — {{reason}}`,{reason:P.error?.message??a(`archive.review.noReason`,`no reason given`)})}):null,se=ae??(k.length>1?i(N,{wrapperClassName:`inline-block w-auto`,"aria-label":a(`archive.review.source`,`Source`),value:A??``,onChange:e=>{b(e.target.value),S(null),E(null)},children:k.map(e=>i(`option`,{value:e.value,children:e.label},e.value))}):null);return e(`div`,{className:`grid grid-cols-1 gap-3 lg:grid-cols-[minmax(0,calc(40vh*16/9))_minmax(20rem,1fr)]`,children:[i(`div`,{className:`order-1 flex min-w-0 flex-col gap-2 lg:order-none lg:col-start-1 lg:row-start-1`,children:i(`div`,{className:`mx-auto aspect-video w-full max-w-[calc(40vh*16/9)] overflow-hidden rounded-lg border border-border bg-black`,"data-testid":`archive-review-player`,children:i(on,{deviceId:t})})}),e(`div`,{className:`order-3 flex min-w-0 flex-col gap-2 lg:order-none lg:col-start-2 lg:row-start-1 lg:max-h-[40vh] lg:overflow-y-auto`,"data-testid":`archive-review-events`,children:[T!==null&&i(K,{variant:`warning`,message:a(`archive.review.noClipAt`,`This source holds no clip at {{time}}. Pick another source or another moment.`,{time:new Date(T).toLocaleTimeString()})}),x!==null&&A!==null&&i(We,{deviceId:t,clip:x,profile:C,onProfileChange:w}),i(Ii,{deviceId:t,window:re,rowFilter:R,onListChange:f,onSeek:V,layout:`rows`,toolbarTarget:ee})]}),i(`div`,{className:`order-2 flex min-w-0 flex-col gap-2 lg:order-none lg:col-span-2 lg:row-start-2`,children:i(Ze,{deviceId:t,seekTo:p,onExportRange:(e,t)=>{v(!1),g({fromMs:e,toMs:t})},onViewChange:B,densityPoints:ne,toolbar:e(`div`,{className:`contents`,"data-testid":`archive-review-bar`,children:[se,_&&e(`span`,{className:`text-[11px] text-success`,role:`status`,children:[a(`archive.review.exportQueued`,`Export queued.`),` `,i(nn,{to:un(t),className:`font-medium underline`,children:a(`archive.review.openExports`,`Open Library → Exports`)})]}),i(`span`,{ref:D,className:`contents`}),i(Eo,{filters:l,zones:I,onChange:u,unchecked:z}),oe]}),lanes:i($e,{deviceId:t,options:k,view:s,selectedProvider:A,onPickClip:ie})})}),i(`div`,{className:`order-4 min-w-0 lg:order-none lg:col-span-2 lg:row-start-3`,children:i(Co,{deviceId:t,debug:l.debug})}),h!==null&&i(Tn,{onClose:()=>g(null),onCreated:()=>{g(null),v(!0)},initialDeviceId:t,initialRange:h})]})}function jo({deviceId:e}){return i(tt,{deviceId:e,children:i(sn,{deviceId:e,sectionFilter:e=>e.location===`top-tab`&&e.tab===`recording`})},e)}function Mo(e){return e.locationIds!==void 0&&e.locationIds.length>0?e.locationIds:e.locationId===null?[]:[e.locationId]}function No(e,t){let n=Mo(e);return n.length===0?q.t(`helpers.cameraDisk.defaultRoot`):n.map(e=>t.get(e)??e).join(` + `)}function Po(e,t,n){if(e.length===0)return null;let r=e[0];if(e.length===1&&r!==void 0)return{label:No(r,t),exact:!0};if(n===null)return null;let i=e.find(e=>Mo(e).includes(n));return i===void 0?null:{label:No(i,t),exact:!1}}c();var Fo=[{value:`retention`,labelKey:`recordings.storageSection.pruneRetention`},{value:`quota`,labelKey:`recordings.storageSection.pruneQuota`},{value:`operator`,labelKey:`recordings.storageSection.pruneOperator`}],Io=`—`;function Lo({data:t,row:a}){let{t:s}=J(),c=L(),u=l(),[d,f]=o(`retention`),p=Ft({}).data,m=r(()=>{u.invalidateQueries({queryKey:[[`recording`]]}),u.invalidateQueries({queryKey:[[`recordingArchive`]]}),u.invalidateQueries({queryKey:[[`pipelineAnalytics`]]})},[u]),h=Tt({onSuccess:m}),g=Ke({onSuccess:m}),_=rt({onSuccess:m}),v=n(()=>{let e=new Map((p??[]).map(e=>[e.id,e.displayName])),n=(p??[]).filter(e=>e.type===`recordings`),r=(n.find(e=>U(e)===`active`)??n[0])?.id??null;return Po(t.usage?.locations??[],e,r)},[p,t.usage?.locations]),y=r(async(e,t,n,r)=>c({title:e,message:t,confirmLabel:n,variant:`danger`,action:r}),[c]),b=async()=>{await y(s(`archive.space.pruneTitle`,`Apply retention to {{name}}?`,{name:a.name}),s(`archive.space.pruneMessage`,`Footage beyond the retention policy is permanently deleted.`),s(`archive.space.pruneNow`,`Prune now`),()=>h.mutateAsync({deviceId:a.deviceId,reason:d}))},x=async()=>{await y(s(`archive.space.deleteFootageTitle`,`Delete all footage for {{name}}?`,{name:a.name}),s(`archive.space.deleteFootageMessage`,`Permanently deletes {{size}} of recorded footage. This cannot be undone.`,{size:a.footageBytes===null?Io:Y(a.footageBytes)}),s(`archive.space.deleteFootage`,`Delete footage`),()=>g.mutateAsync({deviceId:a.deviceId}))},S=async()=>{await y(s(`archive.space.deleteEventsTitle`,`Delete all events for {{name}}?`,{name:a.name}),s(`archive.space.deleteEventsMessage`,`Permanently deletes the events and their media. This cannot be undone.`),s(`archive.space.deleteEvents`,`Delete events`),()=>_.mutateAsync({deviceId:a.deviceId}))};return e(`div`,{className:`flex flex-col gap-4`,"data-testid":`archive-space`,children:[e(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-3`,children:[i(B,{label:s(`archive.space.footage`,`Footage`),icon:i(w,{className:`h-3.5 w-3.5`}),footer:v===null?s(`archive.space.diskUnknown`,`Disk not reported`):v.exact?v.label:s(`archive.space.diskDefault`,`{{label}} (default)`,{label:v.label}),children:a.footageBytes===null?Io:Y(a.footageBytes)}),i(B,{label:s(`archive.space.events`,`Event storage`),footer:a.eventRows===null?void 0:s(`archive.space.eventRows`,`{{count}} events`,{count:a.eventRows}),children:a.eventBytes===null?Io:Y(a.eventBytes)}),i(B,{label:s(`archive.space.oldest`,`Oldest footage`),children:a.oldestMs===null?Io:new Date(a.oldestMs).toLocaleDateString()})]}),e(`div`,{className:`flex flex-col gap-2 rounded-lg border border-danger/40 p-3`,children:[i(`h3`,{className:`text-sm font-semibold text-danger`,children:s(`archive.space.danger`,`Danger zone`)}),e(`div`,{className:`flex flex-wrap items-center gap-2 text-xs`,children:[i(`span`,{className:`text-foreground-subtle`,children:s(`recordings.storageSection.pruneReason`,`Prune reason`)}),i(N,{wrapperClassName:`inline-block w-auto`,value:d,"aria-label":s(`recordings.storageSection.pruneReason`,`Prune reason`),onChange:e=>{let t=Fo.find(t=>t.value===e.target.value);t&&f(t.value)},children:Fo.map(e=>i(`option`,{value:e.value,children:s(e.labelKey)},e.value))})]}),e(`div`,{className:`flex flex-wrap gap-2`,children:[e(H,{variant:`secondary`,onClick:()=>void b(),disabled:h.isPending,children:[i(we,{className:`h-3.5 w-3.5`}),s(`archive.space.applyRetention`,`Apply retention now`)]}),e(H,{variant:`secondary`,onClick:()=>void x(),disabled:g.isPending,children:[i(ce,{className:`h-3.5 w-3.5`}),s(`archive.space.deleteFootage`,`Delete footage`)]}),e(H,{variant:`secondary`,onClick:()=>void S(),disabled:_.isPending,children:[i(ce,{className:`h-3.5 w-3.5`}),s(`archive.space.deleteEvents`,`Delete events`)]})]})]})]})}c();var Ro=[he.Camera],zo=[`review`,`health`,`settings`];function Bo(e){return zo.some(t=>t===e)}function Vo({data:t}){let{t:n}=J(),[a,o]=rn(),s=a.get(ln),c=a.get(dn),l=Bo(c)?c:`review`,u=s===null?t.cameras[0]?.id??null:Number(s),d=r((e,t)=>{o(n=>{let r=new URLSearchParams(n);return r.set(e,t),r},{replace:!0})},[o]);if(u===null||!Number.isFinite(u))return i(qe,{icon:S,title:n(`archive.camera.none`,`No cameras yet`),description:n(`archive.camera.noneHint`,`Cameras appear here once one is added.`)});let f=t.rows.find(e=>e.deviceId===u),p=er(cr(t,u),nr(t.findings,u));return e(`div`,{className:`flex flex-col gap-3`,"data-testid":`archive-camera-section`,children:[e(`div`,{className:`flex flex-wrap items-center gap-2`,children:[i(Ve,{pick:`device`,noun:`camera`,fixedTypes:Ro,recentKey:`archive-camera`,testId:`archive-camera`,clearable:!1,className:`w-auto min-w-48`,value:{deviceId:u},onChange:e=>{e!==null&&d(ln,String(e.deviceId))}}),p.map(t=>e(G,{variant:sr[t.state],children:[n(`archive.function.${t.fn}`,t.fn),` · `,n(`archive.functionState.${t.state}`,t.state)]},t.fn))]}),!t.isLoading&&f===void 0?i(qe,{icon:S,title:n(`archive.camera.unknown`,`Camera not found`),description:n(`archive.camera.unknownHint`,`This camera is not in the Archive. Pick one from the overview.`)}):e(xt,{appearance:`pills`,value:l,onValueChange:e=>d(dn,e),className:`flex flex-col gap-3`,children:[e(it,{"aria-label":n(`archive.camera.sections`,`Camera sections`),children:[i(Kt,{value:`review`,children:n(`archive.camera.review`,`Review`)}),i(Kt,{value:`health`,children:n(`archive.camera.healthSpace`,`Health & space`)}),i(Kt,{value:`settings`,children:n(`archive.camera.settings`,`Settings`)})]}),i(yt,{value:`review`,children:i(ko,{deviceId:u})}),i(yt,{value:`health`,children:e(`div`,{className:`flex flex-col gap-6`,children:[i(lr,{data:t,deviceId:u}),i(Kn,{data:t,deviceId:u}),f!==void 0&&i(Lo,{data:t,row:f})]})}),i(yt,{value:`settings`,children:i(jo,{deviceId:u})})]})]})}c();var Ho={recording:`success`,off:`default`,degraded:`warning`,unknown:`default`},Uo=`—`;function Wo({rows:t,isLoading:r}){let{t:a}=J(),o=tn(),s=n(()=>[{mobile:`primary`,key:`camera`,header:a(`archive.table.camera`,`Camera`),sortValue:e=>e.name,render:e=>i(`span`,{className:`font-medium text-foreground`,children:e.name})},{mobile:`detail`,key:`mode`,header:a(`archive.table.mode`,`Recording`),sortValue:e=>e.mode??``,render:e=>i(`span`,{className:`text-foreground-subtle`,children:e.mode===null?Uo:a(`archive.mode.${e.mode}`,e.mode)})},{mobile:`detail`,key:`status`,header:a(`archive.table.status`,`Status`),sortValue:e=>e.state,render:t=>e(`span`,{className:`inline-flex items-center gap-1.5`,children:[i(G,{variant:Ho[t.state],children:a(`archive.state.${t.state}`,t.state)}),t.warnings>0&&i(G,{variant:`warning`,children:a(`archive.table.warnings`,`{{count}} warning`,{count:t.warnings})})]})},{mobile:`keep`,key:`footage`,header:a(`archive.table.footage`,`Footage`),align:`right`,nowrap:!0,sortValue:e=>e.footageBytes,render:e=>i(`span`,{className:`tabular-nums`,children:e.footageBytes===null?Uo:Y(e.footageBytes)})},{mobile:`hidden`,key:`events`,header:a(`archive.table.events`,`Events`),align:`right`,nowrap:!0,sortValue:e=>e.eventRows,render:e=>i(`span`,{className:`tabular-nums`,children:e.eventRows===null||e.eventBytes===null?Uo:`${e.eventRows.toLocaleString()} · ${Y(e.eventBytes)}`})},{mobile:`hidden`,key:`oldest`,header:a(`archive.table.oldest`,`Oldest footage`),align:`right`,nowrap:!0,sortValue:e=>e.oldestMs,render:e=>i(`span`,{className:`tabular-nums text-foreground-subtle`,children:e.oldestMs===null?Uo:new Date(e.oldestMs).toLocaleDateString()})}],[a]);return!r&&t.length===0?i(qe,{icon:S,title:a(`archive.table.noCameras`,`No cameras`),description:a(`archive.table.addACamera`,`Add a camera first.`)}):i(He,{columns:s,rows:t,rowKey:e=>e.deviceId,onRowClick:e=>o(fn(e.deviceId)),minWidthPx:720,maxBodyHeight:nt,defaultSort:{columnKey:`camera`,dir:`asc`}})}var Go=1440*60*1e3;function Ko(e){if(e.footageBytes===null||e.oldestMs===null)return null;let t=e.nowMs-e.oldestMs;return t<Go?null:e.footageBytes/(t/Go)}function qo(e,t){return e===null||t===null||t<=0?null:e/t}function Jo(e){let t=null;for(let n of e)n.oldestMs!==null&&(t===null||n.oldestMs<t)&&(t=n.oldestMs);return t}c();var Yo=`—`;function Xo({data:t}){let{t:r}=J(),{usage:a,footprint:o,rows:s,totals:c}=t,l=a!==null&&a.devicesRead!==`unavailable`,u=n(()=>Ko({footageBytes:l?a.totalUsedBytes:null,oldestMs:Jo(s),nowMs:Date.now()}),[l,a,s]),d=qo(n(()=>{let e=In(a?.locations??[]);return e===null||e.knownVolumes===0?null:e.freeBytes},[a?.locations]),u);return e(`div`,{className:`grid grid-cols-2 gap-3 lg:grid-cols-5`,"data-testid":`archive-key-numbers`,children:[i(B,{label:r(`archive.keyNumbers.footage`,`Footage`),icon:i(w,{className:`h-3.5 w-3.5`}),footer:l?void 0:r(`archive.keyNumbers.footageUnread`,`The recorder did not answer`),children:l?Y(a.totalUsedBytes):Yo}),i(B,{label:r(`archive.keyNumbers.eventStorage`,`Event storage`),icon:i(D,{className:`h-3.5 w-3.5`}),footer:o===null?r(`archive.keyNumbers.eventsUnread`,`The event store did not answer`):r(`archive.keyNumbers.eventRows`,`{{count}} events`,{count:o.totalRows}),children:o===null?Yo:Y(o.totalBytes)}),i(B,{label:r(`archive.keyNumbers.growth`,`Growth per day`),icon:i(de,{className:`h-3.5 w-3.5`}),footer:u===null?r(`archive.keyNumbers.growthUnknown`,`Needs a day of footage`):d===null?r(`archive.keyNumbers.daysUnknown`,`Free space unknown`):r(`archive.keyNumbers.daysLeft`,`{{days}} days of space left`,{days:Math.floor(d)}),children:u===null?Yo:Y(u)}),i(B,{label:r(`archive.keyNumbers.cameras`,`Cameras`),icon:i(S,{className:`h-3.5 w-3.5`}),footer:r(`archive.keyNumbers.cameraStates`,`{{degraded}} degraded · {{off}} off`,{degraded:c.degraded,off:c.off}),children:r(`archive.keyNumbers.recordingOf`,`{{recording}} of {{total}} recording`,{recording:c.recording,total:s.length})}),i(B,{label:r(`archive.keyNumbers.warnings`,`Open warnings`),icon:i(k,{className:`h-3.5 w-3.5`}),footer:t.findings===null?r(`archive.keyNumbers.digestPending`,`No health digest yet`):void 0,children:t.findings===null?Yo:String(c.warnings)})]})}c();var Zo={active:`success`,readonly:`default`,drain:`warning`,disabled:`danger`};function Qo(){let{t}=J(),n=Nn(),[r,a]=o(null);return n.locations.length===0?i(qe,{icon:w,title:t(`archive.storage.none`,`No storage locations`),description:t(`archive.storage.noneHint`,`Add a location to start storing footage and events.`)}):e(u,{children:[i(`div`,{className:`grid grid-cols-1 gap-3 md:grid-cols-2 xl:grid-cols-3`,"data-testid":`archive-storage-cards`,children:n.locations.map(r=>{let o=jn(r);return e(`div`,{className:`flex flex-col gap-2 rounded-lg border border-border bg-surface p-3`,children:[e(`div`,{className:`flex items-start justify-between gap-2`,children:[e(`div`,{className:`min-w-0`,children:[i(`div`,{className:`truncate text-sm font-medium text-foreground`,children:r.displayName}),e(`div`,{className:`text-[11px] text-foreground-subtle`,children:[r.type,r.nodeId===void 0?``:` · ${r.nodeId}`]})]}),i(G,{variant:Zo[o],children:Mn(o).label})]}),i(Fn,{location:r,ownedBytes:n.ownedBytesById.get(r.id)??null}),i(Pn,{drain:n.drainOf(r)}),e(`div`,{className:`flex items-center justify-between gap-2`,children:[i(`span`,{className:`text-[11px] text-foreground-subtle`,children:o===`active`?t(`archive.storage.writing`,`Taking new writes`):t(`archive.storage.notWriting`,`Not taking new writes`)}),i(H,{variant:`ghost`,onClick:()=>a(r),children:t(`archive.storage.manage`,`Manage`)})]})]},r.id)})}),r!==null&&i(Te,{open:!0,onOpenChange:e=>!e&&a(null),children:e(Ht,{width:`xl`,placement:`sheet-on-mobile`,scroll:`body`,children:[i(Ct,{children:i(ot,{children:r.displayName})}),i(mt,{children:i(Ln,{kinds:[r.type]})})]})})]})}c();var $o=1440*60*1e3,es=[1,7,30,90],ts=30;function ns(){let{t}=J(),n=L(),a=l(),[s,c]=o(ts),u=Nt({onSuccess:()=>{a.invalidateQueries({queryKey:[[`pipelineAnalytics`]]})}}),d=r(async()=>{await n({title:t(`recordings.eventsManagementSection.pruneTitle`,{count:s}),message:t(`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:t(`recordings.eventsManagementSection.pruneEvents`,`Prune events`),variant:`danger`})&&u.mutate({olderThanMs:Date.now()-s*$o,reason:`retention`})},[n,u,s,t]);return e(`section`,{className:`flex flex-wrap items-center gap-2 text-xs`,"data-testid":`prune-events-by-age`,children:[i(`span`,{className:`text-foreground-subtle`,children:t(`recordings.eventsManagementSection.pruneEventsOlderThan`,`Prune events older than`)}),i(N,{wrapperClassName:`inline-block w-auto`,value:s,onChange:e=>c(Number(e.target.value)),"aria-label":t(`recordings.eventsManagementSection.pruneEventsOlderThan`,`Prune events older than`),children:es.map(e=>i(`option`,{value:e,children:t(`recordings.eventsManagementSection.ageDays`,{count:e})},e))}),e(H,{variant:`secondary`,onClick:()=>void d(),disabled:u.isPending,children:[u.isPending?i(V,{className:`h-3 w-3 animate-spin`}):i(we,{className:`h-3 w-3`}),t(`recordings.eventsManagementSection.pruneNow`,`Prune now`)]})]})}var rs=`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`;c();var is=`storage-migration`,as=new Set([`orphans`,`debug-media`,`ghost-ledger`]);function os(e){return[`${e.orphansReclaimed} orphan rows (${Y(e.orphanBytesReclaimed)})`,e.includeDebugMedia?`${e.debugMediaReclaimed} debug files (${Y(e.debugMediaBytesReclaimed)})`:null,`${e.ghostsForgotten} ghost rows (${Y(e.ghostBytesForgotten)})`].filter(e=>e!==null).join(` · `)}function ss(){let{t:e}=J(),t=ke(is);return t===`pending`?null:t===`unknown`?i(`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`?i(cs,{}):null}function cs(){let{t}=J(),n=L(),[r,a]=o(!1),[s,c]=o(null),l=Gt({},{refetchInterval:2e3}),u=l.data??null,d=u!==null&&as.has(u.phase),f=Ot(),p=ut(),m=async()=>{if(await n({title:t(`recordings.cleanupSection.runStorageCleanup`,`Run storage cleanup?`),message:r?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 f.mutateAsync({includeDebugMedia:r}),await l.refetch()}catch(e){c(e instanceof Error?e.message:String(e))}}},h=async()=>{if(u&&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 p.mutateAsync({jobId:u.jobId}),await l.refetch()}catch{}};return e(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[i(`h2`,{className:`text-sm font-semibold text-foreground`,children:t(`recordings.cleanupSection.cleanup`,`Cleanup`)}),i(`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:[i(le,{checked:r,disabled:d,onChange:e=>{a(e.target.checked)},className:`mt-0.5 h-3.5 w-3.5 accent-primary`}),i(`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(H,{variant:`unstyled`,type:`button`,disabled:d||f.isPending,onClick:()=>{m()},className:rs,children:[(d||f.isPending)&&i(V,{className:`h-3 w-3 animate-spin`}),i(ce,{className:`h-3 w-3`}),t(`recordings.cleanupSection.runCleanup`,`Run cleanup`)]}),d&&i(H,{variant:`unstyled`,type:`button`,onClick:()=>{h()},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&&i(`p`,{className:`mt-2 text-[11px] text-danger`,children:s}),u&&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:`),` `,i(`span`,{className:`font-medium`,children:u.phase}),d&&i(V,{className:`ml-2 inline h-3 w-3 animate-spin text-primary`})]}),u.detail&&i(`p`,{className:`text-[11px] text-foreground-subtle`,children:u.detail}),i(`p`,{className:`text-[11px] text-foreground-subtle`,children:os(u)}),u.error&&i(`p`,{className:`text-[11px] text-danger`,children:u.error})]})]})}c();var ls=2e3;function us(){let{t}=J(),n=L(),r=l(),o=Xt(),s=Je(void 0,{refetchInterval:e=>e.state.data?.state===`running`?ls:!1}),c=s.data,u=c?.state===`running`,d=u||o.isPending;a(()=>{c?.state!==`done`||c.finishedAtMs===null||(r.invalidateQueries({queryKey:[[`recording`]]}),r.invalidateQueries({queryKey:[[`pipelineAnalytics`]]}))},[c?.state,c?.finishedAtMs,r]);let f=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 s.refetch())},p=u?c.total>0?`Reconciling ${String(c.completed)}/${String(c.total)}…`:`Reconciling…`:o.isPending?`Reconciling…`:`Reconcile from disk`;return e(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[i(`h3`,{className:`text-sm font-semibold text-foreground`,children:t(`recordings.diskReconcileSection.diskReconcile`,`Disk reconcile`)}),i(`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(H,{variant:`unstyled`,type:`button`,onClick:()=>void f(),disabled:d,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:[d?i(V,{className:`h-3.5 w-3.5 animate-spin`}):i(w,{className:`h-3.5 w-3.5`}),p]}),c?.state===`done`?e(`p`,{className:`text-[11px] text-foreground-subtle`,children:[t(`recordings.diskReconcileSection.lastRun`,`Last run:`),` `,t(`recordings.diskReconcileSection.summary`,{completed:String(c.completed),tracks:String(c.tracks),events:String(c.events),media:String(c.mediaDropped)}),c.failed.length>0?t(`recordings.diskReconcileSection.failed`,`, {{value1}} failed ({{value2}})`,{value1:String(c.failed.length),value2:c.failed.join(`, `)}):``,`.`]}):null,c?.state===`error`&&c.error!==null?e(`p`,{className:`text-[11px] text-destructive`,children:[t(`recordings.diskReconcileSection.reconcileFailed`,`Reconcile failed:`),` `,c.error]}):null]})]})}var ds=1e3,fs=60*ds,ps=60*fs;function ms(e){return e.toLocaleString(`en-US`)}function hs(e){if(!Number.isFinite(e)||e<0)return`—`;if(e>=ps){let t=Math.floor(e/ps),n=Math.round(e%ps/fs);return`${t.toString()}h ${n.toString()}m`}if(e>=fs){let t=Math.floor(e/fs),n=Math.round(e%fs/ds);return`${t.toString()}m ${n.toString()}s`}return`${Math.max(0,Math.round(e/ds)).toString()}s`}function gs(e){let t=Math.max(0,e.observedAt-e.startedAt),n=e.filesTotal===null?`${ms(e.filesMoved)} files`:`${ms(e.filesMoved)} / ${ms(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?`${Y(e.bytesMoved/t*ds)}/s`:null,o=e.filesTotal===null?null:e.filesTotal-e.filesMoved,s=!i||o===null||o<=0?null:`~${hs(o*t/e.filesMoved)} left`;return{counted:n,fraction:r,moved:`${Y(e.bytesMoved)} moved`,rate:a,eta:s}}function _s(e){let t=gs(e);return[t.counted,t.moved,t.rate,t.eta].filter(e=>e!==null).join(` · `)}c();var vs=`storage-migration`,ys=[{id:`recordings`,labelKey:`recordings.storageMigrationSection.classRecordings`,locationType:`recordings`},{id:`recordingsLow`,labelKey:`recordings.storageMigrationSection.classRecordingsLow`,locationType:`recordingsLow`},{id:`eventMedia`,labelKey:`recordings.storageMigrationSection.classEventMedia`,locationType:`eventMedia`}],bs=new Set([`planning`,`sealing`,`pausing`,`moving`,`draining`,`verifying`,`repointing`,`refreshing`,`resuming`]);function xs(){let{t}=J(),n=ke(vs);return n===`pending`?e(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[i(V,{className:`h-4 w-4 animate-spin`}),t(`migration.storageMigrationSection.checkingWhetherStorageMigrationIs`,`Checking whether storage migration is installed…`)]}):n===`unknown`?i(qe,{icon:k,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`?i(qe,{icon:P,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.`)}):i(Ss,{})}function Ss(){let{t}=J(),r=L(),{data:a}=Ft({}),[s,c]=o({}),[l,u]=o({}),[d,f]=o(null),[p,m]=o(null),h=n(()=>{let e=new Map;for(let t of a??[]){let n=e.get(t.type);n?n.push(t):e.set(t.type,[t])}return e},[a]),_=n(()=>{let e=new Map;for(let t of a??[]){if(!ve(t))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},[a]),v=at({},{refetchInterval:2e3}),y=v.data??null,b=y!==null&&bs.has(y.phase),x=n(()=>{let e={};for(let t of ys){let n=s[t.id];n&&(e[t.id]=n)}return Object.keys(e).length>0?e:void 0},[s]),S=n(()=>{let e={};for(let t of ys){if(!s[t.id])continue;let n=l[t.id]??_.get(t.locationType);n&&(e[t.id]=n)}return Object.keys(e).length>0?e:void 0},[s,l,_]),C=n(()=>({destinations:x??{},...S?{sources:S}:{}}),[x,S]),w=At(C,{enabled:!1,retry:!1}),T=bt(),E=Vt(),ee=async()=>{if(!x)return;m(null);let e=await w.refetch();if(e.error){m(e.error instanceof Error?e.error.message:String(e.error));return}f(e.data??null)},D=async()=>{if(x&&await r({title:t(`migration.storageMigrationSection.startStorageMigration`,`Start storage migration?`),message:t(`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:t(`migration.storageMigrationSection.startMigration`,`Start migration`),variant:`danger`})){m(null);try{await T.mutateAsync(C),f(null),await v.refetch()}catch(e){m(e instanceof Error?e.message:String(e))}}},O=async()=>{if(y&&await r({title:t(`migration.storageMigrationSection.cancelMigration`,`Cancel migration?`),message:t(`migration.storageMigrationSection.stopsTheInProgressMigration`,`Stops the in-progress migration. Data already moved and verified stays at the destination; anything already repointed is not reverted.`),confirmLabel:t(`migration.storageMigrationSection.cancelMigration2`,`Cancel migration`),variant:`danger`}))try{await E.mutateAsync({jobId:y.jobId}),await v.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:[i(P,{className:`h-3.5 w-3.5`}),t(`migration.storageMigrationSection.storageMigration`,`Storage migration`)]}),i(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:t(`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.`)}),i(`div`,{className:`mt-3 grid grid-cols-1 gap-3 sm:grid-cols-3`,children:ys.map(n=>{let r=h.get(n.locationType)??[],a=_.get(n.locationType)??``;return e(`div`,{className:`space-y-2`,children:[i(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:t(n.labelKey)}),e(`div`,{className:`space-y-1`,children:[i(`label`,{htmlFor:`migration-from-${n.id}`,className:`text-[10px] text-foreground-subtle`,children:t(`recordings.storageMigrationSection.classFrom`,{label:t(n.labelKey)})}),i(N,{id:`migration-from-${n.id}`,value:l[n.id]??a,onChange:e=>{let t=e.target.value;u(e=>({...e,[n.id]:t}))},disabled:b,className:`w-full`,children:r.map(n=>e(`option`,{value:n.id,children:[n.displayName,ve(n)?``:` (${t(`recordings.storageMigrationSection.readOnly`)})`]},n.id))})]}),e(`div`,{className:`space-y-1`,children:[i(`label`,{htmlFor:`migration-dest-${n.id}`,className:`text-[10px] text-foreground-subtle`,children:t(`recordings.storageMigrationSection.classTo`,{label:t(n.labelKey)})}),e(N,{id:`migration-dest-${n.id}`,value:s[n.id]??``,onChange:e=>{let t=e.target.value;c(e=>({...e,[n.id]:t}))},disabled:b,className:`w-full`,children:[i(`option`,{value:``,children:t(`migration.storageMigrationSection.skip`,`— skip —`)}),r.map(e=>i(`option`,{value:e.id,children:e.displayName},e.id))]})]})]},n.id)})}),p&&i(`p`,{className:`mt-2 text-[11px] text-danger`,children:p}),e(`div`,{className:`mt-3 flex items-center gap-2`,children:[e(H,{variant:`unstyled`,type:`button`,onClick:()=>{ee()},disabled:!x||w.isFetching||b,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:[w.isFetching&&i(V,{className:`h-3 w-3 animate-spin`}),t(`migration.storageMigrationSection.plan`,`Plan`)]}),e(H,{variant:`unstyled`,type:`button`,onClick:()=>{D()},disabled:!x||T.isPending||b,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:[T.isPending&&i(V,{className:`h-3 w-3 animate-spin`}),t(`migration.storageMigrationSection.startMigration`,`Start migration`)]})]}),d&&i(`div`,{className:`mt-3 divide-y divide-border rounded-md border border-border`,children:d.moves.length===0?i(`p`,{className:`px-2.5 py-1.5 text-[11px] text-foreground-subtle`,children:t(`migration.storageMigrationSection.nothingToMoveSelectedDestinations`,`Nothing to move — selected destinations match the current defaults.`)}):d.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}`))}),y&&e(`div`,{className:`mt-4 border-t border-border pt-3`,children:[e(`div`,{className:`flex items-center justify-between`,children:[i(`h4`,{className:`text-xs font-semibold text-foreground`,children:t(`migration.storageMigrationSection.migrationStatus`,`Migration status`)}),b&&e(H,{variant:`unstyled`,type:`button`,onClick:()=>{O()},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:[i(g,{className:`h-3 w-3`}),t(`common.cancel`,`Cancel`)]})]}),e(`p`,{className:`mt-1 text-xs text-foreground`,children:[t(`migration.storageMigrationSection.phase`,`Phase:`),` `,i(`span`,{className:`font-medium`,children:y.phase}),b&&i(V,{className:`ml-2 inline h-3 w-3 animate-spin text-primary`})]}),y.error&&i(`p`,{className:`mt-1 text-[11px] text-danger`,children:y.error}),y.pausedParticipants.length>0&&e(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:[t(`migration.storageMigrationSection.paused`,`Paused:`),` `,y.pausedParticipants.join(`, `)]}),i(`div`,{className:`mt-2 divide-y divide-border rounded-md border border-border`,children:y.moves.map(e=>i(Cs,{move:e},`${e.storageClass}-${e.fromLocationId}`))})]}),i(ws,{})]}),i(Ts,{running:b}),i(Ds,{})]})}function Cs({move:t}){let{t:n}=J(),r=t.progress===null?null:gs(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:[r!==null&&r.fraction!==null&&i(`div`,{className:`h-1 w-full overflow-hidden rounded bg-border`,children:i(`div`,{className:`h-full bg-primary`,style:{width:`${(r.fraction*100).toFixed(1)}%`}})}),i(`p`,{className:`text-[10px] text-foreground-subtle`,children:_s(t.progress)})]})]})}function ws(){let{t}=J(),{data:n}=vt({});return!n||n.length===0?null:e(`div`,{className:`mt-4 border-t border-border pt-3`,children:[i(`h4`,{className:`text-xs font-semibold text-foreground`,children:t(`migration.storageMigrationSection.migrationHistory`,`Migration history`)}),i(`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:[i(`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 Ts({running:t}){let{t:n}=J(),r=L(),a=St({},{staleTime:1/0,refetchOnWindowFocus:!1}),s=pt(),[c,l]=o(null),u=a.data??[];if(u.length===0)return null;let d=async e=>{if(await r({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 a.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:[i(`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:[i(`span`,{className:`text-[10px] text-foreground-subtle`,children:a.dataUpdatedAt>0?n(`migration.storageMigrationSection.measured`,`Measured {{value1}}`,{value1:new Date(a.dataUpdatedAt).toLocaleTimeString()}):n(`migration.storageMigrationSection.measuredNever`,`Measured — never`)}),i(H,{variant:`unstyled`,type:`button`,onClick:()=>{a.refetch()},disabled:a.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:a.isFetching?n(`migration.storageMigrationSection.counting`,`Counting…`):n(`common.refresh`,`Refresh`)})]})]}),i(`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.`)}),i(`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&&i(`p`,{className:`mt-2 text-[11px] text-danger`,children:c}),i(`div`,{className:`mt-2 divide-y divide-border rounded-md border border-border`,children:u.map(r=>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:[r.storageClass,`: `,r.fromLocationId,` → `,r.toLocationId,i(`span`,{className:`ml-2 text-foreground-subtle`,children:Es(r)})]}),i(H,{variant:`unstyled`,type:`button`,onClick:()=>{d(r)},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`)})]},`${r.storageClass}-${r.fromLocationId}`))})]})}function Es(e){if(e.items===null)return q.t(`recordings.storageMigrationSection.residueUnknown`);let t=e.items.toLocaleString(`en-US`);return e.bytes===null?q.t(`recordings.storageMigrationSection.residueRows`,{count:e.items,items:t}):q.t(`recordings.storageMigrationSection.residueSegments`,{count:e.items,items:t,size:Y(e.bytes)})}function Ds(){let{t}=J(),{data:n}=Lt({},{refetchInterval:2e3}),r=(n??[]).filter(e=>e.migrationJobId===null&&e.job.state===`running`);return r.length===0?null:e(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[i(`h3`,{className:`text-sm font-semibold text-foreground`,children:t(`migration.storageMigrationSection.moversRunningOutsideAMigration`,`Movers running outside a migration`)}),i(`div`,{className:`mt-2 divide-y divide-border rounded-md border border-border`,children:r.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]}),i(`p`,{className:`mt-1 text-[10px] text-foreground-subtle`,children:_s({filesMoved:t.job.filesMoved,filesTotal:t.job.filesTotal,bytesMoved:t.job.bytesMoved,startedAt:t.job.startedAt,observedAt:t.observedAt})})]},t.job.jobId))})]})}c();function Os({openOnMount:t}){let{t:n}=J(),[r,s]=o(t);return a(()=>{t&&s(!0)},[t]),i(Ye,{expanded:r,onExpandedChange:s,header:e(`span`,{className:`flex items-center gap-2 text-sm font-medium text-foreground`,children:[i(v,{className:`h-3.5 w-3.5`}),n(`archive.tools.title`,`Tools`),i(`span`,{className:`text-[11px] font-normal text-foreground-subtle`,children:n(`archive.tools.subtitle`,`Storage migration, prune events, cleanup, reconcile from disk`)})]}),children:e(`div`,{className:`flex flex-col gap-6`,"data-testid":`archive-tools`,children:[e(`section`,{className:`flex flex-col gap-2`,children:[i(`h3`,{className:`text-sm font-semibold text-foreground`,children:n(`archive.tools.migration`,`Move storage`)}),i(`p`,{className:`text-[11px] text-foreground-subtle`,children:n(`archive.tools.migrationHint`,`Copy footage, low-res footage or event media to a new location, verify, then repoint the default. Applies to every camera.`)}),i(xs,{})]}),e(`section`,{className:`flex flex-col gap-2`,children:[i(`h3`,{className:`text-sm font-semibold text-foreground`,children:n(`archive.tools.pruneEvents`,`Prune old events`)}),i(ns,{})]}),i(ss,{}),i(us,{})]})})}c();function ks({data:t}){let{t:n}=J(),{hash:r}=en();return a(()=>{r.length>1&&document.getElementById(r.slice(1))?.scrollIntoView({block:`start`})},[r]),e(`div`,{className:`flex flex-col gap-4`,children:[i(Xo,{data:t}),i(Le,{headingId:`archive-storage`,title:n(`archive.section.storage`,`Storage`),icon:w,children:i(`div`,{className:`p-3`,children:i(Qo,{})})}),i(Le,{headingId:`archive-cameras`,title:n(`archive.section.cameras`,`Cameras`),icon:S,children:i(Wo,{rows:t.rows,isLoading:t.isLoading})}),i(`div`,{id:`activity`,children:i(Le,{headingId:`archive-activity`,title:n(`archive.section.activity`,`Activity & health`),icon:M,children:i(`div`,{className:`p-3`,children:i(Kn,{data:t})})})}),i(`div`,{id:`tools`,children:i(Os,{openOnMount:r===`#tools`})})]})}c();function As(){let e=Ue({isCamera:!0,projection:`slim`}),t=Dt({},{refetchOnWindowFocus:!1}),r=Ee({},{refetchOnWindowFocus:!1}),i=Jt({},{refetchOnWindowFocus:!1}),a=Ge({history:1},{refetchOnWindowFocus:!1}),o=n(()=>(e.data??[]).map(e=>({id:e.id,name:e.name})).toSorted((e,t)=>e.name.localeCompare(t.name)),[e.data]),s=t.data??null,c=s!==null&&s.devicesRead!==`unavailable`,l=r.data??null,u=i.data??null,d=a.data?.latest??null,f=d===null?null:d.findings,p=n(()=>ar({cameras:o,footage:c?s.devices:null,events:l===null?null:l.devices,statuses:u,findings:f}),[o,c,s,l,u,f]);return{cameras:o,rows:p,totals:n(()=>or(p),[p]),usage:s,footprint:l,statuses:u,findings:f,digestAtMs:d===null?null:d.generatedAt,isLoading:e.isLoading||t.isLoading||r.isLoading}}function js(){let{t:e}=J(),t=As();return i(mn,{icon:xe,title:e(`nav.archive`,`Archive`),subtitle:e(`archive.subtitle`,`Recorded footage and captured events — what they occupy, where they are written, and how each camera is doing.`),paramName:pn,defaultSection:`overview`,sectionsLabel:e(`archive.sections`,`Archive sections`),sections:[{id:`overview`,label:e(`archive.section.overview`,`Overview`),content:i(ks,{data:t})},{id:`cameras`,label:e(`archive.section.cameras`,`Cameras`),ownedParams:[ln,dn],content:i(Vo,{data:t})}]})}export{js as ArchivePage};
|