@camstack/addon-admin-ui 1.2.461 → 1.2.463
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-CmEqgzfX.js → AddonAssetIcon-C9AdDz0x.js} +1 -1
- package/dist/assets/Addons-BPh7Eayh.js +4 -0
- package/dist/assets/{AdminPage-N36spL8r.js → AdminPage-Bly6H-Ei.js} +1 -1
- package/dist/assets/{AdminSectionedPage-B4DO1cch.js → AdminSectionedPage-DVGnfLgr.js} +1 -1
- package/dist/assets/{AiProfiles-Dm1A5qaJ.js → AiProfiles-XE0_l3jU.js} +1 -1
- package/dist/assets/{BrokerForm-BDBUNSWe.js → BrokerForm-XjXbfqrZ.js} +1 -1
- package/dist/assets/Build-D4NDTkw2.js +40 -0
- package/dist/assets/{Calendars-C4GvODYM.js → Calendars-CDSTKKMT.js} +1 -1
- package/dist/assets/{Cluster-CUaBA2On.js → Cluster-DKTNITYY.js} +1 -1
- package/dist/assets/CompositionEditor-BiWIw_xC.js +1 -0
- package/dist/assets/CompositionEditorPage-CRAPYt_u.js +1 -0
- package/dist/assets/{Data-B49CFnpf.js → Data-C-9OmLam.js} +2 -2
- package/dist/assets/DeviceDetail-CZ23_AX8.js +2 -0
- package/dist/assets/{DeviceDoActionFields-zsHf4EON.js → DeviceDoActionFields-C7VbUl2q.js} +1 -1
- package/dist/assets/{Devices-DHWIbLrr.js → Devices-CjR3mkUm.js} +1 -1
- package/dist/assets/{EmbedPlayerPage-C3Riyl8J.js → EmbedPlayerPage-DMVU4L2Z.js} +1 -1
- package/dist/assets/{History-g1qlGuSi.js → History-CCPlalru.js} +1 -1
- package/dist/assets/Identity-pegWB0x7.js +1 -0
- package/dist/assets/{IntegrationDetail-y7qRdb6V.js → IntegrationDetail-DakB5HuG.js} +1 -1
- package/dist/assets/{IntegrationHub-D4VoDe9W.js → IntegrationHub-Cl-yRdYk.js} +1 -1
- package/dist/assets/Integrations-D4JXGApt.js +1 -0
- package/dist/assets/Integrations-DRLVrdBM.js +1 -0
- package/dist/assets/{Library-BF596aV_.js → Library-Bzo29YWC.js} +1 -1
- package/dist/assets/{Locations-CWErnyPW.js → Locations-DyZCCP98.js} +1 -1
- package/dist/assets/{Logs-CQcRBcxc.js → Logs-B-7ptLpL.js} +1 -1
- package/dist/assets/{MaskShapeCanvas-CBe03CMO.js → MaskShapeCanvas-BmtOGyK5.js} +1 -1
- package/dist/assets/{MotionZonesSettings-Ci1jf-Mm.js → MotionZonesSettings-CV3Xgsr4.js} +1 -1
- package/dist/assets/MyAccess-B37DRC8C.js +2 -0
- package/dist/assets/{Network-CfC1bac2.js → Network-Du7T4f3O.js} +1 -1
- package/dist/assets/{NodeAddonsSettingsPanel-CxfoWry5.js → NodeAddonsSettingsPanel-BdXMzxN1.js} +1 -1
- package/dist/assets/Notifications-D31A_aMl.js +1 -0
- package/dist/assets/{Pipeline-D8nt-Y81.js → Pipeline-Bz5cI-qM.js} +1 -1
- package/dist/assets/{PrivacyMaskSettings-DSh1TEIJ.js → PrivacyMaskSettings-BPRo3O3B.js} +1 -1
- package/dist/assets/{Recordings-D2QgV6gh.js → Recordings-PbSzlND2.js} +1 -1
- package/dist/assets/{ScanNetworkModal-Ba_B2lf-.js → ScanNetworkModal-D7f9c95h.js} +1 -1
- package/dist/assets/{SceneMonitorEditor-Dn0NH3UY.js → SceneMonitorEditor-BA9763ix.js} +1 -1
- package/dist/assets/{SessionsList-Bik0vNoP.js → SessionsList-POtDsHqi.js} +2 -2
- package/dist/assets/{Showroom-BFwRdZBU.js → Showroom-DNy-w6tP.js} +1 -1
- package/dist/assets/{System-DSqTdlP0.js → System-B0A3Vybn.js} +1 -1
- package/dist/assets/{Terminal-DviYZMzd.js → Terminal-DAkEfEl7.js} +1 -1
- package/dist/assets/{Viewer-BqGWuKOT.js → Viewer-C2mhbwBs.js} +1 -1
- package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-C-OpByVg.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-BcUHsXvG.js} +1 -1
- package/dist/assets/{addon-icons-context-Dk7L05cY.js → addon-icons-context-BwHvrxKK.js} +1 -1
- package/dist/assets/{archive-S-zO_vQF.js → archive-D-CLwZIU.js} +1 -1
- package/dist/assets/{authed-media-Cpc0v-lW.js → authed-media-DdZ3AKzY.js} +1 -1
- package/dist/assets/{bell-off-B0BNkY5Q.js → bell-off-DkKnBqQi.js} +1 -1
- package/dist/assets/{board-model-BLL_cD-z.js → board-model-CGqWH_FA.js} +1 -1
- package/dist/assets/{boxes-B89A109J.js → boxes-BeinIpIz.js} +1 -1
- package/dist/assets/circle-slash-D94rdTZs.js +1 -0
- package/dist/assets/client-CJZuPHbz.js +358 -0
- package/dist/assets/{cloud-upload-EnqEFlW5.js → cloud-upload-CqA8Voyh.js} +1 -1
- package/dist/assets/crop-CJTlG5-P.js +1 -0
- package/dist/assets/{device-integration-icon-DpIPAgxb.js → device-integration-icon-CLpD5eef.js} +1 -1
- package/dist/assets/device-picker-model-BHInrZJO.js +1 -0
- package/dist/assets/{dist-CnH0kuMY.js → dist-Dmgqu93O.js} +1 -1
- package/dist/assets/dist-v3iXCHPG.js +358 -0
- package/dist/assets/{eraser-CTiJOqJH.js → eraser-B_CtxhBO.js} +1 -1
- package/dist/assets/{format-3n872UoD.js → format-C7c-WeCC.js} +1 -1
- package/dist/assets/{hard-drive-download-B-xmEXyG.js → hard-drive-download-BSXwOh9q.js} +1 -1
- package/dist/assets/{hostInit-CGuLmCP7.js → hostInit-W8TL-CCW.js} +1 -1
- package/dist/assets/i18n-CvoV4ITH.js +1 -0
- package/dist/assets/{icons-D1XGgPoq.js → icons-eXZhq5Wj.js} +1 -1
- package/dist/assets/{index-Av4-A8rY.js → index-DgzFfJ-E.js} +3 -3
- package/dist/assets/{index-DhkrLRVh.css → index-z_YJmgwP.css} +1 -1
- package/dist/assets/{key-BEqu-lXr.js → key-DojLc55s.js} +1 -1
- package/dist/assets/{key-round-Bx5_IMpS.js → key-round-BAehItCF.js} +1 -1
- package/dist/assets/{layers-Dl1ZfXjR.js → layers-DAJqwsng.js} +1 -1
- package/dist/assets/{linked-devices-model-7z16tmo3.js → linked-devices-model-B8q5duvG.js} +1 -1
- package/dist/assets/{list-ordered-Dgp6etRJ.js → list-ordered-BYVhOPoV.js} +1 -1
- package/dist/assets/{location-owned-usage-bGdU9_ER.js → location-owned-usage-BrB6XdyC.js} +1 -1
- package/dist/assets/{log-in-D8cVgea3.js → log-in-C1oX8GRe.js} +1 -1
- package/dist/assets/{memory-stick-9OcSMd1G.js → memory-stick-H0-1j4vS.js} +1 -1
- package/dist/assets/{message-square-plus-C4vA4iYJ.js → message-square-plus-Cu3mjwr6.js} +1 -1
- package/dist/assets/{mf-entry-bootstrap-0-6251002a.js → mf-entry-bootstrap-0-4d6817b1.js} +2 -2
- package/dist/assets/{mic-off-3EqpKDCs.js → mic-off-BZE0vpPb.js} +1 -1
- package/dist/assets/{monitor-off-BnrglR7J.js → monitor-off-CeoPVLdS.js} +1 -1
- package/dist/assets/{monitor-smartphone-CjzyjUlp.js → monitor-smartphone-X2sF7PZY.js} +1 -1
- package/dist/assets/mount-BHInrZJO.js +1 -0
- package/dist/assets/{player-overlays-C2qGnksg.js → player-overlays-D5ZBZ0eM.js} +1 -1
- package/dist/assets/{recycle-tvZPZI99.js → recycle-DLXIFr8U.js} +1 -1
- package/dist/assets/remoteEntry-BBh0_eO2.js +1 -0
- package/dist/assets/{scan-eye-6_8sPy1t.js → scan-eye-CvEU2c_X.js} +1 -1
- package/dist/assets/{scissors-BYLfeqTv.js → scissors-x6ajWh6r.js} +1 -1
- package/dist/assets/{search-x-CLjmzP4o.js → search-x-5Z0cDXke.js} +1 -1
- package/dist/assets/{send-CcDHb3r4.js → send-CQyb3VPM.js} +1 -1
- package/dist/assets/{settings-2-G-7M0you.js → settings-2-BrZJLOf8.js} +1 -1
- package/dist/assets/{speaker-CaxICJfu.js → speaker-BYU0CVCA.js} +1 -1
- package/dist/assets/{src-D1steZEF.js → src-El9yRQEE.js} +10 -10
- package/dist/assets/{step-inspector-model-p9HUQGve.js → step-inspector-model-Be_ULwEg.js} +1 -1
- package/dist/assets/{timer-reset-D0SmO8M1.js → timer-reset-DA0wUEff.js} +1 -1
- package/dist/assets/{ungroup-BjWmPSAJ.js → ungroup-FYon4fz1.js} +1 -1
- package/dist/assets/{unlink-8CYYb6J2.js → unlink-BCjfZGMX.js} +1 -1
- package/dist/assets/{usb-vxNmd1OO.js → usb-BBQDAd-3.js} +1 -1
- package/dist/assets/{use-scenes-feed-BepTQeVo.js → use-scenes-feed-B95-25e8.js} +1 -1
- package/dist/assets/{use-stationary-objects-Dnn6yNrY.js → use-stationary-objects-zVOdbaPk.js} +1 -1
- package/dist/assets/useEventInvalidation-BHInrZJO.js +1 -0
- package/dist/assets/{useNodeUrlSelection-i_Uu58Pu.js → useNodeUrlSelection-DTDVRQ9H.js} +1 -1
- package/dist/assets/user-round-qrIUAwAY.js +1 -0
- package/dist/assets/{user-x-_Ch_VgmF.js → user-x-DGH-0MS_.js} +1 -1
- package/dist/assets/{video-CnGFIENR.js → video-CQJAIcvp.js} +1 -1
- package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-sNr_TQNF.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-BDOG6ivJ.js} +2 -2
- package/dist/index.html +10 -10
- package/dist/server/addon.js +22 -3
- package/package.json +1 -1
- package/dist/assets/Addons-CVkkdf3V.js +0 -4
- package/dist/assets/Build-Btk8hgSX.js +0 -40
- package/dist/assets/CompositionEditor-Kq2kEnnh.js +0 -1
- package/dist/assets/CompositionEditorPage-D89-6PCw.js +0 -1
- package/dist/assets/DeviceDetail-BPyZ6uyd.js +0 -2
- package/dist/assets/Identity-DWlP85j-.js +0 -1
- package/dist/assets/Integrations-ByoGCmDg.js +0 -1
- package/dist/assets/Integrations-YNiehsXN.js +0 -1
- package/dist/assets/MyAccess-DUFCQyd0.js +0 -2
- package/dist/assets/Notifications-BqYoqEfY.js +0 -1
- package/dist/assets/circle-slash-DtOy5nTT.js +0 -1
- package/dist/assets/client-B741nZQJ.js +0 -358
- package/dist/assets/crop-BM88jjat.js +0 -1
- package/dist/assets/device-picker-model-BIknMBUl.js +0 -1
- package/dist/assets/dist-xq0sTO1C.js +0 -358
- package/dist/assets/i18n-SRLxy4I7.js +0 -1
- package/dist/assets/mount-BIknMBUl.js +0 -1
- package/dist/assets/remoteEntry-C-4WYf0M.js +0 -1
- package/dist/assets/useEventInvalidation-BIknMBUl.js +0 -1
- package/dist/assets/user-round-DD5YK-sO.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{$ as e,B as t,G as n,J as r,L as i,S as a,b as o,i as s,o as c,p as l,q as u,x as d}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 f,D as p,Fr as m,It as h,N as g,Nn as _,Nt as v,O as y,Or as b,T as x,V as S,Xn as C,Xr as w,Zt as T,_t as E,b as D,bn as ee,cn as O,dn as k,dt as A,ir as j,j as M,k as N,mn as P,or as te,ot as F,rr as I,sa as L,ta as R,ur as z,ut as B,v as V,xi as ne,xn as H,y as re,yi as U,z as W}from"./player-overlays-C2qGnksg.js";import{ar as ie,c as ae,cr as oe,dr as se,fa as ce,lr as le,or as ue,rr as de,s as fe,sr as pe,u as me,ur as he}from"./client-B741nZQJ.js";import{l as ge,t as _e,u as ve}from"./video-CnGFIENR.js";import{a as ye,i as be,n as xe,r as Se,t as Ce}from"./usb-vxNmd1OO.js";import{t as we}from"./crop-BM88jjat.js";import{t as Te}from"./layers-Dl1ZfXjR.js";import{n as Ee}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_trpc_mf_1_react_mf_2_query__loadShare__.js-DdJYWyu3.js";import{$c as De,$u as G,Bn as Oe,Ct as ke,Dc as Ae,Fc as je,Fr as K,Gu as Me,Hr as q,Ic as Ne,In as Pe,J as Fe,Jc as Ie,Jn as Le,Kn as Re,Ku as ze,Lc as Be,Ln as Ve,Mc as He,Nc as Ue,Nn as We,Nr as Ge,Nu as Ke,Oc as qe,Pn as Je,Q as Ye,Qc as Xe,Qr as Ze,Rc as Qe,Rn as $e,Ru as et,Sn as tt,St as nt,Tc as rt,Wt as it,X as at,Xc as ot,Y as st,Yc as ct,Yn as lt,Z as ut,Zc as dt,Zr as ft,Zt as pt,_c as mt,_n as ht,_r as gt,_t,an as vt,ar as yt,bn as bt,cc as xt,cr as St,ct as Ct,dc as wt,ed as Tt,et as Et,fc as Dt,gc as Ot,gn as kt,gr as At,hc as jt,ht as Mt,id as Nt,ir as Pt,jc as Ft,kc as It,lc as Lt,ln as Rt,mc as zt,mn as J,nd as Bt,nr as Vt,oc as Ht,or as Ut,pc as Wt,qc as Gt,r as Kt,rd as qt,rr as Jt,sc as Yt,sr as Xt,td as Zt,ti as Qt,tl as $t,to as en,tr as tn,wc as nn,xc as rn,xn as an,zc as on,zn as sn,zu as cn}from"./src-D1steZEF.js";import{t as Y}from"./i18n-SRLxy4I7.js";import{t as X}from"./useTranslation-D3Is_4B6.js";import{cr as ln,hr as un,mr as dn,yr as fn}from"./index-Av4-A8rY.js";import{_ as pn,a as mn,b as hn,c as gn,d as _n,f as vn,g as yn,h as bn,i as xn,l as Sn,m as Cn,n as wn,p as Tn,r as En,s as Dn,u as On,v as kn,y as An}from"./step-inspector-model-p9HUQGve.js";import"./useEventInvalidation-BIknMBUl.js";import{t as jn}from"./NodeAddonsSettingsPanel-CxfoWry5.js";import{a as Mn,c as Nn,d as Pn,g as Fn,h as In,i as Ln,l as Rn,n as zn,o as Bn,p as Vn,r as Hn,s as Un,t as Wn}from"./board-model-BLL_cD-z.js";e();function Gn(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 Kn(e){return e}function qn(e,t){for(let[n,r]of Object.entries(e??{}))if(n===t)return r}function Jn(e,t){return typeof e==`boolean`?e:Kn(t)}function Yn(e,t){return{pipeline:Jn(qn(e,`detect`),t),audio:Jn(qn(e,`audio`),t),ingest:Jn(qn(e,`ingest`),t)}}function Xn(e,t,n){let r=e?.find(e=>e.nodeId===t);return Yn(r?.settings,n)}function Zn({selectedNodeId:e,onSelect:t,refreshToken:n}){let r=L(),{t:i}=X(),{nodes:s}=Tt(),{data:c}=Ae(void 0),{data:l}=Ft(void 0),u=new Map;for(let e of c??[])u.set(e.agentNodeId,(u.get(e.agentNodeId)??0)+1);let f=s??[],p=f.filter(e=>e.isOnline).length,m=f.filter(e=>!e.isOnline).length;return a(`div`,{className:`flex flex-col h-full`,children:[a(`button`,{type:`button`,onClick:()=>t(Eo),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:[d(ge,{className:`h-4 w-4 flex-shrink-0`}),a(`div`,{className:`min-w-0 flex-1`,children:[d(`div`,{className:`text-xs font-semibold truncate`,children:i(`pipeline.nodeList.cluster`,`Cluster`)}),d(`div`,{className:`text-[10px] text-foreground-subtle`,children:i(`pipeline.nodeList.assignmentsLoadBalancingRoles`,`Assignments, load balancing, roles`)})]})]}),d(`div`,{className:`flex-1 overflow-y-auto`,children:f.map(n=>{let s=e===n.id,c=u.get(n.id)??0,f=n.isHub?k:w,p=Xn(l,n.id,n.isHub),m=n.isOnline?null:it(Gn(n.lastSeen),r);return a(`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 ${s?`bg-primary/10 text-primary`:`text-foreground hover:bg-surface-hover`}${n.isOnline?``:` opacity-60`}`,children:[d(f,{className:`h-4 w-4 flex-shrink-0`}),a(`div`,{className:`min-w-0 flex-1`,children:[a(`div`,{className:`flex items-center gap-2`,children:[d(`span`,{className:`text-xs font-semibold truncate`,children:n.name}),n.isHub&&d(`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&&d(`span`,{className:`h-1.5 w-1.5 rounded-full bg-danger flex-shrink-0`}),n.isOnline&&d(`span`,{className:`h-1.5 w-1.5 rounded-full bg-success flex-shrink-0`})]}),a(`div`,{className:`text-[10px] text-foreground-subtle flex items-center gap-2 mt-0.5`,children:[d(`span`,{children:i(`common.coresCount`,{count:n.cpuCores})}),d(`span`,{children:`•`}),a(`span`,{children:[Math.round(n.memoryMB/1024),` GB`]}),c>0&&a(o,{children:[d(`span`,{children:`•`}),a(`span`,{className:`inline-flex items-center gap-0.5 text-foreground`,children:[d(_e,{className:`h-2.5 w-2.5`}),c]})]}),!n.isOnline&&a(o,{children:[d(`span`,{children:`•`}),a(`span`,{className:`text-danger`,children:[i(`common.offline`),m===null?``:` · ${m}`]})]})]}),a(`div`,{className:`mt-0.5 flex items-center gap-1`,children:[d(q,{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`)}),d(q,{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)})}),a(`div`,{className:`px-4 py-2 border-t border-border text-[10px] text-foreground-subtle flex items-center justify-between`,children:[d(`span`,{children:i(`common.onlineCount`,{count:p})}),m>0&&d(`span`,{className:`text-danger`,children:i(`common.offlineCount`,{count:m})})]})]})}function Qn({nodeId:e,refreshToken:t}){let{t:n}=X(),{nodes:r}=Tt(),i=r?.find(t=>t.id===e),s=Zt(`pipeline.runner-load-snapshot`,t=>t.nodeId===e)?.load??null;return i?a(`div`,{className:`px-6 py-4 border-b border-border`,children:[a(`div`,{className:`flex items-center gap-2 mb-1`,children:[d(`h2`,{className:`text-base font-semibold text-foreground`,children:i.name}),i.isOnline?d(`span`,{className:`text-[10px] px-2 py-0.5 rounded-full bg-success/10 text-success`,children:n(`common.online`)}):d(`span`,{className:`text-[10px] px-2 py-0.5 rounded-full bg-danger/10 text-danger`,children:n(`common.offline`)}),i.isHub&&d(`span`,{className:`text-[9px] uppercase tracking-wider text-foreground-subtle border border-border rounded px-1 py-0.5`,children:n(`common.hubWord`)})]}),a(`div`,{className:`text-[11px] text-foreground-subtle flex items-center gap-2 flex-wrap`,children:[d(`span`,{children:i.cpuModel??`CPU`}),d(`span`,{children:`•`}),d(`span`,{children:n(`common.coresCount`,{count:i.cpuCores})}),d(`span`,{children:`•`}),a(`span`,{children:[Math.round(i.memoryMB/1024),` GB`]}),s&&a(o,{children:[d(`span`,{children:`•`}),d(`span`,{children:n(`pipeline.nodeDetailHeader.cameras`,{attached:s.attachedCameras,active:s.activeCameras})}),d(`span`,{children:`•`}),d(`span`,{children:n(`pipeline.nodeDetailHeader.avgInference`,{ms:s.avgInferenceTimeMs.toFixed(0)})}),d(`span`,{children:`•`}),d(`span`,{children:n(`pipeline.nodeDetailHeader.queue`,{depth:s.queueDepthTotal})}),s.hardware.hasGpu&&a(o,{children:[d(`span`,{children:`•`}),d(`span`,{className:`text-success`,children:`GPU`})]})]})]})]}):d(`div`,{className:`px-6 py-4 border-b border-border`,children:a(`div`,{className:`text-xs text-foreground-subtle`,children:[n(`pipeline.nodeDetailHeader.nodeNotFound`,`Node not found:`),` `,e]})})}var $n=[`assignments`,`tree`,`engines`,`logs`];function er({refreshToken:e,nodeId:t}){let{t:i}=X(),[o,s]=r(new Map),{nodes:c}=G();qt(`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}=mt(void 0),u=n(()=>{let e=new Map;for(let t of l??[])e.set(t.nodeId,t.deviceCount);return e},[l]),f=n(()=>{let e=new Map,t=Date.now()-3e4;for(let n of o.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},[o]),p=n(()=>{let e=new Map;for(let t of c)e.set(t.id,t.shortName);return e},[c]),m=n(()=>{let e=0,t=0,n=0,r=0,i=0;for(let a of f.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}},[f,c]);if(t){let e=f.get(t);return a(`div`,{className:`@container/liveload`,children:[d(`h3`,{className:`text-sm font-semibold text-foreground mb-2`,children:i(`pipeline.liveLoadPanel.liveLoad`,`Live load`)}),a(`div`,{className:`grid grid-cols-2 @md/liveload:grid-cols-3 @3xl/liveload:grid-cols-5 gap-2 mb-3`,children:[d(Z,{label:`FPS`,value:e?e.totalFps.toFixed(1):`—`}),d(Z,{label:i(`pipeline.liveLoadPanel.activeAttached`,`Active / Attached`),value:e?`${e.activeCameras}/${e.attachedCameras}`:`—`}),d(Z,{label:i(`pipeline.liveLoadPanel.avgInferMs`,`Avg infer ms`),value:e&&e.attachedCameras>0?(e.totalInferenceWeighted/e.attachedCameras).toFixed(0):`—`}),d(Z,{label:i(`pipeline.liveLoadPanel.queue`,`Queue`),value:e?String(e.queueDepth):`—`}),d(Z,{label:i(`pipeline.liveLoadPanel.audio`,`Audio`),value:String(u.get(t)??`—`)})]})]})}let h=[...f.entries()].toSorted(([e],[t])=>e===`hub`?-1:t===`hub`?1:e.localeCompare(t));return a(`div`,{className:`@container/liveload`,children:[d(`h3`,{className:`text-sm font-semibold text-foreground mb-2`,children:i(`pipeline.liveLoadPanel.liveLoad`,`Live load`)}),a(`div`,{className:`grid grid-cols-2 @md/liveload:grid-cols-3 @3xl/liveload:grid-cols-5 gap-2 sm:gap-3 mb-3`,children:[d(Z,{label:i(`pipeline.liveLoadPanel.totalAgents`,`Total agents`),value:`${m.onlineAgents}/${m.totalAgents}`}),d(Z,{label:i(`pipeline.liveLoadPanel.activeAttached`,`Active / Attached`),value:`${m.activeCameras}/${m.attachedCameras}`}),d(Z,{label:i(`pipeline.liveLoadPanel.totalFps`,`Total FPS`),value:m.totalFps.toFixed(1)}),d(Z,{label:i(`pipeline.liveLoadPanel.avgInferenceMs`,`Avg inference ms`),value:m.avgInferenceTimeMs.toFixed(0)}),d(Z,{label:i(`pipeline.liveLoadPanel.queueDepth`,`Queue depth`),value:String(m.queueDepth)})]}),d(`div`,{className:`rounded-lg border border-border overflow-x-auto`,children:a(`table`,{className:`w-full text-xs min-w-[480px]`,children:[d(`thead`,{className:`bg-surface`,children:a(`tr`,{className:`text-foreground-subtle text-[10px] uppercase tracking-wider`,children:[d(`th`,{className:`text-left px-3 py-2`,children:i(`pipeline.liveLoadPanel.agent`,`Agent`)}),d(`th`,{className:`text-right px-3 py-2`,children:`FPS`}),d(`th`,{className:`text-right px-3 py-2`,children:i(`pipeline.liveLoadPanel.cameras`,`Cameras`)}),d(`th`,{className:`text-right px-3 py-2`,children:i(`pipeline.liveLoadPanel.inferenceMs`,`Inference ms`)}),d(`th`,{className:`text-right px-3 py-2`,children:i(`pipeline.liveLoadPanel.queue`,`Queue`)}),d(`th`,{className:`text-right px-3 py-2`,children:i(`pipeline.liveLoadPanel.audio`,`Audio`)})]})}),a(`tbody`,{children:[h.map(([e,t])=>a(`tr`,{className:`border-t border-border`,children:[d(`td`,{className:`px-3 py-2 text-foreground font-medium`,children:p.get(e)??e}),d(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t.totalFps.toFixed(1)}),d(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t.attachedCameras}),d(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t.attachedCameras>0?(t.totalInferenceWeighted/t.attachedCameras).toFixed(0):`—`}),d(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t.queueDepth}),d(`td`,{className:`px-3 py-2 text-right text-foreground`,children:u.get(e)??`—`})]},e)),h.length===0&&d(`tr`,{children:d(`td`,{colSpan:6,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:i(`pipeline.liveLoadPanel.noCameraMetricsReceivedYet`,`No camera metrics received yet`)})})]})]})})]})}function Z({label:e,value:t}){return a(`div`,{className:`rounded-lg border border-border bg-surface/60 p-3`,children:[d(`div`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle mb-1`,children:e}),d(`div`,{className:`text-lg font-semibold text-foreground`,children:t})]})}var tr={active:!1,pinned:!1,nodeId:null,reason:``};function nr(e,t){return e.deviceName.localeCompare(t.deviceName)||e.deviceId-t.deviceId}function rr(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??``}:tr,o=n?{active:!0,pinned:n.pinned,nodeId:n.nodeId,reason:``}:tr;return{deviceId:e.id,deviceName:e.name,disabled:e.disabled===!0,pipeline:a,detection:a,decoder:tr,audio:o}}).toSorted(nr)}function ir(e,t,n){return{active:e!==null,pinned:t,nodeId:e,reason:n??``}}function ar(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:ir(t.detectionNodeId,t.pinned.detection,t.reasons.detection),decoder:ir(t.decoderNodeId,t.pinned.decoder,t.reasons.decoder),audio:ir(t.audioNodeId,t.pinned.audio,t.reasons.audio)}})}function or(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(nr)}function sr(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 cr(e){let t=new Map(e.map(e=>[e.id,e.name]));return e=>t.get(e)??Y.t(`helpers.assignmentRows.cameraFallback`,{id:e})}function lr(e,t,n){let r=[...new Set([...e.nodeId===null?[]:[e.nodeId],...t.map(e=>e.id)])];return[{value:`auto`,label:Y.t(`helpers.assignmentRows.auto`)},...r.map(e=>({value:e,label:Y.t(`helpers.assignmentRows.pinTo`,{node:n(e)})}))]}function ur({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 d(bt,{roleId:e,roleLabel:t,nodeName:r(o),colorId:tt(i,o),emphasized:s,pinned:n.pinned})}function dr({detection:e,decoder:t,audio:n,nameOf:r,colorByNodeId:i,emphasizeOnNodeId:o}){let s=(e,t,n)=>d(ur,{roleId:e,roleLabel:t,state:n,nameOf:r,colorByNodeId:i,emphasizeOnNodeId:o},e);return a(`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 fr({snap:e}){let t=L(),{t:n}=X();if(e===void 0)return d(`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:o,queueDepth:s,configuredFps:c,droppedFrames:l}=e.metrics,u=vt(r,t);return a(`div`,{className:`flex h-8 min-w-0 flex-col justify-center font-mono text-[10px] leading-tight tabular-nums`,children:[a(`span`,{className:`inline-flex min-w-0 items-center gap-1 ${u.textColor}`,children:[d(Ct,{phase:r,className:`h-2.5 w-2.5 shrink-0`}),d(`span`,{className:`truncate font-semibold uppercase tracking-wider`,children:u.label}),d(`span`,{className:`text-foreground`,children:i.toFixed(1)}),d(`span`,{className:`text-foreground-subtle`,children:n(`pipeline.assignmentStatusCell.configuredFps`,{fps:c.toFixed(0)})})]}),a(`span`,{className:`truncate text-foreground-subtle`,children:[d(`span`,{className:`text-foreground`,children:o.toFixed(0)}),` ms`,s>0&&a(`span`,{className:`ml-1 text-warning`,children:[`q`,s]}),d(`span`,{className:l>0?`ml-1 text-warning`:`ml-1`,children:n(`pipeline.assignmentStatusCell.drops`,{count:l})})]})]})}e();var pr=1e4,mr=5e3;function hr(e){let[n,i]=r(new Map);return qt(`pipeline.camera-metrics-snapshot`,t=>{let n=t.data;typeof n.deviceId==`number`&&(e!==void 0&&n.nodeId!==e||i(e=>new Map(e).set(n.deviceId,n)))}),t(()=>{if(n.size===0)return;let e=setInterval(()=>{i(e=>{let t=Date.now()-pr,n=[...e].filter(([,e])=>e.timestamp>=t);return n.length===e.size?e:new Map(n)})},mr);return()=>clearInterval(e)},[n.size]),n}var gr=3e5;function _r({state:e,onlineNodes:t,nameOf:n,pending:r,onChange:i}){let{t:a}=X();return d(Ke,{"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:[...lr(e,t,n)],onChange:e=>i(e.target.value)})}function vr({deviceId:e,nodeId:t}){let{t:n}=X(),r=c(),{data:i}=qe({deviceId:e},{refetchOnMount:`always`}),{data:a}=rt({nodeId:t},{staleTime:gr}),o=ct({onSuccess:()=>{r.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineDevicePin`]]})}});if(i===void 0||a===void 0)return d(`span`,{className:`text-[10px] italic text-foreground-subtle`,children:n(`assignments.placementControls.accelerator`,`accelerator: …`)});let s=a.devices??[],l=s.filter(e=>e.enabled),u=i?.deviceKey??`auto`,f=u!==`auto`&&!l.some(e=>e.key===u),p=s.find(e=>e.key===u),m=[{value:`auto`,label:n(`assignments.placementControls.anyAccelerator`,`Any accelerator`)},...f?[{value:u,label:n(`pipeline.placementControls.notEnabled`,{name:p?`${Le(p)} (${u})`:u})}]:[],...l.map(e=>({value:e.key,label:`${Le(e)} · ${e.format}`}))];return d(Ke,{"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})})}e();function yr(e){let t=u(null);return e.nodeId!==null&&(t.current=e),t.current}function br({deviceId:e,state:t,...n}){let{t:r}=X(),i=yr(t);return a(`div`,{className:`grid w-80 grid-cols-2 gap-1.5`,children:[d(_r,{state:t,...n}),i?.nodeId==null?d(Ke,{"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`)}]}):d(vr,{deviceId:e,nodeId:i.nodeId})]})}function xr({state:e,nameOf:t}){let{t:n}=X(),r=yr(e);if(r?.nodeId==null)return d(`span`,{className:`text-[11px] text-foreground-subtle`,children:n(`assignments.clusterRowCells.noSessionYet`,`— no session yet`)});let i=e.active&&e.nodeId!==null,o=r.pinned?`pinned`:`auto · ${r.reason||`capacity`}`;return a(`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:[a(`span`,{className:`flex min-w-0 items-center gap-1.5 text-xs`,children:[d(`span`,{"aria-hidden":!0,className:`h-1.5 w-1.5 shrink-0 rounded-full ${i?`bg-success`:`bg-foreground-subtle/40`}`}),d(`span`,{"data-testid":`resolved-placement-node`,className:`truncate font-medium ${i?`text-foreground`:`text-foreground-muted`}`,children:t(r.nodeId)})]}),d(`span`,{className:`truncate pl-3 text-[10px] ${r.pinned?`text-warning`:`text-foreground-subtle`}`,children:i?o:n(`assignments.clusterRowCells.idleLastSession`,`{{how}} · idle, last session`,{how:o})})]})}function Sr({deviceId:e,deviceName:t}){let{t:n}=X(),[i,s]=r(!1);return a(o,{children:[d(cn,{icon:H,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:()=>s(!0)}),d(Vt,{open:i,onOpenChange:s,children:a(Pt,{width:`lg`,scroll:`body`,placement:`sheet-on-mobile`,children:[d(Xt,{children:d(St,{children:n(`pipeline.clusterRowCells.brokersTitle`,{device:t})})}),d(Jt,{children:i&&d(tn,{widgetId:`stream-broker/stream-broker-panel`,host:`device-tab`,deviceId:e,instanceId:`pipeline-row/${e}`,config:{variant:`compact`}})})]})})]})}function Cr(e){return e.hasFreshMetrics?`active`:e.hasPipelineAssignment?`recently-active`:`inactive`}function wr(e,t){return t.size===0?!0:t.has(e)}var Tr=[{value:`active`,get label(){return Y.t(`helpers.cameraActivity.active`)}},{value:`recently-active`,get label(){return Y.t(`helpers.cameraActivity.recentlyActive`)}},{value:`inactive`,get label(){return Y.t(`helpers.cameraActivity.inactive`)}}];e();var Er=[`pipeline.camera-assigned`,`pipeline.camera-unassigned`,`pipeline.camera-updated`,`agent.online`,`agent.offline`];function Dr(e){for(let t of[`getPipelineAssignments`,`getAudioAssignments`,`getCameraStatuses`])e.invalidateQueries({queryKey:[[`pipelineOrchestrator`,t]]})}function Or(){let{t:e}=X(),t=c();Kt([`pipelineOrchestrator`,`getPipelineAssignments`],Er),Kt([`pipelineOrchestrator`,`getAudioAssignments`],Er),Kt([`pipelineOrchestrator`,`getCameraStatuses`],Er);let{data:i}=en({isCamera:!0,projection:`slim`}),{data:o}=Ae(void 0),{data:s}=Ot(void 0),{data:l}=rn({}),{data:u}=Ft(void 0),{nodes:f}=G(),p=hr(),m=n(()=>sr(f),[f]),h=n(()=>an(u),[u]),g=n(()=>f.filter(e=>e.isOnline).map(e=>({id:e.id,name:e.name})),[f]),_=n(()=>ar(rr((i??[]).map(e=>({id:e.id,name:e.name,disabled:e.disabled})),o??[],s??[]),l??[]),[i,o,s,l]),[v,y]=r(()=>new Set),b=n(()=>_.filter(e=>wr(Cr({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=()=>Dr(t),C=Dt({onSuccess:S}),w=De({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=>a(`div`,{className:`flex w-44 min-w-0 items-center gap-1.5`,children:[d(un,{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&&d(q,{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=>d(br,{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=>d(dr,{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=>d(xr,{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=>d(fr,{snap:p.get(e.deviceId)})},{key:`brokers`,header:``,align:`right`,width:`w-10`,notSortableReason:`An action`,render:e=>d(Sr,{deviceId:e.deviceId,deviceName:e.deviceName})}],ee=i===void 0?`Loading cameras…`:_.length===0?`No cameras`:`No cameras match this activity filter.`;return a(`div`,{className:`flex flex-col gap-2`,children:[d(`nav`,{"aria-label":e(`pipeline.cameraAssignmentsTable.filterByCameraActivity`,`Filter by camera activity`),"data-testid":`assignments-activity-filter`,children:d(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1.5`,children:Tr.map(e=>{let t=v.has(e.value);return d(`button`,{type:`button`,"aria-pressed":t,"data-testid":`assignments-activity-${e.value}`,className:ze(re,t?V:D),onClick:()=>x(e.value),children:e.label},e.value)})})}),d(kt,{columns:E,rows:b,rowKey:e=>e.deviceId,minWidthPx:920,maxBodyHeight:ht,emptyMessage:ee})]})}e();function kr({nodeId:e}){let{t}=X(),r=c();Kt([`pipelineOrchestrator`,`getCameraStatuses`],Er);let{data:i}=rn({}),{data:a}=Ft(void 0),{data:o}=en({isCamera:!0,projection:`slim`}),{nodes:s}=G(),l=hr(),u=n(()=>sr(s),[s]),f=n(()=>an(a),[a]),p=n(()=>or(e,i??[],cr((o??[]).map(e=>({id:e.id,name:e.name})))),[e,i,o]),m=s.filter(t=>t.isOnline&&t.id!==e),h=()=>Dr(r),g=Dt({onSuccess:h}),_=De({onSuccess:h}),v=wt({onSuccess:h}),y=Xe({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 d(kt,{columns:[{key:`camera`,header:t(`pipeline.nodeCameraAssignmentsTable.camera`,`Camera`),width:`w-44`,sortValue:e=>e.deviceName,render:e=>d(un,{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=>d(dr,{detection:t.detection,decoder:t.decoder,audio:t.audio,nameOf:u,colorByNodeId:f,emphasizeOnNodeId:e})},{key:`status`,header:t(`pipeline.nodeCameraAssignmentsTable.status`,`Status`),width:`w-40`,sortValue:e=>l.get(e.deviceId)?.metrics.actualFps??null,render:e=>d(fr,{snap:l.get(e.deviceId)})},{key:`actions`,header:``,align:`right`,width:`w-10`,notSortableReason:`Actions`,render:e=>d(_t,{items:b(e),title:t(`pipeline.nodeCameraAssignmentsTable.move`,`Move {{deviceName}}`,{deviceName:e.deviceName})})}],rows:p,rowKey:e=>e.deviceId,minWidthPx:560,maxBodyHeight:ht,emptyMessage:i===void 0?t(`pipeline.nodeCameraAssignmentsTable.loadingCameras`,`Loading cameras…`):t(`pipeline.nodeCameraAssignmentsTable.noCameraRunsOnThis`,`No camera runs on this node right now`)})}function Ar({nodeId:e,refreshToken:t}){let{t:n}=X(),{nodes:r}=G(),i=r.find(t=>t.id===e)?.name??e;return a(`div`,{className:`space-y-3 sm:space-y-4`,children:[d(er,{refreshToken:t,nodeId:e}),a(`div`,{className:`space-y-2`,children:[a(`div`,{children:[d(`h3`,{className:`text-sm font-semibold text-foreground`,children:n(`pipeline.nodeCamerasTab.camerasOn`,{node:i})}),d(`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.`)})]}),d(kr,{nodeId:e})]})]})}e();function jr(e,t){let n=Math.max(0,t-e),r=Math.floor(e/1e3),i=Math.floor(n/1e3);return Y.t(`pipeline.nodeEnginesTab.idleLeft`,{idle:r,left:i})}function Mr({nodeId:e,refreshToken:t}){let{t:r}=X(),i=c(),o=Ge(),s=Yt({onSettled:()=>{i.invalidateQueries({queryKey:[`pipelineExecutor`,`listLoadedEngines`]})}}),{data:l}=xt({nodeId:e}),u=Zt(`pipeline.engine-metrics-snapshot`,t=>t.nodeId===e)?.engines??l??null,f=u===null;Kt([`pipelineRunner`,`getLocalCameras`],[`pipeline.camera-assigned`,`pipeline.camera-unassigned`]);let{data:p}=$t({nodeId:e}),{values:m}=Bt(`pipeline.camera-metrics-snapshot`,e=>e.deviceId,t=>t.nodeId===e),g=n(()=>m.filter(e=>e.metrics.phase===`active`).length,[m]),_=t=>{let n=p??[];if(n.length===0){s.mutate({nodeId:e,engine:t,force:!1});return}(async()=>{await o({title:r(`pipeline.nodeEnginesTab.killEngine`,`Kill engine`),message:`${String(n.length)} camera(s) are dispatching through this engine. Killing it drops their in-flight work and forces a respawn on the next frame.`,confirmLabel:r(`pipeline.nodeEnginesTab.killEngine`,`Kill engine`),variant:`danger`})&&s.mutate({nodeId:e,engine:t,force:!0})})()};return a(`div`,{className:`space-y-6`,children:[a(`div`,{children:[d(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:r(`pipeline.nodeEnginesTab.inferenceEnginesOnThisNode`,`Inference engines on this node`)}),d(`p`,{className:`text-[11px] text-foreground-subtle`,children:r(`pipeline.nodeEnginesTab.summary`,{engines:(u??[]).length,cameras:(p??[]).length,active:g})})]}),d(`div`,{className:`rounded-lg border border-border overflow-x-auto`,children:a(`table`,{className:`w-full text-xs min-w-[640px]`,children:[d(`thead`,{className:`bg-surface`,children:a(`tr`,{className:`text-foreground-subtle text-[10px] uppercase tracking-wider`,children:[d(`th`,{className:`text-left px-3 py-2 whitespace-nowrap`,children:r(`pipeline.nodeEnginesTab.kind`,`Kind`)}),d(`th`,{className:`text-left px-3 py-2 whitespace-nowrap`,children:r(`pipeline.nodeEnginesTab.runtimeBackendDevice`,`Runtime / Backend / Device`)}),d(`th`,{className:`text-left px-3 py-2`,children:r(`pipeline.nodeEnginesTab.models`,`Models`)}),d(`th`,{className:`text-right px-3 py-2 whitespace-nowrap`,children:r(`pipeline.nodeEnginesTab.poolPid`,`Pool PID`)}),d(`th`,{className:`text-right px-3 py-2 whitespace-nowrap`,children:r(`pipeline.nodeEnginesTab.autoKill`,`Auto-kill`)}),d(`th`,{className:`text-right px-3 py-2 whitespace-nowrap`,children:r(`pipeline.nodeEnginesTab.inUse`,`In use`)}),d(`th`,{className:`w-20`})]})}),a(`tbody`,{children:[f&&d(`tr`,{children:d(`td`,{colSpan:7,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:r(`common.loading`,`Loading…`)})}),!f&&(u??[]).map(e=>{let t=e.kind===`device-pool`;return a(`tr`,{className:`border-t border-border ${t?`bg-primary/[0.05]`:``}`,children:[d(`td`,{className:`px-3 py-2`,children:a(`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:[d(t?Te:w,{className:`h-3 w-3`}),r(t?`pipeline.nodeEnginesTab.pool`:`pipeline.nodeEnginesTab.runtime`)]})}),d(`td`,{className:`px-3 py-2`,children:a(`span`,{className:`inline-flex items-center gap-1 text-[11px] text-sky-400`,children:[d(B,{className:`h-3 w-3`}),e.engine.runtime,`/`,e.engine.backend,e.engine.device?`/${e.engine.device}`:``,e.engine.format?` · ${e.engine.format}`:``]})}),d(`td`,{className:`px-3 py-2`,children:e.modelsLoaded.length===0?d(`span`,{className:`text-foreground-subtle text-[11px]`,children:`—`}):d(`div`,{className:`flex flex-wrap gap-1`,children:e.modelsLoaded.map(e=>d(`span`,{className:`inline-block rounded bg-surface px-1.5 py-0.5 text-[10px] font-mono text-foreground-subtle`,children:e},e))})}),d(`td`,{className:`px-3 py-2 text-right font-mono text-foreground`,children:e.poolPid??`—`}),d(`td`,{className:`px-3 py-2 text-right text-[11px]`,children:e.idleMs!==null&&e.idleTtlMs!==null?d(`span`,{className:`text-foreground-subtle`,children:jr(e.idleMs,e.idleTtlMs)}):d(`span`,{className:`text-foreground-subtle/50`,children:r(`common.never`)})}),d(`td`,{className:`px-3 py-2 text-right text-foreground`,children:(p??[]).length}),d(`td`,{className:`px-3 py-2 text-right`,children:t?d(`span`,{className:`text-[11px] text-foreground-subtle`,children:r(`common.auto`)}):a(K,{variant:`ghost`,size:`sm`,disabled:s.isPending,onClick:()=>_(e.engine),className:`text-danger hover:bg-danger/10 hover:text-danger`,children:[d(h,{className:`h-3.5 w-3.5`}),r(`pipeline.nodeEnginesTab.kill`,`Kill`)]})})]},e.engineKey)}),!f&&(u??[]).length===0&&d(`tr`,{children:d(`td`,{colSpan:7,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:r(`pipeline.nodeEnginesTab.noEnginesResidentTheFactory`,`No engines resident — the factory spins up on the first pipeline run.`)})})]})]})}),d(`div`,{className:`text-[10px] text-foreground-subtle leading-relaxed`,children:d(dn,{i18nKey:`pipeline.nodeEnginesTab.legend`,components:{strong:d(`strong`,{className:`text-foreground`})}})}),s.isError&&d(At,{message:r(`pipeline.nodeEnginesTab.killFailed`,{message:s.error instanceof Error?s.error.message:r(`common.unknownError`)})})]})}var Nr=`pipeline-runner`,Pr=200;function Fr({nodeId:e}){let{t}=X();return a(`div`,{className:`flex flex-col gap-3`,children:[a(`div`,{children:[d(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:t(`pipeline.nodeLogsTab.runnerLogs`,`Runner logs`)}),d(`p`,{className:`text-[11px] text-foreground-subtle`,children:t(`pipeline.nodeLogsTab.description`,{node:e})})]}),d(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:d(pt,{agentId:e,addonId:Nr,limit:Pr,maxHeight:`max-h-[calc(100vh-360px)]`,showScope:!0,showDeviceChip:!0,showFilters:!1,showSourceSelect:!0})})]})}e();function Ir({nodeId:e,title:t}){let r=L(),{t:i}=X(),{data:o}=ln(),{data:s}=Ae(void 0),c=n(()=>{let e=new Map;for(let t of o??[])e.set(t.id,t.name);return e},[o]),l=n(()=>{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=hr(e),f=n(()=>{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 f.length===0?a(`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`]}):a(`div`,{className:`rounded-md border border-border bg-surface px-3 py-2`,children:[a(`div`,{className:`flex items-center gap-2 mb-1.5`,children:[d(`span`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle`,children:t??i(`pipeline.cameraStatusStrip.cameras`,`Cameras`)}),d(`span`,{className:`text-[10px] text-foreground-subtle`,children:f.length})]}),d(`div`,{className:`flex flex-wrap gap-1.5`,children:f.map(e=>{let t=c.get(e.deviceId)??`#${e.deviceId}`,n=vt(e.metrics.phase,r);return a(`div`,{title:i(`pipeline.cameraStatusStrip.fpsMsInferQ`,`{{name}} · {{label}} · {{value3}} fps · {{value4}}ms infer · q={{queueDepth}}`,{name:t,label:n.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] ${n.badgeClass}`,children:[d(Ct,{phase:e.metrics.phase,className:`h-2.5 w-2.5`}),d(`span`,{className:`font-medium text-foreground/90 max-w-[220px] truncate`,children:t}),d(`span`,{className:`font-mono tabular-nums`,children:e.metrics.actualFps.toFixed(1)}),d(`span`,{className:`opacity-60`,children:i(`common.fpsWord`)})]},e.deviceId)})})]})}function Lr(e,t,n,r){let i=t===void 0?void 0:e.find(e=>e.key===t)?.steps?.[n]?.settings,a={...r?.[n],...i};return Object.keys(a).length>0?a:void 0}function Rr(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 zr=`pipeline-analytics`,Br=`face-gallery`,Vr=`pipeline-orchestrator`,Hr=`pipeline-runner`,Ur=`audio-analyzer`;function Wr(e){return[...ie.filter(t=>t.stepId===e).map(e=>pe(e.stepId)),...ue.filter(t=>t.stepId===e).map(e=>le(e.stepId,e.key))]}var Gr=`faces`,Kr=`semantic-search`,qr=`load-balancer`,Jr=`load`,Yr=[{id:Gr,get title(){return Y.t(`helpers.clusterSettingsSections.facesTitle`)},get hint(){return Y.t(`helpers.clusterSettingsSections.facesHint`)},panels:[{addonId:Vr,fieldKeys:Wr(`face-embedding`)},{addonId:zr,capability:Br}]},{id:Kr,get title(){return Y.t(`helpers.clusterSettingsSections.semanticTitle`)},get hint(){return Y.t(`helpers.clusterSettingsSections.semanticHint`)},panels:[{addonId:Vr,fieldKeys:Wr(`clip-embedding`)}]},{id:ae,get title(){return Y.t(`helpers.clusterSettingsSections.cropTitle`)},get hint(){return Y.t(`helpers.clusterSettingsSections.cropHint`)},panels:[{addonId:Vr,sectionIds:[ae]}]},{id:fe,get title(){return Y.t(`helpers.clusterSettingsSections.nativeTitle`)},get hint(){return Y.t(`helpers.clusterSettingsSections.nativeHint`)},panels:[{addonId:Vr,sectionIds:[fe]}]},{id:`runner-defaults`,get title(){return Y.t(`helpers.clusterSettingsSections.runnerTitle`)},get hint(){return Y.t(`helpers.clusterSettingsSections.runnerHint`)},panels:[{addonId:Hr,fieldScope:`cluster`},{addonId:Ur,fieldScope:`cluster`}]},{id:qr,get title(){return Y.t(`helpers.clusterSettingsSections.loadTitle`)},get hint(){return Y.t(`helpers.clusterSettingsSections.loadHint`)},panels:[{addonId:Vr,sectionIds:[Jr]}]},{id:`failover`,get title(){return Y.t(`helpers.clusterSettingsSections.failoverTitle`)},get hint(){return Y.t(`helpers.clusterSettingsSections.failoverHint`)},panels:[{addonId:Vr,sectionIds:[`failover`]}]}],Xr={"cluster-step-models":Gr};function Zr(e){return e===`clip-embedding`?Kr:Gr}var Qr=`ctab`,$r=`section`;function ei(e,t){let n=new URLSearchParams({view:`nodes`,node:Eo,[Qr]:e});return t!==void 0&&n.set($r,t),`/system/pipeline?${n.toString()}`}function ti(e){return ei(`settings`,Zr(e))}function ni(){return ei(`load-balancing`)}var ri=`pipeline-orchestrator`;function ii(e){return ie.find(t=>t.stepId===e)??null}function ai({step:e,engineFormat:t,runnableModelIds:n}){let{t:r}=X(),{data:i}=Ze({addonId:ri}),o=he(i??null)[e.stepId]??e.defaultModelId,s=e.options.find(e=>e.id===o)?.label??o,c=n.length>0&&!n.includes(o);return a(`div`,{className:`space-y-2 rounded-md border border-primary/30 bg-primary/5 px-3 py-2`,children:[a(`div`,{className:`flex flex-wrap items-center gap-2 text-xs`,children:[d(`span`,{className:`font-medium text-foreground`,children:e.label}),d(`span`,{className:`font-mono text-foreground`,children:s}),d(`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`)}),d(un,{to:ti(e.stepId),className:`ml-auto text-[11px] text-primary hover:underline`,children:r(`pipeline.clusterStepModel.changeInClusterSettings`,`Change in Cluster → Settings ›`)})]}),a(`p`,{className:W,children:[r(`pipeline.clusterStepModel.oneModelForEveryNode`,`One model for every node and camera:`),` `,r(`pipeline.clusterStepModel.indexNote`,{index:e.indexName})]}),c&&d(`p`,{className:`rounded border border-warning/40 bg-warning/10 px-2 py-1 text-[10px] leading-snug text-warning`,children:d(dn,{i18nKey:`pipeline.clusterStepModel.noBuild`,values:{engine:t,model:o,index:e.indexName},components:{b:d(`b`,{})}})})]})}var oi=`pipeline-orchestrator`;function si({addonId:e,highlightLabel:t}){let{t:n}=X(),r=oe(e),{data:i}=Ze({addonId:oi});if(r.length===0)return null;let o=se(i??null)[e]??{};return a(`section`,{className:`space-y-1.5 border-t border-border/60 pt-3`,"aria-label":n(`stepInspector.clusterOwnedSettings.clusterWideSettings`,`Cluster-wide settings`),children:[a(`div`,{className:`flex flex-wrap items-center gap-2`,children:[d(`h3`,{className:S,children:n(`stepInspector.clusterOwnedSettings.clusterWideSettings`,`Cluster-wide settings`)}),d(un,{to:ti(e),className:`ml-auto text-[11px] text-primary hover:underline`,children:n(`stepInspector.clusterOwnedSettings.editInClusterSettings`,`Edit in Cluster → Settings ›`)})]}),r.map(e=>a(`div`,{className:`${f} rounded px-2 ${t===e.label?`bg-primary/5 ring-1 ring-primary/40`:``}`,children:[d(`span`,{className:M,children:e.label}),d(`span`,{className:g,children:d(`span`,{className:`font-mono text-xs text-foreground`,children:String(o[e.key]??e.default)})})]},e.key)),d(`p`,{className:W,children:n(`stepInspector.clusterOwnedSettings.oneValueForEveryNode`,`One value for every node and camera — this step writes into a shared index.`)})]})}function ci({rows:e,hint:t}){let{t:n}=X();return a(`div`,{className:`space-y-1.5`,"data-testid":`effective-models`,children:[d(`ul`,{className:`divide-y divide-border rounded-md border border-border`,children:e.map(e=>a(`li`,{className:`${x} flex flex-wrap items-baseline gap-x-2 text-xs`,children:[d(`span`,{className:e.href===void 0?`min-w-0 flex-1 truncate text-foreground-muted`:`basis-full text-foreground-muted`,children:e.label}),d(`span`,{className:`font-mono text-foreground`,children:e.modelId??`—`}),d(`span`,{className:`text-[10px] text-foreground-subtle`,children:e.sourceLabel}),e.href!==void 0&&d(un,{to:e.href,className:`ml-auto text-[11px] text-primary hover:underline`,children:n(`stepInspector.effectiveModelSummary.changeOnAccelerator`)})]},e.id))}),d(`p`,{className:W,children:t??n(`stepInspector.effectiveModelSummary.toChangeAModelOpen`,`To change a model, open that accelerator's cell in the table.`)})]})}e();function li(e){return{agentNodeId:e.nodeId,nodeLabel:e.nodeLabel,engineLabel:e.device.format,deviceKey:e.deviceKey,deviceLabel:Le(e.device),detail:e.device.defaultModelId,disabled:e.disabled}}function ui({tree:e,searchRows:t,accelerators:o,cellState:s,stepBadge:c,disabledCount:l,showDisabled:f,onShowDisabledChange:p,dirty:m,onDiscard:h,summary:g,toolbar:_,label:v,renderDetail:y}){let{t:b}=X(),x=Ge(),S=Me(),{selection:C,open:w,close:T}=Cn(n(()=>mn(e).map(e=>e.node.addonId),[e]),n(()=>o.map(e=>e.id),[o])),[E,D]=r(``),[ee,O]=r(null),[k,j]=r(null),M=u(null),N=u(null),P=u(null),te=u(null),F=n(()=>st(t,E),[t,E]),I=n(()=>E.trim()===``?e:En(e,new Set(F.map(e=>e.addonId))),[e,F,E]),L=e=>F.find(t=>t.addonId===e)?.matchedField??null,R=n(()=>o.map(li),[o]),z=e=>o.find(t=>t.nodeId===e.agentNodeId&&t.deviceKey===e.deviceKey),B=o.find(e=>e.id===C.acceleratorId)??null,V=C.stepId!==null,ne=i(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]),H=()=>{requestAnimationFrame(()=>te.current?.focus())},re=(e,t,n=!1)=>{if(e===C.stepId&&(t?.id??null)===C.acceleratorId){n&&H();return}let r=()=>{O(L(e)),w({stepId:e,...t===void 0?{}:{acceleratorId:t.id}}),n&&H()};e===C.stepId?r():ne(r)},U=()=>{let e=C.stepId;ne(()=>{if(T(),e!==null){let t=B===null?null:ke({agentNodeId:B.nodeId,deviceKey:B.deviceKey});requestAnimationFrame(()=>M.current?.focusCell(e,t))}})},ie=e=>{if(e.key===`Enter`){let t=F[0];if(t===void 0)return;e.preventDefault(),re(t.addonId,void 0,!0)}else e.key===`Escape`&&D(``)},ae=S?d(Ye,{onClick:U}):d(cn,{icon:A,variant:`ghost`,size:`sm`,"aria-label":b(`common.close`,`Close`),onClick:U});return a(`div`,{ref:N,className:`space-y-2`,onKeyDown:e=>{let t=e.target instanceof HTMLElement&&e.target.dataset.r!==void 0;e.key===`/`&&t&&(e.preventDefault(),P.current?.focus()),e.key===`Escape`&&t&&V&&(e.preventDefault(),U())},children:[a(`div`,{className:`flex flex-wrap items-center gap-2 text-xs`,children:[d(`div`,{className:`min-w-0 basis-full sm:basis-auto`,children:g}),d(`input`,{ref:P,type:`search`,value:E,onChange:e=>D(e.target.value),onKeyDown:ie,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&&a(`label`,{className:`inline-flex items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[d(Je,{checked:f,onChange:e=>p(e.target.checked)}),b(`stepInspector.stepMatrixFrame.showDisabled`,{count:l})]}),_]}),C.staleStepId!==null&&d(`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})}),I.length===0?d(`p`,{className:`${W} rounded-md border border-dashed border-border px-3 py-4 text-center`,children:b(`stepInspector.stepMatrixFrame.noStepMatches`,{query:E})}):d(nt,{ref:M,tree:I,agents:R,label:v,getCellState:(e,t)=>{let n=z(t);return n===void 0?{kind:`na`}:s(e,n)},onCellClick:(e,t,n)=>re(e,z(t),n),onStepClick:(e,t)=>re(e,void 0,t),...c===void 0?{}:{stepBadge:c},selectedCell:V&&C.stepId!==null&&B!==null?{addonId:C.stepId,agentNodeId:B.nodeId,deviceKey:B.deviceKey}:null,fallbackNodeId:k,onFallbackNodeChange:j,reserveRightPx:V&&!S?432:0}),d(Et,{open:V,anchor:N,onClose:U,label:b(`stepInspector.stepMatrixFrame.stepSettings`,`Step settings`),children:C.stepId!==null&&y({stepId:C.stepId,accelerator:B,matchedField:ee,closeButton:ae,onEscape:U,headingRef:e=>{te.current=e}})})]})}e();function di(e){t(()=>{if(e===null)return;let t=document.getElementById(e);t===null||typeof t.scrollIntoView!=`function`||t.scrollIntoView({block:`center`,behavior:`smooth`})},[e])}e();function fi(e,t,n){return e.map(e=>{let r={...e.steps},i=r[t.stepId]??{},a=t.models[e.key],o=t.jumps[e.key],s=t.accelerator?.deviceKey===e.key?{...Object.fromEntries(Object.entries(i.settings??{}).filter(([e])=>!n(e))),...t.accelerator.settings}:i.settings,c=s!==void 0&&Object.keys(s).length>0?s:void 0,l=a===void 0?i.modelId:a??void 0,u=o===void 0?i.jumpDeviceKey:o||void 0,d={...l===void 0?{}:{modelId:l},...c===void 0?{}:{settings:c},...u===void 0?{}:{jumpDeviceKey:u}};return Object.keys(d).length>0?r[t.stepId]=d:delete r[t.stepId],{key:e.key,enabled:e.enabled,weight:e.weight,maxSessions:e.maxSessions,steps:r}})}function pi(e,t){return t===void 0?0:[...new Set([...Object.keys(e),...Object.keys(t)])].filter(n=>!me(e[n],t[n])).length}function mi(e,t,n,r){if(t===null)return 0;let i=Object.entries(t.models).filter(([n,r])=>(r??void 0)!==e.find(e=>e.key===n)?.steps?.[t.stepId]?.modelId).length,a=Object.entries(t.jumps).filter(([n,r])=>(r||void 0)!==e.find(e=>e.key===n)?.steps?.[t.stepId]?.jumpDeviceKey).length,o=pi(n,t.nodeSettings),s=t.accelerator===void 0?0:pi(r(t.accelerator.deviceKey),t.accelerator.settings);return i+a+o+s}function hi({nodeId:e,nodeName:t,toolbar:i}){let{t:s}=X(),l=c(),u=rt({nodeId:e},{refetchOnMount:`always`}),f=Ht({nodeId:e},{refetchOnMount:`always`}),p=jt({agentNodeId:e},{refetchOnMount:`always`}),m=p.data?.stepSettings,h=he(Ze({addonId:`pipeline-orchestrator`}).data??null),g=u.data?.devices??[],_=f.data??null,[v,y]=r(null),[b,x]=r(null),[C,w]=r(null),T=Qe({onSuccess:()=>{l.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getNodeInferenceDevices`]]})}}),E=Ie({onSuccess:()=>{l.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getAgentSettings`]]})}}),[D,ee]=r(!1),O=n(()=>_?Fe(_):[],[_]),k=n(()=>mn(O),[O]),[A,j]=r(!1),M=n(()=>Dn(e,t,g,A),[e,t,g,A]),N=n(()=>Dn(e,t,g),[e,t,g]),P=N.length>=2,te=(e,t)=>Lr(g,t?.deviceKey,e,m)??{},F=e=>m?.[e]??{},I=(e,t)=>g.find(e=>e.key===t)?.steps?.[e]?.settings??{},L=(e,t,n)=>{let r=n??t.device.steps?.[e?.id??``]?.jumpDeviceKey;if(r!==void 0&&r!==``)return N.find(e=>e.deviceKey===r);if(!Sn(e,t))return N.filter(n=>n.id!==t.id&&Sn(e,n)).toSorted((e,t)=>e.deviceKey.localeCompare(t.deviceKey))[0]},R=(e,t)=>{let n=xn(_,e),r=ii(e),i=gn(_,t),a=te(e,t),o=L(n,t);return wn({addon:n,acc:t,gatedOn:n?.enabledByDefault??!0,model:n?vn(n,t,{nodePin:t.device.steps?.[e]?.modelId}):{modelId:void 0,source:`default`},...Tn(e,a,i)&&i?{rootName:i.name}:{},...r?{clusterModelId:h[e]??r.defaultModelId}:{},...o?{jumpTo:lt(o.device)}:{}})},z=k.map(({node:e})=>({addonId:e.addonId,name:e.addonName,fieldLabels:_n(xn(_,e.addonId))}));if(u.isLoading||f.isLoading||p.isLoading)return d(`div`,{className:`animate-pulse p-4 text-xs text-foreground-subtle`,children:s(`stepInspector.nodeStepInspector.loadingPipeline`,`Loading pipeline…`)});if(_===null)return d(`div`,{className:`p-4 text-xs text-foreground-subtle`,children:s(`stepInspector.nodeStepInspector.catalogUnavailable`,`Catalog unavailable.`)});let B=a(`span`,{className:W,children:[s(`stepInspector.nodeStepInspector.accelerators`,`Accelerators:`),` `,d(`span`,{className:`text-foreground`,children:N.length>0?N.map(e=>lt(e.device)).join(` · `):s(`stepInspector.nodeStepInspector.noneEnabled`,`none enabled`)}),g.some(e=>!e.enabled)&&a(o,{children:[` `,s(`stepInspector.nodeStepInspector.off`,`— off:`),` `,g.filter(e=>!e.enabled).map(lt).join(`, `)]}),` `,`·`,` `,d(un,{to:ni(),className:`text-primary hover:underline`,children:s(`stepInspector.nodeStepInspector.clusterLoadBalancing`,`Cluster → Load balancing ›`)})]});return d(ui,{tree:O,searchRows:z,accelerators:M,cellState:R,disabledCount:g.filter(e=>!e.enabled).length,showDisabled:A,onShowDisabledChange:j,dirty:v!==null&&mi(g,v,F(v.stepId),e=>I(v.stepId,e))>0,onDiscard:()=>y(null),summary:B,...i===void 0?{}:{toolbar:i},label:s(`stepInspector.nodeStepInspector.detectionSteps`,`Detection steps`),renderDetail:({stepId:n,accelerator:r,matchedField:i,closeButton:c,onEscape:l,headingRef:u})=>{let f=xn(_,n);if(f===null)return d(`div`,{className:`p-4 text-xs text-foreground-subtle`,children:s(`stepInspector.nodeStepInspector.noStepSelected`,`No step selected.`)});let p=v?.stepId===n?v:null,m=r??N[0]??M[0],h=p?.nodeSettings??F(n),O=r===null?{}:p?.accelerator?.deviceKey===r.deviceKey?p.accelerator.settings:I(n,r.deviceKey),k={...h,...O},A=mi(g,p,F(n),e=>I(n,e)),j=e=>{w(null),y(t=>({...t?.stepId===n?t:{stepId:n,models:{},jumps:{}},...e}))},R=ii(n),z=$e(f),{nodeFields:B,acceleratorFields:V}=On(z),ne=new Set(V.flatMap(e=>`key`in e?[e.key,`${e.key}ModelId`]:[])),H=m===void 0?void 0:gn(_,m),re=e=>{let t=p?.models[e.deviceKey];return t===void 0?e.device.steps?.[n]?.modelId:t??void 0},U=m===void 0?void 0:vn(f,m,{nodePin:re(m)}).modelId,ie=e=>{let t=re(e),i=vn(f,e,{nodePin:t}),c=gn(_,e),l=Tn(n,r?.id===e.id?k:te(n,e),c),u=p?.jumps[e.deviceKey],m=L(f,e,u),h=Sn(f,e)?l&&c?d(Pe,{rootModel:c,stepModelId:i.modelId}):void 0:a(o,{children:[s(`stepInspector.nodeStepInspector.noBuild`,{format:e.device.format}),` `,m?s(`stepInspector.nodeStepInspector.itRunsOnInstead`,`It runs on {{shortLabel}} instead.`,{shortLabel:m.shortLabel}):s(`stepInspector.nodeStepInspector.itDoesNotRunHere`,`It does not run here.`)]}),g=P?a(`label`,{className:`block space-y-1`,children:[d(`span`,{className:`text-[11px] font-medium text-foreground`,children:s(`stepInspector.nodeStepInspector.runOn`,`Run on`)}),d(Ke,{"aria-label":s(`stepInspector.nodeStepInspector.runOn`,`Run on`),value:u??e.device.steps?.[n]?.jumpDeviceKey??``,options:[{value:``,label:s(`stepInspector.nodeStepInspector.autoThisAcceleratorOrThe`,`Auto (this accelerator, or the next one that can run it)`)},...N.filter(t=>t.id!==e.id).map(e=>({value:e.deviceKey,label:`${e.label} · ${e.device.format}`}))],onChange:t=>j({jumps:{...p?.jumps,[e.deviceKey]:t.target.value}})}),d(`span`,{className:W,children:s(`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:i.modelId,source:i.source===`node`?`node`:`default`,sourceLabel:i.source===`node`?`node pin`:`hardware default`,models:Re(f.models??[],e.device.format),defaultModelId:f.defaultModelIdByFormat?.[e.device.format]??f.defaultModelId,expanded:b===e.id,onToggle:()=>x(t=>t===e.id?null:e.id),onChangeModel:t=>j({models:{...p?.models,[e.deviceKey]:t}}),...t===void 0?{}:{onReset:()=>j({models:{...p?.models,[e.deviceKey]:null}}),resetLabel:`Reset to hardware default`},...h===void 0?{}:{note:h},...g===void 0?{}:{extra:g},changed:p?.models[e.deviceKey]!==void 0||u!==void 0}},ae=async()=>{if(p!==null){ee(!0);try{(Object.keys(p.models).length>0||Object.keys(p.jumps).length>0||p.accelerator!==void 0)&&await T.mutateAsync({agentNodeId:e,inferenceDevices:Rr(fi(g,p,e=>ne.has(e)))}),p.nodeSettings!==void 0&&pi(F(n),p.nodeSettings)>0&&await E.mutateAsync({agentNodeId:e,addonId:n,settings:Object.keys(p.nodeSettings).length>0?{...p.nodeSettings}:null}),y(null),w({kind:`saved`})}catch(e){w({kind:`error`,error:e instanceof Error?e.message:String(e)})}finally{ee(!1)}}};return d(ut,{ref:u,title:r===null?`${f.name} · ${t}`:`${f.name} · ${r.label}`,subtitle:r===null?s(`stepInspector.nodeStepInspector.everyAcceleratorOf`,`{{slot}} · every accelerator of {{nodeName}}`,{slot:f.slot,nodeName:t}):s(`stepInspector.nodeStepInspector.baseForEveryCameraThat`,`{{slot}} · {{format}} · base for every camera that lands here`,{slot:f.slot,format:r.device.format}),leading:c,onEscape:l,saveBar:{dirtyCount:A,saving:D,status:C?.kind??null,...C?.error===void 0?{}:{error:C.error},onSave:()=>void ae(),onDiscard:()=>y(null)},children:a(`div`,{className:`space-y-3`,children:[a(`section`,{className:`space-y-2`,"aria-label":s(`stepInspector.nodeStepInspector.model`,`Model`),children:[d(`h3`,{className:S,children:s(`stepInspector.nodeStepInspector.model`,`Model`)}),R!==null&&m!==void 0?d(ai,{step:R,engineFormat:m.device.format,runnableModelIds:Re(f.models??[],m.device.format).map(e=>e.id)}):M.length===0?d(`p`,{className:W,children:d(dn,{i18nKey:`stepInspector.nodeStepInspector.noAcceleratorEnabled`,components:{link:d(un,{to:ni(),className:`text-primary hover:underline`})}})}):r===null?d(ci,{rows:M.map(e=>{let t=vn(f,e,{nodePin:re(e)});return{id:e.id,label:e.label,modelId:t.modelId,sourceLabel:t.source===`node`?`node pin`:`hardware default`}})}):d(at,{...ie(r)},r.id)]}),(z.length>0||H!==void 0)&&R===null&&a(`section`,{"aria-label":s(`stepInspector.nodeStepInspector.settings`,`Settings`),className:`space-y-2 border-t border-border/60 pt-2`,children:[d(`p`,{className:`text-[10px] text-foreground-subtle`,"data-testid":`settings-scope`,children:s(`stepInspector.nodeStepInspector.nodeWideSettings`,{node:t})}),(B.length>0||H!==void 0)&&d(gi,{addon:f,fields:B,settings:h,layerLabel:s(`stepInspector.nodeStepInspector.nodeLayer`,`Node`),modelId:Ve(f,U,k,H),root:H,highlight:i,onChange:e=>j({nodeSettings:e})}),V.length>0&&(r===null?d(`p`,{className:`text-[10px] text-foreground-subtle`,"data-testid":`accelerator-settings-hint`,children:s(`stepInspector.nodeStepInspector.thresholdsPerAccelerator`,`Confidence thresholds belong to the model, so they are set per accelerator: open that accelerator's cell.`)}):a(`div`,{className:`space-y-1 border-t border-border/60 pt-2`,children:[d(`p`,{className:`text-[10px] text-foreground-subtle`,"data-testid":`accelerator-settings-scope`,children:s(`stepInspector.nodeStepInspector.acceleratorSettings`,{accelerator:r.label})}),d(gi,{addon:f,fields:V,settings:O,layerLabel:s(`stepInspector.nodeStepInspector.acceleratorLayer`,`This accelerator`),modelId:Ve(f,U,k,H),root:void 0,highlight:i,onChange:e=>j({accelerator:{deviceKey:r.deviceKey,settings:e}})})]}))]}),d(si,{addonId:n,highlightLabel:i})]})})}})}function gi({addon:e,fields:t,settings:n,layerLabel:r,modelId:i,root:a,highlight:o,onChange:s}){let c=t.find(e=>`label`in e&&e.label===o)?.key??null;return di(c===null?null:Oe(c)),d(sn,{addon:e,fields:t,layers:{node:n},target:`node`,labels:{node:r},modelId:i,...a===void 0?{}:{rootModel:a},highlightKey:c,onChangeLayer:s})}e();function _i({nodeId:e,refreshToken:t}){let{t:n}=X(),i=Ge(),[s,c]=r(null),{nodes:l}=G(),u=l.find(t=>t.id===e)?.name??e,f=je({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 i({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),f.mutate({agentNodeId:e}))};return a(`div`,{className:`space-y-2`,children:[d(Ir,{nodeId:e}),d(hi,{nodeId:e,nodeName:u,toolbar:a(o,{children:[s&&d(`span`,{className:`text-[11px] text-success`,children:s}),f.isError&&d(`span`,{className:`text-[11px] text-danger`,children:f.error instanceof Error?f.error.message:n(`pipeline.nodePipelineTab.resetFailed`,`Reset failed`)}),d(K,{variant:`outline`,size:`sm`,onClick:()=>{p()},disabled:f.isPending,title:n(`pipeline.nodePipelineTab.clearThisNodeSPer`,`Clear this node's per-device model defaults + per-camera overrides scoped to this node`),children:f.isPending?n(`pipeline.nodePipelineTab.resetting`,`Resetting…`):n(`pipeline.nodePipelineTab.resetToDefault`,`Reset to default`)})]})})]})}var vi=[`detection-pipeline`,`audio-analyzer`,`pipeline-runner`],yi=`decoder-nodeav`,bi=`ntab`,xi={decoder:`engine`},Si={engine:`Engine & decoder`},Ci=`Nothing here is set per node. Cluster-wide values are on Cluster → Settings.`;function wi({nodeId:e,refreshToken:t}){let{t:n}=X(),[r,i]=fn(),{nodes:o}=G(),s=o.find(t=>t.id===e)?.addons.find(e=>e.capabilities.includes(`decoder`))?.addonId??yi,c=[...vi,s],l=r.get(bi),u={assignments:{id:`assignments`,label:n(`pipeline.nodeDetail.assignments`,`Assignments`),order:-10,content:d(Ar,{nodeId:e,refreshToken:t})},tree:{id:`tree`,label:n(`pipeline.nodeDetail.pipeline`,`Pipeline`),order:39,content:d(_i,{nodeId:e,refreshToken:t})},engines:{id:`engines`,label:n(`pipeline.nodeDetail.warmInstances`,`Warm instances`),order:180,content:d(Mr,{nodeId:e,refreshToken:t})},logs:{id:`logs`,label:n(`pipeline.nodeDetail.logs`,`Logs`),order:300,content:d(Fr,{nodeId:e})}},f=$n.map(e=>u[e]);return a(`div`,{className:`flex flex-col h-full`,children:[d(Qn,{nodeId:e,refreshToken:t}),d(`div`,{className:`flex-1 min-h-0 overflow-y-auto p-4 sm:p-6`,children:d(jn,{nodeId:e,addonIds:c,level:`global`,fieldScope:`perNode`,emptyMessage:Ci,tabAliases:xi,tabLabelOverrides:Si,extraTabs:f,activeTab:l===null?null:xi[l]??l,onActiveTabChange:e=>i(t=>{let n=new URLSearchParams(t);n.set(bi,e);for(let e of hn)n.delete(e);return n},{replace:!0})})})]})}function Ti(){let{t:e}=X();return a(`div`,{className:`space-y-2`,children:[a(`div`,{className:`min-w-0`,children:[d(`h3`,{className:`text-sm font-semibold text-foreground`,children:e(`pipeline.clusterAssignmentsTab.cameraPlacement`,`Camera placement`)}),d(`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.`)})]}),d(Or,{})]})}function Ei(e){return`${Math.round(e*100)}%`}function Di(e){return Y.t(`helpers.autoTuneViewModel.sessions`,{count:e})}var Oi={"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`},ki={"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 Ai(e){return e===null?`—`:Oi[e]??e}function ji(e){return e===null?`—`:ki[e]??e}function Mi(e){switch(e.kind){case`capacity`:return Y.t(`helpers.autoTuneViewModel.capacity`,{sessions:Di(e.sessions),min:e.minSessions});case`tie-faster`:return Y.t(`helpers.autoTuneViewModel.tieFaster`,{over:e.over,recall:Ei(e.recallDelta)});case`stepped-down`:return Y.t(`helpers.autoTuneViewModel.steppedDown`,{from:e.from,limitedBy:e.limitedBy,to:e.to});case`no-fit-lightest`:return Y.t(`helpers.autoTuneViewModel.noFitLightest`,{min:Di(e.minSessions),sessions:Di(e.sessions)});case`derived-latency`:return Y.t(`helpers.autoTuneViewModel.derivedLatency`,{modelId:e.modelId});case`cpu-device`:return Y.t(`helpers.autoTuneViewModel.cpuDevice`);case`device-disabled`:return Y.t(`helpers.autoTuneViewModel.deviceDisabled`);case`device-unavailable`:return Y.t(`helpers.autoTuneViewModel.deviceUnavailable`);case`node-offline`:return Y.t(`helpers.autoTuneViewModel.nodeOffline`);case`no-hardware-facts`:return Y.t(`helpers.autoTuneViewModel.noHardwareFacts`);case`no-measured-data`:return Y.t(`helpers.autoTuneViewModel.noMeasuredData`);case`no-family-build`:return Y.t(`helpers.autoTuneViewModel.noFamilyBuild`,{format:e.format});case`kept-custom-pin`:return Y.t(`helpers.autoTuneViewModel.keptCustomPin`,{modelId:e.modelId,deviceKey:e.deviceKey})}}function Ni(e,t){switch(e.kind){case`custom-pin-kept`:return Y.t(`helpers.autoTuneViewModel.customPinNode`,{node:t(e.nodeId),modelId:e.modelId,deviceKey:e.deviceKey});case`custom-registry-unreadable`:return Y.t(`helpers.autoTuneViewModel.customRegistryUnreadable`,{error:e.error})}}function Pi(e){return{modelChanges:e.nodeChanges.reduce((e,t)=>e+t.modelPins.length,0),thresholdClears:e.nodeChanges.reduce((e,t)=>e+t.thresholds.length,0)}}function Fi(e){let t=Pi(e);return t.modelChanges+t.thresholdClears===0}function Ii(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 Li(e,t){return e?.kind===`node-benchmark`?Y.t(`helpers.autoTuneViewModel.latencyMeasured`,{date:new Date(e.measuredAtMs).toLocaleDateString(t,{day:`numeric`,month:`short`})}):e?.kind===`estimated`?Y.t(`helpers.autoTuneViewModel.latencyEstimated`,{hardware:ji(e.estimatedFrom)}):Y.t(`helpers.autoTuneViewModel.latencyTable`)}e();var Ri=[.3,.4,.5];function zi(e){return Ri.some(t=>t===e)}var Bi=[1,2,3,4,6,8];function Vi({plan:e,node:t,nodeName:n}){let{t:r}=X();return a(`section`,{className:y,"data-testid":`auto-tune-node-${t.nodeId}`,children:[a(`header`,{className:`${N} flex flex-wrap items-center gap-2`,children:[d(w,{className:`h-3.5 w-3.5 shrink-0 text-foreground-subtle`,"aria-hidden":!0}),d(`h3`,{className:`${S} min-w-0 flex-1`,children:n(t.nodeId)}),a(`span`,{className:`text-[11px] text-foreground-subtle`,children:[ji(t.hardwareClass),t.cpuModel===null?``:` · ${t.cpuModel}`]}),t.skipped?d(q,{variant:`warning`,children:r(`pipeline.clusterAutoTuneTab.notChanged`,`Not changed`)}):t.acceleratorModelId!==null&&d(q,{variant:`info`,children:t.acceleratorModelId})]}),t.reasons.length>0&&d(`ul`,{className:`px-3 pt-2 text-[11px] text-foreground-muted`,children:t.reasons.map((e,t)=>d(`li`,{children:Mi(e)},t))}),d(`div`,{className:`overflow-x-auto`,children:a(`table`,{className:`w-full text-xs`,children:[d(`thead`,{children:a(`tr`,{className:`text-left text-[11px] text-foreground-subtle`,children:[d(`th`,{className:`px-3 py-1.5 font-medium`,children:r(`pipeline.clusterAutoTuneTab.device`,`Device`)}),d(`th`,{className:`px-3 py-1.5 font-medium`,children:r(`pipeline.clusterAutoTuneTab.capacity`,`Capacity`)}),d(`th`,{className:`px-3 py-1.5 font-medium`,children:r(`pipeline.clusterAutoTuneTab.detector`,`Detector`)}),d(`th`,{className:`px-3 py-1.5 font-medium`,children:r(`pipeline.clusterAutoTuneTab.why`,`Why`)})]})}),d(`tbody`,{children:t.devices.map(n=>{let i=Ii(e,t.nodeId,n.deviceKey);return a(`tr`,{className:`border-t border-border align-top`,children:[a(`td`,{className:`px-3 py-1.5`,children:[d(`div`,{className:`font-mono text-foreground`,children:n.deviceKey}),d(`div`,{className:`text-[11px] text-foreground-subtle`,children:Ai(n.accelerator)})]}),a(`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&&a(`div`,{className:`text-[11px] text-foreground-subtle`,children:[r(`pipeline.clusterAutoTuneTab.fpsKeptFree`,{fps:n.chosen.fps,percent:Math.round(e.headroom*100)}),d(`div`,{children:Li(n.chosen.source)})]})]}),d(`td`,{className:`px-3 py-1.5`,children:n.chosen===null?d(`span`,{className:`text-foreground-subtle`,children:r(`common.unchanged`)}):i!==null&&i.before!==i.after?a(`span`,{children:[d(`span`,{className:`text-foreground-subtle`,children:i.before??r(`common.defaultWord`)}),` → `,d(`span`,{className:`font-medium text-foreground`,children:i.after})]}):d(`span`,{className:`text-foreground`,children:n.chosen.modelId})}),d(`td`,{className:`px-3 py-1.5 text-[11px] text-foreground-muted`,children:n.reasons.map((e,t)=>d(`div`,{children:Mi(e)},t))})]},n.deviceKey)})})]})})]})}function Hi({plan:e,nodeName:t}){let{t:n}=X();return d(`div`,{className:`flex flex-col gap-3 text-xs`,"data-testid":`auto-tune-change-list`,children:a(`div`,{children:[d(`div`,{className:S,children:n(`pipeline.clusterAutoTuneTab.nodeSettings`,`Node settings`)}),e.nodeChanges.length===0?d(`div`,{className:`text-foreground-subtle`,children:n(`pipeline.clusterAutoTuneTab.noChange`,`No change.`)}):d(`ul`,{className:`mt-1 flex flex-col gap-0.5`,children:e.nodeChanges.flatMap(e=>[...e.modelPins.map(r=>a(`li`,{children:[a(`span`,{className:`font-mono`,children:[t(e.nodeId),` · `,e.deviceKey]}),` `,`— `,r.stepId,`: `,r.before??n(`pipeline.clusterAutoTuneTab.defaultModel`),` →`,` `,r.after??n(`pipeline.clusterAutoTuneTab.stepDefault`,`step default`)]},`${e.nodeId}/${e.deviceKey}/${r.stepId}/pin`)),...e.thresholds.map(r=>a(`li`,{children:[a(`span`,{className:`font-mono`,children:[t(e.nodeId),` · `,e.deviceKey]}),` `,`—`,` `,n(`pipeline.clusterAutoTuneTab.thresholdReset`,{step:r.stepId,keys:r.keys.join(`, `)})]},`${e.nodeId}/${e.deviceKey}/${r.stepId}/thr`))])})]})})}function Ui({result:e}){let{t}=X();return e.kind===`refused`?d(`div`,{className:`text-xs text-warning`,children:t(`pipeline.clusterAutoTuneTab.anotherApplyIsAlreadyRunning`,`Another apply is already running.`)}):e.kind===`stale`?d(`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.`)}):a(`ul`,{className:`text-xs`,"data-testid":`auto-tune-result`,children:[e.kind===`aborted`&&d(`li`,{className:`text-danger`,children:t(`pipeline.clusterAutoTuneTab.aModelCouldNotBe`,`A model could not be downloaded: nothing was changed.`)}),e.phases.map(e=>a(`li`,{className:e.ok?`text-foreground-muted`:`text-danger`,children:[e.ok?`✓`:`✗`,` `,e.phase,`: `,e.detail]},e.phase))]})}function Wi(){let{t:e}=X(),t=c(),[i,o]=r(.4),[s,l]=r(2),[u,f]=r(!1),[p,m]=r(!1),[h,g]=r(null),{nodes:_}=G(),v=n(()=>sr(_),[_]),b=He({headroom:i,minSessionsPerDevice:s},{enabled:u,refetchOnWindowFocus:!1}),x=Lt({onSuccess:e=>{g(e),m(!1),t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getNodeInferenceDevices`]]}),e.kind===`applied`&&b.refetch()}}),C=h?.kind===`stale`?h.plan:b.data,w=C===void 0?null:Pi(C);return a(`div`,{className:`flex flex-col gap-3`,"data-testid":`cluster-auto-tune`,children:[a(`section`,{className:y,children:[a(`header`,{className:`${N} flex flex-wrap items-center gap-2`,children:[d(T,{className:`h-3.5 w-3.5 shrink-0 text-foreground-subtle`,"aria-hidden":!0}),d(`h3`,{className:`${S} min-w-0 flex-1`,children:e(`pipeline.clusterAutoTuneTab.autoTune`,`Auto tune`)})]}),a(`div`,{className:`flex flex-col gap-2 px-3 py-2 text-xs text-foreground-muted`,children:[d(`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 on the accelerators and clears their threshold overrides, so each model runs its own default thresholds. Cameras carry no model or threshold of their own. Enabled steps, devices, pins, recording, notifications, zones and rules are not touched. There is no undo.`)}),a(`div`,{className:`flex flex-wrap items-center gap-2`,children:[a(`label`,{className:`flex items-center gap-1.5`,children:[d(`span`,{className:`whitespace-nowrap`,children:e(`pipeline.clusterAutoTuneTab.keepFree`,`Keep free`)}),d(Ke,{"aria-label":e(`pipeline.clusterAutoTuneTab.shareOfEachAcceleratorKept`,`Share of each accelerator kept free`),value:String(i),options:Ri.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);zi(t)&&o(t)}})]}),a(`label`,{className:`flex items-center gap-1.5`,children:[d(`span`,{className:`whitespace-nowrap`,children:e(`pipeline.clusterAutoTuneTab.atLeast`,`At least`)}),d(Ke,{"aria-label":e(`pipeline.clusterAutoTuneTab.minimumParallelSessionsPerDevice`,`Minimum parallel sessions per device`),value:String(s),options:Bi.map(t=>({value:String(t),label:e(`pipeline.clusterAutoTuneTab.camerasAtOnce`,{count:t})})),onChange:e=>{let t=Number(e.target.value);Bi.some(e=>e===t)&&l(t)}})]}),d(K,{size:`sm`,variant:`secondary`,onClick:()=>{g(null),f(!0),u&&b.refetch()},children:b.isFetching?e(`pipeline.clusterAutoTuneTab.computing`,`Computing…`):C===void 0?e(`pipeline.clusterAutoTuneTab.computePlan`,`Compute plan`):e(`pipeline.clusterAutoTuneTab.recompute`,`Recompute`)}),C!==void 0&&d(K,{size:`sm`,disabled:Fi(C),onClick:()=>m(!0),children:e(`pipeline.clusterAutoTuneTab.apply`,`Apply…`)})]}),b.error!==null&&d(`div`,{className:`text-danger`,children:b.error.message}),h!==null&&d(Ui,{result:h}),w!==null&&d(`div`,{className:`text-[11px] text-foreground-subtle`,children:e(`pipeline.clusterAutoTuneTab.planSummary`,{modelChanges:w.modelChanges,thresholdClears:w.thresholdClears})})]})]}),C?.warnings.map((e,t)=>d(`div`,{className:`rounded-md border border-warning/40 bg-warning/10 px-3 py-2 text-xs text-warning`,children:Ni(e,v)},t)),C?.nodes.map(e=>d(Vi,{plan:C,node:e,nodeName:v},e.nodeId)),C!==void 0&&d(Vt,{open:p,onOpenChange:m,children:a(Pt,{width:`lg`,scroll:`body`,children:[a(Xt,{children:[d(St,{children:e(`pipeline.clusterAutoTuneTab.applyAutoTune`,`Apply auto tune?`)}),d(yt,{children:e(`pipeline.clusterAutoTuneTab.theseAreAllTheChanges`,`These are all the changes. Every override listed is removed and cannot be restored.`)})]}),d(Jt,{children:d(Hi,{plan:C,nodeName:v})}),a(Ut,{children:[d(K,{variant:`ghost`,onClick:()=>m(!1),children:e(`common.cancel`,`Cancel`)}),d(K,{variant:`danger`,disabled:x.isPending,onClick:()=>x.mutate({planHash:C.planHash,headroom:i,minSessionsPerDevice:s}),children:x.isPending?e(`pipeline.clusterAutoTuneTab.applying`,`Applying…`):e(`common.apply`,`Apply`)})]})]})})]})}var Gi={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 Ki(e,t){return t<=0?0:Math.round(e/t*1e3)/10}function qi(e){return e===void 0?!1:e.load.devices.reduce((e,t)=>e+t.attachedCameras,0)>=e.load.attachedCameras}function Ji(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:Le(e),format:e.format,sessions:i,weight:a,weightSharePct:e.exclusion===null?Ki(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 Yi(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=Ji(e.devicesByNode[r.id]??[],new Map((i?.load.devices??[]).map(e=>[e.deviceKey,e.attachedCameras])),qi(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?Ki(c,r.maxCameras):null,queueDepthTotal:i?.load.queueDepthTotal??null,avgInferenceTimeMs:i?.load.avgInferenceTimeMs??null,score:i?.score??null,weight:s,weightSharePct:o?Ki(s,n):null,decodeHwaccel:i?.decodeHwaccel??null,devices:a,eligibleDeviceCount:a.filter(e=>e.exclusion===null).length}})}e();var Xi=2e4,Zi=3e5;function Qi({stats:e,targetWeights:t,showAccelerators:r=!0}){let{t:i}=X(),{nodes:a}=G(),o=F().trpcClient,c=zt(void 0,{placeholderData:l,staleTime:Xi,refetchInterval:Xi,refetchOnWindowFocus:!0}),u=Ft(void 0,{staleTime:Zi}),f=n(()=>a.map(e=>e.id),[a]),m=s({queries:f.map(e=>({queryKey:Ee(Nt.pipelineOrchestrator.getNodeInferenceDevices,{nodeId:e},`query`),queryFn:()=>o.pipelineOrchestrator.getNodeInferenceDevices.query({nodeId:e}),staleTime:Zi,refetchOnWindowFocus:!1,placeholderData:l}))}),h=n(()=>{let e={};return f.forEach((t,n)=>{let r=m[n]?.data;r&&(e[t]=r.devices)}),e},[f,m.map(e=>e.dataUpdatedAt).join(`|`)]),g=n(()=>{let e=new Map;for(let t of u.data??[])e.set(t.nodeId,t.settings);return e},[u.data]),_=n(()=>a.map(e=>{let n=g.get(e.id);return{id:e.id,name:e.name,isOnline:e.isOnline,detectEnabled:Yn(n,e.isHub).pipeline,weight:t?.[e.id]??Pn(n,`detectWeight`)??1,maxCameras:Pn(n,`maxCameras`)}}),[a,g,t]),v=c.data??[],y=n(()=>Yi({nodes:_,loads:v,devicesByNode:h}),[_,v,h]),b=y.reduce((e,t)=>e+(t.attachedCameras??0),0),x=y.reduce((e,t)=>e+(t.activeCameras??0),0),S=c.dataUpdatedAt>0?Date.now()-c.dataUpdatedAt:null,C=new Map((e?.nodes??[]).map(e=>[e.nodeId,e]));return d(J,{headingId:`load-balancing-node-load`,title:i(`pipeline.nodeLoadOverview.nodeLoad`,`Node load`),icon:R,actions:d(`span`,{className:`text-[10px] text-foreground-subtle tabular-nums`,children:i(`pipeline.nodeLoadOverview.summaryLine`,{active:x,attached:b,reading:c.data===void 0?i(`pipeline.nodeLoadOverview.reading`,`reading…`):i(`pipeline.nodeLoadOverview.readingAge`,{age:S===null?`—`:`${Math.round(S/1e3)}s`})})}),children:d(`div`,{className:p,children:y.length===0?d(`p`,{className:`text-[11px] italic text-foreground-subtle`,children:i(`pipeline.nodeLoadOverview.noClusterNodesReportedYet`,`No cluster nodes reported yet.`)}):d(`div`,{className:`grid gap-2 @2xl/clustertab:grid-cols-2 @5xl/clustertab:grid-cols-3`,children:y.map(e=>d($i,{row:e,placed:C.get(e.nodeId),showAccelerators:r},e.nodeId))})})})}function $i({row:e,placed:t,showAccelerators:n}){let{t:r}=X(),i=e.attachedCameras===null?`—`:`${e.activeCameras??0} / ${e.attachedCameras}${e.maxCameras===null?``:` of ${e.maxCameras}`}`;return a(`div`,{className:`rounded-lg border border-border bg-surface/60 p-2.5 min-w-0`,children:[a(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[d(`span`,{className:`h-1.5 w-1.5 shrink-0 rounded-full ${e.isOnline?`bg-emerald-400`:`bg-foreground-subtle/40`}`}),d(`span`,{className:`truncate text-xs font-medium text-foreground`,title:e.nodeId,children:e.name}),!e.detectEnabled&&d(`span`,{className:`shrink-0 rounded bg-surface-hover px-1 text-[9px] uppercase tracking-wide text-foreground-subtle`,children:r(`pipeline.nodeLoadOverview.noDetect`,`no detect`)}),!e.reported&&e.isOnline&&a(`span`,{className:`ml-auto inline-flex shrink-0 items-center gap-1 text-[9px] text-amber-400`,title:r(`pipeline.nodeLoadOverview.onlineButItDidNot`,`Online, but it did not answer the last load read — its numbers below are unknown, not zero.`),children:[d(v,{className:`h-2.5 w-2.5`}),` `,r(`pipeline.nodeLoadOverview.noReading`)]}),!e.isOnline&&a(`span`,{className:`ml-auto inline-flex shrink-0 items-center gap-1 text-[9px] text-foreground-subtle`,children:[d(E,{className:`h-2.5 w-2.5`}),` `,r(`common.offline`)]})]}),a(`dl`,{className:`mt-1.5 grid grid-cols-2 gap-x-2 gap-y-0.5 text-[10px]`,children:[d(na,{label:r(`pipeline.nodeLoadOverview.runningAttached`,`Running / attached`),value:i,title:r(`pipeline.nodeLoadOverview.sessionsInInferenceNowCameras`,`Sessions in inference now / cameras attached to this runner (the balancer's committed load) / operator cap.`)}),d(na,{label:r(`pipeline.nodeLoadOverview.targetShare`,`Target share`),value:e.weightSharePct===null?`out of play`:`${e.weightSharePct}%`,title:r(`pipeline.nodeLoadOverview.theNodeShareAutomaticOr`,`The node share (automatic or manual) normalised over the nodes the balancer actually ranks (online AND detect-enabled).`)}),d(na,{label:r(`pipeline.nodeLoadOverview.actualShare1H`,`Actual share (1 h)`),value:t?.observedShare===null||t===void 0?`—`:`${Math.round(t.observedShare*100)}%`,title:r(`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.`)}),d(na,{label:r(`pipeline.nodeLoadOverview.peakYields`,`Peak · yields`),value:t===void 0?`—`:`${t.peakSessions} · ${t.yieldsAway}`,title:r(`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.`)}),d(na,{label:r(`pipeline.nodeLoadOverview.scoreQueue`,`Score · queue`),value:e.score===null?`—`:`${e.score} · ${e.queueDepthTotal??0}`,title:r(`pipeline.nodeLoadOverview.theCapacityScoreBalanceMinimises`,`The capacity score balance() minimises (attached + queue depth), and the raw queue depth.`)}),e.capacityPct!==null&&d(na,{label:r(`pipeline.nodeLoadOverview.capFill`,`Cap fill`),value:`${e.capacityPct}%`,title:r(`pipeline.nodeLoadOverview.attachedMaxcameras`,`attached / maxCameras.`)}),e.avgInferenceTimeMs!==null&&d(na,{label:r(`pipeline.nodeLoadOverview.avgInfer`,`Avg infer`),value:`${Math.round(e.avgInferenceTimeMs)} ms`,title:r(`pipeline.nodeLoadOverview.meanInferenceTimeAcrossThis`,`Mean inference time across this node's attached cameras.`)}),e.decodeHwaccel!==null&&d(na,{label:r(`pipeline.nodeLoadOverview.decode`,`Decode`),value:e.decodeHwaccel,title:r(`pipeline.nodeLoadOverview.thisNodeSProbedDecode`,`This node's probed decode hwaccel.`)})]}),n&&d(ea,{row:e})]})}function ea({row:e}){let{t}=X();return e.devices.length===0?d(`p`,{className:`mt-2 text-[10px] italic text-foreground-subtle`,children:t(`pipeline.nodeLoadOverview.acceleratorsNotReadYet`,`Accelerators not read yet.`)}):a(`div`,{className:`mt-2 border-t border-border pt-1.5`,children:[a(`div`,{className:`flex items-center gap-1 text-[9px] uppercase tracking-wider text-foreground-subtle`,children:[d(b,{className:`h-2.5 w-2.5`}),t(`pipeline.nodeLoadOverview.accelerators`,`Accelerators`),e.eligibleDeviceCount===0&&d(`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`)})]}),d(`ul`,{className:`mt-1 space-y-0.5`,children:e.devices.map(e=>d(ta,{device:e},e.key))})]})}function ta({device:e}){let{t}=X(),n=e.exclusion;return a(`li`,{className:`flex items-baseline gap-1.5 text-[10px] min-w-0`,children:[d(w,{className:`h-2.5 w-2.5 shrink-0 ${n===null?`text-foreground-subtle`:`text-foreground-subtle/50`}`}),d(`span`,{className:`shrink-0 font-medium ${n===null?`text-foreground`:`text-foreground-subtle`}`,title:`${e.key} · ${e.format}`,children:e.label}),n===null?a(o,{children:[d(`span`,{className:`shrink-0 tabular-nums text-foreground-subtle`,children:t(`pipeline.nodeLoadOverview.sharePct`,{pct:e.weightSharePct})}),a(`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&&d(`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`)})]}):d(`span`,{className:`truncate text-foreground-subtle/80`,title:t(Gi[n]),children:t(`pipeline.nodeLoadOverview.excludedWith`,{reason:t(Gi[n])})})]})}function na({label:e,value:t,title:n}){return a(`div`,{className:`min-w-0`,title:n,children:[d(`dt`,{className:`text-[9px] uppercase tracking-wide text-foreground-subtle`,children:e}),d(`dd`,{className:`truncate font-medium tabular-nums text-foreground`,children:t})]})}function ra(e){return{nodes:Object.fromEntries(e.map(e=>[e.nodeId,Math.max(1,e.weight)])),devices:{}}}function ia(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 aa(e){return Object.fromEntries(e.nodes.map(e=>[e.nodeId,Object.fromEntries(e.devices.map(e=>[e.deviceKey,e.suggestedMaxSessions]))]))}function oa(e){return e.reason===`disabled`?Y.t(`helpers.loadBalancingViewModel.stalePinDisabled`,{deviceKey:e.deviceKey}):Y.t(`helpers.loadBalancingViewModel.stalePinMissing`,{deviceKey:e.deviceKey})}function sa(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 ca(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 Y.t(`helpers.loadBalancingViewModel.shareNote`,{count:n.length,names:i,into:r})}var la=[{value:`hardware`,get label(){return Y.t(`helpers.loadBalancingViewModel.hardwareLabel`)},get hint(){return Y.t(`helpers.loadBalancingViewModel.hardwareHint`)}},{value:`benchmark`,get label(){return Y.t(`helpers.loadBalancingViewModel.benchmarkLabel`)},get hint(){return Y.t(`helpers.loadBalancingViewModel.benchmarkHint`)}},{value:`manual`,get label(){return Y.t(`helpers.loadBalancingViewModel.manualLabel`)},get hint(){return Y.t(`helpers.loadBalancingViewModel.manualHint`)}}];function ua(e){return e===`no-benchmark-results`?Y.t(`helpers.loadBalancingViewModel.fallbackNone`):e===`partial-benchmark-results`?Y.t(`helpers.loadBalancingViewModel.fallbackPartial`):null}function da(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)}: ${ua(e.capacityFallback)??``}`).join(` · `)}e();function fa(e,t,n){return Math.min(Math.max(e,t),n)}function pa(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 ma(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:fa(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 ha(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 ga({nodes:e,pending:n,onCommitWeights:i,weightLabel:s=`Detection weight`,emptyHint:c,footnote:l,readOnly:u=!1}){let{t:f}=X(),[p,m]=r(()=>pa(e)),[h,g]=r(new Set);t(()=>{m(pa(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=>ma(n,e,t,h,_))},b=()=>{let t=ha(p,_,h),n=e.filter(e=>(t[e.id]??0)!==e.weight).map(e=>e.id);if(n.length===0)return;let r=new Set([...n,...h]);i(e.filter(e=>r.has(e.id)).map(e=>({nodeId:e.id,weight:t[e.id]??0})))};if(e.length===0)return d(`p`,{className:`rounded-lg border border-dashed border-border bg-background px-4 py-6 text-center text-xs text-foreground-subtle`,children:c??f(`placementBoard.weightSliderStack.noDetectEnabledNodesEnable`,`No detect-enabled nodes. Enable “Detect” on a node above to distribute detection weight.`)});let x=e.length===1;return a(`div`,{className:`space-y-3`,children:[e.map(e=>{let t=p[e.id]??0,r=h.has(e.id);return a(`div`,{className:`flex items-center gap-3`,children:[d(`span`,{className:`w-28 shrink-0 truncate text-xs font-medium text-foreground`,title:e.name,children:e.name}),d(`input`,{"aria-label":f(`placementBoard.weightSliderStack.for`,`{{weightLabel}} for {{name}}`,{weightLabel:s,name:e.name}),type:`range`,min:0,max:100,step:1,value:Math.round(t),disabled:u||n||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`}),a(`span`,{className:`w-10 shrink-0 text-right font-mono text-xs tabular-nums text-foreground`,children:[Math.round(t),`%`]}),!u&&d(`button`,{type:`button`,onClick:()=>v(e.id),disabled:n||x,"aria-pressed":r,title:r?f(`placementBoard.weightSliderStack.unlockAllowRebalancing`,`Unlock — allow rebalancing`):f(`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:d(r?I:j,{className:`h-3.5 w-3.5`})})]},e.id)}),d(`p`,{className:`text-[10px] leading-tight text-foreground-subtle`,children:l??d(o,{children:f(`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 _a(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}function va(e){if(e.presence===`absent`)return`absent`;if(e.presence===`unknown`)return`unknown`;switch(e.exclusion){case null:return`active`;case`disabled`:return`disabled`;case`unavailable`:return e.available?`backoff`:`unavailable`;case`cannot-host-camera-root`:return`root-incapable`;case`accelerator-preferred`:return`standby`}}function ya(e,t,n){let r=new Map((t?.devices??[]).map(e=>[e.deviceKey,e])),i=new Map((n?.devices??[]).map(e=>[e.deviceKey,e.sessionsNow]));return e.map(e=>{let t=r.get(e.key),a=n===void 0?null:i.get(e.key)??0;return{device:e,state:va(e),share:t===void 0?null:{configuredPct:t.configuredPct,effectivePct:t.effectivePct},sessionsNow:a,atCap:a!==null&&e.maxSessions!==null&&a>=e.maxSessions}})}var ba={active:`success`,disabled:`neutral`,absent:`danger`,unknown:`neutral`,unavailable:`warning`,backoff:`warning`,"root-incapable":`info`,standby:`neutral`};e();function xa(e){let t=Le(e),n=e.backend.toLowerCase(),r=e.device.toLowerCase();return e.key===`cpu`||r===`cpu`?{label:t,Icon:w,hue:`slate`}:r===`npu`?{label:t,Icon:B,hue:`sky`}:r===`gpu`||r===`igpu`?{label:t,Icon:ye,hue:`violet`}:n===`edgetpu`?{label:t,Icon:Ce,hue:`emerald`}:{label:t,Icon:w,hue:`slate`}}var Sa={active:[`placementBoard.nodeInferenceDevices.state.active`,`in use`],disabled:[`placementBoard.nodeInferenceDevices.state.disabled`,`switched off`],absent:[`placementBoard.nodeInferenceDevices.state.absent`,`absent`],unknown:[`placementBoard.nodeInferenceDevices.state.unknown`,`unknown`],unavailable:[`placementBoard.nodeInferenceDevices.state.unavailable`,`unavailable`],backoff:[`placementBoard.nodeInferenceDevices.state.backoff`,`pool down`],"root-incapable":[`placementBoard.nodeInferenceDevices.state.rootIncapable`,`no root model`],standby:[`placementBoard.nodeInferenceDevices.state.standby`,`fallback`]},Ca={active:[`placementBoard.nodeInferenceDevices.stateHint.active`,`A camera-root candidate: placement may start sessions on it.`],disabled:[`placementBoard.nodeInferenceDevices.stateHint.disabled`,`Switched off: it takes no sessions.`],absent:[`placementBoard.nodeInferenceDevices.stateHint.absent`,`The node no longer reports this device (unplugged, or moved to another node). Its settings are kept; it is never used. Forget it to delete them.`],unknown:[`placementBoard.nodeInferenceDevices.stateHint.unknown`,`The node's probe did not answer, so whether the device is there is not known.`],unavailable:[`placementBoard.nodeInferenceDevices.stateHint.unavailable`,`On the node, but the probe reports it unusable.`],backoff:[`placementBoard.nodeInferenceDevices.stateHint.backoff`,`Reported by the node, but its inference pool is down or backing off.`],"root-incapable":[`placementBoard.nodeInferenceDevices.stateHint.rootIncapable`,`Its format cannot run the camera root detector; it serves enrichment steps only.`],standby:[`placementBoard.nodeInferenceDevices.stateHint.standby`,`The CPU fallback: it takes no sessions while an accelerator is serving this node.`]};function wa({nodeId:e,nodeName:i,isOnline:s,suggestedMaxSessions:l,shareSource:u,sharesAutomatic:f,share:p,placed:m}){let{t:g}=X(),_=c(),{data:v,isLoading:y}=rt({nodeId:e},{refetchInterval:15e3}),b=()=>{_.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getNodeInferenceDevices`]]})},x=Qe({onSettled:b}),S=Wt({onSettled:b}),C=Nt.platformProbe.rescanAccelerators.useMutation({onSettled:b}),w=v?.devices??[],T=v?.reachable??s,[D,O]=r({});t(()=>{O(Object.fromEntries(w.map(e=>[e.key,Ta(e)])))},[w.map(e=>`${e.key}:${e.enabled}:${e.weight}:${e.maxSessions}:${JSON.stringify(e.steps??{})}`).join(`|`)]);let k=n(()=>w.filter(e=>(D[e.key]?.enabled??e.enabled)&&e.available).length,[w,D]),[A,j]=r(null),M=A??!0,N=t=>{let n=w.map(e=>{let n=t[e.key]??Ta(e);return{key:e.key,enabled:n.enabled,weight:n.weight,maxSessions:n.maxSessions,steps:n.steps}});x.mutate({agentNodeId:e,inferenceDevices:Rr(n)})},P=(e,t)=>{let n=D[e.key]??Ta(e),r={...D,[e.key]:{...n,...t}};O(r),N(r)},te=n(()=>ya(w,p,m),[w,p,m]),F=n(()=>w.filter(e=>(D[e.key]?.enabled??e.enabled)&&e.available),[w,D]),I=n(()=>F.map(e=>({id:e.key,name:xa(e).label,weight:D[e.key]?.weight??e.weight})),[F,D]),L=e=>{let t={...D};for(let n of e){let e=t[n.nodeId];e&&(t[n.nodeId]={...e,weight:n.weight})}O(t),N(t)},R=x.isPending||S.isPending,z=Ea(g,f?u:`manual`),B=[{key:`device`,header:g(`placementBoard.nodeInferenceDevices.colDevice`,`Device`),nowrap:!1,sortValue:e=>xa(e.device).label,render:e=>d(Oa,{row:e,steps:D[e.device.key]?.steps})},{key:`state`,header:g(`placementBoard.nodeInferenceDevices.colState`,`State`),sortValue:e=>e.state,render:e=>d(`span`,{title:g(Ca[e.state][0],Ca[e.state][1]),children:d(q,{variant:ba[e.state],size:`sm`,children:g(Sa[e.state][0],Sa[e.state][1])})})},{key:`share`,header:g(`placementBoard.nodeInferenceDevices.colShare`,`Share`),align:`right`,sortValue:e=>e.share?.effectivePct??null,render:e=>d(ka,{row:e,sourceLabel:z})},{key:`sessions`,header:g(`placementBoard.nodeInferenceDevices.colSessions`,`Sessions`),align:`right`,sortValue:e=>e.sessionsNow,render:e=>a(`span`,{className:`tabular-nums text-xs text-foreground`,children:[e.sessionsNow??`—`,e.atCap&&d(q,{variant:`warning`,size:`sm`,className:`ml-1`,children:g(`placementBoard.nodeInferenceDevices.atCap`,`at cap`)})]})},{key:`cap`,header:g(`placementBoard.nodeInferenceDevices.colCap`,`Max sessions`),notSortableReason:g(`placementBoard.nodeInferenceDevices.capNotSortable`,`An editable field: sort by Sessions instead.`),render:e=>{let t=D[e.device.key]??Ta(e.device);if(!(t.enabled&&e.device.available))return d(`span`,{className:`text-xs text-foreground-subtle`,children:`—`});let n=xa(e.device).label;return a(`div`,{className:`flex items-center justify-end gap-1`,children:[d(et,{type:`number`,min:1,placeholder:`∞`,value:t.maxSessions??``,onChange:t=>{let n=t.target.value.trim(),r=n===``?null:Number.parseInt(n,10);P(e.device,{maxSessions:r!==null&&r>0?r:null})},disabled:R,"aria-label":g(`placementBoard.nodeInferenceDevices.maxConcurrentSessionsFor`,`Max concurrent sessions for {{label}}`,{label:n}),className:`w-16 text-right`}),d(Aa,{suggested:l?.[e.device.key]??null,current:t.maxSessions,pending:R,onApply:t=>P(e.device,{maxSessions:t})})]})}},{key:`enabled`,header:g(`placementBoard.nodeInferenceDevices.colEnabled`,`Enabled`),align:`right`,notSortableReason:g(`placementBoard.nodeInferenceDevices.enabledNotSortable`,`A switch: sort by State instead.`),render:t=>{let n=xa(t.device).label;if(t.state===`absent`)return d(Rt,{label:g(`placementBoard.nodeInferenceDevices.forget`,`Forget`),icon:h,size:`sm`,triggerVariant:`ghost`,disabled:R,title:g(`placementBoard.nodeInferenceDevices.forgetTitle`,`Forget {{label}} on {{node}}?`,{label:n,node:i}),description:g(`placementBoard.nodeInferenceDevices.forgetDescription`,`Its stored settings (switch, weight, cap, step models) are deleted. If the device comes back it starts from the defaults.`),action:()=>S.mutateAsync({agentNodeId:e,deviceKey:t.device.key})});let r=D[t.device.key]??Ta(t.device);return d(We,{checked:r.enabled&&t.device.available,onCheckedChange:()=>P(t.device,{enabled:!r.enabled}),disabled:!t.device.available||R,"aria-label":g(`placementBoard.nodeInferenceDevices.enable`,`Enable {{label}}`,{label:n})})}}],V=x.error??S.error??C.error;return a(`div`,{className:`rounded-lg border border-border bg-surface`,children:[a(`div`,{className:`flex items-center gap-2 px-3 py-2`,children:[a(K,{variant:`ghost`,size:`sm`,onClick:()=>j(!M),className:`min-w-0 flex-1 justify-start`,"aria-expanded":M,children:[d(U,{className:`h-4 w-4 shrink-0 text-foreground-subtle transition-transform ${M?`rotate-90`:``}`}),d(`span`,{className:`truncate text-sm font-medium text-foreground`,children:i}),d(`span`,{className:`ml-auto flex items-center gap-1 text-xs text-foreground-subtle`,children:T?a(o,{children:[d(Te,{className:`h-3.5 w-3.5`}),g(`pipeline.nodeInferenceDevices.accelerators`,{count:k})]}):a(o,{children:[d(E,{className:`h-3.5 w-3.5`}),` `,g(`common.unreachable`)]})})]}),a(K,{variant:`ghost`,size:`sm`,onClick:()=>C.mutate({nodeId:e}),disabled:C.isPending||!T,title:g(`placementBoard.nodeInferenceDevices.rescanTitle`,`Probe this node for accelerators now (a Coral plugged in or pulled out). The node also re-probes every minute.`),children:[d(ee,{className:`h-3.5 w-3.5 ${C.isPending?`animate-spin`:``}`}),g(`placementBoard.nodeInferenceDevices.rescan`,`Rescan`)]})]}),M&&a(`div`,{className:`space-y-3 border-t border-border p-3`,children:[T?y&&w.length===0?d(`p`,{className:`text-center text-xs text-foreground-subtle`,children:g(`placementBoard.nodeInferenceDevices.probingAccelerators`,`Probing accelerators…`)}):d(kt,{columns:B,rows:te,rowKey:e=>e.device.key,minWidthPx:640,bordered:!1,emptyMessage:g(`placementBoard.nodeInferenceDevices.noInferenceDevicesReportedBy`,`No inference devices reported by this node's platform probe.`)}):d(ja,{}),C.data!==void 0&&d(`p`,{className:`text-xs text-foreground-subtle`,children:Da(g,C.data.appeared,C.data.disappeared)}),T&&!f&&F.length>=2&&a(`div`,{className:`space-y-3 rounded-lg border border-border p-3`,children:[a(`h4`,{className:`flex items-center gap-1.5 text-xs font-semibold uppercase tracking-wide text-foreground-subtle`,children:[d(xe,{className:`h-3.5 w-3.5`}),g(`placementBoard.nodeInferenceDevices.acceleratorShare`,`Accelerator share`)]}),d(ga,{nodes:I,pending:R,onCommitWeights:L,weightLabel:`Accelerator share`,footnote:g(`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%.`)})]}),V!=null&&a(`div`,{className:`rounded-md border border-danger/30 bg-danger/5 px-3 py-2 text-xs text-danger`,children:[g(`placementBoard.nodeInferenceDevices.failedToSaveInferenceDevices`,`Failed to save inference devices:`),` `,V.message]})]})]})}function Ta(e){return{enabled:e.enabled,weight:e.weight,maxSessions:e.maxSessions,steps:e.steps??{}}}function Ea(e,t){switch(t){case`benchmark`:return e(`placementBoard.nodeInferenceDevices.sourceBenchmark`,`benchmark`);case`hardware`:return e(`placementBoard.nodeInferenceDevices.sourceHardware`,`hardware`);case`manual`:return e(`placementBoard.nodeInferenceDevices.sourceManual`,`manual`);case void 0:return null}}function Da(e,t,n){return t.length===0&&n.length===0?e(`placementBoard.nodeInferenceDevices.rescanNoChange`,`Rescanned: no change.`):e(`placementBoard.nodeInferenceDevices.rescanChanged`,`Rescanned: appeared {{appeared}} · disappeared {{disappeared}}`,{appeared:t.length>0?t.join(`, `):`—`,disappeared:n.length>0?n.join(`, `):`—`})}function Oa({row:e,steps:t}){let n=xa(e.device),r=_a({defaultModelId:e.device.defaultModelId,steps:t??e.device.steps??{}});return a(`div`,{className:`flex min-w-0 items-center gap-2`,children:[d(n.Icon,{className:`h-4 w-4 shrink-0 text-foreground-subtle`}),a(`div`,{className:`min-w-0`,children:[a(`div`,{className:`flex items-center gap-1.5`,children:[d(`span`,{className:`text-sm font-medium text-foreground`,children:n.label}),d(q,{variant:`neutral`,size:`sm`,className:`font-mono`,children:e.device.format})]}),a(`div`,{className:`flex flex-wrap items-center gap-x-1.5 text-xs text-foreground-subtle`,children:[d(`span`,{className:`font-mono`,children:e.device.key}),r!==null&&a(o,{children:[d(`span`,{"aria-hidden":!0,children:`·`}),d(`span`,{children:d(dn,{i18nKey:`pipeline.nodeInferenceDevices.rootModel`,values:{model:r},components:{mono:d(`span`,{className:`font-mono text-foreground-muted`})}})})]})]})]})]})}function ka({row:e,sourceLabel:t}){let{t:n}=X();if(e.share===null)return d(`span`,{className:`text-xs text-foreground-subtle`,children:`—`});let{configuredPct:r,effectivePct:i}=e.share,o=Math.round(r)!==Math.round(i);return a(`div`,{className:`text-right`,children:[a(`div`,{className:`tabular-nums text-sm text-foreground`,children:[Math.round(i),`%`]}),a(`div`,{className:`text-xs text-foreground-subtle`,children:[o?n(`placementBoard.nodeInferenceDevices.shareConfigured`,`set {{pct}}%`,{pct:Math.round(r)}):null,o&&t!==null?` · `:null,t]})]})}function Aa({suggested:e,current:t,pending:n,onApply:r}){let{t:i}=X();return e===null||e<1||e===t?null:d(K,{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 ja(){let{t:e}=X();return a(`div`,{className:`flex flex-col items-center gap-2 px-4 py-6 text-center`,children:[d(E,{className:`h-6 w-6 text-foreground-subtle`}),d(`p`,{className:`text-xs font-medium text-foreground`,children:e(`placementBoard.nodeInferenceDevices.nodeUnreachable`,`Node unreachable`)}),d(`p`,{className:`max-w-sm text-xs 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.`)})]})}e();var Ma=3600*1e3,Na=2e4,Pa=.4;function Fa({refreshToken:e,onOpenAutoTune:t}){let{t:i}=X(),s=c(),{nodes:u}=G(),f=Ft(void 0),m=en({isCamera:!0,projection:`slim`}),h=It({windowMs:Ma},{refetchInterval:Na,placeholderData:l}).data,g=nn(void 0,{refetchInterval:Na,placeholderData:l}).data,_=()=>{Rn(s),s.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getNodeInferenceDevices`]]})},v=Gt({onSuccess:_}),y=ot({onSuccess:()=>{_(),s.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getEffectiveShares`]]})}}),b=on({onSuccess:_}),S=Ue(),[C,E]=r(!1),D=g?.source,ee=D===`benchmark`?`benchmark`:`hardware`,O=dt({headroom:Pa,source:ee},{enabled:C,staleTime:1/0}),k=O.data,A=n(()=>{let e=new Map((f.data??[]).map(e=>[e.nodeId,e.settings]));return u.filter(t=>Yn(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:Pn(n,`detectWeight`)??1,maxCameras:Pn(n,`maxCameras`)}})},[u,f.data]),j=e=>u.find(t=>t.id===e)?.name??e,M=cr((m.data??[]).map(e=>({id:e.id,name:e.name}))),N=k?aa(k):void 0,P=sa(A,g),te=D!==`manual`,F=g!==void 0&&g.source!==`manual`&&!g.autoPending,I=e=>g?.nodes.find(t=>t.nodeId===e),L=e=>h?.nodes.find(t=>t.nodeId===e),R=g?ca(g,j):null,V=g?da(g,j):null,ne=la.find(e=>e.value===D)?.hint;return a(`div`,{className:`space-y-3 sm:space-y-4`,children:[d(er,{refreshToken:e}),d(Qi,{stats:h,showAccelerators:!1,...g!==void 0&&g.source!==`manual`&&!g.autoPending?{targetWeights:Object.fromEntries(g.nodes.map(e=>[e.nodeId,e.configuredPct]))}:{}}),d(J,{headingId:`load-balancing-node-shares`,title:i(`pipeline.clusterLoadBalancingTab.nodeShares`,`Node shares`),icon:xe,actions:a(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[d(`div`,{role:`radiogroup`,"aria-label":i(`pipeline.clusterLoadBalancingTab.shareSource`,`Share source`),className:`flex items-center gap-1`,children:la.map(e=>d(K,{role:`radio`,"aria-checked":D===e.value,variant:D===e.value?`primary`:`outline`,size:`sm`,title:e.hint,disabled:y.isPending||g===void 0,onClick:()=>{D!==e.value&&y.mutate({source:e.value})},children:e.label},e.value))}),a(K,{variant:`outline`,size:`sm`,onClick:()=>{E(!0),C&&O.refetch()},disabled:O.isFetching,children:[d(z,{className:`h-3.5 w-3.5`}),O.isFetching?i(`pipeline.clusterLoadBalancingTab.suggesting`,`Suggesting…`):ee===`benchmark`?i(`pipeline.clusterLoadBalancingTab.suggestFromBenchmark`,`Suggest from benchmark`):i(`pipeline.clusterLoadBalancingTab.suggestFromHardware`,`Suggest from hardware`)]}),a(K,{variant:`ghost`,size:`sm`,onClick:t,children:[d(T,{className:`h-3.5 w-3.5`}),i(`pipeline.clusterLoadBalancingTab.autoTune`,`Auto tune`)]}),a(K,{variant:`outline`,size:`sm`,onClick:()=>S.mutate(void 0),disabled:S.isPending,title:i(`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:[d(B,{className:`h-3.5 w-3.5`}),S.isPending?i(`pipeline.clusterLoadBalancingTab.rebalancing`,`Rebalancing…`):i(`pipeline.clusterLoadBalancingTab.rebalance`,`Rebalance`)]})]}),children:a(`div`,{className:`${p} space-y-3`,children:[ne!==void 0&&d(`p`,{className:`text-[10px] text-foreground-subtle`,children:ne}),h&&a(`p`,{className:`text-[10px] text-foreground-subtle`,children:[i(`pipeline.clusterLoadBalancingTab.policy`,`Policy:`),` `,d(q,{variant:h.policy===`share`?`info`:`default`,children:h.policy===`share`?i(`pipeline.clusterLoadBalancingTab.honourShares`,`honour shares`):`least-loaded`}),` `,` · ${i(`pipeline.clusterLoadBalancingTab.clusterPeak`,{count:h.clusterPeakSessions})}`,h.policy===`least-loaded`&&` · ${i(`pipeline.clusterLoadBalancingTab.leastLoadedNote`)}`]}),d(ga,{nodes:P.nodes,pending:v.isPending,readOnly:P.readOnly,onCommitWeights:e=>v.mutate(ra(e)),weightLabel:`Node share`,...P.readOnly?{footnote:g?.autoPending?d(o,{children:i(`pipeline.clusterLoadBalancingTab.automaticSharesAreBeingComputed`,`Automatic shares are being computed from the cluster's measured capacity; the stored values are used meanwhile.`)}):a(o,{children:[D===`benchmark`?i(`pipeline.clusterLoadBalancingTab.benchmarkEachNodeSShare`,`Benchmark: each node's share follows its measured capacity from node benchmark results (hardware capacity where it has none)`):i(`pipeline.clusterLoadBalancingTab.hardwareEachNodeSShare`,`Hardware: each node's share follows its capacity at its Auto tune model, from the measured speed of its hardware`),i(`pipeline.clusterLoadBalancingTab.recomputedWheneverANodeOr`,`, recomputed whenever a node or accelerator is added, removed, switched on or off, or changes model`),g?.computedAt!=null&&d(`span`,{className:`ml-1`,children:i(g.trigger===null?`pipeline.clusterLoadBalancingTab.lastAt`:`pipeline.clusterLoadBalancingTab.lastAtTrigger`,{time:new Date(g.computedAt).toLocaleTimeString(),trigger:g.trigger??``})}),`.`]})}:{}}),R!==null&&d(`p`,{className:`text-[10px] text-foreground-subtle`,children:R}),V!==null&&d(`p`,{className:`text-[10px] text-foreground-subtle`,"data-testid":`benchmark-fallback-note`,children:V}),y.isError&&d(At,{message:i(`pipeline.clusterLoadBalancingTab.switchFailed`,{message:y.error instanceof Error?y.error.message:i(`common.unknownError`)})}),v.isError&&d(At,{message:i(`pipeline.clusterLoadBalancingTab.saveFailed`,{message:v.error instanceof Error?v.error.message:i(`common.unknownError`)})}),a(`details`,{className:`rounded-md border border-border`,children:[d(`summary`,{className:`${x} cursor-pointer text-xs text-foreground`,children:i(`pipeline.clusterLoadBalancingTab.maxConcurrentSessionsAdvanced`,`Max concurrent sessions (advanced)`)}),d(`ul`,{className:`divide-y divide-border border-t border-border`,children:A.map(e=>a(`li`,{className:`${x} flex items-center gap-2`,children:[d(`span`,{className:`min-w-0 flex-1 truncate text-xs text-foreground`,children:e.name}),d(et,{type:`number`,min:1,placeholder:`∞`,defaultValue:e.maxCameras??``,"aria-label":i(`pipeline.clusterLoadBalancingTab.maxConcurrentSessionsFor`,`Max concurrent sessions for {{name}}`,{name:e.name}),className:`w-20 text-right`,disabled:b.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&&b.mutate({agentNodeId:e.id,maxCameras:i})}})]},e.id))}),d(`p`,{className:`${x} ${W} border-t border-border`,children:i(`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.`)})]})]})}),O.isError&&d(At,{message:i(`pipeline.clusterLoadBalancingTab.suggestionFailed`,{message:O.error instanceof Error?O.error.message:i(`common.unknownError`)})}),k&&d(Ia,{suggestion:k,nameOf:j,pending:v.isPending,...te?{}:{onApply:()=>v.mutate(ia(k))}}),d(J,{headingId:`load-balancing-accelerators`,title:i(`pipeline.clusterLoadBalancingTab.accelerators`,`Accelerators`),icon:w,children:d(`div`,{className:`${p} space-y-2`,children:A.length===0?d(gt,{title:i(`pipeline.clusterLoadBalancingTab.noDetectCapableNodes`,`No detect-capable nodes`),description:i(`pipeline.clusterLoadBalancingTab.enableDetectionOnANode`,`Enable detection on a node in Roles & nodes to configure its accelerators.`)}):A.map(e=>d(wa,{nodeId:e.id,nodeName:e.name,isOnline:e.isOnline,...N?.[e.id]===void 0?{}:{suggestedMaxSessions:N[e.id]},sharesAutomatic:F,...g===void 0?{}:{shareSource:g.source},...I(e.id)===void 0?{}:{share:I(e.id)},...L(e.id)===void 0?{}:{placed:L(e.id)}},e.id))})}),h!==void 0&&h.stalePins.length>0&&d(La,{stats:h,cameraName:M})]})}function Ia({suggestion:e,nameOf:t,pending:n,onApply:r}){let{t:i}=X();return a(J,{headingId:`load-balancing-suggestion`,title:e.source===`benchmark`?i(`pipeline.clusterLoadBalancingTab.suggestedFromBenchmark`,`Suggested from benchmark`):i(`pipeline.clusterLoadBalancingTab.suggestedFromHardware`,`Suggested from hardware`),icon:z,...r===void 0?{}:{actions:d(K,{size:`sm`,onClick:r,disabled:n,children:i(`pipeline.clusterLoadBalancingTab.applySuggestedShares`,`Apply suggested shares`)})},children:[d(`ul`,{className:`divide-y divide-border`,children:e.nodes.map(e=>a(`li`,{className:`${x} space-y-0.5`,children:[a(`div`,{className:`flex items-baseline gap-2 text-xs`,children:[d(`span`,{className:`min-w-0 flex-1 truncate font-medium text-foreground`,children:t(e.nodeId)}),d(`span`,{className:`tabular-nums text-foreground`,children:e.share===null?i(`common.skipped`):`${e.share}%`})]}),a(`p`,{className:W,children:[ua(e.capacityFallback)===null?``:`${ua(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))}),a(`p`,{className:`${x} ${W} 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 La({stats:e,cameraName:t}){let{t:n}=X(),r=c(),i=ct({onSuccess:()=>{r.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPlacementStats`]]}),r.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineDevicePin`]]})}});return d(J,{headingId:`load-balancing-stale-pins`,title:n(`pipeline.clusterLoadBalancingTab.staleDevicePins`,`Stale device pins`),icon:Se,children:d(`ul`,{className:`divide-y divide-border`,children:e.stalePins.map(e=>a(`li`,{className:`${x} flex items-center gap-2`,children:[a(`div`,{className:`min-w-0 flex-1`,children:[d(`p`,{className:`truncate text-xs text-foreground`,title:t(e.deviceId),children:t(e.deviceId)}),d(`p`,{className:W,children:oa(e)})]}),d(K,{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 Ra({node:e,emphasis:t=!1}){let{t:n}=X(),r=e.isHub?k:w;return a(`div`,{className:`flex items-center gap-2.5 min-w-0`,children:[d(`span`,{className:`h-2 w-2 shrink-0 rounded-full ${e.isOnline?`bg-success`:`bg-danger`}`,"aria-hidden":`true`}),d(r,{className:`h-4 w-4 shrink-0 text-foreground-subtle`,"aria-hidden":`true`}),a(`div`,{className:`min-w-0`,children:[a(`div`,{className:`flex items-center gap-1.5 ${t?`text-sm`:`text-xs`} font-semibold text-foreground`,children:[d(`span`,{className:`truncate`,children:e.name}),e.isHub&&d(q,{variant:`info`,className:`px-1.5 py-0 text-[9px] uppercase tracking-wider`,children:n(`common.hubWord`)}),!e.isOnline&&d(q,{variant:`danger`,className:`px-1.5 py-0 text-[9px] uppercase tracking-wider`,children:n(`common.offline`)})]}),d(`div`,{className:`font-mono text-[10px] text-foreground-subtle truncate`,children:e.id})]})]})}function za({nodes:e,actions:t}){let{t:n}=X();return d(kt,{columns:[{key:`node`,header:n(`placementBoard.nodeCapabilitiesTable.node`,`Node`),sortValue:e=>e.name,render:e=>d(Ra,{node:e})},...zn.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=>d(We,{"aria-label":n(`placementBoard.nodeCapabilitiesTable.on`,`{{label}} on {{name}}`,{label:n(e.labelKey),name:r.name}),title:n(e.hintKey),checked:Nn(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 Ba({roleValues:e,options:t,pending:n,onRoleChange:r}){let{t:i}=X(),o=t.map(e=>({value:e.id,label:e.id===`hub`?i(`placementBoard.roleControls.default`,`{{name}} (default)`,{name:e.name}):e.name}));return d(`ul`,{className:`divide-y divide-border`,children:Un.map(t=>a(`li`,{className:`${x} flex flex-wrap items-center gap-x-3 gap-y-1.5`,children:[a(`div`,{className:`min-w-0 flex-1 basis-56`,children:[d(`div`,{className:`text-xs font-medium text-foreground`,children:Fn(t)}),d(`p`,{className:W,children:In(t)})]}),d(`div`,{className:`w-full sm:w-48`,children:d(Ke,{"aria-label":i(`placementBoard.roleControls.node`,`{{value1}} node`,{value1:Fn(t)}),value:e[t],disabled:n,options:o,onChange:e=>r(t,e.target.value)})})]},t))})}e();function Va(){let{t:e}=X(),t=c(),{nodes:r}=G(),i=Ft(void 0),o=Ze({addonId:Hn}),s=Ze({addonId:Mn}),l=Ze({addonId:Wn}),u=()=>Rn(t),f=Be({onSuccess:u}),p=Qt({onSuccess:u}),m=n(()=>{let e=new Map;for(let t of i.data??[])e.set(t.nodeId,t.settings);return e},[i.data]),h=n(()=>r.map(e=>{let t=m.get(e.id),n=Yn(t,e.isHub);return{id:e.id,name:e.name,isHub:e.isHub,isOnline:e.isOnline,settings:t,effective:n}}),[r,m]),g={ingestNode:Vn(o.data,`ingestNode`,`hub`),recordingNode:Vn(s.data,Bn,`hub`),audioNode:Vn(o.data,`audioNode`,`hub`),motionNode:Vn(o.data,`motionNode`,`hub`),postProcessingNode:Vn(l.data,Ln,`hub`)},_=n(()=>{let e=r.filter(e=>e.isOnline).map(e=>e.id),t=e=>r.find(t=>t.id===e)?.name||e;return[...new Set([`hub`,...Un.map(e=>g[e]),...e])].filter(e=>e.length>0).map(e=>({id:e,name:t(e)}))},[r,g]),v=i.isLoading||o.isLoading||s.isLoading||l.isLoading,y=(e,t,n)=>{f.mutate({agentNodeId:e,[t]:n})},b=(e,t)=>{if(e===`recordingNode`){p.mutate({addonId:Mn,patch:{[Bn]:t}});return}if(e===`postProcessingNode`){p.mutate({addonId:Wn,patch:{[Ln]:t}});return}p.mutate({addonId:Hn,patch:{[e]:t}})},x={capabilityPending:f.isPending,onToggleCapability:y},S=v?d(te,{className:`h-3.5 w-3.5 animate-spin text-foreground-subtle`,"aria-label":e(`pipeline.clusterRolesNodesTab.loading`,`Loading`)}):null;return a(`div`,{className:`space-y-3 sm:space-y-4`,children:[a(J,{headingId:`roles-nodes-cluster-roles`,title:e(`pipeline.clusterRolesNodesTab.clusterRoles`,`Cluster roles`),icon:be,actions:S,children:[d(`p`,{className:`${W} 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.`)}),d(Ba,{roleValues:g,options:_,pending:p.isPending,onRoleChange:b})]}),d(J,{headingId:`roles-nodes-node-capabilities`,title:e(`pipeline.clusterRolesNodesTab.nodeCapabilities`,`Node capabilities`),icon:k,children:d(za,{nodes:h,actions:x})})]})}e();var Ha=2500,Ua={faces:P,"semantic-search":T,"detail-crop":we,"native-lease":Te,"runner-defaults":w,"load-balancer":xe,failover:O},Wa=[`cluster`,Jr];function Ga(e){t(()=>{if(e===null)return;let t=Xr[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`),Ha),!0)};if(r())return;let i=new MutationObserver(()=>{r()&&i.disconnect()});return i.observe(document.body,{childList:!0,subtree:!0}),()=>i.disconnect()},[e])}function Ka({section:e}){let{t}=X();return d(`div`,{"data-cluster-settings-card":e.id,className:`rounded-lg`,children:d(J,{headingId:`cluster-settings-${e.id}`,title:e.title,...Ua[e.id]===void 0?{}:{icon:Ua[e.id]},children:a(`div`,{className:`${p} space-y-3`,children:[d(`p`,{className:W,children:e.hint}),e.panels.map(e=>d(jn,{nodeId:`hub`,addonIds:[e.addonId],level:`global`,hideSectionChrome:!0,omitSectionIds:Wa.filter(t=>!(e.sectionIds??[]).includes(t)),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 qa({refreshToken:e}){let[t]=fn();return Ga(t.get($r)),d(`div`,{className:`space-y-3 sm:space-y-4`,children:Yr.map(e=>d(Ka,{section:e},e.id))})}var Ja=`pipeline-orchestrator`,Ya=200;function Xa(){let{t:e}=X();return a(`div`,{className:`flex flex-col gap-3`,children:[a(`div`,{children:[d(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:e(`pipeline.clusterOrchestratorLogsTab.orchestratorLogs`,`Orchestrator logs`)}),d(`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.`)})]}),d(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:d(pt,{addonId:Ja,limit:Ya,maxHeight:`max-h-[calc(100vh-360px)]`,showScope:!0,showDeviceChip:!0,showFilters:!1,showSourceSelect:!0})})]})}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 Qa(e){return Za.some(t=>t.id===e)}function $a({refreshToken:e}){let{t}=X(),[n,r]=fn(),i=n.get(Qr),o=Qa(i)?i:`assignments`,s=e=>{r(t=>{let n=new URLSearchParams(t);return n.set(Qr,e),n.delete($r),n},{replace:!0})};return a(`div`,{className:`flex flex-col h-full`,children:[a(`div`,{className:`px-4 sm:px-6 py-4 border-b border-border`,children:[d(`h2`,{className:`text-base font-semibold text-foreground`,children:t(`pipeline.clusterDetail.clusterOrchestration`,`Cluster Orchestration`)}),d(`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.`)})]}),d(`div`,{className:`flex items-center gap-1 px-4 sm:px-6 border-b border-border overflow-x-auto`,children:Za.map(e=>d(`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 ${o===e.id?`border-primary text-primary`:`border-transparent text-foreground-subtle hover:text-foreground`}`,children:t(e.labelKey)},e.id))}),a(`div`,{className:`flex-1 min-h-0 overflow-y-auto p-4 sm:p-6 @container/clustertab`,children:[o===`assignments`&&d(Ti,{}),o===`load-balancing`&&d(Fa,{refreshToken:e,onOpenAutoTune:()=>s(`auto-tune`)}),o===`auto-tune`&&d(Wi,{}),o===`roles-nodes`&&d(Va,{}),o===`settings`&&d(qa,{refreshToken:e}),o===`logs`&&d(Xa,{})]})]})}function Q({title:e,children:t}){return a(`div`,{className:`bg-background px-3.5 py-3 min-w-0`,children:[d(`div`,{className:`text-[9px] font-semibold uppercase tracking-[0.14em] text-foreground-subtle mb-2`,children:e}),d(`div`,{className:`flex flex-col gap-1 min-w-0`,children:t})]})}function $({label:e,children:t,overridden:n=!1}){return a(`div`,{className:`flex items-baseline gap-2 text-[11px] leading-snug min-w-0`,children:[d(`span`,{className:`text-foreground-subtle shrink-0 w-24 truncate`,title:e,children:e}),d(`span`,{className:`font-mono tabular-nums text-foreground min-w-0 truncate flex-1`,children:t}),n&&d(eo,{})]})}function eo(){let{t:e}=X();return d(`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 to={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 no({tone:e=`neutral`,children:t,title:n}){return d(`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 ${to[e]}`,children:t})}function ro({children:e}){return d(`div`,{className:`text-[11px] text-foreground-subtle italic`,children:e})}function io({icon:e,label:t,nodeId:n,pinned:r,reason:i,overridden:s}){let{t:c}=X();return a(`div`,{className:`flex items-center gap-2 text-[11px] leading-snug min-w-0`,children:[d(e,{className:`h-3 w-3 text-foreground-subtle shrink-0`}),d(`span`,{className:`text-foreground-subtle w-[4.5rem] shrink-0`,children:t}),n===null?d(`span`,{className:`text-foreground-subtle italic`,children:c(`cameras.configBlocks.unassigned`)}):a(o,{children:[d(`span`,{className:`font-mono text-foreground truncate`,title:n,children:n}),r?a(`span`,{className:`inline-flex items-center gap-0.5 text-[10px] text-warning shrink-0`,title:c(`cameras.configBlocks.manuallyPinned`,`Manually pinned`),children:[d(_,{className:`h-2.5 w-2.5`}),` `,c(`cameras.configBlocks.manual`)]}):d(`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`)})}),s&&d(`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 ao({assignment:e,settings:t,onlineNodes:n,pinPending:r,onDetectionPinChange:i}){let{t:o}=X(),s=e.pinned.detection&&e.detectionNodeId!==null?e.detectionNodeId:`auto`,c=[...new Set([...e.detectionNodeId===null?[]:[e.detectionNodeId],...n.map(e=>e.id)])];return a(Q,{title:o(`cameras.configBlocks.whereItRuns`,`Where it runs`),children:[d(io,{icon:w,label:o(`cameras.configBlocks.detection`,`Detection`),nodeId:e.detectionNodeId,pinned:e.pinned.detection,reason:e.reasons.detection,overridden:t.overriddenKeys.has(`pipelineNodeId`)}),d(io,{icon:m,label:o(`cameras.configBlocks.decoder`,`Decoder`),nodeId:e.decoderNodeId,pinned:e.pinned.decoder,reason:e.reasons.decoder,overridden:t.overriddenKeys.has(`decoderNodeId`)}),d(io,{icon:C,label:o(`cameras.configBlocks.audio`,`Audio`),nodeId:e.audioNodeId,pinned:e.pinned.audio,reason:e.reasons.audio,overridden:t.overriddenKeys.has(`audioNodeId`)}),d(io,{icon:H,label:o(`cameras.configBlocks.source`,`Source`),nodeId:e.sourceNodeId,pinned:!1,reason:`ingest owner`,overridden:!1}),d(`div`,{className:`mt-1.5`,children:a(`select`,{value:s,disabled:r,"aria-label":o(`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:[d(`option`,{value:`auto`,children:o(`cameras.configBlocks.autoLoadBalanced`,`Auto (load balanced)`)}),c.map(e=>d(`option`,{value:e,children:o(`cameras.configBlocks.pinDetection`,{node:n.find(t=>t.id===e)?.name??e})},e))]})})]})}function oo(e){return`${e.width}×${e.height} ${e.codec} @${e.fps}fps`}function so(e,t){if(!(t===null||e===void 0))return e.find(e=>e.profile===t)}function co(e){return e===null?Y.t(`pipeline.configBlocks.fpsDefault`):e===0?Y.t(`pipeline.configBlocks.fpsNative`):`${e} fps`}function lo({streams:e,brokerProfiles:t,settings:n,motionEnabled:r,motionFpsLive:i,cameraSensors:s}){let{t:c}=X(),l=so(t,n.detectionStreamProfile),u=so(t,n.motionStreamProfile),f=n.motionSources.includes(`analyzer`);return a(Q,{title:c(`cameras.configBlocks.streamsMotion`,`Streams & motion`),children:[a($,{label:c(`cameras.configBlocks.detectStream`,`Detect stream`),overridden:n.overriddenKeys.has(`detectionStreamProfile`),children:[n.detectionStreamProfile??`—`,l!==void 0&&` · ${l.width}×${l.height} ${l.codec}`]}),d($,{label:c(`cameras.configBlocks.detectFps`,`Detect FPS`),overridden:n.overriddenKeys.has(`detectionFps`),children:co(n.detectionFps)}),a($,{label:c(`cameras.configBlocks.motionSrc`,`Motion src`),overridden:n.overriddenKeys.has(`motionSources`),children:[n.motionSources.length>0?n.motionSources.map(de).join(` + `):c(`cameras.configBlocks.none`),r===!1&&` · ${c(`cameras.configBlocks.inactive`)}`]}),d($,{label:c(`cameras.configBlocks.cameraSensors`,`Camera sensors`),children:bn(s)}),f&&a(o,{children:[a($,{label:c(`cameras.configBlocks.motionStream`,`Motion stream`),overridden:n.overriddenKeys.has(`motionStreamProfile`),children:[n.motionStreamProfile??`—`,u!==void 0&&` · ${u.width}×${u.height} ${u.codec}`]}),a($,{label:c(`cameras.configBlocks.motionFps`,`Motion FPS`),overridden:n.overriddenKeys.has(`motionFps`),children:[co(n.motionFps),i!==null&&` · ${c(`cameras.configBlocks.liveFps`,{fps:i.toFixed(1)})}`]})]}),d($,{label:c(`cameras.configBlocks.cooldown`,`Cooldown`),overridden:n.overriddenKeys.has(`motionCooldownMs`),children:n.motionCooldownMs===null?c(`cameras.configBlocks.defaultValue`):`${n.motionCooldownMs/1e3}s`}),d(`div`,{className:`mt-1.5 flex flex-col gap-0.5`,children:e.length===0?d(ro,{children:c(`cameras.configBlocks.noStreamsRegistered`,`No streams registered`)}):e.map(e=>a(`div`,{className:`text-[10px] font-mono text-foreground-subtle truncate`,title:e.camStreamId,children:[d(`span`,{className:`text-foreground-muted`,children:e.kind}),` `,oo(e)]},e.camStreamId))})]})}function uo({steps:e,audioModelId:t,audioEnabled:n,audioMode:r}){let{t:i}=X();return a(Q,{title:i(`cameras.configBlocks.pipelineSteps`,`Pipeline steps`),children:[e===void 0?d(ro,{children:i(`cameras.configBlocks.resolving`,`Resolving…`)}):e.length===0?d(ro,{children:i(`cameras.configBlocks.noStepsConfigured`,`No steps configured`)}):d(`div`,{className:`flex flex-wrap gap-1`,children:e.map((e,t)=>d(no,{tone:e.enabled&&e.depth===0?`info`:`neutral`,title:e.modelId??e.addonId,children:a(`span`,{className:e.enabled?``:`line-through opacity-60`,children:[e.depth>0&&d(`span`,{className:`opacity-50`,children:`↳ `}),e.addonId,e.modelId!==null&&a(`span`,{className:`font-mono opacity-75`,children:[` · `,e.modelId]})]})},`${e.addonId}-${t}`))}),d(`div`,{className:`mt-1`,children:a($,{label:i(`cameras.configBlocks.audioClass`,`Audio class.`),children:[r??`—`,n!==null&&` · ${i(n?`cameras.configBlocks.running`:`cameras.configBlocks.off`)}`,t!==null&&` · ${t}`]})})]})}var fo={ready:`success`,installing:`info`,verifying:`info`,idle:`neutral`,failed:`danger`};function po({detection:e,live:t,detectionMode:n,modeOverridden:r}){let i=L(),{t:o}=X();if(e===null)return a(Q,{title:o(`cameras.runtimeBlocks.detectionRuntime`,`Detection runtime`),children:[d($,{label:o(`cameras.runtimeBlocks.mode`,`Mode`),overridden:r,children:n??`—`}),d(ro,{children:o(`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,f=t?.queueDepth??e.queueDepth,p=vt(s,i),m=s===`active`&&c===0;return a(Q,{title:o(`cameras.runtimeBlocks.detectionRuntime`,`Detection runtime`),children:[a(`div`,{className:`flex items-center gap-1.5 mb-0.5`,children:[a(`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:[d(Ct,{phase:s,className:`h-2.5 w-2.5`}),p.label]}),t!==void 0&&d(`span`,{className:`text-[9px] text-foreground-subtle uppercase tracking-wider`,children:o(`common.live`)})]}),d($,{label:o(`cameras.runtimeBlocks.mode`,`Mode`),overridden:r,children:n??`—`}),a($,{label:`FPS`,children:[d(`span`,{className:m?`text-danger font-semibold`:``,children:c.toFixed(1)}),d(`span`,{className:`ml-1 text-foreground-subtle`,children:o(`cameras.runtimeBlocks.configuredFps`,{fps:l.toFixed(0)})})]}),a($,{label:o(`cameras.runtimeBlocks.inference`,`Inference`),children:[u.toFixed(0),` ms`,f>0&&d(`span`,{className:`ml-1 text-warning`,children:o(`cameras.runtimeBlocks.queue`,{depth:f})}),t!==void 0&&t.droppedFrames>0&&d(`span`,{className:`ml-1 text-warning`,children:o(`cameras.runtimeBlocks.drops`,{count:t.droppedFrames})})]}),a($,{label:o(`cameras.runtimeBlocks.engine`,`Engine`),children:[e.engine.backend,` · `,e.engine.device]}),a($,{label:o(`cameras.runtimeBlocks.provisioning`,`Provisioning`),children:[d(no,{tone:fo[e.provisioning.state]??`neutral`,children:e.provisioning.state}),e.provisioning.error!==void 0&&a(`span`,{className:`text-danger text-[10px]`,children:[` `,e.provisioning.error]})]})]})}function mo({broker:e}){let{t}=X();return e===null?d(Q,{title:t(`cameras.runtimeBlocks.streamBroker`,`Stream broker`),children:d(ro,{children:t(`cameras.runtimeBlocks.brokerStageInactiveOrUnreachable`,`Broker stage inactive or unreachable`)})}):a(Q,{title:t(`cameras.runtimeBlocks.streamBroker`,`Stream broker`),children:[e.profiles.length===0?d(ro,{children:t(`cameras.runtimeBlocks.noBrokerProfiles`,`No broker profiles`)}):d(`div`,{className:`flex flex-col gap-1`,children:e.profiles.map(e=>{let n=e.status===`streaming`,r=n&&e.inFps===0;return a(`div`,{className:`flex items-center gap-2 text-[11px] font-mono tabular-nums min-w-0`,children:[d(`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}),d(`span`,{className:`text-foreground w-10 shrink-0 truncate`,title:e.profile,children:e.profile}),a(`span`,{className:`text-foreground-subtle truncate`,children:[e.width,`×`,e.height,` `,e.codec]}),d(`span`,{className:`ml-auto shrink-0 ${r?`text-danger`:`text-foreground`}`,children:t(`cameras.runtimeBlocks.fpsValue`,{value:e.inFps===null?`—`:e.inFps.toFixed(0)})}),a(`span`,{className:`text-foreground-subtle shrink-0`,title:t(`cameras.runtimeBlocks.subscribers`,`Subscribers`),children:[`×`,e.subscribers]})]},e.profile)})}),a(`div`,{className:`mt-1.5 flex flex-wrap gap-1`,children:[d(no,{tone:e.webrtcSessions>0?`info`:`neutral`,children:t(`cameras.runtimeBlocks.webrtc`,{count:e.webrtcSessions})}),d(no,{tone:e.rtspRestream?`success`:`neutral`,children:e.rtspRestream?t(`cameras.runtimeBlocks.restreamOn`):t(`cameras.runtimeBlocks.restreamOff`)})]})]})}function ho({decoder:e}){let{t}=X();return e===null?d(Q,{title:t(`cameras.runtimeBlocks.decoder`,`Decoder`),children:d(ro,{children:t(`cameras.runtimeBlocks.decoderStageInactiveOrUnreachable`,`Decoder stage inactive or unreachable`)})}):d(Q,{title:t(`cameras.runtimeBlocks.decoder`,`Decoder`),children:d($,{label:t(`cameras.runtimeBlocks.node`,`Node`),children:e.nodeId})})}e();var go=`pipeline-orchestrator`,_o={healthy:`bg-success`,idle:`bg-warning`,error:`bg-danger`},vo={healthy:`pipeline.cameraPipelineCard.healthHealthy`,idle:`pipeline.cameraPipelineCard.healthIdle`,error:`pipeline.cameraPipelineCard.healthError`};function yo({problems:e}){return d(`div`,{role:`alert`,className:`flex flex-col border-b border-border`,children:e.map(e=>a(`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:[d(v,{className:`h-3.5 w-3.5 shrink-0 mt-px`}),d(`span`,{className:`min-w-0`,children:e.message})]},e.code))})}function bo({deviceId:e,name:t,online:r,status:i,live:o,onlineNodes:s}){let{t:l}=X(),u=c(),{data:f}=ft({addonId:go,deviceId:e,nodeId:`hub`},{staleTime:3e4}),{data:p}=Ne({deviceId:e},{staleTime:3e4}),m=n(()=>pn(f),[f]),h=n(()=>p===void 0?void 0:kn(p.steps),[p]),g=n(()=>i===void 0?[]:yn(i),[i]),_=()=>{u.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCameraStatuses`]]}),u.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineAssignments`]]})},v=Dt({onSuccess:_}),y=De({onSuccess:_}),b=t=>{t===`auto`?y.mutate({deviceId:e}):v.mutate({deviceId:e,agentNodeId:t})},x=i===void 0?`idle`:An(i),S=g.some(e=>e.severity===`error`),C=g.length>0,w=S?`border-danger/50`:C?`border-warning/40`:`border-border`;return a(`article`,{"aria-label":l(`cameras.cameraPipelineCard.pipelineStatus`,`{{name}} pipeline status`,{name:t}),className:`rounded-lg border ${w} bg-background overflow-hidden`,children:[a(`header`,{className:`flex items-center gap-2.5 px-4 py-2.5 border-b border-border bg-surface/50 min-w-0`,children:[d(`span`,{className:`inline-block h-2 w-2 rounded-full shrink-0 ${S?`bg-danger`:_o[x]}`,title:S?l(`common.error`,`Error`):l(vo[x]),"aria-label":S?l(`common.error`,`Error`):l(vo[x]),role:`img`}),d(`h3`,{className:`text-[13px] font-semibold text-foreground truncate`,title:t,children:t}),a(`span`,{className:`text-[10px] text-foreground-subtle shrink-0`,children:[`#`,e]}),!r&&d(no,{tone:`danger`,children:l(`common.offline`)}),a(`span`,{className:`ml-auto flex items-center gap-1.5 shrink-0`,children:[m.detectionMode!==null&&d(no,{tone:m.detectionMode===`disabled`?`warning`:m.detectionMode===`always-on`?`info`:`neutral`,title:l(`cameras.cameraPipelineCard.objectDetectionMode`,`Object detection mode`),children:m.detectionMode===`disabled`?l(`cameras.cameraPipelineCard.detectionOff`,`detection off`):m.detectionMode}),i?.recording!=null&&(i.recording.active?a(no,{tone:`danger`,title:l(`cameras.cameraPipelineCard.recording`,`Recording ({{mode}})`,{mode:i.recording.mode}),children:[d(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full bg-danger animate-pulse`}),`REC`]}):i.recording.mode!==`off`&&d(no,{tone:`neutral`,title:l(`cameras.cameraPipelineCard.recordingMode`,`Recording mode`),children:l(`pipeline.cameraPipelineCard.recMode`,{mode:i.recording.mode})}))]})]}),g.length>0&&d(yo,{problems:g}),i===void 0?d(`div`,{className:`px-4 py-5 text-[11px] text-foreground-subtle italic`,children:l(`cameras.cameraPipelineCard.noPipelineStatusYetThe`,`No pipeline status yet — the orchestrator has not composed a snapshot for this camera.`)}):a(`div`,{className:`grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-px bg-border`,children:[d(ao,{assignment:i.assignment,settings:m,onlineNodes:s,pinPending:v.isPending||y.isPending,onDetectionPinChange:b}),d(po,{detection:i.detection,live:o,detectionMode:m.detectionMode,modeOverridden:m.overriddenKeys.has(`detectionMode`)}),d(uo,{steps:h,audioModelId:p?.audio?.modelId??null,audioEnabled:i.audio?.enabled??p?.audio?.enabled??null,audioMode:m.audioMode}),d(lo,{streams:i.source.streams,brokerProfiles:i.broker?.profiles,settings:m,motionEnabled:i.motion?.enabled??null,motionFpsLive:i.motion?.fps??null,cameraSensors:i.cameraSensors}),d(mo,{broker:i.broker}),d(ho,{decoder:i.decoder})]})]})}e();var xo=5e3,So=1e4,Co=5e3;function wo(e){let i=c(),{data:a,isLoading:o}=ln(),{data:s,isLoading:l}=rn({},{refetchInterval:xo}),{nodes:u}=G();t(()=>{e!==0&&i.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCameraStatuses`]]})},[e,i]);let[d,f]=r(new Map);qt(ce.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})}),t(()=>{if(d.size===0)return;let e=setInterval(()=>{f(e=>{let t=Date.now()-So,n=!1,r=new Map(e);for(let[i,a]of e)a.timestamp<t&&(r.delete(i),n=!0);return n?r:e})},Co);return()=>clearInterval(e)},[d.size]);let p=n(()=>{let e=new Map;for(let t of s??[])e.set(t.deviceId,t);return e},[s]);return{rows:n(()=>(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:n(()=>(u??[]).filter(e=>e.isOnline).map(e=>({id:e.id,name:e.name})),[u]),isLoading:o||l}}e();function To({refreshToken:e}){let{t}=X(),{rows:r,liveMetrics:i,onlineNodes:o,isLoading:s}=wo(e),c=n(()=>[...r.map(e=>{let t=e.status===void 0?[]:yn(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),[r]),l=n(()=>{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&&r.length===0?d(`div`,{className:`flex items-center justify-center h-full text-sm text-foreground-subtle`,children:t(`cameras.camerasOverview.loadingCameraPipelines`,`Loading camera pipelines…`)}):r.length===0?d(`div`,{className:`flex items-center justify-center h-full text-sm text-foreground-subtle`,children:t(`cameras.camerasOverview.noCamerasFound`,`No cameras found`)}):d(`div`,{className:`h-full overflow-y-auto`,children:a(`div`,{className:`max-w-6xl mx-auto flex flex-col gap-3 px-4 py-4`,children:[a(`div`,{className:`flex items-center gap-4 text-[11px] text-foreground-subtle px-1`,children:[d(`span`,{children:d(dn,{i18nKey:`pipeline.camerasOverview.camerasTotal`,values:{count:l.total},components:{b:d(`span`,{className:`font-semibold text-foreground`})}})}),d(`span`,{children:d(dn,{i18nKey:`pipeline.camerasOverview.activelyInferring`,values:{count:l.active},components:{b:d(`span`,{className:`font-semibold text-success`})}})}),a(`span`,{children:[d(`span`,{className:`font-semibold ${l.issues>0?`text-danger`:`text-foreground`}`,children:l.issues}),` `,t(`cameras.camerasOverview.withIssues`,`with issues`)]}),d(`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})=>d(bo,{deviceId:e.deviceId,name:e.name,online:e.online,status:e.status,live:i.get(e.deviceId),onlineNodes:o},e.deviceId))]})})}e();var Eo=`__cluster__`;function Do(e){return e===`cameras`?`cameras`:`nodes`}function Oo({viewMode:e,onNodes:t,onCameras:n}){let{t:r}=X();return a(`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:[d(`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`)}),d(`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 ko(){let{t:e}=X(),[n,i]=fn(),s=Do(n.get(`view`)),c=n.get(`node`)??`__cluster__`,[l,u]=r(0),[f,p]=r(!1);return t(()=>{s===`nodes`&&!n.get(`node`)&&i({view:`nodes`,node:Eo},{replace:!0})},[s,n,i]),a(Mt,{icon:ve,title:e(`pipeline.pipeline`,`Pipeline`),subtitle:e(`pipeline.detectionPlacementLoadAndPer`,`Detection placement, load and per-camera runtime across the cluster.`),actions:a(K,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>u(e=>e+1),title:e(`common.refresh`,`Refresh`),children:[d(ee,{className:`h-3.5 w-3.5`}),e(`common.refresh`,`Refresh`)]}),nav:d(Oo,{viewMode:s,onNodes:()=>{i({view:`nodes`,node:c},{replace:!0})},onCameras:()=>{i({view:`cameras`},{replace:!0})}}),className:`flex h-full min-h-0 flex-col overflow-hidden`,children:[s===`nodes`&&a(K,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>p(e=>!e),"aria-expanded":f,className:`flex w-full shrink-0 justify-between border-b border-border md:hidden`,children:[d(`span`,{children:e(f?`pipeline.hideNodeList`:`pipeline.showNodeList`)}),d(ne,{className:[`h-4 w-4 transition-transform`,f?`rotate-180`:``].join(` `)})]}),d(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden md:flex-row`,children:s===`nodes`?a(o,{children:[d(`aside`,{className:[f?`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:d(Zn,{selectedNodeId:c,onSelect:e=>{i({view:`nodes`,node:e},{replace:!0}),p(!1)},refreshToken:l})}),d(`section`,{className:`min-h-0 flex-1 overflow-hidden`,children:c===`__cluster__`?d($a,{refreshToken:l}):d(wi,{nodeId:c,refreshToken:l})})]}):d(`section`,{className:`min-h-0 flex-1 overflow-hidden`,children:d(To,{refreshToken:l})})})]})}export{ko as PipelinePage};
|
|
1
|
+
import{$ as e,B as t,G as n,J as r,L as i,S as a,b as o,i as s,o as c,p as l,q as u,x as d}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 f,D as p,Fr as m,It as h,N as g,Nn as _,Nt as v,O as y,Or as b,T as x,V as S,Xn as C,Xr as w,Zt as T,_t as E,b as D,bn as ee,cn as O,dn as k,dt as A,ir as j,j as M,k as N,mn as P,or as te,ot as F,rr as I,sa as L,ta as R,ur as z,ut as B,v as V,xi as ne,xn as H,y as re,yi as U,z as W}from"./player-overlays-D5ZBZ0eM.js";import{ar as ie,c as ae,cr as oe,da as se,dr as ce,lr as le,or as ue,rr as de,s as fe,sr as pe,u as me,ur as he}from"./client-CJZuPHbz.js";import{l as ge,t as _e,u as ve}from"./video-CQJAIcvp.js";import{a as ye,i as be,n as xe,r as Se,t as Ce}from"./usb-BBQDAd-3.js";import{t as we}from"./crop-CJTlG5-P.js";import{t as Te}from"./layers-DAJqwsng.js";import{n as Ee}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_trpc_mf_1_react_mf_2_query__loadShare__.js-DdJYWyu3.js";import{$c as De,$u as G,Bn as Oe,Ct as ke,Dc as Ae,Fc as je,Fr as K,Gu as Me,Hr as q,Ic as Ne,In as Pe,J as Fe,Jc as Ie,Jn as Le,Kn as Re,Ku as ze,Lc as Be,Ln as Ve,Mc as He,Nc as Ue,Nn as We,Nr as Ge,Nu as Ke,Oc as qe,Pn as Je,Q as Ye,Qc as Xe,Qr as Ze,Rc as Qe,Rn as $e,Ru as et,Sn as tt,St as nt,Tc as rt,Wt as it,X as at,Xc as ot,Y as st,Yc as ct,Yn as lt,Z as ut,Zc as dt,Zr as ft,Zt as pt,_c as mt,_n as ht,_r as gt,_t,an as vt,ar as yt,bn as bt,cc as xt,cr as St,ct as Ct,dc as wt,ed as Tt,et as Et,fc as Dt,gc as Ot,gn as kt,gr as At,hc as jt,ht as Mt,id as Nt,ir as Pt,jc as Ft,kc as It,lc as Lt,ln as Rt,mc as zt,mn as J,nd as Bt,nr as Vt,oc as Ht,or as Ut,pc as Wt,qc as Gt,r as Kt,rd as qt,rr as Jt,sc as Yt,sr as Xt,td as Zt,ti as Qt,tl as $t,to as en,tr as tn,wc as nn,xc as rn,xn as an,zc as on,zn as sn,zu as cn}from"./src-El9yRQEE.js";import{t as Y}from"./i18n-CvoV4ITH.js";import{t as X}from"./useTranslation-D3Is_4B6.js";import{ar as ln,dr as un,fr as dn,gr as fn}from"./index-DgzFfJ-E.js";import{_ as pn,a as mn,b as hn,c as gn,d as _n,f as vn,g as yn,h as bn,i as xn,l as Sn,m as Cn,n as wn,p as Tn,r as En,s as Dn,u as On,v as kn,y as An}from"./step-inspector-model-Be_ULwEg.js";import"./useEventInvalidation-BHInrZJO.js";import{t as jn}from"./NodeAddonsSettingsPanel-BdXMzxN1.js";import{a as Mn,c as Nn,d as Pn,g as Fn,h as In,i as Ln,l as Rn,n as zn,o as Bn,p as Vn,r as Hn,s as Un,t as Wn}from"./board-model-CGqWH_FA.js";e();function Gn(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 Kn(e){return e}function qn(e,t){for(let[n,r]of Object.entries(e??{}))if(n===t)return r}function Jn(e,t){return typeof e==`boolean`?e:Kn(t)}function Yn(e,t){return{pipeline:Jn(qn(e,`detect`),t),audio:Jn(qn(e,`audio`),t),ingest:Jn(qn(e,`ingest`),t)}}function Xn(e,t,n){let r=e?.find(e=>e.nodeId===t);return Yn(r?.settings,n)}function Zn({selectedNodeId:e,onSelect:t,refreshToken:n}){let r=L(),{t:i}=X(),{nodes:s}=Tt(),{data:c}=Ae(void 0),{data:l}=Ft(void 0),u=new Map;for(let e of c??[])u.set(e.agentNodeId,(u.get(e.agentNodeId)??0)+1);let f=s??[],p=f.filter(e=>e.isOnline).length,m=f.filter(e=>!e.isOnline).length;return a(`div`,{className:`flex flex-col h-full`,children:[a(`button`,{type:`button`,onClick:()=>t(Eo),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:[d(ge,{className:`h-4 w-4 flex-shrink-0`}),a(`div`,{className:`min-w-0 flex-1`,children:[d(`div`,{className:`text-xs font-semibold truncate`,children:i(`pipeline.nodeList.cluster`,`Cluster`)}),d(`div`,{className:`text-[10px] text-foreground-subtle`,children:i(`pipeline.nodeList.assignmentsLoadBalancingRoles`,`Assignments, load balancing, roles`)})]})]}),d(`div`,{className:`flex-1 overflow-y-auto`,children:f.map(n=>{let s=e===n.id,c=u.get(n.id)??0,f=n.isHub?k:w,p=Xn(l,n.id,n.isHub),m=n.isOnline?null:it(Gn(n.lastSeen),r);return a(`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 ${s?`bg-primary/10 text-primary`:`text-foreground hover:bg-surface-hover`}${n.isOnline?``:` opacity-60`}`,children:[d(f,{className:`h-4 w-4 flex-shrink-0`}),a(`div`,{className:`min-w-0 flex-1`,children:[a(`div`,{className:`flex items-center gap-2`,children:[d(`span`,{className:`text-xs font-semibold truncate`,children:n.name}),n.isHub&&d(`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&&d(`span`,{className:`h-1.5 w-1.5 rounded-full bg-danger flex-shrink-0`}),n.isOnline&&d(`span`,{className:`h-1.5 w-1.5 rounded-full bg-success flex-shrink-0`})]}),a(`div`,{className:`text-[10px] text-foreground-subtle flex items-center gap-2 mt-0.5`,children:[d(`span`,{children:i(`common.coresCount`,{count:n.cpuCores})}),d(`span`,{children:`•`}),a(`span`,{children:[Math.round(n.memoryMB/1024),` GB`]}),c>0&&a(o,{children:[d(`span`,{children:`•`}),a(`span`,{className:`inline-flex items-center gap-0.5 text-foreground`,children:[d(_e,{className:`h-2.5 w-2.5`}),c]})]}),!n.isOnline&&a(o,{children:[d(`span`,{children:`•`}),a(`span`,{className:`text-danger`,children:[i(`common.offline`),m===null?``:` · ${m}`]})]})]}),a(`div`,{className:`mt-0.5 flex items-center gap-1`,children:[d(q,{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`)}),d(q,{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)})}),a(`div`,{className:`px-4 py-2 border-t border-border text-[10px] text-foreground-subtle flex items-center justify-between`,children:[d(`span`,{children:i(`common.onlineCount`,{count:p})}),m>0&&d(`span`,{className:`text-danger`,children:i(`common.offlineCount`,{count:m})})]})]})}function Qn({nodeId:e,refreshToken:t}){let{t:n}=X(),{nodes:r}=Tt(),i=r?.find(t=>t.id===e),s=Zt(`pipeline.runner-load-snapshot`,t=>t.nodeId===e)?.load??null;return i?a(`div`,{className:`px-6 py-4 border-b border-border`,children:[a(`div`,{className:`flex items-center gap-2 mb-1`,children:[d(`h2`,{className:`text-base font-semibold text-foreground`,children:i.name}),i.isOnline?d(`span`,{className:`text-[10px] px-2 py-0.5 rounded-full bg-success/10 text-success`,children:n(`common.online`)}):d(`span`,{className:`text-[10px] px-2 py-0.5 rounded-full bg-danger/10 text-danger`,children:n(`common.offline`)}),i.isHub&&d(`span`,{className:`text-[9px] uppercase tracking-wider text-foreground-subtle border border-border rounded px-1 py-0.5`,children:n(`common.hubWord`)})]}),a(`div`,{className:`text-[11px] text-foreground-subtle flex items-center gap-2 flex-wrap`,children:[d(`span`,{children:i.cpuModel??`CPU`}),d(`span`,{children:`•`}),d(`span`,{children:n(`common.coresCount`,{count:i.cpuCores})}),d(`span`,{children:`•`}),a(`span`,{children:[Math.round(i.memoryMB/1024),` GB`]}),s&&a(o,{children:[d(`span`,{children:`•`}),d(`span`,{children:n(`pipeline.nodeDetailHeader.cameras`,{attached:s.attachedCameras,active:s.activeCameras})}),d(`span`,{children:`•`}),d(`span`,{children:n(`pipeline.nodeDetailHeader.avgInference`,{ms:s.avgInferenceTimeMs.toFixed(0)})}),d(`span`,{children:`•`}),d(`span`,{children:n(`pipeline.nodeDetailHeader.queue`,{depth:s.queueDepthTotal})}),s.hardware.hasGpu&&a(o,{children:[d(`span`,{children:`•`}),d(`span`,{className:`text-success`,children:`GPU`})]})]})]})]}):d(`div`,{className:`px-6 py-4 border-b border-border`,children:a(`div`,{className:`text-xs text-foreground-subtle`,children:[n(`pipeline.nodeDetailHeader.nodeNotFound`,`Node not found:`),` `,e]})})}var $n=[`assignments`,`tree`,`engines`,`logs`];function er({refreshToken:e,nodeId:t}){let{t:i}=X(),[o,s]=r(new Map),{nodes:c}=G();qt(`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}=mt(void 0),u=n(()=>{let e=new Map;for(let t of l??[])e.set(t.nodeId,t.deviceCount);return e},[l]),f=n(()=>{let e=new Map,t=Date.now()-3e4;for(let n of o.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},[o]),p=n(()=>{let e=new Map;for(let t of c)e.set(t.id,t.shortName);return e},[c]),m=n(()=>{let e=0,t=0,n=0,r=0,i=0;for(let a of f.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}},[f,c]);if(t){let e=f.get(t);return a(`div`,{className:`@container/liveload`,children:[d(`h3`,{className:`text-sm font-semibold text-foreground mb-2`,children:i(`pipeline.liveLoadPanel.liveLoad`,`Live load`)}),a(`div`,{className:`grid grid-cols-2 @md/liveload:grid-cols-3 @3xl/liveload:grid-cols-5 gap-2 mb-3`,children:[d(Z,{label:`FPS`,value:e?e.totalFps.toFixed(1):`—`}),d(Z,{label:i(`pipeline.liveLoadPanel.activeAttached`,`Active / Attached`),value:e?`${e.activeCameras}/${e.attachedCameras}`:`—`}),d(Z,{label:i(`pipeline.liveLoadPanel.avgInferMs`,`Avg infer ms`),value:e&&e.attachedCameras>0?(e.totalInferenceWeighted/e.attachedCameras).toFixed(0):`—`}),d(Z,{label:i(`pipeline.liveLoadPanel.queue`,`Queue`),value:e?String(e.queueDepth):`—`}),d(Z,{label:i(`pipeline.liveLoadPanel.audio`,`Audio`),value:String(u.get(t)??`—`)})]})]})}let h=[...f.entries()].toSorted(([e],[t])=>e===`hub`?-1:t===`hub`?1:e.localeCompare(t));return a(`div`,{className:`@container/liveload`,children:[d(`h3`,{className:`text-sm font-semibold text-foreground mb-2`,children:i(`pipeline.liveLoadPanel.liveLoad`,`Live load`)}),a(`div`,{className:`grid grid-cols-2 @md/liveload:grid-cols-3 @3xl/liveload:grid-cols-5 gap-2 sm:gap-3 mb-3`,children:[d(Z,{label:i(`pipeline.liveLoadPanel.totalAgents`,`Total agents`),value:`${m.onlineAgents}/${m.totalAgents}`}),d(Z,{label:i(`pipeline.liveLoadPanel.activeAttached`,`Active / Attached`),value:`${m.activeCameras}/${m.attachedCameras}`}),d(Z,{label:i(`pipeline.liveLoadPanel.totalFps`,`Total FPS`),value:m.totalFps.toFixed(1)}),d(Z,{label:i(`pipeline.liveLoadPanel.avgInferenceMs`,`Avg inference ms`),value:m.avgInferenceTimeMs.toFixed(0)}),d(Z,{label:i(`pipeline.liveLoadPanel.queueDepth`,`Queue depth`),value:String(m.queueDepth)})]}),d(`div`,{className:`rounded-lg border border-border overflow-x-auto`,children:a(`table`,{className:`w-full text-xs min-w-[480px]`,children:[d(`thead`,{className:`bg-surface`,children:a(`tr`,{className:`text-foreground-subtle text-[10px] uppercase tracking-wider`,children:[d(`th`,{className:`text-left px-3 py-2`,children:i(`pipeline.liveLoadPanel.agent`,`Agent`)}),d(`th`,{className:`text-right px-3 py-2`,children:`FPS`}),d(`th`,{className:`text-right px-3 py-2`,children:i(`pipeline.liveLoadPanel.cameras`,`Cameras`)}),d(`th`,{className:`text-right px-3 py-2`,children:i(`pipeline.liveLoadPanel.inferenceMs`,`Inference ms`)}),d(`th`,{className:`text-right px-3 py-2`,children:i(`pipeline.liveLoadPanel.queue`,`Queue`)}),d(`th`,{className:`text-right px-3 py-2`,children:i(`pipeline.liveLoadPanel.audio`,`Audio`)})]})}),a(`tbody`,{children:[h.map(([e,t])=>a(`tr`,{className:`border-t border-border`,children:[d(`td`,{className:`px-3 py-2 text-foreground font-medium`,children:p.get(e)??e}),d(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t.totalFps.toFixed(1)}),d(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t.attachedCameras}),d(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t.attachedCameras>0?(t.totalInferenceWeighted/t.attachedCameras).toFixed(0):`—`}),d(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t.queueDepth}),d(`td`,{className:`px-3 py-2 text-right text-foreground`,children:u.get(e)??`—`})]},e)),h.length===0&&d(`tr`,{children:d(`td`,{colSpan:6,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:i(`pipeline.liveLoadPanel.noCameraMetricsReceivedYet`,`No camera metrics received yet`)})})]})]})})]})}function Z({label:e,value:t}){return a(`div`,{className:`rounded-lg border border-border bg-surface/60 p-3`,children:[d(`div`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle mb-1`,children:e}),d(`div`,{className:`text-lg font-semibold text-foreground`,children:t})]})}var tr={active:!1,pinned:!1,nodeId:null,reason:``};function nr(e,t){return e.deviceName.localeCompare(t.deviceName)||e.deviceId-t.deviceId}function rr(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??``}:tr,o=n?{active:!0,pinned:n.pinned,nodeId:n.nodeId,reason:``}:tr;return{deviceId:e.id,deviceName:e.name,disabled:e.disabled===!0,pipeline:a,detection:a,decoder:tr,audio:o}}).toSorted(nr)}function ir(e,t,n){return{active:e!==null,pinned:t,nodeId:e,reason:n??``}}function ar(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:ir(t.detectionNodeId,t.pinned.detection,t.reasons.detection),decoder:ir(t.decoderNodeId,t.pinned.decoder,t.reasons.decoder),audio:ir(t.audioNodeId,t.pinned.audio,t.reasons.audio)}})}function or(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(nr)}function sr(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 cr(e){let t=new Map(e.map(e=>[e.id,e.name]));return e=>t.get(e)??Y.t(`helpers.assignmentRows.cameraFallback`,{id:e})}function lr(e,t,n){let r=[...new Set([...e.nodeId===null?[]:[e.nodeId],...t.map(e=>e.id)])];return[{value:`auto`,label:Y.t(`helpers.assignmentRows.auto`)},...r.map(e=>({value:e,label:Y.t(`helpers.assignmentRows.pinTo`,{node:n(e)})}))]}function ur({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 d(bt,{roleId:e,roleLabel:t,nodeName:r(o),colorId:tt(i,o),emphasized:s,pinned:n.pinned})}function dr({detection:e,decoder:t,audio:n,nameOf:r,colorByNodeId:i,emphasizeOnNodeId:o}){let s=(e,t,n)=>d(ur,{roleId:e,roleLabel:t,state:n,nameOf:r,colorByNodeId:i,emphasizeOnNodeId:o},e);return a(`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 fr({snap:e}){let t=L(),{t:n}=X();if(e===void 0)return d(`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:o,queueDepth:s,configuredFps:c,droppedFrames:l}=e.metrics,u=vt(r,t);return a(`div`,{className:`flex h-8 min-w-0 flex-col justify-center font-mono text-[10px] leading-tight tabular-nums`,children:[a(`span`,{className:`inline-flex min-w-0 items-center gap-1 ${u.textColor}`,children:[d(Ct,{phase:r,className:`h-2.5 w-2.5 shrink-0`}),d(`span`,{className:`truncate font-semibold uppercase tracking-wider`,children:u.label}),d(`span`,{className:`text-foreground`,children:i.toFixed(1)}),d(`span`,{className:`text-foreground-subtle`,children:n(`pipeline.assignmentStatusCell.configuredFps`,{fps:c.toFixed(0)})})]}),a(`span`,{className:`truncate text-foreground-subtle`,children:[d(`span`,{className:`text-foreground`,children:o.toFixed(0)}),` ms`,s>0&&a(`span`,{className:`ml-1 text-warning`,children:[`q`,s]}),d(`span`,{className:l>0?`ml-1 text-warning`:`ml-1`,children:n(`pipeline.assignmentStatusCell.drops`,{count:l})})]})]})}e();var pr=1e4,mr=5e3;function hr(e){let[n,i]=r(new Map);return qt(`pipeline.camera-metrics-snapshot`,t=>{let n=t.data;typeof n.deviceId==`number`&&(e!==void 0&&n.nodeId!==e||i(e=>new Map(e).set(n.deviceId,n)))}),t(()=>{if(n.size===0)return;let e=setInterval(()=>{i(e=>{let t=Date.now()-pr,n=[...e].filter(([,e])=>e.timestamp>=t);return n.length===e.size?e:new Map(n)})},mr);return()=>clearInterval(e)},[n.size]),n}var gr=3e5;function _r({state:e,onlineNodes:t,nameOf:n,pending:r,onChange:i}){let{t:a}=X();return d(Ke,{"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:[...lr(e,t,n)],onChange:e=>i(e.target.value)})}function vr({deviceId:e,nodeId:t}){let{t:n}=X(),r=c(),{data:i}=qe({deviceId:e},{refetchOnMount:`always`}),{data:a}=rt({nodeId:t},{staleTime:gr}),o=ct({onSuccess:()=>{r.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineDevicePin`]]})}});if(i===void 0||a===void 0)return d(`span`,{className:`text-[10px] italic text-foreground-subtle`,children:n(`assignments.placementControls.accelerator`,`accelerator: …`)});let s=a.devices??[],l=s.filter(e=>e.enabled),u=i?.deviceKey??`auto`,f=u!==`auto`&&!l.some(e=>e.key===u),p=s.find(e=>e.key===u),m=[{value:`auto`,label:n(`assignments.placementControls.anyAccelerator`,`Any accelerator`)},...f?[{value:u,label:n(`pipeline.placementControls.notEnabled`,{name:p?`${Le(p)} (${u})`:u})}]:[],...l.map(e=>({value:e.key,label:`${Le(e)} · ${e.format}`}))];return d(Ke,{"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})})}e();function yr(e){let t=u(null);return e.nodeId!==null&&(t.current=e),t.current}function br({deviceId:e,state:t,...n}){let{t:r}=X(),i=yr(t);return a(`div`,{className:`grid w-80 grid-cols-2 gap-1.5`,children:[d(_r,{state:t,...n}),i?.nodeId==null?d(Ke,{"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`)}]}):d(vr,{deviceId:e,nodeId:i.nodeId})]})}function xr({state:e,nameOf:t}){let{t:n}=X(),r=yr(e);if(r?.nodeId==null)return d(`span`,{className:`text-[11px] text-foreground-subtle`,children:n(`assignments.clusterRowCells.noSessionYet`,`— no session yet`)});let i=e.active&&e.nodeId!==null,o=r.pinned?`pinned`:`auto · ${r.reason||`capacity`}`;return a(`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:[a(`span`,{className:`flex min-w-0 items-center gap-1.5 text-xs`,children:[d(`span`,{"aria-hidden":!0,className:`h-1.5 w-1.5 shrink-0 rounded-full ${i?`bg-success`:`bg-foreground-subtle/40`}`}),d(`span`,{"data-testid":`resolved-placement-node`,className:`truncate font-medium ${i?`text-foreground`:`text-foreground-muted`}`,children:t(r.nodeId)})]}),d(`span`,{className:`truncate pl-3 text-[10px] ${r.pinned?`text-warning`:`text-foreground-subtle`}`,children:i?o:n(`assignments.clusterRowCells.idleLastSession`,`{{how}} · idle, last session`,{how:o})})]})}function Sr({deviceId:e,deviceName:t}){let{t:n}=X(),[i,s]=r(!1);return a(o,{children:[d(cn,{icon:H,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:()=>s(!0)}),d(Vt,{open:i,onOpenChange:s,children:a(Pt,{width:`lg`,scroll:`body`,placement:`sheet-on-mobile`,children:[d(Xt,{children:d(St,{children:n(`pipeline.clusterRowCells.brokersTitle`,{device:t})})}),d(Jt,{children:i&&d(tn,{widgetId:`stream-broker/stream-broker-panel`,host:`device-tab`,deviceId:e,instanceId:`pipeline-row/${e}`,config:{variant:`compact`}})})]})})]})}function Cr(e){return e.hasFreshMetrics?`active`:e.hasPipelineAssignment?`recently-active`:`inactive`}function wr(e,t){return t.size===0?!0:t.has(e)}var Tr=[{value:`active`,get label(){return Y.t(`helpers.cameraActivity.active`)}},{value:`recently-active`,get label(){return Y.t(`helpers.cameraActivity.recentlyActive`)}},{value:`inactive`,get label(){return Y.t(`helpers.cameraActivity.inactive`)}}];e();var Er=[`pipeline.camera-assigned`,`pipeline.camera-unassigned`,`pipeline.camera-updated`,`agent.online`,`agent.offline`];function Dr(e){for(let t of[`getPipelineAssignments`,`getAudioAssignments`,`getCameraStatuses`])e.invalidateQueries({queryKey:[[`pipelineOrchestrator`,t]]})}function Or(){let{t:e}=X(),t=c();Kt([`pipelineOrchestrator`,`getPipelineAssignments`],Er),Kt([`pipelineOrchestrator`,`getAudioAssignments`],Er),Kt([`pipelineOrchestrator`,`getCameraStatuses`],Er);let{data:i}=en({isCamera:!0,projection:`slim`}),{data:o}=Ae(void 0),{data:s}=Ot(void 0),{data:l}=rn({}),{data:u}=Ft(void 0),{nodes:f}=G(),p=hr(),m=n(()=>sr(f),[f]),h=n(()=>an(u),[u]),g=n(()=>f.filter(e=>e.isOnline).map(e=>({id:e.id,name:e.name})),[f]),_=n(()=>ar(rr((i??[]).map(e=>({id:e.id,name:e.name,disabled:e.disabled})),o??[],s??[]),l??[]),[i,o,s,l]),[v,y]=r(()=>new Set),b=n(()=>_.filter(e=>wr(Cr({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=()=>Dr(t),C=Dt({onSuccess:S}),w=De({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=>a(`div`,{className:`flex w-44 min-w-0 items-center gap-1.5`,children:[d(dn,{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&&d(q,{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=>d(br,{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=>d(dr,{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=>d(xr,{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=>d(fr,{snap:p.get(e.deviceId)})},{key:`brokers`,header:``,align:`right`,width:`w-10`,notSortableReason:`An action`,render:e=>d(Sr,{deviceId:e.deviceId,deviceName:e.deviceName})}],ee=i===void 0?`Loading cameras…`:_.length===0?`No cameras`:`No cameras match this activity filter.`;return a(`div`,{className:`flex flex-col gap-2`,children:[d(`nav`,{"aria-label":e(`pipeline.cameraAssignmentsTable.filterByCameraActivity`,`Filter by camera activity`),"data-testid":`assignments-activity-filter`,children:d(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1.5`,children:Tr.map(e=>{let t=v.has(e.value);return d(`button`,{type:`button`,"aria-pressed":t,"data-testid":`assignments-activity-${e.value}`,className:ze(re,t?V:D),onClick:()=>x(e.value),children:e.label},e.value)})})}),d(kt,{columns:E,rows:b,rowKey:e=>e.deviceId,minWidthPx:920,maxBodyHeight:ht,emptyMessage:ee})]})}e();function kr({nodeId:e}){let{t}=X(),r=c();Kt([`pipelineOrchestrator`,`getCameraStatuses`],Er);let{data:i}=rn({}),{data:a}=Ft(void 0),{data:o}=en({isCamera:!0,projection:`slim`}),{nodes:s}=G(),l=hr(),u=n(()=>sr(s),[s]),f=n(()=>an(a),[a]),p=n(()=>or(e,i??[],cr((o??[]).map(e=>({id:e.id,name:e.name})))),[e,i,o]),m=s.filter(t=>t.isOnline&&t.id!==e),h=()=>Dr(r),g=Dt({onSuccess:h}),_=De({onSuccess:h}),v=wt({onSuccess:h}),y=Xe({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 d(kt,{columns:[{key:`camera`,header:t(`pipeline.nodeCameraAssignmentsTable.camera`,`Camera`),width:`w-44`,sortValue:e=>e.deviceName,render:e=>d(dn,{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=>d(dr,{detection:t.detection,decoder:t.decoder,audio:t.audio,nameOf:u,colorByNodeId:f,emphasizeOnNodeId:e})},{key:`status`,header:t(`pipeline.nodeCameraAssignmentsTable.status`,`Status`),width:`w-40`,sortValue:e=>l.get(e.deviceId)?.metrics.actualFps??null,render:e=>d(fr,{snap:l.get(e.deviceId)})},{key:`actions`,header:``,align:`right`,width:`w-10`,notSortableReason:`Actions`,render:e=>d(_t,{items:b(e),title:t(`pipeline.nodeCameraAssignmentsTable.move`,`Move {{deviceName}}`,{deviceName:e.deviceName})})}],rows:p,rowKey:e=>e.deviceId,minWidthPx:560,maxBodyHeight:ht,emptyMessage:i===void 0?t(`pipeline.nodeCameraAssignmentsTable.loadingCameras`,`Loading cameras…`):t(`pipeline.nodeCameraAssignmentsTable.noCameraRunsOnThis`,`No camera runs on this node right now`)})}function Ar({nodeId:e,refreshToken:t}){let{t:n}=X(),{nodes:r}=G(),i=r.find(t=>t.id===e)?.name??e;return a(`div`,{className:`space-y-3 sm:space-y-4`,children:[d(er,{refreshToken:t,nodeId:e}),a(`div`,{className:`space-y-2`,children:[a(`div`,{children:[d(`h3`,{className:`text-sm font-semibold text-foreground`,children:n(`pipeline.nodeCamerasTab.camerasOn`,{node:i})}),d(`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.`)})]}),d(kr,{nodeId:e})]})]})}e();function jr(e,t){let n=Math.max(0,t-e),r=Math.floor(e/1e3),i=Math.floor(n/1e3);return Y.t(`pipeline.nodeEnginesTab.idleLeft`,{idle:r,left:i})}function Mr({nodeId:e,refreshToken:t}){let{t:r}=X(),i=c(),o=Ge(),s=Yt({onSettled:()=>{i.invalidateQueries({queryKey:[`pipelineExecutor`,`listLoadedEngines`]})}}),{data:l}=xt({nodeId:e}),u=Zt(`pipeline.engine-metrics-snapshot`,t=>t.nodeId===e)?.engines??l??null,f=u===null;Kt([`pipelineRunner`,`getLocalCameras`],[`pipeline.camera-assigned`,`pipeline.camera-unassigned`]);let{data:p}=$t({nodeId:e}),{values:m}=Bt(`pipeline.camera-metrics-snapshot`,e=>e.deviceId,t=>t.nodeId===e),g=n(()=>m.filter(e=>e.metrics.phase===`active`).length,[m]),_=t=>{let n=p??[];if(n.length===0){s.mutate({nodeId:e,engine:t,force:!1});return}(async()=>{await o({title:r(`pipeline.nodeEnginesTab.killEngine`,`Kill engine`),message:`${String(n.length)} camera(s) are dispatching through this engine. Killing it drops their in-flight work and forces a respawn on the next frame.`,confirmLabel:r(`pipeline.nodeEnginesTab.killEngine`,`Kill engine`),variant:`danger`})&&s.mutate({nodeId:e,engine:t,force:!0})})()};return a(`div`,{className:`space-y-6`,children:[a(`div`,{children:[d(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:r(`pipeline.nodeEnginesTab.inferenceEnginesOnThisNode`,`Inference engines on this node`)}),d(`p`,{className:`text-[11px] text-foreground-subtle`,children:r(`pipeline.nodeEnginesTab.summary`,{engines:(u??[]).length,cameras:(p??[]).length,active:g})})]}),d(`div`,{className:`rounded-lg border border-border overflow-x-auto`,children:a(`table`,{className:`w-full text-xs min-w-[640px]`,children:[d(`thead`,{className:`bg-surface`,children:a(`tr`,{className:`text-foreground-subtle text-[10px] uppercase tracking-wider`,children:[d(`th`,{className:`text-left px-3 py-2 whitespace-nowrap`,children:r(`pipeline.nodeEnginesTab.kind`,`Kind`)}),d(`th`,{className:`text-left px-3 py-2 whitespace-nowrap`,children:r(`pipeline.nodeEnginesTab.runtimeBackendDevice`,`Runtime / Backend / Device`)}),d(`th`,{className:`text-left px-3 py-2`,children:r(`pipeline.nodeEnginesTab.models`,`Models`)}),d(`th`,{className:`text-right px-3 py-2 whitespace-nowrap`,children:r(`pipeline.nodeEnginesTab.poolPid`,`Pool PID`)}),d(`th`,{className:`text-right px-3 py-2 whitespace-nowrap`,children:r(`pipeline.nodeEnginesTab.autoKill`,`Auto-kill`)}),d(`th`,{className:`text-right px-3 py-2 whitespace-nowrap`,children:r(`pipeline.nodeEnginesTab.inUse`,`In use`)}),d(`th`,{className:`w-20`})]})}),a(`tbody`,{children:[f&&d(`tr`,{children:d(`td`,{colSpan:7,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:r(`common.loading`,`Loading…`)})}),!f&&(u??[]).map(e=>{let t=e.kind===`device-pool`;return a(`tr`,{className:`border-t border-border ${t?`bg-primary/[0.05]`:``}`,children:[d(`td`,{className:`px-3 py-2`,children:a(`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:[d(t?Te:w,{className:`h-3 w-3`}),r(t?`pipeline.nodeEnginesTab.pool`:`pipeline.nodeEnginesTab.runtime`)]})}),d(`td`,{className:`px-3 py-2`,children:a(`span`,{className:`inline-flex items-center gap-1 text-[11px] text-sky-400`,children:[d(B,{className:`h-3 w-3`}),e.engine.runtime,`/`,e.engine.backend,e.engine.device?`/${e.engine.device}`:``,e.engine.format?` · ${e.engine.format}`:``]})}),d(`td`,{className:`px-3 py-2`,children:e.modelsLoaded.length===0?d(`span`,{className:`text-foreground-subtle text-[11px]`,children:`—`}):d(`div`,{className:`flex flex-wrap gap-1`,children:e.modelsLoaded.map(e=>d(`span`,{className:`inline-block rounded bg-surface px-1.5 py-0.5 text-[10px] font-mono text-foreground-subtle`,children:e},e))})}),d(`td`,{className:`px-3 py-2 text-right font-mono text-foreground`,children:e.poolPid??`—`}),d(`td`,{className:`px-3 py-2 text-right text-[11px]`,children:e.idleMs!==null&&e.idleTtlMs!==null?d(`span`,{className:`text-foreground-subtle`,children:jr(e.idleMs,e.idleTtlMs)}):d(`span`,{className:`text-foreground-subtle/50`,children:r(`common.never`)})}),d(`td`,{className:`px-3 py-2 text-right text-foreground`,children:(p??[]).length}),d(`td`,{className:`px-3 py-2 text-right`,children:t?d(`span`,{className:`text-[11px] text-foreground-subtle`,children:r(`common.auto`)}):a(K,{variant:`ghost`,size:`sm`,disabled:s.isPending,onClick:()=>_(e.engine),className:`text-danger hover:bg-danger/10 hover:text-danger`,children:[d(h,{className:`h-3.5 w-3.5`}),r(`pipeline.nodeEnginesTab.kill`,`Kill`)]})})]},e.engineKey)}),!f&&(u??[]).length===0&&d(`tr`,{children:d(`td`,{colSpan:7,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:r(`pipeline.nodeEnginesTab.noEnginesResidentTheFactory`,`No engines resident — the factory spins up on the first pipeline run.`)})})]})]})}),d(`div`,{className:`text-[10px] text-foreground-subtle leading-relaxed`,children:d(un,{i18nKey:`pipeline.nodeEnginesTab.legend`,components:{strong:d(`strong`,{className:`text-foreground`})}})}),s.isError&&d(At,{message:r(`pipeline.nodeEnginesTab.killFailed`,{message:s.error instanceof Error?s.error.message:r(`common.unknownError`)})})]})}var Nr=`pipeline-runner`,Pr=200;function Fr({nodeId:e}){let{t}=X();return a(`div`,{className:`flex flex-col gap-3`,children:[a(`div`,{children:[d(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:t(`pipeline.nodeLogsTab.runnerLogs`,`Runner logs`)}),d(`p`,{className:`text-[11px] text-foreground-subtle`,children:t(`pipeline.nodeLogsTab.description`,{node:e})})]}),d(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:d(pt,{agentId:e,addonId:Nr,limit:Pr,maxHeight:`max-h-[calc(100vh-360px)]`,showScope:!0,showDeviceChip:!0,showFilters:!1,showSourceSelect:!0})})]})}e();function Ir({nodeId:e,title:t}){let r=L(),{t:i}=X(),{data:o}=ln(),{data:s}=Ae(void 0),c=n(()=>{let e=new Map;for(let t of o??[])e.set(t.id,t.name);return e},[o]),l=n(()=>{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=hr(e),f=n(()=>{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 f.length===0?a(`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`]}):a(`div`,{className:`rounded-md border border-border bg-surface px-3 py-2`,children:[a(`div`,{className:`flex items-center gap-2 mb-1.5`,children:[d(`span`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle`,children:t??i(`pipeline.cameraStatusStrip.cameras`,`Cameras`)}),d(`span`,{className:`text-[10px] text-foreground-subtle`,children:f.length})]}),d(`div`,{className:`flex flex-wrap gap-1.5`,children:f.map(e=>{let t=c.get(e.deviceId)??`#${e.deviceId}`,n=vt(e.metrics.phase,r);return a(`div`,{title:i(`pipeline.cameraStatusStrip.fpsMsInferQ`,`{{name}} · {{label}} · {{value3}} fps · {{value4}}ms infer · q={{queueDepth}}`,{name:t,label:n.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] ${n.badgeClass}`,children:[d(Ct,{phase:e.metrics.phase,className:`h-2.5 w-2.5`}),d(`span`,{className:`font-medium text-foreground/90 max-w-[220px] truncate`,children:t}),d(`span`,{className:`font-mono tabular-nums`,children:e.metrics.actualFps.toFixed(1)}),d(`span`,{className:`opacity-60`,children:i(`common.fpsWord`)})]},e.deviceId)})})]})}function Lr(e,t,n,r){let i=t===void 0?void 0:e.find(e=>e.key===t)?.steps?.[n]?.settings,a={...r?.[n],...i};return Object.keys(a).length>0?a:void 0}function Rr(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 zr=`pipeline-analytics`,Br=`face-gallery`,Vr=`pipeline-orchestrator`,Hr=`pipeline-runner`,Ur=`audio-analyzer`;function Wr(e){return[...ie.filter(t=>t.stepId===e).map(e=>pe(e.stepId)),...ue.filter(t=>t.stepId===e).map(e=>le(e.stepId,e.key))]}var Gr=`faces`,Kr=`semantic-search`,qr=`load-balancer`,Jr=`load`,Yr=[{id:Gr,get title(){return Y.t(`helpers.clusterSettingsSections.facesTitle`)},get hint(){return Y.t(`helpers.clusterSettingsSections.facesHint`)},panels:[{addonId:Vr,fieldKeys:Wr(`face-embedding`)},{addonId:zr,capability:Br}]},{id:Kr,get title(){return Y.t(`helpers.clusterSettingsSections.semanticTitle`)},get hint(){return Y.t(`helpers.clusterSettingsSections.semanticHint`)},panels:[{addonId:Vr,fieldKeys:Wr(`clip-embedding`)}]},{id:ae,get title(){return Y.t(`helpers.clusterSettingsSections.cropTitle`)},get hint(){return Y.t(`helpers.clusterSettingsSections.cropHint`)},panels:[{addonId:Vr,sectionIds:[ae]}]},{id:fe,get title(){return Y.t(`helpers.clusterSettingsSections.nativeTitle`)},get hint(){return Y.t(`helpers.clusterSettingsSections.nativeHint`)},panels:[{addonId:Vr,sectionIds:[fe]}]},{id:`runner-defaults`,get title(){return Y.t(`helpers.clusterSettingsSections.runnerTitle`)},get hint(){return Y.t(`helpers.clusterSettingsSections.runnerHint`)},panels:[{addonId:Hr,fieldScope:`cluster`},{addonId:Ur,fieldScope:`cluster`}]},{id:qr,get title(){return Y.t(`helpers.clusterSettingsSections.loadTitle`)},get hint(){return Y.t(`helpers.clusterSettingsSections.loadHint`)},panels:[{addonId:Vr,sectionIds:[Jr]}]},{id:`failover`,get title(){return Y.t(`helpers.clusterSettingsSections.failoverTitle`)},get hint(){return Y.t(`helpers.clusterSettingsSections.failoverHint`)},panels:[{addonId:Vr,sectionIds:[`failover`]}]}],Xr={"cluster-step-models":Gr};function Zr(e){return e===`clip-embedding`?Kr:Gr}var Qr=`ctab`,$r=`section`;function ei(e,t){let n=new URLSearchParams({view:`nodes`,node:Eo,[Qr]:e});return t!==void 0&&n.set($r,t),`/system/pipeline?${n.toString()}`}function ti(e){return ei(`settings`,Zr(e))}function ni(){return ei(`load-balancing`)}var ri=`pipeline-orchestrator`;function ii(e){return ie.find(t=>t.stepId===e)??null}function ai({step:e,engineFormat:t,runnableModelIds:n}){let{t:r}=X(),{data:i}=Ze({addonId:ri}),o=he(i??null)[e.stepId]??e.defaultModelId,s=e.options.find(e=>e.id===o)?.label??o,c=n.length>0&&!n.includes(o);return a(`div`,{className:`space-y-2 rounded-md border border-primary/30 bg-primary/5 px-3 py-2`,children:[a(`div`,{className:`flex flex-wrap items-center gap-2 text-xs`,children:[d(`span`,{className:`font-medium text-foreground`,children:e.label}),d(`span`,{className:`font-mono text-foreground`,children:s}),d(`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`)}),d(dn,{to:ti(e.stepId),className:`ml-auto text-[11px] text-primary hover:underline`,children:r(`pipeline.clusterStepModel.changeInClusterSettings`,`Change in Cluster → Settings ›`)})]}),a(`p`,{className:W,children:[r(`pipeline.clusterStepModel.oneModelForEveryNode`,`One model for every node and camera:`),` `,r(`pipeline.clusterStepModel.indexNote`,{index:e.indexName})]}),c&&d(`p`,{className:`rounded border border-warning/40 bg-warning/10 px-2 py-1 text-[10px] leading-snug text-warning`,children:d(un,{i18nKey:`pipeline.clusterStepModel.noBuild`,values:{engine:t,model:o,index:e.indexName},components:{b:d(`b`,{})}})})]})}var oi=`pipeline-orchestrator`;function si({addonId:e,highlightLabel:t}){let{t:n}=X(),r=oe(e),{data:i}=Ze({addonId:oi});if(r.length===0)return null;let o=ce(i??null)[e]??{};return a(`section`,{className:`space-y-1.5 border-t border-border/60 pt-3`,"aria-label":n(`stepInspector.clusterOwnedSettings.clusterWideSettings`,`Cluster-wide settings`),children:[a(`div`,{className:`flex flex-wrap items-center gap-2`,children:[d(`h3`,{className:S,children:n(`stepInspector.clusterOwnedSettings.clusterWideSettings`,`Cluster-wide settings`)}),d(dn,{to:ti(e),className:`ml-auto text-[11px] text-primary hover:underline`,children:n(`stepInspector.clusterOwnedSettings.editInClusterSettings`,`Edit in Cluster → Settings ›`)})]}),r.map(e=>a(`div`,{className:`${f} rounded px-2 ${t===e.label?`bg-primary/5 ring-1 ring-primary/40`:``}`,children:[d(`span`,{className:M,children:e.label}),d(`span`,{className:g,children:d(`span`,{className:`font-mono text-xs text-foreground`,children:String(o[e.key]??e.default)})})]},e.key)),d(`p`,{className:W,children:n(`stepInspector.clusterOwnedSettings.oneValueForEveryNode`,`One value for every node and camera — this step writes into a shared index.`)})]})}function ci({rows:e,hint:t}){let{t:n}=X();return a(`div`,{className:`space-y-1.5`,"data-testid":`effective-models`,children:[d(`ul`,{className:`divide-y divide-border rounded-md border border-border`,children:e.map(e=>a(`li`,{className:`${x} flex flex-wrap items-baseline gap-x-2 text-xs`,children:[d(`span`,{className:e.href===void 0?`min-w-0 flex-1 truncate text-foreground-muted`:`basis-full text-foreground-muted`,children:e.label}),d(`span`,{className:`font-mono text-foreground`,children:e.modelId??`—`}),d(`span`,{className:`text-[10px] text-foreground-subtle`,children:e.sourceLabel}),e.href!==void 0&&d(dn,{to:e.href,className:`ml-auto text-[11px] text-primary hover:underline`,children:n(`stepInspector.effectiveModelSummary.changeOnAccelerator`)})]},e.id))}),d(`p`,{className:W,children:t??n(`stepInspector.effectiveModelSummary.toChangeAModelOpen`,`To change a model, open that accelerator's cell in the table.`)})]})}e();function li(e){return{agentNodeId:e.nodeId,nodeLabel:e.nodeLabel,engineLabel:e.device.format,deviceKey:e.deviceKey,deviceLabel:Le(e.device),detail:e.device.defaultModelId,disabled:e.disabled}}function ui({tree:e,searchRows:t,accelerators:o,cellState:s,stepBadge:c,disabledCount:l,showDisabled:f,onShowDisabledChange:p,dirty:m,onDiscard:h,summary:g,toolbar:_,label:v,renderDetail:y}){let{t:b}=X(),x=Ge(),S=Me(),{selection:C,open:w,close:T}=Cn(n(()=>mn(e).map(e=>e.node.addonId),[e]),n(()=>o.map(e=>e.id),[o])),[E,D]=r(``),[ee,O]=r(null),[k,j]=r(null),M=u(null),N=u(null),P=u(null),te=u(null),F=n(()=>st(t,E),[t,E]),I=n(()=>E.trim()===``?e:En(e,new Set(F.map(e=>e.addonId))),[e,F,E]),L=e=>F.find(t=>t.addonId===e)?.matchedField??null,R=n(()=>o.map(li),[o]),z=e=>o.find(t=>t.nodeId===e.agentNodeId&&t.deviceKey===e.deviceKey),B=o.find(e=>e.id===C.acceleratorId)??null,V=C.stepId!==null,ne=i(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]),H=()=>{requestAnimationFrame(()=>te.current?.focus())},re=(e,t,n=!1)=>{if(e===C.stepId&&(t?.id??null)===C.acceleratorId){n&&H();return}let r=()=>{O(L(e)),w({stepId:e,...t===void 0?{}:{acceleratorId:t.id}}),n&&H()};e===C.stepId?r():ne(r)},U=()=>{let e=C.stepId;ne(()=>{if(T(),e!==null){let t=B===null?null:ke({agentNodeId:B.nodeId,deviceKey:B.deviceKey});requestAnimationFrame(()=>M.current?.focusCell(e,t))}})},ie=e=>{if(e.key===`Enter`){let t=F[0];if(t===void 0)return;e.preventDefault(),re(t.addonId,void 0,!0)}else e.key===`Escape`&&D(``)},ae=S?d(Ye,{onClick:U}):d(cn,{icon:A,variant:`ghost`,size:`sm`,"aria-label":b(`common.close`,`Close`),onClick:U});return a(`div`,{ref:N,className:`space-y-2`,onKeyDown:e=>{let t=e.target instanceof HTMLElement&&e.target.dataset.r!==void 0;e.key===`/`&&t&&(e.preventDefault(),P.current?.focus()),e.key===`Escape`&&t&&V&&(e.preventDefault(),U())},children:[a(`div`,{className:`flex flex-wrap items-center gap-2 text-xs`,children:[d(`div`,{className:`min-w-0 basis-full sm:basis-auto`,children:g}),d(`input`,{ref:P,type:`search`,value:E,onChange:e=>D(e.target.value),onKeyDown:ie,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&&a(`label`,{className:`inline-flex items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[d(Je,{checked:f,onChange:e=>p(e.target.checked)}),b(`stepInspector.stepMatrixFrame.showDisabled`,{count:l})]}),_]}),C.staleStepId!==null&&d(`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})}),I.length===0?d(`p`,{className:`${W} rounded-md border border-dashed border-border px-3 py-4 text-center`,children:b(`stepInspector.stepMatrixFrame.noStepMatches`,{query:E})}):d(nt,{ref:M,tree:I,agents:R,label:v,getCellState:(e,t)=>{let n=z(t);return n===void 0?{kind:`na`}:s(e,n)},onCellClick:(e,t,n)=>re(e,z(t),n),onStepClick:(e,t)=>re(e,void 0,t),...c===void 0?{}:{stepBadge:c},selectedCell:V&&C.stepId!==null&&B!==null?{addonId:C.stepId,agentNodeId:B.nodeId,deviceKey:B.deviceKey}:null,fallbackNodeId:k,onFallbackNodeChange:j,reserveRightPx:V&&!S?432:0}),d(Et,{open:V,anchor:N,onClose:U,label:b(`stepInspector.stepMatrixFrame.stepSettings`,`Step settings`),children:C.stepId!==null&&y({stepId:C.stepId,accelerator:B,matchedField:ee,closeButton:ae,onEscape:U,headingRef:e=>{te.current=e}})})]})}e();function di(e){t(()=>{if(e===null)return;let t=document.getElementById(e);t===null||typeof t.scrollIntoView!=`function`||t.scrollIntoView({block:`center`,behavior:`smooth`})},[e])}e();function fi(e,t,n){return e.map(e=>{let r={...e.steps},i=r[t.stepId]??{},a=t.models[e.key],o=t.jumps[e.key],s=t.accelerator?.deviceKey===e.key?{...Object.fromEntries(Object.entries(i.settings??{}).filter(([e])=>!n(e))),...t.accelerator.settings}:i.settings,c=s!==void 0&&Object.keys(s).length>0?s:void 0,l=a===void 0?i.modelId:a??void 0,u=o===void 0?i.jumpDeviceKey:o||void 0,d={...l===void 0?{}:{modelId:l},...c===void 0?{}:{settings:c},...u===void 0?{}:{jumpDeviceKey:u}};return Object.keys(d).length>0?r[t.stepId]=d:delete r[t.stepId],{key:e.key,enabled:e.enabled,weight:e.weight,maxSessions:e.maxSessions,steps:r}})}function pi(e,t){return t===void 0?0:[...new Set([...Object.keys(e),...Object.keys(t)])].filter(n=>!me(e[n],t[n])).length}function mi(e,t,n,r){if(t===null)return 0;let i=Object.entries(t.models).filter(([n,r])=>(r??void 0)!==e.find(e=>e.key===n)?.steps?.[t.stepId]?.modelId).length,a=Object.entries(t.jumps).filter(([n,r])=>(r||void 0)!==e.find(e=>e.key===n)?.steps?.[t.stepId]?.jumpDeviceKey).length,o=pi(n,t.nodeSettings),s=t.accelerator===void 0?0:pi(r(t.accelerator.deviceKey),t.accelerator.settings);return i+a+o+s}function hi({nodeId:e,nodeName:t,toolbar:i}){let{t:s}=X(),l=c(),u=rt({nodeId:e},{refetchOnMount:`always`}),f=Ht({nodeId:e},{refetchOnMount:`always`}),p=jt({agentNodeId:e},{refetchOnMount:`always`}),m=p.data?.stepSettings,h=he(Ze({addonId:`pipeline-orchestrator`}).data??null),g=u.data?.devices??[],_=f.data??null,[v,y]=r(null),[b,x]=r(null),[C,w]=r(null),T=Qe({onSuccess:()=>{l.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getNodeInferenceDevices`]]})}}),E=Ie({onSuccess:()=>{l.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getAgentSettings`]]})}}),[D,ee]=r(!1),O=n(()=>_?Fe(_):[],[_]),k=n(()=>mn(O),[O]),[A,j]=r(!1),M=n(()=>Dn(e,t,g,A),[e,t,g,A]),N=n(()=>Dn(e,t,g),[e,t,g]),P=N.length>=2,te=(e,t)=>Lr(g,t?.deviceKey,e,m)??{},F=e=>m?.[e]??{},I=(e,t)=>g.find(e=>e.key===t)?.steps?.[e]?.settings??{},L=(e,t,n)=>{let r=n??t.device.steps?.[e?.id??``]?.jumpDeviceKey;if(r!==void 0&&r!==``)return N.find(e=>e.deviceKey===r);if(!Sn(e,t))return N.filter(n=>n.id!==t.id&&Sn(e,n)).toSorted((e,t)=>e.deviceKey.localeCompare(t.deviceKey))[0]},R=(e,t)=>{let n=xn(_,e),r=ii(e),i=gn(_,t),a=te(e,t),o=L(n,t);return wn({addon:n,acc:t,gatedOn:n?.enabledByDefault??!0,model:n?vn(n,t,{nodePin:t.device.steps?.[e]?.modelId}):{modelId:void 0,source:`default`},...Tn(e,a,i)&&i?{rootName:i.name}:{},...r?{clusterModelId:h[e]??r.defaultModelId}:{},...o?{jumpTo:lt(o.device)}:{}})},z=k.map(({node:e})=>({addonId:e.addonId,name:e.addonName,fieldLabels:_n(xn(_,e.addonId))}));if(u.isLoading||f.isLoading||p.isLoading)return d(`div`,{className:`animate-pulse p-4 text-xs text-foreground-subtle`,children:s(`stepInspector.nodeStepInspector.loadingPipeline`,`Loading pipeline…`)});if(_===null)return d(`div`,{className:`p-4 text-xs text-foreground-subtle`,children:s(`stepInspector.nodeStepInspector.catalogUnavailable`,`Catalog unavailable.`)});let B=a(`span`,{className:W,children:[s(`stepInspector.nodeStepInspector.accelerators`,`Accelerators:`),` `,d(`span`,{className:`text-foreground`,children:N.length>0?N.map(e=>lt(e.device)).join(` · `):s(`stepInspector.nodeStepInspector.noneEnabled`,`none enabled`)}),g.some(e=>!e.enabled)&&a(o,{children:[` `,s(`stepInspector.nodeStepInspector.off`,`— off:`),` `,g.filter(e=>!e.enabled).map(lt).join(`, `)]}),` `,`·`,` `,d(dn,{to:ni(),className:`text-primary hover:underline`,children:s(`stepInspector.nodeStepInspector.clusterLoadBalancing`,`Cluster → Load balancing ›`)})]});return d(ui,{tree:O,searchRows:z,accelerators:M,cellState:R,disabledCount:g.filter(e=>!e.enabled).length,showDisabled:A,onShowDisabledChange:j,dirty:v!==null&&mi(g,v,F(v.stepId),e=>I(v.stepId,e))>0,onDiscard:()=>y(null),summary:B,...i===void 0?{}:{toolbar:i},label:s(`stepInspector.nodeStepInspector.detectionSteps`,`Detection steps`),renderDetail:({stepId:n,accelerator:r,matchedField:i,closeButton:c,onEscape:l,headingRef:u})=>{let f=xn(_,n);if(f===null)return d(`div`,{className:`p-4 text-xs text-foreground-subtle`,children:s(`stepInspector.nodeStepInspector.noStepSelected`,`No step selected.`)});let p=v?.stepId===n?v:null,m=r??N[0]??M[0],h=p?.nodeSettings??F(n),O=r===null?{}:p?.accelerator?.deviceKey===r.deviceKey?p.accelerator.settings:I(n,r.deviceKey),k={...h,...O},A=mi(g,p,F(n),e=>I(n,e)),j=e=>{w(null),y(t=>({...t?.stepId===n?t:{stepId:n,models:{},jumps:{}},...e}))},R=ii(n),z=$e(f),{nodeFields:B,acceleratorFields:V}=On(z),ne=new Set(V.flatMap(e=>`key`in e?[e.key,`${e.key}ModelId`]:[])),H=m===void 0?void 0:gn(_,m),re=e=>{let t=p?.models[e.deviceKey];return t===void 0?e.device.steps?.[n]?.modelId:t??void 0},U=m===void 0?void 0:vn(f,m,{nodePin:re(m)}).modelId,ie=e=>{let t=re(e),i=vn(f,e,{nodePin:t}),c=gn(_,e),l=Tn(n,r?.id===e.id?k:te(n,e),c),u=p?.jumps[e.deviceKey],m=L(f,e,u),h=Sn(f,e)?l&&c?d(Pe,{rootModel:c,stepModelId:i.modelId}):void 0:a(o,{children:[s(`stepInspector.nodeStepInspector.noBuild`,{format:e.device.format}),` `,m?s(`stepInspector.nodeStepInspector.itRunsOnInstead`,`It runs on {{shortLabel}} instead.`,{shortLabel:m.shortLabel}):s(`stepInspector.nodeStepInspector.itDoesNotRunHere`,`It does not run here.`)]}),g=P?a(`label`,{className:`block space-y-1`,children:[d(`span`,{className:`text-[11px] font-medium text-foreground`,children:s(`stepInspector.nodeStepInspector.runOn`,`Run on`)}),d(Ke,{"aria-label":s(`stepInspector.nodeStepInspector.runOn`,`Run on`),value:u??e.device.steps?.[n]?.jumpDeviceKey??``,options:[{value:``,label:s(`stepInspector.nodeStepInspector.autoThisAcceleratorOrThe`,`Auto (this accelerator, or the next one that can run it)`)},...N.filter(t=>t.id!==e.id).map(e=>({value:e.deviceKey,label:`${e.label} · ${e.device.format}`}))],onChange:t=>j({jumps:{...p?.jumps,[e.deviceKey]:t.target.value}})}),d(`span`,{className:W,children:s(`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:i.modelId,source:i.source===`node`?`node`:`default`,sourceLabel:i.source===`node`?`node pin`:`hardware default`,models:Re(f.models??[],e.device.format),defaultModelId:f.defaultModelIdByFormat?.[e.device.format]??f.defaultModelId,expanded:b===e.id,onToggle:()=>x(t=>t===e.id?null:e.id),onChangeModel:t=>j({models:{...p?.models,[e.deviceKey]:t}}),...t===void 0?{}:{onReset:()=>j({models:{...p?.models,[e.deviceKey]:null}}),resetLabel:`Reset to hardware default`},...h===void 0?{}:{note:h},...g===void 0?{}:{extra:g},changed:p?.models[e.deviceKey]!==void 0||u!==void 0}},ae=async()=>{if(p!==null){ee(!0);try{(Object.keys(p.models).length>0||Object.keys(p.jumps).length>0||p.accelerator!==void 0)&&await T.mutateAsync({agentNodeId:e,inferenceDevices:Rr(fi(g,p,e=>ne.has(e)))}),p.nodeSettings!==void 0&&pi(F(n),p.nodeSettings)>0&&await E.mutateAsync({agentNodeId:e,addonId:n,settings:Object.keys(p.nodeSettings).length>0?{...p.nodeSettings}:null}),y(null),w({kind:`saved`})}catch(e){w({kind:`error`,error:e instanceof Error?e.message:String(e)})}finally{ee(!1)}}};return d(ut,{ref:u,title:r===null?`${f.name} · ${t}`:`${f.name} · ${r.label}`,subtitle:r===null?s(`stepInspector.nodeStepInspector.everyAcceleratorOf`,`{{slot}} · every accelerator of {{nodeName}}`,{slot:f.slot,nodeName:t}):s(`stepInspector.nodeStepInspector.baseForEveryCameraThat`,`{{slot}} · {{format}} · base for every camera that lands here`,{slot:f.slot,format:r.device.format}),leading:c,onEscape:l,saveBar:{dirtyCount:A,saving:D,status:C?.kind??null,...C?.error===void 0?{}:{error:C.error},onSave:()=>void ae(),onDiscard:()=>y(null)},children:a(`div`,{className:`space-y-3`,children:[a(`section`,{className:`space-y-2`,"aria-label":s(`stepInspector.nodeStepInspector.model`,`Model`),children:[d(`h3`,{className:S,children:s(`stepInspector.nodeStepInspector.model`,`Model`)}),R!==null&&m!==void 0?d(ai,{step:R,engineFormat:m.device.format,runnableModelIds:Re(f.models??[],m.device.format).map(e=>e.id)}):M.length===0?d(`p`,{className:W,children:d(un,{i18nKey:`stepInspector.nodeStepInspector.noAcceleratorEnabled`,components:{link:d(dn,{to:ni(),className:`text-primary hover:underline`})}})}):r===null?d(ci,{rows:M.map(e=>{let t=vn(f,e,{nodePin:re(e)});return{id:e.id,label:e.label,modelId:t.modelId,sourceLabel:t.source===`node`?`node pin`:`hardware default`}})}):d(at,{...ie(r)},r.id)]}),(z.length>0||H!==void 0)&&R===null&&a(`section`,{"aria-label":s(`stepInspector.nodeStepInspector.settings`,`Settings`),className:`space-y-2 border-t border-border/60 pt-2`,children:[d(`p`,{className:`text-[10px] text-foreground-subtle`,"data-testid":`settings-scope`,children:s(`stepInspector.nodeStepInspector.nodeWideSettings`,{node:t})}),(B.length>0||H!==void 0)&&d(gi,{addon:f,fields:B,settings:h,layerLabel:s(`stepInspector.nodeStepInspector.nodeLayer`,`Node`),modelId:Ve(f,U,k,H),root:H,highlight:i,onChange:e=>j({nodeSettings:e})}),V.length>0&&(r===null?d(`p`,{className:`text-[10px] text-foreground-subtle`,"data-testid":`accelerator-settings-hint`,children:s(`stepInspector.nodeStepInspector.thresholdsPerAccelerator`,`Confidence thresholds belong to the model, so they are set per accelerator: open that accelerator's cell.`)}):a(`div`,{className:`space-y-1 border-t border-border/60 pt-2`,children:[d(`p`,{className:`text-[10px] text-foreground-subtle`,"data-testid":`accelerator-settings-scope`,children:s(`stepInspector.nodeStepInspector.acceleratorSettings`,{accelerator:r.label})}),d(gi,{addon:f,fields:V,settings:O,layerLabel:s(`stepInspector.nodeStepInspector.acceleratorLayer`,`This accelerator`),modelId:Ve(f,U,k,H),root:void 0,highlight:i,onChange:e=>j({accelerator:{deviceKey:r.deviceKey,settings:e}})})]}))]}),d(si,{addonId:n,highlightLabel:i})]})})}})}function gi({addon:e,fields:t,settings:n,layerLabel:r,modelId:i,root:a,highlight:o,onChange:s}){let c=t.find(e=>`label`in e&&e.label===o)?.key??null;return di(c===null?null:Oe(c)),d(sn,{addon:e,fields:t,layers:{node:n},target:`node`,labels:{node:r},modelId:i,...a===void 0?{}:{rootModel:a},highlightKey:c,onChangeLayer:s})}e();function _i({nodeId:e,refreshToken:t}){let{t:n}=X(),i=Ge(),[s,c]=r(null),{nodes:l}=G(),u=l.find(t=>t.id===e)?.name??e,f=je({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 i({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),f.mutate({agentNodeId:e}))};return a(`div`,{className:`space-y-2`,children:[d(Ir,{nodeId:e}),d(hi,{nodeId:e,nodeName:u,toolbar:a(o,{children:[s&&d(`span`,{className:`text-[11px] text-success`,children:s}),f.isError&&d(`span`,{className:`text-[11px] text-danger`,children:f.error instanceof Error?f.error.message:n(`pipeline.nodePipelineTab.resetFailed`,`Reset failed`)}),d(K,{variant:`outline`,size:`sm`,onClick:()=>{p()},disabled:f.isPending,title:n(`pipeline.nodePipelineTab.clearThisNodeSPer`,`Clear this node's per-device model defaults + per-camera overrides scoped to this node`),children:f.isPending?n(`pipeline.nodePipelineTab.resetting`,`Resetting…`):n(`pipeline.nodePipelineTab.resetToDefault`,`Reset to default`)})]})})]})}var vi=[`detection-pipeline`,`audio-analyzer`,`pipeline-runner`],yi=`decoder-nodeav`,bi=`ntab`,xi={decoder:`engine`},Si={engine:`Engine & decoder`},Ci=`Nothing here is set per node. Cluster-wide values are on Cluster → Settings.`;function wi({nodeId:e,refreshToken:t}){let{t:n}=X(),[r,i]=fn(),{nodes:o}=G(),s=o.find(t=>t.id===e)?.addons.find(e=>e.capabilities.includes(`decoder`))?.addonId??yi,c=[...vi,s],l=r.get(bi),u={assignments:{id:`assignments`,label:n(`pipeline.nodeDetail.assignments`,`Assignments`),order:-10,content:d(Ar,{nodeId:e,refreshToken:t})},tree:{id:`tree`,label:n(`pipeline.nodeDetail.pipeline`,`Pipeline`),order:39,content:d(_i,{nodeId:e,refreshToken:t})},engines:{id:`engines`,label:n(`pipeline.nodeDetail.warmInstances`,`Warm instances`),order:180,content:d(Mr,{nodeId:e,refreshToken:t})},logs:{id:`logs`,label:n(`pipeline.nodeDetail.logs`,`Logs`),order:300,content:d(Fr,{nodeId:e})}},f=$n.map(e=>u[e]);return a(`div`,{className:`flex flex-col h-full`,children:[d(Qn,{nodeId:e,refreshToken:t}),d(`div`,{className:`flex-1 min-h-0 overflow-y-auto p-4 sm:p-6`,children:d(jn,{nodeId:e,addonIds:c,level:`global`,fieldScope:`perNode`,emptyMessage:Ci,tabAliases:xi,tabLabelOverrides:Si,extraTabs:f,activeTab:l===null?null:xi[l]??l,onActiveTabChange:e=>i(t=>{let n=new URLSearchParams(t);n.set(bi,e);for(let e of hn)n.delete(e);return n},{replace:!0})})})]})}function Ti(){let{t:e}=X();return a(`div`,{className:`space-y-2`,children:[a(`div`,{className:`min-w-0`,children:[d(`h3`,{className:`text-sm font-semibold text-foreground`,children:e(`pipeline.clusterAssignmentsTab.cameraPlacement`,`Camera placement`)}),d(`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.`)})]}),d(Or,{})]})}function Ei(e){return`${Math.round(e*100)}%`}function Di(e){return Y.t(`helpers.autoTuneViewModel.sessions`,{count:e})}var Oi={"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`},ki={"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 Ai(e){return e===null?`—`:Oi[e]??e}function ji(e){return e===null?`—`:ki[e]??e}function Mi(e){switch(e.kind){case`capacity`:return Y.t(`helpers.autoTuneViewModel.capacity`,{sessions:Di(e.sessions),min:e.minSessions});case`tie-faster`:return Y.t(`helpers.autoTuneViewModel.tieFaster`,{over:e.over,recall:Ei(e.recallDelta)});case`stepped-down`:return Y.t(`helpers.autoTuneViewModel.steppedDown`,{from:e.from,limitedBy:e.limitedBy,to:e.to});case`no-fit-lightest`:return Y.t(`helpers.autoTuneViewModel.noFitLightest`,{min:Di(e.minSessions),sessions:Di(e.sessions)});case`derived-latency`:return Y.t(`helpers.autoTuneViewModel.derivedLatency`,{modelId:e.modelId});case`cpu-device`:return Y.t(`helpers.autoTuneViewModel.cpuDevice`);case`device-disabled`:return Y.t(`helpers.autoTuneViewModel.deviceDisabled`);case`device-unavailable`:return Y.t(`helpers.autoTuneViewModel.deviceUnavailable`);case`node-offline`:return Y.t(`helpers.autoTuneViewModel.nodeOffline`);case`no-hardware-facts`:return Y.t(`helpers.autoTuneViewModel.noHardwareFacts`);case`no-measured-data`:return Y.t(`helpers.autoTuneViewModel.noMeasuredData`);case`no-family-build`:return Y.t(`helpers.autoTuneViewModel.noFamilyBuild`,{format:e.format});case`kept-custom-pin`:return Y.t(`helpers.autoTuneViewModel.keptCustomPin`,{modelId:e.modelId,deviceKey:e.deviceKey})}}function Ni(e,t){switch(e.kind){case`custom-pin-kept`:return Y.t(`helpers.autoTuneViewModel.customPinNode`,{node:t(e.nodeId),modelId:e.modelId,deviceKey:e.deviceKey});case`custom-registry-unreadable`:return Y.t(`helpers.autoTuneViewModel.customRegistryUnreadable`,{error:e.error})}}function Pi(e){return{modelChanges:e.nodeChanges.reduce((e,t)=>e+t.modelPins.length,0),thresholdClears:e.nodeChanges.reduce((e,t)=>e+t.thresholds.length,0)}}function Fi(e){let t=Pi(e);return t.modelChanges+t.thresholdClears===0}function Ii(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 Li(e,t){return e?.kind===`node-benchmark`?Y.t(`helpers.autoTuneViewModel.latencyMeasured`,{date:new Date(e.measuredAtMs).toLocaleDateString(t,{day:`numeric`,month:`short`})}):e?.kind===`estimated`?Y.t(`helpers.autoTuneViewModel.latencyEstimated`,{hardware:ji(e.estimatedFrom)}):Y.t(`helpers.autoTuneViewModel.latencyTable`)}e();var Ri=[.3,.4,.5];function zi(e){return Ri.some(t=>t===e)}var Bi=[1,2,3,4,6,8];function Vi({plan:e,node:t,nodeName:n}){let{t:r}=X();return a(`section`,{className:y,"data-testid":`auto-tune-node-${t.nodeId}`,children:[a(`header`,{className:`${N} flex flex-wrap items-center gap-2`,children:[d(w,{className:`h-3.5 w-3.5 shrink-0 text-foreground-subtle`,"aria-hidden":!0}),d(`h3`,{className:`${S} min-w-0 flex-1`,children:n(t.nodeId)}),a(`span`,{className:`text-[11px] text-foreground-subtle`,children:[ji(t.hardwareClass),t.cpuModel===null?``:` · ${t.cpuModel}`]}),t.skipped?d(q,{variant:`warning`,children:r(`pipeline.clusterAutoTuneTab.notChanged`,`Not changed`)}):t.acceleratorModelId!==null&&d(q,{variant:`info`,children:t.acceleratorModelId})]}),t.reasons.length>0&&d(`ul`,{className:`px-3 pt-2 text-[11px] text-foreground-muted`,children:t.reasons.map((e,t)=>d(`li`,{children:Mi(e)},t))}),d(`div`,{className:`overflow-x-auto`,children:a(`table`,{className:`w-full text-xs`,children:[d(`thead`,{children:a(`tr`,{className:`text-left text-[11px] text-foreground-subtle`,children:[d(`th`,{className:`px-3 py-1.5 font-medium`,children:r(`pipeline.clusterAutoTuneTab.device`,`Device`)}),d(`th`,{className:`px-3 py-1.5 font-medium`,children:r(`pipeline.clusterAutoTuneTab.capacity`,`Capacity`)}),d(`th`,{className:`px-3 py-1.5 font-medium`,children:r(`pipeline.clusterAutoTuneTab.detector`,`Detector`)}),d(`th`,{className:`px-3 py-1.5 font-medium`,children:r(`pipeline.clusterAutoTuneTab.why`,`Why`)})]})}),d(`tbody`,{children:t.devices.map(n=>{let i=Ii(e,t.nodeId,n.deviceKey);return a(`tr`,{className:`border-t border-border align-top`,children:[a(`td`,{className:`px-3 py-1.5`,children:[d(`div`,{className:`font-mono text-foreground`,children:n.deviceKey}),d(`div`,{className:`text-[11px] text-foreground-subtle`,children:Ai(n.accelerator)})]}),a(`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&&a(`div`,{className:`text-[11px] text-foreground-subtle`,children:[r(`pipeline.clusterAutoTuneTab.fpsKeptFree`,{fps:n.chosen.fps,percent:Math.round(e.headroom*100)}),d(`div`,{children:Li(n.chosen.source)})]})]}),d(`td`,{className:`px-3 py-1.5`,children:n.chosen===null?d(`span`,{className:`text-foreground-subtle`,children:r(`common.unchanged`)}):i!==null&&i.before!==i.after?a(`span`,{children:[d(`span`,{className:`text-foreground-subtle`,children:i.before??r(`common.defaultWord`)}),` → `,d(`span`,{className:`font-medium text-foreground`,children:i.after})]}):d(`span`,{className:`text-foreground`,children:n.chosen.modelId})}),d(`td`,{className:`px-3 py-1.5 text-[11px] text-foreground-muted`,children:n.reasons.map((e,t)=>d(`div`,{children:Mi(e)},t))})]},n.deviceKey)})})]})})]})}function Hi({plan:e,nodeName:t}){let{t:n}=X();return d(`div`,{className:`flex flex-col gap-3 text-xs`,"data-testid":`auto-tune-change-list`,children:a(`div`,{children:[d(`div`,{className:S,children:n(`pipeline.clusterAutoTuneTab.nodeSettings`,`Node settings`)}),e.nodeChanges.length===0?d(`div`,{className:`text-foreground-subtle`,children:n(`pipeline.clusterAutoTuneTab.noChange`,`No change.`)}):d(`ul`,{className:`mt-1 flex flex-col gap-0.5`,children:e.nodeChanges.flatMap(e=>[...e.modelPins.map(r=>a(`li`,{children:[a(`span`,{className:`font-mono`,children:[t(e.nodeId),` · `,e.deviceKey]}),` `,`— `,r.stepId,`: `,r.before??n(`pipeline.clusterAutoTuneTab.defaultModel`),` →`,` `,r.after??n(`pipeline.clusterAutoTuneTab.stepDefault`,`step default`)]},`${e.nodeId}/${e.deviceKey}/${r.stepId}/pin`)),...e.thresholds.map(r=>a(`li`,{children:[a(`span`,{className:`font-mono`,children:[t(e.nodeId),` · `,e.deviceKey]}),` `,`—`,` `,n(`pipeline.clusterAutoTuneTab.thresholdReset`,{step:r.stepId,keys:r.keys.join(`, `)})]},`${e.nodeId}/${e.deviceKey}/${r.stepId}/thr`))])})]})})}function Ui({result:e}){let{t}=X();return e.kind===`refused`?d(`div`,{className:`text-xs text-warning`,children:t(`pipeline.clusterAutoTuneTab.anotherApplyIsAlreadyRunning`,`Another apply is already running.`)}):e.kind===`stale`?d(`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.`)}):a(`ul`,{className:`text-xs`,"data-testid":`auto-tune-result`,children:[e.kind===`aborted`&&d(`li`,{className:`text-danger`,children:t(`pipeline.clusterAutoTuneTab.aModelCouldNotBe`,`A model could not be downloaded: nothing was changed.`)}),e.phases.map(e=>a(`li`,{className:e.ok?`text-foreground-muted`:`text-danger`,children:[e.ok?`✓`:`✗`,` `,e.phase,`: `,e.detail]},e.phase))]})}function Wi(){let{t:e}=X(),t=c(),[i,o]=r(.4),[s,l]=r(2),[u,f]=r(!1),[p,m]=r(!1),[h,g]=r(null),{nodes:_}=G(),v=n(()=>sr(_),[_]),b=He({headroom:i,minSessionsPerDevice:s},{enabled:u,refetchOnWindowFocus:!1}),x=Lt({onSuccess:e=>{g(e),m(!1),t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getNodeInferenceDevices`]]}),e.kind===`applied`&&b.refetch()}}),C=h?.kind===`stale`?h.plan:b.data,w=C===void 0?null:Pi(C);return a(`div`,{className:`flex flex-col gap-3`,"data-testid":`cluster-auto-tune`,children:[a(`section`,{className:y,children:[a(`header`,{className:`${N} flex flex-wrap items-center gap-2`,children:[d(T,{className:`h-3.5 w-3.5 shrink-0 text-foreground-subtle`,"aria-hidden":!0}),d(`h3`,{className:`${S} min-w-0 flex-1`,children:e(`pipeline.clusterAutoTuneTab.autoTune`,`Auto tune`)})]}),a(`div`,{className:`flex flex-col gap-2 px-3 py-2 text-xs text-foreground-muted`,children:[d(`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 on the accelerators and clears their threshold overrides, so each model runs its own default thresholds. Cameras carry no model or threshold of their own. Enabled steps, devices, pins, recording, notifications, zones and rules are not touched. There is no undo.`)}),a(`div`,{className:`flex flex-wrap items-center gap-2`,children:[a(`label`,{className:`flex items-center gap-1.5`,children:[d(`span`,{className:`whitespace-nowrap`,children:e(`pipeline.clusterAutoTuneTab.keepFree`,`Keep free`)}),d(Ke,{"aria-label":e(`pipeline.clusterAutoTuneTab.shareOfEachAcceleratorKept`,`Share of each accelerator kept free`),value:String(i),options:Ri.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);zi(t)&&o(t)}})]}),a(`label`,{className:`flex items-center gap-1.5`,children:[d(`span`,{className:`whitespace-nowrap`,children:e(`pipeline.clusterAutoTuneTab.atLeast`,`At least`)}),d(Ke,{"aria-label":e(`pipeline.clusterAutoTuneTab.minimumParallelSessionsPerDevice`,`Minimum parallel sessions per device`),value:String(s),options:Bi.map(t=>({value:String(t),label:e(`pipeline.clusterAutoTuneTab.camerasAtOnce`,{count:t})})),onChange:e=>{let t=Number(e.target.value);Bi.some(e=>e===t)&&l(t)}})]}),d(K,{size:`sm`,variant:`secondary`,onClick:()=>{g(null),f(!0),u&&b.refetch()},children:b.isFetching?e(`pipeline.clusterAutoTuneTab.computing`,`Computing…`):C===void 0?e(`pipeline.clusterAutoTuneTab.computePlan`,`Compute plan`):e(`pipeline.clusterAutoTuneTab.recompute`,`Recompute`)}),C!==void 0&&d(K,{size:`sm`,disabled:Fi(C),onClick:()=>m(!0),children:e(`pipeline.clusterAutoTuneTab.apply`,`Apply…`)})]}),b.error!==null&&d(`div`,{className:`text-danger`,children:b.error.message}),h!==null&&d(Ui,{result:h}),w!==null&&d(`div`,{className:`text-[11px] text-foreground-subtle`,children:e(`pipeline.clusterAutoTuneTab.planSummary`,{modelChanges:w.modelChanges,thresholdClears:w.thresholdClears})})]})]}),C?.warnings.map((e,t)=>d(`div`,{className:`rounded-md border border-warning/40 bg-warning/10 px-3 py-2 text-xs text-warning`,children:Ni(e,v)},t)),C?.nodes.map(e=>d(Vi,{plan:C,node:e,nodeName:v},e.nodeId)),C!==void 0&&d(Vt,{open:p,onOpenChange:m,children:a(Pt,{width:`lg`,scroll:`body`,children:[a(Xt,{children:[d(St,{children:e(`pipeline.clusterAutoTuneTab.applyAutoTune`,`Apply auto tune?`)}),d(yt,{children:e(`pipeline.clusterAutoTuneTab.theseAreAllTheChanges`,`These are all the changes. Every override listed is removed and cannot be restored.`)})]}),d(Jt,{children:d(Hi,{plan:C,nodeName:v})}),a(Ut,{children:[d(K,{variant:`ghost`,onClick:()=>m(!1),children:e(`common.cancel`,`Cancel`)}),d(K,{variant:`danger`,disabled:x.isPending,onClick:()=>x.mutate({planHash:C.planHash,headroom:i,minSessionsPerDevice:s}),children:x.isPending?e(`pipeline.clusterAutoTuneTab.applying`,`Applying…`):e(`common.apply`,`Apply`)})]})]})})]})}var Gi={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 Ki(e,t){return t<=0?0:Math.round(e/t*1e3)/10}function qi(e){return e===void 0?!1:e.load.devices.reduce((e,t)=>e+t.attachedCameras,0)>=e.load.attachedCameras}function Ji(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:Le(e),format:e.format,sessions:i,weight:a,weightSharePct:e.exclusion===null?Ki(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 Yi(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=Ji(e.devicesByNode[r.id]??[],new Map((i?.load.devices??[]).map(e=>[e.deviceKey,e.attachedCameras])),qi(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?Ki(c,r.maxCameras):null,queueDepthTotal:i?.load.queueDepthTotal??null,avgInferenceTimeMs:i?.load.avgInferenceTimeMs??null,score:i?.score??null,weight:s,weightSharePct:o?Ki(s,n):null,decodeHwaccel:i?.decodeHwaccel??null,devices:a,eligibleDeviceCount:a.filter(e=>e.exclusion===null).length}})}e();var Xi=2e4,Zi=3e5;function Qi({stats:e,targetWeights:t,showAccelerators:r=!0}){let{t:i}=X(),{nodes:a}=G(),o=F().trpcClient,c=zt(void 0,{placeholderData:l,staleTime:Xi,refetchInterval:Xi,refetchOnWindowFocus:!0}),u=Ft(void 0,{staleTime:Zi}),f=n(()=>a.map(e=>e.id),[a]),m=s({queries:f.map(e=>({queryKey:Ee(Nt.pipelineOrchestrator.getNodeInferenceDevices,{nodeId:e},`query`),queryFn:()=>o.pipelineOrchestrator.getNodeInferenceDevices.query({nodeId:e}),staleTime:Zi,refetchOnWindowFocus:!1,placeholderData:l}))}),h=n(()=>{let e={};return f.forEach((t,n)=>{let r=m[n]?.data;r&&(e[t]=r.devices)}),e},[f,m.map(e=>e.dataUpdatedAt).join(`|`)]),g=n(()=>{let e=new Map;for(let t of u.data??[])e.set(t.nodeId,t.settings);return e},[u.data]),_=n(()=>a.map(e=>{let n=g.get(e.id);return{id:e.id,name:e.name,isOnline:e.isOnline,detectEnabled:Yn(n,e.isHub).pipeline,weight:t?.[e.id]??Pn(n,`detectWeight`)??1,maxCameras:Pn(n,`maxCameras`)}}),[a,g,t]),v=c.data??[],y=n(()=>Yi({nodes:_,loads:v,devicesByNode:h}),[_,v,h]),b=y.reduce((e,t)=>e+(t.attachedCameras??0),0),x=y.reduce((e,t)=>e+(t.activeCameras??0),0),S=c.dataUpdatedAt>0?Date.now()-c.dataUpdatedAt:null,C=new Map((e?.nodes??[]).map(e=>[e.nodeId,e]));return d(J,{headingId:`load-balancing-node-load`,title:i(`pipeline.nodeLoadOverview.nodeLoad`,`Node load`),icon:R,actions:d(`span`,{className:`text-[10px] text-foreground-subtle tabular-nums`,children:i(`pipeline.nodeLoadOverview.summaryLine`,{active:x,attached:b,reading:c.data===void 0?i(`pipeline.nodeLoadOverview.reading`,`reading…`):i(`pipeline.nodeLoadOverview.readingAge`,{age:S===null?`—`:`${Math.round(S/1e3)}s`})})}),children:d(`div`,{className:p,children:y.length===0?d(`p`,{className:`text-[11px] italic text-foreground-subtle`,children:i(`pipeline.nodeLoadOverview.noClusterNodesReportedYet`,`No cluster nodes reported yet.`)}):d(`div`,{className:`grid gap-2 @2xl/clustertab:grid-cols-2 @5xl/clustertab:grid-cols-3`,children:y.map(e=>d($i,{row:e,placed:C.get(e.nodeId),showAccelerators:r},e.nodeId))})})})}function $i({row:e,placed:t,showAccelerators:n}){let{t:r}=X(),i=e.attachedCameras===null?`—`:`${e.activeCameras??0} / ${e.attachedCameras}${e.maxCameras===null?``:` of ${e.maxCameras}`}`;return a(`div`,{className:`rounded-lg border border-border bg-surface/60 p-2.5 min-w-0`,children:[a(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[d(`span`,{className:`h-1.5 w-1.5 shrink-0 rounded-full ${e.isOnline?`bg-emerald-400`:`bg-foreground-subtle/40`}`}),d(`span`,{className:`truncate text-xs font-medium text-foreground`,title:e.nodeId,children:e.name}),!e.detectEnabled&&d(`span`,{className:`shrink-0 rounded bg-surface-hover px-1 text-[9px] uppercase tracking-wide text-foreground-subtle`,children:r(`pipeline.nodeLoadOverview.noDetect`,`no detect`)}),!e.reported&&e.isOnline&&a(`span`,{className:`ml-auto inline-flex shrink-0 items-center gap-1 text-[9px] text-amber-400`,title:r(`pipeline.nodeLoadOverview.onlineButItDidNot`,`Online, but it did not answer the last load read — its numbers below are unknown, not zero.`),children:[d(v,{className:`h-2.5 w-2.5`}),` `,r(`pipeline.nodeLoadOverview.noReading`)]}),!e.isOnline&&a(`span`,{className:`ml-auto inline-flex shrink-0 items-center gap-1 text-[9px] text-foreground-subtle`,children:[d(E,{className:`h-2.5 w-2.5`}),` `,r(`common.offline`)]})]}),a(`dl`,{className:`mt-1.5 grid grid-cols-2 gap-x-2 gap-y-0.5 text-[10px]`,children:[d(na,{label:r(`pipeline.nodeLoadOverview.runningAttached`,`Running / attached`),value:i,title:r(`pipeline.nodeLoadOverview.sessionsInInferenceNowCameras`,`Sessions in inference now / cameras attached to this runner (the balancer's committed load) / operator cap.`)}),d(na,{label:r(`pipeline.nodeLoadOverview.targetShare`,`Target share`),value:e.weightSharePct===null?`out of play`:`${e.weightSharePct}%`,title:r(`pipeline.nodeLoadOverview.theNodeShareAutomaticOr`,`The node share (automatic or manual) normalised over the nodes the balancer actually ranks (online AND detect-enabled).`)}),d(na,{label:r(`pipeline.nodeLoadOverview.actualShare1H`,`Actual share (1 h)`),value:t?.observedShare===null||t===void 0?`—`:`${Math.round(t.observedShare*100)}%`,title:r(`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.`)}),d(na,{label:r(`pipeline.nodeLoadOverview.peakYields`,`Peak · yields`),value:t===void 0?`—`:`${t.peakSessions} · ${t.yieldsAway}`,title:r(`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.`)}),d(na,{label:r(`pipeline.nodeLoadOverview.scoreQueue`,`Score · queue`),value:e.score===null?`—`:`${e.score} · ${e.queueDepthTotal??0}`,title:r(`pipeline.nodeLoadOverview.theCapacityScoreBalanceMinimises`,`The capacity score balance() minimises (attached + queue depth), and the raw queue depth.`)}),e.capacityPct!==null&&d(na,{label:r(`pipeline.nodeLoadOverview.capFill`,`Cap fill`),value:`${e.capacityPct}%`,title:r(`pipeline.nodeLoadOverview.attachedMaxcameras`,`attached / maxCameras.`)}),e.avgInferenceTimeMs!==null&&d(na,{label:r(`pipeline.nodeLoadOverview.avgInfer`,`Avg infer`),value:`${Math.round(e.avgInferenceTimeMs)} ms`,title:r(`pipeline.nodeLoadOverview.meanInferenceTimeAcrossThis`,`Mean inference time across this node's attached cameras.`)}),e.decodeHwaccel!==null&&d(na,{label:r(`pipeline.nodeLoadOverview.decode`,`Decode`),value:e.decodeHwaccel,title:r(`pipeline.nodeLoadOverview.thisNodeSProbedDecode`,`This node's probed decode hwaccel.`)})]}),n&&d(ea,{row:e})]})}function ea({row:e}){let{t}=X();return e.devices.length===0?d(`p`,{className:`mt-2 text-[10px] italic text-foreground-subtle`,children:t(`pipeline.nodeLoadOverview.acceleratorsNotReadYet`,`Accelerators not read yet.`)}):a(`div`,{className:`mt-2 border-t border-border pt-1.5`,children:[a(`div`,{className:`flex items-center gap-1 text-[9px] uppercase tracking-wider text-foreground-subtle`,children:[d(b,{className:`h-2.5 w-2.5`}),t(`pipeline.nodeLoadOverview.accelerators`,`Accelerators`),e.eligibleDeviceCount===0&&d(`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`)})]}),d(`ul`,{className:`mt-1 space-y-0.5`,children:e.devices.map(e=>d(ta,{device:e},e.key))})]})}function ta({device:e}){let{t}=X(),n=e.exclusion;return a(`li`,{className:`flex items-baseline gap-1.5 text-[10px] min-w-0`,children:[d(w,{className:`h-2.5 w-2.5 shrink-0 ${n===null?`text-foreground-subtle`:`text-foreground-subtle/50`}`}),d(`span`,{className:`shrink-0 font-medium ${n===null?`text-foreground`:`text-foreground-subtle`}`,title:`${e.key} · ${e.format}`,children:e.label}),n===null?a(o,{children:[d(`span`,{className:`shrink-0 tabular-nums text-foreground-subtle`,children:t(`pipeline.nodeLoadOverview.sharePct`,{pct:e.weightSharePct})}),a(`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&&d(`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`)})]}):d(`span`,{className:`truncate text-foreground-subtle/80`,title:t(Gi[n]),children:t(`pipeline.nodeLoadOverview.excludedWith`,{reason:t(Gi[n])})})]})}function na({label:e,value:t,title:n}){return a(`div`,{className:`min-w-0`,title:n,children:[d(`dt`,{className:`text-[9px] uppercase tracking-wide text-foreground-subtle`,children:e}),d(`dd`,{className:`truncate font-medium tabular-nums text-foreground`,children:t})]})}function ra(e){return{nodes:Object.fromEntries(e.map(e=>[e.nodeId,Math.max(1,e.weight)])),devices:{}}}function ia(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 aa(e){return Object.fromEntries(e.nodes.map(e=>[e.nodeId,Object.fromEntries(e.devices.map(e=>[e.deviceKey,e.suggestedMaxSessions]))]))}function oa(e){return e.reason===`disabled`?Y.t(`helpers.loadBalancingViewModel.stalePinDisabled`,{deviceKey:e.deviceKey}):Y.t(`helpers.loadBalancingViewModel.stalePinMissing`,{deviceKey:e.deviceKey})}function sa(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 ca(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 Y.t(`helpers.loadBalancingViewModel.shareNote`,{count:n.length,names:i,into:r})}var la=[{value:`hardware`,get label(){return Y.t(`helpers.loadBalancingViewModel.hardwareLabel`)},get hint(){return Y.t(`helpers.loadBalancingViewModel.hardwareHint`)}},{value:`benchmark`,get label(){return Y.t(`helpers.loadBalancingViewModel.benchmarkLabel`)},get hint(){return Y.t(`helpers.loadBalancingViewModel.benchmarkHint`)}},{value:`manual`,get label(){return Y.t(`helpers.loadBalancingViewModel.manualLabel`)},get hint(){return Y.t(`helpers.loadBalancingViewModel.manualHint`)}}];function ua(e){return e===`no-benchmark-results`?Y.t(`helpers.loadBalancingViewModel.fallbackNone`):e===`partial-benchmark-results`?Y.t(`helpers.loadBalancingViewModel.fallbackPartial`):null}function da(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)}: ${ua(e.capacityFallback)??``}`).join(` · `)}e();function fa(e,t,n){return Math.min(Math.max(e,t),n)}function pa(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 ma(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:fa(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 ha(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 ga({nodes:e,pending:n,onCommitWeights:i,weightLabel:s=`Detection weight`,emptyHint:c,footnote:l,readOnly:u=!1}){let{t:f}=X(),[p,m]=r(()=>pa(e)),[h,g]=r(new Set);t(()=>{m(pa(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=>ma(n,e,t,h,_))},b=()=>{let t=ha(p,_,h),n=e.filter(e=>(t[e.id]??0)!==e.weight).map(e=>e.id);if(n.length===0)return;let r=new Set([...n,...h]);i(e.filter(e=>r.has(e.id)).map(e=>({nodeId:e.id,weight:t[e.id]??0})))};if(e.length===0)return d(`p`,{className:`rounded-lg border border-dashed border-border bg-background px-4 py-6 text-center text-xs text-foreground-subtle`,children:c??f(`placementBoard.weightSliderStack.noDetectEnabledNodesEnable`,`No detect-enabled nodes. Enable “Detect” on a node above to distribute detection weight.`)});let x=e.length===1;return a(`div`,{className:`space-y-3`,children:[e.map(e=>{let t=p[e.id]??0,r=h.has(e.id);return a(`div`,{className:`flex items-center gap-3`,children:[d(`span`,{className:`w-28 shrink-0 truncate text-xs font-medium text-foreground`,title:e.name,children:e.name}),d(`input`,{"aria-label":f(`placementBoard.weightSliderStack.for`,`{{weightLabel}} for {{name}}`,{weightLabel:s,name:e.name}),type:`range`,min:0,max:100,step:1,value:Math.round(t),disabled:u||n||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`}),a(`span`,{className:`w-10 shrink-0 text-right font-mono text-xs tabular-nums text-foreground`,children:[Math.round(t),`%`]}),!u&&d(`button`,{type:`button`,onClick:()=>v(e.id),disabled:n||x,"aria-pressed":r,title:r?f(`placementBoard.weightSliderStack.unlockAllowRebalancing`,`Unlock — allow rebalancing`):f(`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:d(r?I:j,{className:`h-3.5 w-3.5`})})]},e.id)}),d(`p`,{className:`text-[10px] leading-tight text-foreground-subtle`,children:l??d(o,{children:f(`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 _a(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}function va(e){if(e.presence===`absent`)return`absent`;if(e.presence===`unknown`)return`unknown`;switch(e.exclusion){case null:return`active`;case`disabled`:return`disabled`;case`unavailable`:return e.available?`backoff`:`unavailable`;case`cannot-host-camera-root`:return`root-incapable`;case`accelerator-preferred`:return`standby`}}function ya(e,t,n){let r=new Map((t?.devices??[]).map(e=>[e.deviceKey,e])),i=new Map((n?.devices??[]).map(e=>[e.deviceKey,e.sessionsNow]));return e.map(e=>{let t=r.get(e.key),a=n===void 0?null:i.get(e.key)??0;return{device:e,state:va(e),share:t===void 0?null:{configuredPct:t.configuredPct,effectivePct:t.effectivePct},sessionsNow:a,atCap:a!==null&&e.maxSessions!==null&&a>=e.maxSessions}})}var ba={active:`success`,disabled:`neutral`,absent:`danger`,unknown:`neutral`,unavailable:`warning`,backoff:`warning`,"root-incapable":`info`,standby:`neutral`};e();function xa(e){let t=Le(e),n=e.backend.toLowerCase(),r=e.device.toLowerCase();return e.key===`cpu`||r===`cpu`?{label:t,Icon:w,hue:`slate`}:r===`npu`?{label:t,Icon:B,hue:`sky`}:r===`gpu`||r===`igpu`?{label:t,Icon:ye,hue:`violet`}:n===`edgetpu`?{label:t,Icon:Ce,hue:`emerald`}:{label:t,Icon:w,hue:`slate`}}var Sa={active:[`placementBoard.nodeInferenceDevices.state.active`,`in use`],disabled:[`placementBoard.nodeInferenceDevices.state.disabled`,`switched off`],absent:[`placementBoard.nodeInferenceDevices.state.absent`,`absent`],unknown:[`placementBoard.nodeInferenceDevices.state.unknown`,`unknown`],unavailable:[`placementBoard.nodeInferenceDevices.state.unavailable`,`unavailable`],backoff:[`placementBoard.nodeInferenceDevices.state.backoff`,`pool down`],"root-incapable":[`placementBoard.nodeInferenceDevices.state.rootIncapable`,`no root model`],standby:[`placementBoard.nodeInferenceDevices.state.standby`,`fallback`]},Ca={active:[`placementBoard.nodeInferenceDevices.stateHint.active`,`A camera-root candidate: placement may start sessions on it.`],disabled:[`placementBoard.nodeInferenceDevices.stateHint.disabled`,`Switched off: it takes no sessions.`],absent:[`placementBoard.nodeInferenceDevices.stateHint.absent`,`The node no longer reports this device (unplugged, or moved to another node). Its settings are kept; it is never used. Forget it to delete them.`],unknown:[`placementBoard.nodeInferenceDevices.stateHint.unknown`,`The node's probe did not answer, so whether the device is there is not known.`],unavailable:[`placementBoard.nodeInferenceDevices.stateHint.unavailable`,`On the node, but the probe reports it unusable.`],backoff:[`placementBoard.nodeInferenceDevices.stateHint.backoff`,`Reported by the node, but its inference pool is down or backing off.`],"root-incapable":[`placementBoard.nodeInferenceDevices.stateHint.rootIncapable`,`Its format cannot run the camera root detector; it serves enrichment steps only.`],standby:[`placementBoard.nodeInferenceDevices.stateHint.standby`,`The CPU fallback: it takes no sessions while an accelerator is serving this node.`]};function wa({nodeId:e,nodeName:i,isOnline:s,suggestedMaxSessions:l,shareSource:u,sharesAutomatic:f,share:p,placed:m}){let{t:g}=X(),_=c(),{data:v,isLoading:y}=rt({nodeId:e},{refetchInterval:15e3}),b=()=>{_.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getNodeInferenceDevices`]]})},x=Qe({onSettled:b}),S=Wt({onSettled:b}),C=Nt.platformProbe.rescanAccelerators.useMutation({onSettled:b}),w=v?.devices??[],T=v?.reachable??s,[D,O]=r({});t(()=>{O(Object.fromEntries(w.map(e=>[e.key,Ta(e)])))},[w.map(e=>`${e.key}:${e.enabled}:${e.weight}:${e.maxSessions}:${JSON.stringify(e.steps??{})}`).join(`|`)]);let k=n(()=>w.filter(e=>(D[e.key]?.enabled??e.enabled)&&e.available).length,[w,D]),[A,j]=r(null),M=A??!0,N=t=>{let n=w.map(e=>{let n=t[e.key]??Ta(e);return{key:e.key,enabled:n.enabled,weight:n.weight,maxSessions:n.maxSessions,steps:n.steps}});x.mutate({agentNodeId:e,inferenceDevices:Rr(n)})},P=(e,t)=>{let n=D[e.key]??Ta(e),r={...D,[e.key]:{...n,...t}};O(r),N(r)},te=n(()=>ya(w,p,m),[w,p,m]),F=n(()=>w.filter(e=>(D[e.key]?.enabled??e.enabled)&&e.available),[w,D]),I=n(()=>F.map(e=>({id:e.key,name:xa(e).label,weight:D[e.key]?.weight??e.weight})),[F,D]),L=e=>{let t={...D};for(let n of e){let e=t[n.nodeId];e&&(t[n.nodeId]={...e,weight:n.weight})}O(t),N(t)},R=x.isPending||S.isPending,z=Ea(g,f?u:`manual`),B=[{key:`device`,header:g(`placementBoard.nodeInferenceDevices.colDevice`,`Device`),nowrap:!1,sortValue:e=>xa(e.device).label,render:e=>d(Oa,{row:e,steps:D[e.device.key]?.steps})},{key:`state`,header:g(`placementBoard.nodeInferenceDevices.colState`,`State`),sortValue:e=>e.state,render:e=>d(`span`,{title:g(Ca[e.state][0],Ca[e.state][1]),children:d(q,{variant:ba[e.state],size:`sm`,children:g(Sa[e.state][0],Sa[e.state][1])})})},{key:`share`,header:g(`placementBoard.nodeInferenceDevices.colShare`,`Share`),align:`right`,sortValue:e=>e.share?.effectivePct??null,render:e=>d(ka,{row:e,sourceLabel:z})},{key:`sessions`,header:g(`placementBoard.nodeInferenceDevices.colSessions`,`Sessions`),align:`right`,sortValue:e=>e.sessionsNow,render:e=>a(`span`,{className:`tabular-nums text-xs text-foreground`,children:[e.sessionsNow??`—`,e.atCap&&d(q,{variant:`warning`,size:`sm`,className:`ml-1`,children:g(`placementBoard.nodeInferenceDevices.atCap`,`at cap`)})]})},{key:`cap`,header:g(`placementBoard.nodeInferenceDevices.colCap`,`Max sessions`),notSortableReason:g(`placementBoard.nodeInferenceDevices.capNotSortable`,`An editable field: sort by Sessions instead.`),render:e=>{let t=D[e.device.key]??Ta(e.device);if(!(t.enabled&&e.device.available))return d(`span`,{className:`text-xs text-foreground-subtle`,children:`—`});let n=xa(e.device).label;return a(`div`,{className:`flex items-center justify-end gap-1`,children:[d(et,{type:`number`,min:1,placeholder:`∞`,value:t.maxSessions??``,onChange:t=>{let n=t.target.value.trim(),r=n===``?null:Number.parseInt(n,10);P(e.device,{maxSessions:r!==null&&r>0?r:null})},disabled:R,"aria-label":g(`placementBoard.nodeInferenceDevices.maxConcurrentSessionsFor`,`Max concurrent sessions for {{label}}`,{label:n}),className:`w-16 text-right`}),d(Aa,{suggested:l?.[e.device.key]??null,current:t.maxSessions,pending:R,onApply:t=>P(e.device,{maxSessions:t})})]})}},{key:`enabled`,header:g(`placementBoard.nodeInferenceDevices.colEnabled`,`Enabled`),align:`right`,notSortableReason:g(`placementBoard.nodeInferenceDevices.enabledNotSortable`,`A switch: sort by State instead.`),render:t=>{let n=xa(t.device).label;if(t.state===`absent`)return d(Rt,{label:g(`placementBoard.nodeInferenceDevices.forget`,`Forget`),icon:h,size:`sm`,triggerVariant:`ghost`,disabled:R,title:g(`placementBoard.nodeInferenceDevices.forgetTitle`,`Forget {{label}} on {{node}}?`,{label:n,node:i}),description:g(`placementBoard.nodeInferenceDevices.forgetDescription`,`Its stored settings (switch, weight, cap, step models) are deleted. If the device comes back it starts from the defaults.`),action:()=>S.mutateAsync({agentNodeId:e,deviceKey:t.device.key})});let r=D[t.device.key]??Ta(t.device);return d(We,{checked:r.enabled&&t.device.available,onCheckedChange:()=>P(t.device,{enabled:!r.enabled}),disabled:!t.device.available||R,"aria-label":g(`placementBoard.nodeInferenceDevices.enable`,`Enable {{label}}`,{label:n})})}}],V=x.error??S.error??C.error;return a(`div`,{className:`rounded-lg border border-border bg-surface`,children:[a(`div`,{className:`flex items-center gap-2 px-3 py-2`,children:[a(K,{variant:`ghost`,size:`sm`,onClick:()=>j(!M),className:`min-w-0 flex-1 justify-start`,"aria-expanded":M,children:[d(U,{className:`h-4 w-4 shrink-0 text-foreground-subtle transition-transform ${M?`rotate-90`:``}`}),d(`span`,{className:`truncate text-sm font-medium text-foreground`,children:i}),d(`span`,{className:`ml-auto flex items-center gap-1 text-xs text-foreground-subtle`,children:T?a(o,{children:[d(Te,{className:`h-3.5 w-3.5`}),g(`pipeline.nodeInferenceDevices.accelerators`,{count:k})]}):a(o,{children:[d(E,{className:`h-3.5 w-3.5`}),` `,g(`common.unreachable`)]})})]}),a(K,{variant:`ghost`,size:`sm`,onClick:()=>C.mutate({nodeId:e}),disabled:C.isPending||!T,title:g(`placementBoard.nodeInferenceDevices.rescanTitle`,`Probe this node for accelerators now (a Coral plugged in or pulled out). The node also re-probes every minute.`),children:[d(ee,{className:`h-3.5 w-3.5 ${C.isPending?`animate-spin`:``}`}),g(`placementBoard.nodeInferenceDevices.rescan`,`Rescan`)]})]}),M&&a(`div`,{className:`space-y-3 border-t border-border p-3`,children:[T?y&&w.length===0?d(`p`,{className:`text-center text-xs text-foreground-subtle`,children:g(`placementBoard.nodeInferenceDevices.probingAccelerators`,`Probing accelerators…`)}):d(kt,{columns:B,rows:te,rowKey:e=>e.device.key,minWidthPx:640,bordered:!1,emptyMessage:g(`placementBoard.nodeInferenceDevices.noInferenceDevicesReportedBy`,`No inference devices reported by this node's platform probe.`)}):d(ja,{}),C.data!==void 0&&d(`p`,{className:`text-xs text-foreground-subtle`,children:Da(g,C.data.appeared,C.data.disappeared)}),T&&!f&&F.length>=2&&a(`div`,{className:`space-y-3 rounded-lg border border-border p-3`,children:[a(`h4`,{className:`flex items-center gap-1.5 text-xs font-semibold uppercase tracking-wide text-foreground-subtle`,children:[d(xe,{className:`h-3.5 w-3.5`}),g(`placementBoard.nodeInferenceDevices.acceleratorShare`,`Accelerator share`)]}),d(ga,{nodes:I,pending:R,onCommitWeights:L,weightLabel:`Accelerator share`,footnote:g(`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%.`)})]}),V!=null&&a(`div`,{className:`rounded-md border border-danger/30 bg-danger/5 px-3 py-2 text-xs text-danger`,children:[g(`placementBoard.nodeInferenceDevices.failedToSaveInferenceDevices`,`Failed to save inference devices:`),` `,V.message]})]})]})}function Ta(e){return{enabled:e.enabled,weight:e.weight,maxSessions:e.maxSessions,steps:e.steps??{}}}function Ea(e,t){switch(t){case`benchmark`:return e(`placementBoard.nodeInferenceDevices.sourceBenchmark`,`benchmark`);case`hardware`:return e(`placementBoard.nodeInferenceDevices.sourceHardware`,`hardware`);case`manual`:return e(`placementBoard.nodeInferenceDevices.sourceManual`,`manual`);case void 0:return null}}function Da(e,t,n){return t.length===0&&n.length===0?e(`placementBoard.nodeInferenceDevices.rescanNoChange`,`Rescanned: no change.`):e(`placementBoard.nodeInferenceDevices.rescanChanged`,`Rescanned: appeared {{appeared}} · disappeared {{disappeared}}`,{appeared:t.length>0?t.join(`, `):`—`,disappeared:n.length>0?n.join(`, `):`—`})}function Oa({row:e,steps:t}){let n=xa(e.device),r=_a({defaultModelId:e.device.defaultModelId,steps:t??e.device.steps??{}});return a(`div`,{className:`flex min-w-0 items-center gap-2`,children:[d(n.Icon,{className:`h-4 w-4 shrink-0 text-foreground-subtle`}),a(`div`,{className:`min-w-0`,children:[a(`div`,{className:`flex items-center gap-1.5`,children:[d(`span`,{className:`text-sm font-medium text-foreground`,children:n.label}),d(q,{variant:`neutral`,size:`sm`,className:`font-mono`,children:e.device.format})]}),a(`div`,{className:`flex flex-wrap items-center gap-x-1.5 text-xs text-foreground-subtle`,children:[d(`span`,{className:`font-mono`,children:e.device.key}),r!==null&&a(o,{children:[d(`span`,{"aria-hidden":!0,children:`·`}),d(`span`,{children:d(un,{i18nKey:`pipeline.nodeInferenceDevices.rootModel`,values:{model:r},components:{mono:d(`span`,{className:`font-mono text-foreground-muted`})}})})]})]})]})]})}function ka({row:e,sourceLabel:t}){let{t:n}=X();if(e.share===null)return d(`span`,{className:`text-xs text-foreground-subtle`,children:`—`});let{configuredPct:r,effectivePct:i}=e.share,o=Math.round(r)!==Math.round(i);return a(`div`,{className:`text-right`,children:[a(`div`,{className:`tabular-nums text-sm text-foreground`,children:[Math.round(i),`%`]}),a(`div`,{className:`text-xs text-foreground-subtle`,children:[o?n(`placementBoard.nodeInferenceDevices.shareConfigured`,`set {{pct}}%`,{pct:Math.round(r)}):null,o&&t!==null?` · `:null,t]})]})}function Aa({suggested:e,current:t,pending:n,onApply:r}){let{t:i}=X();return e===null||e<1||e===t?null:d(K,{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 ja(){let{t:e}=X();return a(`div`,{className:`flex flex-col items-center gap-2 px-4 py-6 text-center`,children:[d(E,{className:`h-6 w-6 text-foreground-subtle`}),d(`p`,{className:`text-xs font-medium text-foreground`,children:e(`placementBoard.nodeInferenceDevices.nodeUnreachable`,`Node unreachable`)}),d(`p`,{className:`max-w-sm text-xs 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.`)})]})}e();var Ma=3600*1e3,Na=2e4,Pa=.4;function Fa({refreshToken:e,onOpenAutoTune:t}){let{t:i}=X(),s=c(),{nodes:u}=G(),f=Ft(void 0),m=en({isCamera:!0,projection:`slim`}),h=It({windowMs:Ma},{refetchInterval:Na,placeholderData:l}).data,g=nn(void 0,{refetchInterval:Na,placeholderData:l}).data,_=()=>{Rn(s),s.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getNodeInferenceDevices`]]})},v=Gt({onSuccess:_}),y=ot({onSuccess:()=>{_(),s.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getEffectiveShares`]]})}}),b=on({onSuccess:_}),S=Ue(),[C,E]=r(!1),D=g?.source,ee=D===`benchmark`?`benchmark`:`hardware`,O=dt({headroom:Pa,source:ee},{enabled:C,staleTime:1/0}),k=O.data,A=n(()=>{let e=new Map((f.data??[]).map(e=>[e.nodeId,e.settings]));return u.filter(t=>Yn(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:Pn(n,`detectWeight`)??1,maxCameras:Pn(n,`maxCameras`)}})},[u,f.data]),j=e=>u.find(t=>t.id===e)?.name??e,M=cr((m.data??[]).map(e=>({id:e.id,name:e.name}))),N=k?aa(k):void 0,P=sa(A,g),te=D!==`manual`,F=g!==void 0&&g.source!==`manual`&&!g.autoPending,I=e=>g?.nodes.find(t=>t.nodeId===e),L=e=>h?.nodes.find(t=>t.nodeId===e),R=g?ca(g,j):null,V=g?da(g,j):null,ne=la.find(e=>e.value===D)?.hint;return a(`div`,{className:`space-y-3 sm:space-y-4`,children:[d(er,{refreshToken:e}),d(Qi,{stats:h,showAccelerators:!1,...g!==void 0&&g.source!==`manual`&&!g.autoPending?{targetWeights:Object.fromEntries(g.nodes.map(e=>[e.nodeId,e.configuredPct]))}:{}}),d(J,{headingId:`load-balancing-node-shares`,title:i(`pipeline.clusterLoadBalancingTab.nodeShares`,`Node shares`),icon:xe,actions:a(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[d(`div`,{role:`radiogroup`,"aria-label":i(`pipeline.clusterLoadBalancingTab.shareSource`,`Share source`),className:`flex items-center gap-1`,children:la.map(e=>d(K,{role:`radio`,"aria-checked":D===e.value,variant:D===e.value?`primary`:`outline`,size:`sm`,title:e.hint,disabled:y.isPending||g===void 0,onClick:()=>{D!==e.value&&y.mutate({source:e.value})},children:e.label},e.value))}),a(K,{variant:`outline`,size:`sm`,onClick:()=>{E(!0),C&&O.refetch()},disabled:O.isFetching,children:[d(z,{className:`h-3.5 w-3.5`}),O.isFetching?i(`pipeline.clusterLoadBalancingTab.suggesting`,`Suggesting…`):ee===`benchmark`?i(`pipeline.clusterLoadBalancingTab.suggestFromBenchmark`,`Suggest from benchmark`):i(`pipeline.clusterLoadBalancingTab.suggestFromHardware`,`Suggest from hardware`)]}),a(K,{variant:`ghost`,size:`sm`,onClick:t,children:[d(T,{className:`h-3.5 w-3.5`}),i(`pipeline.clusterLoadBalancingTab.autoTune`,`Auto tune`)]}),a(K,{variant:`outline`,size:`sm`,onClick:()=>S.mutate(void 0),disabled:S.isPending,title:i(`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:[d(B,{className:`h-3.5 w-3.5`}),S.isPending?i(`pipeline.clusterLoadBalancingTab.rebalancing`,`Rebalancing…`):i(`pipeline.clusterLoadBalancingTab.rebalance`,`Rebalance`)]})]}),children:a(`div`,{className:`${p} space-y-3`,children:[ne!==void 0&&d(`p`,{className:`text-[10px] text-foreground-subtle`,children:ne}),h&&a(`p`,{className:`text-[10px] text-foreground-subtle`,children:[i(`pipeline.clusterLoadBalancingTab.policy`,`Policy:`),` `,d(q,{variant:h.policy===`share`?`info`:`default`,children:h.policy===`share`?i(`pipeline.clusterLoadBalancingTab.honourShares`,`honour shares`):`least-loaded`}),` `,` · ${i(`pipeline.clusterLoadBalancingTab.clusterPeak`,{count:h.clusterPeakSessions})}`,h.policy===`least-loaded`&&` · ${i(`pipeline.clusterLoadBalancingTab.leastLoadedNote`)}`]}),d(ga,{nodes:P.nodes,pending:v.isPending,readOnly:P.readOnly,onCommitWeights:e=>v.mutate(ra(e)),weightLabel:`Node share`,...P.readOnly?{footnote:g?.autoPending?d(o,{children:i(`pipeline.clusterLoadBalancingTab.automaticSharesAreBeingComputed`,`Automatic shares are being computed from the cluster's measured capacity; the stored values are used meanwhile.`)}):a(o,{children:[D===`benchmark`?i(`pipeline.clusterLoadBalancingTab.benchmarkEachNodeSShare`,`Benchmark: each node's share follows its measured capacity from node benchmark results (hardware capacity where it has none)`):i(`pipeline.clusterLoadBalancingTab.hardwareEachNodeSShare`,`Hardware: each node's share follows its capacity at its Auto tune model, from the measured speed of its hardware`),i(`pipeline.clusterLoadBalancingTab.recomputedWheneverANodeOr`,`, recomputed whenever a node or accelerator is added, removed, switched on or off, or changes model`),g?.computedAt!=null&&d(`span`,{className:`ml-1`,children:i(g.trigger===null?`pipeline.clusterLoadBalancingTab.lastAt`:`pipeline.clusterLoadBalancingTab.lastAtTrigger`,{time:new Date(g.computedAt).toLocaleTimeString(),trigger:g.trigger??``})}),`.`]})}:{}}),R!==null&&d(`p`,{className:`text-[10px] text-foreground-subtle`,children:R}),V!==null&&d(`p`,{className:`text-[10px] text-foreground-subtle`,"data-testid":`benchmark-fallback-note`,children:V}),y.isError&&d(At,{message:i(`pipeline.clusterLoadBalancingTab.switchFailed`,{message:y.error instanceof Error?y.error.message:i(`common.unknownError`)})}),v.isError&&d(At,{message:i(`pipeline.clusterLoadBalancingTab.saveFailed`,{message:v.error instanceof Error?v.error.message:i(`common.unknownError`)})}),a(`details`,{className:`rounded-md border border-border`,children:[d(`summary`,{className:`${x} cursor-pointer text-xs text-foreground`,children:i(`pipeline.clusterLoadBalancingTab.maxConcurrentSessionsAdvanced`,`Max concurrent sessions (advanced)`)}),d(`ul`,{className:`divide-y divide-border border-t border-border`,children:A.map(e=>a(`li`,{className:`${x} flex items-center gap-2`,children:[d(`span`,{className:`min-w-0 flex-1 truncate text-xs text-foreground`,children:e.name}),d(et,{type:`number`,min:1,placeholder:`∞`,defaultValue:e.maxCameras??``,"aria-label":i(`pipeline.clusterLoadBalancingTab.maxConcurrentSessionsFor`,`Max concurrent sessions for {{name}}`,{name:e.name}),className:`w-20 text-right`,disabled:b.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&&b.mutate({agentNodeId:e.id,maxCameras:i})}})]},e.id))}),d(`p`,{className:`${x} ${W} border-t border-border`,children:i(`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.`)})]})]})}),O.isError&&d(At,{message:i(`pipeline.clusterLoadBalancingTab.suggestionFailed`,{message:O.error instanceof Error?O.error.message:i(`common.unknownError`)})}),k&&d(Ia,{suggestion:k,nameOf:j,pending:v.isPending,...te?{}:{onApply:()=>v.mutate(ia(k))}}),d(J,{headingId:`load-balancing-accelerators`,title:i(`pipeline.clusterLoadBalancingTab.accelerators`,`Accelerators`),icon:w,children:d(`div`,{className:`${p} space-y-2`,children:A.length===0?d(gt,{title:i(`pipeline.clusterLoadBalancingTab.noDetectCapableNodes`,`No detect-capable nodes`),description:i(`pipeline.clusterLoadBalancingTab.enableDetectionOnANode`,`Enable detection on a node in Roles & nodes to configure its accelerators.`)}):A.map(e=>d(wa,{nodeId:e.id,nodeName:e.name,isOnline:e.isOnline,...N?.[e.id]===void 0?{}:{suggestedMaxSessions:N[e.id]},sharesAutomatic:F,...g===void 0?{}:{shareSource:g.source},...I(e.id)===void 0?{}:{share:I(e.id)},...L(e.id)===void 0?{}:{placed:L(e.id)}},e.id))})}),h!==void 0&&h.stalePins.length>0&&d(La,{stats:h,cameraName:M})]})}function Ia({suggestion:e,nameOf:t,pending:n,onApply:r}){let{t:i}=X();return a(J,{headingId:`load-balancing-suggestion`,title:e.source===`benchmark`?i(`pipeline.clusterLoadBalancingTab.suggestedFromBenchmark`,`Suggested from benchmark`):i(`pipeline.clusterLoadBalancingTab.suggestedFromHardware`,`Suggested from hardware`),icon:z,...r===void 0?{}:{actions:d(K,{size:`sm`,onClick:r,disabled:n,children:i(`pipeline.clusterLoadBalancingTab.applySuggestedShares`,`Apply suggested shares`)})},children:[d(`ul`,{className:`divide-y divide-border`,children:e.nodes.map(e=>a(`li`,{className:`${x} space-y-0.5`,children:[a(`div`,{className:`flex items-baseline gap-2 text-xs`,children:[d(`span`,{className:`min-w-0 flex-1 truncate font-medium text-foreground`,children:t(e.nodeId)}),d(`span`,{className:`tabular-nums text-foreground`,children:e.share===null?i(`common.skipped`):`${e.share}%`})]}),a(`p`,{className:W,children:[ua(e.capacityFallback)===null?``:`${ua(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))}),a(`p`,{className:`${x} ${W} 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 La({stats:e,cameraName:t}){let{t:n}=X(),r=c(),i=ct({onSuccess:()=>{r.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPlacementStats`]]}),r.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineDevicePin`]]})}});return d(J,{headingId:`load-balancing-stale-pins`,title:n(`pipeline.clusterLoadBalancingTab.staleDevicePins`,`Stale device pins`),icon:Se,children:d(`ul`,{className:`divide-y divide-border`,children:e.stalePins.map(e=>a(`li`,{className:`${x} flex items-center gap-2`,children:[a(`div`,{className:`min-w-0 flex-1`,children:[d(`p`,{className:`truncate text-xs text-foreground`,title:t(e.deviceId),children:t(e.deviceId)}),d(`p`,{className:W,children:oa(e)})]}),d(K,{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 Ra({node:e,emphasis:t=!1}){let{t:n}=X(),r=e.isHub?k:w;return a(`div`,{className:`flex items-center gap-2.5 min-w-0`,children:[d(`span`,{className:`h-2 w-2 shrink-0 rounded-full ${e.isOnline?`bg-success`:`bg-danger`}`,"aria-hidden":`true`}),d(r,{className:`h-4 w-4 shrink-0 text-foreground-subtle`,"aria-hidden":`true`}),a(`div`,{className:`min-w-0`,children:[a(`div`,{className:`flex items-center gap-1.5 ${t?`text-sm`:`text-xs`} font-semibold text-foreground`,children:[d(`span`,{className:`truncate`,children:e.name}),e.isHub&&d(q,{variant:`info`,className:`px-1.5 py-0 text-[9px] uppercase tracking-wider`,children:n(`common.hubWord`)}),!e.isOnline&&d(q,{variant:`danger`,className:`px-1.5 py-0 text-[9px] uppercase tracking-wider`,children:n(`common.offline`)})]}),d(`div`,{className:`font-mono text-[10px] text-foreground-subtle truncate`,children:e.id})]})]})}function za({nodes:e,actions:t}){let{t:n}=X();return d(kt,{columns:[{key:`node`,header:n(`placementBoard.nodeCapabilitiesTable.node`,`Node`),sortValue:e=>e.name,render:e=>d(Ra,{node:e})},...zn.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=>d(We,{"aria-label":n(`placementBoard.nodeCapabilitiesTable.on`,`{{label}} on {{name}}`,{label:n(e.labelKey),name:r.name}),title:n(e.hintKey),checked:Nn(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 Ba({roleValues:e,options:t,pending:n,onRoleChange:r}){let{t:i}=X(),o=t.map(e=>({value:e.id,label:e.id===`hub`?i(`placementBoard.roleControls.default`,`{{name}} (default)`,{name:e.name}):e.name}));return d(`ul`,{className:`divide-y divide-border`,children:Un.map(t=>a(`li`,{className:`${x} flex flex-wrap items-center gap-x-3 gap-y-1.5`,children:[a(`div`,{className:`min-w-0 flex-1 basis-56`,children:[d(`div`,{className:`text-xs font-medium text-foreground`,children:Fn(t)}),d(`p`,{className:W,children:In(t)})]}),d(`div`,{className:`w-full sm:w-48`,children:d(Ke,{"aria-label":i(`placementBoard.roleControls.node`,`{{value1}} node`,{value1:Fn(t)}),value:e[t],disabled:n,options:o,onChange:e=>r(t,e.target.value)})})]},t))})}e();function Va(){let{t:e}=X(),t=c(),{nodes:r}=G(),i=Ft(void 0),o=Ze({addonId:Hn}),s=Ze({addonId:Mn}),l=Ze({addonId:Wn}),u=()=>Rn(t),f=Be({onSuccess:u}),p=Qt({onSuccess:u}),m=n(()=>{let e=new Map;for(let t of i.data??[])e.set(t.nodeId,t.settings);return e},[i.data]),h=n(()=>r.map(e=>{let t=m.get(e.id),n=Yn(t,e.isHub);return{id:e.id,name:e.name,isHub:e.isHub,isOnline:e.isOnline,settings:t,effective:n}}),[r,m]),g={ingestNode:Vn(o.data,`ingestNode`,`hub`),recordingNode:Vn(s.data,Bn,`hub`),audioNode:Vn(o.data,`audioNode`,`hub`),motionNode:Vn(o.data,`motionNode`,`hub`),postProcessingNode:Vn(l.data,Ln,`hub`)},_=n(()=>{let e=r.filter(e=>e.isOnline).map(e=>e.id),t=e=>r.find(t=>t.id===e)?.name||e;return[...new Set([`hub`,...Un.map(e=>g[e]),...e])].filter(e=>e.length>0).map(e=>({id:e,name:t(e)}))},[r,g]),v=i.isLoading||o.isLoading||s.isLoading||l.isLoading,y=(e,t,n)=>{f.mutate({agentNodeId:e,[t]:n})},b=(e,t)=>{if(e===`recordingNode`){p.mutate({addonId:Mn,patch:{[Bn]:t}});return}if(e===`postProcessingNode`){p.mutate({addonId:Wn,patch:{[Ln]:t}});return}p.mutate({addonId:Hn,patch:{[e]:t}})},x={capabilityPending:f.isPending,onToggleCapability:y},S=v?d(te,{className:`h-3.5 w-3.5 animate-spin text-foreground-subtle`,"aria-label":e(`pipeline.clusterRolesNodesTab.loading`,`Loading`)}):null;return a(`div`,{className:`space-y-3 sm:space-y-4`,children:[a(J,{headingId:`roles-nodes-cluster-roles`,title:e(`pipeline.clusterRolesNodesTab.clusterRoles`,`Cluster roles`),icon:be,actions:S,children:[d(`p`,{className:`${W} 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.`)}),d(Ba,{roleValues:g,options:_,pending:p.isPending,onRoleChange:b})]}),d(J,{headingId:`roles-nodes-node-capabilities`,title:e(`pipeline.clusterRolesNodesTab.nodeCapabilities`,`Node capabilities`),icon:k,children:d(za,{nodes:h,actions:x})})]})}e();var Ha=2500,Ua={faces:P,"semantic-search":T,"detail-crop":we,"native-lease":Te,"runner-defaults":w,"load-balancer":xe,failover:O},Wa=[`cluster`,Jr];function Ga(e){t(()=>{if(e===null)return;let t=Xr[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`),Ha),!0)};if(r())return;let i=new MutationObserver(()=>{r()&&i.disconnect()});return i.observe(document.body,{childList:!0,subtree:!0}),()=>i.disconnect()},[e])}function Ka({section:e}){let{t}=X();return d(`div`,{"data-cluster-settings-card":e.id,className:`rounded-lg`,children:d(J,{headingId:`cluster-settings-${e.id}`,title:e.title,...Ua[e.id]===void 0?{}:{icon:Ua[e.id]},children:a(`div`,{className:`${p} space-y-3`,children:[d(`p`,{className:W,children:e.hint}),e.panels.map(e=>d(jn,{nodeId:`hub`,addonIds:[e.addonId],level:`global`,hideSectionChrome:!0,omitSectionIds:Wa.filter(t=>!(e.sectionIds??[]).includes(t)),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 qa({refreshToken:e}){let[t]=fn();return Ga(t.get($r)),d(`div`,{className:`space-y-3 sm:space-y-4`,children:Yr.map(e=>d(Ka,{section:e},e.id))})}var Ja=`pipeline-orchestrator`,Ya=200;function Xa(){let{t:e}=X();return a(`div`,{className:`flex flex-col gap-3`,children:[a(`div`,{children:[d(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:e(`pipeline.clusterOrchestratorLogsTab.orchestratorLogs`,`Orchestrator logs`)}),d(`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.`)})]}),d(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:d(pt,{addonId:Ja,limit:Ya,maxHeight:`max-h-[calc(100vh-360px)]`,showScope:!0,showDeviceChip:!0,showFilters:!1,showSourceSelect:!0})})]})}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 Qa(e){return Za.some(t=>t.id===e)}function $a({refreshToken:e}){let{t}=X(),[n,r]=fn(),i=n.get(Qr),o=Qa(i)?i:`assignments`,s=e=>{r(t=>{let n=new URLSearchParams(t);return n.set(Qr,e),n.delete($r),n},{replace:!0})};return a(`div`,{className:`flex flex-col h-full`,children:[a(`div`,{className:`px-4 sm:px-6 py-4 border-b border-border`,children:[d(`h2`,{className:`text-base font-semibold text-foreground`,children:t(`pipeline.clusterDetail.clusterOrchestration`,`Cluster Orchestration`)}),d(`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.`)})]}),d(`div`,{className:`flex items-center gap-1 px-4 sm:px-6 border-b border-border overflow-x-auto`,children:Za.map(e=>d(`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 ${o===e.id?`border-primary text-primary`:`border-transparent text-foreground-subtle hover:text-foreground`}`,children:t(e.labelKey)},e.id))}),a(`div`,{className:`flex-1 min-h-0 overflow-y-auto p-4 sm:p-6 @container/clustertab`,children:[o===`assignments`&&d(Ti,{}),o===`load-balancing`&&d(Fa,{refreshToken:e,onOpenAutoTune:()=>s(`auto-tune`)}),o===`auto-tune`&&d(Wi,{}),o===`roles-nodes`&&d(Va,{}),o===`settings`&&d(qa,{refreshToken:e}),o===`logs`&&d(Xa,{})]})]})}function Q({title:e,children:t}){return a(`div`,{className:`bg-background px-3.5 py-3 min-w-0`,children:[d(`div`,{className:`text-[9px] font-semibold uppercase tracking-[0.14em] text-foreground-subtle mb-2`,children:e}),d(`div`,{className:`flex flex-col gap-1 min-w-0`,children:t})]})}function $({label:e,children:t,overridden:n=!1}){return a(`div`,{className:`flex items-baseline gap-2 text-[11px] leading-snug min-w-0`,children:[d(`span`,{className:`text-foreground-subtle shrink-0 w-24 truncate`,title:e,children:e}),d(`span`,{className:`font-mono tabular-nums text-foreground min-w-0 truncate flex-1`,children:t}),n&&d(eo,{})]})}function eo(){let{t:e}=X();return d(`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 to={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 no({tone:e=`neutral`,children:t,title:n}){return d(`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 ${to[e]}`,children:t})}function ro({children:e}){return d(`div`,{className:`text-[11px] text-foreground-subtle italic`,children:e})}function io({icon:e,label:t,nodeId:n,pinned:r,reason:i,overridden:s}){let{t:c}=X();return a(`div`,{className:`flex items-center gap-2 text-[11px] leading-snug min-w-0`,children:[d(e,{className:`h-3 w-3 text-foreground-subtle shrink-0`}),d(`span`,{className:`text-foreground-subtle w-[4.5rem] shrink-0`,children:t}),n===null?d(`span`,{className:`text-foreground-subtle italic`,children:c(`cameras.configBlocks.unassigned`)}):a(o,{children:[d(`span`,{className:`font-mono text-foreground truncate`,title:n,children:n}),r?a(`span`,{className:`inline-flex items-center gap-0.5 text-[10px] text-warning shrink-0`,title:c(`cameras.configBlocks.manuallyPinned`,`Manually pinned`),children:[d(_,{className:`h-2.5 w-2.5`}),` `,c(`cameras.configBlocks.manual`)]}):d(`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`)})}),s&&d(`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 ao({assignment:e,settings:t,onlineNodes:n,pinPending:r,onDetectionPinChange:i}){let{t:o}=X(),s=e.pinned.detection&&e.detectionNodeId!==null?e.detectionNodeId:`auto`,c=[...new Set([...e.detectionNodeId===null?[]:[e.detectionNodeId],...n.map(e=>e.id)])];return a(Q,{title:o(`cameras.configBlocks.whereItRuns`,`Where it runs`),children:[d(io,{icon:w,label:o(`cameras.configBlocks.detection`,`Detection`),nodeId:e.detectionNodeId,pinned:e.pinned.detection,reason:e.reasons.detection,overridden:t.overriddenKeys.has(`pipelineNodeId`)}),d(io,{icon:m,label:o(`cameras.configBlocks.decoder`,`Decoder`),nodeId:e.decoderNodeId,pinned:e.pinned.decoder,reason:e.reasons.decoder,overridden:t.overriddenKeys.has(`decoderNodeId`)}),d(io,{icon:C,label:o(`cameras.configBlocks.audio`,`Audio`),nodeId:e.audioNodeId,pinned:e.pinned.audio,reason:e.reasons.audio,overridden:t.overriddenKeys.has(`audioNodeId`)}),d(io,{icon:H,label:o(`cameras.configBlocks.source`,`Source`),nodeId:e.sourceNodeId,pinned:!1,reason:`ingest owner`,overridden:!1}),d(`div`,{className:`mt-1.5`,children:a(`select`,{value:s,disabled:r,"aria-label":o(`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:[d(`option`,{value:`auto`,children:o(`cameras.configBlocks.autoLoadBalanced`,`Auto (load balanced)`)}),c.map(e=>d(`option`,{value:e,children:o(`cameras.configBlocks.pinDetection`,{node:n.find(t=>t.id===e)?.name??e})},e))]})})]})}function oo(e){return`${e.width}×${e.height} ${e.codec} @${e.fps}fps`}function so(e,t){if(!(t===null||e===void 0))return e.find(e=>e.profile===t)}function co(e){return e===null?Y.t(`pipeline.configBlocks.fpsDefault`):e===0?Y.t(`pipeline.configBlocks.fpsNative`):`${e} fps`}function lo({streams:e,brokerProfiles:t,settings:n,motionEnabled:r,motionFpsLive:i,cameraSensors:s}){let{t:c}=X(),l=so(t,n.detectionStreamProfile),u=so(t,n.motionStreamProfile),f=n.motionSources.includes(`analyzer`);return a(Q,{title:c(`cameras.configBlocks.streamsMotion`,`Streams & motion`),children:[a($,{label:c(`cameras.configBlocks.detectStream`,`Detect stream`),overridden:n.overriddenKeys.has(`detectionStreamProfile`),children:[n.detectionStreamProfile??`—`,l!==void 0&&` · ${l.width}×${l.height} ${l.codec}`]}),d($,{label:c(`cameras.configBlocks.detectFps`,`Detect FPS`),overridden:n.overriddenKeys.has(`detectionFps`),children:co(n.detectionFps)}),a($,{label:c(`cameras.configBlocks.motionSrc`,`Motion src`),overridden:n.overriddenKeys.has(`motionSources`),children:[n.motionSources.length>0?n.motionSources.map(de).join(` + `):c(`cameras.configBlocks.none`),r===!1&&` · ${c(`cameras.configBlocks.inactive`)}`]}),d($,{label:c(`cameras.configBlocks.cameraSensors`,`Camera sensors`),children:bn(s)}),f&&a(o,{children:[a($,{label:c(`cameras.configBlocks.motionStream`,`Motion stream`),overridden:n.overriddenKeys.has(`motionStreamProfile`),children:[n.motionStreamProfile??`—`,u!==void 0&&` · ${u.width}×${u.height} ${u.codec}`]}),a($,{label:c(`cameras.configBlocks.motionFps`,`Motion FPS`),overridden:n.overriddenKeys.has(`motionFps`),children:[co(n.motionFps),i!==null&&` · ${c(`cameras.configBlocks.liveFps`,{fps:i.toFixed(1)})}`]})]}),d($,{label:c(`cameras.configBlocks.cooldown`,`Cooldown`),overridden:n.overriddenKeys.has(`motionCooldownMs`),children:n.motionCooldownMs===null?c(`cameras.configBlocks.defaultValue`):`${n.motionCooldownMs/1e3}s`}),d(`div`,{className:`mt-1.5 flex flex-col gap-0.5`,children:e.length===0?d(ro,{children:c(`cameras.configBlocks.noStreamsRegistered`,`No streams registered`)}):e.map(e=>a(`div`,{className:`text-[10px] font-mono text-foreground-subtle truncate`,title:e.camStreamId,children:[d(`span`,{className:`text-foreground-muted`,children:e.kind}),` `,oo(e)]},e.camStreamId))})]})}function uo({steps:e,audioModelId:t,audioEnabled:n,audioMode:r}){let{t:i}=X();return a(Q,{title:i(`cameras.configBlocks.pipelineSteps`,`Pipeline steps`),children:[e===void 0?d(ro,{children:i(`cameras.configBlocks.resolving`,`Resolving…`)}):e.length===0?d(ro,{children:i(`cameras.configBlocks.noStepsConfigured`,`No steps configured`)}):d(`div`,{className:`flex flex-wrap gap-1`,children:e.map((e,t)=>d(no,{tone:e.enabled&&e.depth===0?`info`:`neutral`,title:e.modelId??e.addonId,children:a(`span`,{className:e.enabled?``:`line-through opacity-60`,children:[e.depth>0&&d(`span`,{className:`opacity-50`,children:`↳ `}),e.addonId,e.modelId!==null&&a(`span`,{className:`font-mono opacity-75`,children:[` · `,e.modelId]})]})},`${e.addonId}-${t}`))}),d(`div`,{className:`mt-1`,children:a($,{label:i(`cameras.configBlocks.audioClass`,`Audio class.`),children:[r??`—`,n!==null&&` · ${i(n?`cameras.configBlocks.running`:`cameras.configBlocks.off`)}`,t!==null&&` · ${t}`]})})]})}var fo={ready:`success`,installing:`info`,verifying:`info`,idle:`neutral`,failed:`danger`};function po({detection:e,live:t,detectionMode:n,modeOverridden:r}){let i=L(),{t:o}=X();if(e===null)return a(Q,{title:o(`cameras.runtimeBlocks.detectionRuntime`,`Detection runtime`),children:[d($,{label:o(`cameras.runtimeBlocks.mode`,`Mode`),overridden:r,children:n??`—`}),d(ro,{children:o(`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,f=t?.queueDepth??e.queueDepth,p=vt(s,i),m=s===`active`&&c===0;return a(Q,{title:o(`cameras.runtimeBlocks.detectionRuntime`,`Detection runtime`),children:[a(`div`,{className:`flex items-center gap-1.5 mb-0.5`,children:[a(`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:[d(Ct,{phase:s,className:`h-2.5 w-2.5`}),p.label]}),t!==void 0&&d(`span`,{className:`text-[9px] text-foreground-subtle uppercase tracking-wider`,children:o(`common.live`)})]}),d($,{label:o(`cameras.runtimeBlocks.mode`,`Mode`),overridden:r,children:n??`—`}),a($,{label:`FPS`,children:[d(`span`,{className:m?`text-danger font-semibold`:``,children:c.toFixed(1)}),d(`span`,{className:`ml-1 text-foreground-subtle`,children:o(`cameras.runtimeBlocks.configuredFps`,{fps:l.toFixed(0)})})]}),a($,{label:o(`cameras.runtimeBlocks.inference`,`Inference`),children:[u.toFixed(0),` ms`,f>0&&d(`span`,{className:`ml-1 text-warning`,children:o(`cameras.runtimeBlocks.queue`,{depth:f})}),t!==void 0&&t.droppedFrames>0&&d(`span`,{className:`ml-1 text-warning`,children:o(`cameras.runtimeBlocks.drops`,{count:t.droppedFrames})})]}),a($,{label:o(`cameras.runtimeBlocks.engine`,`Engine`),children:[e.engine.backend,` · `,e.engine.device]}),a($,{label:o(`cameras.runtimeBlocks.provisioning`,`Provisioning`),children:[d(no,{tone:fo[e.provisioning.state]??`neutral`,children:e.provisioning.state}),e.provisioning.error!==void 0&&a(`span`,{className:`text-danger text-[10px]`,children:[` `,e.provisioning.error]})]})]})}function mo({broker:e}){let{t}=X();return e===null?d(Q,{title:t(`cameras.runtimeBlocks.streamBroker`,`Stream broker`),children:d(ro,{children:t(`cameras.runtimeBlocks.brokerStageInactiveOrUnreachable`,`Broker stage inactive or unreachable`)})}):a(Q,{title:t(`cameras.runtimeBlocks.streamBroker`,`Stream broker`),children:[e.profiles.length===0?d(ro,{children:t(`cameras.runtimeBlocks.noBrokerProfiles`,`No broker profiles`)}):d(`div`,{className:`flex flex-col gap-1`,children:e.profiles.map(e=>{let n=e.status===`streaming`,r=n&&e.inFps===0;return a(`div`,{className:`flex items-center gap-2 text-[11px] font-mono tabular-nums min-w-0`,children:[d(`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}),d(`span`,{className:`text-foreground w-10 shrink-0 truncate`,title:e.profile,children:e.profile}),a(`span`,{className:`text-foreground-subtle truncate`,children:[e.width,`×`,e.height,` `,e.codec]}),d(`span`,{className:`ml-auto shrink-0 ${r?`text-danger`:`text-foreground`}`,children:t(`cameras.runtimeBlocks.fpsValue`,{value:e.inFps===null?`—`:e.inFps.toFixed(0)})}),a(`span`,{className:`text-foreground-subtle shrink-0`,title:t(`cameras.runtimeBlocks.subscribers`,`Subscribers`),children:[`×`,e.subscribers]})]},e.profile)})}),a(`div`,{className:`mt-1.5 flex flex-wrap gap-1`,children:[d(no,{tone:e.webrtcSessions>0?`info`:`neutral`,children:t(`cameras.runtimeBlocks.webrtc`,{count:e.webrtcSessions})}),d(no,{tone:e.rtspRestream?`success`:`neutral`,children:e.rtspRestream?t(`cameras.runtimeBlocks.restreamOn`):t(`cameras.runtimeBlocks.restreamOff`)})]})]})}function ho({decoder:e}){let{t}=X();return e===null?d(Q,{title:t(`cameras.runtimeBlocks.decoder`,`Decoder`),children:d(ro,{children:t(`cameras.runtimeBlocks.decoderStageInactiveOrUnreachable`,`Decoder stage inactive or unreachable`)})}):d(Q,{title:t(`cameras.runtimeBlocks.decoder`,`Decoder`),children:d($,{label:t(`cameras.runtimeBlocks.node`,`Node`),children:e.nodeId})})}e();var go=`pipeline-orchestrator`,_o={healthy:`bg-success`,idle:`bg-warning`,error:`bg-danger`},vo={healthy:`pipeline.cameraPipelineCard.healthHealthy`,idle:`pipeline.cameraPipelineCard.healthIdle`,error:`pipeline.cameraPipelineCard.healthError`};function yo({problems:e}){return d(`div`,{role:`alert`,className:`flex flex-col border-b border-border`,children:e.map(e=>a(`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:[d(v,{className:`h-3.5 w-3.5 shrink-0 mt-px`}),d(`span`,{className:`min-w-0`,children:e.message})]},e.code))})}function bo({deviceId:e,name:t,online:r,status:i,live:o,onlineNodes:s}){let{t:l}=X(),u=c(),{data:f}=ft({addonId:go,deviceId:e,nodeId:`hub`},{staleTime:3e4}),{data:p}=Ne({deviceId:e},{staleTime:3e4}),m=n(()=>pn(f),[f]),h=n(()=>p===void 0?void 0:kn(p.steps),[p]),g=n(()=>i===void 0?[]:yn(i),[i]),_=()=>{u.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCameraStatuses`]]}),u.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineAssignments`]]})},v=Dt({onSuccess:_}),y=De({onSuccess:_}),b=t=>{t===`auto`?y.mutate({deviceId:e}):v.mutate({deviceId:e,agentNodeId:t})},x=i===void 0?`idle`:An(i),S=g.some(e=>e.severity===`error`),C=g.length>0,w=S?`border-danger/50`:C?`border-warning/40`:`border-border`;return a(`article`,{"aria-label":l(`cameras.cameraPipelineCard.pipelineStatus`,`{{name}} pipeline status`,{name:t}),className:`rounded-lg border ${w} bg-background overflow-hidden`,children:[a(`header`,{className:`flex items-center gap-2.5 px-4 py-2.5 border-b border-border bg-surface/50 min-w-0`,children:[d(`span`,{className:`inline-block h-2 w-2 rounded-full shrink-0 ${S?`bg-danger`:_o[x]}`,title:S?l(`common.error`,`Error`):l(vo[x]),"aria-label":S?l(`common.error`,`Error`):l(vo[x]),role:`img`}),d(`h3`,{className:`text-[13px] font-semibold text-foreground truncate`,title:t,children:t}),a(`span`,{className:`text-[10px] text-foreground-subtle shrink-0`,children:[`#`,e]}),!r&&d(no,{tone:`danger`,children:l(`common.offline`)}),a(`span`,{className:`ml-auto flex items-center gap-1.5 shrink-0`,children:[m.detectionMode!==null&&d(no,{tone:m.detectionMode===`disabled`?`warning`:m.detectionMode===`always-on`?`info`:`neutral`,title:l(`cameras.cameraPipelineCard.objectDetectionMode`,`Object detection mode`),children:m.detectionMode===`disabled`?l(`cameras.cameraPipelineCard.detectionOff`,`detection off`):m.detectionMode}),i?.recording!=null&&(i.recording.active?a(no,{tone:`danger`,title:l(`cameras.cameraPipelineCard.recording`,`Recording ({{mode}})`,{mode:i.recording.mode}),children:[d(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full bg-danger animate-pulse`}),`REC`]}):i.recording.mode!==`off`&&d(no,{tone:`neutral`,title:l(`cameras.cameraPipelineCard.recordingMode`,`Recording mode`),children:l(`pipeline.cameraPipelineCard.recMode`,{mode:i.recording.mode})}))]})]}),g.length>0&&d(yo,{problems:g}),i===void 0?d(`div`,{className:`px-4 py-5 text-[11px] text-foreground-subtle italic`,children:l(`cameras.cameraPipelineCard.noPipelineStatusYetThe`,`No pipeline status yet — the orchestrator has not composed a snapshot for this camera.`)}):a(`div`,{className:`grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-px bg-border`,children:[d(ao,{assignment:i.assignment,settings:m,onlineNodes:s,pinPending:v.isPending||y.isPending,onDetectionPinChange:b}),d(po,{detection:i.detection,live:o,detectionMode:m.detectionMode,modeOverridden:m.overriddenKeys.has(`detectionMode`)}),d(uo,{steps:h,audioModelId:p?.audio?.modelId??null,audioEnabled:i.audio?.enabled??p?.audio?.enabled??null,audioMode:m.audioMode}),d(lo,{streams:i.source.streams,brokerProfiles:i.broker?.profiles,settings:m,motionEnabled:i.motion?.enabled??null,motionFpsLive:i.motion?.fps??null,cameraSensors:i.cameraSensors}),d(mo,{broker:i.broker}),d(ho,{decoder:i.decoder})]})]})}e();var xo=5e3,So=1e4,Co=5e3;function wo(e){let i=c(),{data:a,isLoading:o}=ln(),{data:s,isLoading:l}=rn({},{refetchInterval:xo}),{nodes:u}=G();t(()=>{e!==0&&i.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCameraStatuses`]]})},[e,i]);let[d,f]=r(new Map);qt(se.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})}),t(()=>{if(d.size===0)return;let e=setInterval(()=>{f(e=>{let t=Date.now()-So,n=!1,r=new Map(e);for(let[i,a]of e)a.timestamp<t&&(r.delete(i),n=!0);return n?r:e})},Co);return()=>clearInterval(e)},[d.size]);let p=n(()=>{let e=new Map;for(let t of s??[])e.set(t.deviceId,t);return e},[s]);return{rows:n(()=>(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:n(()=>(u??[]).filter(e=>e.isOnline).map(e=>({id:e.id,name:e.name})),[u]),isLoading:o||l}}e();function To({refreshToken:e}){let{t}=X(),{rows:r,liveMetrics:i,onlineNodes:o,isLoading:s}=wo(e),c=n(()=>[...r.map(e=>{let t=e.status===void 0?[]:yn(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),[r]),l=n(()=>{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&&r.length===0?d(`div`,{className:`flex items-center justify-center h-full text-sm text-foreground-subtle`,children:t(`cameras.camerasOverview.loadingCameraPipelines`,`Loading camera pipelines…`)}):r.length===0?d(`div`,{className:`flex items-center justify-center h-full text-sm text-foreground-subtle`,children:t(`cameras.camerasOverview.noCamerasFound`,`No cameras found`)}):d(`div`,{className:`h-full overflow-y-auto`,children:a(`div`,{className:`max-w-6xl mx-auto flex flex-col gap-3 px-4 py-4`,children:[a(`div`,{className:`flex items-center gap-4 text-[11px] text-foreground-subtle px-1`,children:[d(`span`,{children:d(un,{i18nKey:`pipeline.camerasOverview.camerasTotal`,values:{count:l.total},components:{b:d(`span`,{className:`font-semibold text-foreground`})}})}),d(`span`,{children:d(un,{i18nKey:`pipeline.camerasOverview.activelyInferring`,values:{count:l.active},components:{b:d(`span`,{className:`font-semibold text-success`})}})}),a(`span`,{children:[d(`span`,{className:`font-semibold ${l.issues>0?`text-danger`:`text-foreground`}`,children:l.issues}),` `,t(`cameras.camerasOverview.withIssues`,`with issues`)]}),d(`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})=>d(bo,{deviceId:e.deviceId,name:e.name,online:e.online,status:e.status,live:i.get(e.deviceId),onlineNodes:o},e.deviceId))]})})}e();var Eo=`__cluster__`;function Do(e){return e===`cameras`?`cameras`:`nodes`}function Oo({viewMode:e,onNodes:t,onCameras:n}){let{t:r}=X();return a(`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:[d(`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`)}),d(`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 ko(){let{t:e}=X(),[n,i]=fn(),s=Do(n.get(`view`)),c=n.get(`node`)??`__cluster__`,[l,u]=r(0),[f,p]=r(!1);return t(()=>{s===`nodes`&&!n.get(`node`)&&i({view:`nodes`,node:Eo},{replace:!0})},[s,n,i]),a(Mt,{icon:ve,title:e(`pipeline.pipeline`,`Pipeline`),subtitle:e(`pipeline.detectionPlacementLoadAndPer`,`Detection placement, load and per-camera runtime across the cluster.`),actions:a(K,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>u(e=>e+1),title:e(`common.refresh`,`Refresh`),children:[d(ee,{className:`h-3.5 w-3.5`}),e(`common.refresh`,`Refresh`)]}),nav:d(Oo,{viewMode:s,onNodes:()=>{i({view:`nodes`,node:c},{replace:!0})},onCameras:()=>{i({view:`cameras`},{replace:!0})}}),className:`flex h-full min-h-0 flex-col overflow-hidden`,children:[s===`nodes`&&a(K,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>p(e=>!e),"aria-expanded":f,className:`flex w-full shrink-0 justify-between border-b border-border md:hidden`,children:[d(`span`,{children:e(f?`pipeline.hideNodeList`:`pipeline.showNodeList`)}),d(ne,{className:[`h-4 w-4 transition-transform`,f?`rotate-180`:``].join(` `)})]}),d(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden md:flex-row`,children:s===`nodes`?a(o,{children:[d(`aside`,{className:[f?`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:d(Zn,{selectedNodeId:c,onSelect:e=>{i({view:`nodes`,node:e},{replace:!0}),p(!1)},refreshToken:l})}),d(`section`,{className:`min-h-0 flex-1 overflow-hidden`,children:c===`__cluster__`?d($a,{refreshToken:l}):d(wi,{nodeId:c,refreshToken:l})})]}):d(`section`,{className:`min-h-0 flex-1 overflow-hidden`,children:d(To,{refreshToken:l})})})]})}export{ko as PipelinePage};
|