@camstack/addon-admin-ui 1.2.427 → 1.2.428
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-BgXfFdy2.js → AddonAssetIcon-Cs_blBpK.js} +1 -1
- package/dist/assets/Addons-2xWF73cR.js +4 -0
- package/dist/assets/{AdminPage-C0Zxs_ot.js → AdminPage-DuuyDIsY.js} +1 -1
- package/dist/assets/{AdminSectionedPage-D2kYQhvu.js → AdminSectionedPage-C3VHg80L.js} +1 -1
- package/dist/assets/AiProfiles-DmHcVlS2.js +3 -0
- package/dist/assets/BrokerForm-Dqhjsi3Y.js +1 -0
- package/dist/assets/Build-CBYP1fT5.js +40 -0
- package/dist/assets/Calendars-C926x7b_.js +1 -0
- package/dist/assets/Cluster-OZlA14uV.js +1 -0
- package/dist/assets/ClusterStepModel-DHbwIGAW.js +1 -0
- package/dist/assets/CompositionEditor-vP3JcV2R.js +1 -0
- package/dist/assets/{CompositionEditorPage-CDyW_Buu.js → CompositionEditorPage-Acq7iapA.js} +1 -1
- package/dist/assets/Data-7BoejvKA.js +1 -0
- package/dist/assets/DeviceDetail-ByM0856T.js +2 -0
- package/dist/assets/DeviceDoActionFields-BDJsvRNX.js +1 -0
- package/dist/assets/{Devices-CHeb_BTk.js → Devices-PIrWjfhq.js} +1 -1
- package/dist/assets/EmbedPlayerPage-RXOmf2F3.js +1 -0
- package/dist/assets/Identity-C-tztwfa.js +1 -0
- package/dist/assets/IntegrationDetail-DugB7cv6.js +1 -0
- package/dist/assets/IntegrationHub-BePMbmC5.js +1 -0
- package/dist/assets/Integrations-Dj3nT9ZT.js +1 -0
- package/dist/assets/Integrations-OH5z-t03.js +1 -0
- package/dist/assets/Library-DDNti2te.js +1 -0
- package/dist/assets/Locations-OL9_NoSi.js +3 -0
- package/dist/assets/Logs-DIeXeCqI.js +1 -0
- package/dist/assets/{MotionZonesSettings-DjvGw8j4.js → MotionZonesSettings-CfTOerul.js} +1 -1
- package/dist/assets/MyAccess-iJP3JQIS.js +2 -0
- package/dist/assets/Network-DYssxNiN.js +1 -0
- package/dist/assets/NodeAddonsSettingsPanel-mmtEgDbu.js +1 -0
- package/dist/assets/Notifications-DEcxFWp3.js +1 -0
- package/dist/assets/{PrivacyMaskSettings-IK6ytyM8.js → PrivacyMaskSettings-CJUKFEIs.js} +1 -1
- package/dist/assets/Recordings-lygSYEJj.js +1 -0
- package/dist/assets/ScanNetworkModal-C2oJlLfj.js +1 -0
- package/dist/assets/{SceneMonitorEditor-V_pHxg3U.js → SceneMonitorEditor-D1S-D2V9.js} +1 -1
- package/dist/assets/SessionsList-CIN4GdSm.js +2 -0
- package/dist/assets/{Showroom-Cw-6ZdvC.js → Showroom-W2yJvb8s.js} +1 -1
- package/dist/assets/System-ChWpOOqN.js +1 -0
- package/dist/assets/{Terminal-D-YHBrHK.js → Terminal-CrFum1tE.js} +5 -5
- package/dist/assets/{Viewer-BmXiweP2.js → Viewer-YBzeS3RA.js} +1 -1
- package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-wt87pCBz.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-CE2IIKhe.js} +1 -1
- package/dist/assets/{addon-icons-context-CvwUgMRr.js → addon-icons-context-D6glxUQF.js} +1 -1
- package/dist/assets/{archive-Bwv0mNo-.js → archive-kvflMCgL.js} +1 -1
- package/dist/assets/{authed-media-0TPg9TTZ.js → authed-media-CSlndmzS.js} +1 -1
- package/dist/assets/{bell-off-D2KzCQW2.js → bell-off-BYnwGeiH.js} +1 -1
- package/dist/assets/{boxes-BXQUMgws.js → boxes-Dx4USyB3.js} +1 -1
- package/dist/assets/circle-slash-D5mo-8G0.js +1 -0
- package/dist/assets/client-CMlUvfoK.js +358 -0
- package/dist/assets/{cloud-upload-BsULjxPu.js → cloud-upload-82x5w5u8.js} +1 -1
- package/dist/assets/crop-Dev61hIh.js +1 -0
- package/dist/assets/{device-integration-icon-CCoHGEQZ.js → device-integration-icon-bTnWrYe0.js} +1 -1
- package/dist/assets/device-picker-model-DlnG_8P7.js +1 -0
- package/dist/assets/{dist-DQtBl_2T.js → dist--5X8Gy0U.js} +1 -1
- package/dist/assets/{dist-DWoekMi0.js → dist-Dod19ois.js} +13 -13
- package/dist/assets/{eraser-DB7_WMyf.js → eraser-B8Awx5Sj.js} +1 -1
- package/dist/assets/{file-up-DuqaeMYR.js → file-up-LqDVgVVa.js} +1 -1
- package/dist/assets/{hard-drive-download-CKj8xKOz.js → hard-drive-download-C24D80x2.js} +1 -1
- package/dist/assets/{history-V8RQKQAb.js → history-DZsORyBG.js} +1 -1
- package/dist/assets/{hostInit-CdxLRG1l.js → hostInit-D2EmEDvv.js} +1 -1
- package/dist/assets/i18n-vggiB6gm.js +1 -0
- package/dist/assets/{icons-CEMmjIEL.js → icons-D5RaCH1q.js} +1 -1
- package/dist/assets/index-BgQGn3LX.js +4 -0
- package/dist/assets/index-BndCgmxf.css +2 -0
- package/dist/assets/{key-Bj5-ZBrb.js → key-DLwSBrPM.js} +1 -1
- package/dist/assets/{key-round-B2I1YisX.js → key-round-CYflkUyd.js} +1 -1
- package/dist/assets/{layers-BARFkXZ5.js → layers-C1wzFfr1.js} +1 -1
- package/dist/assets/linked-devices-model-CCTQ_gka.js +1 -0
- package/dist/assets/{list-ordered-9lF0Gp3K.js → list-ordered-CFeS9o_w.js} +1 -1
- package/dist/assets/location-owned-usage-DSLiI6RY.js +1 -0
- package/dist/assets/{log-in-CjtrIfG3.js → log-in-Be_RcxDr.js} +1 -1
- package/dist/assets/{memory-stick-B26_SbtH.js → memory-stick-4BwYEagi.js} +1 -1
- package/dist/assets/{message-square-plus-COMrVZEZ.js → message-square-plus-D7BNG3h7.js} +1 -1
- package/dist/assets/{mf-entry-bootstrap-0-ec37d41a.js → mf-entry-bootstrap-0-9df0d08c.js} +2 -2
- package/dist/assets/{mic-off-DBIqFVjg.js → mic-off-e162Bcfu.js} +1 -1
- package/dist/assets/{monitor-off-CTQMySOs.js → monitor-off-CARYfHC4.js} +1 -1
- package/dist/assets/{monitor-smartphone-iBd_3nPv.js → monitor-smartphone-lsNgnRRZ.js} +1 -1
- package/dist/assets/mount-DlnG_8P7.js +1 -0
- package/dist/assets/notification-schedule-field-DWpT_5Vh.js +1 -0
- package/dist/assets/{octagon-alert-DMjnTemh.js → octagon-alert-h80nyWRM.js} +1 -1
- package/dist/assets/{player-overlays-DWMIy1MJ.js → player-overlays-Cda8wso6.js} +1 -1
- package/dist/assets/{recycle-BCVF0r6Y.js → recycle-0MLWppmT.js} +1 -1
- package/dist/assets/remoteEntry-V_83-NrI.js +1 -0
- package/dist/assets/{scan-eye-DRXP3PgB.js → scan-eye-DVK8MF3K.js} +1 -1
- package/dist/assets/{scissors-DUFtPb9T.js → scissors-Cz3GoeOd.js} +1 -1
- package/dist/assets/{search-x-B3nve3vV.js → search-x-i_A-Upbe.js} +1 -1
- package/dist/assets/{send-P2KlabIu.js → send-B5VKcNUH.js} +1 -1
- package/dist/assets/{settings-2-reEhyiKz.js → settings-2-ZQsYJ0Zb.js} +1 -1
- package/dist/assets/{speaker-DSNMuvS8.js → speaker-Cl8DZGk_.js} +1 -1
- package/dist/assets/{src-BLkInT8U.js → src-eoSUZcV-.js} +8 -8
- package/dist/assets/{timer-reset-CsRTbSzh.js → timer-reset-A5ofAkBW.js} +1 -1
- package/dist/assets/{ungroup-BLeVa8__.js → ungroup-t0yDnzVf.js} +1 -1
- package/dist/assets/{unlink-DeNvF8r-.js → unlink-C1ZpCxl3.js} +1 -1
- package/dist/assets/{usb-CFseVsQJ.js → usb-DmUPajSy.js} +1 -1
- package/dist/assets/{use-scenes-feed-C8frh3hQ.js → use-scenes-feed-BQlYhRMq.js} +1 -1
- package/dist/assets/{use-stationary-objects-DNayAuMq.js → use-stationary-objects-BWM4vE0E.js} +1 -1
- package/dist/assets/useEventInvalidation-DlnG_8P7.js +1 -0
- package/dist/assets/{useNodeUrlSelection-BsLRiUy8.js → useNodeUrlSelection-CTxv9Em7.js} +1 -1
- package/dist/assets/user-round-BTaID248.js +1 -0
- package/dist/assets/{user-x-CpaZ5HO0.js → user-x-DRcPeM9C.js} +1 -1
- package/dist/assets/{video--MLJeLNU.js → video-tLHyNE3q.js} +1 -1
- package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-1Do_dc2z.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-DOOXjnRq.js} +2 -2
- package/dist/index.html +11 -10
- package/dist/server/addon.js +27 -3
- package/package.json +1 -1
- package/dist/assets/Addons-BTWw53aT.js +0 -4
- package/dist/assets/AiProfiles-Ca7zuVMp.js +0 -3
- package/dist/assets/BrokerForm-6-BwPs-g.js +0 -1
- package/dist/assets/Build-BsduavcU.js +0 -40
- package/dist/assets/Calendars-DVTk_2iT.js +0 -1
- package/dist/assets/Cluster-BPJ4maiI.js +0 -1
- package/dist/assets/ClusterStepModel-CjuZ-oml.js +0 -1
- package/dist/assets/CompositionEditor-DJcmWU2U.js +0 -1
- package/dist/assets/Data-CLLvqZwG.js +0 -1
- package/dist/assets/DeviceDetail-BKw1gufS.js +0 -2
- package/dist/assets/DeviceDoActionFields-R-ZYIdMv.js +0 -1
- package/dist/assets/EmbedPlayerPage-B4y0Q0wO.js +0 -1
- package/dist/assets/Identity-NOlTR-3q.js +0 -1
- package/dist/assets/IntegrationDetail-CcZkPlbN.js +0 -1
- package/dist/assets/IntegrationHub-CuW7-WRy.js +0 -1
- package/dist/assets/Integrations-ACdx4iPR.js +0 -1
- package/dist/assets/Integrations-DjnhmLye.js +0 -1
- package/dist/assets/Library-B3iyoKdK.js +0 -1
- package/dist/assets/Locations-Cs1VwmXB.js +0 -3
- package/dist/assets/Logs-BMc6WXCH.js +0 -1
- package/dist/assets/MyAccess-BfUfTXrv.js +0 -2
- package/dist/assets/Network-F2lAIcbT.js +0 -1
- package/dist/assets/NodeAddonsSettingsPanel-D3ux_JIo.js +0 -1
- package/dist/assets/Notifications-Cp3qo_EC.js +0 -1
- package/dist/assets/Recordings-D91q74Ga.js +0 -1
- package/dist/assets/ScanNetworkModal-DjU-xM4X.js +0 -1
- package/dist/assets/SessionsList-DQ7kj8fX.js +0 -2
- package/dist/assets/System-DLLa4weE.js +0 -1
- package/dist/assets/circle-slash-DpUtlEnB.js +0 -1
- package/dist/assets/client-CjyKfSu1.js +0 -358
- package/dist/assets/crop-BtQBZ9jm.js +0 -1
- package/dist/assets/device-picker-model-1Z6p3UkP.js +0 -1
- package/dist/assets/index-D66JvELZ.js +0 -4
- package/dist/assets/index-dmZ34NAY.css +0 -2
- package/dist/assets/location-owned-usage-CNXQ-Obv.js +0 -1
- package/dist/assets/mount-1Z6p3UkP.js +0 -1
- package/dist/assets/notification-schedule-field-D8dd67dT.js +0 -1
- package/dist/assets/remoteEntry-RwWzzVu_.js +0 -1
- package/dist/assets/useEventInvalidation-1Z6p3UkP.js +0 -1
- package/dist/assets/user-round-BB0VDRnJ.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{I as e,K as t,Q as n,S as r,V as i,W as a,b as o,o as s,q as c,x as l,z as u}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{D as d,It as f,Jr as p,Nt as m,Oi as h,On as g,Pn as _,Rn as v,Rr as y,Sn as b,Yi as x,_i as S,_n as C,ai as w,ar as T,bi as E,bn as D,di as O,dn as k,dt as A,fn as j,on as M,ot as N,pi as P,un as F,yi as ee,yn as I}from"./player-overlays-Cda8wso6.js";import{t as te}from"./hard-drive-download-C24D80x2.js";import{t as ne}from"./memory-stick-4BwYEagi.js";import{t as re}from"./unlink-C1ZpCxl3.js";import{$r as ie,Qr as ae,ei as oe,ri as se}from"./client-CMlUvfoK.js";import{$o as ce,An as le,Bn as L,Dn as ue,En as de,Fc as fe,G as R,Go as pe,Ht as z,Ic as me,Lc as he,Ln as B,M as ge,Ns as _e,On as ve,Pc as ye,Qo as be,Rn as xe,Tn as Se,Tt as Ce,U as we,Ut as Te,Vs as Ee,Vt as De,Wo as Oe,Wt as ke,Xs as Ae,Xt as je,Zl as V,Zn as H,Zo as Me,_u as U,ar as Ne,cr as Pe,dr as Fe,es as Ie,il as Le,jn as Re,kn as ze,lr as Be,ma as Ve,mu as W,pu as He,rc as Ue,ur as We,wt as Ge}from"./src-eoSUZcV-.js";import{t as G}from"./useTranslation-Bc5yH9V9.js";import{Q as Ke,S as qe}from"./index-BgQGn3LX.js";import{t as Je}from"./AdminPage-DuuyDIsY.js";import{t as Ye}from"./NodeAddonsSettingsPanel-mmtEgDbu.js";import{f as Xe,l as Ze,m as Qe,u as $e}from"./board-model-Bmts6hrg.js";import{t as K}from"./format-size-DIxKXxtj.js";import{n as et,t as tt}from"./useNodeUrlSelection-CTxv9Em7.js";n();var nt={unpaired:`Not paired`,pending:`Pairing…`,paired:`Paired`},rt=new Set([`paired`,`rejected`,`failed`,`expired`]);function it(e){return rt.has(e)}function at(e){return e.replace(/\D/g,``).slice(0,6)}function ot(e){return e.length===6}function st(e,t){let n=Math.max(0,Math.ceil((e-t)/1e3)),r=Math.floor(n/60),i=n%60;return`${r}:${String(i).padStart(2,`0`)}`}function ct(e,t){return e.includes(`:`)?`[${e}]:${t}`:`${e}:${t}`}function lt(e){return e.length<=23?e:`${e.slice(0,20)}…`}function ut({view:e,beginError:t}){if(e===null)return t===null?`sending`:`send-failed`;switch(e.state){case`paired`:return`paired`;case`rejected`:return`rejected`;case`failed`:return`failed`;case`expired`:return`expired`;case`completing`:return`completing`;case`awaiting-confirmation`:return e.hubConfirmed&&!e.agentConfirmed?`awaiting-agent`:e.agentConfirmed&&!e.hubConfirmed?`awaiting-hub`:`awaiting-both`}}function dt(e){return e===`awaiting-both`||e===`awaiting-hub`}var ft={sending:`Sending the pairing offer to the agent…`,"send-failed":`The agent could not be reached`,"awaiting-both":`Waiting for both confirmations`,"awaiting-agent":`Confirmed here — waiting for the agent`,"awaiting-hub":`The agent is confirmed — now confirm here`,completing:`Issuing the node certificate…`,paired:`Paired`,rejected:`Pairing was rejected`,failed:`Pairing failed`,expired:`The pairing expired`},pt=2e3,mt=1e3;function ht(e){return e.message.length>0?e.message:`Request failed`}function gt(e){return e.length===6?`${e.slice(0,3)} ${e.slice(3)}`:e}function _t(e){let[t,n]=c(()=>Date.now());return u(()=>{if(!e)return;let t=setInterval(()=>n(Date.now()),mt);return()=>clearInterval(t)},[e]),t}function vt({target:e,onClose:n,onSettled:i,onOpenNode:a}){let{t:s}=G(),[d,f]=c(null),[p,m]=c(null),[h,g]=c(``),[_,v]=c(null),y=t(null),b=U.agentPairing.beginPairing.useMutation(),x=U.agentPairing.confirmPairing.useMutation(),S=U.agentPairing.rejectPairing.useMutation();u(()=>{if(e===null){y.current=null,f(null),m(null),g(``),v(null);return}y.current!==e&&(y.current=e,b.mutateAsync({host:e.host,port:e.port}).then(t=>{y.current===e&&f(t.pairingId)}).catch(t=>{y.current===e&&m(ht(t))}))},[e]);let C=U.agentPairing.getPairing.useQuery({pairingId:d??``},{enabled:d!==null,refetchInterval:e=>{let t=e.state.data?.state;return t!==void 0&&it(t)?!1:pt}}),w=yt(x.data??S.data??null,C.data??null),E=ut({view:w,beginError:p}),D=w!==null&&it(w.state),O=t(!1);u(()=>{if(!D){O.current=!1;return}O.current||(O.current=!0,i())},[D,i]);let k=_t(w!==null&&!D),A=()=>{d===null||!ot(h)||(v(null),x.mutate({pairingId:d,code:h},{onError:e=>{v(ht(e)),g(``)}}))};return l(Se,{open:e!==null,onOpenChange:e=>!e&&n(),children:r(ue,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[r(le,{children:[r(Re,{children:[`Pair agent `,e?.nodeId??``]}),l(ve,{children:e===null?``:s(`pairing.pairingDialog.eachScreenShowsACode`,`Each screen shows a code; you type the code from the OTHER screen. Agent at {{value1}}`,{value1:ct(e.host,e.port)})})]}),r(de,{className:`space-y-4`,children:[l(bt,{phase:E}),E===`send-failed`&&p!==null&&l(B,{title:s(`pairing.pairingDialog.couldNotStartThePairing`,`Could not start the pairing`),message:p}),w!==null&&!D&&l(xt,{view:w,phase:E,now:k,typed:h,onType:e=>g(at(e)),onSubmit:A,confirmError:_,busy:x.isPending}),E===`paired`&&w!==null&&l(St,{nodeId:w.nodeId,onOpenNode:a,onClose:n}),D&&E!==`paired`&&w?.failure!=null&&l(B,{message:w.failure})]}),l(ze,{children:D||E===`send-failed`?l(L,{type:`button`,variant:`outline`,onClick:n,children:s(`common.close`,`Close`)}):r(o,{children:[l(L,{type:`button`,variant:`outline`,disabled:S.isPending,onClick:()=>{if(d===null){n();return}S.mutate({pairingId:d},{onSettled:n})},children:s(`pairing.pairingDialog.reject`,`Reject`)}),dt(E)&&r(L,{type:`button`,disabled:!ot(h)||x.isPending,onClick:A,children:[x.isPending&&l(T,{className:`h-4 w-4 animate-spin`}),s(`common.confirm`,`Confirm`)]})]})})]})})}function yt(e,t){if(t===null)return e;if(e===null)return t;let n=e=>(it(e.state)?10:e.state===`completing`?5:0)+ +!!e.hubConfirmed+ +!!e.agentConfirmed;return n(e)>n(t)?e:t}function bt({phase:e}){let t=e===`sending`||e===`completing`,n=e===`paired`,i=e===`rejected`||e===`failed`||e===`expired`||e===`send-failed`;return r(`p`,{role:`status`,className:`flex items-center gap-2 text-sm font-medium ${n?`text-success`:i?`text-danger`:`text-foreground`}`,children:[t&&l(T,{className:`h-4 w-4 animate-spin`}),n&&l(O,{className:`h-4 w-4`}),i&&l(w,{className:`h-4 w-4`}),ft[e]]})}function xt({view:e,phase:t,now:n,typed:i,onType:a,onSubmit:o,confirmError:s,busy:c}){let{t:u}=G();return r(`div`,{className:`space-y-4`,children:[r(`section`,{"aria-label":u(`pairing.pairingDialog.codeOnThisHub`,`Code on this hub`),className:`rounded-md border border-border bg-surface p-3`,children:[l(`p`,{className:`text-xs text-foreground-muted`,children:u(`pairing.pairingDialog.codeOnThisHubRead`,`Code on this hub — read it out to the agent`)}),l(`p`,{"data-testid":`hub-code`,className:`mt-1 font-mono text-3xl font-semibold tracking-widest text-foreground`,children:gt(e.code)}),l(`p`,{className:`mt-2 text-xs text-foreground-muted`,children:u(`pairing.pairingDialog.onTheAgentEnterThis`,`On the agent, enter this code and the agent’s local PIN (shown on the agent’s console or log, or on its own screen).`)})]}),dt(t)?l(`form`,{className:`space-y-2`,onSubmit:e=>{e.preventDefault(),o()},children:l(R,{label:u(`pairing.pairingDialog.codeShownOnTheAgent`,`Code shown on the agent`),description:u(`pairing.pairingDialog.typeTheSixDigitsThe`,`Type the six digits the agent displays. Do not copy the code above.`),...s===null?{}:{error:s},children:l(V,{value:i,onChange:e=>a(e.target.value),inputMode:`numeric`,autoComplete:`off`,spellCheck:!1,placeholder:`000000`,maxLength:6,disabled:c,"aria-label":u(`pairing.pairingDialog.codeShownOnTheAgent`,`Code shown on the agent`),className:`font-mono tracking-widest`})})}):l(`p`,{className:`text-xs text-foreground-muted`,children:t===`awaiting-agent`?u(`pairing.pairingDialog.youConfirmedHereTheAgent`,`You confirmed here. The agent still has to enter the hub code and its PIN.`):u(`pairing.pairingDialog.working`,`Working…`)}),r(`ul`,{className:`flex flex-wrap gap-x-4 gap-y-1 text-xs text-foreground-muted`,children:[l(`li`,{children:e.hubConfirmed?u(`pairing.pairingDialog.hubConfirmed`,`Hub: confirmed`):u(`pairing.pairingDialog.hubNotConfirmed`,`Hub: not confirmed`)}),l(`li`,{children:e.agentConfirmed?u(`pairing.pairingDialog.agentConfirmed`,`Agent: confirmed`):u(`pairing.pairingDialog.agentNotConfirmed`,`Agent: not confirmed`)}),r(`li`,{"data-testid":`countdown`,children:[`Expires in `,st(e.expiresAt,n)]})]})]})}function St({nodeId:e,onOpenNode:t,onClose:n}){let{t:i}=G(),{nodes:a}=He(),o=a?.some(t=>t.id===e&&t.isOnline)===!0;return r(`div`,{className:`space-y-2 rounded-md border border-success/40 bg-success/10 p-3 text-sm`,children:[r(`p`,{className:`flex items-center gap-2 text-success`,children:[l(M,{className:`h-4 w-4`}),o?i(`pairing.pairingDialog.joinedAndRegisteredItsCapabilities`,`{{nodeId}} joined and registered its capabilities.`,{nodeId:e}):i(`pairing.pairingDialog.holdsItsCertificateWaitingFor`,`{{nodeId}} holds its certificate. Waiting for it to connect and register its capabilities…`,{nodeId:e})]}),l(L,{type:`button`,size:`sm`,variant:`outline`,disabled:!o,onClick:()=>{n(),t(e)},children:i(`pairing.pairingDialog.openNode`,`Open node`)})]})}var Ct={paired:`success`,pending:`warning`,unpaired:`default`};function wt({state:e,connected:t}){let{t:n}=G();return r(`span`,{className:`inline-flex items-center gap-1.5`,children:[l(Ne,{variant:Ct[e],className:`text-[10px]`,children:nt[e]}),e===`paired`&&l(`span`,{className:`text-[10px] text-foreground-muted`,children:t?`connected`:n(`pairing.agentStateBadge.notConnected`,`not connected`)})]})}n();var Tt={pending:0,unpaired:1,paired:2};function Et(e){if(e.trim().length===0)return;let t=Number(e);return Number.isInteger(t)&&t>=1&&t<=65535?t:null}function Dt({onOpenNode:e}){let{t}=G(),n=H(),i=U.useUtils(),s=U.agentPairing.listDiscoveredAgents.useQuery(void 0,{refetchInterval:15e3}),[u,f]=c(null),[p,m]=c(null),[h,_]=c(!1),[v,y]=c(``),[x,S]=c(``),[C,w]=c(null),[E,D]=c(!1),O=()=>void i.agentPairing.listDiscoveredAgents.invalidate(),k=U.agentPairing.addAgentByAddress.useMutation({onSuccess:()=>{_(!1),y(``),S(``),w(null),O()},onError:e=>w(e.message)}),A=U.agentPairing.unpairAgent.useMutation({onSuccess:e=>{m({tone:`success`,message:`${e.nodeId}: ${e.next}${e.agentNotified?``:` The agent could not be told; forget the hub on its own page.`}`}),O()},onError:e=>m({tone:`danger`,message:t(`pairing.agentsFoundSection.unpairFailed`,`Unpair failed: {{message}}`,{message:e.message})})}),j=a(()=>(s.data?.agents??[]).toSorted((e,t)=>Tt[e.state]-Tt[t.state]),[s.data]),M=async()=>{D(!0);try{await i.agentPairing.listDiscoveredAgents.fetch({refresh:!0}),O()}finally{D(!1)}},N=()=>{let e=Et(x);if(e===null){w(`The port must be a whole number between 1 and 65535.`);return}w(null),k.mutate({host:v.trim(),...e===void 0?{}:{port:e}})},P=async e=>{await n({title:t(`pairing.agentsFoundSection.unpair`,`Unpair {{nodeId}}`,{nodeId:e.nodeId}),message:t(`pairing.agentsFoundSection.sCertificatesAreRevokedAt`,`{{nodeId}}'s certificates are revoked at once and it is disconnected from the mesh. It must be paired again before it can rejoin.`,{nodeId:e.nodeId}),confirmLabel:t(`pairing.agentsFoundSection.unpair2`,`Unpair`),variant:`danger`})&&(m(null),A.mutate({nodeId:e.nodeId}))},F=a(()=>[{key:`node`,header:t(`pairing.agentsFoundSection.node`,`Node`),render:e=>l(`span`,{className:`font-medium text-foreground`,children:e.nodeId}),sortValue:e=>e.nodeId},{key:`address`,header:t(`pairing.agentsFoundSection.address`,`Address`),render:e=>l(`span`,{className:`font-mono text-xs`,children:ct(e.host,e.port)}),sortValue:e=>e.host},{key:`version`,header:t(`pairing.agentsFoundSection.version`,`Version`),render:e=>e.version??`—`,sortValue:e=>e.version},{key:`state`,header:t(`pairing.agentsFoundSection.state`,`State`),render:e=>l(wt,{state:e.state,connected:e.connected}),sortValue:e=>Tt[e.state]},{key:`fingerprint`,header:t(`pairing.agentsFoundSection.certificate`,`Certificate`),render:e=>e.fingerprint===null?`—`:l(`span`,{className:`font-mono text-xs`,title:e.fingerprint,children:lt(e.fingerprint)}),sortValue:e=>e.fingerprint},{key:`actions`,header:``,align:`right`,notSortableReason:`Row actions`,render:e=>e.state===`unpaired`?l(L,{type:`button`,size:`sm`,onClick:()=>f({nodeId:e.nodeId,host:e.host,port:e.port}),children:t(`pairing.agentsFoundSection.pair`,`Pair`)}):e.state===`paired`?l(L,{type:`button`,size:`sm`,variant:`outline`,disabled:A.isPending,onClick:()=>void P(e),children:t(`pairing.agentsFoundSection.unpair2`,`Unpair`)}):null}],[A.isPending,t]);return r(De,{headingId:`agents-found`,title:t(`pairing.agentsFoundSection.agentsFoundOnTheNetwork`,`Agents found on the network`),icon:b,testId:`agents-found`,actions:r(o,{children:[r(L,{type:`button`,size:`sm`,variant:`outline`,disabled:E,onClick:()=>void M(),children:[E?l(T,{className:`h-3.5 w-3.5 animate-spin`}):l(I,{className:`h-3.5 w-3.5`}),t(`pairing.agentsFoundSection.scan`,`Scan`)]}),r(L,{type:`button`,size:`sm`,onClick:()=>_(e=>!e),children:[l(g,{className:`h-3.5 w-3.5`}),t(`pairing.agentsFoundSection.addByAddress`,`Add by address`)]})]}),children:[r(`div`,{className:`${d} space-y-3`,children:[l(`p`,{className:`text-[11px] leading-relaxed text-foreground-muted`,children:t(`pairing.agentsFoundSection.anAgentHoldsNoSecret`,`An agent holds no secret: pairing issues it a certificate after you confirm the same six digits on this page and on the agent. Discovery needs the agent on its own IP or host networking; a Docker bridge hides it — add it by address.`)}),h&&r(`form`,{"aria-label":t(`pairing.agentsFoundSection.addAgentByAddress`,`Add agent by address`),className:`flex flex-wrap items-start gap-2`,onSubmit:e=>{e.preventDefault(),v.trim().length>0&&!k.isPending&&N()},children:[l(R,{label:t(`pairing.agentsFoundSection.address`,`Address`),description:t(`pairing.agentsFoundSection.aPrivateOrLocalAddress`,`A private or local address only.`),...C===null?{}:{error:C},children:l(V,{value:v,onChange:e=>y(e.target.value),placeholder:`192.168.1.50`,"aria-label":t(`pairing.agentsFoundSection.agentAddress`,`Agent address`),autoComplete:`off`})}),l(R,{label:t(`pairing.agentsFoundSection.port`,`Port`),description:t(`pairing.agentsFoundSection.optional`,`Optional.`),children:l(V,{value:x,onChange:e=>S(e.target.value),placeholder:`4444`,inputMode:`numeric`,"aria-label":t(`pairing.agentsFoundSection.agentPort`,`Agent port`),className:`w-24`})}),r(L,{type:`submit`,size:`sm`,className:`mt-5`,disabled:v.trim().length===0||k.isPending,children:[k.isPending&&l(T,{className:`h-3.5 w-3.5 animate-spin`}),t(`common.add`,`Add`)]})]}),p!==null&&l(`p`,{role:`status`,className:`rounded border px-3 py-2 text-xs ${p.tone===`success`?`border-success/30 text-foreground`:`border-danger/40 text-danger`}`,children:p.message}),s.isError?l(B,{title:t(`pairing.agentsFoundSection.couldNotListAgents`,`Could not list agents`),message:s.error?.message??t(`pairing.agentsFoundSection.requestFailed`,`Request failed`),onRetry:O}):s.isLoading?l(`p`,{className:`py-4 text-center text-xs text-foreground-muted`,children:t(`pairing.agentsFoundSection.lookingForAgents`,`Looking for agents…`)}):j.length===0?l(xe,{icon:b,title:t(`pairing.agentsFoundSection.noAgentsFound`,`No agents found`),description:t(`pairing.agentsFoundSection.nothingIsAdvertisingOnThis`,`Nothing is advertising on this network. Start the agent on its own IP (or host networking), or add it by address.`)}):l(z,{columns:F,rows:j,rowKey:e=>e.nodeId,minWidthPx:720,mobileMode:`cards`,defaultSort:{columnKey:`state`,dir:`asc`}})]}),l(vt,{target:u,onClose:()=>f(null),onSettled:O,onOpenNode:e})]})}function Ot(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function kt(e){if(!Ot(e))return null;let t=e.ticket;if(typeof t!=`string`||t.length===0)return null;let n=e.dashboardUrl;return typeof n==`string`&&n.length>0?{ticket:t,dashboardUrl:n}:{ticket:t}}function At(e){let t=e.trim();return!(t.length===0||t.includes(`/`)||t.includes(`?`)||t.includes(`#`)||t.includes(`@`)||t.includes(`:`))}function jt(e){return e.startsWith(`172.17.`)}function Mt(e){let t=/^100\.(\d+)\./.exec(e);if(t===null)return!1;let n=Number(t[1]);return n>=64&&n<=127}function Nt(e){if(e.startsWith(`10.`)||e.startsWith(`192.168.`))return!0;let t=/^172\.(\d+)\./.exec(e);if(t===null)return!1;let n=Number(t[1]);return n>=16&&n<=31&&!jt(e)}function Pt(e,t){if(typeof t==`string`&&At(t))return t.trim();let n=e.filter(e=>!e.includes(`:`)),r=n.find(e=>!e.startsWith(`127.`)&&!e.startsWith(`169.254.`)&&!jt(e)&&!Mt(e)&&Nt(e));if(r!==void 0)return r;for(let e of n)if(!e.startsWith(`127.`)&&!e.startsWith(`169.254.`)&&!jt(e))return e;return null}function Ft(e){return`http://${e}:4444/`}function It(e,t){let n=new URL(Ft(e));return n.searchParams.set(`ticket`,t),n.toString()}function Lt(){return window.open(`about:blank`,`_blank`)}function Rt(e,t){return e===null||e.closed?!1:(e.location.href=t,!0)}function zt({node:e}){let{info:t}=qe();return!e.isHub||t===null?l(`span`,{className:`text-sm font-semibold shrink-0`,children:e.name}):r(o,{children:[l(`span`,{className:`text-sm font-semibold shrink-0`,"data-testid":`node-title-name`,children:t.name}),t.name!==e.id&&l(`span`,{className:`text-xs text-foreground-subtle shrink-0`,"data-testid":`node-title-id`,children:e.id})]})}n();function Bt(e){if(e<60)return`${e}s`;let t=Math.floor(e/60);if(t<60)return`${t}m`;let n=Math.floor(t/60);return n<24?`${n}h ${t%60}m`:`${Math.floor(n/24)}d ${n%24}h`}function Vt(e){return e===`running`?`running`:e===`crashed`||e===`failed`?`error`:`stopped`}var Ht=[`trace`,`debug`,`info`,`warn`,`error`];function Ut({proc:e,nodeId:t,defaultExpanded:n,activePanel:i,onTogglePanel:a}){let{t:o}=G(),s=e.services??[],u=s.length===1,[d,f]=c(u||n),[p,m]=c(null),[g,_]=c(`info`),v=e.name.includes(`(core)`),y=be(),b=ce(),x=Ie(),w=async e=>{m(e);try{await y.mutateAsync({nodeId:t,addonId:e})}catch(e){console.error(`Failed to restart addon:`,e)}finally{m(null)}},T=async()=>{m(e.name);try{await b.mutateAsync({nodeId:t,processName:e.name})}catch(e){console.error(`Failed to restart process:`,e)}finally{m(null)}},E=async n=>{let r=`${t}/${e.name}`;try{await x.mutateAsync({nodeId:r,level:n}),_(n)}catch(e){console.error(`Failed to set log level:`,e)}};return r(`div`,{className:`border border-border/50 rounded-lg overflow-hidden`,children:[r(`div`,{role:u?void 0:`button`,tabIndex:u?void 0:0,onClick:u?void 0:()=>f(!d),onKeyDown:u?void 0:e=>{(e.key===`Enter`||e.key===` `)&&f(!d)},className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 w-full px-3 py-2 bg-muted/20 transition-colors text-left select-none ${u?``:`hover:bg-muted/40 cursor-pointer`}`,children:[u?l(`span`,{className:`h-3 w-3 shrink-0`}):l(d?ee:S,{className:`h-3 w-3 text-muted-foreground shrink-0`}),v?l(F,{className:`h-3.5 w-3.5 text-primary shrink-0`}):l(h,{className:`h-3.5 w-3.5 text-warning shrink-0`}),l(`span`,{className:`text-xs font-semibold min-w-0 flex-1 basis-full truncate sm:basis-auto`,children:e.name}),r(`span`,{className:`text-[10px] text-muted-foreground tabular-nums shrink-0`,children:[`PID `,e.pid]}),l(ge,{status:Vt(e.state),label:e.state}),r(`span`,{className:`text-[10px] text-muted-foreground tabular-nums shrink-0`,children:[e.cpuPercent,`% CPU`]}),l(`span`,{className:`text-[10px] text-muted-foreground tabular-nums shrink-0`,children:K(e.memoryRss)}),l(`span`,{className:`text-[10px] text-muted-foreground tabular-nums shrink-0`,children:Bt(e.uptimeSeconds)}),!v&&r(`div`,{className:`flex items-center gap-1`,onClick:e=>e.stopPropagation(),children:[r(Pe,{children:[l(Fe,{className:`text-[9px] px-1.5 py-0.5 rounded border border-border text-muted-foreground hover:text-foreground hover:bg-muted transition-colors font-mono`,title:o(`cluster.forksTab.setLogLevel`,`Set log level`),children:g}),l(Be,{align:`end`,className:`min-w-[70px] py-0.5`,children:Ht.map(e=>l(We,{onClick:()=>E(e),className:`h-auto px-2 py-1 text-[10px] font-mono ${e===g?`text-primary font-semibold`:``}`,children:e},e))})]}),l(`button`,{onClick:T,disabled:p===e.name,className:`p-1 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50`,title:o(`cluster.forksTab.restartProcess`,`Restart process`),children:l(C,{className:`h-3 w-3 ${p===e.name?`animate-spin`:``}`})})]})]}),d&&s.length>0&&l(`div`,{className:`divide-y divide-border/30`,children:s.map(e=>r(`div`,{children:[r(`div`,{className:`flex items-center gap-2 px-3 py-1.5 pl-9 hover:bg-muted/10 transition-colors`,children:[l(`div`,{className:`h-1.5 w-1.5 rounded-full shrink-0 ${e.status===`running`?`bg-success`:`bg-muted-foreground/30`}`}),l(`span`,{className:`text-xs font-medium flex-1 min-w-0 truncate`,children:e.addonId}),e.capabilities.length>0&&r(`div`,{className:`flex gap-1 flex-shrink-0`,children:[e.capabilities.slice(0,3).map(e=>l(`span`,{className:`text-[9px] px-1 py-0.5 rounded bg-info/10 text-info truncate max-w-[80px]`,children:e},e)),e.capabilities.length>3&&r(`span`,{className:`text-[9px] text-muted-foreground`,children:[`+`,e.capabilities.length-3]})]}),r(`div`,{className:`flex items-center gap-1 shrink-0`,children:[l(`button`,{onClick:()=>a(e.addonId,`logs`),className:`p-0.5 rounded transition-colors ${i?.addonId===e.addonId&&i.type===`logs`?`bg-primary/10 text-primary`:`hover:bg-muted text-muted-foreground hover:text-foreground`}`,title:o(`cluster.forksTab.showLogsFor`,`Show logs for {{addonId}}`,{addonId:e.addonId}),children:l(j,{className:`h-3 w-3`})}),l(`button`,{onClick:()=>a(e.addonId,`events`),className:`p-0.5 rounded transition-colors ${i?.addonId===e.addonId&&i.type===`events`?`bg-primary/10 text-primary`:`hover:bg-muted text-muted-foreground hover:text-foreground`}`,title:o(`cluster.forksTab.showEventsFor`,`Show events for {{addonId}}`,{addonId:e.addonId}),children:l(D,{className:`h-3 w-3`})}),l(`button`,{onClick:()=>w(e.addonId),disabled:p===e.addonId,className:`p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50`,title:o(`cluster.forksTab.restart`,`Restart {{addonId}}`,{addonId:e.addonId}),children:l(C,{className:`h-3 w-3 ${p===e.addonId?`animate-spin`:``}`})})]})]}),i?.addonId===e.addonId&&i.type===`logs`&&l(`div`,{className:`border-t border-border/40 bg-muted/5`,children:l(Ce,{addonId:e.addonId,agentId:t,maxHeight:`max-h-48`,showFilters:!1,onClose:()=>a(e.addonId,`logs`)})}),i?.addonId===e.addonId&&i.type===`events`&&l(`div`,{className:`border-t border-border/40 bg-muted/5`,children:l(Ge,{addonId:e.addonId,category:`addon.*`,maxHeight:`max-h-48`,onClose:()=>a(e.addonId,`events`)})})]},e.addonId))}),d&&s.length===0&&l(`div`,{className:`px-3 py-2 pl-9 text-[10px] text-muted-foreground`,children:o(`cluster.forksTab.noServices`,`No services`)})]})}function Wt({nodeId:e,processes:t}){let{t:n}=G(),[r,i]=c(null),a=(e,t)=>{i(n=>n?.addonId===e&&n.type===t?null:{addonId:e,type:t})};return t.length===0?l(`div`,{className:`py-4 text-xs text-muted-foreground text-center`,children:n(`cluster.forksTab.noProcessesOnThisNode`,`No processes on this node`)}):l(`div`,{className:`space-y-2 py-1`,children:t.map((t,n)=>l(Ut,{proc:t,nodeId:e,defaultExpanded:n===0,activePanel:r,onTogglePanel:a},t.name))})}var Gt={system:0,managed:1,root:2};n();function Kt(e){return e<60?`${e}s`:e<3600?`${Math.floor(e/60)}m ${e%60}s`:e<86400?`${Math.floor(e/3600)}h ${Math.floor(e%3600/60)}m`:`${Math.floor(e/86400)}d ${Math.floor(e%86400/3600)}h`}function qt(e,t=80){return e.length<=t?e:`…${e.slice(e.length-t+1)}`}function Jt({nodeId:e}){let{t}=G(),n=s(),i=W(`metrics.node-processes-snapshot`,t=>t.nodeId===e),{data:o}=pe({nodeId:e}),c=i?.processes??o,u=a(()=>c?[...c]:[],[c]),d=a(()=>[{key:`classification`,header:t(`cluster.processesTab.class`,`Class`),sortValue:e=>Gt[e.classification],render:e=>l(`span`,{className:`inline-block rounded-full px-1.5 py-0.5 text-[10px] font-medium ${e.classification===`root`?`bg-info/20 text-info`:e.classification===`system`?`bg-foreground-subtle/20 text-foreground-subtle`:`bg-success/20 text-success`}`,children:e.classification})},{key:`pid`,header:`PID`,align:`right`,sortValue:e=>e.pid,render:e=>l(`span`,{className:`font-mono`,children:e.pid})},{key:`ppid`,header:`PPID`,align:`right`,sortValue:e=>e.ppid,render:e=>l(`span`,{className:`font-mono text-foreground-subtle`,children:e.ppid})},{key:`addonId`,header:t(`cluster.processesTab.addon`,`Addon`),sortValue:e=>e.addonId,render:e=>l(`span`,{className:`text-foreground-subtle text-[11px]`,children:e.addonId??`—`})},{key:`command`,header:t(`cluster.processesTab.command`,`Command`),nowrap:!1,render:e=>l(`span`,{className:`font-mono text-[10px] text-foreground-subtle break-all`,children:qt(e.command)})},{key:`cpuPercent`,header:t(`cluster.processesTab.cpu`,`CPU%`),align:`right`,sortValue:e=>e.cpuPercent,render:e=>e.cpuPercent.toFixed(1)},{key:`memoryRssBytes`,header:`RSS`,align:`right`,sortValue:e=>e.memoryRssBytes,render:e=>K(e.memoryRssBytes)},{key:`uptimeSec`,header:t(`cluster.processesTab.uptime`,`Uptime`),align:`right`,sortValue:e=>e.uptimeSec,render:e=>l(`span`,{className:`text-foreground-subtle`,children:Kt(e.uptimeSec)})}],[t]);return r(`div`,{className:`space-y-4`,children:[l(`div`,{className:`flex items-start justify-end gap-4`,children:r(`button`,{type:`button`,onClick:()=>n.invalidateQueries({queryKey:[[`metricsProvider`,`listNodeProcesses`]]}),className:`inline-flex items-center gap-1 rounded border border-border px-2 py-1 text-[11px] text-foreground hover:bg-surface-hover`,children:[l(I,{className:`h-3 w-3`}),` Refresh`]})}),l(z,{columns:d,rows:u,rowKey:e=>e.pid,minWidthPx:880,mobileMode:`cards`,maxBodyHeight:Te,emptyMessage:t(`cluster.processesTab.scanning`,`Scanning…`)})]})}var q={width:320,height:64},Yt=.8,J=Math.ceil(8*Yt-3)+1,Y=q.width+34,Xt=q.height+J+1+11,Zt=J+q.height+1+3+Math.ceil(8*Yt),Qt=[1,2,5,10],$t=[1,2,4,8,16,32,64,128,256,512,1024],en=[1,1.5,2,2.5,3,4,5],tn=[4,3,5,2],nn=1e-9;function rn(e,t){if(!Number.isFinite(e)||e<=0)return!1;if(t===`bytes`){if(!Number.isInteger(e))return!1;let t=e/1024**Math.floor(Math.log(e)/Math.log(1024));return en.some(e=>Math.abs(t-e)<nn)}let n=e/10**Math.floor(Math.log10(e));return en.some(e=>Math.abs(n-e)<nn)}function an(e,t,n){let r=0;for(let t of e)t!==null&&t>r&&(r=t);if(r<=t)return t;if(n===`bytes`){let e=1024**Math.floor(Math.log(r)/Math.log(1024));for(let t of $t){let n=t*e;if(n>=r)return n}return 1024*e}let i=10**Math.floor(Math.log10(r));for(let e of Qt){let t=e*i;if(t>=r)return t}return 10*i}function on(e,t){if(!Number.isFinite(e)||e<=0)return[];let n=tn.find(n=>rn(e/n,t))??tn[tn.length-1],r=e/n,i=[];for(let e=1;e<=n;e++)i.push(r*e);return i}var sn=2.5;function cn(e){return e*sn}function ln(e,t,n,r){if(e.length===0)return[];let i=e[0].atMs,a=e.at(-1).atMs-i,o=n<=0?1:n,s=r!==void 0&&r>0?r:null;return e.map((r,c)=>{let l=a>0?(r.atMs-i)/a*t.width:c/Math.max(1,e.length-1)*t.width,u=c>0?e[c-1]:void 0;return{x:l,y:r.value===null?null:t.height-Math.min(r.value,n)/o*t.height,gapBefore:s!==null&&u!==void 0&&r.atMs-u.atMs>s}})}function un(e){let t=[],n=!1;for(let r of e){if(r.y===null){n=!1;continue}r.gapBefore&&(n=!1),t.push(`${n?`L`:`M`}${r.x.toFixed(1)},${r.y.toFixed(1)}`),n=!0}return t.join(` `)}function dn(e,t){let n=[],r=[],i=()=>{if(r.length<2){r=[];return}let e=r.map((e,t)=>`${t===0?`M`:`L`}${e.x.toFixed(1)},${e.top.toFixed(1)}`),t=[...r].reverse().map(e=>`L${e.x.toFixed(1)},${e.bottom.toFixed(1)}`);n.push(`${e.join(` `)} ${t.join(` `)} Z`),r=[]};for(let n=0;n<e.length;n++){let a=e[n],o=t[n];if(!a||!o||a.y===null||o.y===null){i();continue}(a.gapBefore||o.gapBefore)&&i(),r.push({x:a.x,top:a.y,bottom:o.y})}return i(),n.join(` `)}function fn(e,t,n=3){if(e.length<2||n<2)return[];let r=e[0].atMs,i=e.at(-1).atMs-r;if(i<=0)return[];let a=[];for(let e=0;e<n;e++){let o=e/(n-1);a.push({atMs:r+i*o,x:o*t.width,anchor:e===0?`start`:e===n-1?`end`:`middle`})}return a}function pn(e){return e.length<2?0:Math.max(0,e.at(-1).atMs-e[0].atMs)}function mn(e){let t=[];for(let n=1;n<e.length;n++){let r=e[n];r.gapBefore&&t.push({fromX:e[n-1].x,toX:r.x})}return t}function hn(e,t){if(e.length===0)return null;let n=0,r=1/0;for(let i=0;i<e.length;i++){let a=Math.abs(e[i].x-t);a<r&&(r=a,n=i)}return n}n();var X={main:`var(--color-chart-series-a)`,gc:`var(--color-chart-series-b)`},Z=q,gn={height:Xt};function _n({title:e,points:n,mainLabel:s,gcLabel:u,formatValue:d,emptyMessage:f,gapMs:p}){let{t:m}=G(),h=i(),g=t(null),[_,v]=c(null),y=a(()=>{let e=n.map(e=>({atMs:e.atMs,value:e.main===null||e.gc===null?null:e.main+e.gc})),t=n.map(e=>({atMs:e.atMs,value:e.main})),r=an(e.map(e=>e.value),25,`linear`),i=ln(e,Z,r,p),a=ln(t,Z,r,p),o=a.map(e=>({x:e.x,y:e.y===null?null:Z.height,gapBefore:e.gapBefore}));return{max:r,ticks:on(r,`linear`),upper:i,middle:a,base:o,gaps:mn(i),times:fn(e,Z),spanMs:pn(e)}},[n,p]),b=n.at(-1),x=_===null?void 0:n[_.index],S=x??b;return n.length===0||y.upper.every(e=>e.y===null)?l(Q,{title:e,children:l(kn,{message:f})}):l(Q,{title:e,legend:r(o,{children:[l(Dn,{color:X.main,label:s}),l(Dn,{color:X.gc,label:u})]}),readout:S&&S.main!==null&&S.gc!==null?r(o,{children:[x!==void 0&&l(En,{atMs:x.atMs,spanMs:y.spanMs}),l(On,{color:X.main,text:d(S.main)}),l(On,{color:X.gc,text:d(S.gc)})]}):null,children:r(`svg`,{ref:g,viewBox:`0 0 ${Y} ${Xt}`,preserveAspectRatio:`none`,className:`w-full`,style:gn,role:`img`,"aria-label":m(`load.loadChart.andOverTime`,`{{title}}: {{mainLabel}} and {{gcLabel}} over time`,{title:e,mainLabel:s,gcLabel:u}),onMouseLeave:()=>v(null),onMouseMove:e=>{let t=e.currentTarget.getBoundingClientRect();if(t.width===0)return;let n=(e.clientX-t.left)/t.width*Y-34,r=hn(y.upper,n);r!==null&&v({index:r,xPx:y.upper[r].x})},children:[l(yn,{ticks:y.ticks,max:y.max,formatValue:d}),l(Tn,{ticks:y.times,spanMs:y.spanMs}),r(`g`,{transform:`translate(34,${J})`,clipPath:`url(#${h})`,children:[l(`clipPath`,{id:h,children:l(`rect`,{x:0,y:0,width:Z.width,height:Z.height})}),l(bn,{spans:y.gaps}),l(`path`,{d:dn(y.middle,y.base),fill:X.main,fillOpacity:.85}),l(`path`,{d:dn(y.upper,y.middle),fill:X.gc,fillOpacity:.85,stroke:`var(--color-surface, transparent)`,strokeWidth:2}),l(`path`,{d:un(y.upper),fill:`none`,stroke:X.gc,strokeWidth:2}),_!==null&&l(`line`,{x1:_.xPx,x2:_.xPx,y1:0,y2:Z.height,stroke:`currentColor`,strokeWidth:1,className:`text-foreground-subtle`})]})]})})}function vn({title:e,points:n,formatValue:i,emptyMessage:s,axisFloor:u,axisScale:d=`linear`,gapMs:f}){let p=t(null),[m,h]=c(null),g=a(()=>{let e=an(n.map(e=>e.value),u,d),t=ln(n,Z,e,f);return{max:e,ticks:on(e,d),projected:t,gaps:mn(t),times:fn(n,Z),spanMs:pn(n)}},[n,u,d,f]),_=m===null?void 0:n[m.index],v=_??n.at(-1)??void 0;return n.length===0||g.projected.every(e=>e.y===null)?l(Q,{title:e,children:l(kn,{message:s})}):l(Q,{title:e,readout:v&&v.value!==null?r(o,{children:[_!==void 0&&l(En,{atMs:_.atMs,spanMs:g.spanMs}),l(On,{color:X.main,text:i(v.value)})]}):null,children:r(`svg`,{ref:p,viewBox:`0 0 ${Y} ${Xt}`,preserveAspectRatio:`none`,className:`w-full`,style:gn,role:`img`,"aria-label":e,onMouseLeave:()=>h(null),onMouseMove:e=>{let t=e.currentTarget.getBoundingClientRect();if(t.width===0)return;let n=(e.clientX-t.left)/t.width*Y-34,r=hn(g.projected,n);r!==null&&h({index:r,xPx:g.projected[r].x})},children:[l(yn,{ticks:g.ticks,max:g.max,formatValue:i}),l(Tn,{ticks:g.times,spanMs:g.spanMs}),r(`g`,{transform:`translate(34,${J})`,children:[l(bn,{spans:g.gaps}),l(`path`,{d:un(g.projected),fill:`none`,stroke:X.main,strokeWidth:2}),m!==null&&l(`line`,{x1:m.xPx,x2:m.xPx,y1:0,y2:Z.height,stroke:`currentColor`,strokeWidth:1,className:`text-foreground-subtle`})]})]})})}function yn({ticks:e,max:t,formatValue:n}){let i=t<=0?1:t;return l(`g`,{className:`text-foreground-subtle`,children:e.map(e=>{let t=J+Z.height-e/i*Z.height;return r(`g`,{children:[l(`line`,{x1:34,x2:34+Z.width,y1:t,y2:t,stroke:`currentColor`,strokeWidth:.5,strokeOpacity:.3}),l(`text`,{x:0,y:t+3,fontSize:8,fill:`currentColor`,children:n(e)})]},e)})})}function bn({spans:e}){let{t}=G();return e.length===0?null:l(`g`,{className:`text-foreground-subtle`,children:e.map(e=>l(`rect`,{x:e.fromX,y:0,width:Math.max(1,e.toX-e.fromX),height:Z.height,fill:`currentColor`,fillOpacity:.12,children:l(`title`,{children:t(`load.loadChart.noSamplesInThisInterval`,`No samples in this interval — nothing was measured, nothing is drawn.`)})},`${e.fromX}-${e.toX}`))})}var xn=10*6e4,Sn={hour:`2-digit`,minute:`2-digit`},Cn={hour:`2-digit`,minute:`2-digit`,second:`2-digit`};function wn(e,t){return new Date(e).toLocaleTimeString(void 0,t<xn?Cn:Sn)}function Tn({ticks:e,spanMs:t}){return e.length===0?null:l(`g`,{className:`text-foreground-subtle`,children:e.map(e=>l(`text`,{x:34+e.x,y:Zt,fontSize:8,textAnchor:e.anchor,fill:`currentColor`,children:wn(e.atMs,t)},e.atMs))})}function En({atMs:e,spanMs:t}){return l(`span`,{className:`text-[10px] tabular-nums text-foreground-subtle`,children:wn(e,t)})}function Q({title:e,legend:t,readout:n,children:i}){return r(`div`,{className:`min-w-0`,children:[r(`div`,{className:`flex items-baseline justify-between gap-2 mb-1`,children:[l(`span`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle`,children:e}),l(`div`,{className:`flex items-center gap-2`,children:n})]}),i,t&&l(`div`,{className:`flex items-center gap-3 mt-1`,children:t})]})}function Dn({color:e,label:t}){return r(`span`,{className:`inline-flex items-center gap-1 text-[9px] text-foreground-subtle`,children:[l(`span`,{className:`inline-block h-2 w-2 rounded-[2px]`,style:{backgroundColor:e}}),t]})}function On({color:e,text:t}){return r(`span`,{className:`inline-flex items-center gap-1 text-[11px] tabular-nums text-foreground`,children:[l(`span`,{className:`inline-block h-2 w-2 rounded-[2px]`,style:{backgroundColor:e}}),t]})}function kn({message:e}){return l(`div`,{className:`h-16 flex items-center justify-center rounded border border-dashed border-border text-[10px] text-foreground-subtle text-center px-2`,children:e})}function An(e,t){let n=e.at(-1);return n===void 0?[t]:t.atMs>n.atMs?[...e,t]:e.some(e=>e.atMs===t.atMs)?e:[...e,t].toSorted((e,t)=>e.atMs-t.atMs)}function jn(e,t,n,r){let i=e.get(t),a=An(i?.points??[],r);if(i!==void 0&&a===i.points)return e;let o=new Map(e);return o.set(t,{key:t,kind:n,points:a.slice(Math.max(0,a.length-720))}),o}function Mn(e,t,n){let r=e;for(let e of se(t,n))r=jn(r,e.key,e.kind,e.point);return r}function Nn(e,t){let n=e;for(let e of t)for(let t of e.points)n=jn(n,e.key,e.kind,t);return n}function Pn(e){let t=null;for(let n of e.values()){let e=n.points.at(-1);e!==void 0&&(t===null||e.atMs>t)&&(t=e.atMs)}return t}var Fn=12e4;function In(e,t){return e===null?!1:t-e>Fn}function Ln(e){let t=e=>{let t=e.points.at(-1);return t===void 0?-1:t.cpuMainPercent!==null&&t.cpuGcPercent!==null?t.cpuMainPercent+t.cpuGcPercent:t.cpuLifetimePercent};return[...e.values()].toSorted((e,n)=>{let r=t(n)-t(e);return r===0?e.key.localeCompare(n.key):r})}function Rn(e){for(let t of e.values()){let e=t.points.at(-1);if(e&&e.cpuMainPercent!==null)return!0}return!1}var zn={key:`cpu`,dir:`desc`};function Bn(e){let t=e.points.at(-1);return t===void 0?null:t.cpuMainPercent!==null&&t.cpuGcPercent!==null?t.cpuMainPercent+t.cpuGcPercent:t.cpuLifetimePercent}function Vn(e){return e.points.at(-1)?.memoryRssBytes??null}function Hn(e,t,n){let r=n.trim().toLowerCase();return r===``?!0:e.toLowerCase().includes(r)||t.toLowerCase().includes(r)}function Un(e,t){return t===`memory`?Vn(e):Bn(e)}function Wn(e,t,n){let r=e.filter(e=>t.selectedKeys.size>0&&!t.selectedKeys.has(e.key)?!1:Hn(n(e),e.key,t.search)),i=(e,t)=>e.key.localeCompare(t.key);return[...r].toSorted((e,r)=>{if(t.sort.key===`name`){let a=n(e).localeCompare(n(r)),o=t.sort.dir===`asc`?a:-a;return o===0?i(e,r):o}let a=Un(e,t.sort.key),o=Un(r,t.sort.key);if(a===null&&o===null)return i(e,r);if(a===null)return 1;if(o===null)return-1;let s=t.sort.dir===`desc`?o-a:a-o;return s===0?i(e,r):s})}n();function Gn(e,n=720){let r=W(`metrics.node-processes-snapshot`,t=>t.nodeId===e),[i,a]=c(new Map),[o,s]=c(void 0),l=t(null),{data:d,isPending:f}=Oe({forNodeId:e,sinceMs:o,maxPoints:n});u(()=>{d!==void 0&&a(e=>{let t=Nn(e,d.series);return l.current=Pn(t),t})},[d]);let p=r?.timestamp;u(()=>{r==null||p===void 0||(In(l.current,p)&&s(l.current??0),a(e=>{let t=Mn(e,r.processes,p);return l.current=Pn(t),t}))},[p]),u(()=>{a(new Map),s(void 0),l.current=null},[e]);let m=0;for(let e of i.values())m=Math.max(m,e.points.length);return{series:Ln(i),sampleCount:m,threadSplitAvailable:Rn(i),loadingRetained:f,durable:d?.durable??null,bucketMs:d?.bucketMs??null,cadenceMs:d?.cadenceMs??null,retainedSamples:d?.retainedSamples??null}}var Kn=`__unclaimed__`;function qn(e,t){return{kind:e,deviceId:t,cpu:0,cpuKnown:!0,rss:0,rssKnown:!0,count:0,roles:new Set}}function Jn(e,t){return{key:e,kind:t.kind,deviceId:t.deviceId,cpuSeconds:t.cpuKnown?Math.round(t.cpu*100)/100:null,rssBytes:t.rssKnown?t.rss:null,unitCount:t.count,roles:[...t.roles].sort()}}function Yn(e,t){let n=new Map,r=new Set;for(let t of e){t.pid!==void 0&&r.add(t.pid);let e=t.deviceId!==null&&t.attribution!==`unattributable`,i=e?`device:${t.deviceId}`:`shared:${t.role}`,a=n.get(i)??qn(e?`camera`:`shared`,e?t.deviceId:null);a.count+=1,a.roles.add(t.role),t.cpuSeconds===void 0?a.cpuKnown=!1:a.cpu+=t.cpuSeconds,t.rssBytes===void 0?a.rssKnown=!1:a.rss+=t.rssBytes,n.set(i,a)}let i=[...n.entries()].map(([e,t])=>Jn(e,t));if(t===void 0)return i;let a=t.filter(e=>!r.has(e.pid));if(a.length===0)return i;let o=qn(`unclaimed`,null);for(let e of a)o.count+=1,o.rss+=e.memoryRssBytes;return o.cpuKnown=!1,[...i,Jn(Kn,o)]}var Xn=[{family:`decode`,attribution:`measured`,unit:`one forked decode-worker child per decode SESSION`,perCamera:!0,wiredToday:!0,missingLink:``,evidence:[`packages/addon-pipeline/src/session-decode/fork-decode-worker.ts:118`,`packages/addon-pipeline/src/session-decode/fork-decode-worker.ts:131`,`packages/addon-pipeline/src/pipeline-runner/index.ts:2765`,`packages/types/src/process/child-cost-registry.ts:188`]},{family:`transcode`,attribution:`measured`,unit:`one ffmpeg child per (camera, encode plan)`,perCamera:!0,wiredToday:!0,missingLink:``,evidence:[`packages/addon-pipeline/src/stream-broker/stream-broker/egress-transcode-manager.ts:960`,`packages/addon-pipeline/src/stream-broker/stream-broker/transcode-egress.ts:282`,`packages/addon-pipeline/src/stream-broker/stream-broker/transcode-egress.ts:324`,`packages/types/src/ffmpeg/sharing-key.ts:139`]},{family:`recording`,attribution:`measured`,unit:`one passthrough ffmpeg per (camera, profile)`,perCamera:!0,wiredToday:!0,missingLink:``,evidence:[`packages/addon-pipeline/src/recorder/addon/segment-writer.ts:33`,`packages/addon-pipeline/src/recorder/addon/segment-writer.ts:217`,`packages/addon-pipeline/src/recorder/addon/segment-writer.ts:279`,`packages/addon-pipeline/src/recorder/addon/recording-controller.ts:1710`]},{family:`detection`,attribution:`accounted`,unit:`a SHARED inference pool per (node, runtime, device) — no per-camera process`,perCamera:!1,wiredToday:!0,missingLink:"Nothing is missing for COUNTING — per-camera inference milliseconds, processed/shed frames and bytes-to-pool are already accumulated. What is missing is any basis for CPU seconds: `deviceId` reaches the pool as a diagnostic label and selects nothing, so cost can only ever be apportioned, never measured. Since 2026-08-27 the pool DECLARES this itself, contributing `deviceId: null` + `attribution: unattributable` rather than leaving an observer to infer it — the renunciation is data, and it is still refused by the chart gate.",evidence:[`packages/addon-pipeline/src/detection-pipeline/provider.ts:540`,`packages/addon-pipeline/src/detection-pipeline/engine/shared-inference-pool.ts:413`,`packages/types/src/interfaces/inference-engine.ts:24`,`packages/addon-pipeline/src/pipeline-runner/timing-sampler.ts:63`,`packages/addon-pipeline/src/pipeline-runner/runner.ts:353`,`packages/addon-pipeline/src/pipeline-runner/runner.ts:849`,`packages/addon-pipeline/src/pipeline-runner/frame-lazy-metrics.ts:100`]},{family:`streaming`,attribution:`measured`,unit:"one StreamBroker per `${deviceId}/${camStreamId}`, with an exact RTP ring byte counter",perCamera:!0,wiredToday:!1,missingLink:"The ffmpeg-backed ingest is now reported per camera, but that is the minority path. `rtpRingBytes` — the exact figure for the in-process case — is maintained on every push and drop and is still private and absent from `getStats()`. The three `EncodedRingBuffer`s track packets and duration and have no byte accumulator at all; the only byte figure they offer is `preRollBudgetBytes`, which is a BUDGET, not an occupancy.",evidence:[`packages/addon-pipeline/src/stream-broker/stream-broker/stream-broker.ts:2895`,`packages/addon-pipeline/src/stream-broker/rtsp/ffmpeg-push-reader.ts:189`,`packages/addon-pipeline/src/stream-broker/stream-broker/stream-broker.ts:494`,`packages/addon-pipeline/src/stream-broker/stream-broker/stream-broker.ts:498`,`packages/addon-pipeline/src/stream-broker/stream-broker/stream-broker.ts:2505`,`packages/addon-pipeline/src/stream-broker/stream-broker/pre-roll.ts:269`]}];function Zn(e){return e.attribution===`measured`&&e.wiredToday}function Qn(){let e=new Set;for(let t of Xn)Zn(t)&&e.add(t.family);return e}var $n=Qn();function er(e){return!$n.has(e.role)||e.deviceId===null?!1:e.attribution===`measured`}function tr(e){return`${e.addonId}${e.role}${e.unit}${e.pid??`-`}`}function nr(){return{cpuSeconds:0,cpuKnown:!0,rssBytes:0,rssKnown:!0,unitCount:0,roles:new Set}}function rr(e,t,n){if(t.cpuSeconds===void 0)return null;if(e===void 0)return t.startedAtMs===void 0||t.startedAtMs<n?null:t.cpuSeconds;if(e.cpuSeconds===void 0||e.startedAtMs===void 0||t.startedAtMs===void 0||e.startedAtMs!==t.startedAtMs)return null;let r=t.cpuSeconds-e.cpuSeconds;return r<0?null:r}function ir(e){return Math.round(e*10)/10}function ar(e,t){let n=t.atMs-e.atMs;if(n<=0)return[];let r=n/1e3,i=new Map;for(let t of e.entries)er(t)&&i.set(tr(t),t);let a=new Map,o=new Set;for(let n of t.entries){if(!er(n)||n.deviceId===null)continue;let t=tr(n);o.add(t);let r=a.get(n.deviceId)??nr();r.unitCount+=1,r.roles.add(n.role);let s=rr(i.get(t),n,e.atMs);s===null?r.cpuKnown=!1:r.cpuSeconds+=s,n.rssBytes===void 0?r.rssKnown=!1:r.rssBytes+=n.rssBytes,a.set(n.deviceId,r)}for(let[e,t]of i){if(o.has(e)||t.deviceId===null)continue;let n=a.get(t.deviceId);n!==void 0&&(n.cpuKnown=!1)}return[...a.entries()].map(([e,n])=>({deviceId:e,point:{atMs:t.atMs,cpuPercent:n.cpuKnown?ir(n.cpuSeconds/r*100):null,rssBytes:n.rssKnown?n.rssBytes:null,unitCount:n.unitCount,roles:[...n.roles].toSorted()}}))}function or(e,t){if(t.length===0)return e;let n=new Map(e);for(let e of t){let t=n.get(e.deviceId),r=t?.points.at(-1);if(r!==void 0&&e.point.atMs<=r.atMs)continue;let i=[...t?.points??[],e.point];n.set(e.deviceId,{deviceId:e.deviceId,points:i.slice(Math.max(0,i.length-720))})}return n}function sr(e){let t=e=>{for(let t=e.points.length-1;t>=0;t--){let n=e.points[t]?.cpuPercent;if(n!=null)return n}return-1};return[...e.values()].toSorted((e,n)=>{let r=t(n)-t(e);return r===0?e.deviceId-n.deviceId:r})}function cr(e){let t=e.indexOf(`@`);return t===-1?{addonId:e,nodeId:null}:{addonId:e.slice(0,t),nodeId:e.slice(t+1)}}function lr(e,t){let n=cr(e);return n.nodeId===null?t.isHub:n.nodeId===t.nodeId}function ur(e,t){return e.filter(e=>lr(e.addonId,t))}n();function dr(e){let n=W(`metrics.node-processes-snapshot`,t=>t.nodeId===e.nodeId),r=Le(void 0,{staleTime:1/0,refetchOnWindowFocus:!1}),[i,a]=c(new Map),o=t(null),s=t(r.refetch);s.current=r.refetch;let l=n?.timestamp;u(()=>{l!==void 0&&s.current()},[l]),u(()=>{a(new Map),o.current=null},[e.nodeId,e.isHub]);let d=r.data,f=r.dataUpdatedAt;u(()=>{if(d===void 0||f===0)return;let t={atMs:f,entries:ur(d,e)},n=o.current;if(o.current=t,n===null)return;let r=ar(n,t);r.length!==0&&a(e=>or(e,r))},[d,f,e.nodeId,e.isHub]);let p=d===void 0?[]:ur(d,e),m=n?.processes,h=Yn(p,m);return{series:sr(i),unclaimed:h.find(e=>e.kind===`unclaimed`)??null,loading:r.isPending,error:r.error===null?null:r.error.message}}function fr(e){let t=new Map;for(let n of e){let e=n.name?.trim();e===void 0||e===``||t.set(n.id,e)}return t}var pr=25,mr=64*1024*1024,hr=1e4;function gr({scope:e,cadenceMs:t}){let{t:n}=G(),i=dr(e),{data:a=[]}=Ve({isCamera:!0,projection:`slim`}),o=fr(a),s=cn(t??hr);return r(`section`,{className:`space-y-3`,children:[i.error!==null&&r(`div`,{className:`flex items-start gap-2 rounded-md border border-destructive/40 bg-destructive/5 px-3 py-2 text-[11px] text-destructive`,children:[l(m,{className:`h-3 w-3 mt-0.5 shrink-0`}),l(`span`,{children:n(`cameraLoad.readFailed`,`Could not read the load contributions: {{error}}. This is a failed read, NOT an idle cluster.`,{error:i.error})})]}),l(vr,{unclaimed:i.unclaimed}),i.series.length===0&&i.error===null&&l(`div`,{className:`rounded-md border border-dashed border-border px-3 py-6 text-center text-[11px] text-foreground-subtle`,children:i.loading?n(`cameraLoad.loading`,`Reading what the addons report…`):n(`cameraLoad.waitingWindow`,`No per-camera window yet.`)}),l(`div`,{className:`space-y-3`,children:i.series.map(e=>r(`div`,{className:`rounded-lg border border-border p-3`,children:[r(`div`,{className:`flex items-baseline justify-between gap-2 mb-2`,children:[l(_r,{deviceId:e.deviceId,name:o.get(e.deviceId)}),l(`span`,{className:`text-[10px] text-foreground-subtle`,children:n(`cameraLoad.unitCount`,`{{count}} unit(s): {{roles}}`,{count:e.points.at(-1)?.unitCount??0,roles:(e.points.at(-1)?.roles??[]).join(`, `)})})]}),r(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[l(vn,{title:n(`cameraLoad.cpuTitle`,`CPU % of one core (delta)`),points:e.points.map(e=>({atMs:e.atMs,value:e.cpuPercent})),formatValue:e=>`${e.toFixed(1)}%`,axisFloor:pr,gapMs:s,emptyMessage:n(`cameraLoad.cpuUnavailable`,`No measurable window yet.`)}),l(vn,{title:n(`cameraLoad.memoryTitle`,`Memory RSS`),points:e.points.map(e=>({atMs:e.atMs,value:e.rssBytes})),formatValue:K,axisFloor:mr,axisScale:`bytes`,gapMs:s,emptyMessage:n(`cameraLoad.memoryUnavailable`,`No memory reported.`)})]})]},e.deviceId))})]})}function _r({deviceId:e,name:t}){let{t:n}=G();return t===void 0?l(`span`,{className:`text-xs font-medium text-foreground`,children:n(`cameraLoad.deviceLabel`,`Camera {{deviceId}}`,{deviceId:e})}):r(`span`,{className:`flex items-baseline gap-1.5 min-w-0`,children:[l(`span`,{className:`text-xs font-medium text-foreground truncate`,children:t}),r(`span`,{className:`shrink-0 text-[10px] font-mono text-foreground-subtle`,children:[`#`,e]})]})}function vr({unclaimed:e}){let{t}=G();return e===null||e.unitCount===0?null:l(`div`,{className:`flex items-center gap-2`,children:l(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded-full bg-warning/10 text-warning font-medium tabular-nums`,children:t(`cameraLoad.unclaimedBadge`,`{{count}} unclaimed · {{rss}}`,{count:e.unitCount,rss:e.rssBytes===null?`—`:K(e.rssBytes)})})})}n();var yr=256*1024*1024,br=1e4;function xr({nodeId:e,isHub:t}){let{t:n}=G(),{series:i,sampleCount:o,threadSplitAvailable:s,loadingRetained:u,bucketMs:d,cadenceMs:f}=Gn(e),[p,h]=c(``),[g,_]=c(new Set),[v,y]=c(zn),b=e=>e.key===`__root__`?n(`clusterLoad.bucketRoot`,`Node supervisor`):e.key===`__unattributed__`?n(`clusterLoad.bucketUnattributed`,`Unattributed processes`):e.key,x=cn(d??f??br),S=a(()=>Wn(i,{search:p,selectedKeys:g,sort:v},b),[i,p,g,v]),C=e=>{_(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})};return r(`div`,{className:`space-y-4`,children:[l(Sr,{bucketMs:d,cadenceMs:f}),!s&&o>0&&r(`div`,{className:`flex items-start gap-2 rounded-md border border-warning/40 bg-warning/5 px-3 py-2 text-[11px] text-warning`,children:[l(m,{className:`h-3 w-3 mt-0.5 shrink-0`}),l(`span`,{children:n(`clusterLoad.noThreadSplit`,`No thread-level CPU split on this node — /proc/<pid>/task is Linux-only, and the first sample after a restart has no window to measure. CPU below falls back to the ps lifetime AVERAGE, which is not a rate.`)})]}),o===0&&l(`div`,{className:`rounded-md border border-dashed border-border px-3 py-6 text-center text-[11px] text-foreground-subtle`,children:u?n(`clusterLoad.loadingRetained`,`Reading the retained series from this node…`):n(`clusterLoad.waitingFirstSample`,`No retained samples for this node — waiting for the next snapshot (up to 20s). The chart needs two to draw a rate.`)}),i.length>0&&r(`div`,{className:`space-y-2`,children:[r(`div`,{className:`flex flex-wrap items-center gap-2`,children:[r(`label`,{className:`relative flex-1 min-w-[160px]`,children:[l(k,{className:`pointer-events-none absolute left-2 top-1/2 h-3 w-3 -translate-y-1/2 text-foreground-subtle`}),l(`input`,{type:`search`,value:p,onChange:e=>h(e.target.value),placeholder:n(`clusterLoad.searchPlaceholder`,`Find a runner…`),"aria-label":n(`clusterLoad.searchLabel`,`Find a runner`),className:`w-full rounded border border-border bg-background py-1 pl-7 pr-2 text-[11px] text-foreground placeholder:text-foreground-subtle`})]}),l(Cr,{sort:v,onChange:y})]}),r(`div`,{className:`flex flex-wrap items-center gap-1`,children:[i.map(e=>{let t=g.has(e.key);return l(`button`,{type:`button`,"aria-pressed":t,onClick:()=>C(e.key),className:`rounded-full border px-2 py-0.5 text-[10px] transition-colors ${t?`border-primary bg-primary/10 text-primary`:`border-border text-foreground-subtle hover:text-foreground`}`,children:b(e)},e.key)}),g.size>0&&r(`button`,{type:`button`,onClick:()=>_(new Set),className:`inline-flex items-center gap-1 rounded-full border border-border px-2 py-0.5 text-[10px] text-foreground-subtle hover:text-foreground`,children:[l(A,{className:`h-2.5 w-2.5`}),n(`clusterLoad.clearFilter`,`All runners`)]})]})]}),i.length>0&&S.length===0&&l(`div`,{className:`rounded-md border border-dashed border-border px-3 py-6 text-center text-[11px] text-foreground-subtle`,children:n(`clusterLoad.noMatches`,`No runner matches this search on {{count}} present. The node is reporting — the filter is hiding them.`,{count:i.length})}),l(`div`,{className:`space-y-3`,children:S.map(e=>r(`div`,{className:`rounded-lg border border-border p-3`,children:[r(`div`,{className:`flex items-baseline justify-between gap-2 mb-2`,children:[l(`span`,{className:`text-xs font-medium text-foreground`,children:b(e)}),l(`span`,{className:`text-[10px] text-foreground-subtle`,children:n(`clusterLoad.processCount`,`{{count}} process(es)`,{count:e.points.at(-1)?.processCount??0})})]}),r(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[l(_n,{title:s?n(`clusterLoad.cpuTitle`,`CPU % of one core`):n(`clusterLoad.cpuTitleLifetime`,`CPU % (ps lifetime average)`),mainLabel:n(`clusterLoad.seriesMain`,`Main threads`),gcLabel:n(`clusterLoad.seriesGc`,`GC / V8 helpers`),points:e.points.map(e=>({atMs:e.atMs,main:e.cpuMainPercent,gc:e.cpuGcPercent})),formatValue:e=>`${e.toFixed(0)}%`,gapMs:x,emptyMessage:n(`clusterLoad.cpuUnavailable`,`No thread split on this node. Lifetime average: {{avg}}%`,{avg:(e.points.at(-1)?.cpuLifetimePercent??0).toFixed(1)})}),l(vn,{title:n(`clusterLoad.memoryTitle`,`Memory RSS`),points:e.points.map(e=>({atMs:e.atMs,value:e.memoryRssBytes})),formatValue:K,axisFloor:yr,axisScale:`bytes`,gapMs:x,emptyMessage:n(`clusterLoad.memoryUnavailable`,`No memory samples yet.`)})]})]},e.key))}),l(gr,{scope:{nodeId:e,isHub:t},cadenceMs:f})]})}function Sr({bucketMs:e,cadenceMs:t}){let{t:n}=G();return e===null?null:l(`p`,{className:`text-[10px] text-foreground-subtle`,children:t!==null&&e>t?n(`clusterLoad.captionBucket`,`1 point = {{bucket}}s (bucket MAXIMUM, not a mean)`,{bucket:Math.round(e/1e3)}):n(`clusterLoad.captionRaw`,`1 point = 1 snapshot`)})}function Cr({sort:e,onChange:t}){let{t:n}=G(),i=[{key:`cpu`,label:n(`clusterLoad.sortCpu`,`CPU`)},{key:`memory`,label:n(`clusterLoad.sortMemory`,`Memory`)},{key:`name`,label:n(`clusterLoad.sortName`,`Name`)}];return r(`div`,{className:`flex items-center gap-1`,children:[l(`span`,{className:`text-[10px] text-foreground-subtle`,children:n(`clusterLoad.sortBy`,`Sort by`)}),i.map(n=>{let i=e.key===n.key;return r(`button`,{type:`button`,"aria-pressed":i,onClick:()=>t(i?{key:n.key,dir:e.dir===`desc`?`asc`:`desc`}:{key:n.key,dir:n.key===`name`?`asc`:`desc`}),className:`rounded border px-1.5 py-0.5 text-[10px] transition-colors ${i?`border-primary bg-primary/10 text-primary`:`border-border text-foreground-subtle hover:text-foreground`}`,children:[n.label,i&&(e.dir===`desc`?` ↓`:` ↑`)]},n.key)})]})}var wr=`No per-node settings on this node. Every other setting these addons expose is one value for the whole cluster — edit those in System → Settings, not here.`;function Tr({nodeId:e,addonIds:t}){let{t:n}=G();return t.length===0?l(`div`,{className:`py-4 text-xs text-muted-foreground text-center`,children:n(`cluster.nodeDetailSettingsTab.noAddonsOnThisNode`,`No addons on this node`)}):l(`div`,{className:`w-full py-2`,children:l(Ye,{nodeId:e,addonIds:t,level:`global`,fieldScope:`perNode`,emptyMessage:wr,selfTabbed:!0})})}n();function Er({nodeId:e,addons:t}){let{t:n}=G(),r=s(),{data:i,isLoading:o}=_e({nodeId:e}),c=a(()=>{let e=new Map;for(let n of t)for(let t of n.capabilities){let r=e.get(t)??[];r.push(n.id),e.set(t,r)}return[...e.entries()].toSorted(([e],[t])=>e.localeCompare(t)).map(([e,t])=>({capName:e,providers:t}))},[t]),u=Ue({onSuccess:()=>{r.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCapabilityBindings`]]})}});return c.length===0?l(`div`,{className:`py-4 text-xs text-muted-foreground text-center`,children:n(`cluster.nodeDetailCapabilitiesTab.noCapabilitiesOnThisNode`,`No capabilities on this node`)}):l(z,{columns:[{key:`capName`,header:n(`cluster.nodeDetailCapabilitiesTab.capability`,`Capability`),width:`w-1/2`,sortValue:e=>e.capName,render:e=>l(`span`,{className:`font-medium`,children:e.capName})},{key:`provider`,header:n(`cluster.nodeDetailCapabilitiesTab.boundProvider`,`Bound provider`),render:t=>{let r=i?.[t.capName]??t.providers[0]??``,a=t.providers.length===1;return l(`select`,{value:r,onChange:n=>u.mutate({nodeId:e,capName:t.capName,addonId:n.target.value}),disabled:a||u.isPending||o,className:`w-full rounded-md border border-border bg-surface px-2 py-1 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary disabled:opacity-60`,title:a?n(`cluster.nodeDetailCapabilitiesTab.onlyOneProviderInstalledChoice`,`Only one provider installed — choice becomes available once a second addon registers this capability`):void 0,children:t.providers.map(e=>l(`option`,{value:e,children:e},e))})}}],rows:c,rowKey:e=>e.capName,minWidthPx:520,mobileMode:`cards`,maxBodyHeight:Te})}n();function Dr(e){if(e==null)return`—`;let t=Math.floor(e/1e3),n=Math.floor(t/86400),r=Math.floor(t%86400/3600),i=Math.floor(t%3600/60);return n>0?`${n}d ${r}h ${i}m`:r>0?`${r}h ${i}m`:`${i}m`}function Or(e){let{t}=G(),[n,i]=c(!1),[a,o]=c(e.name),u=s(),d=Me({onSuccess:()=>{u.invalidateQueries({queryKey:[[`nodes`,`topology`]]})}}),f=(e.localIps??[]).filter(e=>!e.includes(`:`)),p=(e.localIps??[]).filter(e=>e.includes(`:`)),m=async()=>{if(!a.trim()||a===e.name){i(!1);return}try{await d.mutateAsync({nodeId:e.nodeId,name:a.trim()}),i(!1)}catch(e){console.error(`Rename failed:`,e)}},h=[[`Node ID`,l(`span`,{className:`font-mono text-xs`,children:e.nodeId})],[`Display Name`,n?r(`div`,{className:`flex items-center gap-1.5`,children:[l(`input`,{type:`text`,className:`flex-1 px-2 py-0.5 text-xs border border-border rounded bg-background focus:outline-none focus:ring-1 focus:ring-primary`,value:a,onChange:e=>o(e.target.value),onKeyDown:e=>{e.key===`Enter`&&m(),e.key===`Escape`&&i(!1)},disabled:d.isPending,autoFocus:!0}),l(`button`,{onClick:()=>void m(),disabled:d.isPending,className:`p-0.5 text-success hover:bg-success/10 rounded`,title:t(`common.save`,`Save`),children:l(E,{className:`h-3.5 w-3.5`})}),l(`button`,{onClick:()=>i(!1),className:`p-0.5 text-muted-foreground hover:bg-muted rounded`,title:t(`common.cancel`,`Cancel`),children:l(A,{className:`h-3.5 w-3.5`})})]}):r(`div`,{className:`flex items-center gap-1.5`,children:[l(`span`,{className:`text-xs`,children:e.name}),!e.isHub&&l(`button`,{onClick:()=>{o(e.name),i(!0)},className:`p-0.5 text-muted-foreground hover:text-primary rounded`,title:t(`cluster.nodeInfoTab.rename`,`Rename`),children:l(_,{className:`h-3 w-3`})})]})],[`Hostname`,l(`span`,{className:`text-xs`,children:e.hostname})],[`Role`,e.isHub?l(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-primary/10 text-primary font-medium`,children:t(`cluster.nodeInfoTab.hub`,`Hub`)}):l(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-muted text-muted-foreground font-medium`,children:t(`cluster.nodeInfoTab.agent`,`Agent`)})],[`Root Package`,e.rootPackage?r(`span`,{className:`font-mono text-xs`,children:[e.rootPackage.name,`@`,e.rootPackage.version]}):l(`span`,{className:`text-xs text-muted-foreground`,children:`—`})],[`Platform`,r(`span`,{className:`text-xs`,children:[e.platform,` / `,e.arch]})],[`CPU`,r(`span`,{className:`text-xs`,children:[e.cpuModel??`—`,` (`,e.cpuCores,` cores)`]})],[`Memory`,l(`span`,{className:`text-xs`,children:e.memoryMB>0?t(`cluster.nodeInfoTab.gb`,`{{value1}} GB`,{value1:(e.memoryMB/1024).toFixed(1)}):`—`})],[`Uptime`,l(`span`,{className:`text-xs`,children:Dr(e.uptime)})],[`Engines`,e.engines.length>0?l(`div`,{className:`flex flex-wrap gap-1`,children:e.engines.map(e=>l(`span`,{className:`text-[9px] px-1.5 py-0.5 rounded-full bg-primary/10 text-primary font-medium`,children:e},e))}):l(`span`,{className:`text-xs text-muted-foreground`,children:`—`})]];return f.length>0&&h.push([`IPv4`,l(`div`,{className:`flex flex-wrap gap-1.5`,children:f.map((e,t)=>l(`span`,{className:`font-mono text-xs px-1.5 py-0.5 rounded bg-muted`,children:e},`${e}-${t}`))})]),p.length>0&&h.push([`IPv6`,l(`div`,{className:`flex flex-wrap gap-1.5`,children:p.map((e,t)=>l(`span`,{className:`font-mono text-[10px] px-1.5 py-0.5 rounded bg-muted truncate max-w-[280px]`,title:e,children:e},`${e}-${t}`))})]),l(`div`,{className:`py-2`,children:l(`table`,{className:`w-full text-sm`,children:l(`tbody`,{children:h.map(([e,t],n)=>r(`tr`,{className:n%2==0?`bg-muted/20`:``,children:[l(`td`,{className:`py-1.5 px-2 text-xs font-medium text-muted-foreground w-28 align-top whitespace-nowrap`,children:e}),l(`td`,{className:`py-1.5 px-2`,children:t})]},e))})})})}n();function kr({nodeId:e,value:t,detectedHosts:n,status:i,errorMessage:a,onCommit:o}){let{t:s}=G(),[d,f]=c(t??``);u(()=>{f(t??``)},[t]);let p=n[0],m=p===void 0?`auto-detect`:`auto: ${p}`,h=i===`pending`,g=d.trim(),_=g!==(t??``),v=_&&!h,y=()=>{v&&o(e,g.length>0?g:null)};return r(`div`,{className:`flex items-center gap-1.5`,children:[l(V,{"aria-label":s(`placementBoard.reachableHostInput.reachableHostFor`,`Reachable host for {{nodeId}}`,{nodeId:e}),type:`text`,inputMode:`url`,autoComplete:`off`,spellCheck:!1,placeholder:m,value:d,disabled:h,onChange:e=>f(e.target.value),onBlur:y,onKeyDown:e=>{e.key===`Enter`&&y(),e.key===`Escape`&&f(t??``)},className:`w-36`}),r(L,{variant:`outline`,size:`sm`,onClick:y,disabled:!v,"aria-label":s(`placementBoard.reachableHostInput.saveReachableHostFor`,`Save reachable host for {{nodeId}}`,{nodeId:e}),title:s(`placementBoard.reachableHostInput.saveReachableHost`,`Save reachable host`),children:[h?l(T,{className:`h-3 w-3 animate-spin`,"aria-hidden":`true`}):l(E,{className:`h-3 w-3`,"aria-hidden":`true`}),s(`common.save`,`Save`)]}),!_&&!h&&i===`success`&&l(E,{className:`h-3.5 w-3.5 shrink-0 text-success`,"aria-label":s(`placementBoard.reachableHostInput.saved`,`Saved`),role:`img`}),i===`error`&&l(`span`,{title:a??s(`placementBoard.reachableHostInput.failedToSaveReachableHost`,`Failed to save reachable host`),children:l(P,{className:`h-3.5 w-3.5 shrink-0 text-danger`,"aria-label":a??s(`placementBoard.reachableHostInput.failedToSaveReachableHost`,`Failed to save reachable host`),role:`img`})})]})}n();function Ar(e){let t=ie.safeParse(Xe(e,`color`));return t.success?t.data:null}function jr(e,t){return t.variables?.agentNodeId===e?t.isPending?`pending`:t.isError?`error`:t.isSuccess?`success`:`idle`:`idle`}function Mr({nodeId:e,detectedHosts:t}){let{t:n}=G(),i=s(),o=Ee(void 0),c=Ae({onSuccess:()=>Ze(i)}),u=Ae({onSuccess:()=>Ze(i)}),d=a(()=>o.data?.find(t=>t.nodeId===e)?.settings,[o.data,e]),f=Ar(d)??(o.isLoading?null:oe(e)),p=Qe(d,`reachableHost`),m=jr(e,c),h=m===`error`?$e(c.error):null,g=t.filter(e=>!e.includes(`:`)),_=t=>{t!==f&&u.mutate({agentNodeId:e,color:t})};return r(`div`,{className:`rounded-lg border border-border bg-surface/40 divide-y divide-border px-3`,children:[l(ke,{label:n(`nodes.general.nodeColour`,`Node colour`),children:l(`div`,{role:`group`,"aria-label":n(`nodes.general.nodeColourGroup`,`Node colour`),className:`flex flex-wrap gap-2`,children:ae.map(e=>{let t=f===e;return l(L,{type:`button`,role:`radio`,"aria-checked":t,"aria-label":e,variant:`outline`,size:`sm`,disabled:o.isLoading||u.isPending,title:e,onClick:()=>_(e),className:`h-6 w-6 min-w-6 shrink-0 rounded-full border-0 p-0 ${je(e)} ${t?`ring-2 ring-primary ring-offset-2 ring-offset-background`:`opacity-80 hover:opacity-100`}`,children:l(`span`,{className:`sr-only`,children:e})},e)})})}),l(ke,{label:n(`nodes.general.reachableHost`,`Reachable host`),children:l(kr,{nodeId:e,value:p,detectedHosts:g,status:m,errorMessage:h,onCommit:(e,t)=>{c.mutate({agentNodeId:e,reachableHost:t})}})})]})}n();var Nr=[[`serverManagement`,`getServerPackageStatus`]];function Pr({label:e,tone:t}){return l(`span`,{className:`inline-flex items-center rounded px-2 py-0.5 text-[11px] font-medium ${{neutral:`bg-surface-muted text-foreground-subtle`,ok:`bg-success/15 text-success`,info:`bg-info/15 text-info`,warn:`bg-warning/15 text-warning`,error:`bg-danger/15 text-danger`}[t]}`,children:e})}function $({label:e,value:t}){return r(`div`,{className:`flex items-center justify-between gap-4 text-sm`,children:[l(`span`,{className:`text-foreground-subtle`,children:e}),l(`span`,{className:`font-mono text-foreground`,children:t??`—`})]})}function Fr({runningVersion:e,latestVersion:t,seedVersion:n,nodeRuntimeVersion:i,labelRunning:a,labelLatest:o,labelSeed:s,labelRuntime:c}){return l(`div`,{className:`flex flex-wrap gap-x-3 gap-y-1 text-sm`,children:[{key:`running`,label:a,value:e},{key:`latest`,label:o,value:t},{key:`seed`,label:s,value:n},{key:`runtime`,label:c,value:i}].map(({key:e,label:t,value:n})=>r(`span`,{className:`inline-flex items-baseline gap-1`,children:[l(`span`,{className:`text-foreground-subtle`,children:t}),l(`span`,{className:`font-mono text-foreground`,children:n??`—`})]},e))})}var Ir={ok:`border-success/40 bg-success/10 text-success`,warn:`border-warning/40 bg-warning/10 text-warning`,error:`border-danger/40 bg-danger/10 text-danger`};function Lr(e){return e.outcome===`failed`?`error`:(e.outcome,e.accepted?`ok`:`warn`)}function Rr(e,t){let n=t instanceof Error?t.message:String(t);return`${e(`serverManagement.outcomeDropped`,`The connection dropped and the result could not be confirmed. The node may be restarting — re-check the version above.`)} — ${n}`}function zr({node:t}){let{t:n}=G(),i=s(),a=H(),[o,u]=c(!1),[d,f]=c(null),p=t.isHub?void 0:{nodeId:t.id},m=me(p,{refetchInterval:1e4,enabled:t.isOnline,retry:1}),h=m.data??null,g=e(()=>{i.invalidateQueries({queryKey:Nr})},[i]),_=fe({onSettled:g}),v=ye({onSettled:g}),y=he({onSettled:g}),b=e(async()=>{if(h?.latestVersion==null){f({tone:`warn`,text:n(`serverManagement.outcomeNoTarget`,`No target version is known for this node — run "Check for update" first.`)});return}if(await a({title:n(`serverManagement.confirmUpdateTitle`,`Update node root package`),message:n(`serverManagement.confirmUpdateBody`,`Install {{pkg}}@{{version}} on "{{node}}" and restart to apply.`,{pkg:h.packageName,version:h.latestVersion,node:t.name}),confirmLabel:n(`serverManagement.confirmUpdateAction`,`Update & restart`)})){f(null);try{let e=await v.mutateAsync({version:h.latestVersion,...p});f({tone:Lr(e),text:e.message}),e.restarting&&u(!0)}catch(e){f({tone:`warn`,text:Rr(n,e)})}}},[v,a,t.name,p,h,n]),S=e(async()=>{if(await a({title:n(`serverManagement.confirmRestartTitle`,`Restart node`),message:n(`serverManagement.confirmRestartBody`,`Restart "{{node}}"? In-flight requests to this node are dropped.`,{node:t.name}),confirmLabel:n(`serverManagement.confirmRestartAction`,`Restart`),variant:`warning`})){f(null);try{let e=await y.mutateAsync(p);f({tone:Lr(e),text:e.message}),e.restarting&&u(!0)}catch(e){f({tone:`warn`,text:Rr(n,e)})}}},[a,t.name,y,p,n]),w=()=>{switch(h?.bootMode){case`data-root`:return{label:n(`serverManagement.bootDataRoot`,`runtime-updatable`),tone:`ok`};case`workspace`:return{label:n(`serverManagement.bootWorkspace`,`dev workspace`),tone:`info`};default:return{label:n(`serverManagement.bootBaked`,`baked image seed`),tone:`neutral`}}},E=()=>{if(h==null)return null;switch(h.updateState){case`checking`:return{label:n(`serverManagement.stateChecking`,`checking…`),tone:`info`};case`staging`:return{label:n(`serverManagement.stateStaging`,`updating…`),tone:`info`};case`pending-restart`:return{label:n(`serverManagement.statePending`,`restart pending`),tone:`warn`};default:return h.restartRequired===!0?{label:n(`serverManagement.stateRestartRequired`,`restart required`),tone:`warn`}:h.updateAvailable?{label:n(`serverManagement.stateUpdateAvailable`,`update available`),tone:`warn`}:{label:n(`serverManagement.stateUpToDate`,`up to date`),tone:`ok`}}},D=h?.bootMode===`workspace`,O=t.isOnline&&h!=null&&!D&&h.updateAvailable&&h.updateState===`idle`&&!v.isPending,k=t.isOnline&&h!=null&&h.updateState===`idle`&&!y.isPending,A=t.isOnline?E():null;return r(`div`,{className:`space-y-4 py-2`,children:[r(`div`,{className:`flex items-center justify-between gap-3`,children:[r(`div`,{className:`flex items-center gap-2 min-w-0`,children:[l(`span`,{className:`font-mono text-xs text-foreground-subtle truncate`,children:h?.packageName??t.rootPackage?.name??`@camstack/server`}),t.isOnline&&h!=null&&l(Pr,{...w()})]}),A!=null&&l(Pr,{...A})]}),!t.isOnline&&l($,{label:n(`serverManagement.lastReportedVersion`,`Last reported version`),value:t.rootPackage?.version??null}),t.isOnline&&m.isLoading&&r(`div`,{className:`flex items-center gap-2 text-sm text-foreground-subtle`,children:[l(T,{className:`h-4 w-4 animate-spin`}),n(`common.loading`,`Loading…`)]}),t.isOnline&&m.isError&&r(`div`,{className:`space-y-1.5`,children:[l(`p`,{className:`text-sm text-danger`,children:n(`serverManagement.loadError`,`Could not load the node root-package status.`)}),t.rootPackage!=null&&l($,{label:n(`serverManagement.lastReportedVersion`,`Last reported version`),value:t.rootPackage.version})]}),t.isOnline&&h!=null&&r(`div`,{className:`space-y-1.5`,children:[l(Fr,{runningVersion:h.runningVersion,latestVersion:h.latestVersion,seedVersion:h.seedVersion,nodeRuntimeVersion:h.nodeRuntimeVersion,labelRunning:n(`serverManagement.runningVersionShort`,`Running`),labelLatest:n(`serverManagement.latestVersionShort`,`Latest`),labelSeed:n(`serverManagement.imageSeedShort`,`Seed`),labelRuntime:n(`serverManagement.nodeRuntimeVersionShort`,`Node.js`)}),h.pendingVersion!=null&&l($,{label:n(`serverManagement.pendingVersion`,`Staged (applies on restart)`),value:h.pendingVersion}),h.installedVersion!=null&&h.installedVersion!==h.runningVersion&&l($,{label:n(`serverManagement.installedVersion`,`Installed on disk (runs after restart)`),value:h.installedVersion})]}),t.isOnline&&h?.imageContract?.state===`behind-series`&&r(`div`,{className:`rounded-md border border-danger/40 bg-danger/10 px-3 py-2 text-xs leading-relaxed text-danger`,children:[l(`p`,{className:`mb-0.5 font-semibold`,children:n(`serverManagement.imageContractDiverged`,`Container image diverges from the deployment contract`)}),l(`p`,{children:h.imageContract.message})]}),t.isOnline&&D&&l(`p`,{className:`text-xs text-foreground-subtle`,children:n(`serverManagement.workspaceNote`,`Development workspace detected — runtime updates are disabled (the dev loop resolves code from the workspace).`)}),d!=null&&l(`p`,{role:`status`,className:`rounded border px-2 py-1.5 text-xs leading-relaxed ${Ir[d.tone]}`,children:d.text}),o&&r(`div`,{className:`flex items-center gap-2 text-sm text-warning`,children:[l(T,{className:`h-4 w-4 animate-spin`}),n(`serverManagement.nodeRestarting`,`The node is restarting to apply the change…`)]}),t.isOnline&&r(`div`,{className:`flex flex-wrap items-center gap-2 pt-1`,children:[r(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded border border-border px-2.5 py-1.5 text-xs font-medium text-foreground hover:bg-surface-muted disabled:opacity-50`,disabled:_.isPending||h?.updateState===`staging`,onClick:()=>_.mutate(p),children:[_.isPending?l(T,{className:`h-3.5 w-3.5 animate-spin`}):l(I,{className:`h-3.5 w-3.5`}),n(`serverManagement.checkForUpdate`,`Check for update`)]}),O&&r(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded bg-primary px-2.5 py-1.5 text-xs font-medium text-primary-foreground hover:opacity-90 disabled:opacity-50`,onClick:()=>void b(),children:[v.isPending?l(T,{className:`h-3.5 w-3.5 animate-spin`}):l(x,{className:`h-3.5 w-3.5`}),n(`serverManagement.updateTo`,`Update to {{version}}`,{version:h?.latestVersion??``})]}),r(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded border border-border px-2.5 py-1.5 text-xs font-medium text-foreground hover:bg-surface-muted disabled:opacity-50`,disabled:!k,onClick:()=>void S(),children:[y.isPending?l(T,{className:`h-3.5 w-3.5 animate-spin`}):l(C,{className:`h-3.5 w-3.5`}),n(`serverManagement.restart`,`Restart`)]})]}),t.isOnline&&h?.lastCheckedAtMs!=null&&r(`p`,{className:`flex items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[l(te,{className:`h-3 w-3`}),n(`serverManagement.lastChecked`,`Last checked: {{when}}`,{when:new Date(h.lastCheckedAtMs).toLocaleString()})]})]})}n();function Br(e){if(typeof e!=`object`||!e||Array.isArray(e))return null;let t=Reflect.get(e,`reachableHost`);return typeof t==`string`&&t.length>0?t:null}function Vr({node:t}){let{t:n}=G(),i=N(),u=s(),d=H(),[m,h]=c(!1),[g,_]=c(`info`),[v,b]=c(!1),[x,S]=c(null),C=t.processes??[],w=t.addons.map(e=>e.id),T=Ee(void 0),E=a(()=>{let e=T.data?.find(e=>e.nodeId===t.id);return Br(e?.settings)},[T.data,t.id]),[D,O]=c(!1),[k,A]=c(null),[j,M]=c(null),P=e(async()=>{if(D||t.isHub)return;let e=Pt(t.localIps??[],E);if(e===null){A(`No LAN IPv4 on this node — open its :4444 URL by hand.`),M(null);return}let n=Lt();O(!0),A(null),M(null);try{let r=kt(await i.trpcClient.addons.custom.mutate({addonId:`system-config`,action:`mintAgentUiUnlockTicket`,input:{nodeId:t.id,dashboardBaseUrl:Ft(e)}})),a=r===null?null:r.dashboardUrl??It(e,r.ticket);if(a===null){n?.close(),A(`Hub did not return an unlock ticket.`);return}Rt(n,a)||(M(a),A(`Browser blocked the new tab — click the link below (or allow popups for this site).`))}catch(e){n?.close(),A(e instanceof Error?e.message:String(e))}finally{O(!1)}},[t.id,t.isHub,t.localIps,D,E,i.trpcClient]),F=async()=>{if(!v){b(!0),S(null);try{await i.trpcClient.pipelineOrchestrator.removeAgentSettings.mutate({agentNodeId:t.id}).catch(()=>void 0);let e=await i.trpcClient.clusterNodes.forgetNode.mutate({nodeId:t.id});S({tone:e.stillListed?`warn`:`ok`,text:e.message}),e.stillListed||u.invalidateQueries({queryKey:[[`nodes`,`topology`]]})}catch(e){S({tone:`warn`,text:`Forget failed: ${e instanceof Error?e.message:String(e)}`})}finally{b(!1)}}},ee=async()=>{if(!m&&await d({title:n(`cluster.nodeCard.unpair`,`Unpair {{name}}`,{name:t.name}),message:n(`cluster.nodeCard.unpairItDisconnectsAndMust`,`Unpair {{name}}? It disconnects and must be paired again.`,{name:t.name}),confirmLabel:n(`cluster.nodeCard.unpair2`,`Unpair`),variant:`danger`})){h(!0),S(null);try{let e=await i.trpcClient.agentPairing.unpairAgent.mutate({nodeId:t.id});S({tone:e.agentNotified?`ok`:`warn`,text:`${e.nodeId}: ${e.next}${e.agentNotified?``:` The agent could not be told; forget the hub on its own page.`}`}),u.invalidateQueries({queryKey:[[`nodes`,`topology`]]})}catch(e){S({tone:`warn`,text:`Unpair failed: ${e instanceof Error?e.message:String(e)}`})}finally{h(!1)}}},I=t.isHub?null:r(L,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>void ee(),disabled:m,title:n(`cluster.nodeCard.unpairThisNodeRevokesIts`,`Unpair this node — revokes its certificates; it must be paired again to rejoin`),children:[l(re,{className:`h-3 w-3`,"aria-hidden":!0}),m?n(`cluster.nodeCard.unpairing`,`Unpairing…`):n(`cluster.nodeCard.unpair2`,`Unpair`)]});return t.isOnline?r(`div`,{className:`border border-border rounded-xl`,children:[r(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-3 gap-y-2 px-4 py-3 bg-muted/30 border-b border-border rounded-t-xl`,children:[r(`div`,{className:`flex min-w-0 flex-1 basis-full items-center gap-x-2 gap-y-1 sm:basis-auto sm:flex-initial`,children:[l(`div`,{className:`w-2.5 h-2.5 rounded-full bg-success shrink-0`}),l(zt,{node:t}),r(`span`,{className:`text-xs text-muted-foreground min-w-0 truncate`,children:[t.cpuModel??t.platform,` ·`,` `,t.memoryMB>0?n(`cluster.nodeCard.gb`,`{{value1}}GB`,{value1:Math.round(t.memoryMB/1024)}):``,` `,`· `,t.arch]})]}),t.engines.map(e=>l(`span`,{className:`text-[9px] px-1.5 py-0.5 rounded-full bg-primary/10 text-primary font-medium shrink-0`,children:e},e)),r(`div`,{className:`flex min-w-0 flex-wrap items-center justify-end gap-x-3 gap-y-1 text-xs text-muted-foreground w-full sm:ml-auto sm:w-auto`,children:[!t.isHub&&r(`button`,{type:`button`,onClick:()=>void P(),disabled:D,title:n(`cluster.nodeCard.openThisAgentSStatus`,`Open this agent's status dashboard (unlocks with a short-lived hub ticket)`),className:`inline-flex items-center gap-1 rounded border border-border px-2 py-1 text-xs text-foreground hover:bg-surface-hover disabled:opacity-50`,children:[l(y,{className:`h-3 w-3`}),D?n(`cluster.nodeCard.opening`,`Opening…`):n(`cluster.nodeCard.openDashboard`,`Open dashboard`)]}),I,r(`span`,{className:`flex items-center gap-1`,children:[l(p,{className:`h-3 w-3`}),` `,t.cpuPercent,`%`]}),r(`span`,{className:`flex items-center gap-1`,children:[l(ne,{className:`h-3 w-3`}),` `,t.memoryPercent,`%`]})]})]}),x!=null&&l(`p`,{role:`status`,className:`px-4 pt-2 text-xs ${x.tone===`ok`?`text-success`:`text-warning`}`,children:x.text}),(k!==null||j!==null)&&r(`p`,{role:`status`,className:`px-4 pt-2 text-xs text-warning`,children:[k,j!==null&&r(o,{children:[` `,l(`a`,{href:j,target:`_blank`,rel:`noreferrer`,className:`underline text-foreground`,children:n(`cluster.nodeCard.openDashboard`,`Open dashboard`)})]})]}),l(`div`,{className:`sticky top-0 z-20 flex border-b border-border px-4 bg-background overflow-x-auto`,children:[`info`,`forks`,`processes`,`load`,`settings`,`capabilities`].map(e=>l(`button`,{onClick:()=>_(e),className:`shrink-0 whitespace-nowrap px-3 py-2 text-xs font-medium border-b-2 transition-colors ${g===e?`border-primary text-primary`:`border-transparent text-muted-foreground hover:text-foreground`}`,children:e===`info`?n(`cluster.nodeCard.general`,`General`):e===`forks`?n(`cluster.nodeCard.forks`,`Forks ({{length}})`,{length:C.length}):e===`processes`?n(`cluster.nodeCard.processes`,`Processes`):e===`load`?n(`cluster.nodeCard.load`,`Load`):e===`settings`?n(`cluster.nodeCard.settings`,`Settings`):n(`cluster.nodeCard.capabilities`,`Capabilities`)},e))}),r(`div`,{className:`px-4 py-2`,children:[g===`info`&&r(`div`,{className:`space-y-3`,children:[l(Or,{nodeId:t.id,name:t.name,hostname:t.hostname,platform:t.platform,arch:t.arch,cpuModel:t.cpuModel,cpuCores:t.cpuCores,memoryMB:t.memoryMB,engines:t.engines,isHub:t.isHub,uptime:t.uptime,localIps:t.localIps,rootPackage:t.rootPackage}),l(Mr,{nodeId:t.id,detectedHosts:t.localIps??[]}),l(`div`,{className:`border-t border-border pt-1`,children:l(zr,{node:{id:t.id,name:t.name,isHub:t.isHub,isOnline:t.isOnline,rootPackage:t.rootPackage??null}})})]}),g===`forks`&&l(Wt,{nodeId:t.id,processes:C}),g===`processes`&&l(Jt,{nodeId:t.id}),g===`load`&&l(xr,{nodeId:t.id,isHub:t.isHub}),g===`settings`&&l(Tr,{nodeId:t.id,addonIds:w}),g===`capabilities`&&l(Er,{nodeId:t.id,addons:t.addons})]})]}):r(`div`,{className:`border border-border rounded-xl overflow-hidden opacity-60`,children:[r(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-3 gap-y-2 px-4 py-3 bg-muted/30`,children:[l(`div`,{className:`w-2.5 h-2.5 rounded-full bg-destructive shrink-0`}),l(zt,{node:t}),r(`span`,{className:`text-xs text-muted-foreground min-w-0 truncate`,children:[t.cpuModel??t.platform,` ·`,` `,t.memoryMB>0?n(`cluster.nodeCard.gb`,`{{value1}}GB`,{value1:Math.round(t.memoryMB/1024)}):``,` `,`· `,t.arch]}),t.engines.map(e=>l(`span`,{className:`text-[9px] px-1.5 py-0.5 rounded-full bg-primary/10 text-primary font-medium`,children:e},e)),t.rootPackage&&r(`span`,{className:`text-[10px] font-mono px-1.5 py-0.5 rounded bg-muted text-muted-foreground`,children:[t.rootPackage.name,`@`,t.rootPackage.version]}),l(`span`,{className:`ml-auto text-xs px-2 py-0.5 rounded-full bg-destructive/10 text-destructive`,children:`offline`})]}),r(`div`,{className:`flex items-center justify-between gap-3 px-4 py-3`,children:[r(`span`,{className:`text-xs text-muted-foreground`,children:[t.lastSeen?`Last seen ${new Date(t.lastSeen).toLocaleString()} — `:``,t.addons.length,` addon`,t.addons.length===1?``:`s`,` assigned; will resume when node reconnects`]}),r(`div`,{className:`flex shrink-0 items-center gap-2`,children:[I,r(`button`,{type:`button`,onClick:()=>void F(),disabled:v,title:n(`cluster.nodeCard.forgetThisNodeRemovesIts`,`Forget this node — removes its saved history and pipeline assignments`),className:`flex items-center gap-1 text-xs px-2 py-1 rounded-md border border-border text-muted-foreground hover:text-destructive hover:border-destructive/50 disabled:opacity-50 transition-colors`,children:[l(f,{className:`h-3 w-3`}),v?n(`cluster.nodeCard.forgetting`,`Forgetting…`):n(`cluster.nodeCard.forgetNode`,`Forget node`)]})]})]}),x!=null&&l(`p`,{role:`status`,className:`px-4 pb-3 text-xs leading-relaxed ${x.tone===`ok`?`text-success`:`text-warning`}`,children:x.text})]})}var Hr=3,Ur=7e3;function Wr(e){return[...e].sort((e,t)=>e.isHub===t.isHub?0:e.isHub?1:-1)}function Gr(e){return e.isHub?{}:{nodeId:e.id}}function Kr(e){return e.updateState===`staging`||e.updateState===`pending-restart`||e.pendingVersion!==null?!0:!e.updateAvailable}async function qr(e,t){let n=Gr(e),r=`no answer`;for(let i=1;i<=Hr;i+=1)try{let r=await t.readStatus(n);return Kr(r)?{nodeId:e.id,nodeName:e.name,outcome:`applied`,detail:`Connection dropped, and the node confirms the update landed (state ${r.updateState}, running ${r.runningVersion??`unknown`}).`}:{nodeId:e.id,nodeName:e.name,outcome:`failed`,detail:`Connection dropped and the node came back unchanged (still ${r.runningVersion??`unknown`}, update still available). Nothing was staged.`}}catch(e){r=e instanceof Error?e.message:String(e),i<Hr&&await t.wait(Ur)}return{nodeId:e.id,nodeName:e.name,outcome:`unconfirmed`,detail:`Connection dropped and the node could not be confirmed after ${Hr} attempts (${r}). It may be restarting — re-check this node.`}}function Jr(e){return e.accepted?`applied`:e.outcome===`failed`?`failed`:`refused`}async function Yr(e,t){let n=[];for(let r of Wr(e))try{let e=await t.apply(Gr(r));n.push({nodeId:r.id,nodeName:r.name,outcome:Jr(e),detail:e.message})}catch{n.push(await qr(r,t))}return n}n();function Xr(){let{nodes:e,isLoading:t}=He(),n=a(()=>e??[],[e]);return{nodes:n,isLoading:t&&n.length===0}}var Zr={applied:`border-success/40 bg-success/10 text-success`,refused:`border-warning/40 bg-warning/10 text-warning`,failed:`border-danger/40 bg-danger/10 text-danger`,unconfirmed:`border-warning/40 bg-warning/10 text-warning`};function Qr(){let{t}=G(),n=H(),{nodes:i,isLoading:s}=Xr(),[d,f]=Ke(),{selection:p,selectNode:m}=tt(i),h=p.node,g=a(()=>i.filter(e=>e.isOnline),[i]),_=g.length,y=i.filter(e=>!e.isOnline).length,b=ye(),S=N(),[C,w]=c(!1),[E,D]=c([]),O=d.get(`unlockNode`),k=d.get(`returnTo`),[A,j]=c(null);u(()=>{if(O===null||k===null)return;let e=!1;return(async()=>{try{let t=await S.trpcClient.addons.custom.mutate({addonId:`system-config`,action:`mintAgentUiUnlockTicket`,input:{nodeId:O,dashboardBaseUrl:k}});if(e)return;let n=kt(t),r=n===null?null:n.dashboardUrl??(()=>{let e=new URL(k);return e.searchParams.set(`ticket`,n.ticket),e.toString()})();if(r===null){j(`Could not mint an unlock ticket.`);return}let i=new URLSearchParams(d);i.delete(`unlockNode`),i.delete(`returnTo`),f(i,{replace:!0}),window.location.assign(r)}catch(t){e||j(t instanceof Error?t.message:String(t))}})(),()=>{e=!0}},[O,k,d,f,S.trpcClient]);let M=e(async()=>{let e=g.map(e=>({id:e.id,name:e.name,isHub:e.isHub}));if(await n({title:t(`serverManagement.confirmUpdateAllTitle`,`Update all nodes`),message:t(`serverManagement.confirmUpdateAllBody`,`Update and restart every online node, agents first, hub last. Up-to-date nodes are skipped; this page reconnects when the hub comes back.`),confirmLabel:t(`serverManagement.confirmUpdateAllAction`,`Update all & restart`),variant:`warning`})){w(!0),D([]);try{D(await Yr(e,{apply:e=>b.mutateAsync(e),readStatus:e=>S.trpcClient.serverManagement.getServerPackageStatus.query(e),wait:e=>new Promise(t=>setTimeout(t,e))}))}finally{w(!1)}}},[b,n,g,S,t]);return r(Je,{icon:v,title:t(`nav.nodes`,`Nodes`),subtitle:t(`cluster.subtitle`,`One node at a time — topology and packages. Agents join by pairing (certificate, no shared secret).`),actions:r(o,{children:[_>0&&r(`span`,{className:`rounded-full bg-success/10 px-2 py-0.5 text-xs text-success`,children:[_,` online`]}),y>0&&r(`span`,{className:`rounded-full bg-destructive/10 px-2 py-0.5 text-xs text-destructive`,children:[y,` offline`]}),_>1&&r(L,{type:`button`,size:`sm`,disabled:C,title:t(`serverManagement.updateAllHint`,`Sequenced agents-first, hub-last — up-to-date nodes are skipped.`),onClick:()=>void M(),children:[C?l(T,{className:`h-3.5 w-3.5 animate-spin`}):l(x,{className:`h-3.5 w-3.5`}),t(`serverManagement.updateAll`,`Update all nodes`)]})]}),children:[E.length>0&&l(`ul`,{"aria-label":`update-all-report`,className:`flex flex-col gap-1 text-xs`,children:E.map(e=>r(`li`,{"data-outcome":e.outcome,className:`rounded border px-2 py-1 ${Zr[e.outcome]}`,children:[l(`span`,{className:`font-medium`,children:e.nodeName}),l(`span`,{className:`mx-1 uppercase tracking-wide`,children:e.outcome}),l(`span`,{className:`opacity-80`,children:e.detail})]},e.nodeId))}),A!==null&&r(`p`,{role:`alert`,className:`rounded border border-warning/40 bg-warning/10 px-3 py-2 text-xs text-warning`,children:[t(`system.cluster.unlockFromAgentFailed`,`Unlock from agent failed:`),` `,A]}),l(Dt,{onOpenNode:m}),s?l(`div`,{className:`flex items-center justify-center py-12 text-muted-foreground`,children:t(`system.cluster.loadingClusterTopology`,`Loading cluster topology...`)}):h===null?l(`div`,{className:`rounded-md border border-dashed border-border px-3 py-6 text-center text-xs text-foreground-subtle`,children:t(`cluster.noNodes`,`No nodes in this cluster yet.`)}):r(`div`,{className:`flex flex-col gap-3`,children:[l(et,{staleNodeId:p.staleNodeId,shownNodeName:h.name}),l(we,{selectedNodeId:h.id,onSelect:m,allowOffline:!0,alwaysShow:!0}),l(Vr,{node:h})]})]})}export{Qr as ClusterPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-Cyuzqnbw.js";import{I as t,K as n,Q as r,S as i,W as a,b as o,i as s,o as c,p as l,q as u,x as d,z as f}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{A as p,D as m,It as h,Jr as g,Mn as _,N as v,Nr as y,Nt as b,O as x,Qi as S,T as C,Tr as w,V as T,Xt as E,Yn as D,_i as O,_t as k,ar as A,b as j,bn as M,dt as N,j as P,k as F,lr as I,nr as L,ot as ee,pn as te,rr as ne,sn as re,un as R,ut as z,v as ie,y as ae,yi as oe,yn as se,z as B}from"./player-overlays-Cda8wso6.js";import{c as ce,l as le,t as ue}from"./video-tLHyNE3q.js";import{a as de,i as fe,n as pe,r as me,t as he}from"./usb-DmUPajSy.js";import{t as ge}from"./crop-Dev61hIh.js";import{t as _e}from"./layers-C1wzFfr1.js";import{An as ve,Dn as ye,En as be,Gr as xe,Kr as Se,Mn as Ce,On as we,Ti as Te,Tn as Ee,c as De,jn as Oe,kn as ke,l as Ae,m as je,vi as Me,wn as Ne}from"./client-CMlUvfoK.js";import{n as Pe}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_trpc_mf_1_react_mf_2_query__loadShare__.js-DX7sYWrs.js";import{An as Fe,As as Ie,Bn as V,C as Le,Cs as Re,Dn as ze,E as Be,En as Ve,Es as He,F as Ue,Fs as We,Gs as Ge,H as Ke,Hs as qe,Ht as Je,J as Ye,Js as Xe,Jt as Ze,Kl as H,Ks as Qe,Ln as $e,Ls as et,Mt as tt,O as nt,On as rt,Ps as it,Ql as at,Rn as ot,Rs as st,S as ct,Ss as lt,T as ut,Tn as dt,Ts as ft,Tt as pt,Us as mt,Ut as ht,Vs as gt,Vt as U,W as _t,Y as vt,Ys as yt,Yt as bt,Zl as xt,Zn as St,_n as Ct,_r as wt,_u as Tt,ac as Et,an as Dt,ar as W,au as Ot,bs as kt,cc as At,cn as jt,dc as Mt,dn as Nt,fu as G,gu as Pt,hn as Ft,hu as It,ic as Lt,in as Rt,iu as zt,jn as Bt,kn as Vt,lc as Ht,ln as Ut,ma as Wt,mn as Gt,mr as Kt,mu as qt,oc as Jt,pn as Yt,pr as Xt,pu as Zt,qs as Qt,qt as $t,r as en,sc as tn,sn as nn,un as rn,vn as an,vs as on,vt as sn,w as cn,wn as ln,ws as un,xs as dn,ys as fn,zs as pn}from"./src-eoSUZcV-.js";import{t as K}from"./useTranslation-Bc5yH9V9.js";import{H as mn,J as hn,Q as gn}from"./index-BgQGn3LX.js";import"./useEventInvalidation-DlnG_8P7.js";import{t as _n}from"./NodeAddonsSettingsPanel-mmtEgDbu.js";import{a as vn,c as yn,d as bn,g as xn,h as Sn,i as Cn,l as wn,n as Tn,o as En,p as Dn,r as On,s as kn,t as An}from"./board-model-Bmts6hrg.js";var jn=`step`,Mn=[jn,`acc`];function Nn(e,t){return`${e}/${t}`}function Pn(e,t,n){let r=n.step!==null&&e.includes(n.step),i=n.acc!==null&&t.includes(n.acc);return{stepId:r?n.step:null,acceleratorId:i?n.acc:null,staleStepId:n.step!==null&&n.step!==``&&!r&&e.length>0?n.step:null}}function Fn(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 In(e){return e}function Ln(e,t){for(let[n,r]of Object.entries(e??{}))if(n===t)return r}function Rn(e,t){return typeof e==`boolean`?e:In(t)}function zn(e,t){return{pipeline:Rn(Ln(e,`detect`),t),audio:Rn(Ln(e,`audio`),t),ingest:Rn(Ln(e,`ingest`),t)}}function Bn(e,t,n){let r=e?.find(e=>e.nodeId===t);return zn(r?.settings,n)}function Vn({selectedNodeId:e,onSelect:t,refreshToken:n}){let{t:r}=K(),{nodes:a}=Zt(),{data:s}=et(void 0),{data:c}=gt(void 0),l=new Map;for(let e of s??[])l.set(e.agentNodeId,(l.get(e.agentNodeId)??0)+1);let u=a??[],f=u.filter(e=>e.isOnline).length,p=u.filter(e=>!e.isOnline).length;return i(`div`,{className:`flex flex-col h-full`,children:[i(`button`,{type:`button`,onClick:()=>t(ko),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(ce,{className:`h-4 w-4 flex-shrink-0`}),i(`div`,{className:`min-w-0 flex-1`,children:[d(`div`,{className:`text-xs font-semibold truncate`,children:r(`pipeline.nodeList.cluster`,`Cluster`)}),d(`div`,{className:`text-[10px] text-foreground-subtle`,children:r(`pipeline.nodeList.assignmentsLoadBalancingRoles`,`Assignments, load balancing, roles`)})]})]}),d(`div`,{className:`flex-1 overflow-y-auto`,children:u.map(n=>{let a=e===n.id,s=l.get(n.id)??0,u=n.isHub?R:g,f=Bn(c,n.id,n.isHub),p=n.isOnline?null:sn(Fn(n.lastSeen));return i(`button`,{type:`button`,onClick:()=>t(n.id),className:`flex items-center gap-3 w-full px-4 py-3 border-b border-border text-left transition-colors ${a?`bg-primary/10 text-primary`:`text-foreground hover:bg-surface-hover`}${n.isOnline?``:` opacity-60`}`,children:[d(u,{className:`h-4 w-4 flex-shrink-0`}),i(`div`,{className:`min-w-0 flex-1`,children:[i(`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:`hub`}),!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`})]}),i(`div`,{className:`text-[10px] text-foreground-subtle flex items-center gap-2 mt-0.5`,children:[i(`span`,{children:[n.cpuCores,` cores`]}),d(`span`,{children:`•`}),i(`span`,{children:[Math.round(n.memoryMB/1024),` GB`]}),s>0&&i(o,{children:[d(`span`,{children:`•`}),i(`span`,{className:`inline-flex items-center gap-0.5 text-foreground`,children:[d(ue,{className:`h-2.5 w-2.5`}),s]})]}),!n.isOnline&&i(o,{children:[d(`span`,{children:`•`}),i(`span`,{className:`text-danger`,children:[`offline`,p===null?``:` · ${p}`]})]})]}),i(`div`,{className:`mt-0.5 flex items-center gap-1`,children:[d(W,{variant:f.pipeline?`success`:`danger`,className:`px-1 py-0 text-[9px] leading-3`,title:f.pipeline?r(`pipeline.nodeList.pipelineEnabled`,`Pipeline: enabled`):r(`pipeline.nodeList.pipelineNotEnabledAgentCapability`,`Pipeline: not enabled (agent capability)`),children:r(`pipeline.nodeList.pipe`,`Pipe`)}),d(W,{variant:f.audio?`success`:`danger`,className:`px-1 py-0 text-[9px] leading-3`,title:f.audio?r(`pipeline.nodeList.audioEnabled`,`Audio: enabled`):r(`pipeline.nodeList.audioNotEnabledAgentCapability`,`Audio: not enabled (agent capability)`),children:r(`pipeline.nodeList.aud`,`Aud`)})]})]})]},n.id)})}),i(`div`,{className:`px-4 py-2 border-t border-border text-[10px] text-foreground-subtle flex items-center justify-between`,children:[i(`span`,{children:[f,` online`]}),p>0&&i(`span`,{className:`text-danger`,children:[p,` offline`]})]})]})}function Hn({nodeId:e,refreshToken:t}){let{t:n}=K(),{nodes:r}=Zt(),a=r?.find(t=>t.id===e),s=qt(`pipeline.runner-load-snapshot`,t=>t.nodeId===e)?.load??null;return a?i(`div`,{className:`px-6 py-4 border-b border-border`,children:[i(`div`,{className:`flex items-center gap-2 mb-1`,children:[d(`h2`,{className:`text-base font-semibold text-foreground`,children:a.name}),a.isOnline?d(`span`,{className:`text-[10px] px-2 py-0.5 rounded-full bg-success/10 text-success`,children:`online`}):d(`span`,{className:`text-[10px] px-2 py-0.5 rounded-full bg-danger/10 text-danger`,children:`offline`}),a.isHub&&d(`span`,{className:`text-[9px] uppercase tracking-wider text-foreground-subtle border border-border rounded px-1 py-0.5`,children:`hub`})]}),i(`div`,{className:`text-[11px] text-foreground-subtle flex items-center gap-2 flex-wrap`,children:[d(`span`,{children:a.cpuModel??`CPU`}),d(`span`,{children:`•`}),i(`span`,{children:[a.cpuCores,` cores`]}),d(`span`,{children:`•`}),i(`span`,{children:[Math.round(a.memoryMB/1024),` GB`]}),s&&i(o,{children:[d(`span`,{children:`•`}),i(`span`,{children:[s.attachedCameras,` cameras (`,s.activeCameras,` active)`]}),d(`span`,{children:`•`}),i(`span`,{children:[s.avgInferenceTimeMs.toFixed(0),`ms avg inference`]}),d(`span`,{children:`•`}),i(`span`,{children:[`queue `,s.queueDepthTotal]}),s.hardware.hasGpu&&i(o,{children:[d(`span`,{children:`•`}),d(`span`,{className:`text-success`,children:`GPU`})]})]})]})]}):d(`div`,{className:`px-6 py-4 border-b border-border`,children:i(`div`,{className:`text-xs text-foreground-subtle`,children:[n(`pipeline.nodeDetailHeader.nodeNotFound`,`Node not found:`),` `,e]})})}var Un=[`assignments`,`tree`,`engines`,`logs`];r();function Wn({refreshToken:e,nodeId:t}){let{t:n}=K(),[r,o]=u(new Map),{nodes:s}=G();Pt(`pipeline.camera-metrics-snapshot`,e=>{let t=e.data;typeof t?.deviceId==`number`&&o(e=>{let n=new Map(e);return n.set(t.deviceId,t),n})});let{data:c}=He(void 0),l=a(()=>{let e=new Map;for(let t of c??[])e.set(t.nodeId,t.deviceCount);return e},[c]),f=a(()=>{let e=new Map,t=Date.now()-3e4;for(let n of r.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},[r]),p=a(()=>{let e=new Map;for(let t of s)e.set(t.id,t.shortName);return e},[s]),m=a(()=>{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:s.length,onlineAgents:s.filter(e=>e.isOnline).length,attachedCameras:e,activeCameras:t,avgInferenceTimeMs:a,queueDepth:i,totalFps:n}},[f,s]);if(t){let e=f.get(t);return i(`div`,{className:`@container/liveload`,children:[d(`h3`,{className:`text-sm font-semibold text-foreground mb-2`,children:n(`pipeline.liveLoadPanel.liveLoad`,`Live load`)}),i(`div`,{className:`grid grid-cols-2 @md/liveload:grid-cols-3 @3xl/liveload:grid-cols-5 gap-2 mb-3`,children:[d(q,{label:`FPS`,value:e?e.totalFps.toFixed(1):`—`}),d(q,{label:n(`pipeline.liveLoadPanel.activeAttached`,`Active / Attached`),value:e?`${e.activeCameras}/${e.attachedCameras}`:`—`}),d(q,{label:n(`pipeline.liveLoadPanel.avgInferMs`,`Avg infer ms`),value:e&&e.attachedCameras>0?(e.totalInferenceWeighted/e.attachedCameras).toFixed(0):`—`}),d(q,{label:n(`pipeline.liveLoadPanel.queue`,`Queue`),value:e?String(e.queueDepth):`—`}),d(q,{label:n(`pipeline.liveLoadPanel.audio`,`Audio`),value:String(l.get(t)??`—`)})]})]})}let h=[...f.entries()].toSorted(([e],[t])=>e===`hub`?-1:t===`hub`?1:e.localeCompare(t));return i(`div`,{className:`@container/liveload`,children:[d(`h3`,{className:`text-sm font-semibold text-foreground mb-2`,children:n(`pipeline.liveLoadPanel.liveLoad`,`Live load`)}),i(`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(q,{label:n(`pipeline.liveLoadPanel.totalAgents`,`Total agents`),value:`${m.onlineAgents}/${m.totalAgents}`}),d(q,{label:n(`pipeline.liveLoadPanel.activeAttached`,`Active / Attached`),value:`${m.activeCameras}/${m.attachedCameras}`}),d(q,{label:n(`pipeline.liveLoadPanel.totalFps`,`Total FPS`),value:m.totalFps.toFixed(1)}),d(q,{label:n(`pipeline.liveLoadPanel.avgInferenceMs`,`Avg inference ms`),value:m.avgInferenceTimeMs.toFixed(0)}),d(q,{label:n(`pipeline.liveLoadPanel.queueDepth`,`Queue depth`),value:String(m.queueDepth)})]}),d(`div`,{className:`rounded-lg border border-border overflow-x-auto`,children:i(`table`,{className:`w-full text-xs min-w-[480px]`,children:[d(`thead`,{className:`bg-surface`,children:i(`tr`,{className:`text-foreground-subtle text-[10px] uppercase tracking-wider`,children:[d(`th`,{className:`text-left px-3 py-2`,children:n(`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:n(`pipeline.liveLoadPanel.cameras`,`Cameras`)}),d(`th`,{className:`text-right px-3 py-2`,children:n(`pipeline.liveLoadPanel.inferenceMs`,`Inference ms`)}),d(`th`,{className:`text-right px-3 py-2`,children:n(`pipeline.liveLoadPanel.queue`,`Queue`)}),d(`th`,{className:`text-right px-3 py-2`,children:n(`pipeline.liveLoadPanel.audio`,`Audio`)})]})}),i(`tbody`,{children:[h.map(([e,t])=>i(`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:l.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:n(`pipeline.liveLoadPanel.noCameraMetricsReceivedYet`,`No camera metrics received yet`)})})]})]})})]})}function q({label:e,value:t}){return i(`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 Gn={active:!1,pinned:!1,nodeId:null,reason:``};function Kn(e,t){return e.deviceName.localeCompare(t.deviceName)||e.deviceId-t.deviceId}function qn(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??``}:Gn,o=n?{active:!0,pinned:n.pinned,nodeId:n.nodeId,reason:``}:Gn;return{deviceId:e.id,deviceName:e.name,disabled:e.disabled===!0,pipeline:a,detection:a,decoder:Gn,audio:o}}).toSorted(Kn)}function Jn(e,t,n){return{active:e!==null,pinned:t,nodeId:e,reason:n??``}}function Yn(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:Jn(t.detectionNodeId,t.pinned.detection,t.reasons.detection),decoder:Jn(t.decoderNodeId,t.pinned.decoder,t.reasons.decoder),audio:Jn(t.audioNodeId,t.pinned.audio,t.reasons.audio)}})}function Xn(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(Kn)}function Zn(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 Qn(e){let t=new Map(e.map(e=>[e.id,e.name]));return e=>t.get(e)??`Camera ${e}`}function $n(e,t,n){return[{value:`auto`,label:`Auto`},...[...new Set([...e.nodeId===null?[]:[e.nodeId],...t.map(e=>e.id)])].map(e=>({value:e,label:`Pin → ${n(e)}`}))]}function er({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($t,{roleId:e,roleLabel:t,nodeName:r(o),colorId:bt(i,o),emphasized:s,pinned:n.pinned})}function tr({detection:e,decoder:t,audio:n,nameOf:r,colorByNodeId:a,emphasizeOnNodeId:o}){let s=(e,t,n)=>d(er,{roleId:e,roleLabel:t,state:n,nameOf:r,colorByNodeId:a,emphasizeOnNodeId:o},e);return i(`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 nr({snap:e}){let{t}=K();if(e===void 0)return d(`div`,{className:`flex h-8 items-center text-[11px] text-foreground-subtle`,title:t(`assignments.assignmentStatusCell.noMetricsInTheLast`,`No metrics in the last 10 s — the camera has no session running`),children:t(`assignments.assignmentStatusCell.noLiveData`,`no live data`)});let{phase:n,actualFps:r,avgInferenceTimeMs:a,queueDepth:o,configuredFps:s,droppedFrames:c}=e.metrics,l=tt(n);return i(`div`,{className:`flex h-8 min-w-0 flex-col justify-center font-mono text-[10px] leading-tight tabular-nums`,children:[i(`span`,{className:`inline-flex min-w-0 items-center gap-1 ${l.textColor}`,children:[d(Ue,{phase:n,className:`h-2.5 w-2.5 shrink-0`}),d(`span`,{className:`truncate font-semibold uppercase tracking-wider`,children:l.label}),d(`span`,{className:`text-foreground`,children:r.toFixed(1)}),i(`span`,{className:`text-foreground-subtle`,children:[`/`,s.toFixed(0),` fps`]})]}),i(`span`,{className:`truncate text-foreground-subtle`,children:[d(`span`,{className:`text-foreground`,children:a.toFixed(0)}),` ms`,o>0&&i(`span`,{className:`ml-1 text-warning`,children:[`q`,o]}),i(`span`,{className:c>0?`ml-1 text-warning`:`ml-1`,children:[`drops `,c]})]})]})}r();var rr=1e4,ir=5e3;function ar(e){let[t,n]=u(new Map);return Pt(`pipeline.camera-metrics-snapshot`,t=>{let r=t.data;typeof r.deviceId==`number`&&(e!==void 0&&r.nodeId!==e||n(e=>new Map(e).set(r.deviceId,r)))}),f(()=>{if(t.size===0)return;let e=setInterval(()=>{n(e=>{let t=Date.now()-rr,n=[...e].filter(([,e])=>e.timestamp>=t);return n.length===e.size?e:new Map(n)})},ir);return()=>clearInterval(e)},[t.size]),t}var or=3e5;function sr({state:e,onlineNodes:t,nameOf:n,pending:r,onChange:i}){let{t:a}=K();return d(H,{"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:[...$n(e,t,n)],onChange:e=>i(e.target.value)})}function cr({deviceId:e,nodeId:t}){let{t:n}=K(),r=c(),{data:i}=st({deviceId:e},{refetchOnMount:`always`}),{data:a}=We({nodeId:t},{staleTime:or}),o=Et({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:`${p?`${Ct(p)} (${u})`:u} (not enabled)`}]:[],...l.map(e=>({value:e.key,label:`${Ct(e)} · ${e.format}`}))];return d(H,{"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})})}r();function lr(e){let t=n(null);return e.nodeId!==null&&(t.current=e),t.current}function ur({deviceId:e,state:t,...n}){let{t:r}=K(),a=lr(t);return i(`div`,{className:`grid w-80 grid-cols-2 gap-1.5`,children:[d(sr,{state:t,...n}),a?.nodeId==null?d(H,{"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(cr,{deviceId:e,nodeId:a.nodeId})]})}function dr({state:e,nameOf:t}){let{t:n}=K(),r=lr(e);if(r?.nodeId==null)return d(`span`,{className:`text-[11px] text-foreground-subtle`,children:n(`assignments.clusterRowCells.noSessionYet`,`— no session yet`)});let a=e.active&&e.nodeId!==null,o=r.pinned?`pinned`:`auto · ${r.reason||`capacity`}`;return i(`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:[i(`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 ${a?`bg-success`:`bg-foreground-subtle/40`}`}),d(`span`,{"data-testid":`resolved-placement-node`,className:`truncate font-medium ${a?`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:a?o:n(`assignments.clusterRowCells.idleLastSession`,`{{how}} · idle, last session`,{how:o})})]})}function fr({deviceId:e,deviceName:t}){let{t:n}=K(),[r,a]=u(!1);return i(o,{children:[d(at,{icon:M,variant:`ghost`,size:`sm`,"aria-label":n(`assignments.clusterRowCells.streamBrokersOf`,`Stream brokers of {{deviceName}}`,{deviceName:t}),title:n(`assignments.clusterRowCells.streamBrokersClients`,`Stream brokers & clients`),onClick:()=>a(!0)}),d(dt,{open:r,onOpenChange:a,children:i(ze,{width:`lg`,scroll:`body`,placement:`sheet-on-mobile`,children:[d(Fe,{children:i(Bt,{children:[t,` — stream brokers & clients`]})}),d(Ve,{children:r&&d(ln,{widgetId:`stream-broker/stream-broker-panel`,host:`device-tab`,deviceId:e,instanceId:`pipeline-row/${e}`,config:{variant:`compact`}})})]})})]})}function pr(e){return e.hasFreshMetrics?`active`:e.hasPipelineAssignment?`recently-active`:`inactive`}function mr(e,t){return t.size===0?!0:t.has(e)}var hr=[{value:`active`,label:`Active`},{value:`recently-active`,label:`Recently active`},{value:`inactive`,label:`Inactive`}];r();var gr=[`pipeline.camera-assigned`,`pipeline.camera-unassigned`,`pipeline.camera-updated`,`agent.online`,`agent.offline`];function _r(e){for(let t of[`getPipelineAssignments`,`getAudioAssignments`,`getCameraStatuses`])e.invalidateQueries({queryKey:[[`pipelineOrchestrator`,t]]})}function vr(){let{t:e}=K(),t=c();en([`pipelineOrchestrator`,`getPipelineAssignments`],gr),en([`pipelineOrchestrator`,`getAudioAssignments`],gr),en([`pipelineOrchestrator`,`getCameraStatuses`],gr);let{data:n}=Wt({isCamera:!0,projection:`slim`}),{data:r}=et(void 0),{data:o}=ft(void 0),{data:s}=Ie({}),{data:l}=gt(void 0),{nodes:f}=G(),p=ar(),m=a(()=>Zn(f),[f]),h=a(()=>Ze(l),[l]),g=a(()=>f.filter(e=>e.isOnline).map(e=>({id:e.id,name:e.name})),[f]),_=a(()=>Yn(qn((n??[]).map(e=>({id:e.id,name:e.name,disabled:e.disabled})),r??[],o??[]),s??[]),[n,r,o,s]),[v,y]=u(()=>new Set),b=a(()=>_.filter(e=>mr(pr({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=()=>_r(t),C=Re({onSuccess:S}),w=Ht({onSuccess:S}),T=C.isPending||w.isPending,E=[{key:`camera`,header:e(`pipeline.cameraAssignmentsTable.camera`,`Camera`),width:`w-44`,sortValue:e=>e.deviceName,render:e=>i(`div`,{className:`flex w-44 min-w-0 items-center gap-1.5`,children:[d(hn,{to:`/devices/${String(e.deviceId)}`,className:`min-w-0 truncate text-xs font-medium text-primary hover:underline`,title:e.deviceName,children:e.deviceName}),e.disabled&&d(W,{variant:`default`,children:`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(ur,{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(tr,{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(dr,{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(nr,{snap:p.get(e.deviceId)})},{key:`brokers`,header:``,align:`right`,width:`w-10`,notSortableReason:`An action`,render:e=>d(fr,{deviceId:e.deviceId,deviceName:e.deviceName})}],D=n===void 0?`Loading cameras…`:_.length===0?`No cameras`:`No cameras match this activity filter.`;return i(`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:hr.map(e=>{let t=v.has(e.value);return d(`button`,{type:`button`,"aria-pressed":t,"data-testid":`assignments-activity-${e.value}`,className:Ot(ae,t?ie:j),onClick:()=>x(e.value),children:e.label},e.value)})})}),d(Je,{columns:E,rows:b,rowKey:e=>e.deviceId,minWidthPx:920,mobileMode:`scroll`,maxBodyHeight:ht,emptyMessage:D})]})}r();function yr({nodeId:e}){let{t}=K(),n=c();en([`pipelineOrchestrator`,`getCameraStatuses`],gr);let{data:r}=Ie({}),{data:i}=gt(void 0),{data:o}=Wt({isCamera:!0,projection:`slim`}),{nodes:s}=G(),l=ar(),u=a(()=>Zn(s),[s]),f=a(()=>Ze(i),[i]),p=a(()=>Xn(e,r??[],Qn((o??[]).map(e=>({id:e.id,name:e.name})))),[e,r,o]),m=s.filter(t=>t.isOnline&&t.id!==e),h=()=>_r(n),g=Re({onSuccess:h}),_=Ht({onSuccess:h}),v=lt({onSuccess:h}),y=At({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(Je,{columns:[{key:`camera`,header:t(`pipeline.nodeCameraAssignmentsTable.camera`,`Camera`),width:`w-44`,sortValue:e=>e.deviceName,render:e=>d(hn,{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(tr,{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(nr,{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,mobileMode:`scroll`,maxBodyHeight:ht,emptyMessage:r===void 0?t(`pipeline.nodeCameraAssignmentsTable.loadingCameras`,`Loading cameras…`):t(`pipeline.nodeCameraAssignmentsTable.noCameraRunsOnThis`,`No camera runs on this node right now`)})}function br({nodeId:e,refreshToken:t}){let{t:n}=K(),{nodes:r}=G(),a=r.find(t=>t.id===e)?.name??e;return i(`div`,{className:`space-y-3 sm:space-y-4`,children:[d(Wn,{refreshToken:t,nodeId:e}),i(`div`,{className:`space-y-2`,children:[i(`div`,{children:[i(`h3`,{className:`text-sm font-semibold text-foreground`,children:[`Cameras on `,a]}),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(yr,{nodeId:e})]})]})}r();function xr(e,t){let n=Math.max(0,t-e);return`${Math.floor(e/1e3)}s idle · ${Math.floor(n/1e3)}s left`}function Sr({nodeId:e,refreshToken:t}){let{t:n}=K(),r=c(),o=St(),s=fn({onSettled:()=>{r.invalidateQueries({queryKey:[`pipelineExecutor`,`listLoadedEngines`]})}}),{data:l}=kt({nodeId:e}),u=qt(`pipeline.engine-metrics-snapshot`,t=>t.nodeId===e)?.engines??l??null,f=u===null;en([`pipelineRunner`,`getLocalCameras`],[`pipeline.camera-assigned`,`pipeline.camera-unassigned`]);let{data:p}=Mt({nodeId:e}),{values:m}=It(`pipeline.camera-metrics-snapshot`,e=>e.deviceId,t=>t.nodeId===e),_=a(()=>m.filter(e=>e.metrics.phase===`active`).length,[m]),v=t=>{let r=p??[];if(r.length===0){s.mutate({nodeId:e,engine:t,force:!1});return}(async()=>{await o({title:n(`pipeline.nodeEnginesTab.killEngine`,`Kill engine`),message:`${String(r.length)} camera(s) are dispatching through this engine. Killing it drops their in-flight work and forces a respawn on the next frame.`,confirmLabel:n(`pipeline.nodeEnginesTab.killEngine`,`Kill engine`),variant:`danger`})&&s.mutate({nodeId:e,engine:t,force:!0})})()};return i(`div`,{className:`space-y-6`,children:[i(`div`,{children:[d(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:n(`pipeline.nodeEnginesTab.inferenceEnginesOnThisNode`,`Inference engines on this node`)}),i(`p`,{className:`text-[11px] text-foreground-subtle`,children:[(u??[]).length,` engine(s) resident in RAM. `,(p??[]).length,` `,`camera(s) attached, `,_,` actively dispatching frames. Refreshes every 5s.`]})]}),d(`div`,{className:`rounded-lg border border-border overflow-x-auto`,children:i(`table`,{className:`w-full text-xs min-w-[640px]`,children:[d(`thead`,{className:`bg-surface`,children:i(`tr`,{className:`text-foreground-subtle text-[10px] uppercase tracking-wider`,children:[d(`th`,{className:`text-left px-3 py-2 whitespace-nowrap`,children:n(`pipeline.nodeEnginesTab.kind`,`Kind`)}),d(`th`,{className:`text-left px-3 py-2 whitespace-nowrap`,children:n(`pipeline.nodeEnginesTab.runtimeBackendDevice`,`Runtime / Backend / Device`)}),d(`th`,{className:`text-left px-3 py-2`,children:n(`pipeline.nodeEnginesTab.models`,`Models`)}),d(`th`,{className:`text-right px-3 py-2 whitespace-nowrap`,children:n(`pipeline.nodeEnginesTab.poolPid`,`Pool PID`)}),d(`th`,{className:`text-right px-3 py-2 whitespace-nowrap`,children:n(`pipeline.nodeEnginesTab.autoKill`,`Auto-kill`)}),d(`th`,{className:`text-right px-3 py-2 whitespace-nowrap`,children:n(`pipeline.nodeEnginesTab.inUse`,`In use`)}),d(`th`,{className:`w-20`})]})}),i(`tbody`,{children:[f&&d(`tr`,{children:d(`td`,{colSpan:7,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:n(`common.loading`,`Loading…`)})}),!f&&(u??[]).map(e=>{let t=e.kind===`device-pool`;return i(`tr`,{className:`border-t border-border ${t?`bg-primary/[0.05]`:``}`,children:[d(`td`,{className:`px-3 py-2`,children:i(`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?_e:g,{className:`h-3 w-3`}),t?`pool`:`runtime`]})}),d(`td`,{className:`px-3 py-2`,children:i(`span`,{className:`inline-flex items-center gap-1 text-[11px] text-sky-400`,children:[d(z,{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:xr(e.idleMs,e.idleTtlMs)}):d(`span`,{className:`text-foreground-subtle/50`,children:`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:`auto`}):i(V,{variant:`ghost`,size:`sm`,disabled:s.isPending,onClick:()=>v(e.engine),className:`text-danger hover:bg-danger/10 hover:text-danger`,children:[d(h,{className:`h-3.5 w-3.5`}),n(`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:n(`pipeline.nodeEnginesTab.noEnginesResidentTheFactory`,`No engines resident — the factory spins up on the first pipeline run.`)})})]})]})}),i(`div`,{className:`text-[10px] text-foreground-subtle leading-relaxed`,children:[d(`strong`,{className:`text-foreground`,children:`runtime`}),`: main camera-serving engine; never auto-killed while cameras attached. `,d(`strong`,{className:`text-foreground`,children:`warm`}),`: benchmark/test override held in cache for fast re-use; auto-disposed after the idle TTL.`,` `,d(`strong`,{className:`text-foreground`,children:`pool`}),`: a per-device balanced inference pool (one per enabled accelerator, running concurrently); reaper-managed on its own idle TTL.`]}),s.isError&&d($e,{message:`Kill failed: ${s.error instanceof Error?s.error.message:`unknown error`}`})]})}var Cr=`pipeline-runner`,wr=200;function Tr({nodeId:e}){let{t}=K();return i(`div`,{className:`flex flex-col gap-3`,children:[i(`div`,{children:[d(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:t(`pipeline.nodeLogsTab.runnerLogs`,`Runner logs`)}),i(`p`,{className:`text-[11px] text-foreground-subtle`,children:[`pipeline-runner activity on `,e,` — camera attach/detach, engine phases and pipeline errors. 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,{agentId:e,addonId:Cr,limit:wr,maxHeight:`max-h-[calc(100vh-360px)]`,showScope:!0,showDeviceChip:!0,showFilters:!1})})]})}r();function Er({nodeId:e,title:t}){let{t:n}=K(),{data:r}=mn(),{data:o}=et(void 0),s=a(()=>{let e=new Map;for(let t of r??[])e.set(t.id,t.name);return e},[r]),c=a(()=>{if(!e)return null;let t=new Set;for(let n of o??[])n.agentNodeId===e&&t.add(n.deviceId);return t},[e,o]),l=ar(e),u=a(()=>{let e=[];for(let t of l.values())c&&!c.has(t.deviceId)||e.push(t);return e.sort((e,t)=>e.deviceId-t.deviceId),e},[l,c]);return u.length===0?i(`div`,{className:`rounded-md border border-border bg-surface px-3 py-2 text-[11px] text-foreground-subtle italic`,children:[t??n(`pipeline.cameraStatusStrip.cameras`,`Cameras`),`: no live snapshots yet`]}):i(`div`,{className:`rounded-md border border-border bg-surface px-3 py-2`,children:[i(`div`,{className:`flex items-center gap-2 mb-1.5`,children:[d(`span`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle`,children:t??n(`pipeline.cameraStatusStrip.cameras`,`Cameras`)}),d(`span`,{className:`text-[10px] text-foreground-subtle`,children:u.length})]}),d(`div`,{className:`flex flex-wrap gap-1.5`,children:u.map(e=>{let t=s.get(e.deviceId)??`#${e.deviceId}`,r=tt(e.metrics.phase);return i(`div`,{title:n(`pipeline.cameraStatusStrip.fpsMsInferQ`,`{{name}} · {{label}} · {{value3}} fps · {{value4}}ms infer · q={{queueDepth}}`,{name:t,label:r.label,value3:e.metrics.actualFps.toFixed(1),value4:e.metrics.avgInferenceTimeMs.toFixed(0),queueDepth:e.metrics.queueDepth}),className:`inline-flex items-center gap-1 rounded border px-1.5 py-0.5 text-[10px] ${r.badgeClass}`,children:[d(Ue,{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:`fps`})]},e.deviceId)})})]})}function Dr(e,t,n){return e.map(e=>{if(e.key===t)return e;let r=e.steps[n];if(!r||r.settings===void 0)return e;let{settings:i,...a}=r,o={...e.steps};return Object.keys(a).length>0?o[n]=a:delete o[n],{...e,steps:o}})}function Or(e,t,n){let r=e.filter(e=>e.key!==t).toSorted((e,t)=>e.key.localeCompare(t.key)),i=[...r.filter(e=>!e.enabled),...r.filter(e=>e.enabled),...e.filter(e=>e.key===t)],a;for(let e of i){let t=e.steps?.[n]?.settings;!t||Object.keys(t).length===0||(a={...a,...t})}return a}function kr(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 Ar=`pipeline-orchestrator`;function jr({addonId:e,highlightLabel:t}){let{t:n}=K(),r=we(e),{data:a}=Kt({addonId:Ar});if(r.length===0)return null;let o=Oe(a??null)[e]??{};return i(`section`,{className:`space-y-1.5 border-t border-border/60 pt-3`,"aria-label":n(`stepInspector.clusterOwnedSettings.clusterWideSettings`,`Cluster-wide settings`),children:[i(`div`,{className:`flex flex-wrap items-center gap-2`,children:[d(`h3`,{className:T,children:n(`stepInspector.clusterOwnedSettings.clusterWideSettings`,`Cluster-wide settings`)}),d(hn,{to:Io(e),className:`ml-auto text-[11px] text-primary hover:underline`,children:n(`stepInspector.clusterOwnedSettings.editInClusterSettings`,`Edit in Cluster → Settings ›`)})]}),r.map(e=>i(`div`,{className:`${p} rounded px-2 ${t===e.label?`bg-primary/5 ring-1 ring-primary/40`:``}`,children:[d(`span`,{className:P,children:e.label}),d(`span`,{className:v,children:d(`span`,{className:`font-mono text-xs text-foreground`,children:String(o[e.key]??e.default)})})]},e.key)),d(`p`,{className:B,children:n(`stepInspector.clusterOwnedSettings.oneValueForEveryNode`,`One value for every node and camera — this step writes into a shared index.`)})]})}function Mr({rows:e}){let{t}=K();return i(`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=>i(`li`,{className:`${C} flex flex-wrap items-baseline gap-x-2 text-xs`,children:[d(`span`,{className:`min-w-0 flex-1 truncate 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.id))}),d(`p`,{className:B,children:t(`stepInspector.effectiveModelSummary.toChangeAModelOpen`,`To change a model, open that accelerator's cell in the table.`)})]})}r();function Nr(e,n){let[r,i]=gn(),o=r.get(jn),s=r.get(`acc`),c=a(()=>Pn(e,n,{step:o,acc:s}),[e,n,o,s]),l=t(e=>{i(t=>{let n=new URLSearchParams(t);return e(n),n},{replace:!0})},[i]);return{selection:c,open:t(e=>l(t=>{t.set(jn,e.stepId),e.acceleratorId===void 0?t.delete(`acc`):t.set(`acc`,e.acceleratorId)}),[l]),close:t(()=>l(e=>{e.delete(jn),e.delete(`acc`)}),[l])}}function Pr(e,t){for(let n of e?.slots??[])for(let e of n.addons)if(e.id===t)return e;return null}function Fr(e){return e.split(`.`)[0]??e}function Ir(e,t,n){return{id:Nn(e,n.key),nodeId:e,deviceKey:n.key,device:n,label:`${Fr(t)} · ${Ct(n)}`,shortLabel:`${Fr(t)} · ${an(n)}`,nodeLabel:Fr(t),disabled:!n.enabled}}function Lr(e,t,n,r=!1){return n.filter(e=>r||e.enabled).map(n=>Ir(e,t,n))}function Rr(e,t,n=!1){return e.flatMap(e=>{let r=t[e.id]??[];if(n)return r.map(t=>Ir(e.id,e.name,t));let i=r.filter(e=>e.enabled&&e.available);if(i.length>0)return i.map(t=>Ir(e.id,e.name,t));let a=r.find(e=>e.available)??r[0];return a===void 0?[]:[Ir(e.id,e.name,a)]})}function zr(e,t,n){return{modelId:Yt({catalog:e,device:t.device,base:n.nodePin,override:n.cameraPin}),source:n.cameraPin===void 0?n.nodePin===void 0?`default`:`node`:`camera`}}function Br(e,t,n){let r=Pr(e,`object-detection`);if(r===null)return;let i=Yt({catalog:r,device:t.device,base:t.device.steps?.[`object-detection`]?.modelId,override:n});if(i===void 0)return;let a=r.models.find(e=>e.id===i);return{modelId:i,name:a?.name??i,supplies:a?.suppliesSteps??[]}}function Vr(e,t,n){return!xe(e)||n===void 0?!1:Se(e,t,n.supplies).effective}function Hr(e,t){return e!==null&&Gt(e.models,t.device.format)}function Ur(e){return Hr(e.addon,e.acc)?e.clusterModelId===void 0?{kind:`enabled`,modelId:e.model.modelId??`Auto`,overridden:e.model.source===`camera`,...e.rootName===void 0?{}:{suppliedByRoot:e.rootName},...e.jumpTo===void 0?{}:{jumpTo:e.jumpTo}}:{kind:`enabled`,modelId:e.clusterModelId,clusterWide:!0}:e.gatedOn?e.jumpTo===void 0?{kind:`skip`}:{kind:`skip`,jumpTo:e.jumpTo}:{kind:`na`}}function Wr(e){return Object.values(e).reduce((e,t)=>e+t.filter(e=>!e.enabled).length,0)}function Gr(e){if(e===null)return[];let t=(e.configSchema??[]).flatMap(e=>`label`in e&&typeof e.label==`string`?[e.label]:[]),n=we(e.id).map(e=>e.label);return[...new Set([...t,...n])]}function Kr(e){return e.flatMap(e=>[{node:e,depth:0},...Kr(e.children).map(e=>({node:e.node,depth:e.depth+1}))])}function qr(e,t){return e.flatMap(e=>{let n=qr(e.children,t);return t.has(e.addonId)||n.length>0?[{...e,children:n}]:[]})}r();function Jr(e){return{agentNodeId:e.nodeId,nodeLabel:e.nodeLabel,engineLabel:e.device.format,deviceKey:e.deviceKey,deviceLabel:Ct(e.device),detail:e.device.defaultModelId,disabled:e.disabled}}function Yr({tree:e,searchRows:r,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}=K(),x=St(),S=zt(),{selection:C,open:w,close:T}=Nr(a(()=>Kr(e).map(e=>e.node.addonId),[e]),a(()=>o.map(e=>e.id),[o])),[E,D]=u(``),[O,k]=u(null),[A,j]=u(null),M=n(null),P=n(null),F=n(null),I=n(null),L=a(()=>Le(r,E),[r,E]),ee=a(()=>E.trim()===``?e:qr(e,new Set(L.map(e=>e.addonId))),[e,L,E]),te=e=>L.find(t=>t.addonId===e)?.matchedField??null,ne=a(()=>o.map(Jr),[o]),re=e=>o.find(t=>t.nodeId===e.agentNodeId&&t.deviceKey===e.deviceKey),R=o.find(e=>e.id===C.acceleratorId)??null,z=C.stepId!==null,ie=t(async e=>{if(m){if(!await x({title:b(`stepInspector.stepMatrixFrame.discardUnsavedChanges`,`Discard unsaved changes?`),message:b(`stepInspector.stepMatrixFrame.thisStepHasChangesThat`,`This step has changes that are not saved yet.`),confirmLabel:b(`stepInspector.stepMatrixFrame.discard`,`Discard`),variant:`danger`}))return;h()}e()},[x,m,h,b]),ae=()=>{requestAnimationFrame(()=>I.current?.focus())},oe=(e,t,n=!1)=>{if(e===C.stepId&&(t?.id??null)===C.acceleratorId){n&&ae();return}let r=()=>{k(te(e)),w({stepId:e,...t===void 0?{}:{acceleratorId:t.id}}),n&&ae()};e===C.stepId?r():ie(r)},se=()=>{let e=C.stepId;ie(()=>{if(T(),e!==null){let t=R===null?null:vt({agentNodeId:R.nodeId,deviceKey:R.deviceKey});requestAnimationFrame(()=>M.current?.focusCell(e,t))}})},ce=e=>{if(e.key===`Enter`){let t=L[0];if(t===void 0)return;e.preventDefault(),oe(t.addonId,void 0,!0)}else e.key===`Escape`&&D(``)},le=S?d(Be,{onClick:se}):d(at,{icon:N,variant:`ghost`,size:`sm`,"aria-label":b(`common.close`,`Close`),onClick:se});return i(`div`,{ref:P,className:`space-y-2`,onKeyDown:e=>{let t=e.target instanceof HTMLElement&&e.target.dataset.r!==void 0;e.key===`/`&&t&&(e.preventDefault(),F.current?.focus()),e.key===`Escape`&&t&&z&&(e.preventDefault(),se())},children:[i(`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:F,type:`search`,value:E,onChange:e=>D(e.target.value),onKeyDown:ce,placeholder:b(`stepInspector.stepMatrixFrame.filterStepsOrSettings`,`Filter steps or settings /`),"aria-label":b(`stepInspector.stepMatrixFrame.filterStepsOrSettings2`,`Filter steps or settings`),className:`h-9 w-56 rounded-md border border-border bg-background px-2 text-xs text-foreground outline-none focus:border-primary focus:ring-1 focus:ring-primary/30 md:h-7`}),l>0&&i(`label`,{className:`inline-flex items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[d(Dt,{checked:f,onChange:e=>p(e.target.checked)}),`Show disabled accelerators (`,l,`)`]}),_]}),C.staleStepId!==null&&i(`p`,{className:`rounded-md border border-warning/40 bg-warning/10 px-3 py-1.5 text-[11px] text-warning`,children:[`The link names a step this pipeline does not have (`,C.staleStepId,`).`]}),ee.length===0?i(`p`,{className:`${B} rounded-md border border-dashed border-border px-3 py-4 text-center`,children:[`No step matches “`,E,`”.`]}):d(Ye,{ref:M,tree:ee,agents:ne,label:v,getCellState:(e,t)=>{let n=re(t);return n===void 0?{kind:`na`}:s(e,n)},onCellClick:(e,t,n)=>oe(e,re(t),n),onStepClick:(e,t)=>oe(e,void 0,t),...c===void 0?{}:{stepBadge:c},selectedCell:z&&C.stepId!==null&&R!==null?{addonId:C.stepId,agentNodeId:R.nodeId,deviceKey:R.deviceKey}:null,fallbackNodeId:A,onFallbackNodeChange:j,reserveRightPx:z&&!S?432:0}),d(nt,{open:z,anchor:P,onClose:se,label:b(`stepInspector.stepMatrixFrame.stepSettings`,`Step settings`),children:C.stepId!==null&&y({stepId:C.stepId,accelerator:R,matchedField:O,closeButton:le,onEscape:se,headingRef:e=>{I.current=e}})})]})}r();function Xr(e){f(()=>{if(e===null)return;let t=document.getElementById(e);t===null||typeof t.scrollIntoView!=`function`||t.scrollIntoView({block:`center`,behavior:`smooth`})},[e])}r();function Zr(e,t){let n=e.filter(e=>e.steps?.[t]?.settings!==void 0),r=e=>e.toSorted((e,t)=>e.key.localeCompare(t.key));return r(n.filter(e=>e.enabled))[0]?.key??r(n)[0]?.key??r(e.filter(e=>e.enabled))[0]?.key??e[0]?.key}function Qr(e,t){let n=t.settings===void 0?void 0:Zr(e,t.stepId),r=e.map(e=>{let r={...e.steps},i=r[t.stepId]??{},a=t.models[e.key],o=t.jumps[e.key],s=e.key===n&&t.settings!==void 0?Object.keys(t.settings).length>0?t.settings:void 0:i.settings,c=a===void 0?i.modelId:a??void 0,l=o===void 0?i.jumpDeviceKey:o||void 0,u={...c===void 0?{}:{modelId:c},...s===void 0?{}:{settings:s},...l===void 0?{}:{jumpDeviceKey:l}};return Object.keys(u).length>0?r[t.stepId]=u:delete r[t.stepId],{key:e.key,enabled:e.enabled,weight:e.weight,maxSessions:e.maxSessions,steps:r}});return n===void 0?r:Dr(r,n,t.stepId)}function $r(e,t,n){if(t===null)return 0;let r=Object.entries(t.models).filter(([n,r])=>(r??void 0)!==e.find(e=>e.key===n)?.steps?.[t.stepId]?.modelId).length,i=Object.entries(t.jumps).filter(([n,r])=>(r||void 0)!==e.find(e=>e.key===n)?.steps?.[t.stepId]?.jumpDeviceKey).length,a=new Set([...Object.keys(n),...Object.keys(t.settings??{})]),o=t.settings===void 0?0:[...a].filter(e=>!je(n[e],t.settings?.[e])).length;return r+i+o}function ei({nodeId:e,nodeName:t,toolbar:n}){let{t:r}=K(),s=c(),l=We({nodeId:e},{refetchOnMount:`always`}),f=on({nodeId:e},{refetchOnMount:`always`}),p=ve(Kt({addonId:`pipeline-orchestrator`}).data??null),m=l.data?.devices??[],h=f.data??null,[g,_]=u(null),[v,y]=u(null),[b,x]=u(null),S=Xe({onSuccess:()=>{s.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getNodeInferenceDevices`]]})}}),C=a(()=>h?ct(h):[],[h]),w=a(()=>Kr(C),[C]),[E,D]=u(!1),O=a(()=>Lr(e,t,m,E),[e,t,m,E]),k=a(()=>Lr(e,t,m),[e,t,m]),A=k.length>=2,j=(e,t)=>(t===void 0?void 0:Or(m,t.deviceKey,e))??{},M=(e,t,n)=>{let r=n??t.device.steps?.[e?.id??``]?.jumpDeviceKey;if(r!==void 0&&r!==``)return k.find(e=>e.deviceKey===r);if(!Hr(e,t))return k.filter(n=>n.id!==t.id&&Hr(e,n)).toSorted((e,t)=>e.deviceKey.localeCompare(t.deviceKey))[0]},N=(e,t)=>{let n=Pr(h,e),r=zo(e),i=Br(h,t),a=j(e,t),o=M(n,t);return Ur({addon:n,acc:t,gatedOn:n?.enabledByDefault??!0,model:n?zr(n,t,{nodePin:t.device.steps?.[e]?.modelId}):{modelId:void 0,source:`default`},...Vr(e,a,i)&&i?{rootName:i.name}:{},...r?{clusterModelId:p[e]??r.defaultModelId}:{},...o?{jumpTo:an(o.device)}:{}})},P=w.map(({node:e})=>({addonId:e.addonId,name:e.addonName,fieldLabels:Gr(Pr(h,e.addonId))}));if(l.isLoading||f.isLoading)return d(`div`,{className:`animate-pulse p-4 text-xs text-foreground-subtle`,children:r(`stepInspector.nodeStepInspector.loadingPipeline`,`Loading pipeline…`)});if(h===null)return d(`div`,{className:`p-4 text-xs text-foreground-subtle`,children:r(`stepInspector.nodeStepInspector.catalogUnavailable`,`Catalog unavailable.`)});let F=i(`span`,{className:B,children:[r(`stepInspector.nodeStepInspector.accelerators`,`Accelerators:`),` `,d(`span`,{className:`text-foreground`,children:k.length>0?k.map(e=>an(e.device)).join(` · `):r(`stepInspector.nodeStepInspector.noneEnabled`,`none enabled`)}),m.some(e=>!e.enabled)&&i(o,{children:[` `,r(`stepInspector.nodeStepInspector.off`,`— off:`),` `,m.filter(e=>!e.enabled).map(an).join(`, `)]}),` `,`·`,` `,d(hn,{to:Lo(),className:`text-primary hover:underline`,children:r(`stepInspector.nodeStepInspector.clusterLoadBalancing`,`Cluster → Load balancing ›`)})]});return d(Yr,{tree:C,searchRows:P,accelerators:O,cellState:N,disabledCount:m.filter(e=>!e.enabled).length,showDisabled:E,onShowDisabledChange:D,dirty:g!==null&&$r(m,g,j(g.stepId,O[0]))>0,onDiscard:()=>_(null),summary:F,...n===void 0?{}:{toolbar:n},label:r(`stepInspector.nodeStepInspector.detectionSteps`,`Detection steps`),renderDetail:({stepId:n,accelerator:a,matchedField:s,closeButton:c,onEscape:l,headingRef:u})=>{let f=Pr(h,n);if(f===null)return d(`div`,{className:`p-4 text-xs text-foreground-subtle`,children:r(`stepInspector.nodeStepInspector.noStepSelected`,`No step selected.`)});let p=g?.stepId===n?g:null,C=a??k[0]??O[0],w=j(n,C),E=p?.settings??w,D=$r(m,p,w),N=e=>{x(null),_(t=>({...t?.stepId===n?t:{stepId:n,models:{},jumps:{}},...e}))},P=zo(n),F=Ut(f),I=C===void 0?void 0:Br(h,C),L=e=>{let t=p?.models[e.deviceKey];return t===void 0?e.device.steps?.[n]?.modelId:t??void 0},ee=C===void 0?void 0:zr(f,C,{nodePin:L(C)}).modelId,te=O.length>1&&O.some(e=>!je(j(n,e),w)),ne=e=>{let t=L(e),a=zr(f,e,{nodePin:t}),s=Br(h,e),c=Vr(n,p?.settings??j(n,e),s),l=p?.jumps[e.deviceKey],u=M(f,e,l),m=Hr(f,e)?c&&s?d(nn,{rootModel:s,stepModelId:a.modelId}):void 0:i(o,{children:[`No `,e.device.format,` build of this step.`,` `,u?r(`stepInspector.nodeStepInspector.itRunsOnInstead`,`It runs on {{shortLabel}} instead.`,{shortLabel:u.shortLabel}):r(`stepInspector.nodeStepInspector.itDoesNotRunHere`,`It does not run here.`)]}),g=A?i(`label`,{className:`block space-y-1`,children:[d(`span`,{className:`text-[11px] font-medium text-foreground`,children:r(`stepInspector.nodeStepInspector.runOn`,`Run on`)}),d(H,{"aria-label":r(`stepInspector.nodeStepInspector.runOn`,`Run on`),value:l??e.device.steps?.[n]?.jumpDeviceKey??``,options:[{value:``,label:r(`stepInspector.nodeStepInspector.autoThisAcceleratorOrThe`,`Auto (this accelerator, or the next one that can run it)`)},...k.filter(t=>t.id!==e.id).map(e=>({value:e.deviceKey,label:`${e.label} · ${e.device.format}`}))],onChange:t=>N({jumps:{...p?.jumps,[e.deviceKey]:t.target.value}})}),d(`span`,{className:B,children:r(`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:a.modelId,source:a.source===`node`?`node`:`default`,sourceLabel:a.source===`node`?`node pin`:`hardware default`,models:Ft(f.models??[],e.device.format),defaultModelId:f.defaultModelIdByFormat?.[e.device.format]??f.defaultModelId,expanded:v===e.id,onToggle:()=>y(t=>t===e.id?null:e.id),onChangeModel:t=>N({models:{...p?.models,[e.deviceKey]:t}}),...t===void 0?{}:{onReset:()=>N({models:{...p?.models,[e.deviceKey]:null}}),resetLabel:`Reset to hardware default`},...m===void 0?{}:{note:m},...g===void 0?{}:{extra:g},changed:p?.models[e.deviceKey]!==void 0||l!==void 0}},re=()=>{p!==null&&S.mutate({agentNodeId:e,inferenceDevices:kr(Qr(m,p))},{onSuccess:()=>{_(null),x({kind:`saved`})},onError:e=>x({kind:`error`,error:e.message})})};return d(ut,{ref:u,title:a===null?`${f.name} · ${t}`:`${f.name} · ${a.label}`,subtitle:a===null?r(`stepInspector.nodeStepInspector.everyAcceleratorOf`,`{{slot}} · every accelerator of {{nodeName}}`,{slot:f.slot,nodeName:t}):r(`stepInspector.nodeStepInspector.baseForEveryCameraThat`,`{{slot}} · {{format}} · base for every camera that lands here`,{slot:f.slot,format:a.device.format}),leading:c,onEscape:l,saveBar:{dirtyCount:D,saving:S.isPending,status:b?.kind??null,...b?.error===void 0?{}:{error:b.error},onSave:re,onDiscard:()=>_(null)},children:i(`div`,{className:`space-y-3`,children:[i(`section`,{className:`space-y-2`,"aria-label":r(`stepInspector.nodeStepInspector.model`,`Model`),children:[d(`h3`,{className:T,children:r(`stepInspector.nodeStepInspector.model`,`Model`)}),P!==null&&C!==void 0?d(Bo,{step:P,engineFormat:C.device.format,runnableModelIds:Ft(f.models??[],C.device.format).map(e=>e.id)}):O.length===0?i(`p`,{className:B,children:[`No accelerator is enabled on this node —`,` `,d(hn,{to:Lo(),className:`text-primary hover:underline`,children:r(`stepInspector.nodeStepInspector.enableOneInClusterLoad`,`enable one in Cluster → Load balancing`)}),`.`]}):a===null?d(Mr,{rows:O.map(e=>{let t=zr(f,e,{nodePin:L(e)});return{id:e.id,label:e.label,modelId:t.modelId,sourceLabel:t.source===`node`?`node pin`:`hardware default`}})}):d(cn,{...ne(a)},a.id)]}),(F.length>0||I!==void 0)&&P===null&&i(`section`,{"aria-label":r(`stepInspector.nodeStepInspector.settings`,`Settings`),className:`space-y-2 border-t border-border/60 pt-2`,children:[i(`p`,{className:`text-[10px] text-foreground-subtle`,"data-testid":`settings-scope`,children:[`Node-wide: these settings apply on every accelerator of `,t,`.`]}),te&&d(`p`,{className:`rounded-md border border-warning/40 bg-warning/10 px-2 py-1 text-[11px] text-warning`,children:r(`stepInspector.nodeStepInspector.thisStepSSettingsDiffer`,`This step's settings differ between this node's accelerators. Saving makes the values shown here node-wide.`)}),d(ti,{addon:f,fields:F,settings:E,modelId:jt(f,ee,E,I),root:I,highlight:s,onChange:e=>N({settings:e})})]}),d(jr,{addonId:n,highlightLabel:s})]})})}})}function ti({addon:e,fields:t,settings:n,modelId:r,root:i,highlight:a,onChange:o}){let s=t.find(e=>`label`in e&&e.label===a)?.key??null;return Xr(s===null?null:Nt(s)),d(rn,{addon:e,fields:t,layers:{node:n},target:`node`,labels:{node:`Node`},modelId:r,...i===void 0?{}:{rootModel:i},highlightKey:s,onChangeLayer:o})}r();function ni({nodeId:e,refreshToken:t}){let{t:n}=K(),r=St(),[a,s]=u(null),{nodes:c}=G(),l=c.find(t=>t.id===e)?.name??e,f=Ge({onSuccess:e=>{s(e.effectiveModelId===null?`Reset done — model config cleared (node offline: effective model resolves on reconnect)`:`Reset done — effective detection model: ${e.effectiveModelId} (Auto)`)}}),p=async()=>{await r({title:n(`pipeline.nodePipelineTab.resetToHardwareAwareDefaults`,`Reset {{nodeName}} to hardware-aware defaults?`,{nodeName:l}),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`})&&(s(null),f.mutate({agentNodeId:e}))};return i(`div`,{className:`space-y-2`,children:[d(Er,{nodeId:e}),d(ei,{nodeId:e,nodeName:l,toolbar:i(o,{children:[a&&d(`span`,{className:`text-[11px] text-success`,children:a}),f.isError&&d(`span`,{className:`text-[11px] text-danger`,children:f.error instanceof Error?f.error.message:n(`pipeline.nodePipelineTab.resetFailed`,`Reset failed`)}),d(V,{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 ri=[`detection-pipeline`,`audio-analyzer`,`pipeline-runner`],ii=`decoder-nodeav`,ai=`ntab`,oi={decoder:`engine`},si={engine:`Engine & decoder`},ci=`Nothing here is set per node. Cluster-wide values are on Cluster → Settings.`;function li({nodeId:e,refreshToken:t}){let{t:n}=K(),[r,a]=gn(),{nodes:o}=G(),s=o.find(t=>t.id===e)?.addons.find(e=>e.capabilities.includes(`decoder`))?.addonId??ii,c=[...ri,s],l=r.get(ai),u={assignments:{id:`assignments`,label:n(`pipeline.nodeDetail.assignments`,`Assignments`),order:-10,content:d(br,{nodeId:e,refreshToken:t})},tree:{id:`tree`,label:n(`pipeline.nodeDetail.pipeline`,`Pipeline`),order:39,content:d(ni,{nodeId:e,refreshToken:t})},engines:{id:`engines`,label:n(`pipeline.nodeDetail.warmInstances`,`Warm instances`),order:180,content:d(Sr,{nodeId:e,refreshToken:t})},logs:{id:`logs`,label:n(`pipeline.nodeDetail.logs`,`Logs`),order:300,content:d(Tr,{nodeId:e})}},f=Un.map(e=>u[e]);return i(`div`,{className:`flex flex-col h-full`,children:[d(Hn,{nodeId:e,refreshToken:t}),d(`div`,{className:`flex-1 min-h-0 overflow-y-auto p-4 sm:p-6`,children:d(_n,{nodeId:e,addonIds:c,level:`global`,fieldScope:`perNode`,emptyMessage:ci,tabAliases:oi,tabLabelOverrides:si,extraTabs:f,activeTab:l===null?null:oi[l]??l,onActiveTabChange:e=>a(t=>{let n=new URLSearchParams(t);n.set(ai,e);for(let e of Mn)n.delete(e);return n},{replace:!0})})})]})}function ui(){let{t:e}=K();return i(`div`,{className:`space-y-2`,children:[i(`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(vr,{})]})}function di(e){return`${Math.round(e*100)}%`}function fi(e){return`${e} session${e===1?``:`s`}`}var pi={"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`},mi={"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 hi(e){return e===null?`—`:pi[e]??e}function gi(e){return e===null?`—`:mi[e]??e}function _i(e){switch(e.kind){case`capacity`:return`Capacity ${fi(e.sessions)} ≥ min ${e.minSessions}.`;case`tie-faster`:return`As accurate as ${e.over} (within ${di(e.recallDelta)} recall) and faster.`;case`stepped-down`:return`${e.from} would not fit the load on ${e.limitedBy}; ${e.to} is the most accurate that does.`;case`no-fit-lightest`:return`No model reaches ${fi(e.minSessions)} per device; the one with the most capacity (${fi(e.sessions)}) is used.`;case`derived-latency`:return`${e.modelId}: latency estimated from a similar chip, not measured on this one.`;case`cpu-device`:return`CPU fallback device: picked on its own.`;case`coral-untouched`:return`Coral: left as is (no YOLOv9 build exists for it).`;case`device-disabled`:return`Disabled: not changed.`;case`device-unavailable`:return`Not available on the node right now: not changed.`;case`node-offline`:return`Node offline: nothing on it will change.`;case`no-hardware-facts`:return`Hardware could not be read: nothing on this node will change.`;case`no-measured-data`:return`This hardware has no measured data: nothing on this node will change.`;case`no-family-build`:return`No YOLOv9 build for the ${e.format} format: not changed.`;case`kept-custom-pin`:return`Custom model ${e.modelId} is pinned on ${e.deviceKey}: Auto tune skips this device.`}}function vi(e,t){switch(e.kind){case`detector-store-cluster-wide`:return`Per-camera detector thresholds are not tied to a node, so they are cleared for every camera — including cameras that run on skipped nodes (${e.skippedNodes.map(t).join(`, `)}).`;case`detector-store-unreadable`:return`Per-camera detector thresholds could not be read (${e.error}); those will not be cleared.`;case`coral-enabled`:return`${t(e.nodeId)}: the Coral (${e.deviceKey}) is enabled and keeps running its SSD model, which finds far fewer people than YOLOv9. Consider disabling it.`;case`custom-pin-kept`:return e.deviceId===null?`${t(e.nodeId)}: custom model ${e.modelId} pinned on ${e.deviceKey??`—`} — Auto tune skips this node device.`:`Camera ${e.deviceId} pins custom model ${e.modelId} on ${t(e.nodeId)} — Auto tune keeps that override and its thresholds.`;case`custom-registry-unreadable`:return`The custom-model registry could not be read (${e.error}): every pin to a model outside the measured catalog is kept.`}}function yi(e){let t=e.nodeChanges.reduce((e,t)=>e+t.modelPins.length,0),n=e.nodeChanges.reduce((e,t)=>e+t.thresholds.length,0),r=new Set([...e.cameraClears.map(e=>e.deviceId),...e.detectorStoreClears.map(e=>e.deviceId)]);return{modelChanges:t,thresholdClears:n,cameraOverrideClears:e.cameraClears.length,detectorStoreClears:e.detectorStoreClears.length,camerasTouched:r.size}}function bi(e){let t=yi(e);return t.modelChanges+t.thresholdClears+t.cameraOverrideClears+t.detectorStoreClears===0}function xi(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 Si(e,t){return e?.kind===`node-benchmark`?`measured on this node, ${new Date(e.measuredAtMs).toLocaleDateString(t,{day:`numeric`,month:`short`})}`:`from the latency table — benchmark this node to measure it`}r();var Ci=[.3,.4,.5];function wi(e){return Ci.some(t=>t===e)}var Ti=[1,2,3,4,6,8];function Ei({plan:e,node:t,nodeName:n}){let{t:r}=K();return i(`section`,{className:x,"data-testid":`auto-tune-node-${t.nodeId}`,children:[i(`header`,{className:`${F} flex flex-wrap items-center gap-2`,children:[d(g,{className:`h-3.5 w-3.5 shrink-0 text-foreground-subtle`,"aria-hidden":!0}),d(`h3`,{className:`${T} min-w-0 flex-1`,children:n(t.nodeId)}),i(`span`,{className:`text-[11px] text-foreground-subtle`,children:[gi(t.hardwareClass),t.cpuModel===null?``:` · ${t.cpuModel}`]}),t.skipped?d(W,{variant:`warning`,children:r(`pipeline.clusterAutoTuneTab.notChanged`,`Not changed`)}):t.acceleratorModelId!==null&&d(W,{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:_i(e)},t))}),d(`div`,{className:`overflow-x-auto`,children:i(`table`,{className:`w-full text-xs`,children:[d(`thead`,{children:i(`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 r=xi(e,t.nodeId,n.deviceKey);return i(`tr`,{className:`border-t border-border align-top`,children:[i(`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:hi(n.accelerator)})]}),i(`td`,{className:`px-3 py-1.5 text-foreground-muted`,children:[n.chosen===null?`—`:`${n.chosen.capacitySessions} session${n.chosen.capacitySessions===1?``:`s`} at ${e.cameraFps} fps`,n.chosen!==null&&i(`div`,{className:`text-[11px] text-foreground-subtle`,children:[n.chosen.fps,` fps, `,Math.round(e.headroom*100),`% kept free`,d(`div`,{children:Si(n.chosen.source)})]})]}),d(`td`,{className:`px-3 py-1.5`,children:n.chosen===null?d(`span`,{className:`text-foreground-subtle`,children:`unchanged`}):r!==null&&r.before!==r.after?i(`span`,{children:[d(`span`,{className:`text-foreground-subtle`,children:r.before??`default`}),` → `,d(`span`,{className:`font-medium text-foreground`,children:r.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:_i(e)},t))})]},n.deviceKey)})})]})})]})}function Di({plan:e,nameOf:t,nodeName:n}){let{t:r}=K();return i(`div`,{className:`flex flex-col gap-3 text-xs`,"data-testid":`auto-tune-change-list`,children:[i(`div`,{children:[d(`div`,{className:T,children:r(`pipeline.clusterAutoTuneTab.nodeSettings`,`Node settings`)}),e.nodeChanges.length===0?d(`div`,{className:`text-foreground-subtle`,children:r(`pipeline.clusterAutoTuneTab.noChange`,`No change.`)}):d(`ul`,{className:`mt-1 flex flex-col gap-0.5`,children:e.nodeChanges.flatMap(e=>[...e.modelPins.map(t=>i(`li`,{children:[i(`span`,{className:`font-mono`,children:[n(e.nodeId),` · `,e.deviceKey]}),` `,`— `,t.stepId,`: `,t.before??`default`,` →`,` `,t.after??r(`pipeline.clusterAutoTuneTab.stepDefault`,`step default`)]},`${e.nodeId}/${e.deviceKey}/${t.stepId}/pin`)),...e.thresholds.map(t=>i(`li`,{children:[i(`span`,{className:`font-mono`,children:[n(e.nodeId),` · `,e.deviceKey]}),` `,`— `,t.stepId,`: reset `,t.keys.join(`, `),` to the model default`]},`${e.nodeId}/${e.deviceKey}/${t.stepId}/thr`))])})]}),i(`div`,{children:[d(`div`,{className:T,children:r(`pipeline.clusterAutoTuneTab.cameraOverridesCleared`,`Camera overrides cleared`)}),e.cameraClears.length===0&&e.detectorStoreClears.length===0?d(`div`,{className:`text-foreground-subtle`,children:r(`pipeline.clusterAutoTuneTab.none`,`None.`)}):i(`ul`,{className:`mt-1 flex flex-col gap-0.5`,children:[e.cameraClears.map((e,a)=>i(`li`,{children:[t(e.deviceId),` — `,n(e.nodeId),e.deviceKey===null?` (whole pipeline)`:` · ${e.deviceKey}`,` — `,e.stepId,e.modelIdBefore===null?``:r(`pipeline.clusterAutoTuneTab.modelRemoved`,`: model {{modelIdBefore}} removed`,{modelIdBefore:e.modelIdBefore}),e.keys.length>0?r(`pipeline.clusterAutoTuneTab.reset`,`; {{value1}} reset`,{value1:e.keys.join(`, `)}):``]},`c${a}`)),e.detectorStoreClears.map(e=>i(`li`,{children:[t(e.deviceId),` — detector thresholds: `,e.keys.join(`, `),` reset`]},`d${e.deviceId}`))]})]})]})}function Oi({result:e}){let{t}=K();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.`)}):i(`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=>i(`li`,{className:e.ok?`text-foreground-muted`:`text-danger`,children:[e.ok?`✓`:`✗`,` `,e.phase,`: `,e.detail]},e.phase))]})}function ki(){let{t:e}=K(),t=c(),[n,r]=u(.4),[o,s]=u(2),[l,f]=u(!1),[p,m]=u(!1),[h,g]=u(null),{data:_}=mn(),v=a(()=>new Map((_??[]).map(e=>[e.id,e.name])),[_]),y=e=>v.get(e)??`Camera ${e}`,{nodes:b}=G(),S=a(()=>Zn(b),[b]),C=qe({headroom:n,minSessionsPerDevice:o},{enabled:l,refetchOnWindowFocus:!1}),w=dn({onSuccess:e=>{g(e),m(!1),t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getNodeInferenceDevices`]]}),t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCameraStepOverrides`]]}),t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCameraSettings`]]}),e.kind===`applied`&&C.refetch()}}),D=h?.kind===`stale`?h.plan:C.data,O=D===void 0?null:yi(D);return i(`div`,{className:`flex flex-col gap-3`,"data-testid":`cluster-auto-tune`,children:[i(`section`,{className:x,children:[i(`header`,{className:`${F} flex flex-wrap items-center gap-2`,children:[d(E,{className:`h-3.5 w-3.5 shrink-0 text-foreground-subtle`,"aria-hidden":!0}),d(`h3`,{className:`${T} min-w-0 flex-1`,children:e(`pipeline.clusterAutoTuneTab.autoTune`,`Auto tune`)})]}),i(`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 and clears every model and threshold override — node level and per camera — so each model runs its own default thresholds. Enabled steps, devices, pins, recording, notifications, zones and rules are not touched. There is no undo.`)}),i(`div`,{className:`flex flex-wrap items-center gap-2`,children:[i(`label`,{className:`flex items-center gap-1.5`,children:[d(`span`,{className:`whitespace-nowrap`,children:e(`pipeline.clusterAutoTuneTab.keepFree`,`Keep free`)}),d(H,{"aria-label":e(`pipeline.clusterAutoTuneTab.shareOfEachAcceleratorKept`,`Share of each accelerator kept free`),value:String(n),options:Ci.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);wi(t)&&r(t)}})]}),i(`label`,{className:`flex items-center gap-1.5`,children:[d(`span`,{className:`whitespace-nowrap`,children:e(`pipeline.clusterAutoTuneTab.atLeast`,`At least`)}),d(H,{"aria-label":e(`pipeline.clusterAutoTuneTab.minimumParallelSessionsPerDevice`,`Minimum parallel sessions per device`),value:String(o),options:Ti.map(e=>({value:String(e),label:`${e} camera${e===1?``:`s`} at once per accelerator`})),onChange:e=>{let t=Number(e.target.value);Ti.some(e=>e===t)&&s(t)}})]}),d(V,{size:`sm`,variant:`secondary`,onClick:()=>{g(null),f(!0),l&&C.refetch()},children:C.isFetching?e(`pipeline.clusterAutoTuneTab.computing`,`Computing…`):D===void 0?e(`pipeline.clusterAutoTuneTab.computePlan`,`Compute plan`):e(`pipeline.clusterAutoTuneTab.recompute`,`Recompute`)}),D!==void 0&&d(V,{size:`sm`,disabled:bi(D),onClick:()=>m(!0),children:e(`pipeline.clusterAutoTuneTab.apply`,`Apply…`)})]}),C.error!==null&&d(`div`,{className:`text-danger`,children:C.error.message}),h!==null&&d(Oi,{result:h}),O!==null&&i(`div`,{className:`text-[11px] text-foreground-subtle`,children:[O.modelChanges,` model change(s), `,O.thresholdClears,` node threshold reset(s), `,O.cameraOverrideClears+O.detectorStoreClears,` camera override(s) on `,O.camerasTouched,` camera(s).`]})]})]}),D?.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:vi(e,S)},t)),D?.nodes.map(e=>d(Ei,{plan:D,node:e,nodeName:S},e.nodeId)),D!==void 0&&d(dt,{open:p,onOpenChange:m,children:i(ze,{width:`lg`,scroll:`body`,children:[i(Fe,{children:[d(Bt,{children:e(`pipeline.clusterAutoTuneTab.applyAutoTune`,`Apply auto tune?`)}),d(rt,{children:e(`pipeline.clusterAutoTuneTab.theseAreAllTheChanges`,`These are all the changes. Every override listed is removed and cannot be restored.`)})]}),d(Ve,{children:d(Di,{plan:D,nameOf:y,nodeName:S})}),i(Vt,{children:[d(V,{variant:`ghost`,onClick:()=>m(!1),children:e(`common.cancel`,`Cancel`)}),d(V,{variant:`danger`,disabled:w.isPending,onClick:()=>w.mutate({planHash:D.planHash,headroom:n,minSessionsPerDevice:o}),children:w.isPending?e(`pipeline.clusterAutoTuneTab.applying`,`Applying…`):e(`common.apply`,`Apply`)})]})]})})]})}var Ai={disabled:`switched off — not a dispatch target`,unavailable:`the node probe does not see it (unplugged or still provisioning)`,"cannot-host-camera-root":`its engine format has no object-detection root model`,"accelerator-preferred":`CPU fallback — it never competes while an accelerator is serving`};function ji(e,t){return t<=0?0:Math.round(e/t*1e3)/10}function Mi(e){return e===void 0?!1:e.load.devices.reduce((e,t)=>e+t.attachedCameras,0)>=e.load.attachedCameras}function Ni(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:Ct(e),format:e.format,sessions:i,weight:a,weightSharePct:e.exclusion===null?ji(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 Pi(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=Ni(e.devicesByNode[r.id]??[],new Map((i?.load.devices??[]).map(e=>[e.deviceKey,e.attachedCameras])),Mi(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?ji(c,r.maxCameras):null,queueDepthTotal:i?.load.queueDepthTotal??null,avgInferenceTimeMs:i?.load.avgInferenceTimeMs??null,score:i?.score??null,weight:s,weightSharePct:o?ji(s,n):null,decodeHwaccel:i?.decodeHwaccel??null,devices:a,eligibleDeviceCount:a.filter(e=>e.exclusion===null).length}})}r();var Fi=2e4,Ii=3e5;function Li({stats:e,targetWeights:t}){let{t:n}=K(),{nodes:r}=G(),o=ee().trpcClient,c=un(void 0,{placeholderData:l,staleTime:Fi,refetchInterval:Fi,refetchOnWindowFocus:!0}),u=gt(void 0,{staleTime:Ii}),f=a(()=>r.map(e=>e.id),[r]),p=s({queries:f.map(e=>({queryKey:Pe(Tt.pipelineOrchestrator.getNodeInferenceDevices,{nodeId:e},`query`),queryFn:()=>o.pipelineOrchestrator.getNodeInferenceDevices.query({nodeId:e}),staleTime:Ii,refetchOnWindowFocus:!1,placeholderData:l}))}),h=a(()=>{let e={};return f.forEach((t,n)=>{let r=p[n]?.data;r&&(e[t]=r.devices)}),e},[f,p.map(e=>e.dataUpdatedAt).join(`|`)]),g=a(()=>{let e=new Map;for(let t of u.data??[])e.set(t.nodeId,t.settings);return e},[u.data]),_=a(()=>r.map(e=>{let n=g.get(e.id);return{id:e.id,name:e.name,isOnline:e.isOnline,detectEnabled:zn(n,e.isHub).pipeline,weight:t?.[e.id]??bn(n,`detectWeight`)??1,maxCameras:bn(n,`maxCameras`)}}),[r,g,t]),v=c.data??[],y=a(()=>Pi({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),C=c.dataUpdatedAt>0?Date.now()-c.dataUpdatedAt:null,w=new Map((e?.nodes??[]).map(e=>[e.nodeId,e]));return d(U,{headingId:`load-balancing-node-load`,title:n(`pipeline.nodeLoadOverview.nodeLoad`,`Node load`),icon:S,actions:i(`span`,{className:`text-[10px] text-foreground-subtle tabular-nums`,children:[x,` running · `,b,` attached ·`,` `,c.data===void 0?n(`pipeline.nodeLoadOverview.reading`,`reading…`):`${C===null?`—`:`${Math.round(C/1e3)}s`} old`]}),children:d(`div`,{className:m,children:y.length===0?d(`p`,{className:`text-[11px] italic text-foreground-subtle`,children:n(`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(Ri,{row:e,placed:w.get(e.nodeId)},e.nodeId))})})})}function Ri({row:e,placed:t}){let{t:n}=K(),r=e.attachedCameras===null?`—`:`${e.activeCameras??0} / ${e.attachedCameras}${e.maxCameras===null?``:` of ${e.maxCameras}`}`;return i(`div`,{className:`rounded-lg border border-border bg-surface/60 p-2.5 min-w-0`,children:[i(`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:n(`pipeline.nodeLoadOverview.noDetect`,`no detect`)}),!e.reported&&e.isOnline&&i(`span`,{className:`ml-auto inline-flex shrink-0 items-center gap-1 text-[9px] text-amber-400`,title:n(`pipeline.nodeLoadOverview.onlineButItDidNot`,`Online, but it did not answer the last load read — its numbers below are unknown, not zero.`),children:[d(b,{className:`h-2.5 w-2.5`}),` no reading`]}),!e.isOnline&&i(`span`,{className:`ml-auto inline-flex shrink-0 items-center gap-1 text-[9px] text-foreground-subtle`,children:[d(k,{className:`h-2.5 w-2.5`}),` offline`]})]}),i(`dl`,{className:`mt-1.5 grid grid-cols-2 gap-x-2 gap-y-0.5 text-[10px]`,children:[d(J,{label:n(`pipeline.nodeLoadOverview.runningAttached`,`Running / attached`),value:r,title:n(`pipeline.nodeLoadOverview.sessionsInInferenceNowCameras`,`Sessions in inference now / cameras attached to this runner (the balancer's committed load) / operator cap.`)}),d(J,{label:n(`pipeline.nodeLoadOverview.targetShare`,`Target share`),value:e.weightSharePct===null?`out of play`:`${e.weightSharePct}%`,title:n(`pipeline.nodeLoadOverview.theNodeShareAutomaticOr`,`The node share (automatic or manual) normalised over the nodes the balancer actually ranks (online AND detect-enabled).`)}),d(J,{label:n(`pipeline.nodeLoadOverview.actualShare1H`,`Actual share (1 h)`),value:t?.observedShare===null||t===void 0?`—`:`${Math.round(t.observedShare*100)}%`,title:n(`pipeline.nodeLoadOverview.timeWeightedShareOfThe`,`Time-weighted share of the cluster's PARALLEL detection sessions this node carried over the last hour — the quantity a share holds. '—' = no session ran here in the window.`)}),d(J,{label:n(`pipeline.nodeLoadOverview.peakYields`,`Peak · yields`),value:t===void 0?`—`:`${t.peakSessions} · ${t.yieldsAway}`,title:n(`pipeline.nodeLoadOverview.mostSessionsThisNodeRan`,`Most sessions this node ran at once in the last hour, and how many share turns it handed to another node because it was full or drowning.`)}),d(J,{label:n(`pipeline.nodeLoadOverview.scoreQueue`,`Score · queue`),value:e.score===null?`—`:`${e.score} · ${e.queueDepthTotal??0}`,title:n(`pipeline.nodeLoadOverview.theCapacityScoreBalanceMinimises`,`The capacity score balance() minimises (attached + queue depth), and the raw queue depth.`)}),e.capacityPct!==null&&d(J,{label:n(`pipeline.nodeLoadOverview.capFill`,`Cap fill`),value:`${e.capacityPct}%`,title:n(`pipeline.nodeLoadOverview.attachedMaxcameras`,`attached / maxCameras.`)}),e.avgInferenceTimeMs!==null&&d(J,{label:n(`pipeline.nodeLoadOverview.avgInfer`,`Avg infer`),value:`${Math.round(e.avgInferenceTimeMs)} ms`,title:n(`pipeline.nodeLoadOverview.meanInferenceTimeAcrossThis`,`Mean inference time across this node's attached cameras.`)}),e.decodeHwaccel!==null&&d(J,{label:n(`pipeline.nodeLoadOverview.decode`,`Decode`),value:e.decodeHwaccel,title:n(`pipeline.nodeLoadOverview.thisNodeSProbedDecode`,`This node's probed decode hwaccel.`)})]}),d(zi,{row:e})]})}function zi({row:e}){let{t}=K();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.`)}):i(`div`,{className:`mt-2 border-t border-border pt-1.5`,children:[i(`div`,{className:`flex items-center gap-1 text-[9px] uppercase tracking-wider text-foreground-subtle`,children:[d(w,{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(Bi,{device:e},e.key))})]})}function Bi({device:e}){let{t}=K(),n=e.exclusion;return i(`li`,{className:`flex items-baseline gap-1.5 text-[10px] min-w-0`,children:[d(g,{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?i(o,{children:[i(`span`,{className:`shrink-0 tabular-nums text-foreground-subtle`,children:[e.weightSharePct,`% share`]}),i(`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:[`· `,e.sessions??`—`,` session`,e.sessions===1?``:`s`,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`)})]}):i(`span`,{className:`truncate text-foreground-subtle/80`,title:Ai[n],children:[`excluded — `,Ai[n]]})]})}function J({label:e,value:t,title:n}){return i(`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 Vi(e){return{nodes:Object.fromEntries(e.map(e=>[e.nodeId,Math.max(1,e.weight)])),devices:{}}}function Hi(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 Ui(e){return Object.fromEntries(e.nodes.map(e=>[e.nodeId,Object.fromEntries(e.devices.map(e=>[e.deviceKey,e.suggestedMaxSessions]))]))}function Wi(e){return e.reason===`disabled`?`${e.deviceKey} is not enabled on any node — sessions ignore this pin`:`no node offers ${e.deviceKey} — sessions ignore this pin`}function Gi(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 Ki(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(`, `);return`${n.map(e=>t(e.nodeId)).join(`, `)} cannot take sessions — ${n.length===1?`its share goes`:`their shares go`} to the others: ${r}`}var qi=[{value:`hardware`,label:`Hardware`,hint:`Each node’s share follows what its accelerators can carry at their Auto tune models, from the measured speed of its hardware. No load is measured or estimated.`},{value:`benchmark`,label:`Benchmark`,hint:`Each node’s share follows its own node-benchmark results. A node without results uses its hardware capacity instead, and says so.`},{value:`manual`,label:`Manual`,hint:`The sliders below, as you set them.`}];function Ji(e){return e===`no-benchmark-results`?`no benchmark results yet — sized from hardware`:e===`partial-benchmark-results`?`benchmark results miss some of its accelerators — sized from hardware`:null}function Yi(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)}: ${Ji(e.capacityFallback)??``}`).join(` · `)}r();function Xi(e,t,n){return Math.min(Math.max(e,t),n)}function Zi(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 Qi(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:Xi(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 $i(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 ea({nodes:e,pending:t,onCommitWeights:n,weightLabel:r=`Detection weight`,emptyHint:a,footnote:s,readOnly:c=!1}){let{t:l}=K(),[p,m]=u(()=>Zi(e)),[h,g]=u(new Set);f(()=>{m(Zi(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=>Qi(n,e,t,h,_))},b=()=>{let t=$i(p,_,h),r=e.filter(e=>(t[e.id]??0)!==e.weight).map(e=>e.id);if(r.length===0)return;let i=new Set([...r,...h]);n(e.filter(e=>i.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:a??l(`placementBoard.weightSliderStack.noDetectEnabledNodesEnable`,`No detect-enabled nodes. Enable “Detect” on a node above to distribute detection weight.`)});let x=e.length===1;return i(`div`,{className:`space-y-3`,children:[e.map(e=>{let n=p[e.id]??0,a=h.has(e.id);return i(`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":l(`placementBoard.weightSliderStack.for`,`{{weightLabel}} for {{name}}`,{weightLabel:r,name:e.name}),type:`range`,min:0,max:100,step:1,value:Math.round(n),disabled:c||t||a||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`}),i(`span`,{className:`w-10 shrink-0 text-right font-mono text-xs tabular-nums text-foreground`,children:[Math.round(n),`%`]}),!c&&d(`button`,{type:`button`,onClick:()=>v(e.id),disabled:t||x,"aria-pressed":a,title:a?l(`placementBoard.weightSliderStack.unlockAllowRebalancing`,`Unlock — allow rebalancing`):l(`placementBoard.weightSliderStack.lockThisShareWhenOthers`,`Lock this share when others change`),className:`shrink-0 rounded p-1 hover:bg-surface-hover disabled:opacity-40 ${a?`text-amber-400`:`text-foreground-subtle`}`,children:d(a?L:ne,{className:`h-3.5 w-3.5`})})]},e.id)}),d(`p`,{className:`text-[10px] leading-tight text-foreground-subtle`,children:s??d(o,{children:l(`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 ta(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}r();function na(e){let t=Ct(e),n=e.backend.toLowerCase(),r=e.device.toLowerCase();return e.key===`cpu`||r===`cpu`?{label:t,Icon:g,hue:`slate`}:r===`npu`?{label:t,Icon:z,hue:`sky`}:r===`gpu`||r===`igpu`?{label:t,Icon:de,hue:`violet`}:n===`edgetpu`?{label:t,Icon:he,hue:`emerald`}:{label:t,Icon:g,hue:`slate`}}var ra={sky:`bg-sky-500/12 text-sky-400 ring-sky-500/25`,violet:`bg-violet-500/12 text-violet-400 ring-violet-500/25`,emerald:`bg-emerald-500/12 text-emerald-400 ring-emerald-500/25`,slate:`bg-surface-hover text-foreground-subtle ring-border`};function ia({nodeId:e,nodeName:t,isOnline:n,suggestedMaxSessions:r,autoDeviceShares:s}){let{t:l}=K(),p=c(),{data:m,isLoading:h}=We({nodeId:e},{refetchInterval:15e3}),g=Xe({onSettled:()=>{p.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getNodeInferenceDevices`]]})}}),_=m?.devices??[],v=m?.reachable??n,[y,b]=u({});f(()=>{b(Object.fromEntries(_.map(e=>[e.key,{enabled:e.enabled,weight:e.weight,maxSessions:e.maxSessions,steps:e.steps??{}}])))},[_.map(e=>`${e.key}:${e.enabled}:${e.weight}:${e.maxSessions}:${JSON.stringify(e.steps??{})}`).join(`|`)]);let x=a(()=>_.filter(e=>y[e.key]?.enabled??e.enabled).length,[_,y]),[S,C]=u(null),w=S??x>0,T=t=>{let n=_.map(e=>{let n=t[e.key]??E(e);return{key:e.key,enabled:n.enabled,weight:n.weight,maxSessions:n.maxSessions,steps:n.steps}});g.mutate({agentNodeId:e,inferenceDevices:kr(n)})},E=e=>({enabled:e.enabled,weight:e.weight,maxSessions:e.maxSessions,steps:e.steps??{}}),D=e=>{if(!e.available)return;let t=y[e.key]??E(e),n={...y,[e.key]:{...t,enabled:!t.enabled}};b(n),T(n)},A=(e,t)=>{let n=y[e.key]??E(e),r={...y,[e.key]:{...n,maxSessions:t}};b(r),T(r)},j=a(()=>_.filter(e=>(y[e.key]?.enabled??e.enabled)&&e.available),[_,y]),M=a(()=>j.map(e=>({id:e.key,name:na(e).label,weight:s===void 0?y[e.key]?.weight??e.weight:Math.round(s[e.key]??0)})),[j,y,s]);return i(`div`,{className:`rounded-lg border border-border bg-surface/60`,children:[i(`button`,{type:`button`,onClick:()=>C(!w),className:`flex w-full items-center gap-2.5 px-3.5 py-2.5 text-left`,"aria-expanded":w,children:[d(O,{className:`h-4 w-4 shrink-0 text-foreground-subtle transition-transform ${w?`rotate-90`:``}`}),d(`span`,{className:`truncate text-[13px] font-medium text-foreground`,children:t}),d(`span`,{className:`ml-auto flex items-center gap-2 text-[11px]`,children:v?x>=2?i(`span`,{className:`inline-flex items-center gap-1 text-emerald-400`,children:[d(_e,{className:`h-3.5 w-3.5`}),x,` accelerators`]}):x===1?d(`span`,{className:`text-foreground-subtle`,children:l(`placementBoard.nodeInferenceDevices.singleDefault`,`single default`)}):d(`span`,{className:`text-foreground-subtle/70`,children:l(`placementBoard.nodeInferenceDevices.autoDefault`,`auto default`)}):i(`span`,{className:`inline-flex items-center gap-1 text-foreground-subtle`,children:[d(k,{className:`h-3.5 w-3.5`}),` unreachable`]})})]}),w&&i(`div`,{className:`space-y-3 border-t border-border px-3.5 py-3`,children:[v?h&&_.length===0?d(`p`,{className:`rounded-lg border border-dashed border-border bg-background px-4 py-6 text-center text-xs text-foreground-subtle`,children:l(`placementBoard.nodeInferenceDevices.probingAccelerators`,`Probing accelerators…`)}):_.length===0?d(`p`,{className:`rounded-lg border border-dashed border-border bg-background px-4 py-6 text-center text-xs text-foreground-subtle`,children:l(`placementBoard.nodeInferenceDevices.noInferenceDevicesReportedBy`,`No inference devices reported by this node's platform probe.`)}):d(`ul`,{className:`space-y-2`,children:_.map(e=>{let t=na(e),n=y[e.key]??E(e),a=n.enabled&&e.available,s=ta({defaultModelId:e.defaultModelId,steps:n.steps});return i(`li`,{className:`flex items-center gap-3 rounded-lg border px-3 py-2.5 transition-colors ${e.available?a?`border-primary/40 bg-primary/[0.04] ring-1 ring-inset ring-primary/20`:`border-border bg-surface`:`border-border/60 bg-background opacity-55`}`,children:[d(`span`,{className:`grid h-9 w-9 shrink-0 place-items-center rounded-md ring-1 ring-inset ${ra[t.hue]}`,children:d(t.Icon,{className:`h-4.5 w-4.5`})}),i(`div`,{className:`min-w-0 flex-1`,children:[i(`div`,{className:`flex items-center gap-2`,children:[d(`span`,{className:`truncate text-[13px] font-medium text-foreground`,children:t.label}),d(W,{variant:`default`,style:`outline`,className:`font-mono text-[9px]`,children:e.format}),!e.available&&d(W,{variant:`warning`,className:`text-[9px]`,children:`unavailable`})]}),i(`div`,{className:`mt-0.5 flex items-center gap-1.5 text-[10px] text-foreground-subtle`,children:[d(`span`,{className:`font-mono`,children:e.key}),s!==null&&i(o,{children:[d(`span`,{"aria-hidden":!0,children:`·`}),i(`span`,{children:[`root model`,` `,d(`span`,{className:`font-mono text-foreground/80`,children:s})]})]})]})]}),a&&i(`label`,{className:`flex shrink-0 items-center gap-1 text-[10px] text-foreground-subtle`,children:[d(`span`,{className:`hidden @sm/clustertab:inline`,children:`cap`}),d(`input`,{type:`number`,min:1,placeholder:`∞`,value:n.maxSessions??``,onChange:t=>{let n=t.target.value.trim(),r=n===``?null:Number.parseInt(n,10);A(e,r!=null&&r>0?r:null)},disabled:g.isPending,"aria-label":l(`placementBoard.nodeInferenceDevices.maxConcurrentSessionsFor`,`Max concurrent sessions for {{label}}`,{label:t.label}),className:`w-14 rounded border border-border bg-background px-1.5 py-1 text-right font-mono text-[11px] text-foreground focus:border-primary focus:outline-none`})]}),a&&d(aa,{suggested:r?.[e.key]??null,current:n.maxSessions,pending:g.isPending,onApply:t=>A(e,t)}),d(Rt,{checked:a,onCheckedChange:()=>D(e),disabled:!e.available||g.isPending,"aria-label":l(`placementBoard.nodeInferenceDevices.enable`,`Enable {{label}}`,{label:t.label}),className:e.available?``:`cursor-not-allowed opacity-50`})]},e.key)})}):d(oa,{}),v&&j.length>=2&&i(`div`,{className:`space-y-3 rounded-lg border border-border bg-background/60 p-3.5`,children:[i(`h4`,{className:`flex items-center gap-1.5 text-xs font-semibold uppercase tracking-wide text-foreground-subtle`,children:[d(pe,{className:`h-3.5 w-3.5`}),l(`placementBoard.nodeInferenceDevices.acceleratorShare`,`Accelerator share`)]}),d(ea,{nodes:M,pending:g.isPending,onCommitWeights:e=>{let t={...y};for(let n of e){let e=t[n.nodeId];e&&(t[n.nodeId]={...e,weight:n.weight})}b(t),T(t)},weightLabel:`Accelerator share`,readOnly:s!==void 0,footnote:s===void 0?d(o,{children:l(`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%.`)}):d(o,{children:l(`placementBoard.nodeInferenceDevices.automaticEachAcceleratorSShare`,`Automatic: each accelerator's share follows its measured throughput at its model. Switch the node shares to manual to set them yourself.`)})})]}),g.isError&&i(`div`,{className:`rounded-md border border-danger/30 bg-danger/5 px-3 py-2 text-[11px] text-danger`,children:[l(`placementBoard.nodeInferenceDevices.failedToSaveInferenceDevices`,`Failed to save inference devices:`),` `,g.error instanceof Error?g.error.message:l(`placementBoard.nodeInferenceDevices.unknownError`,`unknown error`)]})]})]})}function aa({suggested:e,current:t,pending:n,onApply:r}){let{t:a}=K();return e===null||e<1||e===t?null:i(V,{variant:`ghost`,size:`sm`,onClick:()=>r(e),disabled:n,title:a(`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:[`use `,e]})}function oa(){let{t:e}=K();return i(`div`,{className:`flex flex-col items-center gap-2 rounded-lg border border-dashed border-border bg-background px-4 py-8 text-center`,children:[d(k,{className:`h-6 w-6 text-foreground-subtle/60`}),d(`p`,{className:`text-xs font-medium text-foreground`,children:e(`placementBoard.nodeInferenceDevices.nodeUnreachable`,`Node unreachable`)}),d(`p`,{className:`max-w-sm text-[11px] text-foreground-subtle`,children:e(`placementBoard.nodeInferenceDevices.thePlatformProbeCouldnT`,`The platform probe couldn't be reached, so its live accelerator set is unavailable. Settings resume once the node reconnects.`)})]})}r();var sa=3600*1e3,ca=2e4,la=.4;function ua({refreshToken:e,onOpenAutoTune:t}){let{t:n}=K(),r=c(),{nodes:s}=G(),f=gt(void 0),p=Wt({isCamera:!0,projection:`slim`}),h=pn({windowMs:sa},{refetchInterval:ca,placeholderData:l}).data,_=it(void 0,{refetchInterval:ca,placeholderData:l}).data,v=()=>{wn(r),r.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getNodeInferenceDevices`]]})},y=Lt({onSuccess:v}),b=Jt({onSuccess:()=>{v(),r.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getEffectiveShares`]]})}}),x=yt({onSuccess:v}),S=mt(),[w,T]=u(!1),D=_?.source,O=D===`benchmark`?`benchmark`:`hardware`,k=tn({headroom:la,source:O},{enabled:w,staleTime:1/0}),A=k.data,j=a(()=>{let e=new Map((f.data??[]).map(e=>[e.nodeId,e.settings]));return s.filter(t=>zn(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:bn(n,`detectWeight`)??1,maxCameras:bn(n,`maxCameras`)}})},[s,f.data]),M=e=>s.find(t=>t.id===e)?.name??e,N=Qn((p.data??[]).map(e=>({id:e.id,name:e.name}))),P=A?Ui(A):void 0,F=Gi(j,_),L=D!==`manual`,ee=e=>{if(_===void 0||_.source===`manual`||_.autoPending)return;let t=_.nodes.find(t=>t.nodeId===e);return t===void 0?void 0:Object.fromEntries(t.devices.map(e=>[e.deviceKey,e.configuredPct]))},te=_?Ki(_,M):null,ne=_?Yi(_,M):null,re=qi.find(e=>e.value===D)?.hint;return i(`div`,{className:`space-y-3 sm:space-y-4`,children:[d(_n,{nodeId:`hub`,addonIds:[On],level:`global`,sectionIds:[`load`],title:n(`pipeline.clusterLoadBalancingTab.placementPolicy`,`Placement policy`),description:n(`pipeline.clusterLoadBalancingTab.howANewDetectionSession`,`How a new detection session picks its node and device, and what happens when a node falls behind. 'Honour shares' (default) holds the shares below for PARALLEL sessions.`)}),d(Wn,{refreshToken:e}),d(Li,{stats:h,..._!==void 0&&_.source!==`manual`&&!_.autoPending?{targetWeights:Object.fromEntries(_.nodes.map(e=>[e.nodeId,e.configuredPct]))}:{}}),d(U,{headingId:`load-balancing-node-shares`,title:n(`pipeline.clusterLoadBalancingTab.nodeShares`,`Node shares`),icon:pe,actions:i(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[d(`div`,{role:`radiogroup`,"aria-label":n(`pipeline.clusterLoadBalancingTab.shareSource`,`Share source`),className:`flex items-center gap-1`,children:qi.map(e=>d(V,{role:`radio`,"aria-checked":D===e.value,variant:D===e.value?`primary`:`outline`,size:`sm`,title:e.hint,disabled:b.isPending||_===void 0,onClick:()=>{D!==e.value&&b.mutate({source:e.value})},children:e.label},e.value))}),i(V,{variant:`outline`,size:`sm`,onClick:()=>{T(!0),w&&k.refetch()},disabled:k.isFetching,children:[d(I,{className:`h-3.5 w-3.5`}),k.isFetching?n(`pipeline.clusterLoadBalancingTab.suggesting`,`Suggesting…`):O===`benchmark`?n(`pipeline.clusterLoadBalancingTab.suggestFromBenchmark`,`Suggest from benchmark`):n(`pipeline.clusterLoadBalancingTab.suggestFromHardware`,`Suggest from hardware`)]}),i(V,{variant:`ghost`,size:`sm`,onClick:t,children:[d(E,{className:`h-3.5 w-3.5`}),n(`pipeline.clusterLoadBalancingTab.autoTune`,`Auto tune`)]}),i(V,{variant:`outline`,size:`sm`,onClick:()=>S.mutate(void 0),disabled:S.isPending,title:n(`pipeline.clusterLoadBalancingTab.moveStandingAlwaysOnCameras`,`Move standing (always-on) cameras that are no longer on their best node. Pinned cameras never move; on-motion sessions are placed per session anyway.`),children:[d(z,{className:`h-3.5 w-3.5`}),S.isPending?n(`pipeline.clusterLoadBalancingTab.rebalancing`,`Rebalancing…`):n(`pipeline.clusterLoadBalancingTab.rebalance`,`Rebalance`)]})]}),children:i(`div`,{className:`${m} space-y-3`,children:[re!==void 0&&d(`p`,{className:`text-[10px] text-foreground-subtle`,children:re}),h&&i(`p`,{className:`text-[10px] text-foreground-subtle`,children:[n(`pipeline.clusterLoadBalancingTab.policy`,`Policy:`),` `,d(W,{variant:h.policy===`share`?`info`:`default`,children:h.policy===`share`?n(`pipeline.clusterLoadBalancingTab.honourShares`,`honour shares`):`least-loaded`}),` `,`· cluster peak `,h.clusterPeakSessions,` parallel sessions in the last hour`,h.policy===`least-loaded`&&` · under least-loaded an idle node always wins, so shares only bite once nodes are busy`]}),d(ea,{nodes:F.nodes,pending:y.isPending,readOnly:F.readOnly,onCommitWeights:e=>y.mutate(Vi(e)),weightLabel:`Node share`,...F.readOnly?{footnote:_?.autoPending?d(o,{children:n(`pipeline.clusterLoadBalancingTab.automaticSharesAreBeingComputed`,`Automatic shares are being computed from the cluster's measured capacity; the stored values are used meanwhile.`)}):i(o,{children:[D===`benchmark`?n(`pipeline.clusterLoadBalancingTab.benchmarkEachNodeSShare`,`Benchmark: each node's share follows its measured capacity from node benchmark results (hardware capacity where it has none)`):n(`pipeline.clusterLoadBalancingTab.hardwareEachNodeSShare`,`Hardware: each node's share follows its capacity at its Auto tune model, from the measured speed of its hardware`),n(`pipeline.clusterLoadBalancingTab.recomputedWheneverANodeOr`,`, recomputed whenever a node or accelerator is added, removed, switched on or off, or changes model`),_?.computedAt==null?``:` — last at ${new Date(_.computedAt).toLocaleTimeString()}${_.trigger===null?``:` (${_.trigger})`}`,`.`]})}:{}}),te!==null&&d(`p`,{className:`text-[10px] text-foreground-subtle`,children:te}),ne!==null&&d(`p`,{className:`text-[10px] text-foreground-subtle`,"data-testid":`benchmark-fallback-note`,children:ne}),b.isError&&d($e,{message:`Failed to switch shares: ${b.error instanceof Error?b.error.message:`unknown error`}`}),y.isError&&d($e,{message:`Failed to save shares: ${y.error instanceof Error?y.error.message:`unknown error`}`}),i(`details`,{className:`rounded-md border border-border`,children:[d(`summary`,{className:`${C} cursor-pointer text-xs text-foreground`,children:n(`pipeline.clusterLoadBalancingTab.maxConcurrentSessionsAdvanced`,`Max concurrent sessions (advanced)`)}),d(`ul`,{className:`divide-y divide-border border-t border-border`,children:j.map(e=>i(`li`,{className:`${C} flex items-center gap-2`,children:[d(`span`,{className:`min-w-0 flex-1 truncate text-xs text-foreground`,children:e.name}),d(xt,{type:`number`,min:1,placeholder:`∞`,defaultValue:e.maxCameras??``,"aria-label":n(`pipeline.clusterLoadBalancingTab.maxConcurrentSessionsFor`,`Max concurrent sessions for {{name}}`,{name:e.name}),className:`w-20 text-right`,disabled:x.isPending,onBlur:t=>{let n=t.target.value.trim(),r=n===``?null:Number.parseInt(n,10),i=r!==null&&r>0?r:null;i!==e.maxCameras&&x.mutate({agentNodeId:e.id,maxCameras:i})}})]},e.id))}),d(`p`,{className:`${C} ${B} border-t border-border`,children:n(`pipeline.clusterLoadBalancingTab.aHardCapOnThe`,`A hard cap on the sessions a node runs at once (always-on cameras count too). A node at its cap is never chosen; under shares its turn goes to a free node. Empty = unlimited.`)})]})]})}),k.isError&&d($e,{message:`Suggestion failed: ${k.error instanceof Error?k.error.message:`unknown error`}`}),A&&d(da,{suggestion:A,nameOf:M,pending:y.isPending,...L?{}:{onApply:()=>y.mutate(Hi(A))}}),d(U,{headingId:`load-balancing-accelerators`,title:n(`pipeline.clusterLoadBalancingTab.accelerators`,`Accelerators`),icon:g,children:d(`div`,{className:`${m} space-y-2`,children:j.length===0?d(ot,{title:n(`pipeline.clusterLoadBalancingTab.noDetectCapableNodes`,`No detect-capable nodes`),description:n(`pipeline.clusterLoadBalancingTab.enableDetectionOnANode`,`Enable detection on a node in Roles & nodes to configure its accelerators.`)}):j.map(e=>d(ia,{nodeId:e.id,nodeName:e.name,isOnline:e.isOnline,...P?.[e.id]===void 0?{}:{suggestedMaxSessions:P[e.id]},...ee(e.id)===void 0?{}:{autoDeviceShares:ee(e.id)}},e.id))})}),h!==void 0&&h.stalePins.length>0&&d(fa,{stats:h,cameraName:N})]})}function da({suggestion:e,nameOf:t,pending:n,onApply:r}){let{t:a}=K();return i(U,{headingId:`load-balancing-suggestion`,title:e.source===`benchmark`?a(`pipeline.clusterLoadBalancingTab.suggestedFromBenchmark`,`Suggested from benchmark`):a(`pipeline.clusterLoadBalancingTab.suggestedFromHardware`,`Suggested from hardware`),icon:I,...r===void 0?{}:{actions:d(V,{size:`sm`,onClick:r,disabled:n,children:a(`pipeline.clusterLoadBalancingTab.applySuggestedShares`,`Apply suggested shares`)})},children:[d(`ul`,{className:`divide-y divide-border`,children:e.nodes.map(e=>i(`li`,{className:`${C} space-y-0.5`,children:[i(`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?`skipped`:`${e.share}%`})]}),i(`p`,{className:B,children:[Ji(e.capacityFallback)===null?``:`${Ji(e.capacityFallback)} · `,e.skippedReason===null?a(`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(` · `)}):a(`pipeline.clusterLoadBalancingTab.notPartOfTheSuggestion`,`not part of the suggestion — {{skippedReason}}`,{skippedReason:e.skippedReason})]})]},e.nodeId))}),i(`p`,{className:`${C} ${B} border-t border-border`,children:[`Shares in proportion to each node's capacity in parallel sessions —`,` `,e.source===`benchmark`?a(`pipeline.clusterLoadBalancingTab.measuredByNodeBenchmarksOr`,`measured by node benchmarks, or from the hardware table where a node has no results`):a(`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}),`, counted in `,e.cameraFps,` fps sessions with`,` `,Math.round(e.headroom*100),`% kept free. No load is measured or estimated.`,r===void 0?a(`pipeline.clusterLoadBalancingTab.automaticSharesAlreadyFollowThis`,`Automatic shares already follow this; the caps are advisory — apply each from its accelerator row.`):a(`pipeline.clusterLoadBalancingTab.applyingWritesTheNodeAnd`,`Applying writes the node and accelerator shares; the caps are advisory — apply each from its accelerator row.`)]})]})}function fa({stats:e,cameraName:t}){let{t:n}=K(),r=c(),a=Et({onSuccess:()=>{r.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPlacementStats`]]}),r.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineDevicePin`]]})}});return d(U,{headingId:`load-balancing-stale-pins`,title:n(`pipeline.clusterLoadBalancingTab.staleDevicePins`,`Stale device pins`),icon:me,children:d(`ul`,{className:`divide-y divide-border`,children:e.stalePins.map(e=>i(`li`,{className:`${C} flex items-center gap-2`,children:[i(`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:B,children:Wi(e)})]}),d(V,{variant:`outline`,size:`sm`,disabled:a.isPending,onClick:()=>a.mutate({deviceId:e.deviceId,deviceKey:`auto`}),children:n(`pipeline.clusterLoadBalancingTab.clearPin`,`Clear pin`)})]},e.deviceId))})})}function pa({node:e,emphasis:t=!1}){let n=e.isHub?R:g;return i(`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(n,{className:`h-4 w-4 shrink-0 text-foreground-subtle`,"aria-hidden":`true`}),i(`div`,{className:`min-w-0`,children:[i(`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(W,{variant:`info`,className:`px-1.5 py-0 text-[9px] uppercase tracking-wider`,children:`hub`}),!e.isOnline&&d(W,{variant:`danger`,className:`px-1.5 py-0 text-[9px] uppercase tracking-wider`,children:`offline`})]}),d(`div`,{className:`font-mono text-[10px] text-foreground-subtle truncate`,children:e.id})]})]})}function ma({nodes:e,actions:t}){let{t:n}=K();return d(Je,{columns:[{key:`node`,header:n(`placementBoard.nodeCapabilitiesTable.node`,`Node`),sortValue:e=>e.name,render:e=>d(pa,{node:e})},...Tn.map(e=>({key:e.key,header:e.label,align:`center`,notSortableReason:`A switch — sorting would move the row while it is being changed.`,render:r=>d(Rt,{"aria-label":n(`placementBoard.nodeCapabilitiesTable.on`,`{{label}} on {{name}}`,{label:e.label,name:r.name}),title:e.hint,checked:yn(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,mobileMode:`scroll`,rowClassName:e=>e.isOnline?void 0:`opacity-60`,emptyMessage:n(`placementBoard.nodeCapabilitiesTable.noClusterNodesReportingYet`,`No cluster nodes reporting yet.`)})}function ha({roleValues:e,options:t,pending:n,onRoleChange:r}){let{t:a}=K(),o=t.map(e=>({value:e.id,label:e.id===`hub`?a(`placementBoard.roleControls.default`,`{{name}} (default)`,{name:e.name}):e.name}));return d(`ul`,{className:`divide-y divide-border`,children:kn.map(t=>i(`li`,{className:`${C} flex flex-wrap items-center gap-x-3 gap-y-1.5`,children:[i(`div`,{className:`min-w-0 flex-1 basis-56`,children:[d(`div`,{className:`text-xs font-medium text-foreground`,children:xn(t)}),d(`p`,{className:B,children:Sn(t)})]}),d(`div`,{className:`w-full sm:w-48`,children:d(H,{"aria-label":a(`placementBoard.roleControls.node`,`{{value1}} node`,{value1:xn(t)}),value:e[t],disabled:n,options:o,onChange:e=>r(t,e.target.value)})})]},t))})}r();function ga(){let{t:e}=K(),t=c(),{nodes:n}=G(),r=gt(void 0),o=Kt({addonId:On}),s=Kt({addonId:vn}),l=Kt({addonId:An}),u=()=>wn(t),f=Qt({onSuccess:u}),p=wt({onSuccess:u}),m=a(()=>{let e=new Map;for(let t of r.data??[])e.set(t.nodeId,t.settings);return e},[r.data]),h=a(()=>n.map(e=>{let t=m.get(e.id),n=zn(t,e.isHub);return{id:e.id,name:e.name,isHub:e.isHub,isOnline:e.isOnline,settings:t,effective:n}}),[n,m]),g={ingestNode:Dn(o.data,`ingestNode`,`hub`),recordingNode:Dn(s.data,En,`hub`),audioNode:Dn(o.data,`audioNode`,`hub`),motionNode:Dn(o.data,`motionNode`,`hub`),postProcessingNode:Dn(l.data,Cn,`hub`)},_=a(()=>{let e=n.filter(e=>e.isOnline).map(e=>e.id),t=e=>n.find(t=>t.id===e)?.name||e;return[...new Set([`hub`,...kn.map(e=>g[e]),...e])].filter(e=>e.length>0).map(e=>({id:e,name:t(e)}))},[n,g]),v=r.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:vn,patch:{[En]:t}});return}if(e===`postProcessingNode`){p.mutate({addonId:An,patch:{[Cn]:t}});return}p.mutate({addonId:On,patch:{[e]:t}})},x={capabilityPending:f.isPending,onToggleCapability:y},S=v?d(A,{className:`h-3.5 w-3.5 animate-spin text-foreground-subtle`,"aria-label":e(`pipeline.clusterRolesNodesTab.loading`,`Loading`)}):null;return i(`div`,{className:`space-y-3 sm:space-y-4`,children:[i(U,{headingId:`roles-nodes-cluster-roles`,title:e(`pipeline.clusterRolesNodesTab.clusterRoles`,`Cluster roles`),icon:fe,actions:S,children:[d(`p`,{className:`${B} border-b border-border px-3 py-1.5 sm:px-4`,children:e(`pipeline.clusterRolesNodesTab.oneNodeHoldsEachRole`,`One node holds each role for every camera. Detection shares and caps are on Load balancing.`)}),d(ha,{roleValues:g,options:_,pending:p.isPending,onRoleChange:b})]}),d(U,{headingId:`roles-nodes-node-capabilities`,title:e(`pipeline.clusterRolesNodesTab.nodeCapabilities`,`Node capabilities`),icon:R,children:d(ma,{nodes:h,actions:x})})]})}var _a=`pipeline-analytics`,va=`face-gallery`,ya=`pipeline-orchestrator`,ba=`pipeline-runner`,xa=`audio-analyzer`;function Sa(e){return[...Ee.filter(t=>t.stepId===e).map(e=>ye(e.stepId)),...be.filter(t=>t.stepId===e).map(e=>ke(e.stepId,e.key))]}var Ca=`faces`,wa=`semantic-search`,Ta=[{id:Ca,title:`Faces & recognition`,hint:`The face encoder for every node, the smallest faces worth embedding, keeping and auto-assigning, and how a face is matched to a person.`,panels:[{addonId:ya,fieldKeys:Sa(`face-embedding`)},{addonId:_a,capability:va}]},{id:wa,title:`Semantic search`,hint:`The image encoder behind "search by description". One for the whole cluster: changing it hides existing results until the index is rebuilt.`,panels:[{addonId:ya,fieldKeys:Sa(`clip-embedding`)}]},{id:Ae,title:`Enrichment crop`,hint:`How the crop handed to face, plate and search models is cut from the frame.`,panels:[{addonId:ya,sectionIds:[Ae]}]},{id:De,title:`Full-resolution crops`,hint:`How long each camera keeps full-resolution pixels so a late crop (snapshot, face, plate) is sharp instead of cut from the small detection frame.`,panels:[{addonId:ya,sectionIds:[De]}]},{id:`runner-defaults`,title:`Runner defaults`,hint:`Values every node's detection runner and audio analyzer use. A node's own decode limits (Engine & decoder) take precedence.`,panels:[{addonId:ba,fieldScope:`cluster`},{addonId:xa,fieldScope:`cluster`}]},{id:`failover`,title:`Failover`,hint:`What happens to cameras when a node disconnects and comes back.`,panels:[{addonId:ya,sectionIds:[`failover`]}]}],Ea={"cluster-step-models":Ca};function Da(e){return e===`clip-embedding`?wa:Ca}r();var Oa=2500,ka={faces:te,"semantic-search":E,"detail-crop":ge,"native-lease":_e,"runner-defaults":g,failover:re};function Aa(e){f(()=>{if(e===null)return;let t=Ea[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`),Oa),!0)};if(r())return;let i=new MutationObserver(()=>{r()&&i.disconnect()});return i.observe(document.body,{childList:!0,subtree:!0}),()=>i.disconnect()},[e])}function ja({section:e}){let{t}=K();return d(`div`,{"data-cluster-settings-card":e.id,className:`rounded-lg`,children:d(U,{headingId:`cluster-settings-${e.id}`,title:e.title,...ka[e.id]===void 0?{}:{icon:ka[e.id]},children:i(`div`,{className:`${m} space-y-3`,children:[d(`p`,{className:B,children:e.hint}),e.panels.map(e=>d(_n,{nodeId:`hub`,addonIds:[e.addonId],level:`global`,hideSectionChrome:!0,omitSectionIds:[`cluster`,`load`],emptyMessage:t(`pipeline.clusterSettingsTab.notAvailableTheAddonThat`,`Not available — the addon that owns these settings did not answer.`),...e.capability===void 0?{}:{capability:e.capability},...e.sectionIds===void 0?{}:{sectionIds:e.sectionIds},...e.fieldKeys===void 0?{}:{fieldKeys:e.fieldKeys},...e.fieldScope===void 0?{}:{fieldScope:e.fieldScope}},`${e.addonId}:${e.capability??``}`))]})})})}function Ma({refreshToken:e}){let[t]=gn();return Aa(t.get(Po)),d(`div`,{className:`space-y-3 sm:space-y-4`,children:Ta.map(e=>d(ja,{section:e},e.id))})}var Na=`pipeline-orchestrator`,Pa=200;function Fa(){let{t:e}=K();return i(`div`,{className:`flex flex-col gap-3`,children:[i(`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:Na,limit:Pa,maxHeight:`max-h-[calc(100vh-360px)]`,showScope:!0,showDeviceChip:!0,showFilters:!1})})]})}var Ia=[{id:`assignments`,label:`Assignments`},{id:`load-balancing`,label:`Load balancing`},{id:`auto-tune`,label:`Auto tune`},{id:`roles-nodes`,label:`Roles`},{id:`settings`,label:`Settings`},{id:`logs`,label:`Logs`}];function La(e){return Ia.some(t=>t.id===e)}function Ra({refreshToken:e}){let{t}=K(),[n,r]=gn(),a=n.get(No),o=La(a)?a:`assignments`,s=e=>{r(t=>{let n=new URLSearchParams(t);return n.set(No,e),n.delete(Po),n},{replace:!0})};return i(`div`,{className:`flex flex-col h-full`,children:[i(`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:Ia.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:e.label},e.id))}),i(`div`,{className:`flex-1 min-h-0 overflow-y-auto p-4 sm:p-6 @container/clustertab`,children:[o===`assignments`&&d(ui,{}),o===`load-balancing`&&d(ua,{refreshToken:e,onOpenAutoTune:()=>s(`auto-tune`)}),o===`auto-tune`&&d(ki,{}),o===`roles-nodes`&&d(ga,{}),o===`settings`&&d(Ma,{refreshToken:e}),o===`logs`&&d(Fa,{})]})]})}var za=`armed:`;function Ba(e){return e.assignment.reasons.detection?.startsWith(za)===!0}function Va(e){let{assignment:t,detection:n}=e;return n!==null&&n.provisioning.state===`failed`||t.detectionNodeId===null&&n===null&&!Ba(e)?`error`:n!==null&&n.phase===`active`?`healthy`:`idle`}function Ha(e){let t=[],n=[],{assignment:r,detection:i,broker:a}=e;i!==null&&i.provisioning.state===`failed`&&t.push({code:`provisioning-failed`,severity:`error`,message:i.provisioning.error!==void 0&&i.provisioning.error.length>0?`Engine provisioning failed: ${i.provisioning.error}`:`Engine provisioning failed on the detection node`}),i!==null&&i.phase===`active`&&i.actualFps===0&&t.push({code:`detection-black-hole`,severity:`error`,message:`Detection phase is ACTIVE but 0 fps are being processed — frames are not reaching the detector (cross-node black-hole signature)`}),r.detectionNodeId===null&&i===null&&!Ba(e)&&n.push({code:`unassigned`,severity:`warning`,message:`Not placed on any detection node — no pipeline is running for this camera`});let o=e.degraded??[];if(o.length>0){let e=[...new Set(o.map(e=>e.stage))].join(`, `);n.push({code:`status-unreadable`,severity:`warning`,message:`Could not read ${e} for this camera — those blocks are unknown, not empty (a switch read that failed does NOT mean nothing is switched off)`})}n.push(...Ga(e.cameraSensors));for(let e of a?.profiles??[])e.status===`streaming`&&e.inFps===0&&n.push({code:`broker-stalled`,severity:`warning`,message:`Broker profile "${e.profile}" reports streaming but 0 in-fps — the source pull may be stalled`});return[...t,...n]}function Ua(e){return e.state===`unreadable`&&Ce.state===`unreadable`&&e.reason===Ce.reason}function Wa(e){switch(e.state){case`ready`:return null;case`missing`:return{code:`camera-sensor-missing`,severity:`warning`,message:`Camera sensor ${e.addonId}/${e.stableId} is missing`};case`offline`:return{code:`camera-sensor-offline`,severity:`warning`,message:`Camera sensor ${e.name} (#${e.deviceId}) is ${e.reason}`};case`unsupported`:return{code:`camera-sensor-unsupported`,severity:`warning`,message:`Camera sensor ${e.name} (#${e.deviceId}) cannot drive motion: ${e.reason}`};case`unreadable`:return{code:`camera-sensor-unreadable`,severity:`warning`,message:`Camera sensor ${e.addonId}/${e.stableId} is unreadable: ${e.reason}`}}}function Ga(e){if(e===void 0||e.state===`not-configured`)return[];if(e.state===`unreadable`)return Ua(e)?[]:[{code:`camera-sensors-unreadable`,severity:`warning`,message:`Camera sensors unreadable: ${e.reason}`}];let t=e.sensors.flatMap(e=>{let t=Wa(e);return t===null?[]:[t]}),n=e.notForwarded===void 0?t:[Ka(e.notForwarded),...t];return e.notEnforced===void 0?n:[{code:`camera-sensors-not-enforced`,severity:`warning`,message:`Confirm / Replace cannot suppress this camera's own motion until its provider is updated`},...n]}function Ka(e){return{code:`camera-sensors-not-forwarded`,severity:`warning`,message:e===`onboard-not-listed`?`Camera sensors are attached but never fire: add "Camera sensors" (onboard) to this camera's motion sources`:`Camera sensors are attached but never fire: this camera has no active detection`}}function qa(e){return e===void 0?`status unavailable from this node`:e.state===`not-configured`?`none attached`:e.state===`unreadable`?`unknown — ${e.reason}`:e.sensors.map(Ya).join(`, `)}function Ja(e){return e.mode===`in-addition`?``:` · ${e.mode}`}function Ya(e){return`${Xa(e)}${Ja(e)}`}function Xa(e){switch(e.state){case`ready`:return`${e.name} (#${e.deviceId})`;case`offline`:return`${e.name} (#${e.deviceId}) — ${e.reason}`;case`unsupported`:return`${e.name} (#${e.deviceId}) — unsupported`;case`missing`:case`unreadable`:return`${e.addonId}/${e.stableId} — ${e.state}`}}function Za(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Y(e){return typeof e==`string`&&e.length>0?e:null}function Qa(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function $a(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function eo(e,t){return e==null?!1:JSON.stringify(e)!==JSON.stringify(t??null)}var to={detectionMode:null,detectionStreamProfile:null,detectionFps:null,motionSources:[],motionFps:null,motionCooldownMs:null,motionStreamProfile:null,audioMode:null,pipelineNodeId:null,decoderNodeId:null,audioNodeId:null,overriddenKeys:new Set};function no(e){if(!Za(e)||!Array.isArray(e.sections))return to;let t=Me(e),n=e=>{let n=t.get(e);if(n!==void 0)return n.value??n.default},r=new Set;for(let[e,n]of t)eo(n.value,n.default)&&r.add(e);return{detectionMode:Y(n(`detectionMode`)),detectionStreamProfile:Y(n(`detectionStreamProfile`)),detectionFps:Qa(n(`detectionFps`)),motionSources:$a(n(`motionSources`)),motionFps:Qa(n(`motionFps`)),motionCooldownMs:Qa(n(`motionCooldownMs`)),motionStreamProfile:Y(n(`motionStreamProfile`)),audioMode:Y(n(`audioMode`)),pipelineNodeId:Y(n(`pipelineNodeId`)),decoderNodeId:Y(n(`decoderNodeId`)),audioNodeId:Y(n(`audioNodeId`)),overriddenKeys:r}}function ro(e,t=0){let n=[];for(let r of e)n.push({addonId:r.addonId,modelId:r.modelId??null,enabled:r.enabled,depth:t}),r.children!==void 0&&r.children.length>0&&n.push(...ro(r.children,t+1));return n}function X({title:e,children:t}){return i(`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 Z({label:e,children:t,overridden:n=!1}){return i(`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(io,{})]})}function io(){let{t:e}=K();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 ao={neutral:`border-border text-foreground-muted`,success:`border-success/40 text-success`,warning:`border-warning/40 text-warning`,danger:`border-danger/40 text-danger`,info:`border-info/40 text-info`};function Q({tone:e=`neutral`,children:t,title:n}){return 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 ${ao[e]}`,children:t})}function $({children:e}){return d(`div`,{className:`text-[11px] text-foreground-subtle italic`,children:e})}function oo({icon:e,label:t,nodeId:n,pinned:r,reason:a,overridden:s}){let{t:c}=K();return i(`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:`unassigned`}):i(o,{children:[d(`span`,{className:`font-mono text-foreground truncate`,title:n,children:n}),r?i(`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`}),` manual`]}):i(`span`,{className:`text-[10px] text-foreground-subtle shrink-0 truncate`,children:[`auto · `,a!==void 0&&a.length>0?a:`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 so({assignment:e,settings:t,onlineNodes:n,pinPending:r,onDetectionPinChange:a}){let{t:o}=K(),s=e.pinned.detection&&e.detectionNodeId!==null?e.detectionNodeId:`auto`,c=[...new Set([...e.detectionNodeId===null?[]:[e.detectionNodeId],...n.map(e=>e.id)])];return i(X,{title:o(`cameras.configBlocks.whereItRuns`,`Where it runs`),children:[d(oo,{icon:g,label:o(`cameras.configBlocks.detection`,`Detection`),nodeId:e.detectionNodeId,pinned:e.pinned.detection,reason:e.reasons.detection,overridden:t.overriddenKeys.has(`pipelineNodeId`)}),d(oo,{icon:y,label:o(`cameras.configBlocks.decoder`,`Decoder`),nodeId:e.decoderNodeId,pinned:e.pinned.decoder,reason:e.reasons.decoder,overridden:t.overriddenKeys.has(`decoderNodeId`)}),d(oo,{icon:D,label:o(`cameras.configBlocks.audio`,`Audio`),nodeId:e.audioNodeId,pinned:e.pinned.audio,reason:e.reasons.audio,overridden:t.overriddenKeys.has(`audioNodeId`)}),d(oo,{icon:M,label:o(`cameras.configBlocks.source`,`Source`),nodeId:e.sourceNodeId,pinned:!1,reason:`ingest owner`,overridden:!1}),d(`div`,{className:`mt-1.5`,children:i(`select`,{value:s,disabled:r,"aria-label":o(`cameras.configBlocks.detectionPlacementPin`,`Detection placement pin`),onChange:e=>a(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=>i(`option`,{value:e,children:[`Pin detection → `,n.find(t=>t.id===e)?.name??e]},e))]})})]})}function co(e){return`${e.width}×${e.height} ${e.codec} @${e.fps}fps`}function lo(e,t){if(!(t===null||e===void 0))return e.find(e=>e.profile===t)}function uo(e){return e===null?`default`:e===0?`native (no throttle)`:`${e} fps`}function fo({streams:e,brokerProfiles:t,settings:n,motionEnabled:r,motionFpsLive:a,cameraSensors:s}){let{t:c}=K(),l=lo(t,n.detectionStreamProfile),u=lo(t,n.motionStreamProfile),f=n.motionSources.includes(`analyzer`);return i(X,{title:c(`cameras.configBlocks.streamsMotion`,`Streams & motion`),children:[i(Z,{label:c(`cameras.configBlocks.detectStream`,`Detect stream`),overridden:n.overriddenKeys.has(`detectionStreamProfile`),children:[n.detectionStreamProfile??`—`,l!==void 0&&` · ${l.width}×${l.height} ${l.codec}`]}),d(Z,{label:c(`cameras.configBlocks.detectFps`,`Detect FPS`),overridden:n.overriddenKeys.has(`detectionFps`),children:uo(n.detectionFps)}),i(Z,{label:c(`cameras.configBlocks.motionSrc`,`Motion src`),overridden:n.overriddenKeys.has(`motionSources`),children:[n.motionSources.length>0?n.motionSources.map(Ne).join(` + `):`none`,r===!1&&` · inactive`]}),d(Z,{label:c(`cameras.configBlocks.cameraSensors`,`Camera sensors`),children:qa(s)}),f&&i(o,{children:[i(Z,{label:c(`cameras.configBlocks.motionStream`,`Motion stream`),overridden:n.overriddenKeys.has(`motionStreamProfile`),children:[n.motionStreamProfile??`—`,u!==void 0&&` · ${u.width}×${u.height} ${u.codec}`]}),i(Z,{label:c(`cameras.configBlocks.motionFps`,`Motion FPS`),overridden:n.overriddenKeys.has(`motionFps`),children:[uo(n.motionFps),a!==null&&` · live ${a.toFixed(1)}`]})]}),d(Z,{label:c(`cameras.configBlocks.cooldown`,`Cooldown`),overridden:n.overriddenKeys.has(`motionCooldownMs`),children:n.motionCooldownMs===null?`default`:`${n.motionCooldownMs/1e3}s`}),d(`div`,{className:`mt-1.5 flex flex-col gap-0.5`,children:e.length===0?d($,{children:c(`cameras.configBlocks.noStreamsRegistered`,`No streams registered`)}):e.map(e=>i(`div`,{className:`text-[10px] font-mono text-foreground-subtle truncate`,title:e.camStreamId,children:[d(`span`,{className:`text-foreground-muted`,children:e.kind}),` `,co(e)]},e.camStreamId))})]})}function po({steps:e,audioModelId:t,audioEnabled:n,audioMode:r}){let{t:a}=K();return i(X,{title:a(`cameras.configBlocks.pipelineSteps`,`Pipeline steps`),children:[e===void 0?d($,{children:a(`cameras.configBlocks.resolving`,`Resolving…`)}):e.length===0?d($,{children:a(`cameras.configBlocks.noStepsConfigured`,`No steps configured`)}):d(`div`,{className:`flex flex-wrap gap-1`,children:e.map((e,t)=>d(Q,{tone:e.enabled&&e.depth===0?`info`:`neutral`,title:e.modelId??e.addonId,children:i(`span`,{className:e.enabled?``:`line-through opacity-60`,children:[e.depth>0&&d(`span`,{className:`opacity-50`,children:`↳ `}),e.addonId,e.modelId!==null&&i(`span`,{className:`font-mono opacity-75`,children:[` · `,e.modelId]})]})},`${e.addonId}-${t}`))}),d(`div`,{className:`mt-1`,children:i(Z,{label:a(`cameras.configBlocks.audioClass`,`Audio class.`),children:[r??`—`,n!==null&&(n?` · running`:` · off`),t!==null&&` · ${t}`]})})]})}var mo={ready:`success`,installing:`info`,verifying:`info`,idle:`neutral`,failed:`danger`};function ho({detection:e,live:t,detectionMode:n,modeOverridden:r}){let{t:a}=K();if(e===null)return i(X,{title:a(`cameras.runtimeBlocks.detectionRuntime`,`Detection runtime`),children:[d(Z,{label:a(`cameras.runtimeBlocks.mode`,`Mode`),overridden:r,children:n??`—`}),d($,{children:a(`cameras.runtimeBlocks.detectionStageInactiveOrUnreachable`,`Detection stage inactive or unreachable`)})]});let o=t?.phase??e.phase,s=t?.actualFps??e.actualFps,c=t?.configuredFps??e.configuredFps,l=t?.avgInferenceTimeMs??e.avgInferenceMs,u=t?.queueDepth??e.queueDepth,f=tt(o),p=o===`active`&&s===0;return i(X,{title:a(`cameras.runtimeBlocks.detectionRuntime`,`Detection runtime`),children:[i(`div`,{className:`flex items-center gap-1.5 mb-0.5`,children:[i(`span`,{className:`inline-flex items-center gap-1 rounded border px-1.5 py-px text-[10px] font-semibold uppercase tracking-wider ${f.badgeClass}`,children:[d(Ue,{phase:o,className:`h-2.5 w-2.5`}),f.label]}),t!==void 0&&d(`span`,{className:`text-[9px] text-foreground-subtle uppercase tracking-wider`,children:`live`})]}),d(Z,{label:a(`cameras.runtimeBlocks.mode`,`Mode`),overridden:r,children:n??`—`}),i(Z,{label:`FPS`,children:[d(`span`,{className:p?`text-danger font-semibold`:``,children:s.toFixed(1)}),i(`span`,{className:`text-foreground-subtle`,children:[` / `,c.toFixed(0),` configured`]})]}),i(Z,{label:a(`cameras.runtimeBlocks.inference`,`Inference`),children:[l.toFixed(0),` ms`,u>0&&i(`span`,{className:`text-warning`,children:[` · queue `,u]}),t!==void 0&&t.droppedFrames>0&&i(`span`,{className:`text-warning`,children:[` · drops `,t.droppedFrames]})]}),i(Z,{label:a(`cameras.runtimeBlocks.engine`,`Engine`),children:[e.engine.backend,` · `,e.engine.device]}),i(Z,{label:a(`cameras.runtimeBlocks.provisioning`,`Provisioning`),children:[d(Q,{tone:mo[e.provisioning.state]??`neutral`,children:e.provisioning.state}),e.provisioning.error!==void 0&&i(`span`,{className:`text-danger text-[10px]`,children:[` `,e.provisioning.error]})]})]})}function go({broker:e}){let{t}=K();return e===null?d(X,{title:t(`cameras.runtimeBlocks.streamBroker`,`Stream broker`),children:d($,{children:t(`cameras.runtimeBlocks.brokerStageInactiveOrUnreachable`,`Broker stage inactive or unreachable`)})}):i(X,{title:t(`cameras.runtimeBlocks.streamBroker`,`Stream broker`),children:[e.profiles.length===0?d($,{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 i(`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}),i(`span`,{className:`text-foreground-subtle truncate`,children:[e.width,`×`,e.height,` `,e.codec]}),i(`span`,{className:`ml-auto shrink-0 ${r?`text-danger`:`text-foreground`}`,children:[e.inFps===null?`—`:e.inFps.toFixed(0),`fps`]}),i(`span`,{className:`text-foreground-subtle shrink-0`,title:t(`cameras.runtimeBlocks.subscribers`,`Subscribers`),children:[`×`,e.subscribers]})]},e.profile)})}),i(`div`,{className:`mt-1.5 flex flex-wrap gap-1`,children:[i(Q,{tone:e.webrtcSessions>0?`info`:`neutral`,children:[`WebRTC `,e.webrtcSessions]}),i(Q,{tone:e.rtspRestream?`success`:`neutral`,children:[`restream `,e.rtspRestream?`on`:`off`]})]})]})}function _o({decoder:e}){let{t}=K();return e===null?d(X,{title:t(`cameras.runtimeBlocks.decoder`,`Decoder`),children:d($,{children:t(`cameras.runtimeBlocks.decoderStageInactiveOrUnreachable`,`Decoder stage inactive or unreachable`)})}):d(X,{title:t(`cameras.runtimeBlocks.decoder`,`Decoder`),children:d(Z,{label:t(`cameras.runtimeBlocks.node`,`Node`),children:e.nodeId})})}r();var vo=`pipeline-orchestrator`,yo={healthy:`bg-success`,idle:`bg-warning`,error:`bg-danger`},bo={healthy:`Healthy`,idle:`Idle`,error:`Error`};function xo({problems:e}){return d(`div`,{role:`alert`,className:`flex flex-col border-b border-border`,children:e.map(e=>i(`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(b,{className:`h-3.5 w-3.5 shrink-0 mt-px`}),d(`span`,{className:`min-w-0`,children:e.message})]},e.code))})}function So({deviceId:e,name:t,online:n,status:r,live:o,onlineNodes:s}){let{t:l}=K(),u=c(),{data:f}=Xt({addonId:vo,deviceId:e,nodeId:`hub`},{staleTime:3e4}),{data:p}=Qe({deviceId:e},{staleTime:3e4}),m=a(()=>no(f),[f]),h=a(()=>p===void 0?void 0:ro(p.steps),[p]),g=a(()=>r===void 0?[]:Ha(r),[r]),_=()=>{u.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCameraStatuses`]]}),u.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineAssignments`]]})},v=Re({onSuccess:_}),y=Ht({onSuccess:_}),b=t=>{t===`auto`?y.mutate({deviceId:e}):v.mutate({deviceId:e,agentNodeId:t})},x=r===void 0?`idle`:Va(r),S=g.some(e=>e.severity===`error`),C=g.length>0,w=S?`border-danger/50`:C?`border-warning/40`:`border-border`;return i(`article`,{"aria-label":l(`cameras.cameraPipelineCard.pipelineStatus`,`{{name}} pipeline status`,{name:t}),className:`rounded-lg border ${w} bg-background overflow-hidden`,children:[i(`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`:yo[x]}`,title:S?l(`common.error`,`Error`):bo[x],"aria-label":S?l(`common.error`,`Error`):bo[x],role:`img`}),d(`h3`,{className:`text-[13px] font-semibold text-foreground truncate`,title:t,children:t}),i(`span`,{className:`text-[10px] text-foreground-subtle shrink-0`,children:[`#`,e]}),!n&&d(Q,{tone:`danger`,children:`offline`}),i(`span`,{className:`ml-auto flex items-center gap-1.5 shrink-0`,children:[m.detectionMode!==null&&d(Q,{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}),r?.recording!=null&&(r.recording.active?i(Q,{tone:`danger`,title:l(`cameras.cameraPipelineCard.recording`,`Recording ({{mode}})`,{mode:r.recording.mode}),children:[d(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full bg-danger animate-pulse`}),`REC`]}):r.recording.mode!==`off`&&i(Q,{tone:`neutral`,title:l(`cameras.cameraPipelineCard.recordingMode`,`Recording mode`),children:[`rec `,r.recording.mode]}))]})]}),g.length>0&&d(xo,{problems:g}),r===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.`)}):i(`div`,{className:`grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-px bg-border`,children:[d(so,{assignment:r.assignment,settings:m,onlineNodes:s,pinPending:v.isPending||y.isPending,onDetectionPinChange:b}),d(ho,{detection:r.detection,live:o,detectionMode:m.detectionMode,modeOverridden:m.overriddenKeys.has(`detectionMode`)}),d(po,{steps:h,audioModelId:p?.audio?.modelId??null,audioEnabled:r.audio?.enabled??p?.audio?.enabled??null,audioMode:m.audioMode}),d(fo,{streams:r.source.streams,brokerProfiles:r.broker?.profiles,settings:m,motionEnabled:r.motion?.enabled??null,motionFpsLive:r.motion?.fps??null,cameraSensors:r.cameraSensors}),d(go,{broker:r.broker}),d(_o,{decoder:r.decoder})]})]})}r();var Co=5e3,wo=1e4,To=5e3;function Eo(e){let t=c(),{data:n,isLoading:r}=mn(),{data:i,isLoading:o}=Ie({},{refetchInterval:Co}),{nodes:s}=G();f(()=>{e!==0&&t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCameraStatuses`]]})},[e,t]);let[l,d]=u(new Map);Pt(Te.PipelineCameraMetricsSnapshot,e=>{let t=e.data;typeof t.deviceId==`number`&&d(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})}),f(()=>{if(l.size===0)return;let e=setInterval(()=>{d(e=>{let t=Date.now()-wo,n=!1,r=new Map(e);for(let[i,a]of e)a.timestamp<t&&(r.delete(i),n=!0);return n?r:e})},To);return()=>clearInterval(e)},[l.size]);let p=a(()=>{let e=new Map;for(let t of i??[])e.set(t.deviceId,t);return e},[i]);return{rows:a(()=>(n??[]).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)),[n,p]),liveMetrics:l,onlineNodes:a(()=>(s??[]).filter(e=>e.isOnline).map(e=>({id:e.id,name:e.name})),[s]),isLoading:r||o}}r();function Do({refreshToken:e}){let{t}=K(),{rows:n,liveMetrics:r,onlineNodes:o,isLoading:s}=Eo(e),c=a(()=>[...n.map(e=>{let t=e.status===void 0?[]:Ha(e.status);return{row:e,errorCount:t.filter(e=>e.severity===`error`).length,warningCount:t.filter(e=>e.severity===`warning`).length}})].sort((e,t)=>e.errorCount===t.errorCount?e.warningCount===t.warningCount?0:t.warningCount-e.warningCount:t.errorCount-e.errorCount),[n]),l=a(()=>{let e=0,t=0;for(let n of c)(n.errorCount>0||n.warningCount>0)&&(t+=1),(r.get(n.row.deviceId)?.phase??n.row.status?.detection?.phase)===`active`&&(e+=1);return{total:c.length,active:e,issues:t}},[c,r]);return s&&n.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…`)}):n.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:i(`div`,{className:`max-w-6xl mx-auto flex flex-col gap-3 px-4 py-4`,children:[i(`div`,{className:`flex items-center gap-4 text-[11px] text-foreground-subtle px-1`,children:[i(`span`,{children:[d(`span`,{className:`font-semibold text-foreground`,children:l.total}),` cameras`]}),i(`span`,{children:[d(`span`,{className:`font-semibold text-success`,children:l.active}),` actively inferring`]}),i(`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(So,{deviceId:e.deviceId,name:e.name,online:e.online,status:e.status,live:r.get(e.deviceId),onlineNodes:o},e.deviceId))]})})}var Oo=e({CLUSTER_NODE_ID:()=>ko,PipelinePage:()=>Mo});r();var ko=`__cluster__`;function Ao(e){return e===`cameras`?`cameras`:`nodes`}function jo({viewMode:e,onNodes:t,onCameras:n}){let{t:r}=K();return i(`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 Mo(){let{t:e}=K(),[t,n]=gn(),r=Ao(t.get(`view`)),a=t.get(`node`)??`__cluster__`,[s,c]=u(0),[l,p]=u(!1);return f(()=>{r===`nodes`&&!t.get(`node`)&&n({view:`nodes`,node:ko},{replace:!0})},[r,t,n]),i(Ke,{icon:le,title:e(`pipeline.pipeline`,`Pipeline`),subtitle:e(`pipeline.detectionPlacementLoadAndPer`,`Detection placement, load and per-camera runtime across the cluster.`),actions:i(V,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>c(e=>e+1),title:e(`common.refresh`,`Refresh`),children:[d(se,{className:`h-3.5 w-3.5`}),e(`common.refresh`,`Refresh`)]}),nav:d(jo,{viewMode:r,onNodes:()=>{n({view:`nodes`,node:a},{replace:!0})},onCameras:()=>{n({view:`cameras`},{replace:!0})}}),className:`flex h-full min-h-0 flex-col overflow-hidden`,children:[r===`nodes`&&i(V,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>p(e=>!e),"aria-expanded":l,className:`flex w-full shrink-0 justify-between border-b border-border md:hidden`,children:[i(`span`,{children:[l?e(`pipeline.hide`,`Hide`):e(`pipeline.show`,`Show`),` node list`]}),d(oe,{className:[`h-4 w-4 transition-transform`,l?`rotate-180`:``].join(` `)})]}),d(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden md:flex-row`,children:r===`nodes`?i(o,{children:[d(`aside`,{className:[l?`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(Vn,{selectedNodeId:a,onSelect:e=>{n({view:`nodes`,node:e},{replace:!0}),p(!1)},refreshToken:s})}),d(`section`,{className:`min-h-0 flex-1 overflow-hidden`,children:a===`__cluster__`?d(Ra,{refreshToken:s}):d(li,{nodeId:a,refreshToken:s})})]}):d(`section`,{className:`min-h-0 flex-1 overflow-hidden`,children:d(Do,{refreshToken:s})})})]})}var No=`ctab`,Po=`section`;function Fo(e,t){let n=new URLSearchParams({view:`nodes`,node:ko,[No]:e});return t!==void 0&&n.set(Po,t),`/system/pipeline?${n.toString()}`}function Io(e){return Fo(`settings`,Da(e))}function Lo(){return Fo(`load-balancing`)}var Ro=`pipeline-orchestrator`;function zo(e){return Ee.find(t=>t.stepId===e)??null}function Bo({step:e,engineFormat:t,runnableModelIds:n}){let{t:r}=K(),{data:a}=Kt({addonId:Ro}),o=ve(a??null)[e.stepId]??e.defaultModelId,s=e.options.find(e=>e.id===o)?.label??o,c=n.length>0&&!n.includes(o);return i(`div`,{className:`space-y-2 rounded-md border border-primary/30 bg-primary/5 px-3 py-2`,children:[i(`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:`cluster-wide`}),d(hn,{to:Io(e.stepId),className:`ml-auto text-[11px] text-primary hover:underline`,children:r(`pipeline.clusterStepModel.changeInClusterSettings`,`Change in Cluster → Settings ›`)})]}),i(`p`,{className:B,children:[r(`pipeline.clusterStepModel.oneModelForEveryNode`,`One model for every node and camera:`),` `,e.indexName,` only matches vectors from the model that made them.`]}),c&&i(`p`,{className:`rounded border border-warning/40 bg-warning/10 px-2 py-1 text-[10px] leading-snug text-warning`,children:[`This accelerator's engine (`,t,`) ships no build of `,d(`b`,{children:o}),`. It refuses this step rather than run a different encoder — a substitute would put a second feature space into `,e.indexName,`.`]})]})}export{jr as _,Yr as a,Pr as c,Br as d,Hr as f,Mr as g,Vr as h,Xr as i,Kr as l,zr as m,zo as n,Rr as o,Gr as p,Oo as r,Ur as s,Bo as t,Wr as u,Or as v,Mn as y};
|