@camstack/addon-admin-ui 1.2.435 → 1.2.436
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/dist/assets/{AddonAssetIcon-DwyvMm0j.js → AddonAssetIcon-BPpbpBRb.js} +1 -1
- package/dist/assets/Addons-BKpZvzxZ.js +4 -0
- package/dist/assets/{AdminPage-Dla2hgly.js → AdminPage-Dq8Ikceb.js} +1 -1
- package/dist/assets/{AdminSectionedPage-C6laWV2D.js → AdminSectionedPage-CMXlVHaE.js} +1 -1
- package/dist/assets/AiProfiles-BNa-wvuk.js +3 -0
- package/dist/assets/{BrokerForm-XPsm7VqN.js → BrokerForm-CTEvkdiJ.js} +1 -1
- package/dist/assets/Build-BtwPkUNT.js +40 -0
- package/dist/assets/{Calendars-D9aQ6xfy.js → Calendars-BDEesia0.js} +1 -1
- package/dist/assets/Cluster-CPOYtnsH.js +1 -0
- package/dist/assets/ClusterStepModel-CD3lGILg.js +1 -0
- package/dist/assets/{CompositionEditor-Djw5jKF1.js → CompositionEditor-thMDSEPc.js} +1 -1
- package/dist/assets/CompositionEditorPage-sur0OoTs.js +1 -0
- package/dist/assets/Data-DYZzdYTt.js +2 -0
- package/dist/assets/DeviceDetail-Dfkdbk5S.js +2 -0
- package/dist/assets/{DeviceDoActionFields-DLWA9-J9.js → DeviceDoActionFields-C3Dz4KrE.js} +1 -1
- package/dist/assets/{Devices-C1k3PqRv.js → Devices-xUTbIFJe.js} +1 -1
- package/dist/assets/{EmbedPlayerPage-Dz0lVYTn.js → EmbedPlayerPage-DYCZQ47V.js} +1 -1
- package/dist/assets/Identity-DRemX8Kt.js +1 -0
- package/dist/assets/IntegrationDetail-CVONA8Vu.js +1 -0
- package/dist/assets/IntegrationHub-CKPuIBCW.js +1 -0
- package/dist/assets/{Integrations-B3EhTwi-.js → Integrations-D8689xLx.js} +1 -1
- package/dist/assets/Integrations-RmhoSCir.js +1 -0
- package/dist/assets/{Library-BLUxFISX.js → Library-bvbXCasj.js} +1 -1
- package/dist/assets/Locations-DvnbXzXE.js +3 -0
- package/dist/assets/{Logs-C5wdcV2o.js → Logs-BCis7K87.js} +1 -1
- package/dist/assets/{MaskShapeCanvas-WPSz6MvT.js → MaskShapeCanvas-BDELFcW-.js} +1 -1
- package/dist/assets/{MotionZonesSettings-CxZucl1G.js → MotionZonesSettings-B4Sz3Hxi.js} +1 -1
- package/dist/assets/MyAccess-SjNSbZFI.js +2 -0
- package/dist/assets/Network-BvT1oKui.js +1 -0
- package/dist/assets/{NodeAddonsSettingsPanel-CSyREPja.js → NodeAddonsSettingsPanel-DPOu3bzA.js} +1 -1
- package/dist/assets/Notifications-CdyKO4mW.js +1 -0
- package/dist/assets/{PrivacyMaskSettings-DQ7Xe8cq.js → PrivacyMaskSettings-DHIoMgiM.js} +1 -1
- package/dist/assets/Recordings-DaqBEWTR.js +1 -0
- package/dist/assets/{ScanNetworkModal-Dw7_YiJk.js → ScanNetworkModal-C5ek4_xr.js} +1 -1
- package/dist/assets/{SceneMonitorEditor-CQtUJ-Cg.js → SceneMonitorEditor-BPo9HYQH.js} +1 -1
- package/dist/assets/SessionsList-CLdfIlct.js +2 -0
- package/dist/assets/{Showroom-DZRq9gks.js → Showroom-DNWKiETZ.js} +1 -1
- package/dist/assets/{System-n6EeqhH2.js → System-BEpuTl2A.js} +1 -1
- package/dist/assets/{Terminal-Dt_ribAu.js → Terminal-CZxQeSQv.js} +3 -3
- package/dist/assets/{Viewer-DbBh61dj.js → Viewer-DRzTXkJf.js} +1 -1
- package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-CEvIRFB4.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-C5raVFJt.js} +1 -1
- package/dist/assets/{addon-icons-context-r49093mC.js → addon-icons-context-PT674I68.js} +1 -1
- package/dist/assets/{archive-CgDcyTmT.js → archive-Ciq6-gRM.js} +1 -1
- package/dist/assets/{authed-media-CN55sP4S.js → authed-media-Dj1jG_u8.js} +1 -1
- package/dist/assets/{bell-off-CdHPL528.js → bell-off-BSKweN0I.js} +1 -1
- package/dist/assets/{board-model-DXmUHcnO.js → board-model-5GbhsRIK.js} +1 -1
- package/dist/assets/{boxes-DJvrVSZy.js → boxes-Be_6S2Ig.js} +1 -1
- package/dist/assets/circle-slash-CtNDkZYp.js +1 -0
- package/dist/assets/client-CPwvt_HG.js +358 -0
- package/dist/assets/{cloud-upload-BkTrXwKr.js → cloud-upload-B9nCTjv1.js} +1 -1
- package/dist/assets/crop-D5vMVrdf.js +1 -0
- package/dist/assets/{device-integration-icon-CViPS882.js → device-integration-icon-C31xC4qv.js} +1 -1
- package/dist/assets/device-picker-model-zmV5eDza.js +1 -0
- package/dist/assets/{dist-0P_zMe7Y.js → dist-B6sP5E_m.js} +1 -1
- package/dist/assets/dist-Sy-AM1_J.js +358 -0
- package/dist/assets/{eraser-BCiOGK5K.js → eraser-BIioNznG.js} +1 -1
- package/dist/assets/{hard-drive-download-Df-zlQQG.js → hard-drive-download-B4JsHavv.js} +1 -1
- package/dist/assets/{history-CWpQe6k9.js → history-DjLzg0Rr.js} +1 -1
- package/dist/assets/{hostInit-Cnw529bc.js → hostInit-BwwyWMg1.js} +1 -1
- package/dist/assets/i18n-GaxP0h6E.js +1 -0
- package/dist/assets/{icons-aI8aLvw4.js → icons-4P43FpmR.js} +1 -1
- package/dist/assets/index-i0Y8_-ur.css +2 -0
- package/dist/assets/{index-DkNBNJNl.js → index-tgPOSbne.js} +3 -3
- package/dist/assets/{key-CZcpRn4A.js → key-BMcy7xHz.js} +1 -1
- package/dist/assets/{key-round-BBPO5HDK.js → key-round-C__KHy-x.js} +1 -1
- package/dist/assets/{layers-DLOgDOBH.js → layers-Dbn6yDeS.js} +1 -1
- package/dist/assets/{linked-devices-model-f_SAvOZs.js → linked-devices-model-D8dKG29p.js} +1 -1
- package/dist/assets/{list-ordered-BaNkdvWk.js → list-ordered-CwWFTuog.js} +1 -1
- package/dist/assets/{location-owned-usage-BFxIuzRL.js → location-owned-usage-kz2UtPi1.js} +1 -1
- package/dist/assets/{log-in-CL3_o1dD.js → log-in-D-fa0CNC.js} +1 -1
- package/dist/assets/{memory-stick-CHkvUw7C.js → memory-stick-BNvRqOgn.js} +1 -1
- package/dist/assets/{message-square-plus-CIeWtcNn.js → message-square-plus-yiE3dC2J.js} +1 -1
- package/dist/assets/{mf-entry-bootstrap-0-657dd3ff.js → mf-entry-bootstrap-0-3d7ac4be.js} +2 -2
- package/dist/assets/{mic-off-DS8OGDQW.js → mic-off-Ct9OQSHX.js} +1 -1
- package/dist/assets/{monitor-off-DC9Xug5Z.js → monitor-off-gNZ5sErH.js} +1 -1
- package/dist/assets/{monitor-smartphone-CS_5BZqr.js → monitor-smartphone-B9ZL4epZ.js} +1 -1
- package/dist/assets/mount-zmV5eDza.js +1 -0
- package/dist/assets/{notification-schedule-field-aMkV5LtX.js → notification-schedule-field-91fTFul7.js} +1 -1
- package/dist/assets/{octagon-alert-Cdtac8l_.js → octagon-alert-CkSZIflH.js} +1 -1
- package/dist/assets/{player-overlays-CZXV2ES3.js → player-overlays-CVyuEj4x.js} +1 -1
- package/dist/assets/{recycle-wY_-o-u0.js → recycle-CH0GJM3I.js} +1 -1
- package/dist/assets/remoteEntry-CEVdKgl-.js +1 -0
- package/dist/assets/{scan-eye-A6IBODIs.js → scan-eye-D6obPT9p.js} +1 -1
- package/dist/assets/{scissors-BzZpfzIa.js → scissors-BXMmNEgj.js} +1 -1
- package/dist/assets/{search-x-DqjVJK7_.js → search-x-ByAKuo4f.js} +1 -1
- package/dist/assets/{send-BDCQEx8-.js → send-CholqiEk.js} +1 -1
- package/dist/assets/{settings-2-BBgeb4tF.js → settings-2-3k9hj27t.js} +1 -1
- package/dist/assets/{speaker-Bw_8wVkA.js → speaker-Ca4eeGU9.js} +1 -1
- package/dist/assets/src-D7EY8vSW.js +67 -0
- package/dist/assets/{timer-reset-CNH944ar.js → timer-reset-bq-8RFf6.js} +1 -1
- package/dist/assets/{ungroup-D4fdKtA6.js → ungroup-DMrJzuO_.js} +1 -1
- package/dist/assets/{unlink-BKDNubwr.js → unlink-CgiLXfCU.js} +1 -1
- package/dist/assets/{usb-CU5DhEWn.js → usb-BpqC1Eim.js} +1 -1
- package/dist/assets/{use-scenes-feed-Bk660KRI.js → use-scenes-feed-CtmmYk4L.js} +1 -1
- package/dist/assets/{use-stationary-objects-BVxOU14q.js → use-stationary-objects-DsURgc1b.js} +1 -1
- package/dist/assets/useEventInvalidation-zmV5eDza.js +1 -0
- package/dist/assets/{useNodeUrlSelection-Bg0rHiIl.js → useNodeUrlSelection-nj7EK04j.js} +1 -1
- package/dist/assets/user-round-B0EP32hl.js +1 -0
- package/dist/assets/{user-x-DRzptq94.js → user-x-CpjXT41_.js} +1 -1
- package/dist/assets/{video-CEzO-5-D.js → video-BAANd9N-.js} +1 -1
- package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-DzDhE-1_.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-Bp8_lhik.js} +2 -2
- package/dist/index.html +11 -11
- package/dist/server/addon.js +44 -22
- package/package.json +1 -1
- package/dist/assets/Addons-N1hcMjwi.js +0 -4
- package/dist/assets/AiProfiles-CW5cr9nz.js +0 -3
- package/dist/assets/Build-Dg7gaee7.js +0 -40
- package/dist/assets/Cluster-NV3ZrTk7.js +0 -1
- package/dist/assets/ClusterStepModel-BUROhnKA.js +0 -1
- package/dist/assets/CompositionEditorPage-BNAhOgDE.js +0 -1
- package/dist/assets/Data-Bkq3Cr_h.js +0 -2
- package/dist/assets/DeviceDetail-BR_FSl-i.js +0 -2
- package/dist/assets/Identity-CJN1MNrJ.js +0 -1
- package/dist/assets/IntegrationDetail-DomJ4oV8.js +0 -1
- package/dist/assets/IntegrationHub-BTJM3uSD.js +0 -1
- package/dist/assets/Integrations-w1Zb-AYc.js +0 -1
- package/dist/assets/Locations-5WWzr64x.js +0 -3
- package/dist/assets/MyAccess-2bAujGDI.js +0 -2
- package/dist/assets/Network-DFt5Vib8.js +0 -1
- package/dist/assets/Notifications-KG9O3i8q.js +0 -1
- package/dist/assets/Recordings-BbQTlUaN.js +0 -1
- package/dist/assets/SessionsList-BuiRHWv-.js +0 -2
- package/dist/assets/circle-slash-BvkFL8F1.js +0 -1
- package/dist/assets/client-CVIfL49c.js +0 -358
- package/dist/assets/crop-DUVdBcFC.js +0 -1
- package/dist/assets/device-picker-model-mxypQ5EF.js +0 -1
- package/dist/assets/dist-U5_IP253.js +0 -358
- package/dist/assets/i18n-CmGpgquB.js +0 -1
- package/dist/assets/index-DKqvG7BE.css +0 -2
- package/dist/assets/mount-mxypQ5EF.js +0 -1
- package/dist/assets/remoteEntry-BFNP-i5_.js +0 -1
- package/dist/assets/src-DOs8Kg5s.js +0 -67
- package/dist/assets/useEventInvalidation-mxypQ5EF.js +0 -1
- package/dist/assets/user-round-CYlbEszq.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-Cyuzqnbw.js";import{$ as t,B as n,G as r,J as i,L as a,S as o,b as s,i as c,o as l,p as u,q as d,x as f}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEHpkaJP.js";import{A as p,D as m,It as h,Jr as g,Mn as _,N as v,Nr as y,Nt as b,O as x,Qi as S,T as C,Tr as w,V as T,Xt as E,Yn as D,_i as O,_t as k,ar as A,b as j,bn as M,dt as N,ia as P,j as F,k as I,lr as L,nr as ee,ot as te,pn as ne,rr as re,sn as R,un as z,ut as ie,v as ae,y as oe,yi as se,yn as ce,z as B}from"./player-overlays-CZXV2ES3.js";import{c as le,l as ue,t as de}from"./video-CEzO-5-D.js";import{a as fe,i as pe,n as me,r as he,t as ge}from"./usb-CU5DhEWn.js";import{t as _e}from"./crop-DUVdBcFC.js";import{t as ve}from"./layers-DLOgDOBH.js";import{An as ye,Dn as be,En as xe,Gr as Se,Kr as Ce,Mn as we,On as Te,Ti as Ee,Tn as De,c as Oe,jn as ke,kn as Ae,l as je,m as Me,vi as Ne,wn as Pe}from"./client-CVIfL49c.js";import{n as Fe}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_trpc_mf_1_react_mf_2_query__loadShare__.js-DdJYWyu3.js";import{$l as Ie,An as Le,Bn as V,Bs as Re,C as ze,Cs as Be,Dn as Ve,Ds as He,E as Ue,En as We,Es as Ge,F as Ke,Gs as qe,H as Je,Is as Ye,J as Xe,Jl as Ze,Js as Qe,Jt as $e,Ln as et,Ls as tt,Ms as nt,Mt as rt,O as it,On as at,Os as ot,Rn as st,S as ct,Ss as lt,T as ut,Tn as dt,Ts as ft,Tt as pt,Us as mt,Ut as ht,Vs as gt,Vt as H,W as _t,Ws as vt,Wt as yt,Xs as bt,Y as xt,Ys as St,Yt as Ct,Zn as wt,Zs as Tt,_n as Et,_r as Dt,_u as Ot,an as kt,ar as U,bs as At,cc as jt,cn as Mt,dc as Nt,dn as Pt,eu as Ft,gu as It,ha as Lt,hn as Rt,hu as zt,in as Bt,jn as Vt,kn as Ht,lc as Ut,ln as Wt,mn as Gt,mr as Kt,mu as W,oc as qt,ou as Jt,pc as Yt,pn as Xt,pr as Zt,qs as Qt,qt as $t,r as en,sc as tn,sn as nn,su as rn,uc as an,un as on,vn as sn,vt as cn,vu as ln,w as un,wn as dn,ws as fn,xs as pn,yu as mn,zs as hn}from"./src-DOs8Kg5s.js";import{t as G}from"./i18n-CmGpgquB.js";import{t as K}from"./useTranslation-D3Is_4B6.js";import{U as gn,X as _n,Y as vn,et as yn}from"./index-DkNBNJNl.js";import"./useEventInvalidation-mxypQ5EF.js";import{t as bn}from"./NodeAddonsSettingsPanel-CSyREPja.js";import{a as xn,c as Sn,d as Cn,g as wn,h as Tn,i as En,l as Dn,n as On,o as kn,p as An,r as jn,s as Mn,t as Nn}from"./board-model-DXmUHcnO.js";var Pn=`step`,Fn=[Pn,`acc`];function In(e,t){return`${e}/${t}`}function Ln(e,t,n){let r=n.step!==null&&e.includes(n.step),i=n.acc!==null&&t.includes(n.acc);return{stepId:r?n.step:null,acceleratorId:i?n.acc:null,staleStepId:n.step!==null&&n.step!==``&&!r&&e.length>0?n.step:null}}function Rn(e){if(e==null)return null;if(typeof e==`number`)return e>0?e:null;let t=Date.parse(e);return Number.isNaN(t)?null:t}function zn(e){return e}function Bn(e,t){for(let[n,r]of Object.entries(e??{}))if(n===t)return r}function Vn(e,t){return typeof e==`boolean`?e:zn(t)}function Hn(e,t){return{pipeline:Vn(Bn(e,`detect`),t),audio:Vn(Bn(e,`audio`),t),ingest:Vn(Bn(e,`ingest`),t)}}function Un(e,t,n){let r=e?.find(e=>e.nodeId===t);return Hn(r?.settings,n)}function Wn({selectedNodeId:e,onSelect:t,refreshToken:n}){let r=P(),{t:i}=K(),{nodes:a}=zt(),{data:c}=hn(void 0),{data:l}=mt(void 0),u=new Map;for(let e of c??[])u.set(e.agentNodeId,(u.get(e.agentNodeId)??0)+1);let d=a??[],p=d.filter(e=>e.isOnline).length,m=d.filter(e=>!e.isOnline).length;return o(`div`,{className:`flex flex-col h-full`,children:[o(`button`,{type:`button`,onClick:()=>t(Mo),className:`flex items-center gap-3 px-4 py-3 border-b border-border text-left transition-colors ${e===`__cluster__`?`bg-primary/10 text-primary`:`text-foreground hover:bg-surface-hover`}`,children:[f(le,{className:`h-4 w-4 flex-shrink-0`}),o(`div`,{className:`min-w-0 flex-1`,children:[f(`div`,{className:`text-xs font-semibold truncate`,children:i(`pipeline.nodeList.cluster`,`Cluster`)}),f(`div`,{className:`text-[10px] text-foreground-subtle`,children:i(`pipeline.nodeList.assignmentsLoadBalancingRoles`,`Assignments, load balancing, roles`)})]})]}),f(`div`,{className:`flex-1 overflow-y-auto`,children:d.map(n=>{let a=e===n.id,c=u.get(n.id)??0,d=n.isHub?z:g,p=Un(l,n.id,n.isHub),m=n.isOnline?null:cn(Rn(n.lastSeen),r);return o(`button`,{type:`button`,onClick:()=>t(n.id),className:`flex items-center gap-3 w-full px-4 py-3 border-b border-border text-left transition-colors ${a?`bg-primary/10 text-primary`:`text-foreground hover:bg-surface-hover`}${n.isOnline?``:` opacity-60`}`,children:[f(d,{className:`h-4 w-4 flex-shrink-0`}),o(`div`,{className:`min-w-0 flex-1`,children:[o(`div`,{className:`flex items-center gap-2`,children:[f(`span`,{className:`text-xs font-semibold truncate`,children:n.name}),n.isHub&&f(`span`,{className:`text-[9px] uppercase tracking-wider text-foreground-subtle border border-border rounded px-1 py-0.5`,children:i(`common.hubWord`)}),!n.isOnline&&f(`span`,{className:`h-1.5 w-1.5 rounded-full bg-danger flex-shrink-0`}),n.isOnline&&f(`span`,{className:`h-1.5 w-1.5 rounded-full bg-success flex-shrink-0`})]}),o(`div`,{className:`text-[10px] text-foreground-subtle flex items-center gap-2 mt-0.5`,children:[f(`span`,{children:i(`common.coresCount`,{count:n.cpuCores})}),f(`span`,{children:`•`}),o(`span`,{children:[Math.round(n.memoryMB/1024),` GB`]}),c>0&&o(s,{children:[f(`span`,{children:`•`}),o(`span`,{className:`inline-flex items-center gap-0.5 text-foreground`,children:[f(de,{className:`h-2.5 w-2.5`}),c]})]}),!n.isOnline&&o(s,{children:[f(`span`,{children:`•`}),o(`span`,{className:`text-danger`,children:[i(`common.offline`),m===null?``:` · ${m}`]})]})]}),o(`div`,{className:`mt-0.5 flex items-center gap-1`,children:[f(U,{variant:p.pipeline?`success`:`danger`,className:`px-1 py-0 text-[9px] leading-3`,title:p.pipeline?i(`pipeline.nodeList.pipelineEnabled`,`Pipeline: enabled`):i(`pipeline.nodeList.pipelineNotEnabledAgentCapability`,`Pipeline: not enabled (agent capability)`),children:i(`pipeline.nodeList.pipe`,`Pipe`)}),f(U,{variant:p.audio?`success`:`danger`,className:`px-1 py-0 text-[9px] leading-3`,title:p.audio?i(`pipeline.nodeList.audioEnabled`,`Audio: enabled`):i(`pipeline.nodeList.audioNotEnabledAgentCapability`,`Audio: not enabled (agent capability)`),children:i(`pipeline.nodeList.aud`,`Aud`)})]})]})]},n.id)})}),o(`div`,{className:`px-4 py-2 border-t border-border text-[10px] text-foreground-subtle flex items-center justify-between`,children:[f(`span`,{children:i(`common.onlineCount`,{count:p})}),m>0&&f(`span`,{className:`text-danger`,children:i(`common.offlineCount`,{count:m})})]})]})}function Gn({nodeId:e,refreshToken:t}){let{t:n}=K(),{nodes:r}=zt(),i=r?.find(t=>t.id===e),a=It(`pipeline.runner-load-snapshot`,t=>t.nodeId===e)?.load??null;return i?o(`div`,{className:`px-6 py-4 border-b border-border`,children:[o(`div`,{className:`flex items-center gap-2 mb-1`,children:[f(`h2`,{className:`text-base font-semibold text-foreground`,children:i.name}),i.isOnline?f(`span`,{className:`text-[10px] px-2 py-0.5 rounded-full bg-success/10 text-success`,children:n(`common.online`)}):f(`span`,{className:`text-[10px] px-2 py-0.5 rounded-full bg-danger/10 text-danger`,children:n(`common.offline`)}),i.isHub&&f(`span`,{className:`text-[9px] uppercase tracking-wider text-foreground-subtle border border-border rounded px-1 py-0.5`,children:n(`common.hubWord`)})]}),o(`div`,{className:`text-[11px] text-foreground-subtle flex items-center gap-2 flex-wrap`,children:[f(`span`,{children:i.cpuModel??`CPU`}),f(`span`,{children:`•`}),f(`span`,{children:n(`common.coresCount`,{count:i.cpuCores})}),f(`span`,{children:`•`}),o(`span`,{children:[Math.round(i.memoryMB/1024),` GB`]}),a&&o(s,{children:[f(`span`,{children:`•`}),f(`span`,{children:n(`pipeline.nodeDetailHeader.cameras`,{attached:a.attachedCameras,active:a.activeCameras})}),f(`span`,{children:`•`}),f(`span`,{children:n(`pipeline.nodeDetailHeader.avgInference`,{ms:a.avgInferenceTimeMs.toFixed(0)})}),f(`span`,{children:`•`}),f(`span`,{children:n(`pipeline.nodeDetailHeader.queue`,{depth:a.queueDepthTotal})}),a.hardware.hasGpu&&o(s,{children:[f(`span`,{children:`•`}),f(`span`,{className:`text-success`,children:`GPU`})]})]})]})]}):f(`div`,{className:`px-6 py-4 border-b border-border`,children:o(`div`,{className:`text-xs text-foreground-subtle`,children:[n(`pipeline.nodeDetailHeader.nodeNotFound`,`Node not found:`),` `,e]})})}var Kn=[`assignments`,`tree`,`engines`,`logs`];t();function qn({refreshToken:e,nodeId:t}){let{t:n}=K(),[a,s]=i(new Map),{nodes:c}=W();ln(`pipeline.camera-metrics-snapshot`,e=>{let t=e.data;typeof t?.deviceId==`number`&&s(e=>{let n=new Map(e);return n.set(t.deviceId,t),n})});let{data:l}=ot(void 0),u=r(()=>{let e=new Map;for(let t of l??[])e.set(t.nodeId,t.deviceCount);return e},[l]),d=r(()=>{let e=new Map,t=Date.now()-3e4;for(let n of a.values()){if(n.timestamp<t)continue;let r=n.nodeId??`hub`,i=e.get(r)??{attachedCameras:0,activeCameras:0,totalFps:0,totalInferenceWeighted:0,queueDepth:0};i.attachedCameras++,n.metrics.phase===`active`&&i.activeCameras++,i.totalFps+=n.metrics.actualFps,i.totalInferenceWeighted+=n.metrics.avgInferenceTimeMs,i.queueDepth+=n.metrics.queueDepth,e.set(r,i)}return e},[a]),p=r(()=>{let e=new Map;for(let t of c)e.set(t.id,t.shortName);return e},[c]),m=r(()=>{let e=0,t=0,n=0,r=0,i=0;for(let a of d.values())e+=a.attachedCameras,t+=a.activeCameras,n+=a.totalFps,r+=a.totalInferenceWeighted,i+=a.queueDepth;let a=e>0?r/e:0;return{totalAgents:c.length,onlineAgents:c.filter(e=>e.isOnline).length,attachedCameras:e,activeCameras:t,avgInferenceTimeMs:a,queueDepth:i,totalFps:n}},[d,c]);if(t){let e=d.get(t);return o(`div`,{className:`@container/liveload`,children:[f(`h3`,{className:`text-sm font-semibold text-foreground mb-2`,children:n(`pipeline.liveLoadPanel.liveLoad`,`Live load`)}),o(`div`,{className:`grid grid-cols-2 @md/liveload:grid-cols-3 @3xl/liveload:grid-cols-5 gap-2 mb-3`,children:[f(q,{label:`FPS`,value:e?e.totalFps.toFixed(1):`—`}),f(q,{label:n(`pipeline.liveLoadPanel.activeAttached`,`Active / Attached`),value:e?`${e.activeCameras}/${e.attachedCameras}`:`—`}),f(q,{label:n(`pipeline.liveLoadPanel.avgInferMs`,`Avg infer ms`),value:e&&e.attachedCameras>0?(e.totalInferenceWeighted/e.attachedCameras).toFixed(0):`—`}),f(q,{label:n(`pipeline.liveLoadPanel.queue`,`Queue`),value:e?String(e.queueDepth):`—`}),f(q,{label:n(`pipeline.liveLoadPanel.audio`,`Audio`),value:String(u.get(t)??`—`)})]})]})}let h=[...d.entries()].toSorted(([e],[t])=>e===`hub`?-1:t===`hub`?1:e.localeCompare(t));return o(`div`,{className:`@container/liveload`,children:[f(`h3`,{className:`text-sm font-semibold text-foreground mb-2`,children:n(`pipeline.liveLoadPanel.liveLoad`,`Live load`)}),o(`div`,{className:`grid grid-cols-2 @md/liveload:grid-cols-3 @3xl/liveload:grid-cols-5 gap-2 sm:gap-3 mb-3`,children:[f(q,{label:n(`pipeline.liveLoadPanel.totalAgents`,`Total agents`),value:`${m.onlineAgents}/${m.totalAgents}`}),f(q,{label:n(`pipeline.liveLoadPanel.activeAttached`,`Active / Attached`),value:`${m.activeCameras}/${m.attachedCameras}`}),f(q,{label:n(`pipeline.liveLoadPanel.totalFps`,`Total FPS`),value:m.totalFps.toFixed(1)}),f(q,{label:n(`pipeline.liveLoadPanel.avgInferenceMs`,`Avg inference ms`),value:m.avgInferenceTimeMs.toFixed(0)}),f(q,{label:n(`pipeline.liveLoadPanel.queueDepth`,`Queue depth`),value:String(m.queueDepth)})]}),f(`div`,{className:`rounded-lg border border-border overflow-x-auto`,children:o(`table`,{className:`w-full text-xs min-w-[480px]`,children:[f(`thead`,{className:`bg-surface`,children:o(`tr`,{className:`text-foreground-subtle text-[10px] uppercase tracking-wider`,children:[f(`th`,{className:`text-left px-3 py-2`,children:n(`pipeline.liveLoadPanel.agent`,`Agent`)}),f(`th`,{className:`text-right px-3 py-2`,children:`FPS`}),f(`th`,{className:`text-right px-3 py-2`,children:n(`pipeline.liveLoadPanel.cameras`,`Cameras`)}),f(`th`,{className:`text-right px-3 py-2`,children:n(`pipeline.liveLoadPanel.inferenceMs`,`Inference ms`)}),f(`th`,{className:`text-right px-3 py-2`,children:n(`pipeline.liveLoadPanel.queue`,`Queue`)}),f(`th`,{className:`text-right px-3 py-2`,children:n(`pipeline.liveLoadPanel.audio`,`Audio`)})]})}),o(`tbody`,{children:[h.map(([e,t])=>o(`tr`,{className:`border-t border-border`,children:[f(`td`,{className:`px-3 py-2 text-foreground font-medium`,children:p.get(e)??e}),f(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t.totalFps.toFixed(1)}),f(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t.attachedCameras}),f(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t.attachedCameras>0?(t.totalInferenceWeighted/t.attachedCameras).toFixed(0):`—`}),f(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t.queueDepth}),f(`td`,{className:`px-3 py-2 text-right text-foreground`,children:u.get(e)??`—`})]},e)),h.length===0&&f(`tr`,{children:f(`td`,{colSpan:6,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:n(`pipeline.liveLoadPanel.noCameraMetricsReceivedYet`,`No camera metrics received yet`)})})]})]})})]})}function q({label:e,value:t}){return o(`div`,{className:`rounded-lg border border-border bg-surface/60 p-3`,children:[f(`div`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle mb-1`,children:e}),f(`div`,{className:`text-lg font-semibold text-foreground`,children:t})]})}var Jn={active:!1,pinned:!1,nodeId:null,reason:``};function Yn(e,t){return e.deviceName.localeCompare(t.deviceName)||e.deviceId-t.deviceId}function Xn(e,t,n){let r=new Map(t.map(e=>[e.deviceId,e])),i=new Map(n.map(e=>[e.deviceId,e]));return e.map(e=>{let t=r.get(e.id),n=i.get(e.id),a=t?{active:!0,pinned:t.pinned,nodeId:t.agentNodeId,reason:t.reason??``}:Jn,o=n?{active:!0,pinned:n.pinned,nodeId:n.nodeId,reason:``}:Jn;return{deviceId:e.id,deviceName:e.name,disabled:e.disabled===!0,pipeline:a,detection:a,decoder:Jn,audio:o}}).toSorted(Yn)}function Zn(e,t,n){return{active:e!==null,pinned:t,nodeId:e,reason:n??``}}function Qn(e,t){let n=new Map(t.map(e=>[e.deviceId,e.assignment]));return e.map(e=>{let t=n.get(e.deviceId);return t===void 0?e:{...e,detection:Zn(t.detectionNodeId,t.pinned.detection,t.reasons.detection),decoder:Zn(t.decoderNodeId,t.pinned.decoder,t.reasons.decoder),audio:Zn(t.audioNodeId,t.pinned.audio,t.reasons.audio)}})}function $n(e,t,n){let r=(t,n,r)=>({active:t!==null&&t===e,pinned:n,nodeId:t,reason:r??``});return t.map(({deviceId:e,assignment:t})=>({deviceId:e,deviceName:n(e),detection:r(t.detectionNodeId,t.pinned.detection,t.reasons.detection),decoder:r(t.decoderNodeId,t.pinned.decoder,t.reasons.decoder),audio:r(t.audioNodeId,t.pinned.audio,t.reasons.audio)})).filter(e=>e.detection.active||e.decoder.active||e.audio.active).toSorted(Yn)}function er(e){let t=new Map(e.map(e=>[e.id,e.name]));return e=>{let n=t.get(e);return n!==void 0&&n!==``?n:e}}function tr(e){let t=new Map(e.map(e=>[e.id,e.name]));return e=>t.get(e)??G.t(`helpers.assignmentRows.cameraFallback`,{id:e})}function nr(e,t,n){let r=[...new Set([...e.nodeId===null?[]:[e.nodeId],...t.map(e=>e.id)])];return[{value:`auto`,label:G.t(`helpers.assignmentRows.auto`)},...r.map(e=>({value:e,label:G.t(`helpers.assignmentRows.pinTo`,{node:n(e)})}))]}function rr({roleId:e,roleLabel:t,state:n,nameOf:r,colorByNodeId:i,emphasizeOnNodeId:a}){if(n.nodeId===null)return null;let o=n.nodeId,s=a===void 0?!1:n.active&&o===a;return f($t,{roleId:e,roleLabel:t,nodeName:r(o),colorId:Ct(i,o),emphasized:s,pinned:n.pinned})}function ir({detection:e,decoder:t,audio:n,nameOf:r,colorByNodeId:i,emphasizeOnNodeId:a}){let s=(e,t,n)=>f(rr,{roleId:e,roleLabel:t,state:n,nameOf:r,colorByNodeId:i,emphasizeOnNodeId:a},e);return o(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1.5`,children:[s(`detection`,`Detection`,e),s(`decode`,`Decode`,t),s(`audio`,`Audio`,n)]})}function ar({snap:e}){let t=P(),{t:n}=K();if(e===void 0)return f(`div`,{className:`flex h-8 items-center text-[11px] text-foreground-subtle`,title:n(`assignments.assignmentStatusCell.noMetricsInTheLast`,`No metrics in the last 10 s — the camera has no session running`),children:n(`assignments.assignmentStatusCell.noLiveData`,`no live data`)});let{phase:r,actualFps:i,avgInferenceTimeMs:a,queueDepth:s,configuredFps:c,droppedFrames:l}=e.metrics,u=rt(r,t);return o(`div`,{className:`flex h-8 min-w-0 flex-col justify-center font-mono text-[10px] leading-tight tabular-nums`,children:[o(`span`,{className:`inline-flex min-w-0 items-center gap-1 ${u.textColor}`,children:[f(Ke,{phase:r,className:`h-2.5 w-2.5 shrink-0`}),f(`span`,{className:`truncate font-semibold uppercase tracking-wider`,children:u.label}),f(`span`,{className:`text-foreground`,children:i.toFixed(1)}),f(`span`,{className:`text-foreground-subtle`,children:n(`pipeline.assignmentStatusCell.configuredFps`,{fps:c.toFixed(0)})})]}),o(`span`,{className:`truncate text-foreground-subtle`,children:[f(`span`,{className:`text-foreground`,children:a.toFixed(0)}),` ms`,s>0&&o(`span`,{className:`ml-1 text-warning`,children:[`q`,s]}),f(`span`,{className:l>0?`ml-1 text-warning`:`ml-1`,children:n(`pipeline.assignmentStatusCell.drops`,{count:l})})]})]})}t();var or=1e4,sr=5e3;function cr(e){let[t,r]=i(new Map);return ln(`pipeline.camera-metrics-snapshot`,t=>{let n=t.data;typeof n.deviceId==`number`&&(e!==void 0&&n.nodeId!==e||r(e=>new Map(e).set(n.deviceId,n)))}),n(()=>{if(t.size===0)return;let e=setInterval(()=>{r(e=>{let t=Date.now()-or,n=[...e].filter(([,e])=>e.timestamp>=t);return n.length===e.size?e:new Map(n)})},sr);return()=>clearInterval(e)},[t.size]),t}var lr=3e5;function ur({state:e,onlineNodes:t,nameOf:n,pending:r,onChange:i}){let{t:a}=K();return f(Ze,{"aria-label":a(`assignments.placementControls.nodePin`,`Node pin`),title:a(`assignments.placementControls.autoLetsEachSessionPick`,`Auto lets each session pick its node; a pin keeps the camera on one node.`),value:e.pinned&&e.nodeId!==null?e.nodeId:`auto`,disabled:r,options:[...nr(e,t,n)],onChange:e=>i(e.target.value)})}function dr({deviceId:e,nodeId:t}){let{t:n}=K(),r=l(),{data:i}=Re({deviceId:e},{refetchOnMount:`always`}),{data:a}=tt({nodeId:t},{staleTime:lr}),o=tn({onSuccess:()=>{r.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineDevicePin`]]})}});if(i===void 0||a===void 0)return f(`span`,{className:`text-[10px] italic text-foreground-subtle`,children:n(`assignments.placementControls.accelerator`,`accelerator: …`)});let s=a.devices??[],c=s.filter(e=>e.enabled),u=i?.deviceKey??`auto`,d=u!==`auto`&&!c.some(e=>e.key===u),p=s.find(e=>e.key===u),m=[{value:`auto`,label:n(`assignments.placementControls.anyAccelerator`,`Any accelerator`)},...d?[{value:u,label:n(`pipeline.placementControls.notEnabled`,{name:p?`${Et(p)} (${u})`:u})}]:[],...c.map(e=>({value:e.key,label:`${Et(e)} · ${e.format}`}))];return f(Ze,{"aria-label":n(`assignments.placementControls.inferenceDevicePin`,`Inference device pin`),title:n(`assignments.placementControls.pinDetectionToOneAccelerator`,`Pin detection to one accelerator of the node, or let each session pick.`),value:u,disabled:o.isPending,options:m,onChange:t=>o.mutate({deviceId:e,deviceKey:t.target.value})})}t();function fr(e){let t=d(null);return e.nodeId!==null&&(t.current=e),t.current}function pr({deviceId:e,state:t,...n}){let{t:r}=K(),i=fr(t);return o(`div`,{className:`grid w-80 grid-cols-2 gap-1.5`,children:[f(ur,{state:t,...n}),i?.nodeId==null?f(Ze,{"aria-label":r(`assignments.clusterRowCells.inferenceDevicePinNoNode`,`Inference device pin (no node yet)`),title:r(`assignments.clusterRowCells.anAcceleratorIsPinnedOn`,`An accelerator is pinned on the camera's node; this camera has not run on one yet.`),disabled:!0,defaultValue:`auto`,options:[{value:`auto`,label:r(`assignments.clusterRowCells.anyAccelerator`,`Any accelerator`)}]}):f(dr,{deviceId:e,nodeId:i.nodeId})]})}function mr({state:e,nameOf:t}){let{t:n}=K(),r=fr(e);if(r?.nodeId==null)return f(`span`,{className:`text-[11px] text-foreground-subtle`,children:n(`assignments.clusterRowCells.noSessionYet`,`— no session yet`)});let i=e.active&&e.nodeId!==null,a=r.pinned?`pinned`:`auto · ${r.reason||`capacity`}`;return o(`div`,{"data-testid":`resolved-placement`,className:`flex w-40 min-w-0 flex-col leading-tight`,title:r.pinned?void 0:n(`assignments.clusterRowCells.anUnpinnedCameraIsPlaced`,`An unpinned camera is placed again at every session start, so this can change between sessions.`),children:[o(`span`,{className:`flex min-w-0 items-center gap-1.5 text-xs`,children:[f(`span`,{"aria-hidden":!0,className:`h-1.5 w-1.5 shrink-0 rounded-full ${i?`bg-success`:`bg-foreground-subtle/40`}`}),f(`span`,{"data-testid":`resolved-placement-node`,className:`truncate font-medium ${i?`text-foreground`:`text-foreground-muted`}`,children:t(r.nodeId)})]}),f(`span`,{className:`truncate pl-3 text-[10px] ${r.pinned?`text-warning`:`text-foreground-subtle`}`,children:i?a:n(`assignments.clusterRowCells.idleLastSession`,`{{how}} · idle, last session`,{how:a})})]})}function hr({deviceId:e,deviceName:t}){let{t:n}=K(),[r,a]=i(!1);return o(s,{children:[f(Ft,{icon:M,variant:`ghost`,size:`sm`,"aria-label":n(`assignments.clusterRowCells.streamBrokersOf`,`Stream brokers of {{deviceName}}`,{deviceName:t}),title:n(`assignments.clusterRowCells.streamBrokersClients`,`Stream brokers & clients`),onClick:()=>a(!0)}),f(dt,{open:r,onOpenChange:a,children:o(Ve,{width:`lg`,scroll:`body`,placement:`sheet-on-mobile`,children:[f(Le,{children:f(Vt,{children:n(`pipeline.clusterRowCells.brokersTitle`,{device:t})})}),f(We,{children:r&&f(dn,{widgetId:`stream-broker/stream-broker-panel`,host:`device-tab`,deviceId:e,instanceId:`pipeline-row/${e}`,config:{variant:`compact`}})})]})})]})}function gr(e){return e.hasFreshMetrics?`active`:e.hasPipelineAssignment?`recently-active`:`inactive`}function _r(e,t){return t.size===0?!0:t.has(e)}var vr=[{value:`active`,get label(){return G.t(`helpers.cameraActivity.active`)}},{value:`recently-active`,get label(){return G.t(`helpers.cameraActivity.recentlyActive`)}},{value:`inactive`,get label(){return G.t(`helpers.cameraActivity.inactive`)}}];t();var yr=[`pipeline.camera-assigned`,`pipeline.camera-unassigned`,`pipeline.camera-updated`,`agent.online`,`agent.offline`];function br(e){for(let t of[`getPipelineAssignments`,`getAudioAssignments`,`getCameraStatuses`])e.invalidateQueries({queryKey:[[`pipelineOrchestrator`,t]]})}function xr(){let{t:e}=K(),t=l();en([`pipelineOrchestrator`,`getPipelineAssignments`],yr),en([`pipelineOrchestrator`,`getAudioAssignments`],yr),en([`pipelineOrchestrator`,`getCameraStatuses`],yr);let{data:n}=Lt({isCamera:!0,projection:`slim`}),{data:a}=hn(void 0),{data:s}=He(void 0),{data:c}=nt({}),{data:u}=mt(void 0),{nodes:d}=W(),p=cr(),m=r(()=>er(d),[d]),h=r(()=>$e(u),[u]),g=r(()=>d.filter(e=>e.isOnline).map(e=>({id:e.id,name:e.name})),[d]),_=r(()=>Qn(Xn((n??[]).map(e=>({id:e.id,name:e.name,disabled:e.disabled})),a??[],s??[]),c??[]),[n,a,s,c]),[v,y]=i(()=>new Set),b=r(()=>_.filter(e=>_r(gr({hasPipelineAssignment:e.pipeline.active,hasFreshMetrics:p.has(e.deviceId)}),v)),[_,p,v]),x=e=>{y(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},S=()=>br(t),C=ft({onSuccess:S}),w=Nt({onSuccess:S}),T=C.isPending||w.isPending,E=[{key:`camera`,header:e(`pipeline.cameraAssignmentsTable.camera`,`Camera`),width:`w-44`,sortValue:e=>e.deviceName,render:t=>o(`div`,{className:`flex w-44 min-w-0 items-center gap-1.5`,children:[f(_n,{to:`/devices/${String(t.deviceId)}`,className:`min-w-0 truncate text-xs font-medium text-primary hover:underline`,title:t.deviceName,children:t.deviceName}),t.disabled&&f(U,{variant:`default`,children:e(`common.off`)})]})},{key:`placement`,header:e(`pipeline.cameraAssignmentsTable.placement`,`Placement`),width:`w-80`,notSortableReason:`A pair of controls — editing one would move the row under the cursor.`,render:e=>f(pr,{deviceId:e.deviceId,state:e.pipeline,onlineNodes:g,nameOf:m,pending:T,onChange:t=>t===`auto`?w.mutate({deviceId:e.deviceId}):C.mutate({deviceId:e.deviceId,agentNodeId:t})})},{key:`roles`,header:e(`pipeline.cameraAssignmentsTable.rolesHere`,`Roles here`),notSortableReason:`A set of roles has no single order.`,render:e=>f(ir,{detection:e.detection,decoder:e.decoder,audio:e.audio,nameOf:m,colorByNodeId:h})},{key:`resolved`,header:e(`pipeline.cameraAssignmentsTable.runningOn`,`Running on`),width:`w-40`,sortValue:e=>e.pipeline.nodeId===null?null:m(e.pipeline.nodeId),render:e=>f(mr,{state:e.pipeline,nameOf:m})},{key:`status`,header:e(`pipeline.cameraAssignmentsTable.status`,`Status`),width:`w-40`,sortValue:e=>p.get(e.deviceId)?.metrics.actualFps??null,render:e=>f(ar,{snap:p.get(e.deviceId)})},{key:`brokers`,header:``,align:`right`,width:`w-10`,notSortableReason:`An action`,render:e=>f(hr,{deviceId:e.deviceId,deviceName:e.deviceName})}],D=n===void 0?`Loading cameras…`:_.length===0?`No cameras`:`No cameras match this activity filter.`;return o(`div`,{className:`flex flex-col gap-2`,children:[f(`nav`,{"aria-label":e(`pipeline.cameraAssignmentsTable.filterByCameraActivity`,`Filter by camera activity`),"data-testid":`assignments-activity-filter`,children:f(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1.5`,children:vr.map(e=>{let t=v.has(e.value);return f(`button`,{type:`button`,"aria-pressed":t,"data-testid":`assignments-activity-${e.value}`,className:rn(oe,t?ae:j),onClick:()=>x(e.value),children:e.label},e.value)})})}),f(ht,{columns:E,rows:b,rowKey:e=>e.deviceId,minWidthPx:920,maxBodyHeight:yt,emptyMessage:D})]})}t();function Sr({nodeId:e}){let{t}=K(),n=l();en([`pipelineOrchestrator`,`getCameraStatuses`],yr);let{data:i}=nt({}),{data:a}=mt(void 0),{data:o}=Lt({isCamera:!0,projection:`slim`}),{nodes:s}=W(),c=cr(),u=r(()=>er(s),[s]),d=r(()=>$e(a),[a]),p=r(()=>$n(e,i??[],tr((o??[]).map(e=>({id:e.id,name:e.name})))),[e,i,o]),m=s.filter(t=>t.isOnline&&t.id!==e),h=()=>br(n),g=ft({onSuccess:h}),_=Nt({onSuccess:h}),v=fn({onSuccess:h}),y=an({onSuccess:h}),b=e=>[...e.detection.active?m.map(n=>({id:`detect-${n.id}`,label:t(`pipeline.nodeCameraAssignmentsTable.moveDetectionTo`,`Move detection to {{name}}`,{name:n.name}),onClick:()=>g.mutate({deviceId:e.deviceId,agentNodeId:n.id})})):[],...e.audio.active?m.map(n=>({id:`audio-${n.id}`,label:t(`pipeline.nodeCameraAssignmentsTable.moveAudioTo`,`Move audio to {{name}}`,{name:n.name}),onClick:()=>v.mutate({deviceId:e.deviceId,nodeId:n.id})})):[],{id:`unpin-detect`,label:t(`pipeline.nodeCameraAssignmentsTable.unpinDetection`,`Unpin detection`),hidden:!(e.detection.active&&e.detection.pinned),separatorBefore:!0,onClick:()=>_.mutate({deviceId:e.deviceId})},{id:`unpin-audio`,label:t(`pipeline.nodeCameraAssignmentsTable.unpinAudio`,`Unpin audio`),hidden:!(e.audio.active&&e.audio.pinned),onClick:()=>y.mutate({deviceId:e.deviceId})}];return f(ht,{columns:[{key:`camera`,header:t(`pipeline.nodeCameraAssignmentsTable.camera`,`Camera`),width:`w-44`,sortValue:e=>e.deviceName,render:e=>f(_n,{to:`/devices/${String(e.deviceId)}`,className:`block w-44 truncate text-xs font-medium text-primary hover:underline`,title:e.deviceName,children:e.deviceName})},{key:`roles`,header:t(`pipeline.nodeCameraAssignmentsTable.rolesHere`,`Roles here`),notSortableReason:`A set of roles has no single order.`,render:t=>f(ir,{detection:t.detection,decoder:t.decoder,audio:t.audio,nameOf:u,colorByNodeId:d,emphasizeOnNodeId:e})},{key:`status`,header:t(`pipeline.nodeCameraAssignmentsTable.status`,`Status`),width:`w-40`,sortValue:e=>c.get(e.deviceId)?.metrics.actualFps??null,render:e=>f(ar,{snap:c.get(e.deviceId)})},{key:`actions`,header:``,align:`right`,width:`w-10`,notSortableReason:`Actions`,render:e=>f(_t,{items:b(e),title:t(`pipeline.nodeCameraAssignmentsTable.move`,`Move {{deviceName}}`,{deviceName:e.deviceName})})}],rows:p,rowKey:e=>e.deviceId,minWidthPx:560,maxBodyHeight:yt,emptyMessage:i===void 0?t(`pipeline.nodeCameraAssignmentsTable.loadingCameras`,`Loading cameras…`):t(`pipeline.nodeCameraAssignmentsTable.noCameraRunsOnThis`,`No camera runs on this node right now`)})}function Cr({nodeId:e,refreshToken:t}){let{t:n}=K(),{nodes:r}=W(),i=r.find(t=>t.id===e)?.name??e;return o(`div`,{className:`space-y-3 sm:space-y-4`,children:[f(qn,{refreshToken:t,nodeId:e}),o(`div`,{className:`space-y-2`,children:[o(`div`,{children:[f(`h3`,{className:`text-sm font-semibold text-foreground`,children:n(`pipeline.nodeCamerasTab.camerasOn`,{node:i})}),f(`p`,{className:`text-[11px] text-foreground-subtle`,children:n(`pipeline.nodeCamerasTab.theRolesEachCameraRuns`,`The roles each camera runs here right now. Move a role or unpin it from the row menu; pins for every camera are on Cluster → Assignments.`)})]}),f(Sr,{nodeId:e})]})]})}t();function wr(e,t){let n=Math.max(0,t-e),r=Math.floor(e/1e3),i=Math.floor(n/1e3);return G.t(`pipeline.nodeEnginesTab.idleLeft`,{idle:r,left:i})}function Tr({nodeId:e,refreshToken:t}){let{t:n}=K(),i=l(),a=wt(),s=pn({onSettled:()=>{i.invalidateQueries({queryKey:[`pipelineExecutor`,`listLoadedEngines`]})}}),{data:c}=lt({nodeId:e}),u=It(`pipeline.engine-metrics-snapshot`,t=>t.nodeId===e)?.engines??c??null,d=u===null;en([`pipelineRunner`,`getLocalCameras`],[`pipeline.camera-assigned`,`pipeline.camera-unassigned`]);let{data:p}=Yt({nodeId:e}),{values:m}=Ot(`pipeline.camera-metrics-snapshot`,e=>e.deviceId,t=>t.nodeId===e),_=r(()=>m.filter(e=>e.metrics.phase===`active`).length,[m]),v=t=>{let r=p??[];if(r.length===0){s.mutate({nodeId:e,engine:t,force:!1});return}(async()=>{await a({title:n(`pipeline.nodeEnginesTab.killEngine`,`Kill engine`),message:`${String(r.length)} camera(s) are dispatching through this engine. Killing it drops their in-flight work and forces a respawn on the next frame.`,confirmLabel:n(`pipeline.nodeEnginesTab.killEngine`,`Kill engine`),variant:`danger`})&&s.mutate({nodeId:e,engine:t,force:!0})})()};return o(`div`,{className:`space-y-6`,children:[o(`div`,{children:[f(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:n(`pipeline.nodeEnginesTab.inferenceEnginesOnThisNode`,`Inference engines on this node`)}),f(`p`,{className:`text-[11px] text-foreground-subtle`,children:n(`pipeline.nodeEnginesTab.summary`,{engines:(u??[]).length,cameras:(p??[]).length,active:_})})]}),f(`div`,{className:`rounded-lg border border-border overflow-x-auto`,children:o(`table`,{className:`w-full text-xs min-w-[640px]`,children:[f(`thead`,{className:`bg-surface`,children:o(`tr`,{className:`text-foreground-subtle text-[10px] uppercase tracking-wider`,children:[f(`th`,{className:`text-left px-3 py-2 whitespace-nowrap`,children:n(`pipeline.nodeEnginesTab.kind`,`Kind`)}),f(`th`,{className:`text-left px-3 py-2 whitespace-nowrap`,children:n(`pipeline.nodeEnginesTab.runtimeBackendDevice`,`Runtime / Backend / Device`)}),f(`th`,{className:`text-left px-3 py-2`,children:n(`pipeline.nodeEnginesTab.models`,`Models`)}),f(`th`,{className:`text-right px-3 py-2 whitespace-nowrap`,children:n(`pipeline.nodeEnginesTab.poolPid`,`Pool PID`)}),f(`th`,{className:`text-right px-3 py-2 whitespace-nowrap`,children:n(`pipeline.nodeEnginesTab.autoKill`,`Auto-kill`)}),f(`th`,{className:`text-right px-3 py-2 whitespace-nowrap`,children:n(`pipeline.nodeEnginesTab.inUse`,`In use`)}),f(`th`,{className:`w-20`})]})}),o(`tbody`,{children:[d&&f(`tr`,{children:f(`td`,{colSpan:7,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:n(`common.loading`,`Loading…`)})}),!d&&(u??[]).map(e=>{let t=e.kind===`device-pool`;return o(`tr`,{className:`border-t border-border ${t?`bg-primary/[0.05]`:``}`,children:[f(`td`,{className:`px-3 py-2`,children:o(`span`,{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded-full text-[10px] font-medium ${t?`bg-primary/15 text-primary`:`bg-success/15 text-success`}`,children:[f(t?ve:g,{className:`h-3 w-3`}),n(t?`pipeline.nodeEnginesTab.pool`:`pipeline.nodeEnginesTab.runtime`)]})}),f(`td`,{className:`px-3 py-2`,children:o(`span`,{className:`inline-flex items-center gap-1 text-[11px] text-sky-400`,children:[f(ie,{className:`h-3 w-3`}),e.engine.runtime,`/`,e.engine.backend,e.engine.device?`/${e.engine.device}`:``,e.engine.format?` · ${e.engine.format}`:``]})}),f(`td`,{className:`px-3 py-2`,children:e.modelsLoaded.length===0?f(`span`,{className:`text-foreground-subtle text-[11px]`,children:`—`}):f(`div`,{className:`flex flex-wrap gap-1`,children:e.modelsLoaded.map(e=>f(`span`,{className:`inline-block rounded bg-surface px-1.5 py-0.5 text-[10px] font-mono text-foreground-subtle`,children:e},e))})}),f(`td`,{className:`px-3 py-2 text-right font-mono text-foreground`,children:e.poolPid??`—`}),f(`td`,{className:`px-3 py-2 text-right text-[11px]`,children:e.idleMs!==null&&e.idleTtlMs!==null?f(`span`,{className:`text-foreground-subtle`,children:wr(e.idleMs,e.idleTtlMs)}):f(`span`,{className:`text-foreground-subtle/50`,children:n(`common.never`)})}),f(`td`,{className:`px-3 py-2 text-right text-foreground`,children:(p??[]).length}),f(`td`,{className:`px-3 py-2 text-right`,children:t?f(`span`,{className:`text-[11px] text-foreground-subtle`,children:n(`common.auto`)}):o(V,{variant:`ghost`,size:`sm`,disabled:s.isPending,onClick:()=>v(e.engine),className:`text-danger hover:bg-danger/10 hover:text-danger`,children:[f(h,{className:`h-3.5 w-3.5`}),n(`pipeline.nodeEnginesTab.kill`,`Kill`)]})})]},e.engineKey)}),!d&&(u??[]).length===0&&f(`tr`,{children:f(`td`,{colSpan:7,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:n(`pipeline.nodeEnginesTab.noEnginesResidentTheFactory`,`No engines resident — the factory spins up on the first pipeline run.`)})})]})]})}),f(`div`,{className:`text-[10px] text-foreground-subtle leading-relaxed`,children:f(vn,{i18nKey:`pipeline.nodeEnginesTab.legend`,components:{strong:f(`strong`,{className:`text-foreground`})}})}),s.isError&&f(et,{message:n(`pipeline.nodeEnginesTab.killFailed`,{message:s.error instanceof Error?s.error.message:n(`common.unknownError`)})})]})}var Er=`pipeline-runner`,Dr=200;function Or({nodeId:e}){let{t}=K();return o(`div`,{className:`flex flex-col gap-3`,children:[o(`div`,{children:[f(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:t(`pipeline.nodeLogsTab.runnerLogs`,`Runner logs`)}),f(`p`,{className:`text-[11px] text-foreground-subtle`,children:t(`pipeline.nodeLogsTab.description`,{node:e})})]}),f(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:f(pt,{agentId:e,addonId:Er,limit:Dr,maxHeight:`max-h-[calc(100vh-360px)]`,showScope:!0,showDeviceChip:!0,showFilters:!1})})]})}t();function kr({nodeId:e,title:t}){let n=P(),{t:i}=K(),{data:a}=gn(),{data:s}=hn(void 0),c=r(()=>{let e=new Map;for(let t of a??[])e.set(t.id,t.name);return e},[a]),l=r(()=>{if(!e)return null;let t=new Set;for(let n of s??[])n.agentNodeId===e&&t.add(n.deviceId);return t},[e,s]),u=cr(e),d=r(()=>{let e=[];for(let t of u.values())l&&!l.has(t.deviceId)||e.push(t);return e.sort((e,t)=>e.deviceId-t.deviceId),e},[u,l]);return d.length===0?o(`div`,{className:`rounded-md border border-border bg-surface px-3 py-2 text-[11px] text-foreground-subtle italic`,children:[t??i(`pipeline.cameraStatusStrip.cameras`,`Cameras`),`: no live snapshots yet`]}):o(`div`,{className:`rounded-md border border-border bg-surface px-3 py-2`,children:[o(`div`,{className:`flex items-center gap-2 mb-1.5`,children:[f(`span`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle`,children:t??i(`pipeline.cameraStatusStrip.cameras`,`Cameras`)}),f(`span`,{className:`text-[10px] text-foreground-subtle`,children:d.length})]}),f(`div`,{className:`flex flex-wrap gap-1.5`,children:d.map(e=>{let t=c.get(e.deviceId)??`#${e.deviceId}`,r=rt(e.metrics.phase,n);return o(`div`,{title:i(`pipeline.cameraStatusStrip.fpsMsInferQ`,`{{name}} · {{label}} · {{value3}} fps · {{value4}}ms infer · q={{queueDepth}}`,{name:t,label:r.label,value3:e.metrics.actualFps.toFixed(1),value4:e.metrics.avgInferenceTimeMs.toFixed(0),queueDepth:e.metrics.queueDepth}),className:`inline-flex items-center gap-1 rounded border px-1.5 py-0.5 text-[10px] ${r.badgeClass}`,children:[f(Ke,{phase:e.metrics.phase,className:`h-2.5 w-2.5`}),f(`span`,{className:`font-medium text-foreground/90 max-w-[220px] truncate`,children:t}),f(`span`,{className:`font-mono tabular-nums`,children:e.metrics.actualFps.toFixed(1)}),f(`span`,{className:`opacity-60`,children:i(`common.fpsWord`)})]},e.deviceId)})})]})}function Ar(e,t,n){return e.map(e=>{if(e.key===t)return e;let r=e.steps[n];if(!r||r.settings===void 0)return e;let{settings:i,...a}=r,o={...e.steps};return Object.keys(a).length>0?o[n]=a:delete o[n],{...e,steps:o}})}function jr(e,t,n){let r=e.filter(e=>e.key!==t).toSorted((e,t)=>e.key.localeCompare(t.key)),i=[...r.filter(e=>!e.enabled),...r.filter(e=>e.enabled),...e.filter(e=>e.key===t)],a;for(let e of i){let t=e.steps?.[n]?.settings;!t||Object.keys(t).length===0||(a={...a,...t})}return a}function Mr(e){let t={};for(let n of e){let e=Object.keys(n.steps).length>0;t[n.key]={enabled:n.enabled,weight:Math.max(1,n.weight),...n.maxSessions!==null&&n.maxSessions>0?{maxSessions:n.maxSessions}:{},...e?{steps:n.steps}:{}}}return t}var Nr=`pipeline-orchestrator`;function Pr({addonId:e,highlightLabel:t}){let{t:n}=K(),r=Te(e),{data:i}=Kt({addonId:Nr});if(r.length===0)return null;let a=ke(i??null)[e]??{};return o(`section`,{className:`space-y-1.5 border-t border-border/60 pt-3`,"aria-label":n(`stepInspector.clusterOwnedSettings.clusterWideSettings`,`Cluster-wide settings`),children:[o(`div`,{className:`flex flex-wrap items-center gap-2`,children:[f(`h3`,{className:T,children:n(`stepInspector.clusterOwnedSettings.clusterWideSettings`,`Cluster-wide settings`)}),f(_n,{to:zo(e),className:`ml-auto text-[11px] text-primary hover:underline`,children:n(`stepInspector.clusterOwnedSettings.editInClusterSettings`,`Edit in Cluster → Settings ›`)})]}),r.map(e=>o(`div`,{className:`${p} rounded px-2 ${t===e.label?`bg-primary/5 ring-1 ring-primary/40`:``}`,children:[f(`span`,{className:F,children:e.label}),f(`span`,{className:v,children:f(`span`,{className:`font-mono text-xs text-foreground`,children:String(a[e.key]??e.default)})})]},e.key)),f(`p`,{className:B,children:n(`stepInspector.clusterOwnedSettings.oneValueForEveryNode`,`One value for every node and camera — this step writes into a shared index.`)})]})}function Fr({rows:e}){let{t}=K();return o(`div`,{className:`space-y-1.5`,"data-testid":`effective-models`,children:[f(`ul`,{className:`divide-y divide-border rounded-md border border-border`,children:e.map(e=>o(`li`,{className:`${C} flex flex-wrap items-baseline gap-x-2 text-xs`,children:[f(`span`,{className:`min-w-0 flex-1 truncate text-foreground-muted`,children:e.label}),f(`span`,{className:`font-mono text-foreground`,children:e.modelId??`—`}),f(`span`,{className:`text-[10px] text-foreground-subtle`,children:e.sourceLabel})]},e.id))}),f(`p`,{className:B,children:t(`stepInspector.effectiveModelSummary.toChangeAModelOpen`,`To change a model, open that accelerator's cell in the table.`)})]})}t();function Ir(e,t){let[n,i]=yn(),o=n.get(Pn),s=n.get(`acc`),c=r(()=>Ln(e,t,{step:o,acc:s}),[e,t,o,s]),l=a(e=>{i(t=>{let n=new URLSearchParams(t);return e(n),n},{replace:!0})},[i]);return{selection:c,open:a(e=>l(t=>{t.set(Pn,e.stepId),e.acceleratorId===void 0?t.delete(`acc`):t.set(`acc`,e.acceleratorId)}),[l]),close:a(()=>l(e=>{e.delete(Pn),e.delete(`acc`)}),[l])}}function Lr(e,t){for(let n of e?.slots??[])for(let e of n.addons)if(e.id===t)return e;return null}function Rr(e){return e.split(`.`)[0]??e}function zr(e,t,n){return{id:In(e,n.key),nodeId:e,deviceKey:n.key,device:n,label:`${Rr(t)} · ${Et(n)}`,shortLabel:`${Rr(t)} · ${sn(n)}`,nodeLabel:Rr(t),disabled:!n.enabled}}function Br(e,t,n,r=!1){return n.filter(e=>r||e.enabled).map(n=>zr(e,t,n))}function Vr(e,t,n=!1){return e.flatMap(e=>{let r=t[e.id]??[];if(n)return r.map(t=>zr(e.id,e.name,t));let i=r.filter(e=>e.enabled&&e.available);if(i.length>0)return i.map(t=>zr(e.id,e.name,t));let a=r.find(e=>e.available)??r[0];return a===void 0?[]:[zr(e.id,e.name,a)]})}function Hr(e,t,n){return{modelId:Xt({catalog:e,device:t.device,base:n.nodePin,override:n.cameraPin}),source:n.cameraPin===void 0?n.nodePin===void 0?`default`:`node`:`camera`}}function Ur(e,t,n){let r=Lr(e,`object-detection`);if(r===null)return;let i=Xt({catalog:r,device:t.device,base:t.device.steps?.[`object-detection`]?.modelId,override:n});if(i===void 0)return;let a=r.models.find(e=>e.id===i);return{modelId:i,name:a?.name??i,supplies:a?.suppliesSteps??[]}}function Wr(e,t,n){return!Se(e)||n===void 0?!1:Ce(e,t,n.supplies).effective}function Gr(e,t){return e!==null&&Gt(e.models,t.device.format)}function Kr(e){return Gr(e.addon,e.acc)?e.clusterModelId===void 0?{kind:`enabled`,modelId:e.model.modelId??`Auto`,overridden:e.model.source===`camera`,...e.rootName===void 0?{}:{suppliedByRoot:e.rootName},...e.jumpTo===void 0?{}:{jumpTo:e.jumpTo}}:{kind:`enabled`,modelId:e.clusterModelId,clusterWide:!0}:e.gatedOn?e.jumpTo===void 0?{kind:`skip`}:{kind:`skip`,jumpTo:e.jumpTo}:{kind:`na`}}function qr(e){return Object.values(e).reduce((e,t)=>e+t.filter(e=>!e.enabled).length,0)}function Jr(e){if(e===null)return[];let t=(e.configSchema??[]).flatMap(e=>`label`in e&&typeof e.label==`string`?[e.label]:[]),n=Te(e.id).map(e=>e.label);return[...new Set([...t,...n])]}function Yr(e){return e.flatMap(e=>[{node:e,depth:0},...Yr(e.children).map(e=>({node:e.node,depth:e.depth+1}))])}function Xr(e,t){return e.flatMap(e=>{let n=Xr(e.children,t);return t.has(e.addonId)||n.length>0?[{...e,children:n}]:[]})}t();function Zr(e){return{agentNodeId:e.nodeId,nodeLabel:e.nodeLabel,engineLabel:e.device.format,deviceKey:e.deviceKey,deviceLabel:Et(e.device),detail:e.device.defaultModelId,disabled:e.disabled}}function Qr({tree:e,searchRows:t,accelerators:n,cellState:s,stepBadge:c,disabledCount:l,showDisabled:u,onShowDisabledChange:p,dirty:m,onDiscard:h,summary:g,toolbar:_,label:v,renderDetail:y}){let{t:b}=K(),x=wt(),S=Jt(),{selection:C,open:w,close:T}=Ir(r(()=>Yr(e).map(e=>e.node.addonId),[e]),r(()=>n.map(e=>e.id),[n])),[E,D]=i(``),[O,k]=i(null),[A,j]=i(null),M=d(null),P=d(null),F=d(null),I=d(null),L=r(()=>ze(t,E),[t,E]),ee=r(()=>E.trim()===``?e:Xr(e,new Set(L.map(e=>e.addonId))),[e,L,E]),te=e=>L.find(t=>t.addonId===e)?.matchedField??null,ne=r(()=>n.map(Zr),[n]),re=e=>n.find(t=>t.nodeId===e.agentNodeId&&t.deviceKey===e.deviceKey),R=n.find(e=>e.id===C.acceleratorId)??null,z=C.stepId!==null,ie=a(async e=>{if(m){if(!await x({title:b(`stepInspector.stepMatrixFrame.discardUnsavedChanges`,`Discard unsaved changes?`),message:b(`stepInspector.stepMatrixFrame.thisStepHasChangesThat`,`This step has changes that are not saved yet.`),confirmLabel:b(`stepInspector.stepMatrixFrame.discard`,`Discard`),variant:`danger`}))return;h()}e()},[x,m,h,b]),ae=()=>{requestAnimationFrame(()=>I.current?.focus())},oe=(e,t,n=!1)=>{if(e===C.stepId&&(t?.id??null)===C.acceleratorId){n&&ae();return}let r=()=>{k(te(e)),w({stepId:e,...t===void 0?{}:{acceleratorId:t.id}}),n&&ae()};e===C.stepId?r():ie(r)},se=()=>{let e=C.stepId;ie(()=>{if(T(),e!==null){let t=R===null?null:xt({agentNodeId:R.nodeId,deviceKey:R.deviceKey});requestAnimationFrame(()=>M.current?.focusCell(e,t))}})},ce=e=>{if(e.key===`Enter`){let t=L[0];if(t===void 0)return;e.preventDefault(),oe(t.addonId,void 0,!0)}else e.key===`Escape`&&D(``)},le=S?f(Ue,{onClick:se}):f(Ft,{icon:N,variant:`ghost`,size:`sm`,"aria-label":b(`common.close`,`Close`),onClick:se});return o(`div`,{ref:P,className:`space-y-2`,onKeyDown:e=>{let t=e.target instanceof HTMLElement&&e.target.dataset.r!==void 0;e.key===`/`&&t&&(e.preventDefault(),F.current?.focus()),e.key===`Escape`&&t&&z&&(e.preventDefault(),se())},children:[o(`div`,{className:`flex flex-wrap items-center gap-2 text-xs`,children:[f(`div`,{className:`min-w-0 basis-full sm:basis-auto`,children:g}),f(`input`,{ref:F,type:`search`,value:E,onChange:e=>D(e.target.value),onKeyDown:ce,placeholder:b(`stepInspector.stepMatrixFrame.filterStepsOrSettings`,`Filter steps or settings /`),"aria-label":b(`stepInspector.stepMatrixFrame.filterStepsOrSettings2`,`Filter steps or settings`),className:`h-9 w-56 rounded-md border border-border bg-background px-2 text-xs text-foreground outline-none focus:border-primary focus:ring-1 focus:ring-primary/30 md:h-7`}),l>0&&o(`label`,{className:`inline-flex items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[f(kt,{checked:u,onChange:e=>p(e.target.checked)}),b(`stepInspector.stepMatrixFrame.showDisabled`,{count:l})]}),_]}),C.staleStepId!==null&&f(`p`,{className:`rounded-md border border-warning/40 bg-warning/10 px-3 py-1.5 text-[11px] text-warning`,children:b(`stepInspector.stepMatrixFrame.staleStep`,{id:C.staleStepId})}),ee.length===0?f(`p`,{className:`${B} rounded-md border border-dashed border-border px-3 py-4 text-center`,children:b(`stepInspector.stepMatrixFrame.noStepMatches`,{query:E})}):f(Xe,{ref:M,tree:ee,agents:ne,label:v,getCellState:(e,t)=>{let n=re(t);return n===void 0?{kind:`na`}:s(e,n)},onCellClick:(e,t,n)=>oe(e,re(t),n),onStepClick:(e,t)=>oe(e,void 0,t),...c===void 0?{}:{stepBadge:c},selectedCell:z&&C.stepId!==null&&R!==null?{addonId:C.stepId,agentNodeId:R.nodeId,deviceKey:R.deviceKey}:null,fallbackNodeId:A,onFallbackNodeChange:j,reserveRightPx:z&&!S?432:0}),f(it,{open:z,anchor:P,onClose:se,label:b(`stepInspector.stepMatrixFrame.stepSettings`,`Step settings`),children:C.stepId!==null&&y({stepId:C.stepId,accelerator:R,matchedField:O,closeButton:le,onEscape:se,headingRef:e=>{I.current=e}})})]})}t();function $r(e){n(()=>{if(e===null)return;let t=document.getElementById(e);t===null||typeof t.scrollIntoView!=`function`||t.scrollIntoView({block:`center`,behavior:`smooth`})},[e])}t();function ei(e,t){let n=e.filter(e=>e.steps?.[t]?.settings!==void 0),r=e=>e.toSorted((e,t)=>e.key.localeCompare(t.key));return r(n.filter(e=>e.enabled))[0]?.key??r(n)[0]?.key??r(e.filter(e=>e.enabled))[0]?.key??e[0]?.key}function ti(e,t){let n=t.settings===void 0?void 0:ei(e,t.stepId),r=e.map(e=>{let r={...e.steps},i=r[t.stepId]??{},a=t.models[e.key],o=t.jumps[e.key],s=e.key===n&&t.settings!==void 0?Object.keys(t.settings).length>0?t.settings:void 0:i.settings,c=a===void 0?i.modelId:a??void 0,l=o===void 0?i.jumpDeviceKey:o||void 0,u={...c===void 0?{}:{modelId:c},...s===void 0?{}:{settings:s},...l===void 0?{}:{jumpDeviceKey:l}};return Object.keys(u).length>0?r[t.stepId]=u:delete r[t.stepId],{key:e.key,enabled:e.enabled,weight:e.weight,maxSessions:e.maxSessions,steps:r}});return n===void 0?r:Ar(r,n,t.stepId)}function ni(e,t,n){if(t===null)return 0;let r=Object.entries(t.models).filter(([n,r])=>(r??void 0)!==e.find(e=>e.key===n)?.steps?.[t.stepId]?.modelId).length,i=Object.entries(t.jumps).filter(([n,r])=>(r||void 0)!==e.find(e=>e.key===n)?.steps?.[t.stepId]?.jumpDeviceKey).length,a=new Set([...Object.keys(n),...Object.keys(t.settings??{})]),o=t.settings===void 0?0:[...a].filter(e=>!Me(n[e],t.settings?.[e])).length;return r+i+o}function ri({nodeId:e,nodeName:t,toolbar:n}){let{t:a}=K(),c=l(),u=tt({nodeId:e},{refetchOnMount:`always`}),d=At({nodeId:e},{refetchOnMount:`always`}),p=ye(Kt({addonId:`pipeline-orchestrator`}).data??null),m=u.data?.devices??[],h=d.data??null,[g,_]=i(null),[v,y]=i(null),[b,x]=i(null),S=bt({onSuccess:()=>{c.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getNodeInferenceDevices`]]})}}),C=r(()=>h?ct(h):[],[h]),w=r(()=>Yr(C),[C]),[E,D]=i(!1),O=r(()=>Br(e,t,m,E),[e,t,m,E]),k=r(()=>Br(e,t,m),[e,t,m]),A=k.length>=2,j=(e,t)=>(t===void 0?void 0:jr(m,t.deviceKey,e))??{},M=(e,t,n)=>{let r=n??t.device.steps?.[e?.id??``]?.jumpDeviceKey;if(r!==void 0&&r!==``)return k.find(e=>e.deviceKey===r);if(!Gr(e,t))return k.filter(n=>n.id!==t.id&&Gr(e,n)).toSorted((e,t)=>e.deviceKey.localeCompare(t.deviceKey))[0]},N=(e,t)=>{let n=Lr(h,e),r=Ho(e),i=Ur(h,t),a=j(e,t),o=M(n,t);return Kr({addon:n,acc:t,gatedOn:n?.enabledByDefault??!0,model:n?Hr(n,t,{nodePin:t.device.steps?.[e]?.modelId}):{modelId:void 0,source:`default`},...Wr(e,a,i)&&i?{rootName:i.name}:{},...r?{clusterModelId:p[e]??r.defaultModelId}:{},...o?{jumpTo:sn(o.device)}:{}})},P=w.map(({node:e})=>({addonId:e.addonId,name:e.addonName,fieldLabels:Jr(Lr(h,e.addonId))}));if(u.isLoading||d.isLoading)return f(`div`,{className:`animate-pulse p-4 text-xs text-foreground-subtle`,children:a(`stepInspector.nodeStepInspector.loadingPipeline`,`Loading pipeline…`)});if(h===null)return f(`div`,{className:`p-4 text-xs text-foreground-subtle`,children:a(`stepInspector.nodeStepInspector.catalogUnavailable`,`Catalog unavailable.`)});let F=o(`span`,{className:B,children:[a(`stepInspector.nodeStepInspector.accelerators`,`Accelerators:`),` `,f(`span`,{className:`text-foreground`,children:k.length>0?k.map(e=>sn(e.device)).join(` · `):a(`stepInspector.nodeStepInspector.noneEnabled`,`none enabled`)}),m.some(e=>!e.enabled)&&o(s,{children:[` `,a(`stepInspector.nodeStepInspector.off`,`— off:`),` `,m.filter(e=>!e.enabled).map(sn).join(`, `)]}),` `,`·`,` `,f(_n,{to:Bo(),className:`text-primary hover:underline`,children:a(`stepInspector.nodeStepInspector.clusterLoadBalancing`,`Cluster → Load balancing ›`)})]});return f(Qr,{tree:C,searchRows:P,accelerators:O,cellState:N,disabledCount:m.filter(e=>!e.enabled).length,showDisabled:E,onShowDisabledChange:D,dirty:g!==null&&ni(m,g,j(g.stepId,O[0]))>0,onDiscard:()=>_(null),summary:F,...n===void 0?{}:{toolbar:n},label:a(`stepInspector.nodeStepInspector.detectionSteps`,`Detection steps`),renderDetail:({stepId:n,accelerator:r,matchedField:i,closeButton:c,onEscape:l,headingRef:u})=>{let d=Lr(h,n);if(d===null)return f(`div`,{className:`p-4 text-xs text-foreground-subtle`,children:a(`stepInspector.nodeStepInspector.noStepSelected`,`No step selected.`)});let p=g?.stepId===n?g:null,C=r??k[0]??O[0],w=j(n,C),E=p?.settings??w,D=ni(m,p,w),N=e=>{x(null),_(t=>({...t?.stepId===n?t:{stepId:n,models:{},jumps:{}},...e}))},P=Ho(n),F=Wt(d),I=C===void 0?void 0:Ur(h,C),L=e=>{let t=p?.models[e.deviceKey];return t===void 0?e.device.steps?.[n]?.modelId:t??void 0},ee=C===void 0?void 0:Hr(d,C,{nodePin:L(C)}).modelId,te=O.length>1&&O.some(e=>!Me(j(n,e),w)),ne=e=>{let t=L(e),r=Hr(d,e,{nodePin:t}),i=Ur(h,e),c=Wr(n,p?.settings??j(n,e),i),l=p?.jumps[e.deviceKey],u=M(d,e,l),m=Gr(d,e)?c&&i?f(nn,{rootModel:i,stepModelId:r.modelId}):void 0:o(s,{children:[a(`stepInspector.nodeStepInspector.noBuild`,{format:e.device.format}),` `,u?a(`stepInspector.nodeStepInspector.itRunsOnInstead`,`It runs on {{shortLabel}} instead.`,{shortLabel:u.shortLabel}):a(`stepInspector.nodeStepInspector.itDoesNotRunHere`,`It does not run here.`)]}),g=A?o(`label`,{className:`block space-y-1`,children:[f(`span`,{className:`text-[11px] font-medium text-foreground`,children:a(`stepInspector.nodeStepInspector.runOn`,`Run on`)}),f(Ze,{"aria-label":a(`stepInspector.nodeStepInspector.runOn`,`Run on`),value:l??e.device.steps?.[n]?.jumpDeviceKey??``,options:[{value:``,label:a(`stepInspector.nodeStepInspector.autoThisAcceleratorOrThe`,`Auto (this accelerator, or the next one that can run it)`)},...k.filter(t=>t.id!==e.id).map(e=>({value:e.deviceKey,label:`${e.label} · ${e.device.format}`}))],onChange:t=>N({jumps:{...p?.jumps,[e.deviceKey]:t.target.value}})}),f(`span`,{className:B,children:a(`stepInspector.nodeStepInspector.routesThisStepAndIts`,`Routes this step (and its child steps) to another accelerator of this node.`)})]}):void 0;return{label:e.label,format:e.device.format,modelId:r.modelId,source:r.source===`node`?`node`:`default`,sourceLabel:r.source===`node`?`node pin`:`hardware default`,models:Rt(d.models??[],e.device.format),defaultModelId:d.defaultModelIdByFormat?.[e.device.format]??d.defaultModelId,expanded:v===e.id,onToggle:()=>y(t=>t===e.id?null:e.id),onChangeModel:t=>N({models:{...p?.models,[e.deviceKey]:t}}),...t===void 0?{}:{onReset:()=>N({models:{...p?.models,[e.deviceKey]:null}}),resetLabel:`Reset to hardware default`},...m===void 0?{}:{note:m},...g===void 0?{}:{extra:g},changed:p?.models[e.deviceKey]!==void 0||l!==void 0}},re=()=>{p!==null&&S.mutate({agentNodeId:e,inferenceDevices:Mr(ti(m,p))},{onSuccess:()=>{_(null),x({kind:`saved`})},onError:e=>x({kind:`error`,error:e.message})})};return f(ut,{ref:u,title:r===null?`${d.name} · ${t}`:`${d.name} · ${r.label}`,subtitle:r===null?a(`stepInspector.nodeStepInspector.everyAcceleratorOf`,`{{slot}} · every accelerator of {{nodeName}}`,{slot:d.slot,nodeName:t}):a(`stepInspector.nodeStepInspector.baseForEveryCameraThat`,`{{slot}} · {{format}} · base for every camera that lands here`,{slot:d.slot,format:r.device.format}),leading:c,onEscape:l,saveBar:{dirtyCount:D,saving:S.isPending,status:b?.kind??null,...b?.error===void 0?{}:{error:b.error},onSave:re,onDiscard:()=>_(null)},children:o(`div`,{className:`space-y-3`,children:[o(`section`,{className:`space-y-2`,"aria-label":a(`stepInspector.nodeStepInspector.model`,`Model`),children:[f(`h3`,{className:T,children:a(`stepInspector.nodeStepInspector.model`,`Model`)}),P!==null&&C!==void 0?f(Uo,{step:P,engineFormat:C.device.format,runnableModelIds:Rt(d.models??[],C.device.format).map(e=>e.id)}):O.length===0?f(`p`,{className:B,children:f(vn,{i18nKey:`stepInspector.nodeStepInspector.noAcceleratorEnabled`,components:{link:f(_n,{to:Bo(),className:`text-primary hover:underline`})}})}):r===null?f(Fr,{rows:O.map(e=>{let t=Hr(d,e,{nodePin:L(e)});return{id:e.id,label:e.label,modelId:t.modelId,sourceLabel:t.source===`node`?`node pin`:`hardware default`}})}):f(un,{...ne(r)},r.id)]}),(F.length>0||I!==void 0)&&P===null&&o(`section`,{"aria-label":a(`stepInspector.nodeStepInspector.settings`,`Settings`),className:`space-y-2 border-t border-border/60 pt-2`,children:[f(`p`,{className:`text-[10px] text-foreground-subtle`,"data-testid":`settings-scope`,children:a(`stepInspector.nodeStepInspector.nodeWideSettings`,{node:t})}),te&&f(`p`,{className:`rounded-md border border-warning/40 bg-warning/10 px-2 py-1 text-[11px] text-warning`,children:a(`stepInspector.nodeStepInspector.thisStepSSettingsDiffer`,`This step's settings differ between this node's accelerators. Saving makes the values shown here node-wide.`)}),f(ii,{addon:d,fields:F,settings:E,modelId:Mt(d,ee,E,I),root:I,highlight:i,onChange:e=>N({settings:e})})]}),f(Pr,{addonId:n,highlightLabel:i})]})})}})}function ii({addon:e,fields:t,settings:n,modelId:r,root:i,highlight:a,onChange:o}){let s=t.find(e=>`label`in e&&e.label===a)?.key??null;return $r(s===null?null:Pt(s)),f(on,{addon:e,fields:t,layers:{node:n},target:`node`,labels:{node:`Node`},modelId:r,...i===void 0?{}:{rootModel:i},highlightKey:s,onChangeLayer:o})}t();function ai({nodeId:e,refreshToken:t}){let{t:n}=K(),r=wt(),[a,c]=i(null),{nodes:l}=W(),u=l.find(t=>t.id===e)?.name??e,d=Qt({onSuccess:e=>{c(e.effectiveModelId===null?`Reset done — model config cleared (node offline: effective model resolves on reconnect)`:`Reset done — effective detection model: ${e.effectiveModelId} (Auto)`)}}),p=async()=>{await r({title:n(`pipeline.nodePipelineTab.resetToHardwareAwareDefaults`,`Reset {{nodeName}} to hardware-aware defaults?`,{nodeName:u}),message:n(`pipeline.nodePipelineTab.thisClearsEveryPerDevice`,`This clears every per-device model default on this node (back to the format default) and every per-camera step override scoped to it. Existing per-camera customisations on this node are lost.`),confirmLabel:n(`common.reset`,`Reset`),variant:`danger`})&&(c(null),d.mutate({agentNodeId:e}))};return o(`div`,{className:`space-y-2`,children:[f(kr,{nodeId:e}),f(ri,{nodeId:e,nodeName:u,toolbar:o(s,{children:[a&&f(`span`,{className:`text-[11px] text-success`,children:a}),d.isError&&f(`span`,{className:`text-[11px] text-danger`,children:d.error instanceof Error?d.error.message:n(`pipeline.nodePipelineTab.resetFailed`,`Reset failed`)}),f(V,{variant:`outline`,size:`sm`,onClick:()=>{p()},disabled:d.isPending,title:n(`pipeline.nodePipelineTab.clearThisNodeSPer`,`Clear this node's per-device model defaults + per-camera overrides scoped to this node`),children:d.isPending?n(`pipeline.nodePipelineTab.resetting`,`Resetting…`):n(`pipeline.nodePipelineTab.resetToDefault`,`Reset to default`)})]})})]})}var oi=[`detection-pipeline`,`audio-analyzer`,`pipeline-runner`],si=`decoder-nodeav`,ci=`ntab`,li={decoder:`engine`},ui={engine:`Engine & decoder`},di=`Nothing here is set per node. Cluster-wide values are on Cluster → Settings.`;function fi({nodeId:e,refreshToken:t}){let{t:n}=K(),[r,i]=yn(),{nodes:a}=W(),s=a.find(t=>t.id===e)?.addons.find(e=>e.capabilities.includes(`decoder`))?.addonId??si,c=[...oi,s],l=r.get(ci),u={assignments:{id:`assignments`,label:n(`pipeline.nodeDetail.assignments`,`Assignments`),order:-10,content:f(Cr,{nodeId:e,refreshToken:t})},tree:{id:`tree`,label:n(`pipeline.nodeDetail.pipeline`,`Pipeline`),order:39,content:f(ai,{nodeId:e,refreshToken:t})},engines:{id:`engines`,label:n(`pipeline.nodeDetail.warmInstances`,`Warm instances`),order:180,content:f(Tr,{nodeId:e,refreshToken:t})},logs:{id:`logs`,label:n(`pipeline.nodeDetail.logs`,`Logs`),order:300,content:f(Or,{nodeId:e})}},d=Kn.map(e=>u[e]);return o(`div`,{className:`flex flex-col h-full`,children:[f(Gn,{nodeId:e,refreshToken:t}),f(`div`,{className:`flex-1 min-h-0 overflow-y-auto p-4 sm:p-6`,children:f(bn,{nodeId:e,addonIds:c,level:`global`,fieldScope:`perNode`,emptyMessage:di,tabAliases:li,tabLabelOverrides:ui,extraTabs:d,activeTab:l===null?null:li[l]??l,onActiveTabChange:e=>i(t=>{let n=new URLSearchParams(t);n.set(ci,e);for(let e of Fn)n.delete(e);return n},{replace:!0})})})]})}function pi(){let{t:e}=K();return o(`div`,{className:`space-y-2`,children:[o(`div`,{className:`min-w-0`,children:[f(`h3`,{className:`text-sm font-semibold text-foreground`,children:e(`pipeline.clusterAssignmentsTab.cameraPlacement`,`Camera placement`)}),f(`p`,{className:`text-[11px] text-foreground-subtle`,children:e(`pipeline.clusterAssignmentsTab.pinACameraToA`,`Pin a camera to a node, or to one accelerator of its node; Auto lets each session pick. Decode always runs with detection. Load, shares and caps are on Load balancing.`)})]}),f(xr,{})]})}function mi(e){return`${Math.round(e*100)}%`}function hi(e){return G.t(`helpers.autoTuneViewModel.sessions`,{count:e})}var gi={"intel-npu":`Intel NPU`,"intel-igpu":`Intel iGPU`,"amd-igpu":`AMD iGPU (WebGPU)`,"amd-npu":`AMD XDNA NPU`,"x86-cpu":`CPU`,"arm-cpu":`CPU`,"apple-ane":`Apple Neural Engine`,coral:`Coral Edge TPU`},_i={"intel-core-ultra":`Intel Core Ultra`,"intel-n-series":`Intel N-series`,"apple-m-base":`Apple M (base)`,"apple-m-pro":`Apple M Pro / Max / Ultra`,"amd-phoenix":`AMD Ryzen Phoenix / Hawk Point`,unknown:`Not measured`};function vi(e){return e===null?`—`:gi[e]??e}function yi(e){return e===null?`—`:_i[e]??e}function bi(e){switch(e.kind){case`capacity`:return G.t(`helpers.autoTuneViewModel.capacity`,{sessions:hi(e.sessions),min:e.minSessions});case`tie-faster`:return G.t(`helpers.autoTuneViewModel.tieFaster`,{over:e.over,recall:mi(e.recallDelta)});case`stepped-down`:return G.t(`helpers.autoTuneViewModel.steppedDown`,{from:e.from,limitedBy:e.limitedBy,to:e.to});case`no-fit-lightest`:return G.t(`helpers.autoTuneViewModel.noFitLightest`,{min:hi(e.minSessions),sessions:hi(e.sessions)});case`derived-latency`:return G.t(`helpers.autoTuneViewModel.derivedLatency`,{modelId:e.modelId});case`cpu-device`:return G.t(`helpers.autoTuneViewModel.cpuDevice`);case`coral-untouched`:return G.t(`helpers.autoTuneViewModel.coralUntouched`);case`device-disabled`:return G.t(`helpers.autoTuneViewModel.deviceDisabled`);case`device-unavailable`:return G.t(`helpers.autoTuneViewModel.deviceUnavailable`);case`node-offline`:return G.t(`helpers.autoTuneViewModel.nodeOffline`);case`no-hardware-facts`:return G.t(`helpers.autoTuneViewModel.noHardwareFacts`);case`no-measured-data`:return G.t(`helpers.autoTuneViewModel.noMeasuredData`);case`no-family-build`:return G.t(`helpers.autoTuneViewModel.noFamilyBuild`,{format:e.format});case`kept-custom-pin`:return G.t(`helpers.autoTuneViewModel.keptCustomPin`,{modelId:e.modelId,deviceKey:e.deviceKey})}}function xi(e,t){switch(e.kind){case`detector-store-cluster-wide`:return G.t(`helpers.autoTuneViewModel.detectorStoreClusterWide`,{nodes:e.skippedNodes.map(t).join(`, `)});case`detector-store-unreadable`:return G.t(`helpers.autoTuneViewModel.detectorStoreUnreadable`,{error:e.error});case`coral-enabled`:return G.t(`helpers.autoTuneViewModel.coralEnabled`,{node:t(e.nodeId),deviceKey:e.deviceKey});case`custom-pin-kept`:return e.deviceId===null?G.t(`helpers.autoTuneViewModel.customPinNode`,{node:t(e.nodeId),modelId:e.modelId,deviceKey:e.deviceKey??`—`}):G.t(`helpers.autoTuneViewModel.customPinCamera`,{deviceId:e.deviceId,modelId:e.modelId,node:t(e.nodeId)});case`custom-registry-unreadable`:return G.t(`helpers.autoTuneViewModel.customRegistryUnreadable`,{error:e.error})}}function Si(e){let t=e.nodeChanges.reduce((e,t)=>e+t.modelPins.length,0),n=e.nodeChanges.reduce((e,t)=>e+t.thresholds.length,0),r=new Set([...e.cameraClears.map(e=>e.deviceId),...e.detectorStoreClears.map(e=>e.deviceId)]);return{modelChanges:t,thresholdClears:n,cameraOverrideClears:e.cameraClears.length,detectorStoreClears:e.detectorStoreClears.length,camerasTouched:r.size}}function Ci(e){let t=Si(e);return t.modelChanges+t.thresholdClears+t.cameraOverrideClears+t.detectorStoreClears===0}function wi(e,t,n){let r=e.nodeChanges.find(e=>e.nodeId===t&&e.deviceKey===n)?.modelPins.find(e=>e.stepId===`object-detection`);return r===void 0?null:{before:r.before,after:r.after}}function Ti(e,t){return e?.kind===`node-benchmark`?G.t(`helpers.autoTuneViewModel.latencyMeasured`,{date:new Date(e.measuredAtMs).toLocaleDateString(t,{day:`numeric`,month:`short`})}):G.t(`helpers.autoTuneViewModel.latencyTable`)}t();var Ei=[.3,.4,.5];function Di(e){return Ei.some(t=>t===e)}var Oi=[1,2,3,4,6,8];function ki({plan:e,node:t,nodeName:n}){let{t:r}=K();return o(`section`,{className:x,"data-testid":`auto-tune-node-${t.nodeId}`,children:[o(`header`,{className:`${I} flex flex-wrap items-center gap-2`,children:[f(g,{className:`h-3.5 w-3.5 shrink-0 text-foreground-subtle`,"aria-hidden":!0}),f(`h3`,{className:`${T} min-w-0 flex-1`,children:n(t.nodeId)}),o(`span`,{className:`text-[11px] text-foreground-subtle`,children:[yi(t.hardwareClass),t.cpuModel===null?``:` · ${t.cpuModel}`]}),t.skipped?f(U,{variant:`warning`,children:r(`pipeline.clusterAutoTuneTab.notChanged`,`Not changed`)}):t.acceleratorModelId!==null&&f(U,{variant:`info`,children:t.acceleratorModelId})]}),t.reasons.length>0&&f(`ul`,{className:`px-3 pt-2 text-[11px] text-foreground-muted`,children:t.reasons.map((e,t)=>f(`li`,{children:bi(e)},t))}),f(`div`,{className:`overflow-x-auto`,children:o(`table`,{className:`w-full text-xs`,children:[f(`thead`,{children:o(`tr`,{className:`text-left text-[11px] text-foreground-subtle`,children:[f(`th`,{className:`px-3 py-1.5 font-medium`,children:r(`pipeline.clusterAutoTuneTab.device`,`Device`)}),f(`th`,{className:`px-3 py-1.5 font-medium`,children:r(`pipeline.clusterAutoTuneTab.capacity`,`Capacity`)}),f(`th`,{className:`px-3 py-1.5 font-medium`,children:r(`pipeline.clusterAutoTuneTab.detector`,`Detector`)}),f(`th`,{className:`px-3 py-1.5 font-medium`,children:r(`pipeline.clusterAutoTuneTab.why`,`Why`)})]})}),f(`tbody`,{children:t.devices.map(n=>{let i=wi(e,t.nodeId,n.deviceKey);return o(`tr`,{className:`border-t border-border align-top`,children:[o(`td`,{className:`px-3 py-1.5`,children:[f(`div`,{className:`font-mono text-foreground`,children:n.deviceKey}),f(`div`,{className:`text-[11px] text-foreground-subtle`,children:vi(n.accelerator)})]}),o(`td`,{className:`px-3 py-1.5 text-foreground-muted`,children:[n.chosen===null?`—`:r(`pipeline.clusterAutoTuneTab.sessionsAtFps`,{count:n.chosen.capacitySessions,fps:e.cameraFps}),n.chosen!==null&&o(`div`,{className:`text-[11px] text-foreground-subtle`,children:[r(`pipeline.clusterAutoTuneTab.fpsKeptFree`,{fps:n.chosen.fps,percent:Math.round(e.headroom*100)}),f(`div`,{children:Ti(n.chosen.source)})]})]}),f(`td`,{className:`px-3 py-1.5`,children:n.chosen===null?f(`span`,{className:`text-foreground-subtle`,children:r(`common.unchanged`)}):i!==null&&i.before!==i.after?o(`span`,{children:[f(`span`,{className:`text-foreground-subtle`,children:i.before??r(`common.defaultWord`)}),` → `,f(`span`,{className:`font-medium text-foreground`,children:i.after})]}):f(`span`,{className:`text-foreground`,children:n.chosen.modelId})}),f(`td`,{className:`px-3 py-1.5 text-[11px] text-foreground-muted`,children:n.reasons.map((e,t)=>f(`div`,{children:bi(e)},t))})]},n.deviceKey)})})]})})]})}function Ai({plan:e,nameOf:t,nodeName:n}){let{t:r}=K();return o(`div`,{className:`flex flex-col gap-3 text-xs`,"data-testid":`auto-tune-change-list`,children:[o(`div`,{children:[f(`div`,{className:T,children:r(`pipeline.clusterAutoTuneTab.nodeSettings`,`Node settings`)}),e.nodeChanges.length===0?f(`div`,{className:`text-foreground-subtle`,children:r(`pipeline.clusterAutoTuneTab.noChange`,`No change.`)}):f(`ul`,{className:`mt-1 flex flex-col gap-0.5`,children:e.nodeChanges.flatMap(e=>[...e.modelPins.map(t=>o(`li`,{children:[o(`span`,{className:`font-mono`,children:[n(e.nodeId),` · `,e.deviceKey]}),` `,`— `,t.stepId,`: `,t.before??r(`pipeline.clusterAutoTuneTab.defaultModel`),` →`,` `,t.after??r(`pipeline.clusterAutoTuneTab.stepDefault`,`step default`)]},`${e.nodeId}/${e.deviceKey}/${t.stepId}/pin`)),...e.thresholds.map(t=>o(`li`,{children:[o(`span`,{className:`font-mono`,children:[n(e.nodeId),` · `,e.deviceKey]}),` `,`—`,` `,r(`pipeline.clusterAutoTuneTab.thresholdReset`,{step:t.stepId,keys:t.keys.join(`, `)})]},`${e.nodeId}/${e.deviceKey}/${t.stepId}/thr`))])})]}),o(`div`,{children:[f(`div`,{className:T,children:r(`pipeline.clusterAutoTuneTab.cameraOverridesCleared`,`Camera overrides cleared`)}),e.cameraClears.length===0&&e.detectorStoreClears.length===0?f(`div`,{className:`text-foreground-subtle`,children:r(`pipeline.clusterAutoTuneTab.none`,`None.`)}):o(`ul`,{className:`mt-1 flex flex-col gap-0.5`,children:[e.cameraClears.map((e,i)=>o(`li`,{children:[t(e.deviceId),` — `,n(e.nodeId),e.deviceKey===null?` (${r(`pipeline.clusterAutoTuneTab.wholePipeline`)})`:` · ${e.deviceKey}`,` `,`— `,e.stepId,e.modelIdBefore===null?``:r(`pipeline.clusterAutoTuneTab.modelRemoved`,`: model {{modelIdBefore}} removed`,{modelIdBefore:e.modelIdBefore}),e.keys.length>0?r(`pipeline.clusterAutoTuneTab.reset`,`; {{value1}} reset`,{value1:e.keys.join(`, `)}):``]},`c${i}`)),e.detectorStoreClears.map(e=>o(`li`,{children:[t(e.deviceId),` —`,` `,r(`pipeline.clusterAutoTuneTab.detectorThresholdsReset`,{keys:e.keys.join(`, `)})]},`d${e.deviceId}`))]})]})]})}function ji({result:e}){let{t}=K();return e.kind===`refused`?f(`div`,{className:`text-xs text-warning`,children:t(`pipeline.clusterAutoTuneTab.anotherApplyIsAlreadyRunning`,`Another apply is already running.`)}):e.kind===`stale`?f(`div`,{className:`text-xs text-warning`,children:t(`pipeline.clusterAutoTuneTab.theConfigurationChangedSinceThe`,`The configuration changed since the plan was shown. Review the updated plan below and apply again.`)}):o(`ul`,{className:`text-xs`,"data-testid":`auto-tune-result`,children:[e.kind===`aborted`&&f(`li`,{className:`text-danger`,children:t(`pipeline.clusterAutoTuneTab.aModelCouldNotBe`,`A model could not be downloaded: nothing was changed.`)}),e.phases.map(e=>o(`li`,{className:e.ok?`text-foreground-muted`:`text-danger`,children:[e.ok?`✓`:`✗`,` `,e.phase,`: `,e.detail]},e.phase))]})}function Mi(){let{t:e}=K(),t=l(),[n,a]=i(.4),[s,c]=i(2),[u,d]=i(!1),[p,m]=i(!1),[h,g]=i(null),{data:_}=gn(),v=r(()=>new Map((_??[]).map(e=>[e.id,e.name])),[_]),y=t=>v.get(t)??e(`pipeline.clusterAutoTuneTab.cameraFallback`,{id:t}),{nodes:b}=W(),S=r(()=>er(b),[b]),C=vt({headroom:n,minSessionsPerDevice:s},{enabled:u,refetchOnWindowFocus:!1}),w=Be({onSuccess:e=>{g(e),m(!1),t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getNodeInferenceDevices`]]}),t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCameraStepOverrides`]]}),t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCameraSettings`]]}),e.kind===`applied`&&C.refetch()}}),D=h?.kind===`stale`?h.plan:C.data,O=D===void 0?null:Si(D);return o(`div`,{className:`flex flex-col gap-3`,"data-testid":`cluster-auto-tune`,children:[o(`section`,{className:x,children:[o(`header`,{className:`${I} flex flex-wrap items-center gap-2`,children:[f(E,{className:`h-3.5 w-3.5 shrink-0 text-foreground-subtle`,"aria-hidden":!0}),f(`h3`,{className:`${T} min-w-0 flex-1`,children:e(`pipeline.clusterAutoTuneTab.autoTune`,`Auto tune`)})]}),o(`div`,{className:`flex flex-col gap-2 px-3 py-2 text-xs text-foreground-muted`,children:[f(`p`,{children:e(`pipeline.clusterAutoTuneTab.picksForEveryAcceleratorThe`,`Picks, for every accelerator, the most accurate YOLOv9 detector that still carries at least the chosen number of cameras at once, from the node's hardware and measured speeds. Nothing is measured or estimated about your cameras' activity. Applying it sets those models and clears every model and threshold override — node level and per camera — so each model runs its own default thresholds. Enabled steps, devices, pins, recording, notifications, zones and rules are not touched. There is no undo.`)}),o(`div`,{className:`flex flex-wrap items-center gap-2`,children:[o(`label`,{className:`flex items-center gap-1.5`,children:[f(`span`,{className:`whitespace-nowrap`,children:e(`pipeline.clusterAutoTuneTab.keepFree`,`Keep free`)}),f(Ze,{"aria-label":e(`pipeline.clusterAutoTuneTab.shareOfEachAcceleratorKept`,`Share of each accelerator kept free`),value:String(n),options:Ei.map(t=>({value:String(t),label:e(`pipeline.clusterAutoTuneTab.ofEachAccelerator`,`{{value1}}% of each accelerator`,{value1:Math.round(t*100)})})),onChange:e=>{let t=Number(e.target.value);Di(t)&&a(t)}})]}),o(`label`,{className:`flex items-center gap-1.5`,children:[f(`span`,{className:`whitespace-nowrap`,children:e(`pipeline.clusterAutoTuneTab.atLeast`,`At least`)}),f(Ze,{"aria-label":e(`pipeline.clusterAutoTuneTab.minimumParallelSessionsPerDevice`,`Minimum parallel sessions per device`),value:String(s),options:Oi.map(t=>({value:String(t),label:e(`pipeline.clusterAutoTuneTab.camerasAtOnce`,{count:t})})),onChange:e=>{let t=Number(e.target.value);Oi.some(e=>e===t)&&c(t)}})]}),f(V,{size:`sm`,variant:`secondary`,onClick:()=>{g(null),d(!0),u&&C.refetch()},children:C.isFetching?e(`pipeline.clusterAutoTuneTab.computing`,`Computing…`):D===void 0?e(`pipeline.clusterAutoTuneTab.computePlan`,`Compute plan`):e(`pipeline.clusterAutoTuneTab.recompute`,`Recompute`)}),D!==void 0&&f(V,{size:`sm`,disabled:Ci(D),onClick:()=>m(!0),children:e(`pipeline.clusterAutoTuneTab.apply`,`Apply…`)})]}),C.error!==null&&f(`div`,{className:`text-danger`,children:C.error.message}),h!==null&&f(ji,{result:h}),O!==null&&f(`div`,{className:`text-[11px] text-foreground-subtle`,children:e(`pipeline.clusterAutoTuneTab.planSummary`,{modelChanges:O.modelChanges,thresholdClears:O.thresholdClears,overrides:O.cameraOverrideClears+O.detectorStoreClears,cameras:O.camerasTouched})})]})]}),D?.warnings.map((e,t)=>f(`div`,{className:`rounded-md border border-warning/40 bg-warning/10 px-3 py-2 text-xs text-warning`,children:xi(e,S)},t)),D?.nodes.map(e=>f(ki,{plan:D,node:e,nodeName:S},e.nodeId)),D!==void 0&&f(dt,{open:p,onOpenChange:m,children:o(Ve,{width:`lg`,scroll:`body`,children:[o(Le,{children:[f(Vt,{children:e(`pipeline.clusterAutoTuneTab.applyAutoTune`,`Apply auto tune?`)}),f(at,{children:e(`pipeline.clusterAutoTuneTab.theseAreAllTheChanges`,`These are all the changes. Every override listed is removed and cannot be restored.`)})]}),f(We,{children:f(Ai,{plan:D,nameOf:y,nodeName:S})}),o(Ht,{children:[f(V,{variant:`ghost`,onClick:()=>m(!1),children:e(`common.cancel`,`Cancel`)}),f(V,{variant:`danger`,disabled:w.isPending,onClick:()=>w.mutate({planHash:D.planHash,headroom:n,minSessionsPerDevice:s}),children:w.isPending?e(`pipeline.clusterAutoTuneTab.applying`,`Applying…`):e(`common.apply`,`Apply`)})]})]})})]})}var Ni={disabled:`pipeline.nodeLoadOverview.exclusion.disabled`,unavailable:`pipeline.nodeLoadOverview.exclusion.unavailable`,"cannot-host-camera-root":`pipeline.nodeLoadOverview.exclusion.cannotHostCameraRoot`,"accelerator-preferred":`pipeline.nodeLoadOverview.exclusion.acceleratorPreferred`};function Pi(e,t){return t<=0?0:Math.round(e/t*1e3)/10}function Fi(e){return e===void 0?!1:e.load.devices.reduce((e,t)=>e+t.attachedCameras,0)>=e.load.attachedCameras}function Ii(e,t,n){let r=e.filter(e=>e.exclusion===null).reduce((e,t)=>e+(t.weight>0?t.weight:1),0);return e.map(e=>{let i=t.get(e.key)??(n?0:null),a=e.weight>0?e.weight:1;return{key:e.key,label:Et(e),format:e.format,sessions:i,weight:a,weightSharePct:e.exclusion===null?Pi(a,r):null,maxSessions:e.maxSessions,atCap:e.maxSessions!==null&&i!==null&&i>=e.maxSessions,available:e.available,enabled:e.enabled,exclusion:e.exclusion}}).toSorted((e,t)=>e.exclusion===null==(t.exclusion===null)?e.key.localeCompare(t.key):e.exclusion===null?-1:1)}function Li(e){let t=new Map(e.loads.map(e=>[e.nodeId,e])),n=e.nodes.filter(e=>e.isOnline&&e.detectEnabled).reduce((e,t)=>e+(t.weight>0?t.weight:1),0);return e.nodes.map(r=>{let i=t.get(r.id),a=Ii(e.devicesByNode[r.id]??[],new Map((i?.load.devices??[]).map(e=>[e.deviceKey,e.attachedCameras])),Fi(i)),o=r.isOnline&&r.detectEnabled,s=r.weight>0?r.weight:1,c=i?.load.attachedCameras??null;return{nodeId:r.id,name:r.name,isOnline:r.isOnline,detectEnabled:r.detectEnabled,reported:i!==void 0,attachedCameras:c,activeCameras:i?.load.activeCameras??null,maxCameras:r.maxCameras,capacityPct:c!==null&&r.maxCameras!==null&&r.maxCameras>0?Pi(c,r.maxCameras):null,queueDepthTotal:i?.load.queueDepthTotal??null,avgInferenceTimeMs:i?.load.avgInferenceTimeMs??null,score:i?.score??null,weight:s,weightSharePct:o?Pi(s,n):null,decodeHwaccel:i?.decodeHwaccel??null,devices:a,eligibleDeviceCount:a.filter(e=>e.exclusion===null).length}})}t();var Ri=2e4,zi=3e5;function Bi({stats:e,targetWeights:t}){let{t:n}=K(),{nodes:i}=W(),a=te().trpcClient,o=Ge(void 0,{placeholderData:u,staleTime:Ri,refetchInterval:Ri,refetchOnWindowFocus:!0}),s=mt(void 0,{staleTime:zi}),l=r(()=>i.map(e=>e.id),[i]),d=c({queries:l.map(e=>({queryKey:Fe(mn.pipelineOrchestrator.getNodeInferenceDevices,{nodeId:e},`query`),queryFn:()=>a.pipelineOrchestrator.getNodeInferenceDevices.query({nodeId:e}),staleTime:zi,refetchOnWindowFocus:!1,placeholderData:u}))}),p=r(()=>{let e={};return l.forEach((t,n)=>{let r=d[n]?.data;r&&(e[t]=r.devices)}),e},[l,d.map(e=>e.dataUpdatedAt).join(`|`)]),h=r(()=>{let e=new Map;for(let t of s.data??[])e.set(t.nodeId,t.settings);return e},[s.data]),g=r(()=>i.map(e=>{let n=h.get(e.id);return{id:e.id,name:e.name,isOnline:e.isOnline,detectEnabled:Hn(n,e.isHub).pipeline,weight:t?.[e.id]??Cn(n,`detectWeight`)??1,maxCameras:Cn(n,`maxCameras`)}}),[i,h,t]),_=o.data??[],v=r(()=>Li({nodes:g,loads:_,devicesByNode:p}),[g,_,p]),y=v.reduce((e,t)=>e+(t.attachedCameras??0),0),b=v.reduce((e,t)=>e+(t.activeCameras??0),0),x=o.dataUpdatedAt>0?Date.now()-o.dataUpdatedAt:null,C=new Map((e?.nodes??[]).map(e=>[e.nodeId,e]));return f(H,{headingId:`load-balancing-node-load`,title:n(`pipeline.nodeLoadOverview.nodeLoad`,`Node load`),icon:S,actions:f(`span`,{className:`text-[10px] text-foreground-subtle tabular-nums`,children:n(`pipeline.nodeLoadOverview.summaryLine`,{active:b,attached:y,reading:o.data===void 0?n(`pipeline.nodeLoadOverview.reading`,`reading…`):n(`pipeline.nodeLoadOverview.readingAge`,{age:x===null?`—`:`${Math.round(x/1e3)}s`})})}),children:f(`div`,{className:m,children:v.length===0?f(`p`,{className:`text-[11px] italic text-foreground-subtle`,children:n(`pipeline.nodeLoadOverview.noClusterNodesReportedYet`,`No cluster nodes reported yet.`)}):f(`div`,{className:`grid gap-2 @2xl/clustertab:grid-cols-2 @5xl/clustertab:grid-cols-3`,children:v.map(e=>f(Vi,{row:e,placed:C.get(e.nodeId)},e.nodeId))})})})}function Vi({row:e,placed:t}){let{t:n}=K(),r=e.attachedCameras===null?`—`:`${e.activeCameras??0} / ${e.attachedCameras}${e.maxCameras===null?``:` of ${e.maxCameras}`}`;return o(`div`,{className:`rounded-lg border border-border bg-surface/60 p-2.5 min-w-0`,children:[o(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[f(`span`,{className:`h-1.5 w-1.5 shrink-0 rounded-full ${e.isOnline?`bg-emerald-400`:`bg-foreground-subtle/40`}`}),f(`span`,{className:`truncate text-xs font-medium text-foreground`,title:e.nodeId,children:e.name}),!e.detectEnabled&&f(`span`,{className:`shrink-0 rounded bg-surface-hover px-1 text-[9px] uppercase tracking-wide text-foreground-subtle`,children:n(`pipeline.nodeLoadOverview.noDetect`,`no detect`)}),!e.reported&&e.isOnline&&o(`span`,{className:`ml-auto inline-flex shrink-0 items-center gap-1 text-[9px] text-amber-400`,title:n(`pipeline.nodeLoadOverview.onlineButItDidNot`,`Online, but it did not answer the last load read — its numbers below are unknown, not zero.`),children:[f(b,{className:`h-2.5 w-2.5`}),` `,n(`pipeline.nodeLoadOverview.noReading`)]}),!e.isOnline&&o(`span`,{className:`ml-auto inline-flex shrink-0 items-center gap-1 text-[9px] text-foreground-subtle`,children:[f(k,{className:`h-2.5 w-2.5`}),` `,n(`common.offline`)]})]}),o(`dl`,{className:`mt-1.5 grid grid-cols-2 gap-x-2 gap-y-0.5 text-[10px]`,children:[f(J,{label:n(`pipeline.nodeLoadOverview.runningAttached`,`Running / attached`),value:r,title:n(`pipeline.nodeLoadOverview.sessionsInInferenceNowCameras`,`Sessions in inference now / cameras attached to this runner (the balancer's committed load) / operator cap.`)}),f(J,{label:n(`pipeline.nodeLoadOverview.targetShare`,`Target share`),value:e.weightSharePct===null?`out of play`:`${e.weightSharePct}%`,title:n(`pipeline.nodeLoadOverview.theNodeShareAutomaticOr`,`The node share (automatic or manual) normalised over the nodes the balancer actually ranks (online AND detect-enabled).`)}),f(J,{label:n(`pipeline.nodeLoadOverview.actualShare1H`,`Actual share (1 h)`),value:t?.observedShare===null||t===void 0?`—`:`${Math.round(t.observedShare*100)}%`,title:n(`pipeline.nodeLoadOverview.timeWeightedShareOfThe`,`Time-weighted share of the cluster's PARALLEL detection sessions this node carried over the last hour — the quantity a share holds. '—' = no session ran here in the window.`)}),f(J,{label:n(`pipeline.nodeLoadOverview.peakYields`,`Peak · yields`),value:t===void 0?`—`:`${t.peakSessions} · ${t.yieldsAway}`,title:n(`pipeline.nodeLoadOverview.mostSessionsThisNodeRan`,`Most sessions this node ran at once in the last hour, and how many share turns it handed to another node because it was full or drowning.`)}),f(J,{label:n(`pipeline.nodeLoadOverview.scoreQueue`,`Score · queue`),value:e.score===null?`—`:`${e.score} · ${e.queueDepthTotal??0}`,title:n(`pipeline.nodeLoadOverview.theCapacityScoreBalanceMinimises`,`The capacity score balance() minimises (attached + queue depth), and the raw queue depth.`)}),e.capacityPct!==null&&f(J,{label:n(`pipeline.nodeLoadOverview.capFill`,`Cap fill`),value:`${e.capacityPct}%`,title:n(`pipeline.nodeLoadOverview.attachedMaxcameras`,`attached / maxCameras.`)}),e.avgInferenceTimeMs!==null&&f(J,{label:n(`pipeline.nodeLoadOverview.avgInfer`,`Avg infer`),value:`${Math.round(e.avgInferenceTimeMs)} ms`,title:n(`pipeline.nodeLoadOverview.meanInferenceTimeAcrossThis`,`Mean inference time across this node's attached cameras.`)}),e.decodeHwaccel!==null&&f(J,{label:n(`pipeline.nodeLoadOverview.decode`,`Decode`),value:e.decodeHwaccel,title:n(`pipeline.nodeLoadOverview.thisNodeSProbedDecode`,`This node's probed decode hwaccel.`)})]}),f(Hi,{row:e})]})}function Hi({row:e}){let{t}=K();return e.devices.length===0?f(`p`,{className:`mt-2 text-[10px] italic text-foreground-subtle`,children:t(`pipeline.nodeLoadOverview.acceleratorsNotReadYet`,`Accelerators not read yet.`)}):o(`div`,{className:`mt-2 border-t border-border pt-1.5`,children:[o(`div`,{className:`flex items-center gap-1 text-[9px] uppercase tracking-wider text-foreground-subtle`,children:[f(w,{className:`h-2.5 w-2.5`}),t(`pipeline.nodeLoadOverview.accelerators`,`Accelerators`),e.eligibleDeviceCount===0&&f(`span`,{className:`ml-1 normal-case tracking-normal text-amber-400`,title:t(`pipeline.nodeLoadOverview.noDeviceIsACamera`,`No device is a camera-root candidate on this node — sessions run on the runner's default (CPU) pool.`),children:t(`pipeline.nodeLoadOverview.noneInPlayRunnerDefault`,`none in play · runner default pool`)})]}),f(`ul`,{className:`mt-1 space-y-0.5`,children:e.devices.map(e=>f(Ui,{device:e},e.key))})]})}function Ui({device:e}){let{t}=K(),n=e.exclusion;return o(`li`,{className:`flex items-baseline gap-1.5 text-[10px] min-w-0`,children:[f(g,{className:`h-2.5 w-2.5 shrink-0 ${n===null?`text-foreground-subtle`:`text-foreground-subtle/50`}`}),f(`span`,{className:`shrink-0 font-medium ${n===null?`text-foreground`:`text-foreground-subtle`}`,title:`${e.key} · ${e.format}`,children:e.label}),n===null?o(s,{children:[f(`span`,{className:`shrink-0 tabular-nums text-foreground-subtle`,children:t(`pipeline.nodeLoadOverview.sharePct`,{pct:e.weightSharePct})}),o(`span`,{className:`shrink-0 tabular-nums text-foreground-subtle`,title:e.sessions===null?t(`pipeline.nodeLoadOverview.notKnownTheNodeDid`,`Not known: the node did not report, or runs a session no device accounts for.`):void 0,children:[`· `,t(`common.sessionsCount`,{count:e.sessions??0}),e.maxSessions===null?``:`/${e.maxSessions}`]}),e.atCap&&f(`span`,{className:`shrink-0 text-amber-400`,title:t(`pipeline.nodeLoadOverview.atItsMaxsessionsCapThe`,`At its maxSessions cap — the balancer skips it until a session ends.`),children:t(`pipeline.nodeLoadOverview.atCap`,`· at cap`)})]}):f(`span`,{className:`truncate text-foreground-subtle/80`,title:t(Ni[n]),children:t(`pipeline.nodeLoadOverview.excludedWith`,{reason:t(Ni[n])})})]})}function J({label:e,value:t,title:n}){return o(`div`,{className:`min-w-0`,title:n,children:[f(`dt`,{className:`text-[9px] uppercase tracking-wide text-foreground-subtle`,children:e}),f(`dd`,{className:`truncate font-medium tabular-nums text-foreground`,children:t})]})}function Wi(e){return{nodes:Object.fromEntries(e.map(e=>[e.nodeId,Math.max(1,e.weight)])),devices:{}}}function Gi(e){let t={},n={};for(let r of e.nodes){if(r.share===null||r.share<=0)continue;t[r.nodeId]=r.share;let e=Object.fromEntries(r.devices.filter(e=>e.share>0).map(e=>[e.deviceKey,e.share]));Object.keys(e).length>0&&(n[r.nodeId]=e)}return{nodes:t,devices:n}}function Ki(e){return Object.fromEntries(e.nodes.map(e=>[e.nodeId,Object.fromEntries(e.devices.map(e=>[e.deviceKey,e.suggestedMaxSessions]))]))}function qi(e){return e.reason===`disabled`?G.t(`helpers.loadBalancingViewModel.stalePinDisabled`,{deviceKey:e.deviceKey}):G.t(`helpers.loadBalancingViewModel.stalePinMissing`,{deviceKey:e.deviceKey})}function Ji(e,t){if(t===void 0||t.source===`manual`||t.autoPending)return{nodes:e,readOnly:t!==void 0&&t.source!==`manual`};let n=new Map(t.nodes.map(e=>[e.nodeId,e.configuredPct]));return{nodes:e.map(e=>({...e,weight:Math.round(n.get(e.id)??e.weight)})),readOnly:!0}}function Yi(e,t){let n=e.nodes.filter(e=>!e.eligible);if(n.length===0)return null;let r=e.nodes.filter(e=>e.eligible).map(e=>`${t(e.nodeId)} ${Math.round(e.effectivePct)}%`).join(`, `),i=n.map(e=>t(e.nodeId)).join(`, `);return G.t(`helpers.loadBalancingViewModel.shareNote`,{count:n.length,names:i,into:r})}var Xi=[{value:`hardware`,get label(){return G.t(`helpers.loadBalancingViewModel.hardwareLabel`)},get hint(){return G.t(`helpers.loadBalancingViewModel.hardwareHint`)}},{value:`benchmark`,get label(){return G.t(`helpers.loadBalancingViewModel.benchmarkLabel`)},get hint(){return G.t(`helpers.loadBalancingViewModel.benchmarkHint`)}},{value:`manual`,get label(){return G.t(`helpers.loadBalancingViewModel.manualLabel`)},get hint(){return G.t(`helpers.loadBalancingViewModel.manualHint`)}}];function Zi(e){return e===`no-benchmark-results`?G.t(`helpers.loadBalancingViewModel.fallbackNone`):e===`partial-benchmark-results`?G.t(`helpers.loadBalancingViewModel.fallbackPartial`):null}function Qi(e,t){if(e.source!==`benchmark`)return null;let n=e.nodes.filter(e=>e.capacityFallback!==null);return n.length===0?null:n.map(e=>`${t(e.nodeId)}: ${Zi(e.capacityFallback)??``}`).join(` · `)}t();function $i(e,t,n){return Math.min(Math.max(e,t),n)}function ea(e){let t=e.reduce((e,t)=>e+Math.max(t.weight,0),0);if(t<=0){let t=e.length>0?100/e.length:0;return Object.fromEntries(e.map(e=>[e.id,t]))}return Object.fromEntries(e.map(e=>[e.id,Math.max(e.weight,0)/t*100]))}function ta(e,t,n,r,i){let a=i.filter(e=>e!==t&&r.has(e)).reduce((t,n)=>t+Math.max(e[n]??0,0),0),o=Math.max(0,100-a),s=i.filter(e=>e!==t&&!r.has(e)),c=s.length===0?o:$i(n,0,o),l={...e,[t]:c};if(s.length>0){let e=Math.max(0,o-c)/s.length;for(let t of s)l[t]=e}return l}function na(e,t,n){let r={},i=0,a=[];for(let o of t){let t=Math.max(e[o]??0,0);if(n.has(o)){let e=Math.round(t);r[o]=e,i+=e}else{let e=Math.floor(t);r[o]=e,a.push({id:o,floor:e,frac:t-e})}}let o=Math.max(0,100-i)-a.reduce((e,t)=>e+t.floor,0),s=[...a].sort((e,t)=>t.frac-e.frac);for(let e=0;o>0&&s.length>0;e+=1)r[s[e%s.length].id]+=1,--o;let c=[...a].sort((e,t)=>e.frac-t.frac);for(let e=0;o<0&&c.length>0;e+=1){let t=c[e%c.length].id;r[t]>0&&(--r[t],o+=1)}return r}function ra({nodes:e,pending:t,onCommitWeights:r,weightLabel:a=`Detection weight`,emptyHint:c,footnote:l,readOnly:u=!1}){let{t:d}=K(),[p,m]=i(()=>ea(e)),[h,g]=i(new Set);n(()=>{m(ea(e)),g(t=>new Set([...t].filter(t=>e.some(e=>e.id===t))))},[e.map(e=>`${e.id}:${e.weight}`).join(`|`)]);let _=e.map(e=>e.id),v=e=>{g(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},y=(e,t)=>{m(n=>ta(n,e,t,h,_))},b=()=>{let t=na(p,_,h),n=e.filter(e=>(t[e.id]??0)!==e.weight).map(e=>e.id);if(n.length===0)return;let i=new Set([...n,...h]);r(e.filter(e=>i.has(e.id)).map(e=>({nodeId:e.id,weight:t[e.id]??0})))};if(e.length===0)return f(`p`,{className:`rounded-lg border border-dashed border-border bg-background px-4 py-6 text-center text-xs text-foreground-subtle`,children:c??d(`placementBoard.weightSliderStack.noDetectEnabledNodesEnable`,`No detect-enabled nodes. Enable “Detect” on a node above to distribute detection weight.`)});let x=e.length===1;return o(`div`,{className:`space-y-3`,children:[e.map(e=>{let n=p[e.id]??0,r=h.has(e.id);return o(`div`,{className:`flex items-center gap-3`,children:[f(`span`,{className:`w-28 shrink-0 truncate text-xs font-medium text-foreground`,title:e.name,children:e.name}),f(`input`,{"aria-label":d(`placementBoard.weightSliderStack.for`,`{{weightLabel}} for {{name}}`,{weightLabel:a,name:e.name}),type:`range`,min:0,max:100,step:1,value:Math.round(n),disabled:u||t||r||x,onChange:t=>y(e.id,Number(t.target.value)),onPointerUp:()=>b(),onKeyUp:()=>b(),className:`h-1.5 flex-1 cursor-pointer accent-primary disabled:cursor-not-allowed disabled:opacity-50`}),o(`span`,{className:`w-10 shrink-0 text-right font-mono text-xs tabular-nums text-foreground`,children:[Math.round(n),`%`]}),!u&&f(`button`,{type:`button`,onClick:()=>v(e.id),disabled:t||x,"aria-pressed":r,title:r?d(`placementBoard.weightSliderStack.unlockAllowRebalancing`,`Unlock — allow rebalancing`):d(`placementBoard.weightSliderStack.lockThisShareWhenOthers`,`Lock this share when others change`),className:`shrink-0 rounded p-1 hover:bg-surface-hover disabled:opacity-40 ${r?`text-amber-400`:`text-foreground-subtle`}`,children:f(r?ee:re,{className:`h-3.5 w-3.5`})})]},e.id)}),f(`p`,{className:`text-[10px] leading-tight text-foreground-subtle`,children:l??f(s,{children:d(`placementBoard.weightSliderStack.draggingOneSliderSplitsThe`,`Dragging one slider splits the rest equally across the unlocked nodes; lock a node to pin its share — locked nodes never move and the total always stays at 100%, so a drag is bounded by the room the unlocked nodes leave. Detection only distributes across nodes that can source a camera’s frames.`)})})]})}function ia(e){let t=e.steps?.[`object-detection`]?.modelId;return typeof t==`string`&&t.length>0?t:typeof e.defaultModelId==`string`&&e.defaultModelId.length>0?e.defaultModelId:null}t();function aa(e){let t=Et(e),n=e.backend.toLowerCase(),r=e.device.toLowerCase();return e.key===`cpu`||r===`cpu`?{label:t,Icon:g,hue:`slate`}:r===`npu`?{label:t,Icon:ie,hue:`sky`}:r===`gpu`||r===`igpu`?{label:t,Icon:fe,hue:`violet`}:n===`edgetpu`?{label:t,Icon:ge,hue:`emerald`}:{label:t,Icon:g,hue:`slate`}}var oa={sky:`bg-sky-500/12 text-sky-400 ring-sky-500/25`,violet:`bg-violet-500/12 text-violet-400 ring-violet-500/25`,emerald:`bg-emerald-500/12 text-emerald-400 ring-emerald-500/25`,slate:`bg-surface-hover text-foreground-subtle ring-border`};function sa({nodeId:e,nodeName:t,isOnline:a,suggestedMaxSessions:c,autoDeviceShares:u}){let{t:d}=K(),p=l(),{data:m,isLoading:h}=tt({nodeId:e},{refetchInterval:15e3}),g=bt({onSettled:()=>{p.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getNodeInferenceDevices`]]})}}),_=m?.devices??[],v=m?.reachable??a,[y,b]=i({});n(()=>{b(Object.fromEntries(_.map(e=>[e.key,{enabled:e.enabled,weight:e.weight,maxSessions:e.maxSessions,steps:e.steps??{}}])))},[_.map(e=>`${e.key}:${e.enabled}:${e.weight}:${e.maxSessions}:${JSON.stringify(e.steps??{})}`).join(`|`)]);let x=r(()=>_.filter(e=>y[e.key]?.enabled??e.enabled).length,[_,y]),[S,C]=i(null),w=S??x>0,T=t=>{let n=_.map(e=>{let n=t[e.key]??E(e);return{key:e.key,enabled:n.enabled,weight:n.weight,maxSessions:n.maxSessions,steps:n.steps}});g.mutate({agentNodeId:e,inferenceDevices:Mr(n)})},E=e=>({enabled:e.enabled,weight:e.weight,maxSessions:e.maxSessions,steps:e.steps??{}}),D=e=>{if(!e.available)return;let t=y[e.key]??E(e),n={...y,[e.key]:{...t,enabled:!t.enabled}};b(n),T(n)},A=(e,t)=>{let n=y[e.key]??E(e),r={...y,[e.key]:{...n,maxSessions:t}};b(r),T(r)},j=r(()=>_.filter(e=>(y[e.key]?.enabled??e.enabled)&&e.available),[_,y]),M=r(()=>j.map(e=>({id:e.key,name:aa(e).label,weight:u===void 0?y[e.key]?.weight??e.weight:Math.round(u[e.key]??0)})),[j,y,u]);return o(`div`,{className:`rounded-lg border border-border bg-surface/60`,children:[o(`button`,{type:`button`,onClick:()=>C(!w),className:`flex w-full items-center gap-2.5 px-3.5 py-2.5 text-left`,"aria-expanded":w,children:[f(O,{className:`h-4 w-4 shrink-0 text-foreground-subtle transition-transform ${w?`rotate-90`:``}`}),f(`span`,{className:`truncate text-[13px] font-medium text-foreground`,children:t}),f(`span`,{className:`ml-auto flex items-center gap-2 text-[11px]`,children:v?x>=2?o(`span`,{className:`inline-flex items-center gap-1 text-emerald-400`,children:[f(ve,{className:`h-3.5 w-3.5`}),d(`pipeline.nodeInferenceDevices.accelerators`,{count:x})]}):x===1?f(`span`,{className:`text-foreground-subtle`,children:d(`placementBoard.nodeInferenceDevices.singleDefault`,`single default`)}):f(`span`,{className:`text-foreground-subtle/70`,children:d(`placementBoard.nodeInferenceDevices.autoDefault`,`auto default`)}):o(`span`,{className:`inline-flex items-center gap-1 text-foreground-subtle`,children:[f(k,{className:`h-3.5 w-3.5`}),` `,d(`common.unreachable`)]})})]}),w&&o(`div`,{className:`space-y-3 border-t border-border px-3.5 py-3`,children:[v?h&&_.length===0?f(`p`,{className:`rounded-lg border border-dashed border-border bg-background px-4 py-6 text-center text-xs text-foreground-subtle`,children:d(`placementBoard.nodeInferenceDevices.probingAccelerators`,`Probing accelerators…`)}):_.length===0?f(`p`,{className:`rounded-lg border border-dashed border-border bg-background px-4 py-6 text-center text-xs text-foreground-subtle`,children:d(`placementBoard.nodeInferenceDevices.noInferenceDevicesReportedBy`,`No inference devices reported by this node's platform probe.`)}):f(`ul`,{className:`space-y-2`,children:_.map(e=>{let t=aa(e),n=y[e.key]??E(e),r=n.enabled&&e.available,i=ia({defaultModelId:e.defaultModelId,steps:n.steps});return o(`li`,{className:`flex items-center gap-3 rounded-lg border px-3 py-2.5 transition-colors ${e.available?r?`border-primary/40 bg-primary/[0.04] ring-1 ring-inset ring-primary/20`:`border-border bg-surface`:`border-border/60 bg-background opacity-55`}`,children:[f(`span`,{className:`grid h-9 w-9 shrink-0 place-items-center rounded-md ring-1 ring-inset ${oa[t.hue]}`,children:f(t.Icon,{className:`h-4.5 w-4.5`})}),o(`div`,{className:`min-w-0 flex-1`,children:[o(`div`,{className:`flex items-center gap-2`,children:[f(`span`,{className:`truncate text-[13px] font-medium text-foreground`,children:t.label}),f(U,{variant:`default`,style:`outline`,className:`font-mono text-[9px]`,children:e.format}),!e.available&&f(U,{variant:`warning`,className:`text-[9px]`,children:d(`common.unavailable`)})]}),o(`div`,{className:`mt-0.5 flex items-center gap-1.5 text-[10px] text-foreground-subtle`,children:[f(`span`,{className:`font-mono`,children:e.key}),i!==null&&o(s,{children:[f(`span`,{"aria-hidden":!0,children:`·`}),f(`span`,{children:f(vn,{i18nKey:`pipeline.nodeInferenceDevices.rootModel`,values:{model:i},components:{mono:f(`span`,{className:`font-mono text-foreground/80`})}})})]})]})]}),r&&o(`label`,{className:`flex shrink-0 items-center gap-1 text-[10px] text-foreground-subtle`,children:[f(`span`,{className:`hidden @sm/clustertab:inline`,children:d(`pipeline.nodeInferenceDevices.cap`)}),f(`input`,{type:`number`,min:1,placeholder:`∞`,value:n.maxSessions??``,onChange:t=>{let n=t.target.value.trim(),r=n===``?null:Number.parseInt(n,10);A(e,r!=null&&r>0?r:null)},disabled:g.isPending,"aria-label":d(`placementBoard.nodeInferenceDevices.maxConcurrentSessionsFor`,`Max concurrent sessions for {{label}}`,{label:t.label}),className:`w-14 rounded border border-border bg-background px-1.5 py-1 text-right font-mono text-[11px] text-foreground focus:border-primary focus:outline-none`})]}),r&&f(ca,{suggested:c?.[e.key]??null,current:n.maxSessions,pending:g.isPending,onApply:t=>A(e,t)}),f(Bt,{checked:r,onCheckedChange:()=>D(e),disabled:!e.available||g.isPending,"aria-label":d(`placementBoard.nodeInferenceDevices.enable`,`Enable {{label}}`,{label:t.label}),className:e.available?``:`cursor-not-allowed opacity-50`})]},e.key)})}):f(la,{}),v&&j.length>=2&&o(`div`,{className:`space-y-3 rounded-lg border border-border bg-background/60 p-3.5`,children:[o(`h4`,{className:`flex items-center gap-1.5 text-xs font-semibold uppercase tracking-wide text-foreground-subtle`,children:[f(me,{className:`h-3.5 w-3.5`}),d(`placementBoard.nodeInferenceDevices.acceleratorShare`,`Accelerator share`)]}),f(ra,{nodes:M,pending:g.isPending,onCommitWeights:e=>{let t={...y};for(let n of e){let e=t[n.nodeId];e&&(t[n.nodeId]={...e,weight:n.weight})}b(t),T(t)},weightLabel:`Accelerator share`,readOnly:u!==void 0,footnote:u===void 0?f(s,{children:d(`placementBoard.nodeInferenceDevices.dragToShiftTheShare`,`Drag to shift the share of detection sessions each accelerator handles; lock one to pin its share while the others rebalance. Shares always sum to 100%.`)}):f(s,{children:d(`placementBoard.nodeInferenceDevices.automaticEachAcceleratorSShare`,`Automatic: each accelerator's share follows its measured throughput at its model. Switch the node shares to manual to set them yourself.`)})})]}),g.isError&&o(`div`,{className:`rounded-md border border-danger/30 bg-danger/5 px-3 py-2 text-[11px] text-danger`,children:[d(`placementBoard.nodeInferenceDevices.failedToSaveInferenceDevices`,`Failed to save inference devices:`),` `,g.error instanceof Error?g.error.message:d(`placementBoard.nodeInferenceDevices.unknownError`,`unknown error`)]})]})]})}function ca({suggested:e,current:t,pending:n,onApply:r}){let{t:i}=K();return e===null||e<1||e===t?null:f(V,{variant:`ghost`,size:`sm`,onClick:()=>r(e),disabled:n,title:i(`placementBoard.nodeInferenceDevices.advisoryCapFromTheMeasured`,`Advisory cap from the measured throughput at the suggested model, with the headroom kept free. Applying it writes this device's cap.`),children:i(`pipeline.nodeInferenceDevices.use`,{value:e})})}function la(){let{t:e}=K();return o(`div`,{className:`flex flex-col items-center gap-2 rounded-lg border border-dashed border-border bg-background px-4 py-8 text-center`,children:[f(k,{className:`h-6 w-6 text-foreground-subtle/60`}),f(`p`,{className:`text-xs font-medium text-foreground`,children:e(`placementBoard.nodeInferenceDevices.nodeUnreachable`,`Node unreachable`)}),f(`p`,{className:`max-w-sm text-[11px] text-foreground-subtle`,children:e(`placementBoard.nodeInferenceDevices.thePlatformProbeCouldnT`,`The platform probe couldn't be reached, so its live accelerator set is unavailable. Settings resume once the node reconnects.`)})]})}t();var ua=3600*1e3,da=2e4,fa=.4;function pa({refreshToken:e,onOpenAutoTune:t}){let{t:n}=K(),a=l(),{nodes:c}=W(),d=mt(void 0),p=Lt({isCamera:!0,projection:`slim`}),h=gt({windowMs:ua},{refetchInterval:da,placeholderData:u}).data,_=Ye(void 0,{refetchInterval:da,placeholderData:u}).data,v=()=>{Dn(a),a.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getNodeInferenceDevices`]]})},y=qt({onSuccess:v}),b=jt({onSuccess:()=>{v(),a.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getEffectiveShares`]]})}}),x=Tt({onSuccess:v}),S=qe(),[w,T]=i(!1),D=_?.source,O=D===`benchmark`?`benchmark`:`hardware`,k=Ut({headroom:fa,source:O},{enabled:w,staleTime:1/0}),A=k.data,j=r(()=>{let e=new Map((d.data??[]).map(e=>[e.nodeId,e.settings]));return c.filter(t=>Hn(e.get(t.id),t.isHub).pipeline).map(t=>{let n=e.get(t.id);return{id:t.id,name:t.name,isOnline:t.isOnline,weight:Cn(n,`detectWeight`)??1,maxCameras:Cn(n,`maxCameras`)}})},[c,d.data]),M=e=>c.find(t=>t.id===e)?.name??e,N=tr((p.data??[]).map(e=>({id:e.id,name:e.name}))),P=A?Ki(A):void 0,F=Ji(j,_),I=D!==`manual`,ee=e=>{if(_===void 0||_.source===`manual`||_.autoPending)return;let t=_.nodes.find(t=>t.nodeId===e);return t===void 0?void 0:Object.fromEntries(t.devices.map(e=>[e.deviceKey,e.configuredPct]))},te=_?Yi(_,M):null,ne=_?Qi(_,M):null,re=Xi.find(e=>e.value===D)?.hint;return o(`div`,{className:`space-y-3 sm:space-y-4`,children:[f(bn,{nodeId:`hub`,addonIds:[jn],level:`global`,sectionIds:[`load`],title:n(`pipeline.clusterLoadBalancingTab.placementPolicy`,`Placement policy`),description:n(`pipeline.clusterLoadBalancingTab.howANewDetectionSession`,`How a new detection session picks its node and device, and what happens when a node falls behind. 'Honour shares' (default) holds the shares below for PARALLEL sessions.`)}),f(qn,{refreshToken:e}),f(Bi,{stats:h,..._!==void 0&&_.source!==`manual`&&!_.autoPending?{targetWeights:Object.fromEntries(_.nodes.map(e=>[e.nodeId,e.configuredPct]))}:{}}),f(H,{headingId:`load-balancing-node-shares`,title:n(`pipeline.clusterLoadBalancingTab.nodeShares`,`Node shares`),icon:me,actions:o(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[f(`div`,{role:`radiogroup`,"aria-label":n(`pipeline.clusterLoadBalancingTab.shareSource`,`Share source`),className:`flex items-center gap-1`,children:Xi.map(e=>f(V,{role:`radio`,"aria-checked":D===e.value,variant:D===e.value?`primary`:`outline`,size:`sm`,title:e.hint,disabled:b.isPending||_===void 0,onClick:()=>{D!==e.value&&b.mutate({source:e.value})},children:e.label},e.value))}),o(V,{variant:`outline`,size:`sm`,onClick:()=>{T(!0),w&&k.refetch()},disabled:k.isFetching,children:[f(L,{className:`h-3.5 w-3.5`}),k.isFetching?n(`pipeline.clusterLoadBalancingTab.suggesting`,`Suggesting…`):O===`benchmark`?n(`pipeline.clusterLoadBalancingTab.suggestFromBenchmark`,`Suggest from benchmark`):n(`pipeline.clusterLoadBalancingTab.suggestFromHardware`,`Suggest from hardware`)]}),o(V,{variant:`ghost`,size:`sm`,onClick:t,children:[f(E,{className:`h-3.5 w-3.5`}),n(`pipeline.clusterLoadBalancingTab.autoTune`,`Auto tune`)]}),o(V,{variant:`outline`,size:`sm`,onClick:()=>S.mutate(void 0),disabled:S.isPending,title:n(`pipeline.clusterLoadBalancingTab.moveStandingAlwaysOnCameras`,`Move standing (always-on) cameras that are no longer on their best node. Pinned cameras never move; on-motion sessions are placed per session anyway.`),children:[f(ie,{className:`h-3.5 w-3.5`}),S.isPending?n(`pipeline.clusterLoadBalancingTab.rebalancing`,`Rebalancing…`):n(`pipeline.clusterLoadBalancingTab.rebalance`,`Rebalance`)]})]}),children:o(`div`,{className:`${m} space-y-3`,children:[re!==void 0&&f(`p`,{className:`text-[10px] text-foreground-subtle`,children:re}),h&&o(`p`,{className:`text-[10px] text-foreground-subtle`,children:[n(`pipeline.clusterLoadBalancingTab.policy`,`Policy:`),` `,f(U,{variant:h.policy===`share`?`info`:`default`,children:h.policy===`share`?n(`pipeline.clusterLoadBalancingTab.honourShares`,`honour shares`):`least-loaded`}),` `,` · ${n(`pipeline.clusterLoadBalancingTab.clusterPeak`,{count:h.clusterPeakSessions})}`,h.policy===`least-loaded`&&` · ${n(`pipeline.clusterLoadBalancingTab.leastLoadedNote`)}`]}),f(ra,{nodes:F.nodes,pending:y.isPending,readOnly:F.readOnly,onCommitWeights:e=>y.mutate(Wi(e)),weightLabel:`Node share`,...F.readOnly?{footnote:_?.autoPending?f(s,{children:n(`pipeline.clusterLoadBalancingTab.automaticSharesAreBeingComputed`,`Automatic shares are being computed from the cluster's measured capacity; the stored values are used meanwhile.`)}):o(s,{children:[D===`benchmark`?n(`pipeline.clusterLoadBalancingTab.benchmarkEachNodeSShare`,`Benchmark: each node's share follows its measured capacity from node benchmark results (hardware capacity where it has none)`):n(`pipeline.clusterLoadBalancingTab.hardwareEachNodeSShare`,`Hardware: each node's share follows its capacity at its Auto tune model, from the measured speed of its hardware`),n(`pipeline.clusterLoadBalancingTab.recomputedWheneverANodeOr`,`, recomputed whenever a node or accelerator is added, removed, switched on or off, or changes model`),_?.computedAt!=null&&f(`span`,{className:`ml-1`,children:n(_.trigger===null?`pipeline.clusterLoadBalancingTab.lastAt`:`pipeline.clusterLoadBalancingTab.lastAtTrigger`,{time:new Date(_.computedAt).toLocaleTimeString(),trigger:_.trigger??``})}),`.`]})}:{}}),te!==null&&f(`p`,{className:`text-[10px] text-foreground-subtle`,children:te}),ne!==null&&f(`p`,{className:`text-[10px] text-foreground-subtle`,"data-testid":`benchmark-fallback-note`,children:ne}),b.isError&&f(et,{message:n(`pipeline.clusterLoadBalancingTab.switchFailed`,{message:b.error instanceof Error?b.error.message:n(`common.unknownError`)})}),y.isError&&f(et,{message:n(`pipeline.clusterLoadBalancingTab.saveFailed`,{message:y.error instanceof Error?y.error.message:n(`common.unknownError`)})}),o(`details`,{className:`rounded-md border border-border`,children:[f(`summary`,{className:`${C} cursor-pointer text-xs text-foreground`,children:n(`pipeline.clusterLoadBalancingTab.maxConcurrentSessionsAdvanced`,`Max concurrent sessions (advanced)`)}),f(`ul`,{className:`divide-y divide-border border-t border-border`,children:j.map(e=>o(`li`,{className:`${C} flex items-center gap-2`,children:[f(`span`,{className:`min-w-0 flex-1 truncate text-xs text-foreground`,children:e.name}),f(Ie,{type:`number`,min:1,placeholder:`∞`,defaultValue:e.maxCameras??``,"aria-label":n(`pipeline.clusterLoadBalancingTab.maxConcurrentSessionsFor`,`Max concurrent sessions for {{name}}`,{name:e.name}),className:`w-20 text-right`,disabled:x.isPending,onBlur:t=>{let n=t.target.value.trim(),r=n===``?null:Number.parseInt(n,10),i=r!==null&&r>0?r:null;i!==e.maxCameras&&x.mutate({agentNodeId:e.id,maxCameras:i})}})]},e.id))}),f(`p`,{className:`${C} ${B} border-t border-border`,children:n(`pipeline.clusterLoadBalancingTab.aHardCapOnThe`,`A hard cap on the sessions a node runs at once (always-on cameras count too). A node at its cap is never chosen; under shares its turn goes to a free node. Empty = unlimited.`)})]})]})}),k.isError&&f(et,{message:n(`pipeline.clusterLoadBalancingTab.suggestionFailed`,{message:k.error instanceof Error?k.error.message:n(`common.unknownError`)})}),A&&f(ma,{suggestion:A,nameOf:M,pending:y.isPending,...I?{}:{onApply:()=>y.mutate(Gi(A))}}),f(H,{headingId:`load-balancing-accelerators`,title:n(`pipeline.clusterLoadBalancingTab.accelerators`,`Accelerators`),icon:g,children:f(`div`,{className:`${m} space-y-2`,children:j.length===0?f(st,{title:n(`pipeline.clusterLoadBalancingTab.noDetectCapableNodes`,`No detect-capable nodes`),description:n(`pipeline.clusterLoadBalancingTab.enableDetectionOnANode`,`Enable detection on a node in Roles & nodes to configure its accelerators.`)}):j.map(e=>f(sa,{nodeId:e.id,nodeName:e.name,isOnline:e.isOnline,...P?.[e.id]===void 0?{}:{suggestedMaxSessions:P[e.id]},...ee(e.id)===void 0?{}:{autoDeviceShares:ee(e.id)}},e.id))})}),h!==void 0&&h.stalePins.length>0&&f(ha,{stats:h,cameraName:N})]})}function ma({suggestion:e,nameOf:t,pending:n,onApply:r}){let{t:i}=K();return o(H,{headingId:`load-balancing-suggestion`,title:e.source===`benchmark`?i(`pipeline.clusterLoadBalancingTab.suggestedFromBenchmark`,`Suggested from benchmark`):i(`pipeline.clusterLoadBalancingTab.suggestedFromHardware`,`Suggested from hardware`),icon:L,...r===void 0?{}:{actions:f(V,{size:`sm`,onClick:r,disabled:n,children:i(`pipeline.clusterLoadBalancingTab.applySuggestedShares`,`Apply suggested shares`)})},children:[f(`ul`,{className:`divide-y divide-border`,children:e.nodes.map(e=>o(`li`,{className:`${C} space-y-0.5`,children:[o(`div`,{className:`flex items-baseline gap-2 text-xs`,children:[f(`span`,{className:`min-w-0 flex-1 truncate font-medium text-foreground`,children:t(e.nodeId)}),f(`span`,{className:`tabular-nums text-foreground`,children:e.share===null?i(`common.skipped`):`${e.share}%`})]}),o(`p`,{className:B,children:[Zi(e.capacityFallback)===null?``:`${Zi(e.capacityFallback)} · `,e.skippedReason===null?i(`pipeline.clusterLoadBalancingTab.parallelSessions`,`≈ {{capacitySessions}} parallel sessions · {{value2}}`,{capacitySessions:e.capacitySessions,value2:e.devices.map(e=>`${e.deviceKey} ${e.share}% (${e.modelId??`—`}${e.measured?``:`, estimated`}, cap ${e.suggestedMaxSessions??`—`})`).join(` · `)}):i(`pipeline.clusterLoadBalancingTab.notPartOfTheSuggestion`,`not part of the suggestion — {{skippedReason}}`,{skippedReason:e.skippedReason})]})]},e.nodeId))}),o(`p`,{className:`${C} ${B} border-t border-border`,children:[i(`pipeline.clusterLoadBalancingTab.sharesIntro`,{fps:e.cameraFps,headroom:Math.round(e.headroom*100),basis:e.source===`benchmark`?i(`pipeline.clusterLoadBalancingTab.measuredByNodeBenchmarksOr`,`measured by node benchmarks, or from the hardware table where a node has no results`):i(`pipeline.clusterLoadBalancingTab.atTheModelsAutoTune`,`at the models Auto tune picks (at least {{minSessionsPerDevice}} per accelerator), from the measured speed of each node's hardware`,{minSessionsPerDevice:e.minSessionsPerDevice})}),` `,r===void 0?i(`pipeline.clusterLoadBalancingTab.automaticSharesAlreadyFollowThis`,`Automatic shares already follow this; the caps are advisory — apply each from its accelerator row.`):i(`pipeline.clusterLoadBalancingTab.applyingWritesTheNodeAnd`,`Applying writes the node and accelerator shares; the caps are advisory — apply each from its accelerator row.`)]})]})}function ha({stats:e,cameraName:t}){let{t:n}=K(),r=l(),i=tn({onSuccess:()=>{r.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPlacementStats`]]}),r.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineDevicePin`]]})}});return f(H,{headingId:`load-balancing-stale-pins`,title:n(`pipeline.clusterLoadBalancingTab.staleDevicePins`,`Stale device pins`),icon:he,children:f(`ul`,{className:`divide-y divide-border`,children:e.stalePins.map(e=>o(`li`,{className:`${C} flex items-center gap-2`,children:[o(`div`,{className:`min-w-0 flex-1`,children:[f(`p`,{className:`truncate text-xs text-foreground`,title:t(e.deviceId),children:t(e.deviceId)}),f(`p`,{className:B,children:qi(e)})]}),f(V,{variant:`outline`,size:`sm`,disabled:i.isPending,onClick:()=>i.mutate({deviceId:e.deviceId,deviceKey:`auto`}),children:n(`pipeline.clusterLoadBalancingTab.clearPin`,`Clear pin`)})]},e.deviceId))})})}function ga({node:e,emphasis:t=!1}){let{t:n}=K(),r=e.isHub?z:g;return o(`div`,{className:`flex items-center gap-2.5 min-w-0`,children:[f(`span`,{className:`h-2 w-2 shrink-0 rounded-full ${e.isOnline?`bg-success`:`bg-danger`}`,"aria-hidden":`true`}),f(r,{className:`h-4 w-4 shrink-0 text-foreground-subtle`,"aria-hidden":`true`}),o(`div`,{className:`min-w-0`,children:[o(`div`,{className:`flex items-center gap-1.5 ${t?`text-sm`:`text-xs`} font-semibold text-foreground`,children:[f(`span`,{className:`truncate`,children:e.name}),e.isHub&&f(U,{variant:`info`,className:`px-1.5 py-0 text-[9px] uppercase tracking-wider`,children:n(`common.hubWord`)}),!e.isOnline&&f(U,{variant:`danger`,className:`px-1.5 py-0 text-[9px] uppercase tracking-wider`,children:n(`common.offline`)})]}),f(`div`,{className:`font-mono text-[10px] text-foreground-subtle truncate`,children:e.id})]})]})}function _a({nodes:e,actions:t}){let{t:n}=K();return f(ht,{columns:[{key:`node`,header:n(`placementBoard.nodeCapabilitiesTable.node`,`Node`),sortValue:e=>e.name,render:e=>f(ga,{node:e})},...On.map(e=>({key:e.key,header:n(e.labelKey),align:`center`,notSortableReason:`A switch — sorting would move the row while it is being changed.`,render:r=>f(Bt,{"aria-label":n(`placementBoard.nodeCapabilitiesTable.on`,`{{label}} on {{name}}`,{label:n(e.labelKey),name:r.name}),title:n(e.hintKey),checked:Sn(r.effective,e.key),disabled:t.capabilityPending,onCheckedChange:n=>t.onToggleCapability(r.id,e.key,n)})}))],rows:e,rowKey:e=>e.id,bordered:!1,minWidthPx:720,rowClassName:e=>e.isOnline?void 0:`opacity-60`,emptyMessage:n(`placementBoard.nodeCapabilitiesTable.noClusterNodesReportingYet`,`No cluster nodes reporting yet.`)})}function va({roleValues:e,options:t,pending:n,onRoleChange:r}){let{t:i}=K(),a=t.map(e=>({value:e.id,label:e.id===`hub`?i(`placementBoard.roleControls.default`,`{{name}} (default)`,{name:e.name}):e.name}));return f(`ul`,{className:`divide-y divide-border`,children:Mn.map(t=>o(`li`,{className:`${C} flex flex-wrap items-center gap-x-3 gap-y-1.5`,children:[o(`div`,{className:`min-w-0 flex-1 basis-56`,children:[f(`div`,{className:`text-xs font-medium text-foreground`,children:wn(t)}),f(`p`,{className:B,children:Tn(t)})]}),f(`div`,{className:`w-full sm:w-48`,children:f(Ze,{"aria-label":i(`placementBoard.roleControls.node`,`{{value1}} node`,{value1:wn(t)}),value:e[t],disabled:n,options:a,onChange:e=>r(t,e.target.value)})})]},t))})}t();function ya(){let{t:e}=K(),t=l(),{nodes:n}=W(),i=mt(void 0),a=Kt({addonId:jn}),s=Kt({addonId:xn}),c=Kt({addonId:Nn}),u=()=>Dn(t),d=St({onSuccess:u}),p=Dt({onSuccess:u}),m=r(()=>{let e=new Map;for(let t of i.data??[])e.set(t.nodeId,t.settings);return e},[i.data]),h=r(()=>n.map(e=>{let t=m.get(e.id),n=Hn(t,e.isHub);return{id:e.id,name:e.name,isHub:e.isHub,isOnline:e.isOnline,settings:t,effective:n}}),[n,m]),g={ingestNode:An(a.data,`ingestNode`,`hub`),recordingNode:An(s.data,kn,`hub`),audioNode:An(a.data,`audioNode`,`hub`),motionNode:An(a.data,`motionNode`,`hub`),postProcessingNode:An(c.data,En,`hub`)},_=r(()=>{let e=n.filter(e=>e.isOnline).map(e=>e.id),t=e=>n.find(t=>t.id===e)?.name||e;return[...new Set([`hub`,...Mn.map(e=>g[e]),...e])].filter(e=>e.length>0).map(e=>({id:e,name:t(e)}))},[n,g]),v=i.isLoading||a.isLoading||s.isLoading||c.isLoading,y=(e,t,n)=>{d.mutate({agentNodeId:e,[t]:n})},b=(e,t)=>{if(e===`recordingNode`){p.mutate({addonId:xn,patch:{[kn]:t}});return}if(e===`postProcessingNode`){p.mutate({addonId:Nn,patch:{[En]:t}});return}p.mutate({addonId:jn,patch:{[e]:t}})},x={capabilityPending:d.isPending,onToggleCapability:y},S=v?f(A,{className:`h-3.5 w-3.5 animate-spin text-foreground-subtle`,"aria-label":e(`pipeline.clusterRolesNodesTab.loading`,`Loading`)}):null;return o(`div`,{className:`space-y-3 sm:space-y-4`,children:[o(H,{headingId:`roles-nodes-cluster-roles`,title:e(`pipeline.clusterRolesNodesTab.clusterRoles`,`Cluster roles`),icon:pe,actions:S,children:[f(`p`,{className:`${B} border-b border-border px-3 py-1.5 sm:px-4`,children:e(`pipeline.clusterRolesNodesTab.oneNodeHoldsEachRole`,`One node holds each role for every camera. Detection shares and caps are on Load balancing.`)}),f(va,{roleValues:g,options:_,pending:p.isPending,onRoleChange:b})]}),f(H,{headingId:`roles-nodes-node-capabilities`,title:e(`pipeline.clusterRolesNodesTab.nodeCapabilities`,`Node capabilities`),icon:z,children:f(_a,{nodes:h,actions:x})})]})}var ba=`pipeline-analytics`,xa=`face-gallery`,Sa=`pipeline-orchestrator`,Ca=`pipeline-runner`,wa=`audio-analyzer`;function Ta(e){return[...De.filter(t=>t.stepId===e).map(e=>be(e.stepId)),...xe.filter(t=>t.stepId===e).map(e=>Ae(e.stepId,e.key))]}var Ea=`faces`,Da=`semantic-search`,Oa=[{id:Ea,get title(){return G.t(`helpers.clusterSettingsSections.facesTitle`)},get hint(){return G.t(`helpers.clusterSettingsSections.facesHint`)},panels:[{addonId:Sa,fieldKeys:Ta(`face-embedding`)},{addonId:ba,capability:xa}]},{id:Da,get title(){return G.t(`helpers.clusterSettingsSections.semanticTitle`)},get hint(){return G.t(`helpers.clusterSettingsSections.semanticHint`)},panels:[{addonId:Sa,fieldKeys:Ta(`clip-embedding`)}]},{id:je,get title(){return G.t(`helpers.clusterSettingsSections.cropTitle`)},get hint(){return G.t(`helpers.clusterSettingsSections.cropHint`)},panels:[{addonId:Sa,sectionIds:[je]}]},{id:Oe,get title(){return G.t(`helpers.clusterSettingsSections.nativeTitle`)},get hint(){return G.t(`helpers.clusterSettingsSections.nativeHint`)},panels:[{addonId:Sa,sectionIds:[Oe]}]},{id:`runner-defaults`,get title(){return G.t(`helpers.clusterSettingsSections.runnerTitle`)},get hint(){return G.t(`helpers.clusterSettingsSections.runnerHint`)},panels:[{addonId:Ca,fieldScope:`cluster`},{addonId:wa,fieldScope:`cluster`}]},{id:`failover`,get title(){return G.t(`helpers.clusterSettingsSections.failoverTitle`)},get hint(){return G.t(`helpers.clusterSettingsSections.failoverHint`)},panels:[{addonId:Sa,sectionIds:[`failover`]}]}],ka={"cluster-step-models":Ea};function Aa(e){return e===`clip-embedding`?Da:Ea}t();var ja=2500,Ma={faces:ne,"semantic-search":E,"detail-crop":_e,"native-lease":ve,"runner-defaults":g,failover:R};function Na(e){n(()=>{if(e===null)return;let t=ka[e]??e,n=`[data-cluster-settings-card="${CSS.escape(t)}"]`,r=()=>{let e=document.querySelector(n);return e===null?!1:(e.scrollIntoView({block:`start`,behavior:`smooth`}),e.classList.add(`ring-2`,`ring-primary/60`),setTimeout(()=>e.classList.remove(`ring-2`,`ring-primary/60`),ja),!0)};if(r())return;let i=new MutationObserver(()=>{r()&&i.disconnect()});return i.observe(document.body,{childList:!0,subtree:!0}),()=>i.disconnect()},[e])}function Pa({section:e}){let{t}=K();return f(`div`,{"data-cluster-settings-card":e.id,className:`rounded-lg`,children:f(H,{headingId:`cluster-settings-${e.id}`,title:e.title,...Ma[e.id]===void 0?{}:{icon:Ma[e.id]},children:o(`div`,{className:`${m} space-y-3`,children:[f(`p`,{className:B,children:e.hint}),e.panels.map(e=>f(bn,{nodeId:`hub`,addonIds:[e.addonId],level:`global`,hideSectionChrome:!0,omitSectionIds:[`cluster`,`load`],emptyMessage:t(`pipeline.clusterSettingsTab.notAvailableTheAddonThat`,`Not available — the addon that owns these settings did not answer.`),...e.capability===void 0?{}:{capability:e.capability},...e.sectionIds===void 0?{}:{sectionIds:e.sectionIds},...e.fieldKeys===void 0?{}:{fieldKeys:e.fieldKeys},...e.fieldScope===void 0?{}:{fieldScope:e.fieldScope}},`${e.addonId}:${e.capability??``}`))]})})})}function Fa({refreshToken:e}){let[t]=yn();return Na(t.get(Lo)),f(`div`,{className:`space-y-3 sm:space-y-4`,children:Oa.map(e=>f(Pa,{section:e},e.id))})}var Ia=`pipeline-orchestrator`,La=200;function Ra(){let{t:e}=K();return o(`div`,{className:`flex flex-col gap-3`,children:[o(`div`,{children:[f(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:e(`pipeline.clusterOrchestratorLogsTab.orchestratorLogs`,`Orchestrator logs`)}),f(`p`,{className:`text-[11px] text-foreground-subtle`,children:e(`pipeline.clusterOrchestratorLogsTab.dispatchDecisionsBalancerMovesAnd`,`Dispatch decisions, balancer moves and failover events from the pipeline orchestrator. Streaming live; the device chip on a line tells which camera it refers to.`)})]}),f(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:f(pt,{addonId:Ia,limit:La,maxHeight:`max-h-[calc(100vh-360px)]`,showScope:!0,showDeviceChip:!0,showFilters:!1})})]})}var za=[{id:`assignments`,labelKey:`pipeline.clusterDetail.tabAssignments`},{id:`load-balancing`,labelKey:`pipeline.clusterDetail.tabLoadBalancing`},{id:`auto-tune`,labelKey:`pipeline.clusterDetail.tabAutoTune`},{id:`roles-nodes`,labelKey:`pipeline.clusterDetail.tabRoles`},{id:`settings`,labelKey:`common.settings`},{id:`logs`,labelKey:`common.logs`}];function Ba(e){return za.some(t=>t.id===e)}function Va({refreshToken:e}){let{t}=K(),[n,r]=yn(),i=n.get(Io),a=Ba(i)?i:`assignments`,s=e=>{r(t=>{let n=new URLSearchParams(t);return n.set(Io,e),n.delete(Lo),n},{replace:!0})};return o(`div`,{className:`flex flex-col h-full`,children:[o(`div`,{className:`px-4 sm:px-6 py-4 border-b border-border`,children:[f(`h2`,{className:`text-base font-semibold text-foreground`,children:t(`pipeline.clusterDetail.clusterOrchestration`,`Cluster Orchestration`)}),f(`div`,{className:`text-[11px] text-foreground-subtle mt-1`,children:t(`pipeline.clusterDetail.cameraAssignmentsLoadBalancingThe`,`Camera assignments, load balancing, the detector recommendation, cluster roles and settings.`)})]}),f(`div`,{className:`flex items-center gap-1 px-4 sm:px-6 border-b border-border overflow-x-auto`,children:za.map(e=>f(`button`,{type:`button`,onClick:()=>s(e.id),className:`shrink-0 whitespace-nowrap px-3 py-2 text-xs font-medium border-b-2 transition-colors ${a===e.id?`border-primary text-primary`:`border-transparent text-foreground-subtle hover:text-foreground`}`,children:t(e.labelKey)},e.id))}),o(`div`,{className:`flex-1 min-h-0 overflow-y-auto p-4 sm:p-6 @container/clustertab`,children:[a===`assignments`&&f(pi,{}),a===`load-balancing`&&f(pa,{refreshToken:e,onOpenAutoTune:()=>s(`auto-tune`)}),a===`auto-tune`&&f(Mi,{}),a===`roles-nodes`&&f(ya,{}),a===`settings`&&f(Fa,{refreshToken:e}),a===`logs`&&f(Ra,{})]})]})}var Ha=`armed:`;function Ua(e){return e.assignment.reasons.detection?.startsWith(Ha)===!0}function Wa(e){let{assignment:t,detection:n}=e;return n!==null&&n.provisioning.state===`failed`||t.detectionNodeId===null&&n===null&&!Ua(e)?`error`:n!==null&&n.phase===`active`?`healthy`:`idle`}function Ga(e){let t=[],n=[],{assignment:r,detection:i,broker:a}=e;i!==null&&i.provisioning.state===`failed`&&t.push({code:`provisioning-failed`,severity:`error`,message:i.provisioning.error!==void 0&&i.provisioning.error.length>0?G.t(`helpers.cameraCardModel.provisioningFailedWith`,{error:i.provisioning.error}):G.t(`helpers.cameraCardModel.provisioningFailed`)}),i!==null&&i.phase===`active`&&i.actualFps===0&&t.push({code:`detection-black-hole`,severity:`error`,message:G.t(`helpers.cameraCardModel.blackHole`)}),r.detectionNodeId===null&&i===null&&!Ua(e)&&n.push({code:`unassigned`,severity:`warning`,message:G.t(`helpers.cameraCardModel.unassigned`)});let o=e.degraded??[];if(o.length>0){let e=[...new Set(o.map(e=>e.stage))].join(`, `);n.push({code:`status-unreadable`,severity:`warning`,message:G.t(`helpers.cameraCardModel.statusUnreadable`,{stages:e})})}n.push(...Ja(e.cameraSensors));for(let e of a?.profiles??[])e.status===`streaming`&&e.inFps===0&&n.push({code:`broker-stalled`,severity:`warning`,message:G.t(`helpers.cameraCardModel.brokerStalled`,{profile:e.profile})});return[...t,...n]}function Ka(e){return e.state===`unreadable`&&we.state===`unreadable`&&e.reason===we.reason}function qa(e){switch(e.state){case`ready`:return null;case`missing`:return{code:`camera-sensor-missing`,severity:`warning`,message:G.t(`helpers.cameraCardModel.sensorMissing`,{addonId:e.addonId,stableId:e.stableId})};case`offline`:return{code:`camera-sensor-offline`,severity:`warning`,message:G.t(`helpers.cameraCardModel.sensorOffline`,{name:e.name,deviceId:e.deviceId,reason:e.reason})};case`unsupported`:return{code:`camera-sensor-unsupported`,severity:`warning`,message:G.t(`helpers.cameraCardModel.sensorUnsupported`,{name:e.name,deviceId:e.deviceId,reason:e.reason})};case`unreadable`:return{code:`camera-sensor-unreadable`,severity:`warning`,message:G.t(`helpers.cameraCardModel.sensorUnreadable`,{addonId:e.addonId,stableId:e.stableId,reason:e.reason})}}}function Ja(e){if(e===void 0||e.state===`not-configured`)return[];if(e.state===`unreadable`)return Ka(e)?[]:[{code:`camera-sensors-unreadable`,severity:`warning`,message:G.t(`helpers.cameraCardModel.sensorsUnreadable`,{reason:e.reason})}];let t=e.sensors.flatMap(e=>{let t=qa(e);return t===null?[]:[t]}),n=e.notForwarded===void 0?t:[Ya(e.notForwarded),...t];return e.notEnforced===void 0?n:[{code:`camera-sensors-not-enforced`,severity:`warning`,message:G.t(`helpers.cameraCardModel.notEnforced`)},...n]}function Ya(e){return{code:`camera-sensors-not-forwarded`,severity:`warning`,message:e===`onboard-not-listed`?G.t(`helpers.cameraCardModel.notForwardedOnboard`):G.t(`helpers.cameraCardModel.notForwardedNoDetection`)}}function Xa(e){return e===void 0?G.t(`helpers.cameraCardModel.summaryUnavailable`):e.state===`not-configured`?G.t(`helpers.cameraCardModel.summaryNone`):e.state===`unreadable`?G.t(`helpers.cameraCardModel.summaryUnknown`,{reason:e.reason}):e.sensors.map(Qa).join(`, `)}function Za(e){return e.mode===`in-addition`?``:` · ${e.mode}`}function Qa(e){return`${$a(e)}${Za(e)}`}function $a(e){switch(e.state){case`ready`:return`${e.name} (#${e.deviceId})`;case`offline`:return`${e.name} (#${e.deviceId}) — ${e.reason}`;case`unsupported`:return G.t(`helpers.cameraCardModel.summaryUnsupported`,{name:e.name,deviceId:e.deviceId});case`missing`:case`unreadable`:return`${e.addonId}/${e.stableId} — ${e.state}`}}function eo(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Y(e){return typeof e==`string`&&e.length>0?e:null}function to(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function no(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function ro(e,t){return e==null?!1:JSON.stringify(e)!==JSON.stringify(t??null)}var io={detectionMode:null,detectionStreamProfile:null,detectionFps:null,motionSources:[],motionFps:null,motionCooldownMs:null,motionStreamProfile:null,audioMode:null,pipelineNodeId:null,decoderNodeId:null,audioNodeId:null,overriddenKeys:new Set};function ao(e){if(!eo(e)||!Array.isArray(e.sections))return io;let t=Ne(e),n=e=>{let n=t.get(e);if(n!==void 0)return n.value??n.default},r=new Set;for(let[e,n]of t)ro(n.value,n.default)&&r.add(e);return{detectionMode:Y(n(`detectionMode`)),detectionStreamProfile:Y(n(`detectionStreamProfile`)),detectionFps:to(n(`detectionFps`)),motionSources:no(n(`motionSources`)),motionFps:to(n(`motionFps`)),motionCooldownMs:to(n(`motionCooldownMs`)),motionStreamProfile:Y(n(`motionStreamProfile`)),audioMode:Y(n(`audioMode`)),pipelineNodeId:Y(n(`pipelineNodeId`)),decoderNodeId:Y(n(`decoderNodeId`)),audioNodeId:Y(n(`audioNodeId`)),overriddenKeys:r}}function oo(e,t=0){let n=[];for(let r of e)n.push({addonId:r.addonId,modelId:r.modelId??null,enabled:r.enabled,depth:t}),r.children!==void 0&&r.children.length>0&&n.push(...oo(r.children,t+1));return n}function X({title:e,children:t}){return o(`div`,{className:`bg-background px-3.5 py-3 min-w-0`,children:[f(`div`,{className:`text-[9px] font-semibold uppercase tracking-[0.14em] text-foreground-subtle mb-2`,children:e}),f(`div`,{className:`flex flex-col gap-1 min-w-0`,children:t})]})}function Z({label:e,children:t,overridden:n=!1}){return o(`div`,{className:`flex items-baseline gap-2 text-[11px] leading-snug min-w-0`,children:[f(`span`,{className:`text-foreground-subtle shrink-0 w-24 truncate`,title:e,children:e}),f(`span`,{className:`font-mono tabular-nums text-foreground min-w-0 truncate flex-1`,children:t}),n&&f(so,{})]})}function so(){let{t:e}=K();return f(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full bg-warning shrink-0 self-center`,title:e(`cameras.cardPrimitives.deviceLevelOverrideActive`,`Device-level override active`),"aria-label":e(`cameras.cardPrimitives.deviceLevelOverrideActive`,`Device-level override active`),role:`img`})}var co={neutral:`border-border text-foreground-muted`,success:`border-success/40 text-success`,warning:`border-warning/40 text-warning`,danger:`border-danger/40 text-danger`,info:`border-info/40 text-info`};function Q({tone:e=`neutral`,children:t,title:n}){return f(`span`,{title:n,className:`inline-flex items-center gap-1 rounded border px-1.5 py-px text-[10px] font-medium leading-tight whitespace-nowrap ${co[e]}`,children:t})}function $({children:e}){return f(`div`,{className:`text-[11px] text-foreground-subtle italic`,children:e})}function lo({icon:e,label:t,nodeId:n,pinned:r,reason:i,overridden:a}){let{t:c}=K();return o(`div`,{className:`flex items-center gap-2 text-[11px] leading-snug min-w-0`,children:[f(e,{className:`h-3 w-3 text-foreground-subtle shrink-0`}),f(`span`,{className:`text-foreground-subtle w-[4.5rem] shrink-0`,children:t}),n===null?f(`span`,{className:`text-foreground-subtle italic`,children:c(`cameras.configBlocks.unassigned`)}):o(s,{children:[f(`span`,{className:`font-mono text-foreground truncate`,title:n,children:n}),r?o(`span`,{className:`inline-flex items-center gap-0.5 text-[10px] text-warning shrink-0`,title:c(`cameras.configBlocks.manuallyPinned`,`Manually pinned`),children:[f(_,{className:`h-2.5 w-2.5`}),` `,c(`cameras.configBlocks.manual`)]}):f(`span`,{className:`text-[10px] text-foreground-subtle shrink-0 truncate`,children:c(`cameras.configBlocks.autoReason`,{reason:i!==void 0&&i.length>0?i:c(`cameras.configBlocks.capacity`)})}),a&&f(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full bg-warning shrink-0`,title:c(`cameras.configBlocks.persistedSettingsPinForThis`,`Persisted settings pin for this role`)})]})]})}function uo({assignment:e,settings:t,onlineNodes:n,pinPending:r,onDetectionPinChange:i}){let{t:a}=K(),s=e.pinned.detection&&e.detectionNodeId!==null?e.detectionNodeId:`auto`,c=[...new Set([...e.detectionNodeId===null?[]:[e.detectionNodeId],...n.map(e=>e.id)])];return o(X,{title:a(`cameras.configBlocks.whereItRuns`,`Where it runs`),children:[f(lo,{icon:g,label:a(`cameras.configBlocks.detection`,`Detection`),nodeId:e.detectionNodeId,pinned:e.pinned.detection,reason:e.reasons.detection,overridden:t.overriddenKeys.has(`pipelineNodeId`)}),f(lo,{icon:y,label:a(`cameras.configBlocks.decoder`,`Decoder`),nodeId:e.decoderNodeId,pinned:e.pinned.decoder,reason:e.reasons.decoder,overridden:t.overriddenKeys.has(`decoderNodeId`)}),f(lo,{icon:D,label:a(`cameras.configBlocks.audio`,`Audio`),nodeId:e.audioNodeId,pinned:e.pinned.audio,reason:e.reasons.audio,overridden:t.overriddenKeys.has(`audioNodeId`)}),f(lo,{icon:M,label:a(`cameras.configBlocks.source`,`Source`),nodeId:e.sourceNodeId,pinned:!1,reason:`ingest owner`,overridden:!1}),f(`div`,{className:`mt-1.5`,children:o(`select`,{value:s,disabled:r,"aria-label":a(`cameras.configBlocks.detectionPlacementPin`,`Detection placement pin`),onChange:e=>i(e.target.value),className:`w-full min-w-0 rounded-md border border-border bg-background px-2 py-1 text-[11px] text-foreground disabled:opacity-50`,children:[f(`option`,{value:`auto`,children:a(`cameras.configBlocks.autoLoadBalanced`,`Auto (load balanced)`)}),c.map(e=>f(`option`,{value:e,children:a(`cameras.configBlocks.pinDetection`,{node:n.find(t=>t.id===e)?.name??e})},e))]})})]})}function fo(e){return`${e.width}×${e.height} ${e.codec} @${e.fps}fps`}function po(e,t){if(!(t===null||e===void 0))return e.find(e=>e.profile===t)}function mo(e){return e===null?G.t(`pipeline.configBlocks.fpsDefault`):e===0?G.t(`pipeline.configBlocks.fpsNative`):`${e} fps`}function ho({streams:e,brokerProfiles:t,settings:n,motionEnabled:r,motionFpsLive:i,cameraSensors:a}){let{t:c}=K(),l=po(t,n.detectionStreamProfile),u=po(t,n.motionStreamProfile),d=n.motionSources.includes(`analyzer`);return o(X,{title:c(`cameras.configBlocks.streamsMotion`,`Streams & motion`),children:[o(Z,{label:c(`cameras.configBlocks.detectStream`,`Detect stream`),overridden:n.overriddenKeys.has(`detectionStreamProfile`),children:[n.detectionStreamProfile??`—`,l!==void 0&&` · ${l.width}×${l.height} ${l.codec}`]}),f(Z,{label:c(`cameras.configBlocks.detectFps`,`Detect FPS`),overridden:n.overriddenKeys.has(`detectionFps`),children:mo(n.detectionFps)}),o(Z,{label:c(`cameras.configBlocks.motionSrc`,`Motion src`),overridden:n.overriddenKeys.has(`motionSources`),children:[n.motionSources.length>0?n.motionSources.map(Pe).join(` + `):c(`cameras.configBlocks.none`),r===!1&&` · ${c(`cameras.configBlocks.inactive`)}`]}),f(Z,{label:c(`cameras.configBlocks.cameraSensors`,`Camera sensors`),children:Xa(a)}),d&&o(s,{children:[o(Z,{label:c(`cameras.configBlocks.motionStream`,`Motion stream`),overridden:n.overriddenKeys.has(`motionStreamProfile`),children:[n.motionStreamProfile??`—`,u!==void 0&&` · ${u.width}×${u.height} ${u.codec}`]}),o(Z,{label:c(`cameras.configBlocks.motionFps`,`Motion FPS`),overridden:n.overriddenKeys.has(`motionFps`),children:[mo(n.motionFps),i!==null&&` · ${c(`cameras.configBlocks.liveFps`,{fps:i.toFixed(1)})}`]})]}),f(Z,{label:c(`cameras.configBlocks.cooldown`,`Cooldown`),overridden:n.overriddenKeys.has(`motionCooldownMs`),children:n.motionCooldownMs===null?c(`cameras.configBlocks.defaultValue`):`${n.motionCooldownMs/1e3}s`}),f(`div`,{className:`mt-1.5 flex flex-col gap-0.5`,children:e.length===0?f($,{children:c(`cameras.configBlocks.noStreamsRegistered`,`No streams registered`)}):e.map(e=>o(`div`,{className:`text-[10px] font-mono text-foreground-subtle truncate`,title:e.camStreamId,children:[f(`span`,{className:`text-foreground-muted`,children:e.kind}),` `,fo(e)]},e.camStreamId))})]})}function go({steps:e,audioModelId:t,audioEnabled:n,audioMode:r}){let{t:i}=K();return o(X,{title:i(`cameras.configBlocks.pipelineSteps`,`Pipeline steps`),children:[e===void 0?f($,{children:i(`cameras.configBlocks.resolving`,`Resolving…`)}):e.length===0?f($,{children:i(`cameras.configBlocks.noStepsConfigured`,`No steps configured`)}):f(`div`,{className:`flex flex-wrap gap-1`,children:e.map((e,t)=>f(Q,{tone:e.enabled&&e.depth===0?`info`:`neutral`,title:e.modelId??e.addonId,children:o(`span`,{className:e.enabled?``:`line-through opacity-60`,children:[e.depth>0&&f(`span`,{className:`opacity-50`,children:`↳ `}),e.addonId,e.modelId!==null&&o(`span`,{className:`font-mono opacity-75`,children:[` · `,e.modelId]})]})},`${e.addonId}-${t}`))}),f(`div`,{className:`mt-1`,children:o(Z,{label:i(`cameras.configBlocks.audioClass`,`Audio class.`),children:[r??`—`,n!==null&&` · ${i(n?`cameras.configBlocks.running`:`cameras.configBlocks.off`)}`,t!==null&&` · ${t}`]})})]})}var _o={ready:`success`,installing:`info`,verifying:`info`,idle:`neutral`,failed:`danger`};function vo({detection:e,live:t,detectionMode:n,modeOverridden:r}){let i=P(),{t:a}=K();if(e===null)return o(X,{title:a(`cameras.runtimeBlocks.detectionRuntime`,`Detection runtime`),children:[f(Z,{label:a(`cameras.runtimeBlocks.mode`,`Mode`),overridden:r,children:n??`—`}),f($,{children:a(`cameras.runtimeBlocks.detectionStageInactiveOrUnreachable`,`Detection stage inactive or unreachable`)})]});let s=t?.phase??e.phase,c=t?.actualFps??e.actualFps,l=t?.configuredFps??e.configuredFps,u=t?.avgInferenceTimeMs??e.avgInferenceMs,d=t?.queueDepth??e.queueDepth,p=rt(s,i),m=s===`active`&&c===0;return o(X,{title:a(`cameras.runtimeBlocks.detectionRuntime`,`Detection runtime`),children:[o(`div`,{className:`flex items-center gap-1.5 mb-0.5`,children:[o(`span`,{className:`inline-flex items-center gap-1 rounded border px-1.5 py-px text-[10px] font-semibold uppercase tracking-wider ${p.badgeClass}`,children:[f(Ke,{phase:s,className:`h-2.5 w-2.5`}),p.label]}),t!==void 0&&f(`span`,{className:`text-[9px] text-foreground-subtle uppercase tracking-wider`,children:a(`common.live`)})]}),f(Z,{label:a(`cameras.runtimeBlocks.mode`,`Mode`),overridden:r,children:n??`—`}),o(Z,{label:`FPS`,children:[f(`span`,{className:m?`text-danger font-semibold`:``,children:c.toFixed(1)}),f(`span`,{className:`ml-1 text-foreground-subtle`,children:a(`cameras.runtimeBlocks.configuredFps`,{fps:l.toFixed(0)})})]}),o(Z,{label:a(`cameras.runtimeBlocks.inference`,`Inference`),children:[u.toFixed(0),` ms`,d>0&&f(`span`,{className:`ml-1 text-warning`,children:a(`cameras.runtimeBlocks.queue`,{depth:d})}),t!==void 0&&t.droppedFrames>0&&f(`span`,{className:`ml-1 text-warning`,children:a(`cameras.runtimeBlocks.drops`,{count:t.droppedFrames})})]}),o(Z,{label:a(`cameras.runtimeBlocks.engine`,`Engine`),children:[e.engine.backend,` · `,e.engine.device]}),o(Z,{label:a(`cameras.runtimeBlocks.provisioning`,`Provisioning`),children:[f(Q,{tone:_o[e.provisioning.state]??`neutral`,children:e.provisioning.state}),e.provisioning.error!==void 0&&o(`span`,{className:`text-danger text-[10px]`,children:[` `,e.provisioning.error]})]})]})}function yo({broker:e}){let{t}=K();return e===null?f(X,{title:t(`cameras.runtimeBlocks.streamBroker`,`Stream broker`),children:f($,{children:t(`cameras.runtimeBlocks.brokerStageInactiveOrUnreachable`,`Broker stage inactive or unreachable`)})}):o(X,{title:t(`cameras.runtimeBlocks.streamBroker`,`Stream broker`),children:[e.profiles.length===0?f($,{children:t(`cameras.runtimeBlocks.noBrokerProfiles`,`No broker profiles`)}):f(`div`,{className:`flex flex-col gap-1`,children:e.profiles.map(e=>{let n=e.status===`streaming`,r=n&&e.inFps===0;return o(`div`,{className:`flex items-center gap-2 text-[11px] font-mono tabular-nums min-w-0`,children:[f(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full shrink-0 ${r?`bg-danger`:n?`bg-success animate-pulse`:`bg-border`}`,title:e.status}),f(`span`,{className:`text-foreground w-10 shrink-0 truncate`,title:e.profile,children:e.profile}),o(`span`,{className:`text-foreground-subtle truncate`,children:[e.width,`×`,e.height,` `,e.codec]}),f(`span`,{className:`ml-auto shrink-0 ${r?`text-danger`:`text-foreground`}`,children:t(`cameras.runtimeBlocks.fpsValue`,{value:e.inFps===null?`—`:e.inFps.toFixed(0)})}),o(`span`,{className:`text-foreground-subtle shrink-0`,title:t(`cameras.runtimeBlocks.subscribers`,`Subscribers`),children:[`×`,e.subscribers]})]},e.profile)})}),o(`div`,{className:`mt-1.5 flex flex-wrap gap-1`,children:[f(Q,{tone:e.webrtcSessions>0?`info`:`neutral`,children:t(`cameras.runtimeBlocks.webrtc`,{count:e.webrtcSessions})}),f(Q,{tone:e.rtspRestream?`success`:`neutral`,children:e.rtspRestream?t(`cameras.runtimeBlocks.restreamOn`):t(`cameras.runtimeBlocks.restreamOff`)})]})]})}function bo({decoder:e}){let{t}=K();return e===null?f(X,{title:t(`cameras.runtimeBlocks.decoder`,`Decoder`),children:f($,{children:t(`cameras.runtimeBlocks.decoderStageInactiveOrUnreachable`,`Decoder stage inactive or unreachable`)})}):f(X,{title:t(`cameras.runtimeBlocks.decoder`,`Decoder`),children:f(Z,{label:t(`cameras.runtimeBlocks.node`,`Node`),children:e.nodeId})})}t();var xo=`pipeline-orchestrator`,So={healthy:`bg-success`,idle:`bg-warning`,error:`bg-danger`},Co={healthy:`pipeline.cameraPipelineCard.healthHealthy`,idle:`pipeline.cameraPipelineCard.healthIdle`,error:`pipeline.cameraPipelineCard.healthError`};function wo({problems:e}){return f(`div`,{role:`alert`,className:`flex flex-col border-b border-border`,children:e.map(e=>o(`div`,{className:`flex items-start gap-2 px-4 py-1.5 text-[11px] font-medium ${e.severity===`error`?`bg-danger/10 text-danger`:`bg-warning/10 text-warning`}`,children:[f(b,{className:`h-3.5 w-3.5 shrink-0 mt-px`}),f(`span`,{className:`min-w-0`,children:e.message})]},e.code))})}function To({deviceId:e,name:t,online:n,status:i,live:a,onlineNodes:s}){let{t:c}=K(),u=l(),{data:d}=Zt({addonId:xo,deviceId:e,nodeId:`hub`},{staleTime:3e4}),{data:p}=Qe({deviceId:e},{staleTime:3e4}),m=r(()=>ao(d),[d]),h=r(()=>p===void 0?void 0:oo(p.steps),[p]),g=r(()=>i===void 0?[]:Ga(i),[i]),_=()=>{u.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCameraStatuses`]]}),u.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineAssignments`]]})},v=ft({onSuccess:_}),y=Nt({onSuccess:_}),b=t=>{t===`auto`?y.mutate({deviceId:e}):v.mutate({deviceId:e,agentNodeId:t})},x=i===void 0?`idle`:Wa(i),S=g.some(e=>e.severity===`error`),C=g.length>0,w=S?`border-danger/50`:C?`border-warning/40`:`border-border`;return o(`article`,{"aria-label":c(`cameras.cameraPipelineCard.pipelineStatus`,`{{name}} pipeline status`,{name:t}),className:`rounded-lg border ${w} bg-background overflow-hidden`,children:[o(`header`,{className:`flex items-center gap-2.5 px-4 py-2.5 border-b border-border bg-surface/50 min-w-0`,children:[f(`span`,{className:`inline-block h-2 w-2 rounded-full shrink-0 ${S?`bg-danger`:So[x]}`,title:S?c(`common.error`,`Error`):c(Co[x]),"aria-label":S?c(`common.error`,`Error`):c(Co[x]),role:`img`}),f(`h3`,{className:`text-[13px] font-semibold text-foreground truncate`,title:t,children:t}),o(`span`,{className:`text-[10px] text-foreground-subtle shrink-0`,children:[`#`,e]}),!n&&f(Q,{tone:`danger`,children:c(`common.offline`)}),o(`span`,{className:`ml-auto flex items-center gap-1.5 shrink-0`,children:[m.detectionMode!==null&&f(Q,{tone:m.detectionMode===`disabled`?`warning`:m.detectionMode===`always-on`?`info`:`neutral`,title:c(`cameras.cameraPipelineCard.objectDetectionMode`,`Object detection mode`),children:m.detectionMode===`disabled`?c(`cameras.cameraPipelineCard.detectionOff`,`detection off`):m.detectionMode}),i?.recording!=null&&(i.recording.active?o(Q,{tone:`danger`,title:c(`cameras.cameraPipelineCard.recording`,`Recording ({{mode}})`,{mode:i.recording.mode}),children:[f(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full bg-danger animate-pulse`}),`REC`]}):i.recording.mode!==`off`&&f(Q,{tone:`neutral`,title:c(`cameras.cameraPipelineCard.recordingMode`,`Recording mode`),children:c(`pipeline.cameraPipelineCard.recMode`,{mode:i.recording.mode})}))]})]}),g.length>0&&f(wo,{problems:g}),i===void 0?f(`div`,{className:`px-4 py-5 text-[11px] text-foreground-subtle italic`,children:c(`cameras.cameraPipelineCard.noPipelineStatusYetThe`,`No pipeline status yet — the orchestrator has not composed a snapshot for this camera.`)}):o(`div`,{className:`grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-px bg-border`,children:[f(uo,{assignment:i.assignment,settings:m,onlineNodes:s,pinPending:v.isPending||y.isPending,onDetectionPinChange:b}),f(vo,{detection:i.detection,live:a,detectionMode:m.detectionMode,modeOverridden:m.overriddenKeys.has(`detectionMode`)}),f(go,{steps:h,audioModelId:p?.audio?.modelId??null,audioEnabled:i.audio?.enabled??p?.audio?.enabled??null,audioMode:m.audioMode}),f(ho,{streams:i.source.streams,brokerProfiles:i.broker?.profiles,settings:m,motionEnabled:i.motion?.enabled??null,motionFpsLive:i.motion?.fps??null,cameraSensors:i.cameraSensors}),f(yo,{broker:i.broker}),f(bo,{decoder:i.decoder})]})]})}t();var Eo=5e3,Do=1e4,Oo=5e3;function ko(e){let t=l(),{data:a,isLoading:o}=gn(),{data:s,isLoading:c}=nt({},{refetchInterval:Eo}),{nodes:u}=W();n(()=>{e!==0&&t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCameraStatuses`]]})},[e,t]);let[d,f]=i(new Map);ln(Ee.PipelineCameraMetricsSnapshot,e=>{let t=e.data;typeof t.deviceId==`number`&&f(e=>{let n=new Map(e);return n.set(t.deviceId,{phase:t.metrics.phase,configuredFps:t.metrics.configuredFps,actualFps:t.metrics.actualFps,queueDepth:t.metrics.queueDepth,avgInferenceTimeMs:t.metrics.avgInferenceTimeMs,droppedFrames:t.metrics.droppedFrames,timestamp:t.timestamp}),n})}),n(()=>{if(d.size===0)return;let e=setInterval(()=>{f(e=>{let t=Date.now()-Do,n=!1,r=new Map(e);for(let[i,a]of e)a.timestamp<t&&(r.delete(i),n=!0);return n?r:e})},Oo);return()=>clearInterval(e)},[d.size]);let p=r(()=>{let e=new Map;for(let t of s??[])e.set(t.deviceId,t);return e},[s]);return{rows:r(()=>(a??[]).filter(e=>e.isCamera).map(e=>({deviceId:e.id,name:e.name,online:e.online,status:p.get(e.id)})).sort((e,t)=>e.name.localeCompare(t.name)),[a,p]),liveMetrics:d,onlineNodes:r(()=>(u??[]).filter(e=>e.isOnline).map(e=>({id:e.id,name:e.name})),[u]),isLoading:o||c}}t();function Ao({refreshToken:e}){let{t}=K(),{rows:n,liveMetrics:i,onlineNodes:a,isLoading:s}=ko(e),c=r(()=>[...n.map(e=>{let t=e.status===void 0?[]:Ga(e.status);return{row:e,errorCount:t.filter(e=>e.severity===`error`).length,warningCount:t.filter(e=>e.severity===`warning`).length}})].sort((e,t)=>e.errorCount===t.errorCount?e.warningCount===t.warningCount?0:t.warningCount-e.warningCount:t.errorCount-e.errorCount),[n]),l=r(()=>{let e=0,t=0;for(let n of c)(n.errorCount>0||n.warningCount>0)&&(t+=1),(i.get(n.row.deviceId)?.phase??n.row.status?.detection?.phase)===`active`&&(e+=1);return{total:c.length,active:e,issues:t}},[c,i]);return s&&n.length===0?f(`div`,{className:`flex items-center justify-center h-full text-sm text-foreground-subtle`,children:t(`cameras.camerasOverview.loadingCameraPipelines`,`Loading camera pipelines…`)}):n.length===0?f(`div`,{className:`flex items-center justify-center h-full text-sm text-foreground-subtle`,children:t(`cameras.camerasOverview.noCamerasFound`,`No cameras found`)}):f(`div`,{className:`h-full overflow-y-auto`,children:o(`div`,{className:`max-w-6xl mx-auto flex flex-col gap-3 px-4 py-4`,children:[o(`div`,{className:`flex items-center gap-4 text-[11px] text-foreground-subtle px-1`,children:[f(`span`,{children:f(vn,{i18nKey:`pipeline.camerasOverview.camerasTotal`,values:{count:l.total},components:{b:f(`span`,{className:`font-semibold text-foreground`})}})}),f(`span`,{children:f(vn,{i18nKey:`pipeline.camerasOverview.activelyInferring`,values:{count:l.active},components:{b:f(`span`,{className:`font-semibold text-success`})}})}),o(`span`,{children:[f(`span`,{className:`font-semibold ${l.issues>0?`text-danger`:`text-foreground`}`,children:l.issues}),` `,t(`cameras.camerasOverview.withIssues`,`with issues`)]}),f(`span`,{className:`ml-auto hidden sm:inline text-[10px]`,children:t(`cameras.camerasOverview.polledEvery5SDetection`,`polled every 5 s · detection metrics live at 1 Hz`)})]}),c.map(({row:e})=>f(To,{deviceId:e.deviceId,name:e.name,online:e.online,status:e.status,live:i.get(e.deviceId),onlineNodes:a},e.deviceId))]})})}var jo=e({CLUSTER_NODE_ID:()=>Mo,PipelinePage:()=>Fo});t();var Mo=`__cluster__`;function No(e){return e===`cameras`?`cameras`:`nodes`}function Po({viewMode:e,onNodes:t,onCameras:n}){let{t:r}=K();return o(`div`,{className:`flex items-center gap-1 rounded-lg border border-border bg-surface p-0.5`,role:`tablist`,"aria-label":r(`pipeline.pipelineView`,`Pipeline view`),children:[f(`button`,{type:`button`,role:`tab`,"aria-selected":e===`nodes`,onClick:t,className:[`rounded-md px-3 py-1 text-[11px] font-medium transition-colors`,e===`nodes`?`bg-background text-foreground shadow-sm`:`text-foreground-subtle hover:text-foreground`].join(` `),children:r(`pipeline.nodes`,`Nodes`)}),f(`button`,{type:`button`,role:`tab`,"aria-selected":e===`cameras`,onClick:n,className:[`rounded-md px-3 py-1 text-[11px] font-medium transition-colors`,e===`cameras`?`bg-background text-foreground shadow-sm`:`text-foreground-subtle hover:text-foreground`].join(` `),children:r(`pipeline.cameras`,`Cameras`)})]})}function Fo(){let{t:e}=K(),[t,r]=yn(),a=No(t.get(`view`)),c=t.get(`node`)??`__cluster__`,[l,u]=i(0),[d,p]=i(!1);return n(()=>{a===`nodes`&&!t.get(`node`)&&r({view:`nodes`,node:Mo},{replace:!0})},[a,t,r]),o(Je,{icon:ue,title:e(`pipeline.pipeline`,`Pipeline`),subtitle:e(`pipeline.detectionPlacementLoadAndPer`,`Detection placement, load and per-camera runtime across the cluster.`),actions:o(V,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>u(e=>e+1),title:e(`common.refresh`,`Refresh`),children:[f(ce,{className:`h-3.5 w-3.5`}),e(`common.refresh`,`Refresh`)]}),nav:f(Po,{viewMode:a,onNodes:()=>{r({view:`nodes`,node:c},{replace:!0})},onCameras:()=>{r({view:`cameras`},{replace:!0})}}),className:`flex h-full min-h-0 flex-col overflow-hidden`,children:[a===`nodes`&&o(V,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>p(e=>!e),"aria-expanded":d,className:`flex w-full shrink-0 justify-between border-b border-border md:hidden`,children:[f(`span`,{children:e(d?`pipeline.hideNodeList`:`pipeline.showNodeList`)}),f(se,{className:[`h-4 w-4 transition-transform`,d?`rotate-180`:``].join(` `)})]}),f(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden md:flex-row`,children:a===`nodes`?o(s,{children:[f(`aside`,{className:[d?`block`:`hidden`,`md:block w-full md:w-72 shrink-0 border-b border-border md:border-b-0 md:border-r`,`max-h-[60vh] overflow-y-auto md:max-h-none`].join(` `),children:f(Wn,{selectedNodeId:c,onSelect:e=>{r({view:`nodes`,node:e},{replace:!0}),p(!1)},refreshToken:l})}),f(`section`,{className:`min-h-0 flex-1 overflow-hidden`,children:c===`__cluster__`?f(Va,{refreshToken:l}):f(fi,{nodeId:c,refreshToken:l})})]}):f(`section`,{className:`min-h-0 flex-1 overflow-hidden`,children:f(Ao,{refreshToken:l})})})]})}var Io=`ctab`,Lo=`section`;function Ro(e,t){let n=new URLSearchParams({view:`nodes`,node:Mo,[Io]:e});return t!==void 0&&n.set(Lo,t),`/system/pipeline?${n.toString()}`}function zo(e){return Ro(`settings`,Aa(e))}function Bo(){return Ro(`load-balancing`)}var Vo=`pipeline-orchestrator`;function Ho(e){return De.find(t=>t.stepId===e)??null}function Uo({step:e,engineFormat:t,runnableModelIds:n}){let{t:r}=K(),{data:i}=Kt({addonId:Vo}),a=ye(i??null)[e.stepId]??e.defaultModelId,s=e.options.find(e=>e.id===a)?.label??a,c=n.length>0&&!n.includes(a);return o(`div`,{className:`space-y-2 rounded-md border border-primary/30 bg-primary/5 px-3 py-2`,children:[o(`div`,{className:`flex flex-wrap items-center gap-2 text-xs`,children:[f(`span`,{className:`font-medium text-foreground`,children:e.label}),f(`span`,{className:`font-mono text-foreground`,children:s}),f(`span`,{title:r(`pipeline.clusterStepModel.oneValueForTheWhole`,`One value for the whole cluster — this step writes into a shared vector index, where two encoders make similarity scores meaningless.`),className:`rounded border border-primary/40 bg-primary/10 px-1 py-px text-[9px] font-medium uppercase tracking-wide text-primary`,children:r(`pipeline.clusterStepModel.clusterWide`)}),f(_n,{to:zo(e.stepId),className:`ml-auto text-[11px] text-primary hover:underline`,children:r(`pipeline.clusterStepModel.changeInClusterSettings`,`Change in Cluster → Settings ›`)})]}),o(`p`,{className:B,children:[r(`pipeline.clusterStepModel.oneModelForEveryNode`,`One model for every node and camera:`),` `,r(`pipeline.clusterStepModel.indexNote`,{index:e.indexName})]}),c&&f(`p`,{className:`rounded border border-warning/40 bg-warning/10 px-2 py-1 text-[10px] leading-snug text-warning`,children:f(vn,{i18nKey:`pipeline.clusterStepModel.noBuild`,values:{engine:t,model:a,index:e.indexName},components:{b:f(`b`,{})}})})]})}export{Pr as _,Qr as a,Lr as c,Ur as d,Gr as f,Fr as g,Wr as h,$r as i,Yr as l,Hr as m,Ho as n,Vr as o,Jr as p,jo as r,Kr as s,Uo as t,qr as u,jr as v,Fn as y};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{S as e,x as t}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEHpkaJP.js";import{t as n}from"./boxes-DJvrVSZy.js";import{Mr as r,pr as i}from"./client-CVIfL49c.js";import{Ii as a,Ln as o,Ti as s,ki as c}from"./src-DOs8Kg5s.js";import{t as l}from"./useTranslation-D3Is_4B6.js";import{$ as u,Q as d,X as f,b as p,h as m}from"./index-DkNBNJNl.js";import{E as h,O as g,T as _,t as v,w as y}from"./CompositionEditor-Djw5jKF1.js";import{t as b}from"./AdminPage-Dla2hgly.js";var x=`new`;function S(e){return e instanceof Error?e.message:String(e)}function C(e){let t=e.trim();return t===``?{}:{name:t}}function w(){let{blockId:w}=u(),{t:T}=l(),E=d(),D=s(),O=a(),k=w===void 0||w===x,A=c({blockId:w??``},{enabled:!k}),j=()=>{E(m)},M=e=>t(b,{icon:n,title:T(`compositionEditor.pageTitle`),children:e}),N=e=>t(`section`,{className:`${y} flex flex-col gap-2`,children:e});if(k)return M(t(v,{initial:g(r.Sensor),blockId:null,deviceType:r.Sensor,nativeCaps:null,targetFields:null,showTemplates:!0,onCancel:j,save:async(e,t)=>{try{let{block:n}=await D.mutateAsync({block:{...C(t),enabled:!0,composition:e}});return E(_(n.id,null).path,{replace:!0}),{kind:`saved`}}catch(e){return{kind:`refused`,reason:S(e)}}}}));if(A.status===`pending`)return M(N(t(`p`,{role:`status`,children:T(`compositionEditor.loading`)})));if(A.status===`error`)return M(N(t(o,{title:T(`compositionEditor.loadFailed`),message:A.error.message})));if(A.data.state===`not-loaded`)return M(N(t(`p`,{role:`status`,children:T(`customize.status.notLoaded`,{reason:A.data.reason})})));let P=A.data.view;if(P===null)return M(N(t(`p`,{children:T(`compositionEditor.notFound`,{blockId:w})})));let F=i(P.block);if(F===null)return M(N(t(`p`,{children:T(`compositionEditor.notComposition`)})));if(F.target.kind===`existing`){let e=P.state.kind===`answered`?P.state.state?.deviceId??null:null;return M(N(e===null?t(`p`,{children:T(`compositionEditor.customizationUnknownDevice`)}):t(f,{className:`text-primary`,to:p(e),children:T(`compositionEditor.openOnDevice`)})))}let I=P.state.kind===`answered`?P.state.state?.deviceId??null:null,L=I===null?null:_(P.block.id,I);return M(e(`div`,{className:`flex flex-col gap-3`,children:[L!==null&&L.kind===`device`&&t(f,{className:`text-sm text-primary`,to:L.path,"data-testid":`open-composed-device`,children:T(`compositionEditor.openComposedDevice`,{id:I})}),t(v,{initial:h(F,P.block.name),blockId:P.block.id,deviceType:F.target.type,nativeCaps:null,targetFields:null,onCancel:j,save:async(e,t)=>{try{return await O.mutateAsync({blockId:P.block.id,expectedUpdatedAt:P.block.updatedAt,block:{...C(t),composition:e}}),await A.refetch(),{kind:`saved`}}catch(e){return{kind:`refused`,reason:S(e)}}}},`${P.block.id}@${P.block.updatedAt}`)]}))}export{w as CompositionEditorPage};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{$ as e,B as t,G as n,J as r,L as i,S as a,b as o,o as s,x as c}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEHpkaJP.js";import{Hi as l,Hr as u,It as d,Ki as f,Kr as p,Nt as m,On as h,Pn as g,Q as _,Yr as v,_i as y,_n as b,ai as x,ar as S,di as C,dn as w,kn as T,nr as E,qi as D,ri as O,rr as k,yi as A}from"./player-overlays-CZXV2ES3.js";import{n as j,t as M}from"./cloud-upload-BkTrXwKr.js";import{t as N}from"./circle-slash-BvkFL8F1.js";import{t as P}from"./hard-drive-download-Df-zlQQG.js";import{$l as F,$r as I,An as ee,Bc as L,Bn as R,Dn as te,En as ne,G as z,Hc as re,Jl as ie,L as B,Ln as ae,Nr as oe,Qr as se,R as ce,Rn as le,Tn as ue,Uc as de,Ut as fe,Vc as pe,Wt as me,Xr as he,Yr as ge,Zn as V,Zr as _e,ai as ve,an as ye,ar as be,ci as xe,ea as Se,ei as Ce,eu as H,ii as we,jn as Te,kc as Ee,kn as U,li as De,ni as Oe,nl as ke,oi as Ae,ri as W,si as je,ti as Me,ui as Ne,z as Pe}from"./src-DOs8Kg5s.js";import{t as G}from"./i18n-CmGpgquB.js";import{t as K}from"./useTranslation-D3Is_4B6.js";import"./mount-mxypQ5EF.js";import{C as Fe,Y as Ie}from"./index-DkNBNJNl.js";import{t as Le}from"./AdminSectionedPage-C6laWV2D.js";import{t as Re}from"./AdminPage-Dla2hgly.js";import{n as ze}from"./authed-media-CN55sP4S.js";import{t as q}from"./format-size-DIxKXxtj.js";import{a as Be,c as Ve,l as He,n as Ue,o as We,s as Ge,t as Ke,u as qe}from"./location-owned-usage-BFxIuzRL.js";e();function Je(e){return Object.entries(e).map(([e,t])=>`${e} ${t}`).join(` · `)}function Ye(e){return e.reduce((e,t)=>e+Object.values(t.stores).reduce((e,t)=>e+t,0),0)}function Xe(){let{t:e}=K(),t=V(),n=Se(),[i,s]=r(null),[l,u]=r(null),f=async e=>{u(null);try{s(await n.mutateAsync({confirm:e}))}catch(e){u(e instanceof Error?e.message:String(e))}},p=async()=>{i===null||i.status!==`dry-run`||await t({title:e(`systemPage.deletedDevices.confirmTitle`,`Delete the data of deleted devices?`),message:i.devices.map(e=>`#${e.deviceId}: ${Je(e.stores)}`).join(`
|
|
2
|
-
`),confirmLabel:e(`systemPage.deletedDevices.confirmLabel`,`Delete`),variant:`danger`})&&await f(!0)},m=[{key:`device`,header:e(`systemPage.deletedDevices.device`,`Device`),render:e=>`#${e.deviceId}`},{key:`stores`,header:e(`systemPage.deletedDevices.stores`,`Data held`),nowrap:!1,render:e=>Je(e.stores)}];return a(`div`,{className:`space-y-4`,"data-testid":`deleted-devices-data`,children:[c(`p`,{className:`text-sm text-muted-foreground`,children:e(`systemPage.deletedDevices.intro`,`Data that still belongs to devices that were deleted before deletions were recorded: footage, events, history and per-addon settings. Scanning deletes nothing; deleting asks first and shows what goes.`)}),a(`div`,{className:`flex flex-wrap items-center gap-2`,children:[a(R,{variant:`outline`,onClick:()=>void f(!1),disabled:n.isPending,"data-testid":`deleted-devices-scan`,children:[n.isPending?c(S,{className:`mr-2 h-4 w-4 animate-spin`}):c(w,{className:`mr-2 h-4 w-4`}),e(`systemPage.deletedDevices.scan`,`Scan`)]}),i?.status===`dry-run`&&i.devices.length>0?a(R,{variant:`danger`,onClick:()=>void p(),disabled:n.isPending,"data-testid":`deleted-devices-delete`,children:[c(d,{className:`mr-2 h-4 w-4`}),e(`systemPage.deletedDevices.delete`,`Delete the data of {{count}} devices…`,{count:i.devices.length})]}):null]}),l===null?null:c(`p`,{className:`text-sm text-danger`,children:l}),i?.status===`skipped`?c(`p`,{className:`text-sm text-warning`,"data-testid":`deleted-devices-skipped`,children:e(`systemPage.deletedDevices.skipped`,`Nothing was listed or deleted: the device list could not be trusted ({{reason}}). Try again.`,{reason:i.reason??``})}):null,i!==null&&i.status!==`skipped`?a(o,{children:[c(`p`,{className:`text-sm`,"data-testid":`deleted-devices-summary`,children:i.status===`cleaned`?e(`systemPage.deletedDevices.cleaned`,`Deleted {{rows}} items of {{count}} devices.`,{rows:Ye(i.devices),count:i.devices.length}):e(`systemPage.deletedDevices.found`,`{{count}} deleted devices still hold {{rows}} items.`,{rows:Ye(i.devices),count:i.devices.length})}),c(fe,{columns:m,rows:i.devices,rowKey:e=>e.deviceId,emptyMessage:e(`systemPage.deletedDevices.none`,`No data belongs to a deleted device.`)}),i.unreachable.length>0?c(`p`,{className:`text-xs text-muted-foreground`,children:e(`systemPage.deletedDevices.unreachable`,`Not asked (unreachable): {{names}}`,{names:i.unreachable.join(`, `)})}):null]}):null]})}e();function Ze(){let{t:e}=K(),r=s(),i=V(),{data:o,isLoading:l,isError:u}=de({}),d=re(),f=n(()=>d.data??[],[d.data]),{data:p}=Ee({},{refetchOnWindowFocus:!1}),m=n(()=>Ke(o??[],p?.locations),[o,p?.locations]),{data:h}=pe({},{refetchOnWindowFocus:!1}),g=n(()=>Be(h),[h]),{state:_,openNew:v,openEdit:y,close:b}=B(),[x,S]=ce(`type`),C=()=>{S(null),b()},w=e=>{S(e),v()},T=e=>{S(null),y(e.id)},E=o??[],D=_.mode===`edit`?E.find(e=>e.id===_.id)??null:null;t(()=>{_.mode===`new`&&(x===null||x===``)&&(S(null),b())},[_.mode,x,b,S]),t(()=>{_.mode===`edit`&&!l&&D===null&&(S(null),b())},[_.mode,l,D,b,S]),t(()=>{_.mode===`closed`&&x!==null&&S(null)},[_.mode,x,S]);let O=L({onSuccess:()=>{r.invalidateQueries({queryKey:[[`storage`,`listLocations`]]})}}),k=ke({onSuccess:()=>{r.invalidateQueries({queryKey:[[`storage`,`listLocations`]]})}}),A=async(t,n)=>{He(n)&&!await i({title:e(`system.storage.disable`,`Disable "{{displayName}}"?`,{displayName:t.displayName}),message:e(`system.storage.nothingIsDeletedSetThe`,`{{consequence}} Nothing is deleted — set the location back to Read-only or Active to bring its footage back.`,{consequence:Ve(n).consequence}),confirmLabel:e(`common.disable`,`Disable`),variant:`danger`})||k.mutate(Ge(t,{mode:n}))},j=async t=>{if(await i({title:e(`system.storage.deleteLocation`,`Delete location "{{displayName}}"?`,{displayName:t.displayName}),message:e(`system.storage.thisRemovesTheLocationRecord`,`This removes the location record. Files on disk are not deleted; the underlying directory or remote path stays untouched.`),confirmLabel:e(`common.delete`,`Delete`),variant:`danger`}))try{await O.mutateAsync({id:t.id}),_.mode===`edit`&&_.id===t.id&&C()}catch(n){await i({title:e(`system.storage.deleteAnyway`,`Delete anyway?`),message:e(`system.storage.forcingNote`,{error:n instanceof Error?n.message:String(n)}),confirmLabel:e(`system.storage.forceDelete`,`Force delete`),variant:`danger`})&&O.mutate({id:t.id,force:!0},{onSuccess:()=>{_.mode===`edit`&&_.id===t.id&&C()}})}},M=n(()=>{let e=new Map;for(let t of o??[]){let n=e.get(t.type);n?n.push(t):e.set(t.type,[t])}return e},[o]),N=l||d.isLoading,P=u||d.isError,F=_.mode===`new`&&x!==null&&x!==``,I=_.mode===`edit`&&D!==null;return a(Re,{embedded:!0,children:[N&&c(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:e(`system.storage.loadingLocations`,`Loading locations…`)}),P&&c(`div`,{className:`text-xs text-danger`,children:e(`system.storage.failedToLoadStorageLocations`,`Failed to load storage locations.`)}),!N&&!P&&a(`div`,{className:`space-y-3`,children:[f.length===0&&c(`div`,{className:`rounded-lg border border-border bg-surface px-3 py-4 text-center text-[11px] text-foreground-subtle italic`,children:e(`system.storage.noStorageLocationsDeclaredBy`,`No storage locations declared by any installed addon.`)}),f.map(e=>c(Ue,{type:e.id,displayName:e.displayName,description:e.description,cardinality:e.cardinality,locations:M.get(e.id)??[],onAdd:w,onEdit:T,onDelete:e=>{j(e)},ownedBytesById:m,drainById:g,onSetMode:(e,t)=>{A(e,t)}},e.id))]}),F&&x!==null&&c(qe,{initialType:x,onClose:C,onCreated:()=>{r.invalidateQueries({queryKey:[[`storage`,`listLocations`]]}),C()}}),I&&D!==null&&c(We,{location:D,onClose:C,onSaved:()=>{r.invalidateQueries({queryKey:[[`storage`,`listLocations`]]}),C()}})]})}var Qe={settings:{labelKey:`helpers.backupDatabases.settings.label`,descriptionKey:`helpers.backupDatabases.settings.description`},events:{labelKey:`helpers.backupDatabases.events.label`,descriptionKey:`helpers.backupDatabases.events.description`},history:{labelKey:`helpers.backupDatabases.history.label`,descriptionKey:`helpers.backupDatabases.history.description`}},$e=Object.keys(Qe),J=[`settings`];function et(){return G.t(`helpers.backupDatabases.notCreated`)}function tt(e){return G.t(Qe[e].labelKey)}function nt(e){return G.t(Qe[e].descriptionKey)}function Y(e){let t=new Set(e);return $e.filter(e=>t.has(e))}function X(e){return e!==void 0&&e.length>0?Y(e):J}function rt(e){return Y(e)}function it(e,t){return t===void 0||!t.answered?`unknown`:t.databases.includes(e)?`present`:`absent`}function at(e,t,n){return it(e,t)===`absent`&&!n.has(e)}function ot(e,t){let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n}function st(e){return!e.includes(`settings`)}function ct(e){return{databases:[...rt(e)]}}function lt(e,t){return e!==void 0&&e.length>0?Y(e):t!==void 0&&t.length>0?Y(t.map(e=>e.databaseId??`settings`)):J}function Z({databases:e}){let{t}=K();return a(`span`,{className:`flex flex-wrap items-center gap-1`,"data-testid":`backup-database-badges`,children:[e.map(e=>c(be,{variant:e===`settings`?`primary`:`info`,style:`fill`,size:`sm`,children:tt(e)},e)),st(e)&&c(be,{variant:`warning`,style:`fill`,size:`sm`,children:t(`backup.backupDatabaseBadges.snapshotsOnly`,`Snapshots only`)})]})}e();var ut=[[`backup`,`listDestinations`]],dt=[`backup`,`listArchives`];function ft({destinationId:e,restoreSupported:t,onOpenRestoreWizard:o}){let{t:l}=K(),f=s(),p=V(),{data:m,isLoading:h,isError:g}=Me({destinationId:e}),_=m??[],v=he({onSuccess:()=>{f.invalidateQueries({queryKey:[[...dt]]}),f.invalidateQueries({queryKey:ut})}}),y=i(async t=>{await p({title:l(`backup.archiveList.deleteThisArchive`,`Delete this archive?`),message:l(`backup.archiveList.permanentlyDeletesAndFrees`,`Permanently deletes "{{value1}}" and frees {{value2}}.`,{value1:t.label??t.id,value2:q(t.sizeBytes)}),confirmLabel:l(`common.delete`,`Delete`),variant:`danger`})&&v.mutate({destinationId:e,backupId:t.id})},[p,e,v,l]),[x,C]=r(null),w=i(async t=>{C(t.id);try{let n=await ze(pt(e,t.id)),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`${t.label??t.id}.tar.gz${t.encryption===void 0?``:`.csbk`}`,document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(r)}finally{C(null)}},[e]),T=n(()=>[..._].toSorted((e,t)=>t.createdAt-e.createdAt),[_]);return h?c(`div`,{className:`text-xs text-foreground-subtle animate-pulse py-2`,children:l(`backup.archiveList.loadingArchives`,`Loading archives…`)}):g?c(`div`,{className:`text-xs text-danger py-2`,children:l(`backup.archiveList.failedToReadManifestFor`,`Failed to read manifest for this destination`)}):T.length===0?c(`div`,{className:`text-xs text-foreground-subtle italic py-2`,children:l(`backup.archiveList.noArchivesAtThisDestination`,`No archives at this destination yet.`)}):c(fe,{columns:[{key:`when`,header:l(`backup.archiveList.when`,`When`),sortValue:e=>e.createdAt,render:e=>c(`span`,{className:`tabular-nums`,children:mt(e.createdAt)})},{key:`label`,header:l(`backup.archiveList.label`,`Label`),sortValue:e=>e.label??null,render:e=>a(`span`,{className:`inline-flex items-center gap-1`,children:[e.encryption!==void 0&&c(E,{className:`h-3 w-3 text-success`,"aria-label":l(`backup.archiveList.encryptedRestoreNeedsBackupKey`,`encrypted — restore needs backup key {{keyId}}`,{keyId:e.encryption.keyId})}),e.label??c(`span`,{className:`text-foreground-subtle italic`,children:`—`})]})},{key:`databases`,header:l(`backup.archiveList.databases`,`Databases`),nowrap:!1,notSortableReason:`Database badges`,render:e=>c(Z,{databases:X(e.databases)})},{key:`includes`,header:l(`backup.archiveList.files`,`Files`),nowrap:!1,notSortableReason:`Location list`,render:e=>e.locations.length>0?c(`span`,{className:`text-foreground-subtle`,children:e.locations.join(`, `)}):c(`span`,{className:`text-foreground-subtle italic`,children:l(`common.none`)})},{key:`size`,header:l(`backup.archiveList.size`,`Size`),align:`right`,sortValue:e=>e.sizeBytes,render:e=>c(`span`,{className:`tabular-nums`,children:q(e.sizeBytes)})},{key:`actions`,header:``,align:`right`,notSortableReason:`Actions`,render:n=>a(`span`,{className:`flex items-center justify-end gap-1`,children:[a(R,{variant:`ghost`,size:`sm`,onClick:()=>{w(n)},disabled:x===n.id,title:l(`backup.archiveList.downloadArchive`,`Download archive`),children:[x===n.id?c(S,{className:`h-3 w-3 animate-spin`}):c(u,{className:`h-3 w-3`}),l(`backup.archiveList.download`,`Download`)]}),t&&o&&a(R,{variant:`ghost`,size:`sm`,onClick:()=>o({destinationId:e,archiveId:n.id}),title:l(`backup.archiveList.restoreFromThisArchive`,`Restore from this archive`),children:[c(b,{className:`h-3 w-3`}),l(`backup.archiveList.restore`,`Restore`)]}),c(H,{variant:`ghost`,size:`sm`,icon:d,"aria-label":l(`backup.archiveList.delete`,`Delete {{value1}}`,{value1:n.label??n.id}),disabled:v.isPending,onClick:()=>{y(n)}})]})}],rows:T,rowKey:e=>e.id,minWidthPx:760,emptyMessage:l(`backup.archiveList.noArchivesAtThisDestination`,`No archives at this destination yet.`)})}function pt(e,t){return _(`/api/backup/download/${encodeURIComponent(e)}/${encodeURIComponent(t)}`)}function mt(e){return new Date(e).toLocaleString(void 0,{day:`2-digit`,month:`short`,year:`numeric`,hour:`2-digit`,minute:`2-digit`})}e();var ht=[[`backup`,`listSchedules`]];function gt({onEdit:e,onOpenRestoreWizard:t}){let{t:o}=K(),{data:s,isLoading:l,isError:u,error:d,refetch:f}=ve(),p=s??[],m=W().data??[],h=n(()=>{let e=new Map;for(let t of m)e.set(t.id,t);return e},[m]),[g,_]=r(null),v=i(e=>{_(t=>t===e?null:e)},[]),y=g===null?null:p.find(e=>e.id===g)??null,b=n(()=>_t({destById:h,expandedId:g,onToggleExpand:v,onEdit:e}),[h,g,v,e]);return l?a(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle animate-pulse`,children:[c(S,{className:`h-3.5 w-3.5 animate-spin`}),o(`backup.backupEntriesTable.loadingBackupEntries`,`Loading backup entries…`)]}):u?c(ae,{title:o(`backup.backupEntriesTable.failedToLoadBackupEntries`,`Failed to load backup entries`),message:d instanceof Error?d.message:o(`backup.backupEntriesTable.unknownError`,`Unknown error`),onRetry:()=>void f()}):p.length===0?c(le,{icon:j,title:o(`backup.backupEntriesTable.noBackupEntriesYet`,`No backup entries yet`),description:o(`backup.backupEntriesTable.createOneToScheduleBackups`,`Create one to schedule backups across one or more storage locations.`)}):a(`div`,{className:`space-y-2`,children:[c(fe,{columns:b,rows:p,rowKey:e=>e.id,minWidthPx:980,maxBodyHeight:me,emptyMessage:o(`backup.backupEntriesTable.noBackupEntriesYet`,`No backup entries yet`),onRowClick:t=>e(t)}),y!==null&&c(wt,{row:y,destById:h,...t?{onOpenRestoreWizard:t}:{}})]})}function _t(e){return[{key:`expand`,header:``,width:`w-8`,nowrap:!0,notSortableReason:`Expand control`,render:t=>{let n=e.expandedId===t.id;return c(H,{variant:`ghost`,size:`sm`,icon:n?A:y,"aria-label":n?G.t(`backup.backupEntriesTable.hideArchives`,`Hide archives`):G.t(`backup.backupEntriesTable.showArchives`,`Show archives`),"aria-expanded":n,onClick:n=>{n.stopPropagation(),e.onToggleExpand(t.id)}})}},{key:`entry`,header:G.t(`backup.backupEntriesTable.entry`,`Entry`),sortValue:e=>e.label,render:e=>a(`span`,{className:`flex min-w-0 flex-col`,children:[c(`span`,{className:`truncate font-medium text-foreground`,children:e.label||G.t(`backup.backupEntriesTable.unnamed`,`(unnamed)`)}),e.lastRunAt!==void 0&&c(`span`,{className:`text-[10px] text-foreground-subtle`,children:G.t(`backup.backupEntriesTable.lastRun`,{when:new Date(e.lastRunAt).toLocaleString()})})]})},{key:`enabled`,header:G.t(`backup.backupEntriesTable.enabled`,`Enabled`),width:`w-20`,nowrap:!0,sortValue:e=>+!!e.enabled,render:e=>c(`span`,{onClick:e=>e.stopPropagation(),children:c(xt,{row:e})})},{key:`databases`,header:G.t(`backup.backupEntriesTable.backsUp`,`Backs up`),nowrap:!1,notSortableReason:`Database badges`,render:e=>c(Z,{databases:X(e.databases)})},{key:`locations`,header:G.t(`backup.backupEntriesTable.locations`,`Locations`),nowrap:!1,notSortableReason:`Location chips`,render:t=>c(vt,{row:t,destById:e.destById})},{key:`retention`,header:G.t(`backup.backupEntriesTable.retention`,`Retention`),width:`w-24`,nowrap:!0,sortValue:e=>e.retentionCount,render:e=>c(`span`,{onClick:e=>e.stopPropagation(),children:c(St,{row:e})})},{key:`schedule`,header:G.t(`backup.backupEntriesTable.schedule`,`Schedule`),width:`w-48`,nowrap:!0,sortValue:e=>e.cron,render:e=>c(yt,{row:e})},{key:`actions`,header:``,align:`right`,nowrap:!0,notSortableReason:`Actions`,render:t=>c(`span`,{onClick:e=>e.stopPropagation(),children:c(Ct,{row:t,onEdit:()=>e.onEdit(t)})})}]}function vt({row:e,destById:t}){let{t:n}=K();return e.locationIds.length===0?c(`span`,{className:`text-[11px] italic text-danger`,children:n(`backup.backupEntriesTable.noLocations`,`No locations`)}):c(`span`,{className:`flex flex-wrap gap-1`,children:e.locationIds.map(e=>c(`span`,{className:`inline-flex items-center rounded border border-border bg-background px-1.5 py-0.5 text-[10px] text-foreground`,title:e,children:t.get(e)?.displayName??e},e))})}function yt({row:e}){let{t}=K(),n=e.cron.trim().length>0;return a(`span`,{className:`flex flex-col items-start gap-0.5`,children:[a(`span`,{className:`inline-flex items-center gap-1`,children:[c(j,{className:`h-3 w-3 text-foreground-subtle`}),c(`span`,{className:`font-mono text-[11px] text-foreground`,children:n?e.cron:t(`backup.backupEntriesTable.manual`,`Manual`)})]}),n&&e.nextRunAt!==void 0&&c(`span`,{className:`text-[10px] text-foreground-subtle`,children:G.t(`common.nextRun`,{when:new Date(e.nextRunAt).toLocaleString()})})]})}function bt(e){return n(()=>({id:e.id,label:e.label,cron:e.cron,locationIds:[...e.locationIds],retentionCount:e.retentionCount,...e.dataSources?{dataSources:[...e.dataSources]}:{},...e.databases?{databases:[...e.databases]}:{}}),[e])}function xt({row:e}){let{t}=K(),n=s(),r=Ne({onSuccess:()=>{n.invalidateQueries({queryKey:ht})}}),i=bt(e);return c(`label`,{className:`inline-flex cursor-pointer items-center`,children:c(`input`,{type:`checkbox`,className:`accent-primary`,checked:e.enabled,disabled:r.isPending,onChange:e=>r.mutate({...i,enabled:e.target.checked}),"aria-label":t(`backup.backupEntriesTable.enable`,`Enable {{value1}}`,{value1:e.label||e.id})})})}function St({row:e}){let{t:n}=K(),i=s(),a=Ne({onSuccess:()=>{i.invalidateQueries({queryKey:ht})}}),o=bt(e),[l,u]=r(String(e.retentionCount));return t(()=>{u(String(e.retentionCount))},[e.retentionCount]),c(F,{type:`number`,min:1,max:1e3,value:l,disabled:a.isPending,onChange:e=>u(e.target.value),onBlur:()=>{let t=Number.parseInt(l,10);if(Number.isNaN(t)||t<1){u(String(e.retentionCount));return}t!==e.retentionCount&&a.mutate({...o,enabled:e.enabled,retentionCount:t})},onKeyDown:t=>{t.key===`Enter`&&t.target.blur(),t.key===`Escape`&&u(String(e.retentionCount))},className:`w-16`,"aria-label":n(`backup.backupEntriesTable.retentionFor`,`Retention for {{value1}}`,{value1:e.label||e.id})})}function Ct({row:e,onEdit:t}){let{t:n}=K(),r=s(),i=V(),o=_e({onSuccess:()=>{r.invalidateQueries({queryKey:ht})}}),l=De({onMutate:()=>{r.invalidateQueries({queryKey:[[`backup`,`listRuns`]]})},onSuccess:()=>{r.invalidateQueries({queryKey:[[`backup`,`listArchives`]]}),r.invalidateQueries({queryKey:[[`backup`,`listDestinations`]]}),r.invalidateQueries({queryKey:[[`backup`,`listRuns`]]})}}),u=()=>{e.locationIds.length!==0&&l.mutate({destinations:[...e.locationIds],...e.dataSources&&e.dataSources.length>0?{locations:[...e.dataSources]}:{},label:e.label,retentionCount:e.retentionCount,databases:[...X(e.databases)]})},f=async()=>{await i({title:n(`backup.backupEntriesTable.deleteBackupEntry`,`Delete backup entry?`),message:n(`backup.backupEntriesTable.willStopRunningExistingArchives`,`"{{value1}}" will stop running. Existing archives are kept.`,{value1:e.label||e.id}),confirmLabel:n(`common.delete`,`Delete`),variant:`warning`})&&o.mutate({id:e.id})};return a(`span`,{className:`flex items-center justify-end gap-1.5`,children:[a(R,{size:`sm`,type:`button`,onClick:u,disabled:l.isPending||e.locationIds.length===0,title:n(`backup.backupEntriesTable.runThisEntryNow`,`Run this entry now`),children:[l.isPending?c(S,{className:`h-3 w-3 animate-spin`}):c(T,{className:`h-3 w-3`}),n(`backup.backupEntriesTable.runNow`,`Run now`)]}),c(H,{variant:`ghost`,size:`sm`,icon:g,"aria-label":n(`backup.backupEntriesTable.edit`,`Edit {{value1}}`,{value1:e.label||e.id}),onClick:t}),c(H,{variant:`ghost`,size:`sm`,icon:d,"aria-label":n(`backup.backupEntriesTable.delete`,`Delete {{value1}}`,{value1:e.label||e.id}),disabled:o.isPending,onClick:()=>{f()}})]})}function wt({row:e,destById:t,onOpenRestoreWizard:n}){let{t:r}=K();return a(`div`,{className:`space-y-4 rounded-lg border border-border bg-background/30 px-4 py-3`,children:[c(`p`,{className:`text-[11px] font-medium text-foreground-subtle`,children:r(`backup.backupEntriesTable.archivesFor`,{name:e.label||e.id})}),e.locationIds.length===0&&c(`p`,{className:`text-xs italic text-foreground-subtle`,children:r(`backup.backupEntriesTable.thisEntryHasNoLocations`,`This entry has no locations selected.`)}),e.locationIds.map(e=>a(`div`,{className:`space-y-1.5`,children:[c(`div`,{className:`text-[11px] font-medium text-foreground-subtle`,children:t.get(e)?.displayName??e}),c(ft,{destinationId:e,restoreSupported:t.get(e)?.restoreSupported??!0,...n?{onOpenRestoreWizard:n}:{}})]},e))]})}function Tt({selected:e,onChange:t,disabled:n=!1,testId:r=`backup-databases`}){let{t:i}=K(),o=Oe().data,s=e.size>0&&st(Y(e)),l=e.size===0?`Pick at least one.`:s?`Snapshots only: configuration and files are not part of this backup.`:null;return c(z,{label:i(`backup.backupDatabasePicker.whatToBackUp`,`What to back up`),required:!0,...l===null?{}:{description:l},children:c(`div`,{className:`divide-y divide-border rounded border border-border bg-background`,"data-testid":r,children:$e.map(s=>{let l=it(s,o),u=n||at(s,o,e);return a(`label`,{className:`flex items-start gap-2 px-3 py-2 text-xs ${u?`opacity-60`:`cursor-pointer hover:bg-primary/5`}`,children:[c(ye,{checked:e.has(s),disabled:u,onChange:()=>t(ot(e,s)),"data-testid":`${r}-${s}`}),a(`span`,{className:`min-w-0 flex-1`,children:[a(`span`,{className:`flex flex-wrap items-center gap-1.5 text-foreground`,children:[tt(s),l===`absent`&&c(be,{variant:`neutral`,size:`sm`,children:i(`backup.backupDatabasePicker.notCreatedYet`,`Not created yet`)})]}),c(`span`,{className:`block text-[11px] text-foreground-subtle`,children:l===`absent`?et():nt(s)})]})]},s)})})})}e();function Et({onClose:e}){let{t}=K(),n=s(),[i,o]=r(new Set(J)),l=De({onMutate:()=>{n.invalidateQueries({queryKey:[[`backup`,`listRuns`]]})},onSuccess:()=>{n.invalidateQueries({queryKey:[[`backup`,`listArchives`]]}),n.invalidateQueries({queryKey:[[`backup`,`listDestinations`]]}),n.invalidateQueries({queryKey:[[`backup`,`listRuns`]]}),e()}});return c(ue,{open:!0,onOpenChange:t=>!t&&e(),children:a(te,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[a(ee,{children:[c(Te,{children:t(`backup.backupNowDialog.backUpNow`,`Back up now`)}),c(`p`,{className:`text-xs text-foreground-subtle`,children:t(`backup.backupNowDialog.runsOnceAndWritesThe`,`Runs once and writes the archive to every enabled backup location.`)})]}),c(ne,{children:a(`div`,{className:`p-4`,children:[c(Tt,{selected:i,onChange:o,disabled:l.isPending,testId:`backup-now-databases`}),l.error&&c(`p`,{role:`alert`,className:`pt-2 text-xs text-danger`,children:l.error.message})]})}),a(U,{children:[c(R,{variant:`outline`,size:`sm`,onClick:e,children:t(`common.cancel`,`Cancel`)}),a(R,{size:`sm`,onClick:()=>{i.size!==0&&l.mutate(ct(i))},disabled:i.size===0||l.isPending,"data-testid":`backup-now-run`,children:[l.isPending?c(S,{className:`h-3.5 w-3.5 animate-spin`}):c(T,{className:`h-3.5 w-3.5`}),t(`backup.backupNowDialog.backUpNow`,`Back up now`)]})]})]})})}e();function Dt(e){return e===null?`—`:new Date(e).toLocaleString()}function Ot(e){let t=new Blob([`${e.secretKey}\n`],{type:`text/plain`}),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=`camstack-backup-key-${e.keyId}.txt`,r.click(),URL.revokeObjectURL(n)}function kt({revealed:e,onDone:t}){let{t:n}=K(),[i,o]=r(!1),[s,l]=r(!1);return c(ue,{open:!0,onOpenChange:e=>!e&&i&&t(),children:a(te,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,className:`border-danger/40`,"aria-labelledby":`backup-key-title`,children:[c(ee,{children:c(Te,{id:`backup-key-title`,children:n(`backup.encryptionCard.yourKey`,{keyId:e.keyId})})}),a(ne,{className:`space-y-3`,children:[a(`p`,{className:`flex items-start gap-2 rounded-md border border-danger/40 bg-danger/10 p-2 text-xs text-foreground`,children:[c(m,{className:`mt-0.5 h-4 w-4 shrink-0 text-danger`}),c(`span`,{children:n(`backup.backupEncryptionCard.thisKeyIsShownOnly`,`This key is shown only once. CamStack does not keep it — not the hub, not its database, not its backups. Without it, an encrypted backup cannot be restored by anyone, including you. Store it in a password manager or print it, away from this server.`)})]}),c(`div`,{className:`break-all rounded-md border border-border bg-background p-2 font-mono text-xs text-foreground select-all`,children:e.secretKey}),a(`div`,{className:`flex flex-wrap gap-2`,children:[a(R,{size:`sm`,variant:`outline`,onClick:()=>{navigator.clipboard?.writeText(e.secretKey).then(()=>l(!0))},children:[c(v,{className:`mr-1 h-3.5 w-3.5`}),s?n(`backup.backupEncryptionCard.copied`,`Copied`):n(`common.copy`,`Copy`)]}),a(R,{size:`sm`,variant:`outline`,onClick:()=>Ot(e),children:[c(u,{className:`mr-1 h-3.5 w-3.5`}),n(`backup.backupEncryptionCard.downloadAsFile`,`Download as file`)]})]}),a(`label`,{className:`flex items-center gap-2 text-xs text-foreground`,children:[c(`input`,{type:`checkbox`,checked:i,onChange:e=>o(e.target.checked),className:`accent-primary`}),n(`backup.backupEncryptionCard.iHaveStoredThisKey`,`I have stored this key somewhere safe, off this server.`)]})]}),c(U,{children:c(R,{size:`sm`,disabled:!i,onClick:t,children:n(`backup.backupEncryptionCard.iHaveStoredIt`,`I have stored it`)})})]})})}function At(){let{t:e}=K(),t=I(),n=xe(),i=se(),s=V(),[l,u]=r(null),[d,f]=r(null),p=t.data?.enabled??!1,m=t.data?.active??null,h=(t.data?.keys??[]).filter(e=>e.retiredAt!==null),g=async()=>{if(await s({title:p?e(`backup.backupEncryptionCard.replaceTheBackupKey`,`Replace the backup key`):e(`backup.backupEncryptionCard.encryptBackups`,`Encrypt backups`),message:p?e(`backup.backupEncryptionCard.aNewKeyIsGenerated`,`A new key is generated and shown once; new backups are encrypted to it. Older backups keep needing the key they were made with — keep that one too.`):e(`backup.backupEncryptionCard.aBackupKeyIsGenerated`,`A backup key is generated and shown once. Every new backup is encrypted to it, and restoring one will ask for it. Existing backups stay as they are.`),confirmLabel:p?e(`backup.backupEncryptionCard.generateANewKey`,`Generate a new key`):e(`backup.backupEncryptionCard.generateTheKey`,`Generate the key`),variant:`warning`})){f(null);try{let e=await n.mutateAsync({});u({keyId:e.keyId,secretKey:e.secretKey})}catch(e){f(e instanceof Error?e.message:String(e))}}},_=async()=>{if(await s({title:e(`backup.backupEncryptionCard.turnBackupEncryptionOff`,`Turn backup encryption off`),message:e(`backup.backupEncryptionCard.newBackupsWillBeWritten`,`New backups will be written unencrypted. Existing encrypted backups still need their key to be restored.`),confirmLabel:e(`backup.backupEncryptionCard.turnOff`,`Turn off`),variant:`danger`})){f(null);try{await i.mutateAsync({}),t.refetch()}catch(e){f(e instanceof Error?e.message:String(e))}}};return a(`div`,{className:`space-y-2 rounded-lg border border-border bg-surface p-4`,children:[a(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[a(`div`,{className:`flex items-center gap-2`,children:[p?c(E,{className:`h-4 w-4 text-success`}):c(k,{className:`h-4 w-4 text-foreground-subtle`}),c(`h2`,{className:`text-sm font-semibold text-foreground`,children:e(`backup.backupEncryptionCard.encryption`,`Encryption`)}),c(`span`,{className:`text-xs text-foreground-subtle`,children:p&&m!==null?e(`backup.backupEncryptionCard.onKeySince`,`On — key {{keyId}}, since {{value2}}`,{keyId:m.keyId,value2:Dt(m.createdAt)}):e(`backup.backupEncryptionCard.offBackupsAreNotEncrypted`,`Off — backups are not encrypted`)})]}),c(`div`,{className:`flex gap-2`,children:p?a(o,{children:[c(R,{size:`sm`,variant:`outline`,disabled:n.isPending,onClick:()=>void g(),children:e(`backup.backupEncryptionCard.replaceKey`,`Replace key`)}),c(R,{size:`sm`,variant:`outline`,disabled:i.isPending,onClick:()=>void _(),children:e(`backup.backupEncryptionCard.turnOff`,`Turn off`)})]}):c(R,{size:`sm`,disabled:n.isPending,onClick:()=>void g(),children:e(`backup.backupEncryptionCard.enableEncryption`,`Enable encryption`)})})]}),c(`p`,{className:`text-xs text-foreground-subtle`,children:e(`backup.backupEncryptionCard.archivesAreEncryptedOnThis`,`Archives are encrypted on this server before they reach any destination. The server keeps only a public key, so it can encrypt scheduled backups but cannot decrypt them — only your backup key can. Covers the database snapshot, config.yaml, addon data (HomeKit pairing, Matter fabric, Tailscale state) and TLS.`)}),h.length>0&&a(`div`,{className:`text-xs`,children:[c(`p`,{className:`text-foreground-subtle`,children:e(`backup.backupEncryptionCard.olderKeysBackupsMadeWith`,`Older keys (backups made with them still need them):`)}),c(`ul`,{className:`font-mono text-foreground`,children:h.map(e=>a(`li`,{children:[e.keyId,` · `,Dt(e.createdAt),` → `,Dt(e.retiredAt)]},e.keyId))})]}),d!==null&&c(`p`,{className:`text-xs text-danger`,children:d}),l!==null&&c(kt,{revealed:l,onDone:()=>{u(null),t.refetch()}})]})}e();var jt=[{id:`manual`,labelKey:`backup.cronEditor.presetManual`,cron:``},{id:`hourly`,labelKey:`backup.cronEditor.presetHourly`,cron:`0 * * * *`,descriptionKey:`backup.cronEditor.presetHourlyDesc`},{id:`every-3h`,labelKey:`backup.cronEditor.preset3h`,cron:`0 */3 * * *`,description:`00:00, 03:00, 06:00, 09:00 …`},{id:`every-6h`,labelKey:`backup.cronEditor.preset6h`,cron:`0 */6 * * *`,description:`00:00, 06:00, 12:00, 18:00`},{id:`daily-3am`,labelKey:`backup.cronEditor.presetDaily`,cron:`0 3 * * *`,descriptionKey:`backup.cronEditor.presetDailyDesc`},{id:`weekly-sun`,labelKey:`backup.cronEditor.presetWeekly`,cron:`0 3 * * 0`,descriptionKey:`backup.cronEditor.presetWeeklyDesc`}];function Mt(e){let t=e.trim();for(let e of jt)if(e.cron===t)return e.id;return`custom`}function Nt({value:e,onChange:n,previewCount:i=5,disabled:o=!1}){let{t:s}=K(),l=Mt(e),[u,d]=r(l===`custom`);t(()=>{l!==`custom`&&d(!1)},[l]);let f=It(e,250),p=Ae({cron:f,count:i},{enabled:f.trim().length>0}),m=p.data??null,h=e=>{d(!1),n(e.cron)},g=u||l===`custom`;return a(`div`,{className:`space-y-3`,children:[a(`div`,{className:`space-y-1`,children:[c(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:s(`backup.cronEditor.schedulePreset`,`Schedule preset`)}),a(`div`,{className:`flex flex-wrap gap-1.5`,children:[jt.map(e=>c(`button`,{type:`button`,onClick:()=>h(e),disabled:o,className:`rounded border px-2 py-1 text-[11px] transition-colors disabled:opacity-50 `+(!u&&l===e.id?`border-primary bg-primary/10 text-primary`:`border-border bg-background text-foreground-subtle hover:bg-primary/5 hover:text-foreground`),title:e.descriptionKey===void 0?e.description??s(e.labelKey):s(e.descriptionKey),children:s(e.labelKey)},e.id)),c(`button`,{type:`button`,onClick:()=>{d(!0),e.trim().length===0&&n(`0 3 * * *`)},disabled:o,className:`rounded border px-2 py-1 text-[11px] transition-colors disabled:opacity-50 `+(g?`border-primary bg-primary/10 text-primary`:`border-border bg-background text-foreground-subtle hover:bg-primary/5 hover:text-foreground`),children:s(`backup.cronEditor.custom`,`Custom…`)})]})]}),g&&a(`div`,{className:`space-y-1`,children:[c(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:s(`backup.cronEditor.cronExpression5FieldPosix`,`Cron expression (5-field POSIX)`)}),c(`input`,{type:`text`,value:e,onChange:e=>n(e.target.value),disabled:o,placeholder:`0 3 * * *`,spellCheck:!1,className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs font-mono text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-1 focus:ring-primary`}),a(`p`,{className:`text-[10px] text-foreground-subtle`,children:[s(`backup.cronEditor.format`,`Format:`),` `,c(Ie,{i18nKey:`backup.cronEditor.formatLine`,components:{code:c(`span`,{className:`font-mono`})}})]})]}),c(Pt,{cron:f,preview:m,loading:p.isFetching})]})}function Pt({cron:e,preview:t,loading:n}){let{t:r}=K();return n&&t===null?a(`div`,{className:`flex items-center gap-2 rounded border border-border bg-background/40 px-3 py-2 text-[11px] text-foreground-subtle`,children:[c(S,{className:`h-3 w-3 animate-spin`}),r(`backup.cronEditor.validating`,`Validating…`)]}):t===null?null:t.ok?t.nextRuns.length===0?c(`div`,{className:`rounded border border-border bg-background/40 px-3 py-2 text-[11px] text-foreground-subtle`,children:r(`backup.cronEditor.noFutureRunsMatchThis`,`No future runs match this expression.`)}):a(`div`,{className:`space-y-1`,children:[c(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:r(`backup.cronEditor.nextRuns`,`Next runs`)}),c(`ul`,{className:`rounded border border-border bg-background/40 divide-y divide-border`,children:t.nextRuns.map((e,t)=>a(`li`,{className:`flex items-center justify-between px-3 py-1.5 text-[11px]`,children:[c(`span`,{className:`text-foreground tabular-nums`,children:new Date(e).toLocaleString()}),c(`span`,{className:`text-foreground-subtle text-[10px] tabular-nums`,children:Ft(e)})]},`${e}-${t}`))})]}):c(`div`,{className:`rounded border border-danger/40 bg-danger/10 px-3 py-2 text-[11px] text-danger`,children:t.error??r(`backup.cronEditor.invalidCronExpression`,`Invalid cron expression`)})}function Ft(e){let t=e-Date.now();if(t<=0)return G.t(`helpers.relativeTime.now`);let n=Math.floor(t/1e3);if(n<60)return G.t(`helpers.relativeTime.inSeconds`,{count:n});let r=Math.floor(n/60);if(r<60)return G.t(`helpers.relativeTime.inMinutes`,{count:r});let i=Math.floor(r/60);if(i<24)return G.t(`helpers.relativeTime.inHours`,{count:i});let a=Math.floor(i/24);return G.t(`helpers.relativeTime.inDays`,{count:a})}function It(e,i){let[a,o]=r(e),s=n(()=>e,[e]);return t(()=>{let e=setTimeout(()=>o(s),i);return()=>clearTimeout(e)},[s,i]),a}e();var Lt=[[`backup`,`listSchedules`]];function Rt({entry:e,onClose:t,onSaved:i}){let{t:o}=K(),l=s(),u=W(),d=u.data??[],[f,p]=r(e?.label??``),[m,h]=r(e?.cron??`0 3 * * *`),[g,_]=r(e?.enabled??!0),[v,y]=r(String(e?.retentionCount??7)),[b,x]=r(new Set(e?.locationIds??[])),[C,w]=r(new Set(e===null?J:X(e.databases))),T=Ne({onSuccess:()=>{l.invalidateQueries({queryKey:Lt}),i()}}),E=e=>{x(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},D=Number.parseInt(v,10),O=n(()=>f.trim().length>0&&b.size>0&&C.size>0&&!Number.isNaN(D)&&D>=1&&D<=1e3,[f,b,C,D]),k=()=>{O&&T.mutate({...e?{id:e.id}:{},label:f.trim(),cron:m.trim(),enabled:g,locationIds:Array.from(b),retentionCount:D,databases:[...rt(C)]})},A=T.error instanceof Error?T.error.message:null;return c(Pe,{open:!0,onClose:t,title:e?o(`backup.backupEntryModal.editBackupEntry`,`Edit backup entry`):o(`backup.backupEntryModal.newBackupEntry`,`New backup entry`),icon:j,error:A,width:`lg`,testId:`backup-entry-form`,footer:a(R,{size:`sm`,type:`button`,onClick:k,disabled:!O||T.isPending,children:[T.isPending?c(S,{className:`h-3.5 w-3.5 animate-spin`}):null,e?o(`common.save`,`Save`):o(`backup.backupEntryModal.createEntry`,`Create entry`)]}),children:a(`div`,{className:`space-y-4`,children:[c(z,{label:o(`backup.backupEntryModal.name`,`Name`),required:!0,children:c(F,{value:f,onChange:e=>p(e.target.value),placeholder:o(`backup.backupEntryModal.nightlyOffsite`,`Nightly offsite`),autoFocus:!0,"data-testid":`backup-entry-name`})}),a(z,{label:o(`backup.backupEntryModal.locationsSelected`,`Locations ({{value1}} selected)`,{value1:String(b.size)}),required:!0,children:[u.isLoading&&a(`div`,{className:`flex items-center gap-2 px-1 py-2 text-xs text-foreground-subtle`,children:[c(S,{className:`h-3.5 w-3.5 animate-spin`}),o(`backup.backupEntryModal.loadingLocations`,`Loading locations…`)]}),!u.isLoading&&d.length===0&&c(`div`,{className:`rounded border border-border bg-background px-3 py-2 text-xs text-foreground-subtle italic`,children:o(`backup.backupEntryModal.noBackupsStorageLocationsConfigured`,"No `backups` storage locations configured. Add one in Settings → Storage first.")}),d.length>0&&c(`div`,{className:`max-h-52 divide-y divide-border overflow-y-auto rounded border border-border bg-background`,children:d.map(e=>a(`label`,{className:`flex cursor-pointer items-center justify-between px-3 py-2 text-xs hover:bg-primary/5`,children:[a(`div`,{className:`flex items-center gap-2`,children:[c(`input`,{type:`checkbox`,checked:b.has(e.id),onChange:()=>E(e.id),className:`accent-primary`}),c(`span`,{className:`text-foreground`,children:e.displayName})]}),a(`div`,{className:`flex items-center gap-1.5`,children:[c(`span`,{className:`rounded border border-border bg-surface px-1.5 py-0.5 text-[10px] uppercase tracking-wide text-foreground-subtle`,children:e.kind}),c(`span`,{className:`font-mono text-[10px] text-foreground-subtle`,children:e.id})]})]},e.id))})]}),c(Tt,{selected:C,onChange:w,disabled:T.isPending,testId:`backup-entry-databases`}),a(`div`,{className:`grid grid-cols-2 gap-3`,children:[c(z,{label:o(`backup.backupEntryModal.retentionArchivesKept`,`Retention (archives kept)`),required:!0,children:c(F,{type:`number`,min:1,max:1e3,value:v,onChange:e=>y(e.target.value),"data-testid":`backup-entry-retention`})}),c(z,{label:o(`backup.backupEntryModal.enabled`,`Enabled`),description:o(`backup.backupEntryModal.runOnScheduleWhenChecked`,`Run on schedule when checked.`),children:a(`label`,{className:`inline-flex cursor-pointer items-center gap-2 py-1.5 text-xs text-foreground`,children:[c(`input`,{type:`checkbox`,checked:g,onChange:e=>_(e.target.checked),className:`accent-primary`,"data-testid":`backup-entry-enabled`}),c(`span`,{children:o(`backup.backupEntryModal.runOnSchedule`,`Run on schedule`)})]})})]}),c(z,{label:o(`backup.backupEntryModal.schedule`,`Schedule`),children:c(Nt,{value:m,onChange:h,disabled:T.isPending})})]})})}e();var zt=2e3,Bt=5e3;function Q(e){return e.state===`queued`||e.state===`running`}function Vt(e){if(e.state===`queued`)return{title:G.t(`backup.backupRunsPanel.cancelQueuedBackupRun`,`Cancel queued backup run?`),message:G.t(`backup.backupRunsPanel.thisRunHasNotStarted`,`This run has not started. Cancelling removes it from the queue — nothing has been written, nothing is deleted.`),confirmLabel:G.t(`backup.backupRunsPanel.cancelRun`,`Cancel run`),variant:`warning`};let t=e.completedDestinationIds.length,n=t>0?`${t===1?`The 1 destination`:`The ${t} destinations`} that already completed KEEP${t===1?`S`:``} the archive.`:`No destination has completed yet, so nothing will be kept.`;return{title:G.t(`backup.backupRunsPanel.stopThisBackupRun`,`Stop this backup run?`),message:G.t(`backup.backupRunsPanel.theHalfWrittenStagingArchive`,`The half-written staging archive is deleted and the destination currently uploading discards its partial copy. {{keptSentence}}`,{keptSentence:n}),confirmLabel:G.t(`backup.backupRunsPanel.stopRun`,`Stop run`),variant:`danger`}}function Ht(){let e=V(),[t,n]=r(null),a=we(void 0,{refetchInterval:e=>(e.state.data??[]).some(Q)?zt:Bt}),o=ge({onSettled:()=>{n(null),a.refetch()}}),s=i(async t=>{await e(Vt(t))&&(n(t.id),o.mutate({runId:t.id}))},[e,o]);return c(Ut,{queryState:a.isError?`error`:a.data===void 0?`pending`:`ready`,runs:a.data??[],cancelingId:t,onCancelRequest:e=>{s(e)},now:Date.now()})}function Ut({queryState:e,runs:t,cancelingId:n,onCancelRequest:r,now:i}){let{t:o}=K(),s=e===`ready`&&t.some(Q),l=t.filter(e=>e.state===`running`),u=t.filter(e=>e.state===`queued`),d=t.filter(e=>!Q(e)),f=[...l,...u,...d];return a(`section`,{className:`rounded-lg border border-border bg-surface`,children:[a(`div`,{className:`flex items-center gap-2 px-3 py-2 border-b border-border`,children:[c(`h2`,{className:`text-xs font-semibold text-foreground`,children:o(`backup.backupRunsPanel.runs`,`Runs`)}),s&&a(`span`,{className:`inline-flex items-center gap-1 text-[10px] font-medium text-primary`,title:o(`backup.backupRunsPanel.aBackupRunIsIn`,`A backup run is in progress`),children:[c(`span`,{className:`h-1.5 w-1.5 rounded-full bg-primary animate-pulse`}),o(`backup.runsPanel.live`)]}),c(`span`,{className:`ml-auto text-[10px] text-foreground-subtle`,children:o(`backup.backupRunsPanel.oneRunExecutesAtA`,`One run executes at a time — queued runs wait in line.`)})]}),e===`pending`&&c(`div`,{className:`px-3 py-2.5 text-xs text-foreground-subtle animate-pulse`,children:o(`backup.backupRunsPanel.checkingForBackupRuns`,`Checking for backup runs…`)}),e===`error`&&c(`div`,{className:`px-3 py-2.5 text-xs text-danger`,children:o(`backup.backupRunsPanel.couldNotReadBackupRuns`,`Could not read backup runs — the orchestrator did not answer.`)}),e===`ready`&&t.length===0&&c(`div`,{className:`px-3 py-2.5 text-xs text-foreground-subtle italic`,children:o(`backup.backupRunsPanel.noBackupRunsYetRuns`,`No backup runs yet. Runs appear here the moment one starts — manual or scheduled.`)}),e===`ready`&&t.length>0&&c(`div`,{className:`overflow-x-auto`,children:a(`table`,{className:`w-full text-xs min-w-[720px]`,children:[c(`thead`,{children:a(`tr`,{className:`text-foreground-subtle bg-background/30`,children:[c(`th`,{className:`text-left px-3 py-1.5 font-medium`,children:o(`backup.backupRunsPanel.run`,`Run`)}),c(`th`,{className:`text-left px-3 py-1.5 font-medium`,children:o(`backup.backupRunsPanel.state`,`State`)}),c(`th`,{className:`text-left px-3 py-1.5 font-medium`,children:o(`backup.backupRunsPanel.progress`,`Progress`)}),c(`th`,{className:`text-left px-3 py-1.5 font-medium`,children:o(`backup.backupRunsPanel.destinations`,`Destinations`)}),c(`th`,{className:`text-left px-3 py-1.5 font-medium`,children:o(`backup.backupRunsPanel.timing`,`Timing`)}),c(`th`,{className:`text-right px-3 py-1.5 font-medium w-28`,children:o(`backup.backupRunsPanel.actions`,`Actions`)})]})}),c(`tbody`,{children:f.map(e=>c(Wt,{run:e,canceling:n===e.id,onCancelRequest:r,now:i},e.id))})]})})]})}function Wt({run:e,canceling:t,onCancelRequest:n,now:r}){let{t:i}=K(),o=Q(e);return a(`tr`,{className:`border-t border-border hover:bg-primary/5 align-top`,children:[a(`td`,{className:`px-3 py-2`,children:[c(`div`,{className:`text-foreground`,children:e.label??c(`span`,{className:`text-foreground-subtle italic`,children:i(`backup.runsPanel.manual`)})}),c(`div`,{className:`text-[10px] text-foreground-subtle font-mono`,title:e.id,children:e.id.slice(0,8)})]}),a(`td`,{className:`px-3 py-2`,children:[c(Gt,{run:e}),e.state===`failed`&&e.error!==void 0&&c(`div`,{className:`mt-1 text-[10px] text-danger max-w-56 truncate`,title:e.error,children:e.error})]}),c(`td`,{className:`px-3 py-2`,children:c(Kt,{run:e})}),c(`td`,{className:`px-3 py-2`,children:c(qt,{run:e})}),c(`td`,{className:`px-3 py-2 text-foreground-subtle tabular-nums`,children:c(Jt,{run:e,now:r})}),c(`td`,{className:`px-3 py-2`,children:c(`div`,{className:`flex justify-end`,children:o&&a(`button`,{onClick:()=>n(e),disabled:t,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10 disabled:opacity-50`,title:e.state===`queued`?i(`backup.backupRunsPanel.removeThisRunFromThe`,`Remove this run from the queue before it starts`):i(`backup.backupRunsPanel.stopThisRunTheHalf`,`Stop this run — the half-written archive is discarded`),children:[t?c(S,{className:`h-3 w-3 animate-spin`}):c(l,{className:`h-3 w-3`}),e.state===`queued`?i(`common.cancel`,`Cancel`):i(`backup.backupRunsPanel.stop`,`Stop`)]})})})]})}function Gt({run:e}){let{t}=K();switch(e.state){case`queued`:return a(`span`,{className:`inline-flex items-center gap-1 rounded bg-foreground-subtle/10 px-1.5 py-0.5 text-[10px] font-medium text-foreground-subtle`,children:[c(O,{className:`h-3 w-3`}),t(`backup.backupRunsPanel.queued`,`Queued`)]});case`running`:return a(`span`,{className:`inline-flex items-center gap-1 rounded bg-primary/10 px-1.5 py-0.5 text-[10px] font-medium text-primary`,children:[c(S,{className:`h-3 w-3 animate-spin`}),e.phase===`uploading`?t(`backup.backupRunsPanel.uploading`,`Uploading`):t(`backup.backupRunsPanel.buildingArchive`,`Building archive`)]});case`succeeded`:return a(`span`,{className:`inline-flex items-center gap-1 rounded bg-success/10 px-1.5 py-0.5 text-[10px] font-medium text-success`,children:[c(C,{className:`h-3 w-3`}),t(`backup.backupRunsPanel.succeeded`,`Succeeded`)]});case`failed`:return a(`span`,{className:`inline-flex items-center gap-1 rounded bg-danger/10 px-1.5 py-0.5 text-[10px] font-medium text-danger`,children:[c(x,{className:`h-3 w-3`}),t(`backup.backupRunsPanel.failed`,`Failed`)]});case`cancelled`:return a(`span`,{className:`inline-flex items-center gap-1 rounded bg-amber-500/10 px-1.5 py-0.5 text-[10px] font-medium text-amber-700 dark:text-amber-300`,title:t(`backup.backupRunsPanel.stoppedBeforeCompletingEveryDestination`,`Stopped before completing every destination — not a success`),children:[c(N,{className:`h-3 w-3`}),t(`backup.backupRunsPanel.stopped`,`Stopped`)]})}}function Kt({run:e}){let{t}=K();if(e.state===`queued`)return c(`span`,{className:`text-foreground-subtle`,children:e.queuePosition===void 0?c(`span`,{className:`italic`,children:t(`backup.backupRunsPanel.waitingItsTurn`,`waiting its turn`)}):a(`span`,{className:`inline-flex items-center gap-1`,children:[c(`span`,{className:e.queuePosition===1?`rounded bg-primary/10 px-1.5 py-0.5 text-[10px] font-medium text-primary`:`rounded bg-foreground-subtle/10 px-1.5 py-0.5 text-[10px] font-medium`,children:Yt(e.queuePosition)}),t(`backup.backupRunsPanel.inLine`,`in line`)]})});if(e.state===`running`&&e.phase===`building`)return a(`span`,{className:`inline-flex items-center gap-1.5 text-foreground`,children:[c(P,{className:`h-3 w-3 text-primary`}),c(`span`,{className:`tabular-nums font-medium animate-pulse`,children:q(e.stagedBytes)}),c(`span`,{className:`text-foreground-subtle`,children:t(`backup.backupRunsPanel.stagedSoFar`,`staged so far`)})]});if(e.state===`running`){let n=e.archiveSizeBytes;return a(`span`,{className:`inline-flex items-center gap-1.5 text-foreground`,children:[c(M,{className:`h-3 w-3 text-primary`}),a(`span`,{className:`tabular-nums font-medium`,children:[q(e.uploadedBytes),n===void 0?``:` / ${q(n)}`]}),c(`span`,{className:`text-foreground-subtle`,children:t(`backup.backupRunsPanel.toCurrentDestination`,`to current destination`)})]})}let n=e.archiveSizeBytes??(e.stagedBytes>0?e.stagedBytes:void 0);return n===void 0?c(`span`,{className:`text-foreground-subtle italic`,children:`—`}):c(`span`,{className:`tabular-nums text-foreground`,children:t(`backup.runsPanel.archiveSize`,{size:q(n)})})}function qt({run:e}){let{t}=K(),n=e.destinationIds.length,r=e.completedDestinationIds.length,i=e.failedDestinationIds.length;return n===0?c(`span`,{className:`text-foreground-subtle italic`,children:t(`backup.backupRunsPanel.notResolvedYet`,`not resolved yet`)}):a(`div`,{className:`flex flex-col gap-0.5`,children:[c(`span`,{className:`text-foreground-subtle`,title:e.destinationIds.join(`, `),children:t(`backup.runsPanel.targets`,{count:n})}),a(`span`,{className:`inline-flex items-center gap-2 text-[10px]`,children:[r>0&&c(`span`,{className:`text-success`,title:t(`backup.backupRunsPanel.keptTheirArchive`,`Kept their archive: {{value1}}`,{value1:e.completedDestinationIds.join(`, `)}),children:t(`backup.runsPanel.completed`,{count:r})}),i>0&&c(`span`,{className:`text-danger`,title:t(`backup.backupRunsPanel.failed2`,`Failed: {{value1}}`,{value1:e.failedDestinationIds.join(`, `)}),children:t(`backup.runsPanel.failedCount`,{count:i})})]})]})}function Jt({run:e,now:t}){let{t:n}=K();return e.state===`queued`?c(`span`,{children:n(`backup.runsPanel.queuedAgo`,{elapsed:Xt(t-e.requestedAt)})}):e.startedAt===void 0?c(`span`,{children:`—`}):e.finishedAt===void 0?c(`span`,{children:n(`backup.runsPanel.runningFor`,{elapsed:Xt(t-e.startedAt)})}):a(`div`,{className:`flex flex-col gap-0.5`,children:[c(`span`,{children:Zt(e.finishedAt)}),c(`span`,{className:`text-[10px]`,children:n(`backup.runsPanel.took`,{elapsed:Xt(e.finishedAt-e.startedAt)})})]})}function Yt(e){if(e<=1)return`next`;let t=e%100;if(t>=11&&t<=13)return`${e}th`;switch(e%10){case 1:return`${e}st`;case 2:return`${e}nd`;case 3:return`${e}rd`;default:return`${e}th`}}function Xt(e){let t=Math.max(0,Math.floor(e/1e3));if(t<60)return`${t}s`;let n=Math.floor(t/60);return n<60?`${n}m ${String(t%60).padStart(2,`0`)}s`:`${Math.floor(n/60)}h ${String(n%60).padStart(2,`0`)}m`}function Zt(e){return new Date(e).toLocaleString(void 0,{day:`2-digit`,month:`short`,hour:`2-digit`,minute:`2-digit`})}e();var Qt=[[`backup`,`list`]];function $t({initialDestinationId:e,initialArchiveId:i,onClose:o,onScheduled:l}){let{t:u}=K(),d=s(),[p,m]=r(e&&i?2:1),[h,g]=r(e),[_,v]=r(i),[y,x]=r(new Set),[C,w]=r(``),{data:T}=W(),E=T??[],{data:O,isLoading:k}=Me({destinationId:h??``},{enabled:!!h}),A=O??[];t(()=>{if(h!==void 0)return;let e=E.filter(e=>e.restoreSupported);e.length===1&&g(e[0].id)},[h,E]);let{data:j}=Ce({destinationId:h??``,backupId:_??``},{enabled:!!h&&!!_}),M=n(()=>j?.locations??[],[j]);t(()=>{M.length!==0&&x(e=>e.size===0?new Set(M):e)},[M]);let N=je({onSuccess:()=>{d.invalidateQueries({queryKey:Qt}),l(),o()}}),P=e=>{x(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},F=A.find(e=>e.id===_),I=F?.encryption!==void 0,L=lt(F?.databases,j?.sqliteSnapshots),z=st(L),re=!!h&&!!_,ie=z||y.size>0,B=re&&ie&&!N.isPending&&(!I||C.trim().length>0),ae=()=>{!h||!_||N.mutate({destinationId:h,backupId:_,...z?{}:{locations:[...y]},...I?{backupSecretKey:C.trim()}:{}})};return c(ue,{open:!0,onOpenChange:e=>!e&&o(),children:a(te,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[a(ee,{children:[c(Te,{children:u(`backup.restoreWizard.restoreBackup`,`Restore Backup`)}),c(`p`,{className:`text-xs text-foreground-subtle`,children:u(`backup.restoreWizard.stepOf`,{step:p,name:p===1?u(`backup.restoreWizard.pickSource`,`pick source`):p===2?u(`backup.restoreWizard.pickLocations`,`pick locations`):u(`backup.restoreWizard.confirmStep`)})})]}),a(ne,{children:[p===1&&c(en,{destinations:E,destinationId:h,onPickDestination:e=>{g(e),v(void 0),x(new Set)},archives:A,archivesLoading:k,archiveId:_,onPickArchive:v}),p===2&&c(tn,{locations:M,picked:y,onToggle:P,databases:L,snapshotsOnly:z}),p===3&&c(nn,{destinationName:E.find(e=>e.id===h)?.displayName??h??``,archive:F,picked:[...y],databases:L,snapshotsOnly:z}),p===3&&F?.encryption!==void 0&&c(rn,{keyId:F.encryption.keyId,value:C,onChange:w}),p===3&&N.error&&c(`p`,{role:`alert`,className:`px-4 pb-2 text-xs text-danger`,children:N.error.message})]}),a(U,{className:`justify-between`,children:[c(`div`,{children:p>1&&a(R,{variant:`outline`,size:`sm`,onClick:()=>m(e=>e===3?2:1),children:[c(D,{className:`h-3 w-3`}),u(`common.back`,`Back`)]})}),a(`div`,{className:`flex items-center gap-2`,children:[c(R,{variant:`outline`,size:`sm`,onClick:o,children:u(`common.cancel`,`Cancel`)}),p<3?a(R,{size:`sm`,disabled:p===1&&!re||p===2&&!ie,onClick:()=>m(e=>e===1?2:3),children:[u(`common.next`,`Next`),c(f,{className:`h-3 w-3`})]}):a(R,{size:`sm`,onClick:ae,disabled:!B,children:[N.isPending?c(S,{className:`h-3.5 w-3.5 animate-spin`}):c(b,{className:`h-3.5 w-3.5`}),u(`backup.restoreWizard.scheduleRestore`,`Schedule Restore`)]})]})]})]})})}function en({destinations:e,destinationId:t,onPickDestination:n,archives:r,archivesLoading:i,archiveId:o,onPickArchive:s}){let{t:l}=K(),u=e.filter(e=>e.restoreSupported);return a(`div`,{className:`p-4 space-y-3`,children:[a(`div`,{className:`space-y-1.5`,children:[c(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:l(`backup.restoreWizard.destination`,`Destination`)}),c(ie,{value:t??``,onChange:e=>n(e.target.value),options:[{value:``,label:l(`backup.restoreWizard.selectDestination`,`Select destination…`)},...u.map(e=>({value:e.id,label:`${e.displayName} (${e.kind})`}))]})]}),a(`div`,{className:`space-y-1.5`,children:[c(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:l(`backup.restoreWizard.archive`,`Archive`)}),!t&&c(`div`,{className:`text-xs text-foreground-subtle italic`,children:l(`backup.restoreWizard.pickADestinationFirst`,`Pick a destination first.`)}),t&&i&&c(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:l(`backup.restoreWizard.readingArchives`,`Reading archives…`)}),t&&!i&&r.length===0&&c(`div`,{className:`text-xs text-foreground-subtle italic`,children:l(`backup.restoreWizard.noArchivesAvailableAtThis`,`No archives available at this destination.`)}),t&&r.length>0&&c(`div`,{className:`rounded border border-border bg-background divide-y divide-border max-h-64 overflow-y-auto`,children:r.map(e=>{let t=o===e.id;return a(`label`,{className:`flex items-center justify-between px-3 py-2 text-xs cursor-pointer ${t?`bg-primary/10`:`hover:bg-primary/5`}`,children:[a(`div`,{className:`flex items-center gap-2`,children:[c(`input`,{type:`radio`,name:`archive`,checked:t,onChange:()=>s(e.id),className:`accent-primary`}),a(`div`,{children:[a(`div`,{className:`flex items-center gap-1 font-medium text-foreground`,children:[e.encryption!==void 0&&c(E,{className:`h-3 w-3 text-success`,"aria-label":l(`backup.restoreWizard.encryptedKey`,`encrypted (key {{keyId}})`,{keyId:e.encryption.keyId})}),e.label??e.id]}),c(`div`,{className:`text-[10px] text-foreground-subtle`,children:new Date(e.createdAt).toLocaleString()}),c(`div`,{className:`pt-1`,children:c(Z,{databases:lt(e.databases,void 0)})})]})]}),c(`span`,{className:`text-[10px] text-foreground-subtle tabular-nums`,children:q(e.sizeBytes)})]},e.id)})})]})]})}function tn({locations:e,picked:t,onToggle:n,databases:r,snapshotsOnly:i}){let{t:o}=K();return i?a(`div`,{className:`space-y-3 p-4`,children:[a(`div`,{className:`space-y-1.5`,children:[c(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:o(`backup.restoreWizard.databasesInThisArchive`,`Databases in this archive`)}),c(Z,{databases:r})]}),c(`div`,{className:`rounded border border-info/30 bg-info/10 px-3 py-2 text-[11px] text-info`,children:o(`backup.restoreWizard.snapshotsOnlyRestoringThisArchive`,`Snapshots only: restoring this archive replaces just these databases. It does NOT touch configuration, addons, addon data or certificates.`)})]}):e.length===0?c(`div`,{className:`p-4`,children:c(`div`,{className:`text-xs text-foreground-subtle`,children:o(`backup.restoreWizard.loadingArchiveManifestIfThis`,`Loading archive manifest… If this persists, the archive may predate manifests — restoring will apply everything in the tarball.`)})}):a(`div`,{className:`p-4 space-y-3`,children:[a(`div`,{className:`space-y-1.5`,children:[c(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:o(`backup.restoreWizard.databasesInThisArchive`,`Databases in this archive`)}),c(Z,{databases:r})]}),c(`div`,{className:`rounded border border-warning/30 bg-warning/10 px-3 py-2 text-[11px] text-warning`,children:o(`backup.restoreWizard.selectedEntriesWillOverwriteLive`,`Selected entries will overwrite live data on the next server restart. Unchecked entries stay current.`)}),a(`div`,{className:`space-y-1.5`,children:[c(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:o(`common.apply`,`Apply`)}),c(`div`,{className:`rounded border border-border bg-background divide-y divide-border max-h-64 overflow-y-auto`,children:e.map(e=>a(`label`,{className:`flex items-center gap-2 px-3 py-2 text-xs hover:bg-primary/5 cursor-pointer`,children:[c(`input`,{type:`checkbox`,checked:t.has(e),onChange:()=>n(e),className:`accent-primary`}),c(`span`,{className:`font-mono text-foreground`,children:e}),c(`span`,{className:`ml-auto text-[10px] text-foreground-subtle`,children:on(e)})]},e))})]})]})}function nn({destinationName:e,archive:t,picked:n,databases:r,snapshotsOnly:i}){let{t:o}=K();return a(`div`,{className:`p-4 space-y-3 text-xs`,children:[c(`div`,{className:`rounded border border-warning/30 bg-warning/10 px-3 py-2 text-warning`,children:o(`backup.restoreWizard.restoreIsAppliedAtNext`,`Restore is applied at next server boot. Active connections will drop when you restart.`)}),a(`dl`,{className:`space-y-1.5`,children:[c($,{term:`Destination`,value:e}),c($,{term:`Archive`,value:t?.label??t?.id??`—`}),t&&c($,{term:`Created`,value:`${new Date(t.createdAt).toLocaleString()} · ${q(t.sizeBytes)}`}),c($,{term:`Databases`,value:r.map(e=>tt(e)).join(`, `)}),c($,{term:`Locations`,value:i?`none (configuration is not touched)`:n.length>0?n.join(`, `):`— (full archive)`})]})]})}function rn({keyId:e,value:t,onChange:n}){let{t:r}=K();return a(`div`,{className:`space-y-1.5 px-4 pb-3`,children:[c(`label`,{htmlFor:`restore-backup-key`,className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:r(`backup.restoreWizard.backupKey`,`Backup key`)}),c(`input`,{id:`restore-backup-key`,type:`password`,autoComplete:`off`,spellCheck:!1,value:t,onChange:e=>n(e.target.value),placeholder:r(`backup.restoreWizard.camstackBackupSecretV1`,`camstack-backup-secret-v1:…`),className:`w-full rounded border border-border bg-background px-2 py-1.5 font-mono text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`}),c(`p`,{className:`text-[11px] text-foreground-subtle`,children:c(Ie,{i18nKey:`backup.restoreWizard.encryptedTo`,values:{keyId:e},components:{mono:c(`span`,{className:`font-mono`})}})})]})}function $({term:e,value:t}){return a(`div`,{className:`flex justify-between gap-3`,children:[c(`dt`,{className:`text-foreground-subtle`,children:e}),c(`dd`,{className:`text-foreground font-mono text-right truncate`,children:t})]})}var an={db:`Database`,addons:`Addon configs`,"addons-data":`Addon data`,tls:`TLS certificates`,cache:`Cache`,data:`Top-level data`};function on(e){return an[e]??``}e();function sn(){let{t:e}=K(),n=V(),i=oe(),{state:o,openNew:s,openEdit:l,close:u}=B({editKey:`edit`,newKey:`new`}),d=ve(),f=d.data??[],[p,m]=r(null),[g,_]=r(!1),[v,y]=r(!1),[x,C]=r(!1),w=o.mode===`edit`?f.find(e=>e.id===o.id)??null:null;t(()=>{o.mode===`edit`&&!d.isLoading&&w===null&&u()},[o.mode,d.isLoading,w,u]);let E=o.mode===`new`||o.mode===`edit`&&w!==null,D=async()=>{await n({title:e(`system.backup.restartServerNow`,`Restart server now?`),message:e(`system.backup.activeConnectionsWillDropAnd`,`Active connections will drop and the apply-backup hook will run before boot.`),confirmLabel:e(`system.backup.restart`,`Restart`),variant:`warning`})&&i.mutate({confirm:!0})};return a(Re,{embedded:!0,children:[a(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,"data-testid":`backup-actions`,children:[a(R,{variant:`outline`,size:`sm`,type:`button`,onClick:()=>C(!0),"data-testid":`backup-now`,children:[c(T,{className:`h-3.5 w-3.5`}),e(`system.backup.backUpNow`,`Back up now`)]}),a(R,{variant:`outline`,size:`sm`,type:`button`,onClick:()=>_(!0),children:[c(b,{className:`h-3.5 w-3.5`}),e(`system.backup.restore`,`Restore…`)]}),a(R,{size:`sm`,type:`button`,onClick:s,"data-testid":`backup-new-entry`,children:[c(h,{className:`h-3.5 w-3.5`}),e(`system.backup.newEntry`,`New entry`)]})]}),v&&c(`div`,{className:`rounded-lg border border-warning/30 bg-warning/10 px-3 py-2.5 text-xs text-warning`,children:a(`div`,{className:`flex items-center justify-between gap-3`,children:[a(`div`,{className:`flex items-center gap-2`,children:[c(b,{className:`h-3.5 w-3.5`}),c(`span`,{children:e(`system.backup.restoreScheduledRestartTheServer`,`Restore scheduled. Restart the server to apply.`)})]}),a(R,{size:`sm`,variant:`outline`,type:`button`,onClick:()=>{D()},disabled:i.isPending,children:[i.isPending?c(S,{className:`h-3.5 w-3.5 animate-spin`}):c(b,{className:`h-3.5 w-3.5`}),e(`system.backup.restartNow`,`Restart Now`)]})]})}),c(At,{}),c(Ht,{}),c(gt,{onEdit:e=>l(e.id),onOpenRestoreWizard:e=>m(e)}),E&&c(Rt,{entry:w,onClose:u,onSaved:u}),x&&c(Et,{onClose:()=>C(!1)}),(p||g)&&c($t,{...p?{initialDestinationId:p.destinationId,initialArchiveId:p.archiveId}:{},onClose:()=>{m(null),_(!1)},onScheduled:()=>y(!0)})]})}function cn(){let{t:e}=K(),t=Fe(`/system/data`,{t:e,isAdmin:!0})??{icon:p,title:e(`system.data`,`Data`)};return c(Le,{icon:t.icon,title:t.title,defaultSection:`storage`,sectionsLabel:`${t.title} sections`,sections:[{id:`storage`,label:e(`systemPage.data.storage`,`Storage`),content:c(Ze,{})},{id:`backup`,label:e(`systemPage.data.backup`,`Backup`),content:c(sn,{})},{id:`deleted-devices`,label:e(`systemPage.data.deletedDevices`,`Deleted devices`),content:c(Xe,{})}]})}export{cn as DataPage};
|