@camstack/addon-admin-ui 1.2.429 → 1.2.430

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.
Files changed (123) hide show
  1. package/dist/assets/{AddonAssetIcon-DR35yt0E.js → AddonAssetIcon-BWUL7eDI.js} +1 -1
  2. package/dist/assets/{Addons-gkGgGpTC.js → Addons-2-Q9J_R-.js} +2 -2
  3. package/dist/assets/{AdminPage-DAO24U0w.js → AdminPage-DMiMIHwu.js} +1 -1
  4. package/dist/assets/{AdminSectionedPage-B-qoE6ra.js → AdminSectionedPage-DKH0UpKh.js} +1 -1
  5. package/dist/assets/AiProfiles-DQ5YpTn5.js +3 -0
  6. package/dist/assets/{BrokerForm-B3xs9aBj.js → BrokerForm-wEqc4cpx.js} +1 -1
  7. package/dist/assets/{Build-DeMAJfjN.js → Build-DIaw3f01.js} +4 -4
  8. package/dist/assets/{Calendars-VPH-vy-o.js → Calendars-BpyELuD4.js} +1 -1
  9. package/dist/assets/Cluster-CfJQLikz.js +1 -0
  10. package/dist/assets/ClusterStepModel-B_1igjPf.js +1 -0
  11. package/dist/assets/{CompositionEditor-BrtLjoSu.js → CompositionEditor-DYkQHem0.js} +1 -1
  12. package/dist/assets/{CompositionEditorPage-D51jS9td.js → CompositionEditorPage-DDBZOcqy.js} +1 -1
  13. package/dist/assets/Data-7qDFkx-Q.js +2 -0
  14. package/dist/assets/{DeviceDetail-D1qU_p1k.js → DeviceDetail-Dy2NTHbz.js} +2 -2
  15. package/dist/assets/{DeviceDoActionFields-B62Nv4K7.js → DeviceDoActionFields-DmKzugUt.js} +1 -1
  16. package/dist/assets/{Devices-Cf5Exjsk.js → Devices-COzPWkpB.js} +1 -1
  17. package/dist/assets/{EmbedPlayerPage-CnEcSJ8D.js → EmbedPlayerPage-CD4jAYaX.js} +1 -1
  18. package/dist/assets/Identity-BnBFoIrz.js +1 -0
  19. package/dist/assets/IntegrationDetail-CP91fqQF.js +1 -0
  20. package/dist/assets/{IntegrationHub-DdjWEObX.js → IntegrationHub-DMx7fLHV.js} +1 -1
  21. package/dist/assets/{Integrations-CU7Ll9U_.js → Integrations-Blb_S3_f.js} +1 -1
  22. package/dist/assets/{Integrations-uZB2ozhn.js → Integrations-BzqzbXQ2.js} +1 -1
  23. package/dist/assets/{Library-DSuCaXt6.js → Library-Cqg-Y18g.js} +1 -1
  24. package/dist/assets/Locations-EQXaWxpY.js +3 -0
  25. package/dist/assets/{Logs-cm-1R2Z4.js → Logs-hQ_F2BI5.js} +1 -1
  26. package/dist/assets/{MaskShapeCanvas-CM9D4FOf.js → MaskShapeCanvas-BkBmWJHu.js} +1 -1
  27. package/dist/assets/{MotionZonesSettings-DqS8ndiK.js → MotionZonesSettings-Ctl81l__.js} +1 -1
  28. package/dist/assets/MyAccess-D8vfWKFy.js +2 -0
  29. package/dist/assets/Network-BYFc8leF.js +1 -0
  30. package/dist/assets/{NodeAddonsSettingsPanel-BMat4ckt.js → NodeAddonsSettingsPanel-DMEeQbDW.js} +1 -1
  31. package/dist/assets/{Notifications-EPQiEZ1t.js → Notifications-BtrpoxXL.js} +1 -1
  32. package/dist/assets/{PrivacyMaskSettings-Bis0PO01.js → PrivacyMaskSettings-DEbHPS5X.js} +1 -1
  33. package/dist/assets/Recordings-BrGa72HR.js +1 -0
  34. package/dist/assets/{ScanNetworkModal-dHWFmbFe.js → ScanNetworkModal-CTjVwV69.js} +1 -1
  35. package/dist/assets/{SceneMonitorEditor-SFMMIopn.js → SceneMonitorEditor-DgNqz_fJ.js} +1 -1
  36. package/dist/assets/SessionsList-CzSpm8u5.js +2 -0
  37. package/dist/assets/{Showroom-Er-hes9K.js → Showroom-DC0Rdsfa.js} +1 -1
  38. package/dist/assets/{System-BDXxfgsq.js → System-ByMuYkyz.js} +1 -1
  39. package/dist/assets/{Terminal-B70jnm8e.js → Terminal-CLof2QSK.js} +5 -5
  40. package/dist/assets/{Viewer-BsGL5Dfa.js → Viewer-CLEBXqqR.js} +1 -1
  41. package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-C7iEnSHU.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-CxVe8UPZ.js} +1 -1
  42. package/dist/assets/{addon-icons-context--6Hi3qRW.js → addon-icons-context-B6iVhWXv.js} +1 -1
  43. package/dist/assets/{archive-DtcjevJM.js → archive-WKa1b0o1.js} +1 -1
  44. package/dist/assets/{authed-media-LCmlAEZ5.js → authed-media-B0bKjjhb.js} +1 -1
  45. package/dist/assets/{bell-off-eQBpwamg.js → bell-off-DQeMLsEK.js} +1 -1
  46. package/dist/assets/{board-model-wzCmdEKJ.js → board-model-DIWD11Nh.js} +1 -1
  47. package/dist/assets/{boxes-DikDfAoo.js → boxes-DMqqPR7T.js} +1 -1
  48. package/dist/assets/circle-slash-HW5fnitA.js +1 -0
  49. package/dist/assets/{client-DYbvGOid.js → client-Ck3kx2Z0.js} +3 -3
  50. package/dist/assets/{cloud-upload-DI9XunFf.js → cloud-upload-8Rtciaox.js} +1 -1
  51. package/dist/assets/crop-BCuJfQIp.js +1 -0
  52. package/dist/assets/{device-integration-icon-D2lWVDM2.js → device-integration-icon-BRxzTJPF.js} +1 -1
  53. package/dist/assets/device-picker-model-DUsOqTKW.js +1 -0
  54. package/dist/assets/{dist-ChQzskeX.js → dist-BiqTDJU8.js} +1 -1
  55. package/dist/assets/{dist-CPO0KWoy.js → dist-D4jmeWXJ.js} +3 -3
  56. package/dist/assets/{eraser-Dl5ROV0l.js → eraser-AtBM6hp_.js} +1 -1
  57. package/dist/assets/{file-up-WS3s_T9x.js → file-up-DvSwIdQI.js} +1 -1
  58. package/dist/assets/{hard-drive-download-B1ard6ym.js → hard-drive-download-COMXm0vT.js} +1 -1
  59. package/dist/assets/{history-BMhP0SFG.js → history-CNH6Hwzl.js} +1 -1
  60. package/dist/assets/{hostInit-FCvre9AW.js → hostInit-Cn-rvYrx.js} +1 -1
  61. package/dist/assets/i18n-DWijAvai.js +1 -0
  62. package/dist/assets/{icons-DocdgFuy.js → icons-BzZe_Qg7.js} +1 -1
  63. package/dist/assets/{index-DvOECbab.js → index-IBVizVRk.js} +3 -3
  64. package/dist/assets/{key-B1M6i1mf.js → key-B62K9GgX.js} +1 -1
  65. package/dist/assets/{key-round-yCDTbIQb.js → key-round-DhUJVMTJ.js} +1 -1
  66. package/dist/assets/{layers-c960YTPf.js → layers-BNtkJA8b.js} +1 -1
  67. package/dist/assets/{linked-devices-model-CB7qgVjI.js → linked-devices-model-DXpryeZj.js} +1 -1
  68. package/dist/assets/{list-ordered-C7hEwAd1.js → list-ordered-DE6semVl.js} +1 -1
  69. package/dist/assets/{location-owned-usage-D28vwYJT.js → location-owned-usage-4K4CCW-I.js} +1 -1
  70. package/dist/assets/{log-in-DFfxcqYz.js → log-in-k_3OshGq.js} +1 -1
  71. package/dist/assets/{memory-stick-BBfIGrWx.js → memory-stick--pKqiId8.js} +1 -1
  72. package/dist/assets/{message-square-plus-D8ZUT6rz.js → message-square-plus-DD_p-LBd.js} +1 -1
  73. package/dist/assets/{mf-entry-bootstrap-0-3035e647.js → mf-entry-bootstrap-0-b5dba7ed.js} +2 -2
  74. package/dist/assets/{mic-off-w2mFOBi3.js → mic-off-abkMqo-Z.js} +1 -1
  75. package/dist/assets/{monitor-off-DPi_gm_c.js → monitor-off-Btwz3hik.js} +1 -1
  76. package/dist/assets/{monitor-smartphone-9Ife1Trw.js → monitor-smartphone-CewWbhfo.js} +1 -1
  77. package/dist/assets/mount-DUsOqTKW.js +1 -0
  78. package/dist/assets/{notification-schedule-field-BuLfSYLZ.js → notification-schedule-field-DALe8QBw.js} +1 -1
  79. package/dist/assets/{octagon-alert-C-jH7VH_.js → octagon-alert-B-H38qMt.js} +1 -1
  80. package/dist/assets/{player-overlays-D0U2dNvn.js → player-overlays-CTjp5_0E.js} +1 -1
  81. package/dist/assets/{recycle-Bbki65G2.js → recycle-om2m5njd.js} +1 -1
  82. package/dist/assets/remoteEntry-Dmuue8--.js +1 -0
  83. package/dist/assets/{scan-eye-AfIM_Dlr.js → scan-eye-RPomUFSt.js} +1 -1
  84. package/dist/assets/{scissors-CnL6g0BO.js → scissors-oLO0ZxF2.js} +1 -1
  85. package/dist/assets/{search-x-eqJd3G8u.js → search-x-By7QfPjb.js} +1 -1
  86. package/dist/assets/{send-B72RQ9UL.js → send-CWuZ-VHG.js} +1 -1
  87. package/dist/assets/{settings-2-CXZ6DVRg.js → settings-2-DrkSvhIU.js} +1 -1
  88. package/dist/assets/{speaker-CcCWWecW.js → speaker-Bi1HndpO.js} +1 -1
  89. package/dist/assets/{src-CGxdJN_f.js → src-CoNs4bys.js} +3 -3
  90. package/dist/assets/{timer-reset-B9Lihcw9.js → timer-reset-CX_75T7d.js} +1 -1
  91. package/dist/assets/{ungroup-D753owNE.js → ungroup-CQ9vK9Rb.js} +1 -1
  92. package/dist/assets/{unlink-DzoLNfsq.js → unlink-DRIRCsre.js} +1 -1
  93. package/dist/assets/{usb-CuSU-_EY.js → usb-CSAqtgKZ.js} +1 -1
  94. package/dist/assets/{use-scenes-feed-CZjJNxfD.js → use-scenes-feed-B3oVDWHB.js} +1 -1
  95. package/dist/assets/{use-stationary-objects-BoGqWyLV.js → use-stationary-objects-D8Q3fSKJ.js} +1 -1
  96. package/dist/assets/useEventInvalidation-DUsOqTKW.js +1 -0
  97. package/dist/assets/{useNodeUrlSelection-BA6CgjTU.js → useNodeUrlSelection-CbhdLJkk.js} +1 -1
  98. package/dist/assets/user-round-DhADiv-t.js +1 -0
  99. package/dist/assets/{user-x-PK8sSsso.js → user-x-fVEkryXF.js} +1 -1
  100. package/dist/assets/{video-BBtESt54.js → video-C9XbLIGZ.js} +1 -1
  101. package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-BKfTL-9e.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-CWUvAVp2.js} +2 -2
  102. package/dist/index.html +10 -10
  103. package/dist/server/addon.js +26 -6
  104. package/package.json +1 -1
  105. package/dist/assets/AiProfiles-BXcreqZP.js +0 -3
  106. package/dist/assets/Cluster-B-k0M79z.js +0 -1
  107. package/dist/assets/ClusterStepModel-DaAc_6nI.js +0 -1
  108. package/dist/assets/Data-IfJuKcwc.js +0 -2
  109. package/dist/assets/Identity-DNE80jdX.js +0 -1
  110. package/dist/assets/IntegrationDetail-LKbiJFU3.js +0 -1
  111. package/dist/assets/Locations-BeaznsZS.js +0 -3
  112. package/dist/assets/MyAccess-Dxb11B6h.js +0 -2
  113. package/dist/assets/Network-BCDUHSB0.js +0 -1
  114. package/dist/assets/Recordings-BCeoXxL4.js +0 -1
  115. package/dist/assets/SessionsList-BRTwG3uv.js +0 -2
  116. package/dist/assets/circle-slash-YVgGJTpJ.js +0 -1
  117. package/dist/assets/crop-CxZbpOyK.js +0 -1
  118. package/dist/assets/device-picker-model-C4w1vbly.js +0 -1
  119. package/dist/assets/i18n-Vb3uBp7P.js +0 -1
  120. package/dist/assets/mount-C4w1vbly.js +0 -1
  121. package/dist/assets/remoteEntry-DYVoozgD.js +0 -1
  122. package/dist/assets/useEventInvalidation-C4w1vbly.js +0 -1
  123. package/dist/assets/user-round-CMg3Ndlt.js +0 -1
@@ -0,0 +1 @@
1
+ import{$ as e,B as t,G as n,H as r,J as i,L as a,S as o,b as s,o as c,q as l,x as u}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEHpkaJP.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 ee,pi as N,un as P,yi as te,yn as F}from"./player-overlays-CTjp5_0E.js";import{t as ne}from"./hard-drive-download-COMXm0vT.js";import{t as re}from"./memory-stick--pKqiId8.js";import{t as ie}from"./unlink-DRIRCsre.js";import{$r as ae,Qr as oe,ei as se,ri as ce}from"./client-Ck3kx2Z0.js";import{$l as I,$o as le,An as ue,Bn as L,Dn as de,En as fe,Fs as pe,G as me,Ht as he,Ic as ge,Ko as _e,Lc as ve,Ln as ye,M as be,On as xe,Qs as Se,Rc as Ce,Rn as we,Tn as Te,Tt as Ee,U as De,Us as Oe,Ut as ke,Vt as Ae,Wt as je,Xt as Me,Zn as R,ac as Ne,ar as Pe,cr as Fe,dr as Ie,es as Le,gu as z,ha as Re,hu as ze,jn as Be,kn as Ve,lr as He,ns as Ue,ol as We,qo as Ge,ts as Ke,ur as qe,wt as Je,yu as B,zc as Ye}from"./src-CoNs4bys.js";import{t as V}from"./i18n-DWijAvai.js";import{t as H}from"./useTranslation-D3Is_4B6.js";import{S as Xe,et as Ze}from"./index-IBVizVRk.js";import{t as Qe}from"./AdminPage-DMiMIHwu.js";import{t as $e}from"./NodeAddonsSettingsPanel-DMEeQbDW.js";import{f as et,l as tt,m as nt,u as rt}from"./board-model-DIWD11Nh.js";import{t as U}from"./format-size-DIxKXxtj.js";import{n as it,t as at}from"./useNodeUrlSelection-CbhdLJkk.js";e();var ot={unpaired:`Not paired`,pending:`Pairing…`,paired:`Paired`},st=new Set([`paired`,`rejected`,`failed`,`expired`]);function W(e){return st.has(e)}function ct(e){return e.replace(/\D/g,``).slice(0,6)}function lt(e){return e.length===6}function ut(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 dt(e,t){return e.includes(`:`)?`[${e}]:${t}`:`${e}:${t}`}function ft(e){return e.length<=23?e:`${e.slice(0,20)}…`}function pt({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 mt(e){return e===`awaiting-both`||e===`awaiting-hub`}var ht={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`},gt=2e3,_t=1e3;function vt(e){return e.message.length>0?e.message:V.t(`pairing.agentsFoundSection.requestFailed`)}function yt(e){return e.length===6?`${e.slice(0,3)} ${e.slice(3)}`:e}function bt(e){let[n,r]=i(()=>Date.now());return t(()=>{if(!e)return;let t=setInterval(()=>r(Date.now()),_t);return()=>clearInterval(t)},[e]),n}function xt({target:e,onClose:n,onSettled:r,onOpenNode:a}){let{t:c}=H(),[d,f]=i(null),[p,m]=i(null),[h,g]=i(``),[_,v]=i(null),y=l(null),b=B.agentPairing.beginPairing.useMutation(),x=B.agentPairing.confirmPairing.useMutation(),S=B.agentPairing.rejectPairing.useMutation();t(()=>{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(vt(t))}))},[e]);let C=B.agentPairing.getPairing.useQuery({pairingId:d??``},{enabled:d!==null,refetchInterval:e=>{let t=e.state.data?.state;return t!==void 0&&W(t)?!1:gt}}),w=St(x.data??S.data??null,C.data??null),E=pt({view:w,beginError:p}),D=w!==null&&W(w.state),O=l(!1);t(()=>{if(!D){O.current=!1;return}O.current||(O.current=!0,r())},[D,r]);let k=bt(w!==null&&!D),A=()=>{d===null||!lt(h)||(v(null),x.mutate({pairingId:d,code:h},{onError:e=>{v(vt(e)),g(``)}}))};return u(Te,{open:e!==null,onOpenChange:e=>!e&&n(),children:o(de,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[o(ue,{children:[u(Be,{children:c(`pairing.pairingDialog.title`,{node:e?.nodeId??``})}),u(xe,{children:e===null?``:c(`pairing.pairingDialog.eachScreenShowsACode`,`Each screen shows a code; you type the code from the OTHER screen. Agent at {{value1}}`,{value1:dt(e.host,e.port)})})]}),o(fe,{className:`space-y-4`,children:[u(Ct,{phase:E}),E===`send-failed`&&p!==null&&u(ye,{title:c(`pairing.pairingDialog.couldNotStartThePairing`,`Could not start the pairing`),message:p}),w!==null&&!D&&u(wt,{view:w,phase:E,now:k,typed:h,onType:e=>g(ct(e)),onSubmit:A,confirmError:_,busy:x.isPending}),E===`paired`&&w!==null&&u(Tt,{nodeId:w.nodeId,onOpenNode:a,onClose:n}),D&&E!==`paired`&&w?.failure!=null&&u(ye,{message:w.failure})]}),u(Ve,{children:D||E===`send-failed`?u(L,{type:`button`,variant:`outline`,onClick:n,children:c(`common.close`,`Close`)}):o(s,{children:[u(L,{type:`button`,variant:`outline`,disabled:S.isPending,onClick:()=>{if(d===null){n();return}S.mutate({pairingId:d},{onSettled:n})},children:c(`pairing.pairingDialog.reject`,`Reject`)}),mt(E)&&o(L,{type:`button`,disabled:!lt(h)||x.isPending,onClick:A,children:[x.isPending&&u(T,{className:`h-4 w-4 animate-spin`}),c(`common.confirm`,`Confirm`)]})]})})]})})}function St(e,t){if(t===null)return e;if(e===null)return t;let n=e=>(W(e.state)?10:e.state===`completing`?5:0)+ +!!e.hubConfirmed+ +!!e.agentConfirmed;return n(e)>n(t)?e:t}function Ct({phase:e}){let t=e===`sending`||e===`completing`,n=e===`paired`,r=e===`rejected`||e===`failed`||e===`expired`||e===`send-failed`;return o(`p`,{role:`status`,className:`flex items-center gap-2 text-sm font-medium ${n?`text-success`:r?`text-danger`:`text-foreground`}`,children:[t&&u(T,{className:`h-4 w-4 animate-spin`}),n&&u(O,{className:`h-4 w-4`}),r&&u(w,{className:`h-4 w-4`}),ht[e]]})}function wt({view:e,phase:t,now:n,typed:r,onType:i,onSubmit:a,confirmError:s,busy:c}){let{t:l}=H();return o(`div`,{className:`space-y-4`,children:[o(`section`,{"aria-label":l(`pairing.pairingDialog.codeOnThisHub`,`Code on this hub`),className:`rounded-md border border-border bg-surface p-3`,children:[u(`p`,{className:`text-xs text-foreground-muted`,children:l(`pairing.pairingDialog.codeOnThisHubRead`,`Code on this hub — read it out to the agent`)}),u(`p`,{"data-testid":`hub-code`,className:`mt-1 font-mono text-3xl font-semibold tracking-widest text-foreground`,children:yt(e.code)}),u(`p`,{className:`mt-2 text-xs text-foreground-muted`,children:l(`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).`)})]}),mt(t)?u(`form`,{className:`space-y-2`,onSubmit:e=>{e.preventDefault(),a()},children:u(me,{label:l(`pairing.pairingDialog.codeShownOnTheAgent`,`Code shown on the agent`),description:l(`pairing.pairingDialog.typeTheSixDigitsThe`,`Type the six digits the agent displays. Do not copy the code above.`),...s===null?{}:{error:s},children:u(I,{value:r,onChange:e=>i(e.target.value),inputMode:`numeric`,autoComplete:`off`,spellCheck:!1,placeholder:`000000`,maxLength:6,disabled:c,"aria-label":l(`pairing.pairingDialog.codeShownOnTheAgent`,`Code shown on the agent`),className:`font-mono tracking-widest`})})}):u(`p`,{className:`text-xs text-foreground-muted`,children:t===`awaiting-agent`?l(`pairing.pairingDialog.youConfirmedHereTheAgent`,`You confirmed here. The agent still has to enter the hub code and its PIN.`):l(`pairing.pairingDialog.working`,`Working…`)}),o(`ul`,{className:`flex flex-wrap gap-x-4 gap-y-1 text-xs text-foreground-muted`,children:[u(`li`,{children:e.hubConfirmed?l(`pairing.pairingDialog.hubConfirmed`,`Hub: confirmed`):l(`pairing.pairingDialog.hubNotConfirmed`,`Hub: not confirmed`)}),u(`li`,{children:e.agentConfirmed?l(`pairing.pairingDialog.agentConfirmed`,`Agent: confirmed`):l(`pairing.pairingDialog.agentNotConfirmed`,`Agent: not confirmed`)}),u(`li`,{"data-testid":`countdown`,children:l(`pairing.pairingDialog.expiresIn`,{countdown:ut(e.expiresAt,n)})})]})]})}function Tt({nodeId:e,onOpenNode:t,onClose:n}){let{t:r}=H(),{nodes:i}=ze(),a=i?.some(t=>t.id===e&&t.isOnline)===!0;return o(`div`,{className:`space-y-2 rounded-md border border-success/40 bg-success/10 p-3 text-sm`,children:[o(`p`,{className:`flex items-center gap-2 text-success`,children:[u(M,{className:`h-4 w-4`}),a?r(`pairing.pairingDialog.joinedAndRegisteredItsCapabilities`,`{{nodeId}} joined and registered its capabilities.`,{nodeId:e}):r(`pairing.pairingDialog.holdsItsCertificateWaitingFor`,`{{nodeId}} holds its certificate. Waiting for it to connect and register its capabilities…`,{nodeId:e})]}),u(L,{type:`button`,size:`sm`,variant:`outline`,disabled:!a,onClick:()=>{n(),t(e)},children:r(`pairing.pairingDialog.openNode`,`Open node`)})]})}var Et={paired:`success`,pending:`warning`,unpaired:`default`};function Dt({state:e,connected:t}){let{t:n}=H();return o(`span`,{className:`inline-flex items-center gap-1.5`,children:[u(Pe,{variant:Et[e],className:`text-[10px]`,children:ot[e]}),e===`paired`&&u(`span`,{className:`text-[10px] text-foreground-muted`,children:t?n(`common.connected`):n(`pairing.agentStateBadge.notConnected`,`not connected`)})]})}e();var G={pending:0,unpaired:1,paired:2};function Ot(e){if(e.trim().length===0)return;let t=Number(e);return Number.isInteger(t)&&t>=1&&t<=65535?t:null}function kt({onOpenNode:e}){let{t}=H(),r=R(),a=B.useUtils(),c=B.agentPairing.listDiscoveredAgents.useQuery(void 0,{refetchInterval:15e3}),[l,f]=i(null),[p,m]=i(null),[h,_]=i(!1),[v,y]=i(``),[x,S]=i(``),[C,w]=i(null),[E,D]=i(!1),O=()=>void a.agentPairing.listDiscoveredAgents.invalidate(),k=B.agentPairing.addAgentByAddress.useMutation({onSuccess:()=>{_(!1),y(``),S(``),w(null),O()},onError:e=>w(e.message)}),A=B.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=n(()=>(c.data?.agents??[]).toSorted((e,t)=>G[e.state]-G[t.state]),[c.data]),M=async()=>{D(!0);try{await a.agentPairing.listDiscoveredAgents.fetch({refresh:!0}),O()}finally{D(!1)}},ee=()=>{let e=Ot(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}})},N=async e=>{await r({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}))},P=n(()=>[{key:`node`,header:t(`pairing.agentsFoundSection.node`,`Node`),render:e=>u(`span`,{className:`font-medium text-foreground`,children:e.nodeId}),sortValue:e=>e.nodeId},{key:`address`,header:t(`pairing.agentsFoundSection.address`,`Address`),render:e=>u(`span`,{className:`font-mono text-xs`,children:dt(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=>u(Dt,{state:e.state,connected:e.connected}),sortValue:e=>G[e.state]},{key:`fingerprint`,header:t(`pairing.agentsFoundSection.certificate`,`Certificate`),render:e=>e.fingerprint===null?`—`:u(`span`,{className:`font-mono text-xs`,title:e.fingerprint,children:ft(e.fingerprint)}),sortValue:e=>e.fingerprint},{key:`actions`,header:``,align:`right`,notSortableReason:`Row actions`,render:e=>e.state===`unpaired`?u(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`?u(L,{type:`button`,size:`sm`,variant:`outline`,disabled:A.isPending,onClick:()=>void N(e),children:t(`pairing.agentsFoundSection.unpair2`,`Unpair`)}):null}],[A.isPending,t]);return o(Ae,{headingId:`agents-found`,title:t(`pairing.agentsFoundSection.agentsFoundOnTheNetwork`,`Agents found on the network`),icon:b,testId:`agents-found`,actions:o(s,{children:[o(L,{type:`button`,size:`sm`,variant:`outline`,disabled:E,onClick:()=>void M(),children:[E?u(T,{className:`h-3.5 w-3.5 animate-spin`}):u(F,{className:`h-3.5 w-3.5`}),t(`pairing.agentsFoundSection.scan`,`Scan`)]}),o(L,{type:`button`,size:`sm`,onClick:()=>_(e=>!e),children:[u(g,{className:`h-3.5 w-3.5`}),t(`pairing.agentsFoundSection.addByAddress`,`Add by address`)]})]}),children:[o(`div`,{className:`${d} space-y-3`,children:[u(`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&&o(`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&&ee()},children:[u(me,{label:t(`pairing.agentsFoundSection.address`,`Address`),description:t(`pairing.agentsFoundSection.aPrivateOrLocalAddress`,`A private or local address only.`),...C===null?{}:{error:C},children:u(I,{value:v,onChange:e=>y(e.target.value),placeholder:`192.168.1.50`,"aria-label":t(`pairing.agentsFoundSection.agentAddress`,`Agent address`),autoComplete:`off`})}),u(me,{label:t(`pairing.agentsFoundSection.port`,`Port`),description:t(`pairing.agentsFoundSection.optional`,`Optional.`),children:u(I,{value:x,onChange:e=>S(e.target.value),placeholder:`4444`,inputMode:`numeric`,"aria-label":t(`pairing.agentsFoundSection.agentPort`,`Agent port`),className:`w-24`})}),o(L,{type:`submit`,size:`sm`,className:`mt-5`,disabled:v.trim().length===0||k.isPending,children:[k.isPending&&u(T,{className:`h-3.5 w-3.5 animate-spin`}),t(`common.add`,`Add`)]})]}),p!==null&&u(`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}),c.isError?u(ye,{title:t(`pairing.agentsFoundSection.couldNotListAgents`,`Could not list agents`),message:c.error?.message??t(`pairing.agentsFoundSection.requestFailed`,`Request failed`),onRetry:O}):c.isLoading?u(`p`,{className:`py-4 text-center text-xs text-foreground-muted`,children:t(`pairing.agentsFoundSection.lookingForAgents`,`Looking for agents…`)}):j.length===0?u(we,{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.`)}):u(ke,{columns:P,rows:j,rowKey:e=>e.nodeId,minWidthPx:720,defaultSort:{columnKey:`state`,dir:`asc`}})]}),u(xt,{target:l,onClose:()=>f(null),onSettled:O,onOpenNode:e})]})}function At(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function jt(e){if(!At(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 Mt(e){let t=e.trim();return!(t.length===0||t.includes(`/`)||t.includes(`?`)||t.includes(`#`)||t.includes(`@`)||t.includes(`:`))}function K(e){return e.startsWith(`172.17.`)}function Nt(e){let t=/^100\.(\d+)\./.exec(e);if(t===null)return!1;let n=Number(t[1]);return n>=64&&n<=127}function Pt(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&&!K(e)}function Ft(e,t){if(typeof t==`string`&&Mt(t))return t.trim();let n=e.filter(e=>!e.includes(`:`)),r=n.find(e=>!e.startsWith(`127.`)&&!e.startsWith(`169.254.`)&&!K(e)&&!Nt(e)&&Pt(e));if(r!==void 0)return r;for(let e of n)if(!e.startsWith(`127.`)&&!e.startsWith(`169.254.`)&&!K(e))return e;return null}function It(e){return`http://${e}:4444/`}function Lt(e,t){let n=new URL(It(e));return n.searchParams.set(`ticket`,t),n.toString()}function Rt(){return window.open(`about:blank`,`_blank`)}function zt(e,t){return e===null||e.closed?!1:(e.location.href=t,!0)}function Bt({node:e}){let{info:t}=Xe();return!e.isHub||t===null?u(`span`,{className:`text-sm font-semibold shrink-0`,children:e.name}):o(s,{children:[u(`span`,{className:`text-sm font-semibold shrink-0`,"data-testid":`node-title-name`,children:t.name}),t.name!==e.id&&u(`span`,{className:`text-xs text-foreground-subtle shrink-0`,"data-testid":`node-title-id`,children:e.id})]})}e();function Vt(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 Ht(e){return e===`running`?`running`:e===`crashed`||e===`failed`?`error`:`stopped`}var Ut=[`trace`,`debug`,`info`,`warn`,`error`];function Wt({proc:e,nodeId:t,defaultExpanded:n,activePanel:r,onTogglePanel:a}){let{t:s}=H(),c=e.services??[],l=c.length===1,[d,f]=i(l||n),[p,m]=i(null),[g,_]=i(`info`),v=e.name.includes(`(core)`),y=Le(),b=Ke(),x=Ue(),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 o(`div`,{className:`border border-border/50 rounded-lg overflow-hidden`,children:[o(`div`,{role:l?void 0:`button`,tabIndex:l?void 0:0,onClick:l?void 0:()=>f(!d),onKeyDown:l?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 ${l?``:`hover:bg-muted/40 cursor-pointer`}`,children:[l?u(`span`,{className:`h-3 w-3 shrink-0`}):u(d?te:S,{className:`h-3 w-3 text-muted-foreground shrink-0`}),v?u(P,{className:`h-3.5 w-3.5 text-primary shrink-0`}):u(h,{className:`h-3.5 w-3.5 text-warning shrink-0`}),u(`span`,{className:`text-xs font-semibold min-w-0 flex-1 basis-full truncate sm:basis-auto`,children:e.name}),o(`span`,{className:`text-[10px] text-muted-foreground tabular-nums shrink-0`,children:[`PID `,e.pid]}),u(be,{status:Ht(e.state),label:e.state}),u(`span`,{className:`text-[10px] text-muted-foreground tabular-nums shrink-0`,children:s(`cluster.forksTab.cpu`,{percent:e.cpuPercent})}),u(`span`,{className:`text-[10px] text-muted-foreground tabular-nums shrink-0`,children:U(e.memoryRss)}),u(`span`,{className:`text-[10px] text-muted-foreground tabular-nums shrink-0`,children:Vt(e.uptimeSeconds)}),!v&&o(`div`,{className:`flex items-center gap-1`,onClick:e=>e.stopPropagation(),children:[o(Fe,{children:[u(Ie,{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:s(`cluster.forksTab.setLogLevel`,`Set log level`),children:g}),u(He,{align:`end`,className:`min-w-[70px] py-0.5`,children:Ut.map(e=>u(qe,{onClick:()=>E(e),className:`h-auto px-2 py-1 text-[10px] font-mono ${e===g?`text-primary font-semibold`:``}`,children:e},e))})]}),u(`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:s(`cluster.forksTab.restartProcess`,`Restart process`),children:u(C,{className:`h-3 w-3 ${p===e.name?`animate-spin`:``}`})})]})]}),d&&c.length>0&&u(`div`,{className:`divide-y divide-border/30`,children:c.map(e=>o(`div`,{children:[o(`div`,{className:`flex items-center gap-2 px-3 py-1.5 pl-9 hover:bg-muted/10 transition-colors`,children:[u(`div`,{className:`h-1.5 w-1.5 rounded-full shrink-0 ${e.status===`running`?`bg-success`:`bg-muted-foreground/30`}`}),u(`span`,{className:`text-xs font-medium flex-1 min-w-0 truncate`,children:e.addonId}),e.capabilities.length>0&&o(`div`,{className:`flex gap-1 flex-shrink-0`,children:[e.capabilities.slice(0,3).map(e=>u(`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&&o(`span`,{className:`text-[9px] text-muted-foreground`,children:[`+`,e.capabilities.length-3]})]}),o(`div`,{className:`flex items-center gap-1 shrink-0`,children:[u(`button`,{onClick:()=>a(e.addonId,`logs`),className:`p-0.5 rounded transition-colors ${r?.addonId===e.addonId&&r.type===`logs`?`bg-primary/10 text-primary`:`hover:bg-muted text-muted-foreground hover:text-foreground`}`,title:s(`cluster.forksTab.showLogsFor`,`Show logs for {{addonId}}`,{addonId:e.addonId}),children:u(j,{className:`h-3 w-3`})}),u(`button`,{onClick:()=>a(e.addonId,`events`),className:`p-0.5 rounded transition-colors ${r?.addonId===e.addonId&&r.type===`events`?`bg-primary/10 text-primary`:`hover:bg-muted text-muted-foreground hover:text-foreground`}`,title:s(`cluster.forksTab.showEventsFor`,`Show events for {{addonId}}`,{addonId:e.addonId}),children:u(D,{className:`h-3 w-3`})}),u(`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:s(`cluster.forksTab.restart`,`Restart {{addonId}}`,{addonId:e.addonId}),children:u(C,{className:`h-3 w-3 ${p===e.addonId?`animate-spin`:``}`})})]})]}),r?.addonId===e.addonId&&r.type===`logs`&&u(`div`,{className:`border-t border-border/40 bg-muted/5`,children:u(Ee,{addonId:e.addonId,agentId:t,maxHeight:`max-h-48`,showFilters:!1,onClose:()=>a(e.addonId,`logs`)})}),r?.addonId===e.addonId&&r.type===`events`&&u(`div`,{className:`border-t border-border/40 bg-muted/5`,children:u(Je,{addonId:e.addonId,category:`addon.*`,maxHeight:`max-h-48`,onClose:()=>a(e.addonId,`events`)})})]},e.addonId))}),d&&c.length===0&&u(`div`,{className:`px-3 py-2 pl-9 text-[10px] text-muted-foreground`,children:s(`cluster.forksTab.noServices`,`No services`)})]})}function Gt({nodeId:e,processes:t}){let{t:n}=H(),[r,a]=i(null),o=(e,t)=>{a(n=>n?.addonId===e&&n.type===t?null:{addonId:e,type:t})};return t.length===0?u(`div`,{className:`py-4 text-xs text-muted-foreground text-center`,children:n(`cluster.forksTab.noProcessesOnThisNode`,`No processes on this node`)}):u(`div`,{className:`space-y-2 py-1`,children:t.map((t,n)=>u(Wt,{proc:t,nodeId:e,defaultExpanded:n===0,activePanel:r,onTogglePanel:o},t.name))})}var Kt={system:0,managed:1,root:2};e();function qt(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 Jt(e,t=80){return e.length<=t?e:`…${e.slice(e.length-t+1)}`}function Yt({nodeId:e}){let{t}=H(),r=c(),i=z(`metrics.node-processes-snapshot`,t=>t.nodeId===e),{data:a}=Ge({nodeId:e}),s=i?.processes??a,l=n(()=>s?[...s]:[],[s]),d=n(()=>[{key:`classification`,header:t(`cluster.processesTab.class`,`Class`),sortValue:e=>Kt[e.classification],render:e=>u(`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=>u(`span`,{className:`font-mono`,children:e.pid})},{key:`ppid`,header:`PPID`,align:`right`,sortValue:e=>e.ppid,render:e=>u(`span`,{className:`font-mono text-foreground-subtle`,children:e.ppid})},{key:`addonId`,header:t(`cluster.processesTab.addon`,`Addon`),sortValue:e=>e.addonId,render:e=>u(`span`,{className:`text-foreground-subtle text-[11px]`,children:e.addonId??`—`})},{key:`command`,header:t(`cluster.processesTab.command`,`Command`),nowrap:!1,render:e=>u(`span`,{className:`font-mono text-[10px] text-foreground-subtle break-all`,children:Jt(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=>U(e.memoryRssBytes)},{key:`uptimeSec`,header:t(`cluster.processesTab.uptime`,`Uptime`),align:`right`,sortValue:e=>e.uptimeSec,render:e=>u(`span`,{className:`text-foreground-subtle`,children:qt(e.uptimeSec)})}],[t]);return o(`div`,{className:`space-y-4`,children:[u(`div`,{className:`flex items-start justify-end gap-4`,children:o(`button`,{type:`button`,onClick:()=>r.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:[u(F,{className:`h-3 w-3`}),` `,t(`common.refresh`)]})}),u(ke,{columns:d,rows:l,rowKey:e=>e.pid,minWidthPx:880,maxBodyHeight:je,emptyMessage:t(`cluster.processesTab.scanning`,`Scanning…`)})]})}var q={width:320,height:64},Xt=.8,J=Math.ceil(8*Xt-3)+1,Y=q.width+34,Zt=q.height+J+1+11,Qt=J+q.height+1+3+Math.ceil(8*Xt),$t=[1,2,5,10],en=[1,2,4,8,16,32,64,128,256,512,1024],tn=[1,1.5,2,2.5,3,4,5],nn=[4,3,5,2],rn=1e-9;function an(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 tn.some(e=>Math.abs(t-e)<rn)}let n=e/10**Math.floor(Math.log10(e));return tn.some(e=>Math.abs(n-e)<rn)}function on(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 en){let n=t*e;if(n>=r)return n}return 1024*e}let i=10**Math.floor(Math.log10(r));for(let e of $t){let t=e*i;if(t>=r)return t}return 10*i}function sn(e,t){if(!Number.isFinite(e)||e<=0)return[];let n=nn.find(n=>an(e/n,t))??nn[nn.length-1],r=e/n,i=[];for(let e=1;e<=n;e++)i.push(r*e);return i}var cn=2.5;function ln(e){return e*cn}function un(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 dn(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 fn(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 pn(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 mn(e){return e.length<2?0:Math.max(0,e.at(-1).atMs-e[0].atMs)}function hn(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 gn(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}e();var X={main:`var(--color-chart-series-a)`,gc:`var(--color-chart-series-b)`},Z=q,_n={height:Zt};function vn({title:e,points:t,mainLabel:a,gcLabel:c,formatValue:d,emptyMessage:f,gapMs:p}){let{t:m}=H(),h=r(),g=l(null),[_,v]=i(null),y=n(()=>{let e=t.map(e=>({atMs:e.atMs,value:e.main===null||e.gc===null?null:e.main+e.gc})),n=t.map(e=>({atMs:e.atMs,value:e.main})),r=on(e.map(e=>e.value),25,`linear`),i=un(e,Z,r,p),a=un(n,Z,r,p),o=a.map(e=>({x:e.x,y:e.y===null?null:Z.height,gapBefore:e.gapBefore}));return{max:r,ticks:sn(r,`linear`),upper:i,middle:a,base:o,gaps:hn(i),times:pn(e,Z),spanMs:mn(e)}},[t,p]),b=t.at(-1),x=_===null?void 0:t[_.index],S=x??b;return t.length===0||y.upper.every(e=>e.y===null)?u(Q,{title:e,children:u(An,{message:f})}):u(Q,{title:e,legend:o(s,{children:[u(On,{color:X.main,label:a}),u(On,{color:X.gc,label:c})]}),readout:S&&S.main!==null&&S.gc!==null?o(s,{children:[x!==void 0&&u(Dn,{atMs:x.atMs,spanMs:y.spanMs}),u(kn,{color:X.main,text:d(S.main)}),u(kn,{color:X.gc,text:d(S.gc)})]}):null,children:o(`svg`,{ref:g,viewBox:`0 0 ${Y} ${Zt}`,preserveAspectRatio:`none`,className:`w-full`,style:_n,role:`img`,"aria-label":m(`load.loadChart.andOverTime`,`{{title}}: {{mainLabel}} and {{gcLabel}} over time`,{title:e,mainLabel:a,gcLabel:c}),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=gn(y.upper,n);r!==null&&v({index:r,xPx:y.upper[r].x})},children:[u(bn,{ticks:y.ticks,max:y.max,formatValue:d}),u(En,{ticks:y.times,spanMs:y.spanMs}),o(`g`,{transform:`translate(34,${J})`,clipPath:`url(#${h})`,children:[u(`clipPath`,{id:h,children:u(`rect`,{x:0,y:0,width:Z.width,height:Z.height})}),u(xn,{spans:y.gaps}),u(`path`,{d:fn(y.middle,y.base),fill:X.main,fillOpacity:.85}),u(`path`,{d:fn(y.upper,y.middle),fill:X.gc,fillOpacity:.85,stroke:`var(--color-surface, transparent)`,strokeWidth:2}),u(`path`,{d:dn(y.upper),fill:`none`,stroke:X.gc,strokeWidth:2}),_!==null&&u(`line`,{x1:_.xPx,x2:_.xPx,y1:0,y2:Z.height,stroke:`currentColor`,strokeWidth:1,className:`text-foreground-subtle`})]})]})})}function yn({title:e,points:t,formatValue:r,emptyMessage:a,axisFloor:c,axisScale:d=`linear`,gapMs:f}){let p=l(null),[m,h]=i(null),g=n(()=>{let e=on(t.map(e=>e.value),c,d),n=un(t,Z,e,f);return{max:e,ticks:sn(e,d),projected:n,gaps:hn(n),times:pn(t,Z),spanMs:mn(t)}},[t,c,d,f]),_=m===null?void 0:t[m.index],v=_??t.at(-1)??void 0;return t.length===0||g.projected.every(e=>e.y===null)?u(Q,{title:e,children:u(An,{message:a})}):u(Q,{title:e,readout:v&&v.value!==null?o(s,{children:[_!==void 0&&u(Dn,{atMs:_.atMs,spanMs:g.spanMs}),u(kn,{color:X.main,text:r(v.value)})]}):null,children:o(`svg`,{ref:p,viewBox:`0 0 ${Y} ${Zt}`,preserveAspectRatio:`none`,className:`w-full`,style:_n,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=gn(g.projected,n);r!==null&&h({index:r,xPx:g.projected[r].x})},children:[u(bn,{ticks:g.ticks,max:g.max,formatValue:r}),u(En,{ticks:g.times,spanMs:g.spanMs}),o(`g`,{transform:`translate(34,${J})`,children:[u(xn,{spans:g.gaps}),u(`path`,{d:dn(g.projected),fill:`none`,stroke:X.main,strokeWidth:2}),m!==null&&u(`line`,{x1:m.xPx,x2:m.xPx,y1:0,y2:Z.height,stroke:`currentColor`,strokeWidth:1,className:`text-foreground-subtle`})]})]})})}function bn({ticks:e,max:t,formatValue:n}){let r=t<=0?1:t;return u(`g`,{className:`text-foreground-subtle`,children:e.map(e=>{let t=J+Z.height-e/r*Z.height;return o(`g`,{children:[u(`line`,{x1:34,x2:34+Z.width,y1:t,y2:t,stroke:`currentColor`,strokeWidth:.5,strokeOpacity:.3}),u(`text`,{x:0,y:t+3,fontSize:8,fill:`currentColor`,children:n(e)})]},e)})})}function xn({spans:e}){let{t}=H();return e.length===0?null:u(`g`,{className:`text-foreground-subtle`,children:e.map(e=>u(`rect`,{x:e.fromX,y:0,width:Math.max(1,e.toX-e.fromX),height:Z.height,fill:`currentColor`,fillOpacity:.12,children:u(`title`,{children:t(`load.loadChart.noSamplesInThisInterval`,`No samples in this interval — nothing was measured, nothing is drawn.`)})},`${e.fromX}-${e.toX}`))})}var Sn=10*6e4,Cn={hour:`2-digit`,minute:`2-digit`},wn={hour:`2-digit`,minute:`2-digit`,second:`2-digit`};function Tn(e,t){return new Date(e).toLocaleTimeString(void 0,t<Sn?wn:Cn)}function En({ticks:e,spanMs:t}){return e.length===0?null:u(`g`,{className:`text-foreground-subtle`,children:e.map(e=>u(`text`,{x:34+e.x,y:Qt,fontSize:8,textAnchor:e.anchor,fill:`currentColor`,children:Tn(e.atMs,t)},e.atMs))})}function Dn({atMs:e,spanMs:t}){return u(`span`,{className:`text-[10px] tabular-nums text-foreground-subtle`,children:Tn(e,t)})}function Q({title:e,legend:t,readout:n,children:r}){return o(`div`,{className:`min-w-0`,children:[o(`div`,{className:`flex items-baseline justify-between gap-2 mb-1`,children:[u(`span`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle`,children:e}),u(`div`,{className:`flex items-center gap-2`,children:n})]}),r,t&&u(`div`,{className:`flex items-center gap-3 mt-1`,children:t})]})}function On({color:e,label:t}){return o(`span`,{className:`inline-flex items-center gap-1 text-[9px] text-foreground-subtle`,children:[u(`span`,{className:`inline-block h-2 w-2 rounded-[2px]`,style:{backgroundColor:e}}),t]})}function kn({color:e,text:t}){return o(`span`,{className:`inline-flex items-center gap-1 text-[11px] tabular-nums text-foreground`,children:[u(`span`,{className:`inline-block h-2 w-2 rounded-[2px]`,style:{backgroundColor:e}}),t]})}function An({message:e}){return u(`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 jn(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 Mn(e,t,n,r){let i=e.get(t),a=jn(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 Nn(e,t,n){let r=e;for(let e of ce(t,n))r=Mn(r,e.key,e.kind,e.point);return r}function Pn(e,t){let n=e;for(let e of t)for(let t of e.points)n=Mn(n,e.key,e.kind,t);return n}function Fn(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 In=12e4;function Ln(e,t){return e===null?!1:t-e>In}function Rn(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 zn(e){for(let t of e.values()){let e=t.points.at(-1);if(e&&e.cpuMainPercent!==null)return!0}return!1}var Bn={key:`cpu`,dir:`desc`};function Vn(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 Hn(e){return e.points.at(-1)?.memoryRssBytes??null}function Un(e,t,n){let r=n.trim().toLowerCase();return r===``?!0:e.toLowerCase().includes(r)||t.toLowerCase().includes(r)}function Wn(e,t){return t===`memory`?Hn(e):Vn(e)}function Gn(e,t,n){let r=e.filter(e=>t.selectedKeys.size>0&&!t.selectedKeys.has(e.key)?!1:Un(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=Wn(e,t.sort.key),o=Wn(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})}e();function Kn(e,n=720){let r=z(`metrics.node-processes-snapshot`,t=>t.nodeId===e),[a,o]=i(new Map),[s,c]=i(void 0),u=l(null),{data:d,isPending:f}=_e({forNodeId:e,sinceMs:s,maxPoints:n});t(()=>{d!==void 0&&o(e=>{let t=Pn(e,d.series);return u.current=Fn(t),t})},[d]);let p=r?.timestamp;t(()=>{r==null||p===void 0||(Ln(u.current,p)&&c(u.current??0),o(e=>{let t=Nn(e,r.processes,p);return u.current=Fn(t),t}))},[p]),t(()=>{o(new Map),c(void 0),u.current=null},[e]);let m=0;for(let e of a.values())m=Math.max(m,e.points.length);return{series:Rn(a),sampleCount:m,threadSplitAvailable:zn(a),loadingRetained:f,durable:d?.durable??null,bucketMs:d?.bucketMs??null,cadenceMs:d?.cadenceMs??null,retainedSamples:d?.retainedSamples??null}}var qn=`__unclaimed__`;function Jn(e,t){return{kind:e,deviceId:t,cpu:0,cpuKnown:!0,rss:0,rssKnown:!0,count:0,roles:new Set}}function Yn(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 Xn(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)??Jn(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])=>Yn(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=Jn(`unclaimed`,null);for(let e of a)o.count+=1,o.rss+=e.memoryRssBytes;return o.cpuKnown=!1,[...i,Yn(qn,o)]}var Zn=[{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 Qn(e){return e.attribution===`measured`&&e.wiredToday}function $n(){let e=new Set;for(let t of Zn)Qn(t)&&e.add(t.family);return e}var er=$n();function tr(e){return!er.has(e.role)||e.deviceId===null?!1:e.attribution===`measured`}function nr(e){return`${e.addonId}${e.role}${e.unit}${e.pid??`-`}`}function rr(){return{cpuSeconds:0,cpuKnown:!0,rssBytes:0,rssKnown:!0,unitCount:0,roles:new Set}}function ir(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 ar(e){return Math.round(e*10)/10}function or(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)tr(t)&&i.set(nr(t),t);let a=new Map,o=new Set;for(let n of t.entries){if(!tr(n)||n.deviceId===null)continue;let t=nr(n);o.add(t);let r=a.get(n.deviceId)??rr();r.unitCount+=1,r.roles.add(n.role);let s=ir(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?ar(n.cpuSeconds/r*100):null,rssBytes:n.rssKnown?n.rssBytes:null,unitCount:n.unitCount,roles:[...n.roles].toSorted()}}))}function sr(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 cr(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 lr(e){let t=e.indexOf(`@`);return t===-1?{addonId:e,nodeId:null}:{addonId:e.slice(0,t),nodeId:e.slice(t+1)}}function ur(e,t){let n=lr(e);return n.nodeId===null?t.isHub:n.nodeId===t.nodeId}function dr(e,t){return e.filter(e=>ur(e.addonId,t))}e();function fr(e){let n=z(`metrics.node-processes-snapshot`,t=>t.nodeId===e.nodeId),r=We(void 0,{staleTime:1/0,refetchOnWindowFocus:!1}),[a,o]=i(new Map),s=l(null),c=l(r.refetch);c.current=r.refetch;let u=n?.timestamp;t(()=>{u!==void 0&&c.current()},[u]),t(()=>{o(new Map),s.current=null},[e.nodeId,e.isHub]);let d=r.data,f=r.dataUpdatedAt;t(()=>{if(d===void 0||f===0)return;let t={atMs:f,entries:dr(d,e)},n=s.current;if(s.current=t,n===null)return;let r=or(n,t);r.length!==0&&o(e=>sr(e,r))},[d,f,e.nodeId,e.isHub]);let p=d===void 0?[]:dr(d,e),m=n?.processes,h=Xn(p,m);return{series:cr(a),unclaimed:h.find(e=>e.kind===`unclaimed`)??null,loading:r.isPending,error:r.error===null?null:r.error.message}}function pr(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 mr=25,hr=64*1024*1024,gr=1e4;function _r({scope:e,cadenceMs:t}){let{t:n}=H(),r=fr(e),{data:i=[]}=Re({isCamera:!0,projection:`slim`}),a=pr(i),s=ln(t??gr);return o(`section`,{className:`space-y-3`,children:[r.error!==null&&o(`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:[u(m,{className:`h-3 w-3 mt-0.5 shrink-0`}),u(`span`,{children:n(`cameraLoad.readFailed`,`Could not read the load contributions: {{error}}. This is a failed read, NOT an idle cluster.`,{error:r.error})})]}),u(yr,{unclaimed:r.unclaimed}),r.series.length===0&&r.error===null&&u(`div`,{className:`rounded-md border border-dashed border-border px-3 py-6 text-center text-[11px] text-foreground-subtle`,children:r.loading?n(`cameraLoad.loading`,`Reading what the addons report…`):n(`cameraLoad.waitingWindow`,`No per-camera window yet.`)}),u(`div`,{className:`space-y-3`,children:r.series.map(e=>o(`div`,{className:`rounded-lg border border-border p-3`,children:[o(`div`,{className:`flex items-baseline justify-between gap-2 mb-2`,children:[u(vr,{deviceId:e.deviceId,name:a.get(e.deviceId)}),u(`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(`, `)})})]}),o(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[u(yn,{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:mr,gapMs:s,emptyMessage:n(`cameraLoad.cpuUnavailable`,`No measurable window yet.`)}),u(yn,{title:n(`cameraLoad.memoryTitle`,`Memory RSS`),points:e.points.map(e=>({atMs:e.atMs,value:e.rssBytes})),formatValue:U,axisFloor:hr,axisScale:`bytes`,gapMs:s,emptyMessage:n(`cameraLoad.memoryUnavailable`,`No memory reported.`)})]})]},e.deviceId))})]})}function vr({deviceId:e,name:t}){let{t:n}=H();return t===void 0?u(`span`,{className:`text-xs font-medium text-foreground`,children:n(`cameraLoad.deviceLabel`,`Camera {{deviceId}}`,{deviceId:e})}):o(`span`,{className:`flex items-baseline gap-1.5 min-w-0`,children:[u(`span`,{className:`text-xs font-medium text-foreground truncate`,children:t}),o(`span`,{className:`shrink-0 text-[10px] font-mono text-foreground-subtle`,children:[`#`,e]})]})}function yr({unclaimed:e}){let{t}=H();return e===null||e.unitCount===0?null:u(`div`,{className:`flex items-center gap-2`,children:u(`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?`—`:U(e.rssBytes)})})})}e();var br=256*1024*1024,xr=1e4;function Sr({nodeId:e,isHub:t}){let{t:r}=H(),{series:a,sampleCount:s,threadSplitAvailable:c,loadingRetained:l,bucketMs:d,cadenceMs:f}=Kn(e),[p,h]=i(``),[g,_]=i(new Set),[v,y]=i(Bn),b=e=>e.key===`__root__`?r(`clusterLoad.bucketRoot`,`Node supervisor`):e.key===`__unattributed__`?r(`clusterLoad.bucketUnattributed`,`Unattributed processes`):e.key,x=ln(d??f??xr),S=n(()=>Gn(a,{search:p,selectedKeys:g,sort:v},b),[a,p,g,v]),C=e=>{_(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})};return o(`div`,{className:`space-y-4`,children:[u(Cr,{bucketMs:d,cadenceMs:f}),!c&&s>0&&o(`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:[u(m,{className:`h-3 w-3 mt-0.5 shrink-0`}),u(`span`,{children:r(`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.`)})]}),s===0&&u(`div`,{className:`rounded-md border border-dashed border-border px-3 py-6 text-center text-[11px] text-foreground-subtle`,children:l?r(`clusterLoad.loadingRetained`,`Reading the retained series from this node…`):r(`clusterLoad.waitingFirstSample`,`No retained samples for this node — waiting for the next snapshot (up to 20s). The chart needs two to draw a rate.`)}),a.length>0&&o(`div`,{className:`space-y-2`,children:[o(`div`,{className:`flex flex-wrap items-center gap-2`,children:[o(`label`,{className:`relative flex-1 min-w-[160px]`,children:[u(k,{className:`pointer-events-none absolute left-2 top-1/2 h-3 w-3 -translate-y-1/2 text-foreground-subtle`}),u(`input`,{type:`search`,value:p,onChange:e=>h(e.target.value),placeholder:r(`clusterLoad.searchPlaceholder`,`Find a runner…`),"aria-label":r(`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`})]}),u(wr,{sort:v,onChange:y})]}),o(`div`,{className:`flex flex-wrap items-center gap-1`,children:[a.map(e=>{let t=g.has(e.key);return u(`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&&o(`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:[u(A,{className:`h-2.5 w-2.5`}),r(`clusterLoad.clearFilter`,`All runners`)]})]})]}),a.length>0&&S.length===0&&u(`div`,{className:`rounded-md border border-dashed border-border px-3 py-6 text-center text-[11px] text-foreground-subtle`,children:r(`clusterLoad.noMatches`,`No runner matches this search on {{count}} present. The node is reporting — the filter is hiding them.`,{count:a.length})}),u(`div`,{className:`space-y-3`,children:S.map(e=>o(`div`,{className:`rounded-lg border border-border p-3`,children:[o(`div`,{className:`flex items-baseline justify-between gap-2 mb-2`,children:[u(`span`,{className:`text-xs font-medium text-foreground`,children:b(e)}),u(`span`,{className:`text-[10px] text-foreground-subtle`,children:r(`clusterLoad.processCount`,`{{count}} process(es)`,{count:e.points.at(-1)?.processCount??0})})]}),o(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[u(vn,{title:c?r(`clusterLoad.cpuTitle`,`CPU % of one core`):r(`clusterLoad.cpuTitleLifetime`,`CPU % (ps lifetime average)`),mainLabel:r(`clusterLoad.seriesMain`,`Main threads`),gcLabel:r(`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:r(`clusterLoad.cpuUnavailable`,`No thread split on this node. Lifetime average: {{avg}}%`,{avg:(e.points.at(-1)?.cpuLifetimePercent??0).toFixed(1)})}),u(yn,{title:r(`clusterLoad.memoryTitle`,`Memory RSS`),points:e.points.map(e=>({atMs:e.atMs,value:e.memoryRssBytes})),formatValue:U,axisFloor:br,axisScale:`bytes`,gapMs:x,emptyMessage:r(`clusterLoad.memoryUnavailable`,`No memory samples yet.`)})]})]},e.key))}),u(_r,{scope:{nodeId:e,isHub:t},cadenceMs:f})]})}function Cr({bucketMs:e,cadenceMs:t}){let{t:n}=H();return e===null?null:u(`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 wr({sort:e,onChange:t}){let{t:n}=H(),r=[{key:`cpu`,label:n(`clusterLoad.sortCpu`,`CPU`)},{key:`memory`,label:n(`clusterLoad.sortMemory`,`Memory`)},{key:`name`,label:n(`clusterLoad.sortName`,`Name`)}];return o(`div`,{className:`flex items-center gap-1`,children:[u(`span`,{className:`text-[10px] text-foreground-subtle`,children:n(`clusterLoad.sortBy`,`Sort by`)}),r.map(n=>{let r=e.key===n.key;return o(`button`,{type:`button`,"aria-pressed":r,onClick:()=>t(r?{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 ${r?`border-primary bg-primary/10 text-primary`:`border-border text-foreground-subtle hover:text-foreground`}`,children:[n.label,r&&(e.dir===`desc`?` ↓`:` ↑`)]},n.key)})]})}var Tr=`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 Er({nodeId:e,addonIds:t}){let{t:n}=H();return t.length===0?u(`div`,{className:`py-4 text-xs text-muted-foreground text-center`,children:n(`cluster.nodeDetailSettingsTab.noAddonsOnThisNode`,`No addons on this node`)}):u(`div`,{className:`w-full py-2`,children:u($e,{nodeId:e,addonIds:t,level:`global`,fieldScope:`perNode`,emptyMessage:Tr,selfTabbed:!0})})}e();function Dr({nodeId:e,addons:t}){let{t:r}=H(),i=c(),{data:a,isLoading:o}=pe({nodeId:e}),s=n(()=>{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]),l=Ne({onSuccess:()=>{i.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCapabilityBindings`]]})}});return s.length===0?u(`div`,{className:`py-4 text-xs text-muted-foreground text-center`,children:r(`cluster.nodeDetailCapabilitiesTab.noCapabilitiesOnThisNode`,`No capabilities on this node`)}):u(ke,{columns:[{key:`capName`,header:r(`cluster.nodeDetailCapabilitiesTab.capability`,`Capability`),width:`w-1/2`,sortValue:e=>e.capName,render:e=>u(`span`,{className:`font-medium`,children:e.capName})},{key:`provider`,header:r(`cluster.nodeDetailCapabilitiesTab.boundProvider`,`Bound provider`),render:t=>{let n=a?.[t.capName]??t.providers[0]??``,i=t.providers.length===1;return u(`select`,{value:n,onChange:n=>l.mutate({nodeId:e,capName:t.capName,addonId:n.target.value}),disabled:i||l.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:i?r(`cluster.nodeDetailCapabilitiesTab.onlyOneProviderInstalledChoice`,`Only one provider installed — choice becomes available once a second addon registers this capability`):void 0,children:t.providers.map(e=>u(`option`,{value:e,children:e},e))})}}],rows:s,rowKey:e=>e.capName,minWidthPx:520,maxBodyHeight:je})}e();function Or(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 kr(e){let{t}=H(),[n,r]=i(!1),[a,s]=i(e.name),l=c(),d=le({onSuccess:()=>{l.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){r(!1);return}try{await d.mutateAsync({nodeId:e.nodeId,name:a.trim()}),r(!1)}catch(e){console.error(`Rename failed:`,e)}},h=[[`Node ID`,u(`span`,{className:`font-mono text-xs`,children:e.nodeId})],[`Display Name`,n?o(`div`,{className:`flex items-center gap-1.5`,children:[u(`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=>s(e.target.value),onKeyDown:e=>{e.key===`Enter`&&m(),e.key===`Escape`&&r(!1)},disabled:d.isPending,autoFocus:!0}),u(`button`,{onClick:()=>void m(),disabled:d.isPending,className:`p-0.5 text-success hover:bg-success/10 rounded`,title:t(`common.save`,`Save`),children:u(E,{className:`h-3.5 w-3.5`})}),u(`button`,{onClick:()=>r(!1),className:`p-0.5 text-muted-foreground hover:bg-muted rounded`,title:t(`common.cancel`,`Cancel`),children:u(A,{className:`h-3.5 w-3.5`})})]}):o(`div`,{className:`flex items-center gap-1.5`,children:[u(`span`,{className:`text-xs`,children:e.name}),!e.isHub&&u(`button`,{onClick:()=>{s(e.name),r(!0)},className:`p-0.5 text-muted-foreground hover:text-primary rounded`,title:t(`cluster.nodeInfoTab.rename`,`Rename`),children:u(_,{className:`h-3 w-3`})})]})],[`Hostname`,u(`span`,{className:`text-xs`,children:e.hostname})],[`Role`,e.isHub?u(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-primary/10 text-primary font-medium`,children:t(`cluster.nodeInfoTab.hub`,`Hub`)}):u(`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?o(`span`,{className:`font-mono text-xs`,children:[e.rootPackage.name,`@`,e.rootPackage.version]}):u(`span`,{className:`text-xs text-muted-foreground`,children:`—`})],[`Platform`,o(`span`,{className:`text-xs`,children:[e.platform,` / `,e.arch]})],[`CPU`,o(`span`,{className:`text-xs`,children:[e.cpuModel??`—`,` (`,t(`cluster.nodeInfoTab.cores`,{count:e.cpuCores}),`)`]})],[`Memory`,u(`span`,{className:`text-xs`,children:e.memoryMB>0?t(`cluster.nodeInfoTab.gb`,`{{value1}} GB`,{value1:(e.memoryMB/1024).toFixed(1)}):`—`})],[`Uptime`,u(`span`,{className:`text-xs`,children:Or(e.uptime)})],[`Engines`,e.engines.length>0?u(`div`,{className:`flex flex-wrap gap-1`,children:e.engines.map(e=>u(`span`,{className:`text-[9px] px-1.5 py-0.5 rounded-full bg-primary/10 text-primary font-medium`,children:e},e))}):u(`span`,{className:`text-xs text-muted-foreground`,children:`—`})]];return f.length>0&&h.push([`IPv4`,u(`div`,{className:`flex flex-wrap gap-1.5`,children:f.map((e,t)=>u(`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`,u(`div`,{className:`flex flex-wrap gap-1.5`,children:p.map((e,t)=>u(`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}`))})]),u(`div`,{className:`py-2`,children:u(`table`,{className:`w-full text-sm`,children:u(`tbody`,{children:h.map(([e,t],n)=>o(`tr`,{className:n%2==0?`bg-muted/20`:``,children:[u(`td`,{className:`py-1.5 px-2 text-xs font-medium text-muted-foreground w-28 align-top whitespace-nowrap`,children:e}),u(`td`,{className:`py-1.5 px-2`,children:t})]},e))})})})}e();function Ar({nodeId:e,value:n,detectedHosts:r,status:a,errorMessage:s,onCommit:c}){let{t:l}=H(),[d,f]=i(n??``);t(()=>{f(n??``)},[n]);let p=r[0],m=p===void 0?`auto-detect`:`auto: ${p}`,h=a===`pending`,g=d.trim(),_=g!==(n??``),v=_&&!h,y=()=>{v&&c(e,g.length>0?g:null)};return o(`div`,{className:`flex items-center gap-1.5`,children:[u(I,{"aria-label":l(`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(n??``)},className:`w-36`}),o(L,{variant:`outline`,size:`sm`,onClick:y,disabled:!v,"aria-label":l(`placementBoard.reachableHostInput.saveReachableHostFor`,`Save reachable host for {{nodeId}}`,{nodeId:e}),title:l(`placementBoard.reachableHostInput.saveReachableHost`,`Save reachable host`),children:[h?u(T,{className:`h-3 w-3 animate-spin`,"aria-hidden":`true`}):u(E,{className:`h-3 w-3`,"aria-hidden":`true`}),l(`common.save`,`Save`)]}),!_&&!h&&a===`success`&&u(E,{className:`h-3.5 w-3.5 shrink-0 text-success`,"aria-label":l(`placementBoard.reachableHostInput.saved`,`Saved`),role:`img`}),a===`error`&&u(`span`,{title:s??l(`placementBoard.reachableHostInput.failedToSaveReachableHost`,`Failed to save reachable host`),children:u(N,{className:`h-3.5 w-3.5 shrink-0 text-danger`,"aria-label":s??l(`placementBoard.reachableHostInput.failedToSaveReachableHost`,`Failed to save reachable host`),role:`img`})})]})}e();function jr(e){let t=ae.safeParse(et(e,`color`));return t.success?t.data:null}function Mr(e,t){return t.variables?.agentNodeId===e?t.isPending?`pending`:t.isError?`error`:t.isSuccess?`success`:`idle`:`idle`}function Nr({nodeId:e,detectedHosts:t}){let{t:r}=H(),i=c(),a=Oe(void 0),s=Se({onSuccess:()=>tt(i)}),l=Se({onSuccess:()=>tt(i)}),d=n(()=>a.data?.find(t=>t.nodeId===e)?.settings,[a.data,e]),f=jr(d)??(a.isLoading?null:se(e)),p=nt(d,`reachableHost`),m=Mr(e,s),h=m===`error`?rt(s.error):null,g=t.filter(e=>!e.includes(`:`)),_=t=>{t!==f&&l.mutate({agentNodeId:e,color:t})};return o(`div`,{className:`rounded-lg border border-border bg-surface/40 divide-y divide-border px-3`,children:[u(he,{label:r(`nodes.general.nodeColour`,`Node colour`),children:u(`div`,{role:`group`,"aria-label":r(`nodes.general.nodeColourGroup`,`Node colour`),className:`flex flex-wrap gap-2`,children:oe.map(e=>{let t=f===e;return u(L,{type:`button`,role:`radio`,"aria-checked":t,"aria-label":e,variant:`outline`,size:`sm`,disabled:a.isLoading||l.isPending,title:e,onClick:()=>_(e),className:`h-6 w-6 min-w-6 shrink-0 rounded-full border-0 p-0 ${Me(e)} ${t?`ring-2 ring-primary ring-offset-2 ring-offset-background`:`opacity-80 hover:opacity-100`}`,children:u(`span`,{className:`sr-only`,children:e})},e)})})}),u(he,{label:r(`nodes.general.reachableHost`,`Reachable host`),children:u(Ar,{nodeId:e,value:p,detectedHosts:g,status:m,errorMessage:h,onCommit:(e,t)=>{s.mutate({agentNodeId:e,reachableHost:t})}})})]})}e();var Pr=[[`serverManagement`,`getServerPackageStatus`]];function Fr({label:e,tone:t}){return u(`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 o(`div`,{className:`flex items-center justify-between gap-4 text-sm`,children:[u(`span`,{className:`text-foreground-subtle`,children:e}),u(`span`,{className:`font-mono text-foreground`,children:t??`—`})]})}function Ir({runningVersion:e,latestVersion:t,seedVersion:n,nodeRuntimeVersion:r,labelRunning:i,labelLatest:a,labelSeed:s,labelRuntime:c}){return u(`div`,{className:`flex flex-wrap gap-x-3 gap-y-1 text-sm`,children:[{key:`running`,label:i,value:e},{key:`latest`,label:a,value:t},{key:`seed`,label:s,value:n},{key:`runtime`,label:c,value:r}].map(({key:e,label:t,value:n})=>o(`span`,{className:`inline-flex items-baseline gap-1`,children:[u(`span`,{className:`text-foreground-subtle`,children:t}),u(`span`,{className:`font-mono text-foreground`,children:n??`—`})]},e))})}var Lr={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 Rr(e){return e.outcome===`failed`?`error`:(e.outcome,e.accepted?`ok`:`warn`)}function zr(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 Br({node:e}){let{t}=H(),n=c(),r=R(),[s,l]=i(!1),[d,f]=i(null),p=e.isHub?void 0:{nodeId:e.id},m=Ce(p,{refetchInterval:1e4,enabled:e.isOnline,retry:1}),h=m.data??null,g=a(()=>{n.invalidateQueries({queryKey:Pr})},[n]),_=ve({onSettled:g}),v=ge({onSettled:g}),y=Ye({onSettled:g}),b=a(async()=>{if(h?.latestVersion==null){f({tone:`warn`,text:t(`serverManagement.outcomeNoTarget`,`No target version is known for this node — run "Check for update" first.`)});return}if(await r({title:t(`serverManagement.confirmUpdateTitle`,`Update node root package`),message:t(`serverManagement.confirmUpdateBody`,`Install {{pkg}}@{{version}} on "{{node}}" and restart to apply.`,{pkg:h.packageName,version:h.latestVersion,node:e.name}),confirmLabel:t(`serverManagement.confirmUpdateAction`,`Update & restart`)})){f(null);try{let e=await v.mutateAsync({version:h.latestVersion,...p});f({tone:Rr(e),text:e.message}),e.restarting&&l(!0)}catch(e){f({tone:`warn`,text:zr(t,e)})}}},[v,r,e.name,p,h,t]),S=a(async()=>{if(await r({title:t(`serverManagement.confirmRestartTitle`,`Restart node`),message:t(`serverManagement.confirmRestartBody`,`Restart "{{node}}"? In-flight requests to this node are dropped.`,{node:e.name}),confirmLabel:t(`serverManagement.confirmRestartAction`,`Restart`),variant:`warning`})){f(null);try{let e=await y.mutateAsync(p);f({tone:Rr(e),text:e.message}),e.restarting&&l(!0)}catch(e){f({tone:`warn`,text:zr(t,e)})}}},[r,e.name,y,p,t]),w=()=>{switch(h?.bootMode){case`data-root`:return{label:t(`serverManagement.bootDataRoot`,`runtime-updatable`),tone:`ok`};case`workspace`:return{label:t(`serverManagement.bootWorkspace`,`dev workspace`),tone:`info`};default:return{label:t(`serverManagement.bootBaked`,`baked image seed`),tone:`neutral`}}},E=()=>{if(h==null)return null;switch(h.updateState){case`checking`:return{label:t(`serverManagement.stateChecking`,`checking…`),tone:`info`};case`staging`:return{label:t(`serverManagement.stateStaging`,`updating…`),tone:`info`};case`pending-restart`:return{label:t(`serverManagement.statePending`,`restart pending`),tone:`warn`};default:return h.restartRequired===!0?{label:t(`serverManagement.stateRestartRequired`,`restart required`),tone:`warn`}:h.updateAvailable?{label:t(`serverManagement.stateUpdateAvailable`,`update available`),tone:`warn`}:{label:t(`serverManagement.stateUpToDate`,`up to date`),tone:`ok`}}},D=h?.bootMode===`workspace`,O=e.isOnline&&h!=null&&!D&&h.updateAvailable&&h.updateState===`idle`&&!v.isPending,k=e.isOnline&&h!=null&&h.updateState===`idle`&&!y.isPending,A=e.isOnline?E():null;return o(`div`,{className:`space-y-4 py-2`,children:[o(`div`,{className:`flex items-center justify-between gap-3`,children:[o(`div`,{className:`flex items-center gap-2 min-w-0`,children:[u(`span`,{className:`font-mono text-xs text-foreground-subtle truncate`,children:h?.packageName??e.rootPackage?.name??`@camstack/server`}),e.isOnline&&h!=null&&u(Fr,{...w()})]}),A!=null&&u(Fr,{...A})]}),!e.isOnline&&u($,{label:t(`serverManagement.lastReportedVersion`,`Last reported version`),value:e.rootPackage?.version??null}),e.isOnline&&m.isLoading&&o(`div`,{className:`flex items-center gap-2 text-sm text-foreground-subtle`,children:[u(T,{className:`h-4 w-4 animate-spin`}),t(`common.loading`,`Loading…`)]}),e.isOnline&&m.isError&&o(`div`,{className:`space-y-1.5`,children:[u(`p`,{className:`text-sm text-danger`,children:t(`serverManagement.loadError`,`Could not load the node root-package status.`)}),e.rootPackage!=null&&u($,{label:t(`serverManagement.lastReportedVersion`,`Last reported version`),value:e.rootPackage.version})]}),e.isOnline&&h!=null&&o(`div`,{className:`space-y-1.5`,children:[u(Ir,{runningVersion:h.runningVersion,latestVersion:h.latestVersion,seedVersion:h.seedVersion,nodeRuntimeVersion:h.nodeRuntimeVersion,labelRunning:t(`serverManagement.runningVersionShort`,`Running`),labelLatest:t(`serverManagement.latestVersionShort`,`Latest`),labelSeed:t(`serverManagement.imageSeedShort`,`Seed`),labelRuntime:t(`serverManagement.nodeRuntimeVersionShort`,`Node.js`)}),h.pendingVersion!=null&&u($,{label:t(`serverManagement.pendingVersion`,`Staged (applies on restart)`),value:h.pendingVersion}),h.installedVersion!=null&&h.installedVersion!==h.runningVersion&&u($,{label:t(`serverManagement.installedVersion`,`Installed on disk (runs after restart)`),value:h.installedVersion})]}),e.isOnline&&h?.imageContract?.state===`behind-series`&&o(`div`,{className:`rounded-md border border-danger/40 bg-danger/10 px-3 py-2 text-xs leading-relaxed text-danger`,children:[u(`p`,{className:`mb-0.5 font-semibold`,children:t(`serverManagement.imageContractDiverged`,`Container image diverges from the deployment contract`)}),u(`p`,{children:h.imageContract.message})]}),e.isOnline&&D&&u(`p`,{className:`text-xs text-foreground-subtle`,children:t(`serverManagement.workspaceNote`,`Development workspace detected — runtime updates are disabled (the dev loop resolves code from the workspace).`)}),d!=null&&u(`p`,{role:`status`,className:`rounded border px-2 py-1.5 text-xs leading-relaxed ${Lr[d.tone]}`,children:d.text}),s&&o(`div`,{className:`flex items-center gap-2 text-sm text-warning`,children:[u(T,{className:`h-4 w-4 animate-spin`}),t(`serverManagement.nodeRestarting`,`The node is restarting to apply the change…`)]}),e.isOnline&&o(`div`,{className:`flex flex-wrap items-center gap-2 pt-1`,children:[o(`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?u(T,{className:`h-3.5 w-3.5 animate-spin`}):u(F,{className:`h-3.5 w-3.5`}),t(`serverManagement.checkForUpdate`,`Check for update`)]}),O&&o(`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?u(T,{className:`h-3.5 w-3.5 animate-spin`}):u(x,{className:`h-3.5 w-3.5`}),t(`serverManagement.updateTo`,`Update to {{version}}`,{version:h?.latestVersion??``})]}),o(`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?u(T,{className:`h-3.5 w-3.5 animate-spin`}):u(C,{className:`h-3.5 w-3.5`}),t(`serverManagement.restart`,`Restart`)]})]}),e.isOnline&&h?.lastCheckedAtMs!=null&&o(`p`,{className:`flex items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[u(ne,{className:`h-3 w-3`}),t(`serverManagement.lastChecked`,`Last checked: {{when}}`,{when:new Date(h.lastCheckedAtMs).toLocaleString()})]})]})}e();function Vr(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 Hr({node:e}){let{t}=H(),r=ee(),l=c(),d=R(),[m,h]=i(!1),[g,_]=i(`info`),[v,b]=i(!1),[x,S]=i(null),C=e.processes??[],w=e.addons.map(e=>e.id),T=Oe(void 0),E=n(()=>{let t=T.data?.find(t=>t.nodeId===e.id);return Vr(t?.settings)},[T.data,e.id]),[D,O]=i(!1),[k,A]=i(null),[j,M]=i(null),N=a(async()=>{if(D||e.isHub)return;let t=Ft(e.localIps??[],E);if(t===null){A(`No LAN IPv4 on this node — open its :4444 URL by hand.`),M(null);return}let n=Rt();O(!0),A(null),M(null);try{let i=jt(await r.trpcClient.addons.custom.mutate({addonId:`system-config`,action:`mintAgentUiUnlockTicket`,input:{nodeId:e.id,dashboardBaseUrl:It(t)}})),a=i===null?null:i.dashboardUrl??Lt(t,i.ticket);if(a===null){n?.close(),A(`Hub did not return an unlock ticket.`);return}zt(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)}},[e.id,e.isHub,e.localIps,D,E,r.trpcClient]),P=async()=>{if(!v){b(!0),S(null);try{await r.trpcClient.pipelineOrchestrator.removeAgentSettings.mutate({agentNodeId:e.id}).catch(()=>void 0);let t=await r.trpcClient.clusterNodes.forgetNode.mutate({nodeId:e.id});S({tone:t.stillListed?`warn`:`ok`,text:t.message}),t.stillListed||l.invalidateQueries({queryKey:[[`nodes`,`topology`]]})}catch(e){S({tone:`warn`,text:t(`cluster.nodeCard.forgetFailed`,{error:e instanceof Error?e.message:String(e)})})}finally{b(!1)}}},te=async()=>{if(!m&&await d({title:t(`cluster.nodeCard.unpair`,`Unpair {{name}}`,{name:e.name}),message:t(`cluster.nodeCard.unpairItDisconnectsAndMust`,`Unpair {{name}}? It disconnects and must be paired again.`,{name:e.name}),confirmLabel:t(`cluster.nodeCard.unpair2`,`Unpair`),variant:`danger`})){h(!0),S(null);try{let t=await r.trpcClient.agentPairing.unpairAgent.mutate({nodeId:e.id});S({tone:t.agentNotified?`ok`:`warn`,text:`${t.nodeId}: ${t.next}${t.agentNotified?``:` The agent could not be told; forget the hub on its own page.`}`}),l.invalidateQueries({queryKey:[[`nodes`,`topology`]]})}catch(e){S({tone:`warn`,text:t(`cluster.nodeCard.unpairFailed`,{error:e instanceof Error?e.message:String(e)})})}finally{h(!1)}}},F=e.isHub?null:o(L,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>void te(),disabled:m,title:t(`cluster.nodeCard.unpairThisNodeRevokesIts`,`Unpair this node — revokes its certificates; it must be paired again to rejoin`),children:[u(ie,{className:`h-3 w-3`,"aria-hidden":!0}),m?t(`cluster.nodeCard.unpairing`,`Unpairing…`):t(`cluster.nodeCard.unpair2`,`Unpair`)]});return e.isOnline?o(`div`,{className:`border border-border rounded-xl`,children:[o(`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:[o(`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:[u(`div`,{className:`w-2.5 h-2.5 rounded-full bg-success shrink-0`}),u(Bt,{node:e}),o(`span`,{className:`text-xs text-muted-foreground min-w-0 truncate`,children:[e.cpuModel??e.platform,` ·`,` `,e.memoryMB>0?t(`cluster.nodeCard.gb`,`{{value1}}GB`,{value1:Math.round(e.memoryMB/1024)}):``,` `,`· `,e.arch]})]}),e.engines.map(e=>u(`span`,{className:`text-[9px] px-1.5 py-0.5 rounded-full bg-primary/10 text-primary font-medium shrink-0`,children:e},e)),o(`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:[!e.isHub&&o(`button`,{type:`button`,onClick:()=>void N(),disabled:D,title:t(`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:[u(y,{className:`h-3 w-3`}),D?t(`cluster.nodeCard.opening`,`Opening…`):t(`cluster.nodeCard.openDashboard`,`Open dashboard`)]}),F,o(`span`,{className:`flex items-center gap-1`,children:[u(p,{className:`h-3 w-3`}),` `,e.cpuPercent,`%`]}),o(`span`,{className:`flex items-center gap-1`,children:[u(re,{className:`h-3 w-3`}),` `,e.memoryPercent,`%`]})]})]}),x!=null&&u(`p`,{role:`status`,className:`px-4 pt-2 text-xs ${x.tone===`ok`?`text-success`:`text-warning`}`,children:x.text}),(k!==null||j!==null)&&o(`p`,{role:`status`,className:`px-4 pt-2 text-xs text-warning`,children:[k,j!==null&&o(s,{children:[` `,u(`a`,{href:j,target:`_blank`,rel:`noreferrer`,className:`underline text-foreground`,children:t(`cluster.nodeCard.openDashboard`,`Open dashboard`)})]})]}),u(`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=>u(`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`?t(`cluster.nodeCard.general`,`General`):e===`forks`?t(`cluster.nodeCard.forks`,`Forks ({{length}})`,{length:C.length}):e===`processes`?t(`cluster.nodeCard.processes`,`Processes`):e===`load`?t(`cluster.nodeCard.load`,`Load`):e===`settings`?t(`cluster.nodeCard.settings`,`Settings`):t(`cluster.nodeCard.capabilities`,`Capabilities`)},e))}),o(`div`,{className:`px-4 py-2`,children:[g===`info`&&o(`div`,{className:`space-y-3`,children:[u(kr,{nodeId:e.id,name:e.name,hostname:e.hostname,platform:e.platform,arch:e.arch,cpuModel:e.cpuModel,cpuCores:e.cpuCores,memoryMB:e.memoryMB,engines:e.engines,isHub:e.isHub,uptime:e.uptime,localIps:e.localIps,rootPackage:e.rootPackage}),u(Nr,{nodeId:e.id,detectedHosts:e.localIps??[]}),u(`div`,{className:`border-t border-border pt-1`,children:u(Br,{node:{id:e.id,name:e.name,isHub:e.isHub,isOnline:e.isOnline,rootPackage:e.rootPackage??null}})})]}),g===`forks`&&u(Gt,{nodeId:e.id,processes:C}),g===`processes`&&u(Yt,{nodeId:e.id}),g===`load`&&u(Sr,{nodeId:e.id,isHub:e.isHub}),g===`settings`&&u(Er,{nodeId:e.id,addonIds:w}),g===`capabilities`&&u(Dr,{nodeId:e.id,addons:e.addons})]})]}):o(`div`,{className:`border border-border rounded-xl overflow-hidden opacity-60`,children:[o(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-3 gap-y-2 px-4 py-3 bg-muted/30`,children:[u(`div`,{className:`w-2.5 h-2.5 rounded-full bg-destructive shrink-0`}),u(Bt,{node:e}),o(`span`,{className:`text-xs text-muted-foreground min-w-0 truncate`,children:[e.cpuModel??e.platform,` ·`,` `,e.memoryMB>0?t(`cluster.nodeCard.gb`,`{{value1}}GB`,{value1:Math.round(e.memoryMB/1024)}):``,` `,`· `,e.arch]}),e.engines.map(e=>u(`span`,{className:`text-[9px] px-1.5 py-0.5 rounded-full bg-primary/10 text-primary font-medium`,children:e},e)),e.rootPackage&&o(`span`,{className:`text-[10px] font-mono px-1.5 py-0.5 rounded bg-muted text-muted-foreground`,children:[e.rootPackage.name,`@`,e.rootPackage.version]}),u(`span`,{className:`ml-auto text-xs px-2 py-0.5 rounded-full bg-destructive/10 text-destructive`,children:t(`common.offline`)})]}),o(`div`,{className:`flex items-center justify-between gap-3 px-4 py-3`,children:[o(`span`,{className:`text-xs text-muted-foreground`,children:[e.lastSeen?u(`span`,{className:`mr-1`,children:t(`cluster.nodeCard.lastSeen`,{when:new Date(e.lastSeen).toLocaleString()})}):null,t(`cluster.nodeCard.addonsAssigned`,{count:e.addons.length})]}),o(`div`,{className:`flex shrink-0 items-center gap-2`,children:[F,o(`button`,{type:`button`,onClick:()=>void P(),disabled:v,title:t(`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:[u(f,{className:`h-3 w-3`}),v?t(`cluster.nodeCard.forgetting`,`Forgetting…`):t(`cluster.nodeCard.forgetNode`,`Forget node`)]})]})]}),x!=null&&u(`p`,{role:`status`,className:`px-4 pb-3 text-xs leading-relaxed ${x.tone===`ok`?`text-success`:`text-warning`}`,children:x.text})]})}var Ur=3,Wr=7e3;function Gr(e){return[...e].sort((e,t)=>e.isHub===t.isHub?0:e.isHub?1:-1)}function Kr(e){return e.isHub?{}:{nodeId:e.id}}function qr(e){return e.updateState===`staging`||e.updateState===`pending-restart`||e.pendingVersion!==null?!0:!e.updateAvailable}async function Jr(e,t){let n=Kr(e),r=V.t(`helpers.clusterUpdateAll.noAnswer`);for(let i=1;i<=Ur;i+=1)try{let r=await t.readStatus(n);return qr(r)?{nodeId:e.id,nodeName:e.name,outcome:`applied`,detail:V.t(`helpers.clusterUpdateAll.landed`,{state:r.updateState,version:r.runningVersion??V.t(`helpers.clusterUpdateAll.unknown`)})}:{nodeId:e.id,nodeName:e.name,outcome:`failed`,detail:V.t(`helpers.clusterUpdateAll.unchanged`,{version:r.runningVersion??V.t(`helpers.clusterUpdateAll.unknown`)})}}catch(e){r=e instanceof Error?e.message:String(e),i<Ur&&await t.wait(Wr)}return{nodeId:e.id,nodeName:e.name,outcome:`unconfirmed`,detail:V.t(`helpers.clusterUpdateAll.unconfirmed`,{attempts:Ur,error:r})}}function Yr(e){return e.accepted?`applied`:e.outcome===`failed`?`failed`:`refused`}async function Xr(e,t){let n=[];for(let r of Gr(e))try{let e=await t.apply(Kr(r));n.push({nodeId:r.id,nodeName:r.name,outcome:Yr(e),detail:e.message})}catch{n.push(await Jr(r,t))}return n}e();function Zr(){let{nodes:e,isLoading:t}=ze(),r=n(()=>e??[],[e]);return{nodes:r,isLoading:t&&r.length===0}}var Qr={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 $r(){let{t:e}=H(),r=R(),{nodes:c,isLoading:l}=Zr(),[d,f]=Ze(),{selection:p,selectNode:m}=at(c),h=p.node,g=n(()=>c.filter(e=>e.isOnline),[c]),_=g.length,y=c.filter(e=>!e.isOnline).length,b=ge(),S=ee(),[C,w]=i(!1),[E,D]=i([]),O=d.get(`unlockNode`),k=d.get(`returnTo`),[A,j]=i(null);t(()=>{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=jt(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=a(async()=>{let t=g.map(e=>({id:e.id,name:e.name,isHub:e.isHub}));if(await r({title:e(`serverManagement.confirmUpdateAllTitle`,`Update all nodes`),message:e(`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:e(`serverManagement.confirmUpdateAllAction`,`Update all & restart`),variant:`warning`})){w(!0),D([]);try{D(await Xr(t,{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,r,g,S,e]);return o(Qe,{icon:v,title:e(`nav.nodes`,`Nodes`),subtitle:e(`cluster.subtitle`,`One node at a time — topology and packages. Agents join by pairing (certificate, no shared secret).`),actions:o(s,{children:[_>0&&u(`span`,{className:`rounded-full bg-success/10 px-2 py-0.5 text-xs text-success`,children:e(`common.onlineCount`,{count:_})}),y>0&&u(`span`,{className:`rounded-full bg-destructive/10 px-2 py-0.5 text-xs text-destructive`,children:e(`common.offlineCount`,{count:y})}),_>1&&o(L,{type:`button`,size:`sm`,disabled:C,title:e(`serverManagement.updateAllHint`,`Sequenced agents-first, hub-last — up-to-date nodes are skipped.`),onClick:()=>void M(),children:[C?u(T,{className:`h-3.5 w-3.5 animate-spin`}):u(x,{className:`h-3.5 w-3.5`}),e(`serverManagement.updateAll`,`Update all nodes`)]})]}),children:[E.length>0&&u(`ul`,{"aria-label":`update-all-report`,className:`flex flex-col gap-1 text-xs`,children:E.map(e=>o(`li`,{"data-outcome":e.outcome,className:`rounded border px-2 py-1 ${Qr[e.outcome]}`,children:[u(`span`,{className:`font-medium`,children:e.nodeName}),u(`span`,{className:`mx-1 uppercase tracking-wide`,children:e.outcome}),u(`span`,{className:`opacity-80`,children:e.detail})]},e.nodeId))}),A!==null&&o(`p`,{role:`alert`,className:`rounded border border-warning/40 bg-warning/10 px-3 py-2 text-xs text-warning`,children:[e(`system.cluster.unlockFromAgentFailed`,`Unlock from agent failed:`),` `,A]}),u(kt,{onOpenNode:m}),l?u(`div`,{className:`flex items-center justify-center py-12 text-muted-foreground`,children:e(`system.cluster.loadingClusterTopology`,`Loading cluster topology...`)}):h===null?u(`div`,{className:`rounded-md border border-dashed border-border px-3 py-6 text-center text-xs text-foreground-subtle`,children:e(`cluster.noNodes`,`No nodes in this cluster yet.`)}):o(`div`,{className:`flex flex-col gap-3`,children:[u(it,{staleNodeId:p.staleNodeId,shownNodeName:h.name}),u(De,{selectedNodeId:h.id,onSelect:m,allowOffline:!0,alwaysShow:!0}),u(Hr,{node:h})]})]})}export{$r as ClusterPage};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-Cyuzqnbw.js";import{$ as t,B as n,G as r,J as i,L as a,S as o,b as s,i as c,o as l,p as u,q as d,x as f}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEHpkaJP.js";import{A as p,D as m,It as h,Jr as g,Mn as _,N as v,Nr as y,Nt as b,O as x,Qi as S,T as C,Tr as w,V as T,Xt as E,Yn as D,_i as O,_t as k,ar as A,b as j,bn as M,dt as N,ia as P,j as F,k as I,lr as L,nr as ee,ot as te,pn as ne,rr as re,sn as R,un as z,ut as ie,v as ae,y as oe,yi as se,yn as ce,z as B}from"./player-overlays-CTjp5_0E.js";import{c as le,l as ue,t as de}from"./video-C9XbLIGZ.js";import{a as fe,i as pe,n as me,r as he,t as ge}from"./usb-CSAqtgKZ.js";import{t as _e}from"./crop-BCuJfQIp.js";import{t as ve}from"./layers-BNtkJA8b.js";import{An as ye,Dn as be,En as xe,Gr as Se,Kr as Ce,Mn as we,On as Te,Ti as Ee,Tn as De,c as Oe,jn as ke,kn as Ae,l as je,m as Me,vi as Ne,wn as Pe}from"./client-Ck3kx2Z0.js";import{n as Fe}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_trpc_mf_1_react_mf_2_query__loadShare__.js-DdJYWyu3.js";import{$l as Ie,An as Le,Bn as V,Bs as Re,C as ze,Cs as Be,Dn as Ve,Ds as He,E as Ue,En as We,Es as Ge,F as Ke,Gs as qe,H as Je,Is as Ye,J as Xe,Jl as Ze,Js as Qe,Jt as $e,Ln as et,Ls as tt,Ms as nt,Mt as rt,O as it,On as at,Os as ot,Rn as st,S as ct,Ss as lt,T as ut,Tn as dt,Ts as ft,Tt as pt,Us as mt,Ut as ht,Vs as gt,Vt as H,W as _t,Ws as vt,Wt as yt,Xs as bt,Y as xt,Ys as St,Yt as Ct,Zn as wt,Zs as Tt,_n as Et,_r as Dt,_u as Ot,an as kt,ar as U,bs as At,cc as jt,cn as Mt,dc as Nt,dn as Pt,eu as Ft,gu as It,ha as Lt,hn as Rt,hu as zt,in as Bt,jn as Vt,kn as Ht,lc as Ut,ln as Wt,mn as Gt,mr as Kt,mu as W,oc as qt,ou as Jt,pc as Yt,pn as Xt,pr as Zt,qs as Qt,qt as $t,r as en,sc as tn,sn as nn,su as rn,uc as an,un as on,vn as sn,vt as cn,vu as ln,w as un,wn as dn,ws as fn,xs as pn,yu as mn,zs as hn}from"./src-CoNs4bys.js";import{t as G}from"./i18n-DWijAvai.js";import{t as K}from"./useTranslation-D3Is_4B6.js";import{U as gn,X as _n,Y as vn,et as yn}from"./index-IBVizVRk.js";import"./useEventInvalidation-DUsOqTKW.js";import{t as bn}from"./NodeAddonsSettingsPanel-DMEeQbDW.js";import{a as xn,c as Sn,d as Cn,g as wn,h as Tn,i as En,l as Dn,n as On,o as kn,p as An,r as jn,s as Mn,t as Nn}from"./board-model-DIWD11Nh.js";var Pn=`step`,Fn=[Pn,`acc`];function In(e,t){return`${e}/${t}`}function Ln(e,t,n){let r=n.step!==null&&e.includes(n.step),i=n.acc!==null&&t.includes(n.acc);return{stepId:r?n.step:null,acceleratorId:i?n.acc:null,staleStepId:n.step!==null&&n.step!==``&&!r&&e.length>0?n.step:null}}function Rn(e){if(e==null)return null;if(typeof e==`number`)return e>0?e:null;let t=Date.parse(e);return Number.isNaN(t)?null:t}function zn(e){return e}function Bn(e,t){for(let[n,r]of Object.entries(e??{}))if(n===t)return r}function Vn(e,t){return typeof e==`boolean`?e:zn(t)}function Hn(e,t){return{pipeline:Vn(Bn(e,`detect`),t),audio:Vn(Bn(e,`audio`),t),ingest:Vn(Bn(e,`ingest`),t)}}function Un(e,t,n){let r=e?.find(e=>e.nodeId===t);return Hn(r?.settings,n)}function Wn({selectedNodeId:e,onSelect:t,refreshToken:n}){let r=P(),{t:i}=K(),{nodes:a}=zt(),{data:c}=hn(void 0),{data:l}=mt(void 0),u=new Map;for(let e of c??[])u.set(e.agentNodeId,(u.get(e.agentNodeId)??0)+1);let d=a??[],p=d.filter(e=>e.isOnline).length,m=d.filter(e=>!e.isOnline).length;return o(`div`,{className:`flex flex-col h-full`,children:[o(`button`,{type:`button`,onClick:()=>t(Mo),className:`flex items-center gap-3 px-4 py-3 border-b border-border text-left transition-colors ${e===`__cluster__`?`bg-primary/10 text-primary`:`text-foreground hover:bg-surface-hover`}`,children:[f(le,{className:`h-4 w-4 flex-shrink-0`}),o(`div`,{className:`min-w-0 flex-1`,children:[f(`div`,{className:`text-xs font-semibold truncate`,children:i(`pipeline.nodeList.cluster`,`Cluster`)}),f(`div`,{className:`text-[10px] text-foreground-subtle`,children:i(`pipeline.nodeList.assignmentsLoadBalancingRoles`,`Assignments, load balancing, roles`)})]})]}),f(`div`,{className:`flex-1 overflow-y-auto`,children:d.map(n=>{let a=e===n.id,c=u.get(n.id)??0,d=n.isHub?z:g,p=Un(l,n.id,n.isHub),m=n.isOnline?null:cn(Rn(n.lastSeen),r);return o(`button`,{type:`button`,onClick:()=>t(n.id),className:`flex items-center gap-3 w-full px-4 py-3 border-b border-border text-left transition-colors ${a?`bg-primary/10 text-primary`:`text-foreground hover:bg-surface-hover`}${n.isOnline?``:` opacity-60`}`,children:[f(d,{className:`h-4 w-4 flex-shrink-0`}),o(`div`,{className:`min-w-0 flex-1`,children:[o(`div`,{className:`flex items-center gap-2`,children:[f(`span`,{className:`text-xs font-semibold truncate`,children:n.name}),n.isHub&&f(`span`,{className:`text-[9px] uppercase tracking-wider text-foreground-subtle border border-border rounded px-1 py-0.5`,children:i(`common.hubWord`)}),!n.isOnline&&f(`span`,{className:`h-1.5 w-1.5 rounded-full bg-danger flex-shrink-0`}),n.isOnline&&f(`span`,{className:`h-1.5 w-1.5 rounded-full bg-success flex-shrink-0`})]}),o(`div`,{className:`text-[10px] text-foreground-subtle flex items-center gap-2 mt-0.5`,children:[f(`span`,{children:i(`common.coresCount`,{count:n.cpuCores})}),f(`span`,{children:`•`}),o(`span`,{children:[Math.round(n.memoryMB/1024),` GB`]}),c>0&&o(s,{children:[f(`span`,{children:`•`}),o(`span`,{className:`inline-flex items-center gap-0.5 text-foreground`,children:[f(de,{className:`h-2.5 w-2.5`}),c]})]}),!n.isOnline&&o(s,{children:[f(`span`,{children:`•`}),o(`span`,{className:`text-danger`,children:[i(`common.offline`),m===null?``:` · ${m}`]})]})]}),o(`div`,{className:`mt-0.5 flex items-center gap-1`,children:[f(U,{variant:p.pipeline?`success`:`danger`,className:`px-1 py-0 text-[9px] leading-3`,title:p.pipeline?i(`pipeline.nodeList.pipelineEnabled`,`Pipeline: enabled`):i(`pipeline.nodeList.pipelineNotEnabledAgentCapability`,`Pipeline: not enabled (agent capability)`),children:i(`pipeline.nodeList.pipe`,`Pipe`)}),f(U,{variant:p.audio?`success`:`danger`,className:`px-1 py-0 text-[9px] leading-3`,title:p.audio?i(`pipeline.nodeList.audioEnabled`,`Audio: enabled`):i(`pipeline.nodeList.audioNotEnabledAgentCapability`,`Audio: not enabled (agent capability)`),children:i(`pipeline.nodeList.aud`,`Aud`)})]})]})]},n.id)})}),o(`div`,{className:`px-4 py-2 border-t border-border text-[10px] text-foreground-subtle flex items-center justify-between`,children:[f(`span`,{children:i(`common.onlineCount`,{count:p})}),m>0&&f(`span`,{className:`text-danger`,children:i(`common.offlineCount`,{count:m})})]})]})}function Gn({nodeId:e,refreshToken:t}){let{t:n}=K(),{nodes:r}=zt(),i=r?.find(t=>t.id===e),a=It(`pipeline.runner-load-snapshot`,t=>t.nodeId===e)?.load??null;return i?o(`div`,{className:`px-6 py-4 border-b border-border`,children:[o(`div`,{className:`flex items-center gap-2 mb-1`,children:[f(`h2`,{className:`text-base font-semibold text-foreground`,children:i.name}),i.isOnline?f(`span`,{className:`text-[10px] px-2 py-0.5 rounded-full bg-success/10 text-success`,children:n(`common.online`)}):f(`span`,{className:`text-[10px] px-2 py-0.5 rounded-full bg-danger/10 text-danger`,children:n(`common.offline`)}),i.isHub&&f(`span`,{className:`text-[9px] uppercase tracking-wider text-foreground-subtle border border-border rounded px-1 py-0.5`,children:n(`common.hubWord`)})]}),o(`div`,{className:`text-[11px] text-foreground-subtle flex items-center gap-2 flex-wrap`,children:[f(`span`,{children:i.cpuModel??`CPU`}),f(`span`,{children:`•`}),f(`span`,{children:n(`common.coresCount`,{count:i.cpuCores})}),f(`span`,{children:`•`}),o(`span`,{children:[Math.round(i.memoryMB/1024),` GB`]}),a&&o(s,{children:[f(`span`,{children:`•`}),f(`span`,{children:n(`pipeline.nodeDetailHeader.cameras`,{attached:a.attachedCameras,active:a.activeCameras})}),f(`span`,{children:`•`}),f(`span`,{children:n(`pipeline.nodeDetailHeader.avgInference`,{ms:a.avgInferenceTimeMs.toFixed(0)})}),f(`span`,{children:`•`}),f(`span`,{children:n(`pipeline.nodeDetailHeader.queue`,{depth:a.queueDepthTotal})}),a.hardware.hasGpu&&o(s,{children:[f(`span`,{children:`•`}),f(`span`,{className:`text-success`,children:`GPU`})]})]})]})]}):f(`div`,{className:`px-6 py-4 border-b border-border`,children:o(`div`,{className:`text-xs text-foreground-subtle`,children:[n(`pipeline.nodeDetailHeader.nodeNotFound`,`Node not found:`),` `,e]})})}var Kn=[`assignments`,`tree`,`engines`,`logs`];t();function qn({refreshToken:e,nodeId:t}){let{t:n}=K(),[a,s]=i(new Map),{nodes:c}=W();ln(`pipeline.camera-metrics-snapshot`,e=>{let t=e.data;typeof t?.deviceId==`number`&&s(e=>{let n=new Map(e);return n.set(t.deviceId,t),n})});let{data:l}=ot(void 0),u=r(()=>{let e=new Map;for(let t of l??[])e.set(t.nodeId,t.deviceCount);return e},[l]),d=r(()=>{let e=new Map,t=Date.now()-3e4;for(let n of a.values()){if(n.timestamp<t)continue;let r=n.nodeId??`hub`,i=e.get(r)??{attachedCameras:0,activeCameras:0,totalFps:0,totalInferenceWeighted:0,queueDepth:0};i.attachedCameras++,n.metrics.phase===`active`&&i.activeCameras++,i.totalFps+=n.metrics.actualFps,i.totalInferenceWeighted+=n.metrics.avgInferenceTimeMs,i.queueDepth+=n.metrics.queueDepth,e.set(r,i)}return e},[a]),p=r(()=>{let e=new Map;for(let t of c)e.set(t.id,t.shortName);return e},[c]),m=r(()=>{let e=0,t=0,n=0,r=0,i=0;for(let a of d.values())e+=a.attachedCameras,t+=a.activeCameras,n+=a.totalFps,r+=a.totalInferenceWeighted,i+=a.queueDepth;let a=e>0?r/e:0;return{totalAgents:c.length,onlineAgents:c.filter(e=>e.isOnline).length,attachedCameras:e,activeCameras:t,avgInferenceTimeMs:a,queueDepth:i,totalFps:n}},[d,c]);if(t){let e=d.get(t);return o(`div`,{className:`@container/liveload`,children:[f(`h3`,{className:`text-sm font-semibold text-foreground mb-2`,children:n(`pipeline.liveLoadPanel.liveLoad`,`Live load`)}),o(`div`,{className:`grid grid-cols-2 @md/liveload:grid-cols-3 @3xl/liveload:grid-cols-5 gap-2 mb-3`,children:[f(q,{label:`FPS`,value:e?e.totalFps.toFixed(1):`—`}),f(q,{label:n(`pipeline.liveLoadPanel.activeAttached`,`Active / Attached`),value:e?`${e.activeCameras}/${e.attachedCameras}`:`—`}),f(q,{label:n(`pipeline.liveLoadPanel.avgInferMs`,`Avg infer ms`),value:e&&e.attachedCameras>0?(e.totalInferenceWeighted/e.attachedCameras).toFixed(0):`—`}),f(q,{label:n(`pipeline.liveLoadPanel.queue`,`Queue`),value:e?String(e.queueDepth):`—`}),f(q,{label:n(`pipeline.liveLoadPanel.audio`,`Audio`),value:String(u.get(t)??`—`)})]})]})}let h=[...d.entries()].toSorted(([e],[t])=>e===`hub`?-1:t===`hub`?1:e.localeCompare(t));return o(`div`,{className:`@container/liveload`,children:[f(`h3`,{className:`text-sm font-semibold text-foreground mb-2`,children:n(`pipeline.liveLoadPanel.liveLoad`,`Live load`)}),o(`div`,{className:`grid grid-cols-2 @md/liveload:grid-cols-3 @3xl/liveload:grid-cols-5 gap-2 sm:gap-3 mb-3`,children:[f(q,{label:n(`pipeline.liveLoadPanel.totalAgents`,`Total agents`),value:`${m.onlineAgents}/${m.totalAgents}`}),f(q,{label:n(`pipeline.liveLoadPanel.activeAttached`,`Active / Attached`),value:`${m.activeCameras}/${m.attachedCameras}`}),f(q,{label:n(`pipeline.liveLoadPanel.totalFps`,`Total FPS`),value:m.totalFps.toFixed(1)}),f(q,{label:n(`pipeline.liveLoadPanel.avgInferenceMs`,`Avg inference ms`),value:m.avgInferenceTimeMs.toFixed(0)}),f(q,{label:n(`pipeline.liveLoadPanel.queueDepth`,`Queue depth`),value:String(m.queueDepth)})]}),f(`div`,{className:`rounded-lg border border-border overflow-x-auto`,children:o(`table`,{className:`w-full text-xs min-w-[480px]`,children:[f(`thead`,{className:`bg-surface`,children:o(`tr`,{className:`text-foreground-subtle text-[10px] uppercase tracking-wider`,children:[f(`th`,{className:`text-left px-3 py-2`,children:n(`pipeline.liveLoadPanel.agent`,`Agent`)}),f(`th`,{className:`text-right px-3 py-2`,children:`FPS`}),f(`th`,{className:`text-right px-3 py-2`,children:n(`pipeline.liveLoadPanel.cameras`,`Cameras`)}),f(`th`,{className:`text-right px-3 py-2`,children:n(`pipeline.liveLoadPanel.inferenceMs`,`Inference ms`)}),f(`th`,{className:`text-right px-3 py-2`,children:n(`pipeline.liveLoadPanel.queue`,`Queue`)}),f(`th`,{className:`text-right px-3 py-2`,children:n(`pipeline.liveLoadPanel.audio`,`Audio`)})]})}),o(`tbody`,{children:[h.map(([e,t])=>o(`tr`,{className:`border-t border-border`,children:[f(`td`,{className:`px-3 py-2 text-foreground font-medium`,children:p.get(e)??e}),f(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t.totalFps.toFixed(1)}),f(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t.attachedCameras}),f(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t.attachedCameras>0?(t.totalInferenceWeighted/t.attachedCameras).toFixed(0):`—`}),f(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t.queueDepth}),f(`td`,{className:`px-3 py-2 text-right text-foreground`,children:u.get(e)??`—`})]},e)),h.length===0&&f(`tr`,{children:f(`td`,{colSpan:6,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:n(`pipeline.liveLoadPanel.noCameraMetricsReceivedYet`,`No camera metrics received yet`)})})]})]})})]})}function q({label:e,value:t}){return o(`div`,{className:`rounded-lg border border-border bg-surface/60 p-3`,children:[f(`div`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle mb-1`,children:e}),f(`div`,{className:`text-lg font-semibold text-foreground`,children:t})]})}var Jn={active:!1,pinned:!1,nodeId:null,reason:``};function Yn(e,t){return e.deviceName.localeCompare(t.deviceName)||e.deviceId-t.deviceId}function Xn(e,t,n){let r=new Map(t.map(e=>[e.deviceId,e])),i=new Map(n.map(e=>[e.deviceId,e]));return e.map(e=>{let t=r.get(e.id),n=i.get(e.id),a=t?{active:!0,pinned:t.pinned,nodeId:t.agentNodeId,reason:t.reason??``}:Jn,o=n?{active:!0,pinned:n.pinned,nodeId:n.nodeId,reason:``}:Jn;return{deviceId:e.id,deviceName:e.name,disabled:e.disabled===!0,pipeline:a,detection:a,decoder:Jn,audio:o}}).toSorted(Yn)}function Zn(e,t,n){return{active:e!==null,pinned:t,nodeId:e,reason:n??``}}function Qn(e,t){let n=new Map(t.map(e=>[e.deviceId,e.assignment]));return e.map(e=>{let t=n.get(e.deviceId);return t===void 0?e:{...e,detection:Zn(t.detectionNodeId,t.pinned.detection,t.reasons.detection),decoder:Zn(t.decoderNodeId,t.pinned.decoder,t.reasons.decoder),audio:Zn(t.audioNodeId,t.pinned.audio,t.reasons.audio)}})}function $n(e,t,n){let r=(t,n,r)=>({active:t!==null&&t===e,pinned:n,nodeId:t,reason:r??``});return t.map(({deviceId:e,assignment:t})=>({deviceId:e,deviceName:n(e),detection:r(t.detectionNodeId,t.pinned.detection,t.reasons.detection),decoder:r(t.decoderNodeId,t.pinned.decoder,t.reasons.decoder),audio:r(t.audioNodeId,t.pinned.audio,t.reasons.audio)})).filter(e=>e.detection.active||e.decoder.active||e.audio.active).toSorted(Yn)}function er(e){let t=new Map(e.map(e=>[e.id,e.name]));return e=>{let n=t.get(e);return n!==void 0&&n!==``?n:e}}function tr(e){let t=new Map(e.map(e=>[e.id,e.name]));return e=>t.get(e)??G.t(`helpers.assignmentRows.cameraFallback`,{id:e})}function nr(e,t,n){let r=[...new Set([...e.nodeId===null?[]:[e.nodeId],...t.map(e=>e.id)])];return[{value:`auto`,label:G.t(`helpers.assignmentRows.auto`)},...r.map(e=>({value:e,label:G.t(`helpers.assignmentRows.pinTo`,{node:n(e)})}))]}function rr({roleId:e,roleLabel:t,state:n,nameOf:r,colorByNodeId:i,emphasizeOnNodeId:a}){if(n.nodeId===null)return null;let o=n.nodeId,s=a===void 0?!1:n.active&&o===a;return f($t,{roleId:e,roleLabel:t,nodeName:r(o),colorId:Ct(i,o),emphasized:s,pinned:n.pinned})}function ir({detection:e,decoder:t,audio:n,nameOf:r,colorByNodeId:i,emphasizeOnNodeId:a}){let s=(e,t,n)=>f(rr,{roleId:e,roleLabel:t,state:n,nameOf:r,colorByNodeId:i,emphasizeOnNodeId:a},e);return o(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1.5`,children:[s(`detection`,`Detection`,e),s(`decode`,`Decode`,t),s(`audio`,`Audio`,n)]})}function ar({snap:e}){let t=P(),{t:n}=K();if(e===void 0)return f(`div`,{className:`flex h-8 items-center text-[11px] text-foreground-subtle`,title:n(`assignments.assignmentStatusCell.noMetricsInTheLast`,`No metrics in the last 10 s — the camera has no session running`),children:n(`assignments.assignmentStatusCell.noLiveData`,`no live data`)});let{phase:r,actualFps:i,avgInferenceTimeMs:a,queueDepth:s,configuredFps:c,droppedFrames:l}=e.metrics,u=rt(r,t);return o(`div`,{className:`flex h-8 min-w-0 flex-col justify-center font-mono text-[10px] leading-tight tabular-nums`,children:[o(`span`,{className:`inline-flex min-w-0 items-center gap-1 ${u.textColor}`,children:[f(Ke,{phase:r,className:`h-2.5 w-2.5 shrink-0`}),f(`span`,{className:`truncate font-semibold uppercase tracking-wider`,children:u.label}),f(`span`,{className:`text-foreground`,children:i.toFixed(1)}),f(`span`,{className:`text-foreground-subtle`,children:n(`pipeline.assignmentStatusCell.configuredFps`,{fps:c.toFixed(0)})})]}),o(`span`,{className:`truncate text-foreground-subtle`,children:[f(`span`,{className:`text-foreground`,children:a.toFixed(0)}),` ms`,s>0&&o(`span`,{className:`ml-1 text-warning`,children:[`q`,s]}),f(`span`,{className:l>0?`ml-1 text-warning`:`ml-1`,children:n(`pipeline.assignmentStatusCell.drops`,{count:l})})]})]})}t();var or=1e4,sr=5e3;function cr(e){let[t,r]=i(new Map);return ln(`pipeline.camera-metrics-snapshot`,t=>{let n=t.data;typeof n.deviceId==`number`&&(e!==void 0&&n.nodeId!==e||r(e=>new Map(e).set(n.deviceId,n)))}),n(()=>{if(t.size===0)return;let e=setInterval(()=>{r(e=>{let t=Date.now()-or,n=[...e].filter(([,e])=>e.timestamp>=t);return n.length===e.size?e:new Map(n)})},sr);return()=>clearInterval(e)},[t.size]),t}var lr=3e5;function ur({state:e,onlineNodes:t,nameOf:n,pending:r,onChange:i}){let{t:a}=K();return f(Ze,{"aria-label":a(`assignments.placementControls.nodePin`,`Node pin`),title:a(`assignments.placementControls.autoLetsEachSessionPick`,`Auto lets each session pick its node; a pin keeps the camera on one node.`),value:e.pinned&&e.nodeId!==null?e.nodeId:`auto`,disabled:r,options:[...nr(e,t,n)],onChange:e=>i(e.target.value)})}function dr({deviceId:e,nodeId:t}){let{t:n}=K(),r=l(),{data:i}=Re({deviceId:e},{refetchOnMount:`always`}),{data:a}=tt({nodeId:t},{staleTime:lr}),o=tn({onSuccess:()=>{r.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineDevicePin`]]})}});if(i===void 0||a===void 0)return f(`span`,{className:`text-[10px] italic text-foreground-subtle`,children:n(`assignments.placementControls.accelerator`,`accelerator: …`)});let s=a.devices??[],c=s.filter(e=>e.enabled),u=i?.deviceKey??`auto`,d=u!==`auto`&&!c.some(e=>e.key===u),p=s.find(e=>e.key===u),m=[{value:`auto`,label:n(`assignments.placementControls.anyAccelerator`,`Any accelerator`)},...d?[{value:u,label:n(`pipeline.placementControls.notEnabled`,{name:p?`${Et(p)} (${u})`:u})}]:[],...c.map(e=>({value:e.key,label:`${Et(e)} · ${e.format}`}))];return f(Ze,{"aria-label":n(`assignments.placementControls.inferenceDevicePin`,`Inference device pin`),title:n(`assignments.placementControls.pinDetectionToOneAccelerator`,`Pin detection to one accelerator of the node, or let each session pick.`),value:u,disabled:o.isPending,options:m,onChange:t=>o.mutate({deviceId:e,deviceKey:t.target.value})})}t();function fr(e){let t=d(null);return e.nodeId!==null&&(t.current=e),t.current}function pr({deviceId:e,state:t,...n}){let{t:r}=K(),i=fr(t);return o(`div`,{className:`grid w-80 grid-cols-2 gap-1.5`,children:[f(ur,{state:t,...n}),i?.nodeId==null?f(Ze,{"aria-label":r(`assignments.clusterRowCells.inferenceDevicePinNoNode`,`Inference device pin (no node yet)`),title:r(`assignments.clusterRowCells.anAcceleratorIsPinnedOn`,`An accelerator is pinned on the camera's node; this camera has not run on one yet.`),disabled:!0,defaultValue:`auto`,options:[{value:`auto`,label:r(`assignments.clusterRowCells.anyAccelerator`,`Any accelerator`)}]}):f(dr,{deviceId:e,nodeId:i.nodeId})]})}function mr({state:e,nameOf:t}){let{t:n}=K(),r=fr(e);if(r?.nodeId==null)return f(`span`,{className:`text-[11px] text-foreground-subtle`,children:n(`assignments.clusterRowCells.noSessionYet`,`— no session yet`)});let i=e.active&&e.nodeId!==null,a=r.pinned?`pinned`:`auto · ${r.reason||`capacity`}`;return o(`div`,{"data-testid":`resolved-placement`,className:`flex w-40 min-w-0 flex-col leading-tight`,title:r.pinned?void 0:n(`assignments.clusterRowCells.anUnpinnedCameraIsPlaced`,`An unpinned camera is placed again at every session start, so this can change between sessions.`),children:[o(`span`,{className:`flex min-w-0 items-center gap-1.5 text-xs`,children:[f(`span`,{"aria-hidden":!0,className:`h-1.5 w-1.5 shrink-0 rounded-full ${i?`bg-success`:`bg-foreground-subtle/40`}`}),f(`span`,{"data-testid":`resolved-placement-node`,className:`truncate font-medium ${i?`text-foreground`:`text-foreground-muted`}`,children:t(r.nodeId)})]}),f(`span`,{className:`truncate pl-3 text-[10px] ${r.pinned?`text-warning`:`text-foreground-subtle`}`,children:i?a:n(`assignments.clusterRowCells.idleLastSession`,`{{how}} · idle, last session`,{how:a})})]})}function hr({deviceId:e,deviceName:t}){let{t:n}=K(),[r,a]=i(!1);return o(s,{children:[f(Ft,{icon:M,variant:`ghost`,size:`sm`,"aria-label":n(`assignments.clusterRowCells.streamBrokersOf`,`Stream brokers of {{deviceName}}`,{deviceName:t}),title:n(`assignments.clusterRowCells.streamBrokersClients`,`Stream brokers & clients`),onClick:()=>a(!0)}),f(dt,{open:r,onOpenChange:a,children:o(Ve,{width:`lg`,scroll:`body`,placement:`sheet-on-mobile`,children:[f(Le,{children:f(Vt,{children:n(`pipeline.clusterRowCells.brokersTitle`,{device:t})})}),f(We,{children:r&&f(dn,{widgetId:`stream-broker/stream-broker-panel`,host:`device-tab`,deviceId:e,instanceId:`pipeline-row/${e}`,config:{variant:`compact`}})})]})})]})}function gr(e){return e.hasFreshMetrics?`active`:e.hasPipelineAssignment?`recently-active`:`inactive`}function _r(e,t){return t.size===0?!0:t.has(e)}var vr=[{value:`active`,get label(){return G.t(`helpers.cameraActivity.active`)}},{value:`recently-active`,get label(){return G.t(`helpers.cameraActivity.recentlyActive`)}},{value:`inactive`,get label(){return G.t(`helpers.cameraActivity.inactive`)}}];t();var yr=[`pipeline.camera-assigned`,`pipeline.camera-unassigned`,`pipeline.camera-updated`,`agent.online`,`agent.offline`];function br(e){for(let t of[`getPipelineAssignments`,`getAudioAssignments`,`getCameraStatuses`])e.invalidateQueries({queryKey:[[`pipelineOrchestrator`,t]]})}function xr(){let{t:e}=K(),t=l();en([`pipelineOrchestrator`,`getPipelineAssignments`],yr),en([`pipelineOrchestrator`,`getAudioAssignments`],yr),en([`pipelineOrchestrator`,`getCameraStatuses`],yr);let{data:n}=Lt({isCamera:!0,projection:`slim`}),{data:a}=hn(void 0),{data:s}=He(void 0),{data:c}=nt({}),{data:u}=mt(void 0),{nodes:d}=W(),p=cr(),m=r(()=>er(d),[d]),h=r(()=>$e(u),[u]),g=r(()=>d.filter(e=>e.isOnline).map(e=>({id:e.id,name:e.name})),[d]),_=r(()=>Qn(Xn((n??[]).map(e=>({id:e.id,name:e.name,disabled:e.disabled})),a??[],s??[]),c??[]),[n,a,s,c]),[v,y]=i(()=>new Set),b=r(()=>_.filter(e=>_r(gr({hasPipelineAssignment:e.pipeline.active,hasFreshMetrics:p.has(e.deviceId)}),v)),[_,p,v]),x=e=>{y(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},S=()=>br(t),C=ft({onSuccess:S}),w=Nt({onSuccess:S}),T=C.isPending||w.isPending,E=[{key:`camera`,header:e(`pipeline.cameraAssignmentsTable.camera`,`Camera`),width:`w-44`,sortValue:e=>e.deviceName,render:t=>o(`div`,{className:`flex w-44 min-w-0 items-center gap-1.5`,children:[f(_n,{to:`/devices/${String(t.deviceId)}`,className:`min-w-0 truncate text-xs font-medium text-primary hover:underline`,title:t.deviceName,children:t.deviceName}),t.disabled&&f(U,{variant:`default`,children:e(`common.off`)})]})},{key:`placement`,header:e(`pipeline.cameraAssignmentsTable.placement`,`Placement`),width:`w-80`,notSortableReason:`A pair of controls — editing one would move the row under the cursor.`,render:e=>f(pr,{deviceId:e.deviceId,state:e.pipeline,onlineNodes:g,nameOf:m,pending:T,onChange:t=>t===`auto`?w.mutate({deviceId:e.deviceId}):C.mutate({deviceId:e.deviceId,agentNodeId:t})})},{key:`roles`,header:e(`pipeline.cameraAssignmentsTable.rolesHere`,`Roles here`),notSortableReason:`A set of roles has no single order.`,render:e=>f(ir,{detection:e.detection,decoder:e.decoder,audio:e.audio,nameOf:m,colorByNodeId:h})},{key:`resolved`,header:e(`pipeline.cameraAssignmentsTable.runningOn`,`Running on`),width:`w-40`,sortValue:e=>e.pipeline.nodeId===null?null:m(e.pipeline.nodeId),render:e=>f(mr,{state:e.pipeline,nameOf:m})},{key:`status`,header:e(`pipeline.cameraAssignmentsTable.status`,`Status`),width:`w-40`,sortValue:e=>p.get(e.deviceId)?.metrics.actualFps??null,render:e=>f(ar,{snap:p.get(e.deviceId)})},{key:`brokers`,header:``,align:`right`,width:`w-10`,notSortableReason:`An action`,render:e=>f(hr,{deviceId:e.deviceId,deviceName:e.deviceName})}],D=n===void 0?`Loading cameras…`:_.length===0?`No cameras`:`No cameras match this activity filter.`;return o(`div`,{className:`flex flex-col gap-2`,children:[f(`nav`,{"aria-label":e(`pipeline.cameraAssignmentsTable.filterByCameraActivity`,`Filter by camera activity`),"data-testid":`assignments-activity-filter`,children:f(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1.5`,children:vr.map(e=>{let t=v.has(e.value);return f(`button`,{type:`button`,"aria-pressed":t,"data-testid":`assignments-activity-${e.value}`,className:rn(oe,t?ae:j),onClick:()=>x(e.value),children:e.label},e.value)})})}),f(ht,{columns:E,rows:b,rowKey:e=>e.deviceId,minWidthPx:920,maxBodyHeight:yt,emptyMessage:D})]})}t();function Sr({nodeId:e}){let{t}=K(),n=l();en([`pipelineOrchestrator`,`getCameraStatuses`],yr);let{data:i}=nt({}),{data:a}=mt(void 0),{data:o}=Lt({isCamera:!0,projection:`slim`}),{nodes:s}=W(),c=cr(),u=r(()=>er(s),[s]),d=r(()=>$e(a),[a]),p=r(()=>$n(e,i??[],tr((o??[]).map(e=>({id:e.id,name:e.name})))),[e,i,o]),m=s.filter(t=>t.isOnline&&t.id!==e),h=()=>br(n),g=ft({onSuccess:h}),_=Nt({onSuccess:h}),v=fn({onSuccess:h}),y=an({onSuccess:h}),b=e=>[...e.detection.active?m.map(n=>({id:`detect-${n.id}`,label:t(`pipeline.nodeCameraAssignmentsTable.moveDetectionTo`,`Move detection to {{name}}`,{name:n.name}),onClick:()=>g.mutate({deviceId:e.deviceId,agentNodeId:n.id})})):[],...e.audio.active?m.map(n=>({id:`audio-${n.id}`,label:t(`pipeline.nodeCameraAssignmentsTable.moveAudioTo`,`Move audio to {{name}}`,{name:n.name}),onClick:()=>v.mutate({deviceId:e.deviceId,nodeId:n.id})})):[],{id:`unpin-detect`,label:t(`pipeline.nodeCameraAssignmentsTable.unpinDetection`,`Unpin detection`),hidden:!(e.detection.active&&e.detection.pinned),separatorBefore:!0,onClick:()=>_.mutate({deviceId:e.deviceId})},{id:`unpin-audio`,label:t(`pipeline.nodeCameraAssignmentsTable.unpinAudio`,`Unpin audio`),hidden:!(e.audio.active&&e.audio.pinned),onClick:()=>y.mutate({deviceId:e.deviceId})}];return f(ht,{columns:[{key:`camera`,header:t(`pipeline.nodeCameraAssignmentsTable.camera`,`Camera`),width:`w-44`,sortValue:e=>e.deviceName,render:e=>f(_n,{to:`/devices/${String(e.deviceId)}`,className:`block w-44 truncate text-xs font-medium text-primary hover:underline`,title:e.deviceName,children:e.deviceName})},{key:`roles`,header:t(`pipeline.nodeCameraAssignmentsTable.rolesHere`,`Roles here`),notSortableReason:`A set of roles has no single order.`,render:t=>f(ir,{detection:t.detection,decoder:t.decoder,audio:t.audio,nameOf:u,colorByNodeId:d,emphasizeOnNodeId:e})},{key:`status`,header:t(`pipeline.nodeCameraAssignmentsTable.status`,`Status`),width:`w-40`,sortValue:e=>c.get(e.deviceId)?.metrics.actualFps??null,render:e=>f(ar,{snap:c.get(e.deviceId)})},{key:`actions`,header:``,align:`right`,width:`w-10`,notSortableReason:`Actions`,render:e=>f(_t,{items:b(e),title:t(`pipeline.nodeCameraAssignmentsTable.move`,`Move {{deviceName}}`,{deviceName:e.deviceName})})}],rows:p,rowKey:e=>e.deviceId,minWidthPx:560,maxBodyHeight:yt,emptyMessage:i===void 0?t(`pipeline.nodeCameraAssignmentsTable.loadingCameras`,`Loading cameras…`):t(`pipeline.nodeCameraAssignmentsTable.noCameraRunsOnThis`,`No camera runs on this node right now`)})}function Cr({nodeId:e,refreshToken:t}){let{t:n}=K(),{nodes:r}=W(),i=r.find(t=>t.id===e)?.name??e;return o(`div`,{className:`space-y-3 sm:space-y-4`,children:[f(qn,{refreshToken:t,nodeId:e}),o(`div`,{className:`space-y-2`,children:[o(`div`,{children:[f(`h3`,{className:`text-sm font-semibold text-foreground`,children:n(`pipeline.nodeCamerasTab.camerasOn`,{node:i})}),f(`p`,{className:`text-[11px] text-foreground-subtle`,children:n(`pipeline.nodeCamerasTab.theRolesEachCameraRuns`,`The roles each camera runs here right now. Move a role or unpin it from the row menu; pins for every camera are on Cluster → Assignments.`)})]}),f(Sr,{nodeId:e})]})]})}t();function wr(e,t){let n=Math.max(0,t-e),r=Math.floor(e/1e3),i=Math.floor(n/1e3);return G.t(`pipeline.nodeEnginesTab.idleLeft`,{idle:r,left:i})}function Tr({nodeId:e,refreshToken:t}){let{t:n}=K(),i=l(),a=wt(),s=pn({onSettled:()=>{i.invalidateQueries({queryKey:[`pipelineExecutor`,`listLoadedEngines`]})}}),{data:c}=lt({nodeId:e}),u=It(`pipeline.engine-metrics-snapshot`,t=>t.nodeId===e)?.engines??c??null,d=u===null;en([`pipelineRunner`,`getLocalCameras`],[`pipeline.camera-assigned`,`pipeline.camera-unassigned`]);let{data:p}=Yt({nodeId:e}),{values:m}=Ot(`pipeline.camera-metrics-snapshot`,e=>e.deviceId,t=>t.nodeId===e),_=r(()=>m.filter(e=>e.metrics.phase===`active`).length,[m]),v=t=>{let r=p??[];if(r.length===0){s.mutate({nodeId:e,engine:t,force:!1});return}(async()=>{await a({title:n(`pipeline.nodeEnginesTab.killEngine`,`Kill engine`),message:`${String(r.length)} camera(s) are dispatching through this engine. Killing it drops their in-flight work and forces a respawn on the next frame.`,confirmLabel:n(`pipeline.nodeEnginesTab.killEngine`,`Kill engine`),variant:`danger`})&&s.mutate({nodeId:e,engine:t,force:!0})})()};return o(`div`,{className:`space-y-6`,children:[o(`div`,{children:[f(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:n(`pipeline.nodeEnginesTab.inferenceEnginesOnThisNode`,`Inference engines on this node`)}),f(`p`,{className:`text-[11px] text-foreground-subtle`,children:n(`pipeline.nodeEnginesTab.summary`,{engines:(u??[]).length,cameras:(p??[]).length,active:_})})]}),f(`div`,{className:`rounded-lg border border-border overflow-x-auto`,children:o(`table`,{className:`w-full text-xs min-w-[640px]`,children:[f(`thead`,{className:`bg-surface`,children:o(`tr`,{className:`text-foreground-subtle text-[10px] uppercase tracking-wider`,children:[f(`th`,{className:`text-left px-3 py-2 whitespace-nowrap`,children:n(`pipeline.nodeEnginesTab.kind`,`Kind`)}),f(`th`,{className:`text-left px-3 py-2 whitespace-nowrap`,children:n(`pipeline.nodeEnginesTab.runtimeBackendDevice`,`Runtime / Backend / Device`)}),f(`th`,{className:`text-left px-3 py-2`,children:n(`pipeline.nodeEnginesTab.models`,`Models`)}),f(`th`,{className:`text-right px-3 py-2 whitespace-nowrap`,children:n(`pipeline.nodeEnginesTab.poolPid`,`Pool PID`)}),f(`th`,{className:`text-right px-3 py-2 whitespace-nowrap`,children:n(`pipeline.nodeEnginesTab.autoKill`,`Auto-kill`)}),f(`th`,{className:`text-right px-3 py-2 whitespace-nowrap`,children:n(`pipeline.nodeEnginesTab.inUse`,`In use`)}),f(`th`,{className:`w-20`})]})}),o(`tbody`,{children:[d&&f(`tr`,{children:f(`td`,{colSpan:7,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:n(`common.loading`,`Loading…`)})}),!d&&(u??[]).map(e=>{let t=e.kind===`device-pool`;return o(`tr`,{className:`border-t border-border ${t?`bg-primary/[0.05]`:``}`,children:[f(`td`,{className:`px-3 py-2`,children:o(`span`,{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded-full text-[10px] font-medium ${t?`bg-primary/15 text-primary`:`bg-success/15 text-success`}`,children:[f(t?ve:g,{className:`h-3 w-3`}),n(t?`pipeline.nodeEnginesTab.pool`:`pipeline.nodeEnginesTab.runtime`)]})}),f(`td`,{className:`px-3 py-2`,children:o(`span`,{className:`inline-flex items-center gap-1 text-[11px] text-sky-400`,children:[f(ie,{className:`h-3 w-3`}),e.engine.runtime,`/`,e.engine.backend,e.engine.device?`/${e.engine.device}`:``,e.engine.format?` · ${e.engine.format}`:``]})}),f(`td`,{className:`px-3 py-2`,children:e.modelsLoaded.length===0?f(`span`,{className:`text-foreground-subtle text-[11px]`,children:`—`}):f(`div`,{className:`flex flex-wrap gap-1`,children:e.modelsLoaded.map(e=>f(`span`,{className:`inline-block rounded bg-surface px-1.5 py-0.5 text-[10px] font-mono text-foreground-subtle`,children:e},e))})}),f(`td`,{className:`px-3 py-2 text-right font-mono text-foreground`,children:e.poolPid??`—`}),f(`td`,{className:`px-3 py-2 text-right text-[11px]`,children:e.idleMs!==null&&e.idleTtlMs!==null?f(`span`,{className:`text-foreground-subtle`,children:wr(e.idleMs,e.idleTtlMs)}):f(`span`,{className:`text-foreground-subtle/50`,children:n(`common.never`)})}),f(`td`,{className:`px-3 py-2 text-right text-foreground`,children:(p??[]).length}),f(`td`,{className:`px-3 py-2 text-right`,children:t?f(`span`,{className:`text-[11px] text-foreground-subtle`,children:n(`common.auto`)}):o(V,{variant:`ghost`,size:`sm`,disabled:s.isPending,onClick:()=>v(e.engine),className:`text-danger hover:bg-danger/10 hover:text-danger`,children:[f(h,{className:`h-3.5 w-3.5`}),n(`pipeline.nodeEnginesTab.kill`,`Kill`)]})})]},e.engineKey)}),!d&&(u??[]).length===0&&f(`tr`,{children:f(`td`,{colSpan:7,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:n(`pipeline.nodeEnginesTab.noEnginesResidentTheFactory`,`No engines resident — the factory spins up on the first pipeline run.`)})})]})]})}),f(`div`,{className:`text-[10px] text-foreground-subtle leading-relaxed`,children:f(vn,{i18nKey:`pipeline.nodeEnginesTab.legend`,components:{strong:f(`strong`,{className:`text-foreground`})}})}),s.isError&&f(et,{message:n(`pipeline.nodeEnginesTab.killFailed`,{message:s.error instanceof Error?s.error.message:n(`common.unknownError`)})})]})}var Er=`pipeline-runner`,Dr=200;function Or({nodeId:e}){let{t}=K();return o(`div`,{className:`flex flex-col gap-3`,children:[o(`div`,{children:[f(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:t(`pipeline.nodeLogsTab.runnerLogs`,`Runner logs`)}),f(`p`,{className:`text-[11px] text-foreground-subtle`,children:t(`pipeline.nodeLogsTab.description`,{node:e})})]}),f(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:f(pt,{agentId:e,addonId:Er,limit:Dr,maxHeight:`max-h-[calc(100vh-360px)]`,showScope:!0,showDeviceChip:!0,showFilters:!1})})]})}t();function kr({nodeId:e,title:t}){let n=P(),{t:i}=K(),{data:a}=gn(),{data:s}=hn(void 0),c=r(()=>{let e=new Map;for(let t of a??[])e.set(t.id,t.name);return e},[a]),l=r(()=>{if(!e)return null;let t=new Set;for(let n of s??[])n.agentNodeId===e&&t.add(n.deviceId);return t},[e,s]),u=cr(e),d=r(()=>{let e=[];for(let t of u.values())l&&!l.has(t.deviceId)||e.push(t);return e.sort((e,t)=>e.deviceId-t.deviceId),e},[u,l]);return d.length===0?o(`div`,{className:`rounded-md border border-border bg-surface px-3 py-2 text-[11px] text-foreground-subtle italic`,children:[t??i(`pipeline.cameraStatusStrip.cameras`,`Cameras`),`: no live snapshots yet`]}):o(`div`,{className:`rounded-md border border-border bg-surface px-3 py-2`,children:[o(`div`,{className:`flex items-center gap-2 mb-1.5`,children:[f(`span`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle`,children:t??i(`pipeline.cameraStatusStrip.cameras`,`Cameras`)}),f(`span`,{className:`text-[10px] text-foreground-subtle`,children:d.length})]}),f(`div`,{className:`flex flex-wrap gap-1.5`,children:d.map(e=>{let t=c.get(e.deviceId)??`#${e.deviceId}`,r=rt(e.metrics.phase,n);return o(`div`,{title:i(`pipeline.cameraStatusStrip.fpsMsInferQ`,`{{name}} · {{label}} · {{value3}} fps · {{value4}}ms infer · q={{queueDepth}}`,{name:t,label:r.label,value3:e.metrics.actualFps.toFixed(1),value4:e.metrics.avgInferenceTimeMs.toFixed(0),queueDepth:e.metrics.queueDepth}),className:`inline-flex items-center gap-1 rounded border px-1.5 py-0.5 text-[10px] ${r.badgeClass}`,children:[f(Ke,{phase:e.metrics.phase,className:`h-2.5 w-2.5`}),f(`span`,{className:`font-medium text-foreground/90 max-w-[220px] truncate`,children:t}),f(`span`,{className:`font-mono tabular-nums`,children:e.metrics.actualFps.toFixed(1)}),f(`span`,{className:`opacity-60`,children:i(`common.fpsWord`)})]},e.deviceId)})})]})}function Ar(e,t,n){return e.map(e=>{if(e.key===t)return e;let r=e.steps[n];if(!r||r.settings===void 0)return e;let{settings:i,...a}=r,o={...e.steps};return Object.keys(a).length>0?o[n]=a:delete o[n],{...e,steps:o}})}function jr(e,t,n){let r=e.filter(e=>e.key!==t).toSorted((e,t)=>e.key.localeCompare(t.key)),i=[...r.filter(e=>!e.enabled),...r.filter(e=>e.enabled),...e.filter(e=>e.key===t)],a;for(let e of i){let t=e.steps?.[n]?.settings;!t||Object.keys(t).length===0||(a={...a,...t})}return a}function Mr(e){let t={};for(let n of e){let e=Object.keys(n.steps).length>0;t[n.key]={enabled:n.enabled,weight:Math.max(1,n.weight),...n.maxSessions!==null&&n.maxSessions>0?{maxSessions:n.maxSessions}:{},...e?{steps:n.steps}:{}}}return t}var Nr=`pipeline-orchestrator`;function Pr({addonId:e,highlightLabel:t}){let{t:n}=K(),r=Te(e),{data:i}=Kt({addonId:Nr});if(r.length===0)return null;let a=ke(i??null)[e]??{};return o(`section`,{className:`space-y-1.5 border-t border-border/60 pt-3`,"aria-label":n(`stepInspector.clusterOwnedSettings.clusterWideSettings`,`Cluster-wide settings`),children:[o(`div`,{className:`flex flex-wrap items-center gap-2`,children:[f(`h3`,{className:T,children:n(`stepInspector.clusterOwnedSettings.clusterWideSettings`,`Cluster-wide settings`)}),f(_n,{to:zo(e),className:`ml-auto text-[11px] text-primary hover:underline`,children:n(`stepInspector.clusterOwnedSettings.editInClusterSettings`,`Edit in Cluster → Settings ›`)})]}),r.map(e=>o(`div`,{className:`${p} rounded px-2 ${t===e.label?`bg-primary/5 ring-1 ring-primary/40`:``}`,children:[f(`span`,{className:F,children:e.label}),f(`span`,{className:v,children:f(`span`,{className:`font-mono text-xs text-foreground`,children:String(a[e.key]??e.default)})})]},e.key)),f(`p`,{className:B,children:n(`stepInspector.clusterOwnedSettings.oneValueForEveryNode`,`One value for every node and camera — this step writes into a shared index.`)})]})}function Fr({rows:e}){let{t}=K();return o(`div`,{className:`space-y-1.5`,"data-testid":`effective-models`,children:[f(`ul`,{className:`divide-y divide-border rounded-md border border-border`,children:e.map(e=>o(`li`,{className:`${C} flex flex-wrap items-baseline gap-x-2 text-xs`,children:[f(`span`,{className:`min-w-0 flex-1 truncate text-foreground-muted`,children:e.label}),f(`span`,{className:`font-mono text-foreground`,children:e.modelId??`—`}),f(`span`,{className:`text-[10px] text-foreground-subtle`,children:e.sourceLabel})]},e.id))}),f(`p`,{className:B,children:t(`stepInspector.effectiveModelSummary.toChangeAModelOpen`,`To change a model, open that accelerator's cell in the table.`)})]})}t();function Ir(e,t){let[n,i]=yn(),o=n.get(Pn),s=n.get(`acc`),c=r(()=>Ln(e,t,{step:o,acc:s}),[e,t,o,s]),l=a(e=>{i(t=>{let n=new URLSearchParams(t);return e(n),n},{replace:!0})},[i]);return{selection:c,open:a(e=>l(t=>{t.set(Pn,e.stepId),e.acceleratorId===void 0?t.delete(`acc`):t.set(`acc`,e.acceleratorId)}),[l]),close:a(()=>l(e=>{e.delete(Pn),e.delete(`acc`)}),[l])}}function Lr(e,t){for(let n of e?.slots??[])for(let e of n.addons)if(e.id===t)return e;return null}function Rr(e){return e.split(`.`)[0]??e}function zr(e,t,n){return{id:In(e,n.key),nodeId:e,deviceKey:n.key,device:n,label:`${Rr(t)} · ${Et(n)}`,shortLabel:`${Rr(t)} · ${sn(n)}`,nodeLabel:Rr(t),disabled:!n.enabled}}function Br(e,t,n,r=!1){return n.filter(e=>r||e.enabled).map(n=>zr(e,t,n))}function Vr(e,t,n=!1){return e.flatMap(e=>{let r=t[e.id]??[];if(n)return r.map(t=>zr(e.id,e.name,t));let i=r.filter(e=>e.enabled&&e.available);if(i.length>0)return i.map(t=>zr(e.id,e.name,t));let a=r.find(e=>e.available)??r[0];return a===void 0?[]:[zr(e.id,e.name,a)]})}function Hr(e,t,n){return{modelId:Xt({catalog:e,device:t.device,base:n.nodePin,override:n.cameraPin}),source:n.cameraPin===void 0?n.nodePin===void 0?`default`:`node`:`camera`}}function Ur(e,t,n){let r=Lr(e,`object-detection`);if(r===null)return;let i=Xt({catalog:r,device:t.device,base:t.device.steps?.[`object-detection`]?.modelId,override:n});if(i===void 0)return;let a=r.models.find(e=>e.id===i);return{modelId:i,name:a?.name??i,supplies:a?.suppliesSteps??[]}}function Wr(e,t,n){return!Se(e)||n===void 0?!1:Ce(e,t,n.supplies).effective}function Gr(e,t){return e!==null&&Gt(e.models,t.device.format)}function Kr(e){return Gr(e.addon,e.acc)?e.clusterModelId===void 0?{kind:`enabled`,modelId:e.model.modelId??`Auto`,overridden:e.model.source===`camera`,...e.rootName===void 0?{}:{suppliedByRoot:e.rootName},...e.jumpTo===void 0?{}:{jumpTo:e.jumpTo}}:{kind:`enabled`,modelId:e.clusterModelId,clusterWide:!0}:e.gatedOn?e.jumpTo===void 0?{kind:`skip`}:{kind:`skip`,jumpTo:e.jumpTo}:{kind:`na`}}function qr(e){return Object.values(e).reduce((e,t)=>e+t.filter(e=>!e.enabled).length,0)}function Jr(e){if(e===null)return[];let t=(e.configSchema??[]).flatMap(e=>`label`in e&&typeof e.label==`string`?[e.label]:[]),n=Te(e.id).map(e=>e.label);return[...new Set([...t,...n])]}function Yr(e){return e.flatMap(e=>[{node:e,depth:0},...Yr(e.children).map(e=>({node:e.node,depth:e.depth+1}))])}function Xr(e,t){return e.flatMap(e=>{let n=Xr(e.children,t);return t.has(e.addonId)||n.length>0?[{...e,children:n}]:[]})}t();function Zr(e){return{agentNodeId:e.nodeId,nodeLabel:e.nodeLabel,engineLabel:e.device.format,deviceKey:e.deviceKey,deviceLabel:Et(e.device),detail:e.device.defaultModelId,disabled:e.disabled}}function Qr({tree:e,searchRows:t,accelerators:n,cellState:s,stepBadge:c,disabledCount:l,showDisabled:u,onShowDisabledChange:p,dirty:m,onDiscard:h,summary:g,toolbar:_,label:v,renderDetail:y}){let{t:b}=K(),x=wt(),S=Jt(),{selection:C,open:w,close:T}=Ir(r(()=>Yr(e).map(e=>e.node.addonId),[e]),r(()=>n.map(e=>e.id),[n])),[E,D]=i(``),[O,k]=i(null),[A,j]=i(null),M=d(null),P=d(null),F=d(null),I=d(null),L=r(()=>ze(t,E),[t,E]),ee=r(()=>E.trim()===``?e:Xr(e,new Set(L.map(e=>e.addonId))),[e,L,E]),te=e=>L.find(t=>t.addonId===e)?.matchedField??null,ne=r(()=>n.map(Zr),[n]),re=e=>n.find(t=>t.nodeId===e.agentNodeId&&t.deviceKey===e.deviceKey),R=n.find(e=>e.id===C.acceleratorId)??null,z=C.stepId!==null,ie=a(async e=>{if(m){if(!await x({title:b(`stepInspector.stepMatrixFrame.discardUnsavedChanges`,`Discard unsaved changes?`),message:b(`stepInspector.stepMatrixFrame.thisStepHasChangesThat`,`This step has changes that are not saved yet.`),confirmLabel:b(`stepInspector.stepMatrixFrame.discard`,`Discard`),variant:`danger`}))return;h()}e()},[x,m,h,b]),ae=()=>{requestAnimationFrame(()=>I.current?.focus())},oe=(e,t,n=!1)=>{if(e===C.stepId&&(t?.id??null)===C.acceleratorId){n&&ae();return}let r=()=>{k(te(e)),w({stepId:e,...t===void 0?{}:{acceleratorId:t.id}}),n&&ae()};e===C.stepId?r():ie(r)},se=()=>{let e=C.stepId;ie(()=>{if(T(),e!==null){let t=R===null?null:xt({agentNodeId:R.nodeId,deviceKey:R.deviceKey});requestAnimationFrame(()=>M.current?.focusCell(e,t))}})},ce=e=>{if(e.key===`Enter`){let t=L[0];if(t===void 0)return;e.preventDefault(),oe(t.addonId,void 0,!0)}else e.key===`Escape`&&D(``)},le=S?f(Ue,{onClick:se}):f(Ft,{icon:N,variant:`ghost`,size:`sm`,"aria-label":b(`common.close`,`Close`),onClick:se});return o(`div`,{ref:P,className:`space-y-2`,onKeyDown:e=>{let t=e.target instanceof HTMLElement&&e.target.dataset.r!==void 0;e.key===`/`&&t&&(e.preventDefault(),F.current?.focus()),e.key===`Escape`&&t&&z&&(e.preventDefault(),se())},children:[o(`div`,{className:`flex flex-wrap items-center gap-2 text-xs`,children:[f(`div`,{className:`min-w-0 basis-full sm:basis-auto`,children:g}),f(`input`,{ref:F,type:`search`,value:E,onChange:e=>D(e.target.value),onKeyDown:ce,placeholder:b(`stepInspector.stepMatrixFrame.filterStepsOrSettings`,`Filter steps or settings /`),"aria-label":b(`stepInspector.stepMatrixFrame.filterStepsOrSettings2`,`Filter steps or settings`),className:`h-9 w-56 rounded-md border border-border bg-background px-2 text-xs text-foreground outline-none focus:border-primary focus:ring-1 focus:ring-primary/30 md:h-7`}),l>0&&o(`label`,{className:`inline-flex items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[f(kt,{checked:u,onChange:e=>p(e.target.checked)}),b(`stepInspector.stepMatrixFrame.showDisabled`,{count:l})]}),_]}),C.staleStepId!==null&&f(`p`,{className:`rounded-md border border-warning/40 bg-warning/10 px-3 py-1.5 text-[11px] text-warning`,children:b(`stepInspector.stepMatrixFrame.staleStep`,{id:C.staleStepId})}),ee.length===0?f(`p`,{className:`${B} rounded-md border border-dashed border-border px-3 py-4 text-center`,children:b(`stepInspector.stepMatrixFrame.noStepMatches`,{query:E})}):f(Xe,{ref:M,tree:ee,agents:ne,label:v,getCellState:(e,t)=>{let n=re(t);return n===void 0?{kind:`na`}:s(e,n)},onCellClick:(e,t,n)=>oe(e,re(t),n),onStepClick:(e,t)=>oe(e,void 0,t),...c===void 0?{}:{stepBadge:c},selectedCell:z&&C.stepId!==null&&R!==null?{addonId:C.stepId,agentNodeId:R.nodeId,deviceKey:R.deviceKey}:null,fallbackNodeId:A,onFallbackNodeChange:j,reserveRightPx:z&&!S?432:0}),f(it,{open:z,anchor:P,onClose:se,label:b(`stepInspector.stepMatrixFrame.stepSettings`,`Step settings`),children:C.stepId!==null&&y({stepId:C.stepId,accelerator:R,matchedField:O,closeButton:le,onEscape:se,headingRef:e=>{I.current=e}})})]})}t();function $r(e){n(()=>{if(e===null)return;let t=document.getElementById(e);t===null||typeof t.scrollIntoView!=`function`||t.scrollIntoView({block:`center`,behavior:`smooth`})},[e])}t();function ei(e,t){let n=e.filter(e=>e.steps?.[t]?.settings!==void 0),r=e=>e.toSorted((e,t)=>e.key.localeCompare(t.key));return r(n.filter(e=>e.enabled))[0]?.key??r(n)[0]?.key??r(e.filter(e=>e.enabled))[0]?.key??e[0]?.key}function ti(e,t){let n=t.settings===void 0?void 0:ei(e,t.stepId),r=e.map(e=>{let r={...e.steps},i=r[t.stepId]??{},a=t.models[e.key],o=t.jumps[e.key],s=e.key===n&&t.settings!==void 0?Object.keys(t.settings).length>0?t.settings:void 0:i.settings,c=a===void 0?i.modelId:a??void 0,l=o===void 0?i.jumpDeviceKey:o||void 0,u={...c===void 0?{}:{modelId:c},...s===void 0?{}:{settings:s},...l===void 0?{}:{jumpDeviceKey:l}};return Object.keys(u).length>0?r[t.stepId]=u:delete r[t.stepId],{key:e.key,enabled:e.enabled,weight:e.weight,maxSessions:e.maxSessions,steps:r}});return n===void 0?r:Ar(r,n,t.stepId)}function ni(e,t,n){if(t===null)return 0;let r=Object.entries(t.models).filter(([n,r])=>(r??void 0)!==e.find(e=>e.key===n)?.steps?.[t.stepId]?.modelId).length,i=Object.entries(t.jumps).filter(([n,r])=>(r||void 0)!==e.find(e=>e.key===n)?.steps?.[t.stepId]?.jumpDeviceKey).length,a=new Set([...Object.keys(n),...Object.keys(t.settings??{})]),o=t.settings===void 0?0:[...a].filter(e=>!Me(n[e],t.settings?.[e])).length;return r+i+o}function ri({nodeId:e,nodeName:t,toolbar:n}){let{t:a}=K(),c=l(),u=tt({nodeId:e},{refetchOnMount:`always`}),d=At({nodeId:e},{refetchOnMount:`always`}),p=ye(Kt({addonId:`pipeline-orchestrator`}).data??null),m=u.data?.devices??[],h=d.data??null,[g,_]=i(null),[v,y]=i(null),[b,x]=i(null),S=bt({onSuccess:()=>{c.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getNodeInferenceDevices`]]})}}),C=r(()=>h?ct(h):[],[h]),w=r(()=>Yr(C),[C]),[E,D]=i(!1),O=r(()=>Br(e,t,m,E),[e,t,m,E]),k=r(()=>Br(e,t,m),[e,t,m]),A=k.length>=2,j=(e,t)=>(t===void 0?void 0:jr(m,t.deviceKey,e))??{},M=(e,t,n)=>{let r=n??t.device.steps?.[e?.id??``]?.jumpDeviceKey;if(r!==void 0&&r!==``)return k.find(e=>e.deviceKey===r);if(!Gr(e,t))return k.filter(n=>n.id!==t.id&&Gr(e,n)).toSorted((e,t)=>e.deviceKey.localeCompare(t.deviceKey))[0]},N=(e,t)=>{let n=Lr(h,e),r=Ho(e),i=Ur(h,t),a=j(e,t),o=M(n,t);return Kr({addon:n,acc:t,gatedOn:n?.enabledByDefault??!0,model:n?Hr(n,t,{nodePin:t.device.steps?.[e]?.modelId}):{modelId:void 0,source:`default`},...Wr(e,a,i)&&i?{rootName:i.name}:{},...r?{clusterModelId:p[e]??r.defaultModelId}:{},...o?{jumpTo:sn(o.device)}:{}})},P=w.map(({node:e})=>({addonId:e.addonId,name:e.addonName,fieldLabels:Jr(Lr(h,e.addonId))}));if(u.isLoading||d.isLoading)return f(`div`,{className:`animate-pulse p-4 text-xs text-foreground-subtle`,children:a(`stepInspector.nodeStepInspector.loadingPipeline`,`Loading pipeline…`)});if(h===null)return f(`div`,{className:`p-4 text-xs text-foreground-subtle`,children:a(`stepInspector.nodeStepInspector.catalogUnavailable`,`Catalog unavailable.`)});let F=o(`span`,{className:B,children:[a(`stepInspector.nodeStepInspector.accelerators`,`Accelerators:`),` `,f(`span`,{className:`text-foreground`,children:k.length>0?k.map(e=>sn(e.device)).join(` · `):a(`stepInspector.nodeStepInspector.noneEnabled`,`none enabled`)}),m.some(e=>!e.enabled)&&o(s,{children:[` `,a(`stepInspector.nodeStepInspector.off`,`— off:`),` `,m.filter(e=>!e.enabled).map(sn).join(`, `)]}),` `,`·`,` `,f(_n,{to:Bo(),className:`text-primary hover:underline`,children:a(`stepInspector.nodeStepInspector.clusterLoadBalancing`,`Cluster → Load balancing ›`)})]});return f(Qr,{tree:C,searchRows:P,accelerators:O,cellState:N,disabledCount:m.filter(e=>!e.enabled).length,showDisabled:E,onShowDisabledChange:D,dirty:g!==null&&ni(m,g,j(g.stepId,O[0]))>0,onDiscard:()=>_(null),summary:F,...n===void 0?{}:{toolbar:n},label:a(`stepInspector.nodeStepInspector.detectionSteps`,`Detection steps`),renderDetail:({stepId:n,accelerator:r,matchedField:i,closeButton:c,onEscape:l,headingRef:u})=>{let d=Lr(h,n);if(d===null)return f(`div`,{className:`p-4 text-xs text-foreground-subtle`,children:a(`stepInspector.nodeStepInspector.noStepSelected`,`No step selected.`)});let p=g?.stepId===n?g:null,C=r??k[0]??O[0],w=j(n,C),E=p?.settings??w,D=ni(m,p,w),N=e=>{x(null),_(t=>({...t?.stepId===n?t:{stepId:n,models:{},jumps:{}},...e}))},P=Ho(n),F=Wt(d),I=C===void 0?void 0:Ur(h,C),L=e=>{let t=p?.models[e.deviceKey];return t===void 0?e.device.steps?.[n]?.modelId:t??void 0},ee=C===void 0?void 0:Hr(d,C,{nodePin:L(C)}).modelId,te=O.length>1&&O.some(e=>!Me(j(n,e),w)),ne=e=>{let t=L(e),r=Hr(d,e,{nodePin:t}),i=Ur(h,e),c=Wr(n,p?.settings??j(n,e),i),l=p?.jumps[e.deviceKey],u=M(d,e,l),m=Gr(d,e)?c&&i?f(nn,{rootModel:i,stepModelId:r.modelId}):void 0:o(s,{children:[a(`stepInspector.nodeStepInspector.noBuild`,{format:e.device.format}),` `,u?a(`stepInspector.nodeStepInspector.itRunsOnInstead`,`It runs on {{shortLabel}} instead.`,{shortLabel:u.shortLabel}):a(`stepInspector.nodeStepInspector.itDoesNotRunHere`,`It does not run here.`)]}),g=A?o(`label`,{className:`block space-y-1`,children:[f(`span`,{className:`text-[11px] font-medium text-foreground`,children:a(`stepInspector.nodeStepInspector.runOn`,`Run on`)}),f(Ze,{"aria-label":a(`stepInspector.nodeStepInspector.runOn`,`Run on`),value:l??e.device.steps?.[n]?.jumpDeviceKey??``,options:[{value:``,label:a(`stepInspector.nodeStepInspector.autoThisAcceleratorOrThe`,`Auto (this accelerator, or the next one that can run it)`)},...k.filter(t=>t.id!==e.id).map(e=>({value:e.deviceKey,label:`${e.label} · ${e.device.format}`}))],onChange:t=>N({jumps:{...p?.jumps,[e.deviceKey]:t.target.value}})}),f(`span`,{className:B,children:a(`stepInspector.nodeStepInspector.routesThisStepAndIts`,`Routes this step (and its child steps) to another accelerator of this node.`)})]}):void 0;return{label:e.label,format:e.device.format,modelId:r.modelId,source:r.source===`node`?`node`:`default`,sourceLabel:r.source===`node`?`node pin`:`hardware default`,models:Rt(d.models??[],e.device.format),defaultModelId:d.defaultModelIdByFormat?.[e.device.format]??d.defaultModelId,expanded:v===e.id,onToggle:()=>y(t=>t===e.id?null:e.id),onChangeModel:t=>N({models:{...p?.models,[e.deviceKey]:t}}),...t===void 0?{}:{onReset:()=>N({models:{...p?.models,[e.deviceKey]:null}}),resetLabel:`Reset to hardware default`},...m===void 0?{}:{note:m},...g===void 0?{}:{extra:g},changed:p?.models[e.deviceKey]!==void 0||l!==void 0}},re=()=>{p!==null&&S.mutate({agentNodeId:e,inferenceDevices:Mr(ti(m,p))},{onSuccess:()=>{_(null),x({kind:`saved`})},onError:e=>x({kind:`error`,error:e.message})})};return f(ut,{ref:u,title:r===null?`${d.name} · ${t}`:`${d.name} · ${r.label}`,subtitle:r===null?a(`stepInspector.nodeStepInspector.everyAcceleratorOf`,`{{slot}} · every accelerator of {{nodeName}}`,{slot:d.slot,nodeName:t}):a(`stepInspector.nodeStepInspector.baseForEveryCameraThat`,`{{slot}} · {{format}} · base for every camera that lands here`,{slot:d.slot,format:r.device.format}),leading:c,onEscape:l,saveBar:{dirtyCount:D,saving:S.isPending,status:b?.kind??null,...b?.error===void 0?{}:{error:b.error},onSave:re,onDiscard:()=>_(null)},children:o(`div`,{className:`space-y-3`,children:[o(`section`,{className:`space-y-2`,"aria-label":a(`stepInspector.nodeStepInspector.model`,`Model`),children:[f(`h3`,{className:T,children:a(`stepInspector.nodeStepInspector.model`,`Model`)}),P!==null&&C!==void 0?f(Uo,{step:P,engineFormat:C.device.format,runnableModelIds:Rt(d.models??[],C.device.format).map(e=>e.id)}):O.length===0?f(`p`,{className:B,children:f(vn,{i18nKey:`stepInspector.nodeStepInspector.noAcceleratorEnabled`,components:{link:f(_n,{to:Bo(),className:`text-primary hover:underline`})}})}):r===null?f(Fr,{rows:O.map(e=>{let t=Hr(d,e,{nodePin:L(e)});return{id:e.id,label:e.label,modelId:t.modelId,sourceLabel:t.source===`node`?`node pin`:`hardware default`}})}):f(un,{...ne(r)},r.id)]}),(F.length>0||I!==void 0)&&P===null&&o(`section`,{"aria-label":a(`stepInspector.nodeStepInspector.settings`,`Settings`),className:`space-y-2 border-t border-border/60 pt-2`,children:[f(`p`,{className:`text-[10px] text-foreground-subtle`,"data-testid":`settings-scope`,children:a(`stepInspector.nodeStepInspector.nodeWideSettings`,{node:t})}),te&&f(`p`,{className:`rounded-md border border-warning/40 bg-warning/10 px-2 py-1 text-[11px] text-warning`,children:a(`stepInspector.nodeStepInspector.thisStepSSettingsDiffer`,`This step's settings differ between this node's accelerators. Saving makes the values shown here node-wide.`)}),f(ii,{addon:d,fields:F,settings:E,modelId:Mt(d,ee,E,I),root:I,highlight:i,onChange:e=>N({settings:e})})]}),f(Pr,{addonId:n,highlightLabel:i})]})})}})}function ii({addon:e,fields:t,settings:n,modelId:r,root:i,highlight:a,onChange:o}){let s=t.find(e=>`label`in e&&e.label===a)?.key??null;return $r(s===null?null:Pt(s)),f(on,{addon:e,fields:t,layers:{node:n},target:`node`,labels:{node:`Node`},modelId:r,...i===void 0?{}:{rootModel:i},highlightKey:s,onChangeLayer:o})}t();function ai({nodeId:e,refreshToken:t}){let{t:n}=K(),r=wt(),[a,c]=i(null),{nodes:l}=W(),u=l.find(t=>t.id===e)?.name??e,d=Qt({onSuccess:e=>{c(e.effectiveModelId===null?`Reset done — model config cleared (node offline: effective model resolves on reconnect)`:`Reset done — effective detection model: ${e.effectiveModelId} (Auto)`)}}),p=async()=>{await r({title:n(`pipeline.nodePipelineTab.resetToHardwareAwareDefaults`,`Reset {{nodeName}} to hardware-aware defaults?`,{nodeName:u}),message:n(`pipeline.nodePipelineTab.thisClearsEveryPerDevice`,`This clears every per-device model default on this node (back to the format default) and every per-camera step override scoped to it. Existing per-camera customisations on this node are lost.`),confirmLabel:n(`common.reset`,`Reset`),variant:`danger`})&&(c(null),d.mutate({agentNodeId:e}))};return o(`div`,{className:`space-y-2`,children:[f(kr,{nodeId:e}),f(ri,{nodeId:e,nodeName:u,toolbar:o(s,{children:[a&&f(`span`,{className:`text-[11px] text-success`,children:a}),d.isError&&f(`span`,{className:`text-[11px] text-danger`,children:d.error instanceof Error?d.error.message:n(`pipeline.nodePipelineTab.resetFailed`,`Reset failed`)}),f(V,{variant:`outline`,size:`sm`,onClick:()=>{p()},disabled:d.isPending,title:n(`pipeline.nodePipelineTab.clearThisNodeSPer`,`Clear this node's per-device model defaults + per-camera overrides scoped to this node`),children:d.isPending?n(`pipeline.nodePipelineTab.resetting`,`Resetting…`):n(`pipeline.nodePipelineTab.resetToDefault`,`Reset to default`)})]})})]})}var oi=[`detection-pipeline`,`audio-analyzer`,`pipeline-runner`],si=`decoder-nodeav`,ci=`ntab`,li={decoder:`engine`},ui={engine:`Engine & decoder`},di=`Nothing here is set per node. Cluster-wide values are on Cluster → Settings.`;function fi({nodeId:e,refreshToken:t}){let{t:n}=K(),[r,i]=yn(),{nodes:a}=W(),s=a.find(t=>t.id===e)?.addons.find(e=>e.capabilities.includes(`decoder`))?.addonId??si,c=[...oi,s],l=r.get(ci),u={assignments:{id:`assignments`,label:n(`pipeline.nodeDetail.assignments`,`Assignments`),order:-10,content:f(Cr,{nodeId:e,refreshToken:t})},tree:{id:`tree`,label:n(`pipeline.nodeDetail.pipeline`,`Pipeline`),order:39,content:f(ai,{nodeId:e,refreshToken:t})},engines:{id:`engines`,label:n(`pipeline.nodeDetail.warmInstances`,`Warm instances`),order:180,content:f(Tr,{nodeId:e,refreshToken:t})},logs:{id:`logs`,label:n(`pipeline.nodeDetail.logs`,`Logs`),order:300,content:f(Or,{nodeId:e})}},d=Kn.map(e=>u[e]);return o(`div`,{className:`flex flex-col h-full`,children:[f(Gn,{nodeId:e,refreshToken:t}),f(`div`,{className:`flex-1 min-h-0 overflow-y-auto p-4 sm:p-6`,children:f(bn,{nodeId:e,addonIds:c,level:`global`,fieldScope:`perNode`,emptyMessage:di,tabAliases:li,tabLabelOverrides:ui,extraTabs:d,activeTab:l===null?null:li[l]??l,onActiveTabChange:e=>i(t=>{let n=new URLSearchParams(t);n.set(ci,e);for(let e of Fn)n.delete(e);return n},{replace:!0})})})]})}function pi(){let{t:e}=K();return o(`div`,{className:`space-y-2`,children:[o(`div`,{className:`min-w-0`,children:[f(`h3`,{className:`text-sm font-semibold text-foreground`,children:e(`pipeline.clusterAssignmentsTab.cameraPlacement`,`Camera placement`)}),f(`p`,{className:`text-[11px] text-foreground-subtle`,children:e(`pipeline.clusterAssignmentsTab.pinACameraToA`,`Pin a camera to a node, or to one accelerator of its node; Auto lets each session pick. Decode always runs with detection. Load, shares and caps are on Load balancing.`)})]}),f(xr,{})]})}function mi(e){return`${Math.round(e*100)}%`}function hi(e){return G.t(`helpers.autoTuneViewModel.sessions`,{count:e})}var gi={"intel-npu":`Intel NPU`,"intel-igpu":`Intel iGPU`,"amd-igpu":`AMD iGPU (WebGPU)`,"amd-npu":`AMD XDNA NPU`,"x86-cpu":`CPU`,"arm-cpu":`CPU`,"apple-ane":`Apple Neural Engine`,coral:`Coral Edge TPU`},_i={"intel-core-ultra":`Intel Core Ultra`,"intel-n-series":`Intel N-series`,"apple-m-base":`Apple M (base)`,"apple-m-pro":`Apple M Pro / Max / Ultra`,"amd-phoenix":`AMD Ryzen Phoenix / Hawk Point`,unknown:`Not measured`};function vi(e){return e===null?`—`:gi[e]??e}function yi(e){return e===null?`—`:_i[e]??e}function bi(e){switch(e.kind){case`capacity`:return G.t(`helpers.autoTuneViewModel.capacity`,{sessions:hi(e.sessions),min:e.minSessions});case`tie-faster`:return G.t(`helpers.autoTuneViewModel.tieFaster`,{over:e.over,recall:mi(e.recallDelta)});case`stepped-down`:return G.t(`helpers.autoTuneViewModel.steppedDown`,{from:e.from,limitedBy:e.limitedBy,to:e.to});case`no-fit-lightest`:return G.t(`helpers.autoTuneViewModel.noFitLightest`,{min:hi(e.minSessions),sessions:hi(e.sessions)});case`derived-latency`:return G.t(`helpers.autoTuneViewModel.derivedLatency`,{modelId:e.modelId});case`cpu-device`:return G.t(`helpers.autoTuneViewModel.cpuDevice`);case`coral-untouched`:return G.t(`helpers.autoTuneViewModel.coralUntouched`);case`device-disabled`:return G.t(`helpers.autoTuneViewModel.deviceDisabled`);case`device-unavailable`:return G.t(`helpers.autoTuneViewModel.deviceUnavailable`);case`node-offline`:return G.t(`helpers.autoTuneViewModel.nodeOffline`);case`no-hardware-facts`:return G.t(`helpers.autoTuneViewModel.noHardwareFacts`);case`no-measured-data`:return G.t(`helpers.autoTuneViewModel.noMeasuredData`);case`no-family-build`:return G.t(`helpers.autoTuneViewModel.noFamilyBuild`,{format:e.format});case`kept-custom-pin`:return G.t(`helpers.autoTuneViewModel.keptCustomPin`,{modelId:e.modelId,deviceKey:e.deviceKey})}}function xi(e,t){switch(e.kind){case`detector-store-cluster-wide`:return G.t(`helpers.autoTuneViewModel.detectorStoreClusterWide`,{nodes:e.skippedNodes.map(t).join(`, `)});case`detector-store-unreadable`:return G.t(`helpers.autoTuneViewModel.detectorStoreUnreadable`,{error:e.error});case`coral-enabled`:return G.t(`helpers.autoTuneViewModel.coralEnabled`,{node:t(e.nodeId),deviceKey:e.deviceKey});case`custom-pin-kept`:return e.deviceId===null?G.t(`helpers.autoTuneViewModel.customPinNode`,{node:t(e.nodeId),modelId:e.modelId,deviceKey:e.deviceKey??`—`}):G.t(`helpers.autoTuneViewModel.customPinCamera`,{deviceId:e.deviceId,modelId:e.modelId,node:t(e.nodeId)});case`custom-registry-unreadable`:return G.t(`helpers.autoTuneViewModel.customRegistryUnreadable`,{error:e.error})}}function Si(e){let t=e.nodeChanges.reduce((e,t)=>e+t.modelPins.length,0),n=e.nodeChanges.reduce((e,t)=>e+t.thresholds.length,0),r=new Set([...e.cameraClears.map(e=>e.deviceId),...e.detectorStoreClears.map(e=>e.deviceId)]);return{modelChanges:t,thresholdClears:n,cameraOverrideClears:e.cameraClears.length,detectorStoreClears:e.detectorStoreClears.length,camerasTouched:r.size}}function Ci(e){let t=Si(e);return t.modelChanges+t.thresholdClears+t.cameraOverrideClears+t.detectorStoreClears===0}function wi(e,t,n){let r=e.nodeChanges.find(e=>e.nodeId===t&&e.deviceKey===n)?.modelPins.find(e=>e.stepId===`object-detection`);return r===void 0?null:{before:r.before,after:r.after}}function Ti(e,t){return e?.kind===`node-benchmark`?G.t(`helpers.autoTuneViewModel.latencyMeasured`,{date:new Date(e.measuredAtMs).toLocaleDateString(t,{day:`numeric`,month:`short`})}):G.t(`helpers.autoTuneViewModel.latencyTable`)}t();var Ei=[.3,.4,.5];function Di(e){return Ei.some(t=>t===e)}var Oi=[1,2,3,4,6,8];function ki({plan:e,node:t,nodeName:n}){let{t:r}=K();return o(`section`,{className:x,"data-testid":`auto-tune-node-${t.nodeId}`,children:[o(`header`,{className:`${I} flex flex-wrap items-center gap-2`,children:[f(g,{className:`h-3.5 w-3.5 shrink-0 text-foreground-subtle`,"aria-hidden":!0}),f(`h3`,{className:`${T} min-w-0 flex-1`,children:n(t.nodeId)}),o(`span`,{className:`text-[11px] text-foreground-subtle`,children:[yi(t.hardwareClass),t.cpuModel===null?``:` · ${t.cpuModel}`]}),t.skipped?f(U,{variant:`warning`,children:r(`pipeline.clusterAutoTuneTab.notChanged`,`Not changed`)}):t.acceleratorModelId!==null&&f(U,{variant:`info`,children:t.acceleratorModelId})]}),t.reasons.length>0&&f(`ul`,{className:`px-3 pt-2 text-[11px] text-foreground-muted`,children:t.reasons.map((e,t)=>f(`li`,{children:bi(e)},t))}),f(`div`,{className:`overflow-x-auto`,children:o(`table`,{className:`w-full text-xs`,children:[f(`thead`,{children:o(`tr`,{className:`text-left text-[11px] text-foreground-subtle`,children:[f(`th`,{className:`px-3 py-1.5 font-medium`,children:r(`pipeline.clusterAutoTuneTab.device`,`Device`)}),f(`th`,{className:`px-3 py-1.5 font-medium`,children:r(`pipeline.clusterAutoTuneTab.capacity`,`Capacity`)}),f(`th`,{className:`px-3 py-1.5 font-medium`,children:r(`pipeline.clusterAutoTuneTab.detector`,`Detector`)}),f(`th`,{className:`px-3 py-1.5 font-medium`,children:r(`pipeline.clusterAutoTuneTab.why`,`Why`)})]})}),f(`tbody`,{children:t.devices.map(n=>{let i=wi(e,t.nodeId,n.deviceKey);return o(`tr`,{className:`border-t border-border align-top`,children:[o(`td`,{className:`px-3 py-1.5`,children:[f(`div`,{className:`font-mono text-foreground`,children:n.deviceKey}),f(`div`,{className:`text-[11px] text-foreground-subtle`,children:vi(n.accelerator)})]}),o(`td`,{className:`px-3 py-1.5 text-foreground-muted`,children:[n.chosen===null?`—`:r(`pipeline.clusterAutoTuneTab.sessionsAtFps`,{count:n.chosen.capacitySessions,fps:e.cameraFps}),n.chosen!==null&&o(`div`,{className:`text-[11px] text-foreground-subtle`,children:[r(`pipeline.clusterAutoTuneTab.fpsKeptFree`,{fps:n.chosen.fps,percent:Math.round(e.headroom*100)}),f(`div`,{children:Ti(n.chosen.source)})]})]}),f(`td`,{className:`px-3 py-1.5`,children:n.chosen===null?f(`span`,{className:`text-foreground-subtle`,children:r(`common.unchanged`)}):i!==null&&i.before!==i.after?o(`span`,{children:[f(`span`,{className:`text-foreground-subtle`,children:i.before??r(`common.defaultWord`)}),` → `,f(`span`,{className:`font-medium text-foreground`,children:i.after})]}):f(`span`,{className:`text-foreground`,children:n.chosen.modelId})}),f(`td`,{className:`px-3 py-1.5 text-[11px] text-foreground-muted`,children:n.reasons.map((e,t)=>f(`div`,{children:bi(e)},t))})]},n.deviceKey)})})]})})]})}function Ai({plan:e,nameOf:t,nodeName:n}){let{t:r}=K();return o(`div`,{className:`flex flex-col gap-3 text-xs`,"data-testid":`auto-tune-change-list`,children:[o(`div`,{children:[f(`div`,{className:T,children:r(`pipeline.clusterAutoTuneTab.nodeSettings`,`Node settings`)}),e.nodeChanges.length===0?f(`div`,{className:`text-foreground-subtle`,children:r(`pipeline.clusterAutoTuneTab.noChange`,`No change.`)}):f(`ul`,{className:`mt-1 flex flex-col gap-0.5`,children:e.nodeChanges.flatMap(e=>[...e.modelPins.map(t=>o(`li`,{children:[o(`span`,{className:`font-mono`,children:[n(e.nodeId),` · `,e.deviceKey]}),` `,`— `,t.stepId,`: `,t.before??r(`pipeline.clusterAutoTuneTab.defaultModel`),` →`,` `,t.after??r(`pipeline.clusterAutoTuneTab.stepDefault`,`step default`)]},`${e.nodeId}/${e.deviceKey}/${t.stepId}/pin`)),...e.thresholds.map(t=>o(`li`,{children:[o(`span`,{className:`font-mono`,children:[n(e.nodeId),` · `,e.deviceKey]}),` `,`—`,` `,r(`pipeline.clusterAutoTuneTab.thresholdReset`,{step:t.stepId,keys:t.keys.join(`, `)})]},`${e.nodeId}/${e.deviceKey}/${t.stepId}/thr`))])})]}),o(`div`,{children:[f(`div`,{className:T,children:r(`pipeline.clusterAutoTuneTab.cameraOverridesCleared`,`Camera overrides cleared`)}),e.cameraClears.length===0&&e.detectorStoreClears.length===0?f(`div`,{className:`text-foreground-subtle`,children:r(`pipeline.clusterAutoTuneTab.none`,`None.`)}):o(`ul`,{className:`mt-1 flex flex-col gap-0.5`,children:[e.cameraClears.map((e,i)=>o(`li`,{children:[t(e.deviceId),` — `,n(e.nodeId),e.deviceKey===null?` (${r(`pipeline.clusterAutoTuneTab.wholePipeline`)})`:` · ${e.deviceKey}`,` `,`— `,e.stepId,e.modelIdBefore===null?``:r(`pipeline.clusterAutoTuneTab.modelRemoved`,`: model {{modelIdBefore}} removed`,{modelIdBefore:e.modelIdBefore}),e.keys.length>0?r(`pipeline.clusterAutoTuneTab.reset`,`; {{value1}} reset`,{value1:e.keys.join(`, `)}):``]},`c${i}`)),e.detectorStoreClears.map(e=>o(`li`,{children:[t(e.deviceId),` —`,` `,r(`pipeline.clusterAutoTuneTab.detectorThresholdsReset`,{keys:e.keys.join(`, `)})]},`d${e.deviceId}`))]})]})]})}function ji({result:e}){let{t}=K();return e.kind===`refused`?f(`div`,{className:`text-xs text-warning`,children:t(`pipeline.clusterAutoTuneTab.anotherApplyIsAlreadyRunning`,`Another apply is already running.`)}):e.kind===`stale`?f(`div`,{className:`text-xs text-warning`,children:t(`pipeline.clusterAutoTuneTab.theConfigurationChangedSinceThe`,`The configuration changed since the plan was shown. Review the updated plan below and apply again.`)}):o(`ul`,{className:`text-xs`,"data-testid":`auto-tune-result`,children:[e.kind===`aborted`&&f(`li`,{className:`text-danger`,children:t(`pipeline.clusterAutoTuneTab.aModelCouldNotBe`,`A model could not be downloaded: nothing was changed.`)}),e.phases.map(e=>o(`li`,{className:e.ok?`text-foreground-muted`:`text-danger`,children:[e.ok?`✓`:`✗`,` `,e.phase,`: `,e.detail]},e.phase))]})}function Mi(){let{t:e}=K(),t=l(),[n,a]=i(.4),[s,c]=i(2),[u,d]=i(!1),[p,m]=i(!1),[h,g]=i(null),{data:_}=gn(),v=r(()=>new Map((_??[]).map(e=>[e.id,e.name])),[_]),y=t=>v.get(t)??e(`pipeline.clusterAutoTuneTab.cameraFallback`,{id:t}),{nodes:b}=W(),S=r(()=>er(b),[b]),C=vt({headroom:n,minSessionsPerDevice:s},{enabled:u,refetchOnWindowFocus:!1}),w=Be({onSuccess:e=>{g(e),m(!1),t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getNodeInferenceDevices`]]}),t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCameraStepOverrides`]]}),t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCameraSettings`]]}),e.kind===`applied`&&C.refetch()}}),D=h?.kind===`stale`?h.plan:C.data,O=D===void 0?null:Si(D);return o(`div`,{className:`flex flex-col gap-3`,"data-testid":`cluster-auto-tune`,children:[o(`section`,{className:x,children:[o(`header`,{className:`${I} flex flex-wrap items-center gap-2`,children:[f(E,{className:`h-3.5 w-3.5 shrink-0 text-foreground-subtle`,"aria-hidden":!0}),f(`h3`,{className:`${T} min-w-0 flex-1`,children:e(`pipeline.clusterAutoTuneTab.autoTune`,`Auto tune`)})]}),o(`div`,{className:`flex flex-col gap-2 px-3 py-2 text-xs text-foreground-muted`,children:[f(`p`,{children:e(`pipeline.clusterAutoTuneTab.picksForEveryAcceleratorThe`,`Picks, for every accelerator, the most accurate YOLOv9 detector that still carries at least the chosen number of cameras at once, from the node's hardware and measured speeds. Nothing is measured or estimated about your cameras' activity. Applying it sets those models and clears every model and threshold override — node level and per camera — so each model runs its own default thresholds. Enabled steps, devices, pins, recording, notifications, zones and rules are not touched. There is no undo.`)}),o(`div`,{className:`flex flex-wrap items-center gap-2`,children:[o(`label`,{className:`flex items-center gap-1.5`,children:[f(`span`,{className:`whitespace-nowrap`,children:e(`pipeline.clusterAutoTuneTab.keepFree`,`Keep free`)}),f(Ze,{"aria-label":e(`pipeline.clusterAutoTuneTab.shareOfEachAcceleratorKept`,`Share of each accelerator kept free`),value:String(n),options:Ei.map(t=>({value:String(t),label:e(`pipeline.clusterAutoTuneTab.ofEachAccelerator`,`{{value1}}% of each accelerator`,{value1:Math.round(t*100)})})),onChange:e=>{let t=Number(e.target.value);Di(t)&&a(t)}})]}),o(`label`,{className:`flex items-center gap-1.5`,children:[f(`span`,{className:`whitespace-nowrap`,children:e(`pipeline.clusterAutoTuneTab.atLeast`,`At least`)}),f(Ze,{"aria-label":e(`pipeline.clusterAutoTuneTab.minimumParallelSessionsPerDevice`,`Minimum parallel sessions per device`),value:String(s),options:Oi.map(t=>({value:String(t),label:e(`pipeline.clusterAutoTuneTab.camerasAtOnce`,{count:t})})),onChange:e=>{let t=Number(e.target.value);Oi.some(e=>e===t)&&c(t)}})]}),f(V,{size:`sm`,variant:`secondary`,onClick:()=>{g(null),d(!0),u&&C.refetch()},children:C.isFetching?e(`pipeline.clusterAutoTuneTab.computing`,`Computing…`):D===void 0?e(`pipeline.clusterAutoTuneTab.computePlan`,`Compute plan`):e(`pipeline.clusterAutoTuneTab.recompute`,`Recompute`)}),D!==void 0&&f(V,{size:`sm`,disabled:Ci(D),onClick:()=>m(!0),children:e(`pipeline.clusterAutoTuneTab.apply`,`Apply…`)})]}),C.error!==null&&f(`div`,{className:`text-danger`,children:C.error.message}),h!==null&&f(ji,{result:h}),O!==null&&f(`div`,{className:`text-[11px] text-foreground-subtle`,children:e(`pipeline.clusterAutoTuneTab.planSummary`,{modelChanges:O.modelChanges,thresholdClears:O.thresholdClears,overrides:O.cameraOverrideClears+O.detectorStoreClears,cameras:O.camerasTouched})})]})]}),D?.warnings.map((e,t)=>f(`div`,{className:`rounded-md border border-warning/40 bg-warning/10 px-3 py-2 text-xs text-warning`,children:xi(e,S)},t)),D?.nodes.map(e=>f(ki,{plan:D,node:e,nodeName:S},e.nodeId)),D!==void 0&&f(dt,{open:p,onOpenChange:m,children:o(Ve,{width:`lg`,scroll:`body`,children:[o(Le,{children:[f(Vt,{children:e(`pipeline.clusterAutoTuneTab.applyAutoTune`,`Apply auto tune?`)}),f(at,{children:e(`pipeline.clusterAutoTuneTab.theseAreAllTheChanges`,`These are all the changes. Every override listed is removed and cannot be restored.`)})]}),f(We,{children:f(Ai,{plan:D,nameOf:y,nodeName:S})}),o(Ht,{children:[f(V,{variant:`ghost`,onClick:()=>m(!1),children:e(`common.cancel`,`Cancel`)}),f(V,{variant:`danger`,disabled:w.isPending,onClick:()=>w.mutate({planHash:D.planHash,headroom:n,minSessionsPerDevice:s}),children:w.isPending?e(`pipeline.clusterAutoTuneTab.applying`,`Applying…`):e(`common.apply`,`Apply`)})]})]})})]})}var Ni={disabled:`pipeline.nodeLoadOverview.exclusion.disabled`,unavailable:`pipeline.nodeLoadOverview.exclusion.unavailable`,"cannot-host-camera-root":`pipeline.nodeLoadOverview.exclusion.cannotHostCameraRoot`,"accelerator-preferred":`pipeline.nodeLoadOverview.exclusion.acceleratorPreferred`};function Pi(e,t){return t<=0?0:Math.round(e/t*1e3)/10}function Fi(e){return e===void 0?!1:e.load.devices.reduce((e,t)=>e+t.attachedCameras,0)>=e.load.attachedCameras}function Ii(e,t,n){let r=e.filter(e=>e.exclusion===null).reduce((e,t)=>e+(t.weight>0?t.weight:1),0);return e.map(e=>{let i=t.get(e.key)??(n?0:null),a=e.weight>0?e.weight:1;return{key:e.key,label:Et(e),format:e.format,sessions:i,weight:a,weightSharePct:e.exclusion===null?Pi(a,r):null,maxSessions:e.maxSessions,atCap:e.maxSessions!==null&&i!==null&&i>=e.maxSessions,available:e.available,enabled:e.enabled,exclusion:e.exclusion}}).toSorted((e,t)=>e.exclusion===null==(t.exclusion===null)?e.key.localeCompare(t.key):e.exclusion===null?-1:1)}function Li(e){let t=new Map(e.loads.map(e=>[e.nodeId,e])),n=e.nodes.filter(e=>e.isOnline&&e.detectEnabled).reduce((e,t)=>e+(t.weight>0?t.weight:1),0);return e.nodes.map(r=>{let i=t.get(r.id),a=Ii(e.devicesByNode[r.id]??[],new Map((i?.load.devices??[]).map(e=>[e.deviceKey,e.attachedCameras])),Fi(i)),o=r.isOnline&&r.detectEnabled,s=r.weight>0?r.weight:1,c=i?.load.attachedCameras??null;return{nodeId:r.id,name:r.name,isOnline:r.isOnline,detectEnabled:r.detectEnabled,reported:i!==void 0,attachedCameras:c,activeCameras:i?.load.activeCameras??null,maxCameras:r.maxCameras,capacityPct:c!==null&&r.maxCameras!==null&&r.maxCameras>0?Pi(c,r.maxCameras):null,queueDepthTotal:i?.load.queueDepthTotal??null,avgInferenceTimeMs:i?.load.avgInferenceTimeMs??null,score:i?.score??null,weight:s,weightSharePct:o?Pi(s,n):null,decodeHwaccel:i?.decodeHwaccel??null,devices:a,eligibleDeviceCount:a.filter(e=>e.exclusion===null).length}})}t();var Ri=2e4,zi=3e5;function Bi({stats:e,targetWeights:t}){let{t:n}=K(),{nodes:i}=W(),a=te().trpcClient,o=Ge(void 0,{placeholderData:u,staleTime:Ri,refetchInterval:Ri,refetchOnWindowFocus:!0}),s=mt(void 0,{staleTime:zi}),l=r(()=>i.map(e=>e.id),[i]),d=c({queries:l.map(e=>({queryKey:Fe(mn.pipelineOrchestrator.getNodeInferenceDevices,{nodeId:e},`query`),queryFn:()=>a.pipelineOrchestrator.getNodeInferenceDevices.query({nodeId:e}),staleTime:zi,refetchOnWindowFocus:!1,placeholderData:u}))}),p=r(()=>{let e={};return l.forEach((t,n)=>{let r=d[n]?.data;r&&(e[t]=r.devices)}),e},[l,d.map(e=>e.dataUpdatedAt).join(`|`)]),h=r(()=>{let e=new Map;for(let t of s.data??[])e.set(t.nodeId,t.settings);return e},[s.data]),g=r(()=>i.map(e=>{let n=h.get(e.id);return{id:e.id,name:e.name,isOnline:e.isOnline,detectEnabled:Hn(n,e.isHub).pipeline,weight:t?.[e.id]??Cn(n,`detectWeight`)??1,maxCameras:Cn(n,`maxCameras`)}}),[i,h,t]),_=o.data??[],v=r(()=>Li({nodes:g,loads:_,devicesByNode:p}),[g,_,p]),y=v.reduce((e,t)=>e+(t.attachedCameras??0),0),b=v.reduce((e,t)=>e+(t.activeCameras??0),0),x=o.dataUpdatedAt>0?Date.now()-o.dataUpdatedAt:null,C=new Map((e?.nodes??[]).map(e=>[e.nodeId,e]));return f(H,{headingId:`load-balancing-node-load`,title:n(`pipeline.nodeLoadOverview.nodeLoad`,`Node load`),icon:S,actions:f(`span`,{className:`text-[10px] text-foreground-subtle tabular-nums`,children:n(`pipeline.nodeLoadOverview.summaryLine`,{active:b,attached:y,reading:o.data===void 0?n(`pipeline.nodeLoadOverview.reading`,`reading…`):n(`pipeline.nodeLoadOverview.readingAge`,{age:x===null?`—`:`${Math.round(x/1e3)}s`})})}),children:f(`div`,{className:m,children:v.length===0?f(`p`,{className:`text-[11px] italic text-foreground-subtle`,children:n(`pipeline.nodeLoadOverview.noClusterNodesReportedYet`,`No cluster nodes reported yet.`)}):f(`div`,{className:`grid gap-2 @2xl/clustertab:grid-cols-2 @5xl/clustertab:grid-cols-3`,children:v.map(e=>f(Vi,{row:e,placed:C.get(e.nodeId)},e.nodeId))})})})}function Vi({row:e,placed:t}){let{t:n}=K(),r=e.attachedCameras===null?`—`:`${e.activeCameras??0} / ${e.attachedCameras}${e.maxCameras===null?``:` of ${e.maxCameras}`}`;return o(`div`,{className:`rounded-lg border border-border bg-surface/60 p-2.5 min-w-0`,children:[o(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[f(`span`,{className:`h-1.5 w-1.5 shrink-0 rounded-full ${e.isOnline?`bg-emerald-400`:`bg-foreground-subtle/40`}`}),f(`span`,{className:`truncate text-xs font-medium text-foreground`,title:e.nodeId,children:e.name}),!e.detectEnabled&&f(`span`,{className:`shrink-0 rounded bg-surface-hover px-1 text-[9px] uppercase tracking-wide text-foreground-subtle`,children:n(`pipeline.nodeLoadOverview.noDetect`,`no detect`)}),!e.reported&&e.isOnline&&o(`span`,{className:`ml-auto inline-flex shrink-0 items-center gap-1 text-[9px] text-amber-400`,title:n(`pipeline.nodeLoadOverview.onlineButItDidNot`,`Online, but it did not answer the last load read — its numbers below are unknown, not zero.`),children:[f(b,{className:`h-2.5 w-2.5`}),` `,n(`pipeline.nodeLoadOverview.noReading`)]}),!e.isOnline&&o(`span`,{className:`ml-auto inline-flex shrink-0 items-center gap-1 text-[9px] text-foreground-subtle`,children:[f(k,{className:`h-2.5 w-2.5`}),` `,n(`common.offline`)]})]}),o(`dl`,{className:`mt-1.5 grid grid-cols-2 gap-x-2 gap-y-0.5 text-[10px]`,children:[f(J,{label:n(`pipeline.nodeLoadOverview.runningAttached`,`Running / attached`),value:r,title:n(`pipeline.nodeLoadOverview.sessionsInInferenceNowCameras`,`Sessions in inference now / cameras attached to this runner (the balancer's committed load) / operator cap.`)}),f(J,{label:n(`pipeline.nodeLoadOverview.targetShare`,`Target share`),value:e.weightSharePct===null?`out of play`:`${e.weightSharePct}%`,title:n(`pipeline.nodeLoadOverview.theNodeShareAutomaticOr`,`The node share (automatic or manual) normalised over the nodes the balancer actually ranks (online AND detect-enabled).`)}),f(J,{label:n(`pipeline.nodeLoadOverview.actualShare1H`,`Actual share (1 h)`),value:t?.observedShare===null||t===void 0?`—`:`${Math.round(t.observedShare*100)}%`,title:n(`pipeline.nodeLoadOverview.timeWeightedShareOfThe`,`Time-weighted share of the cluster's PARALLEL detection sessions this node carried over the last hour — the quantity a share holds. '—' = no session ran here in the window.`)}),f(J,{label:n(`pipeline.nodeLoadOverview.peakYields`,`Peak · yields`),value:t===void 0?`—`:`${t.peakSessions} · ${t.yieldsAway}`,title:n(`pipeline.nodeLoadOverview.mostSessionsThisNodeRan`,`Most sessions this node ran at once in the last hour, and how many share turns it handed to another node because it was full or drowning.`)}),f(J,{label:n(`pipeline.nodeLoadOverview.scoreQueue`,`Score · queue`),value:e.score===null?`—`:`${e.score} · ${e.queueDepthTotal??0}`,title:n(`pipeline.nodeLoadOverview.theCapacityScoreBalanceMinimises`,`The capacity score balance() minimises (attached + queue depth), and the raw queue depth.`)}),e.capacityPct!==null&&f(J,{label:n(`pipeline.nodeLoadOverview.capFill`,`Cap fill`),value:`${e.capacityPct}%`,title:n(`pipeline.nodeLoadOverview.attachedMaxcameras`,`attached / maxCameras.`)}),e.avgInferenceTimeMs!==null&&f(J,{label:n(`pipeline.nodeLoadOverview.avgInfer`,`Avg infer`),value:`${Math.round(e.avgInferenceTimeMs)} ms`,title:n(`pipeline.nodeLoadOverview.meanInferenceTimeAcrossThis`,`Mean inference time across this node's attached cameras.`)}),e.decodeHwaccel!==null&&f(J,{label:n(`pipeline.nodeLoadOverview.decode`,`Decode`),value:e.decodeHwaccel,title:n(`pipeline.nodeLoadOverview.thisNodeSProbedDecode`,`This node's probed decode hwaccel.`)})]}),f(Hi,{row:e})]})}function Hi({row:e}){let{t}=K();return e.devices.length===0?f(`p`,{className:`mt-2 text-[10px] italic text-foreground-subtle`,children:t(`pipeline.nodeLoadOverview.acceleratorsNotReadYet`,`Accelerators not read yet.`)}):o(`div`,{className:`mt-2 border-t border-border pt-1.5`,children:[o(`div`,{className:`flex items-center gap-1 text-[9px] uppercase tracking-wider text-foreground-subtle`,children:[f(w,{className:`h-2.5 w-2.5`}),t(`pipeline.nodeLoadOverview.accelerators`,`Accelerators`),e.eligibleDeviceCount===0&&f(`span`,{className:`ml-1 normal-case tracking-normal text-amber-400`,title:t(`pipeline.nodeLoadOverview.noDeviceIsACamera`,`No device is a camera-root candidate on this node — sessions run on the runner's default (CPU) pool.`),children:t(`pipeline.nodeLoadOverview.noneInPlayRunnerDefault`,`none in play · runner default pool`)})]}),f(`ul`,{className:`mt-1 space-y-0.5`,children:e.devices.map(e=>f(Ui,{device:e},e.key))})]})}function Ui({device:e}){let{t}=K(),n=e.exclusion;return o(`li`,{className:`flex items-baseline gap-1.5 text-[10px] min-w-0`,children:[f(g,{className:`h-2.5 w-2.5 shrink-0 ${n===null?`text-foreground-subtle`:`text-foreground-subtle/50`}`}),f(`span`,{className:`shrink-0 font-medium ${n===null?`text-foreground`:`text-foreground-subtle`}`,title:`${e.key} · ${e.format}`,children:e.label}),n===null?o(s,{children:[f(`span`,{className:`shrink-0 tabular-nums text-foreground-subtle`,children:t(`pipeline.nodeLoadOverview.sharePct`,{pct:e.weightSharePct})}),o(`span`,{className:`shrink-0 tabular-nums text-foreground-subtle`,title:e.sessions===null?t(`pipeline.nodeLoadOverview.notKnownTheNodeDid`,`Not known: the node did not report, or runs a session no device accounts for.`):void 0,children:[`· `,t(`common.sessionsCount`,{count:e.sessions??0}),e.maxSessions===null?``:`/${e.maxSessions}`]}),e.atCap&&f(`span`,{className:`shrink-0 text-amber-400`,title:t(`pipeline.nodeLoadOverview.atItsMaxsessionsCapThe`,`At its maxSessions cap — the balancer skips it until a session ends.`),children:t(`pipeline.nodeLoadOverview.atCap`,`· at cap`)})]}):f(`span`,{className:`truncate text-foreground-subtle/80`,title:t(Ni[n]),children:t(`pipeline.nodeLoadOverview.excludedWith`,{reason:t(Ni[n])})})]})}function J({label:e,value:t,title:n}){return o(`div`,{className:`min-w-0`,title:n,children:[f(`dt`,{className:`text-[9px] uppercase tracking-wide text-foreground-subtle`,children:e}),f(`dd`,{className:`truncate font-medium tabular-nums text-foreground`,children:t})]})}function Wi(e){return{nodes:Object.fromEntries(e.map(e=>[e.nodeId,Math.max(1,e.weight)])),devices:{}}}function Gi(e){let t={},n={};for(let r of e.nodes){if(r.share===null||r.share<=0)continue;t[r.nodeId]=r.share;let e=Object.fromEntries(r.devices.filter(e=>e.share>0).map(e=>[e.deviceKey,e.share]));Object.keys(e).length>0&&(n[r.nodeId]=e)}return{nodes:t,devices:n}}function Ki(e){return Object.fromEntries(e.nodes.map(e=>[e.nodeId,Object.fromEntries(e.devices.map(e=>[e.deviceKey,e.suggestedMaxSessions]))]))}function qi(e){return e.reason===`disabled`?G.t(`helpers.loadBalancingViewModel.stalePinDisabled`,{deviceKey:e.deviceKey}):G.t(`helpers.loadBalancingViewModel.stalePinMissing`,{deviceKey:e.deviceKey})}function Ji(e,t){if(t===void 0||t.source===`manual`||t.autoPending)return{nodes:e,readOnly:t!==void 0&&t.source!==`manual`};let n=new Map(t.nodes.map(e=>[e.nodeId,e.configuredPct]));return{nodes:e.map(e=>({...e,weight:Math.round(n.get(e.id)??e.weight)})),readOnly:!0}}function Yi(e,t){let n=e.nodes.filter(e=>!e.eligible);if(n.length===0)return null;let r=e.nodes.filter(e=>e.eligible).map(e=>`${t(e.nodeId)} ${Math.round(e.effectivePct)}%`).join(`, `),i=n.map(e=>t(e.nodeId)).join(`, `);return G.t(`helpers.loadBalancingViewModel.shareNote`,{count:n.length,names:i,into:r})}var Xi=[{value:`hardware`,get label(){return G.t(`helpers.loadBalancingViewModel.hardwareLabel`)},get hint(){return G.t(`helpers.loadBalancingViewModel.hardwareHint`)}},{value:`benchmark`,get label(){return G.t(`helpers.loadBalancingViewModel.benchmarkLabel`)},get hint(){return G.t(`helpers.loadBalancingViewModel.benchmarkHint`)}},{value:`manual`,get label(){return G.t(`helpers.loadBalancingViewModel.manualLabel`)},get hint(){return G.t(`helpers.loadBalancingViewModel.manualHint`)}}];function Zi(e){return e===`no-benchmark-results`?G.t(`helpers.loadBalancingViewModel.fallbackNone`):e===`partial-benchmark-results`?G.t(`helpers.loadBalancingViewModel.fallbackPartial`):null}function Qi(e,t){if(e.source!==`benchmark`)return null;let n=e.nodes.filter(e=>e.capacityFallback!==null);return n.length===0?null:n.map(e=>`${t(e.nodeId)}: ${Zi(e.capacityFallback)??``}`).join(` · `)}t();function $i(e,t,n){return Math.min(Math.max(e,t),n)}function ea(e){let t=e.reduce((e,t)=>e+Math.max(t.weight,0),0);if(t<=0){let t=e.length>0?100/e.length:0;return Object.fromEntries(e.map(e=>[e.id,t]))}return Object.fromEntries(e.map(e=>[e.id,Math.max(e.weight,0)/t*100]))}function ta(e,t,n,r,i){let a=i.filter(e=>e!==t&&r.has(e)).reduce((t,n)=>t+Math.max(e[n]??0,0),0),o=Math.max(0,100-a),s=i.filter(e=>e!==t&&!r.has(e)),c=s.length===0?o:$i(n,0,o),l={...e,[t]:c};if(s.length>0){let e=Math.max(0,o-c)/s.length;for(let t of s)l[t]=e}return l}function na(e,t,n){let r={},i=0,a=[];for(let o of t){let t=Math.max(e[o]??0,0);if(n.has(o)){let e=Math.round(t);r[o]=e,i+=e}else{let e=Math.floor(t);r[o]=e,a.push({id:o,floor:e,frac:t-e})}}let o=Math.max(0,100-i)-a.reduce((e,t)=>e+t.floor,0),s=[...a].sort((e,t)=>t.frac-e.frac);for(let e=0;o>0&&s.length>0;e+=1)r[s[e%s.length].id]+=1,--o;let c=[...a].sort((e,t)=>e.frac-t.frac);for(let e=0;o<0&&c.length>0;e+=1){let t=c[e%c.length].id;r[t]>0&&(--r[t],o+=1)}return r}function ra({nodes:e,pending:t,onCommitWeights:r,weightLabel:a=`Detection weight`,emptyHint:c,footnote:l,readOnly:u=!1}){let{t:d}=K(),[p,m]=i(()=>ea(e)),[h,g]=i(new Set);n(()=>{m(ea(e)),g(t=>new Set([...t].filter(t=>e.some(e=>e.id===t))))},[e.map(e=>`${e.id}:${e.weight}`).join(`|`)]);let _=e.map(e=>e.id),v=e=>{g(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},y=(e,t)=>{m(n=>ta(n,e,t,h,_))},b=()=>{let t=na(p,_,h),n=e.filter(e=>(t[e.id]??0)!==e.weight).map(e=>e.id);if(n.length===0)return;let i=new Set([...n,...h]);r(e.filter(e=>i.has(e.id)).map(e=>({nodeId:e.id,weight:t[e.id]??0})))};if(e.length===0)return f(`p`,{className:`rounded-lg border border-dashed border-border bg-background px-4 py-6 text-center text-xs text-foreground-subtle`,children:c??d(`placementBoard.weightSliderStack.noDetectEnabledNodesEnable`,`No detect-enabled nodes. Enable “Detect” on a node above to distribute detection weight.`)});let x=e.length===1;return o(`div`,{className:`space-y-3`,children:[e.map(e=>{let n=p[e.id]??0,r=h.has(e.id);return o(`div`,{className:`flex items-center gap-3`,children:[f(`span`,{className:`w-28 shrink-0 truncate text-xs font-medium text-foreground`,title:e.name,children:e.name}),f(`input`,{"aria-label":d(`placementBoard.weightSliderStack.for`,`{{weightLabel}} for {{name}}`,{weightLabel:a,name:e.name}),type:`range`,min:0,max:100,step:1,value:Math.round(n),disabled:u||t||r||x,onChange:t=>y(e.id,Number(t.target.value)),onPointerUp:()=>b(),onKeyUp:()=>b(),className:`h-1.5 flex-1 cursor-pointer accent-primary disabled:cursor-not-allowed disabled:opacity-50`}),o(`span`,{className:`w-10 shrink-0 text-right font-mono text-xs tabular-nums text-foreground`,children:[Math.round(n),`%`]}),!u&&f(`button`,{type:`button`,onClick:()=>v(e.id),disabled:t||x,"aria-pressed":r,title:r?d(`placementBoard.weightSliderStack.unlockAllowRebalancing`,`Unlock — allow rebalancing`):d(`placementBoard.weightSliderStack.lockThisShareWhenOthers`,`Lock this share when others change`),className:`shrink-0 rounded p-1 hover:bg-surface-hover disabled:opacity-40 ${r?`text-amber-400`:`text-foreground-subtle`}`,children:f(r?ee:re,{className:`h-3.5 w-3.5`})})]},e.id)}),f(`p`,{className:`text-[10px] leading-tight text-foreground-subtle`,children:l??f(s,{children:d(`placementBoard.weightSliderStack.draggingOneSliderSplitsThe`,`Dragging one slider splits the rest equally across the unlocked nodes; lock a node to pin its share — locked nodes never move and the total always stays at 100%, so a drag is bounded by the room the unlocked nodes leave. Detection only distributes across nodes that can source a camera’s frames.`)})})]})}function ia(e){let t=e.steps?.[`object-detection`]?.modelId;return typeof t==`string`&&t.length>0?t:typeof e.defaultModelId==`string`&&e.defaultModelId.length>0?e.defaultModelId:null}t();function aa(e){let t=Et(e),n=e.backend.toLowerCase(),r=e.device.toLowerCase();return e.key===`cpu`||r===`cpu`?{label:t,Icon:g,hue:`slate`}:r===`npu`?{label:t,Icon:ie,hue:`sky`}:r===`gpu`||r===`igpu`?{label:t,Icon:fe,hue:`violet`}:n===`edgetpu`?{label:t,Icon:ge,hue:`emerald`}:{label:t,Icon:g,hue:`slate`}}var oa={sky:`bg-sky-500/12 text-sky-400 ring-sky-500/25`,violet:`bg-violet-500/12 text-violet-400 ring-violet-500/25`,emerald:`bg-emerald-500/12 text-emerald-400 ring-emerald-500/25`,slate:`bg-surface-hover text-foreground-subtle ring-border`};function sa({nodeId:e,nodeName:t,isOnline:a,suggestedMaxSessions:c,autoDeviceShares:u}){let{t:d}=K(),p=l(),{data:m,isLoading:h}=tt({nodeId:e},{refetchInterval:15e3}),g=bt({onSettled:()=>{p.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getNodeInferenceDevices`]]})}}),_=m?.devices??[],v=m?.reachable??a,[y,b]=i({});n(()=>{b(Object.fromEntries(_.map(e=>[e.key,{enabled:e.enabled,weight:e.weight,maxSessions:e.maxSessions,steps:e.steps??{}}])))},[_.map(e=>`${e.key}:${e.enabled}:${e.weight}:${e.maxSessions}:${JSON.stringify(e.steps??{})}`).join(`|`)]);let x=r(()=>_.filter(e=>y[e.key]?.enabled??e.enabled).length,[_,y]),[S,C]=i(null),w=S??x>0,T=t=>{let n=_.map(e=>{let n=t[e.key]??E(e);return{key:e.key,enabled:n.enabled,weight:n.weight,maxSessions:n.maxSessions,steps:n.steps}});g.mutate({agentNodeId:e,inferenceDevices:Mr(n)})},E=e=>({enabled:e.enabled,weight:e.weight,maxSessions:e.maxSessions,steps:e.steps??{}}),D=e=>{if(!e.available)return;let t=y[e.key]??E(e),n={...y,[e.key]:{...t,enabled:!t.enabled}};b(n),T(n)},A=(e,t)=>{let n=y[e.key]??E(e),r={...y,[e.key]:{...n,maxSessions:t}};b(r),T(r)},j=r(()=>_.filter(e=>(y[e.key]?.enabled??e.enabled)&&e.available),[_,y]),M=r(()=>j.map(e=>({id:e.key,name:aa(e).label,weight:u===void 0?y[e.key]?.weight??e.weight:Math.round(u[e.key]??0)})),[j,y,u]);return o(`div`,{className:`rounded-lg border border-border bg-surface/60`,children:[o(`button`,{type:`button`,onClick:()=>C(!w),className:`flex w-full items-center gap-2.5 px-3.5 py-2.5 text-left`,"aria-expanded":w,children:[f(O,{className:`h-4 w-4 shrink-0 text-foreground-subtle transition-transform ${w?`rotate-90`:``}`}),f(`span`,{className:`truncate text-[13px] font-medium text-foreground`,children:t}),f(`span`,{className:`ml-auto flex items-center gap-2 text-[11px]`,children:v?x>=2?o(`span`,{className:`inline-flex items-center gap-1 text-emerald-400`,children:[f(ve,{className:`h-3.5 w-3.5`}),d(`pipeline.nodeInferenceDevices.accelerators`,{count:x})]}):x===1?f(`span`,{className:`text-foreground-subtle`,children:d(`placementBoard.nodeInferenceDevices.singleDefault`,`single default`)}):f(`span`,{className:`text-foreground-subtle/70`,children:d(`placementBoard.nodeInferenceDevices.autoDefault`,`auto default`)}):o(`span`,{className:`inline-flex items-center gap-1 text-foreground-subtle`,children:[f(k,{className:`h-3.5 w-3.5`}),` `,d(`common.unreachable`)]})})]}),w&&o(`div`,{className:`space-y-3 border-t border-border px-3.5 py-3`,children:[v?h&&_.length===0?f(`p`,{className:`rounded-lg border border-dashed border-border bg-background px-4 py-6 text-center text-xs text-foreground-subtle`,children:d(`placementBoard.nodeInferenceDevices.probingAccelerators`,`Probing accelerators…`)}):_.length===0?f(`p`,{className:`rounded-lg border border-dashed border-border bg-background px-4 py-6 text-center text-xs text-foreground-subtle`,children:d(`placementBoard.nodeInferenceDevices.noInferenceDevicesReportedBy`,`No inference devices reported by this node's platform probe.`)}):f(`ul`,{className:`space-y-2`,children:_.map(e=>{let t=aa(e),n=y[e.key]??E(e),r=n.enabled&&e.available,i=ia({defaultModelId:e.defaultModelId,steps:n.steps});return o(`li`,{className:`flex items-center gap-3 rounded-lg border px-3 py-2.5 transition-colors ${e.available?r?`border-primary/40 bg-primary/[0.04] ring-1 ring-inset ring-primary/20`:`border-border bg-surface`:`border-border/60 bg-background opacity-55`}`,children:[f(`span`,{className:`grid h-9 w-9 shrink-0 place-items-center rounded-md ring-1 ring-inset ${oa[t.hue]}`,children:f(t.Icon,{className:`h-4.5 w-4.5`})}),o(`div`,{className:`min-w-0 flex-1`,children:[o(`div`,{className:`flex items-center gap-2`,children:[f(`span`,{className:`truncate text-[13px] font-medium text-foreground`,children:t.label}),f(U,{variant:`default`,style:`outline`,className:`font-mono text-[9px]`,children:e.format}),!e.available&&f(U,{variant:`warning`,className:`text-[9px]`,children:d(`common.unavailable`)})]}),o(`div`,{className:`mt-0.5 flex items-center gap-1.5 text-[10px] text-foreground-subtle`,children:[f(`span`,{className:`font-mono`,children:e.key}),i!==null&&o(s,{children:[f(`span`,{"aria-hidden":!0,children:`·`}),f(`span`,{children:f(vn,{i18nKey:`pipeline.nodeInferenceDevices.rootModel`,values:{model:i},components:{mono:f(`span`,{className:`font-mono text-foreground/80`})}})})]})]})]}),r&&o(`label`,{className:`flex shrink-0 items-center gap-1 text-[10px] text-foreground-subtle`,children:[f(`span`,{className:`hidden @sm/clustertab:inline`,children:d(`pipeline.nodeInferenceDevices.cap`)}),f(`input`,{type:`number`,min:1,placeholder:`∞`,value:n.maxSessions??``,onChange:t=>{let n=t.target.value.trim(),r=n===``?null:Number.parseInt(n,10);A(e,r!=null&&r>0?r:null)},disabled:g.isPending,"aria-label":d(`placementBoard.nodeInferenceDevices.maxConcurrentSessionsFor`,`Max concurrent sessions for {{label}}`,{label:t.label}),className:`w-14 rounded border border-border bg-background px-1.5 py-1 text-right font-mono text-[11px] text-foreground focus:border-primary focus:outline-none`})]}),r&&f(ca,{suggested:c?.[e.key]??null,current:n.maxSessions,pending:g.isPending,onApply:t=>A(e,t)}),f(Bt,{checked:r,onCheckedChange:()=>D(e),disabled:!e.available||g.isPending,"aria-label":d(`placementBoard.nodeInferenceDevices.enable`,`Enable {{label}}`,{label:t.label}),className:e.available?``:`cursor-not-allowed opacity-50`})]},e.key)})}):f(la,{}),v&&j.length>=2&&o(`div`,{className:`space-y-3 rounded-lg border border-border bg-background/60 p-3.5`,children:[o(`h4`,{className:`flex items-center gap-1.5 text-xs font-semibold uppercase tracking-wide text-foreground-subtle`,children:[f(me,{className:`h-3.5 w-3.5`}),d(`placementBoard.nodeInferenceDevices.acceleratorShare`,`Accelerator share`)]}),f(ra,{nodes:M,pending:g.isPending,onCommitWeights:e=>{let t={...y};for(let n of e){let e=t[n.nodeId];e&&(t[n.nodeId]={...e,weight:n.weight})}b(t),T(t)},weightLabel:`Accelerator share`,readOnly:u!==void 0,footnote:u===void 0?f(s,{children:d(`placementBoard.nodeInferenceDevices.dragToShiftTheShare`,`Drag to shift the share of detection sessions each accelerator handles; lock one to pin its share while the others rebalance. Shares always sum to 100%.`)}):f(s,{children:d(`placementBoard.nodeInferenceDevices.automaticEachAcceleratorSShare`,`Automatic: each accelerator's share follows its measured throughput at its model. Switch the node shares to manual to set them yourself.`)})})]}),g.isError&&o(`div`,{className:`rounded-md border border-danger/30 bg-danger/5 px-3 py-2 text-[11px] text-danger`,children:[d(`placementBoard.nodeInferenceDevices.failedToSaveInferenceDevices`,`Failed to save inference devices:`),` `,g.error instanceof Error?g.error.message:d(`placementBoard.nodeInferenceDevices.unknownError`,`unknown error`)]})]})]})}function ca({suggested:e,current:t,pending:n,onApply:r}){let{t:i}=K();return e===null||e<1||e===t?null:f(V,{variant:`ghost`,size:`sm`,onClick:()=>r(e),disabled:n,title:i(`placementBoard.nodeInferenceDevices.advisoryCapFromTheMeasured`,`Advisory cap from the measured throughput at the suggested model, with the headroom kept free. Applying it writes this device's cap.`),children:i(`pipeline.nodeInferenceDevices.use`,{value:e})})}function la(){let{t:e}=K();return o(`div`,{className:`flex flex-col items-center gap-2 rounded-lg border border-dashed border-border bg-background px-4 py-8 text-center`,children:[f(k,{className:`h-6 w-6 text-foreground-subtle/60`}),f(`p`,{className:`text-xs font-medium text-foreground`,children:e(`placementBoard.nodeInferenceDevices.nodeUnreachable`,`Node unreachable`)}),f(`p`,{className:`max-w-sm text-[11px] text-foreground-subtle`,children:e(`placementBoard.nodeInferenceDevices.thePlatformProbeCouldnT`,`The platform probe couldn't be reached, so its live accelerator set is unavailable. Settings resume once the node reconnects.`)})]})}t();var ua=3600*1e3,da=2e4,fa=.4;function pa({refreshToken:e,onOpenAutoTune:t}){let{t:n}=K(),a=l(),{nodes:c}=W(),d=mt(void 0),p=Lt({isCamera:!0,projection:`slim`}),h=gt({windowMs:ua},{refetchInterval:da,placeholderData:u}).data,_=Ye(void 0,{refetchInterval:da,placeholderData:u}).data,v=()=>{Dn(a),a.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getNodeInferenceDevices`]]})},y=qt({onSuccess:v}),b=jt({onSuccess:()=>{v(),a.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getEffectiveShares`]]})}}),x=Tt({onSuccess:v}),S=qe(),[w,T]=i(!1),D=_?.source,O=D===`benchmark`?`benchmark`:`hardware`,k=Ut({headroom:fa,source:O},{enabled:w,staleTime:1/0}),A=k.data,j=r(()=>{let e=new Map((d.data??[]).map(e=>[e.nodeId,e.settings]));return c.filter(t=>Hn(e.get(t.id),t.isHub).pipeline).map(t=>{let n=e.get(t.id);return{id:t.id,name:t.name,isOnline:t.isOnline,weight:Cn(n,`detectWeight`)??1,maxCameras:Cn(n,`maxCameras`)}})},[c,d.data]),M=e=>c.find(t=>t.id===e)?.name??e,N=tr((p.data??[]).map(e=>({id:e.id,name:e.name}))),P=A?Ki(A):void 0,F=Ji(j,_),I=D!==`manual`,ee=e=>{if(_===void 0||_.source===`manual`||_.autoPending)return;let t=_.nodes.find(t=>t.nodeId===e);return t===void 0?void 0:Object.fromEntries(t.devices.map(e=>[e.deviceKey,e.configuredPct]))},te=_?Yi(_,M):null,ne=_?Qi(_,M):null,re=Xi.find(e=>e.value===D)?.hint;return o(`div`,{className:`space-y-3 sm:space-y-4`,children:[f(bn,{nodeId:`hub`,addonIds:[jn],level:`global`,sectionIds:[`load`],title:n(`pipeline.clusterLoadBalancingTab.placementPolicy`,`Placement policy`),description:n(`pipeline.clusterLoadBalancingTab.howANewDetectionSession`,`How a new detection session picks its node and device, and what happens when a node falls behind. 'Honour shares' (default) holds the shares below for PARALLEL sessions.`)}),f(qn,{refreshToken:e}),f(Bi,{stats:h,..._!==void 0&&_.source!==`manual`&&!_.autoPending?{targetWeights:Object.fromEntries(_.nodes.map(e=>[e.nodeId,e.configuredPct]))}:{}}),f(H,{headingId:`load-balancing-node-shares`,title:n(`pipeline.clusterLoadBalancingTab.nodeShares`,`Node shares`),icon:me,actions:o(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[f(`div`,{role:`radiogroup`,"aria-label":n(`pipeline.clusterLoadBalancingTab.shareSource`,`Share source`),className:`flex items-center gap-1`,children:Xi.map(e=>f(V,{role:`radio`,"aria-checked":D===e.value,variant:D===e.value?`primary`:`outline`,size:`sm`,title:e.hint,disabled:b.isPending||_===void 0,onClick:()=>{D!==e.value&&b.mutate({source:e.value})},children:e.label},e.value))}),o(V,{variant:`outline`,size:`sm`,onClick:()=>{T(!0),w&&k.refetch()},disabled:k.isFetching,children:[f(L,{className:`h-3.5 w-3.5`}),k.isFetching?n(`pipeline.clusterLoadBalancingTab.suggesting`,`Suggesting…`):O===`benchmark`?n(`pipeline.clusterLoadBalancingTab.suggestFromBenchmark`,`Suggest from benchmark`):n(`pipeline.clusterLoadBalancingTab.suggestFromHardware`,`Suggest from hardware`)]}),o(V,{variant:`ghost`,size:`sm`,onClick:t,children:[f(E,{className:`h-3.5 w-3.5`}),n(`pipeline.clusterLoadBalancingTab.autoTune`,`Auto tune`)]}),o(V,{variant:`outline`,size:`sm`,onClick:()=>S.mutate(void 0),disabled:S.isPending,title:n(`pipeline.clusterLoadBalancingTab.moveStandingAlwaysOnCameras`,`Move standing (always-on) cameras that are no longer on their best node. Pinned cameras never move; on-motion sessions are placed per session anyway.`),children:[f(ie,{className:`h-3.5 w-3.5`}),S.isPending?n(`pipeline.clusterLoadBalancingTab.rebalancing`,`Rebalancing…`):n(`pipeline.clusterLoadBalancingTab.rebalance`,`Rebalance`)]})]}),children:o(`div`,{className:`${m} space-y-3`,children:[re!==void 0&&f(`p`,{className:`text-[10px] text-foreground-subtle`,children:re}),h&&o(`p`,{className:`text-[10px] text-foreground-subtle`,children:[n(`pipeline.clusterLoadBalancingTab.policy`,`Policy:`),` `,f(U,{variant:h.policy===`share`?`info`:`default`,children:h.policy===`share`?n(`pipeline.clusterLoadBalancingTab.honourShares`,`honour shares`):`least-loaded`}),` `,` · ${n(`pipeline.clusterLoadBalancingTab.clusterPeak`,{count:h.clusterPeakSessions})}`,h.policy===`least-loaded`&&` · ${n(`pipeline.clusterLoadBalancingTab.leastLoadedNote`)}`]}),f(ra,{nodes:F.nodes,pending:y.isPending,readOnly:F.readOnly,onCommitWeights:e=>y.mutate(Wi(e)),weightLabel:`Node share`,...F.readOnly?{footnote:_?.autoPending?f(s,{children:n(`pipeline.clusterLoadBalancingTab.automaticSharesAreBeingComputed`,`Automatic shares are being computed from the cluster's measured capacity; the stored values are used meanwhile.`)}):o(s,{children:[D===`benchmark`?n(`pipeline.clusterLoadBalancingTab.benchmarkEachNodeSShare`,`Benchmark: each node's share follows its measured capacity from node benchmark results (hardware capacity where it has none)`):n(`pipeline.clusterLoadBalancingTab.hardwareEachNodeSShare`,`Hardware: each node's share follows its capacity at its Auto tune model, from the measured speed of its hardware`),n(`pipeline.clusterLoadBalancingTab.recomputedWheneverANodeOr`,`, recomputed whenever a node or accelerator is added, removed, switched on or off, or changes model`),_?.computedAt!=null&&f(`span`,{className:`ml-1`,children:n(_.trigger===null?`pipeline.clusterLoadBalancingTab.lastAt`:`pipeline.clusterLoadBalancingTab.lastAtTrigger`,{time:new Date(_.computedAt).toLocaleTimeString(),trigger:_.trigger??``})}),`.`]})}:{}}),te!==null&&f(`p`,{className:`text-[10px] text-foreground-subtle`,children:te}),ne!==null&&f(`p`,{className:`text-[10px] text-foreground-subtle`,"data-testid":`benchmark-fallback-note`,children:ne}),b.isError&&f(et,{message:n(`pipeline.clusterLoadBalancingTab.switchFailed`,{message:b.error instanceof Error?b.error.message:n(`common.unknownError`)})}),y.isError&&f(et,{message:n(`pipeline.clusterLoadBalancingTab.saveFailed`,{message:y.error instanceof Error?y.error.message:n(`common.unknownError`)})}),o(`details`,{className:`rounded-md border border-border`,children:[f(`summary`,{className:`${C} cursor-pointer text-xs text-foreground`,children:n(`pipeline.clusterLoadBalancingTab.maxConcurrentSessionsAdvanced`,`Max concurrent sessions (advanced)`)}),f(`ul`,{className:`divide-y divide-border border-t border-border`,children:j.map(e=>o(`li`,{className:`${C} flex items-center gap-2`,children:[f(`span`,{className:`min-w-0 flex-1 truncate text-xs text-foreground`,children:e.name}),f(Ie,{type:`number`,min:1,placeholder:`∞`,defaultValue:e.maxCameras??``,"aria-label":n(`pipeline.clusterLoadBalancingTab.maxConcurrentSessionsFor`,`Max concurrent sessions for {{name}}`,{name:e.name}),className:`w-20 text-right`,disabled:x.isPending,onBlur:t=>{let n=t.target.value.trim(),r=n===``?null:Number.parseInt(n,10),i=r!==null&&r>0?r:null;i!==e.maxCameras&&x.mutate({agentNodeId:e.id,maxCameras:i})}})]},e.id))}),f(`p`,{className:`${C} ${B} border-t border-border`,children:n(`pipeline.clusterLoadBalancingTab.aHardCapOnThe`,`A hard cap on the sessions a node runs at once (always-on cameras count too). A node at its cap is never chosen; under shares its turn goes to a free node. Empty = unlimited.`)})]})]})}),k.isError&&f(et,{message:n(`pipeline.clusterLoadBalancingTab.suggestionFailed`,{message:k.error instanceof Error?k.error.message:n(`common.unknownError`)})}),A&&f(ma,{suggestion:A,nameOf:M,pending:y.isPending,...I?{}:{onApply:()=>y.mutate(Gi(A))}}),f(H,{headingId:`load-balancing-accelerators`,title:n(`pipeline.clusterLoadBalancingTab.accelerators`,`Accelerators`),icon:g,children:f(`div`,{className:`${m} space-y-2`,children:j.length===0?f(st,{title:n(`pipeline.clusterLoadBalancingTab.noDetectCapableNodes`,`No detect-capable nodes`),description:n(`pipeline.clusterLoadBalancingTab.enableDetectionOnANode`,`Enable detection on a node in Roles & nodes to configure its accelerators.`)}):j.map(e=>f(sa,{nodeId:e.id,nodeName:e.name,isOnline:e.isOnline,...P?.[e.id]===void 0?{}:{suggestedMaxSessions:P[e.id]},...ee(e.id)===void 0?{}:{autoDeviceShares:ee(e.id)}},e.id))})}),h!==void 0&&h.stalePins.length>0&&f(ha,{stats:h,cameraName:N})]})}function ma({suggestion:e,nameOf:t,pending:n,onApply:r}){let{t:i}=K();return o(H,{headingId:`load-balancing-suggestion`,title:e.source===`benchmark`?i(`pipeline.clusterLoadBalancingTab.suggestedFromBenchmark`,`Suggested from benchmark`):i(`pipeline.clusterLoadBalancingTab.suggestedFromHardware`,`Suggested from hardware`),icon:L,...r===void 0?{}:{actions:f(V,{size:`sm`,onClick:r,disabled:n,children:i(`pipeline.clusterLoadBalancingTab.applySuggestedShares`,`Apply suggested shares`)})},children:[f(`ul`,{className:`divide-y divide-border`,children:e.nodes.map(e=>o(`li`,{className:`${C} space-y-0.5`,children:[o(`div`,{className:`flex items-baseline gap-2 text-xs`,children:[f(`span`,{className:`min-w-0 flex-1 truncate font-medium text-foreground`,children:t(e.nodeId)}),f(`span`,{className:`tabular-nums text-foreground`,children:e.share===null?i(`common.skipped`):`${e.share}%`})]}),o(`p`,{className:B,children:[Zi(e.capacityFallback)===null?``:`${Zi(e.capacityFallback)} · `,e.skippedReason===null?i(`pipeline.clusterLoadBalancingTab.parallelSessions`,`≈ {{capacitySessions}} parallel sessions · {{value2}}`,{capacitySessions:e.capacitySessions,value2:e.devices.map(e=>`${e.deviceKey} ${e.share}% (${e.modelId??`—`}${e.measured?``:`, estimated`}, cap ${e.suggestedMaxSessions??`—`})`).join(` · `)}):i(`pipeline.clusterLoadBalancingTab.notPartOfTheSuggestion`,`not part of the suggestion — {{skippedReason}}`,{skippedReason:e.skippedReason})]})]},e.nodeId))}),o(`p`,{className:`${C} ${B} border-t border-border`,children:[i(`pipeline.clusterLoadBalancingTab.sharesIntro`,{fps:e.cameraFps,headroom:Math.round(e.headroom*100),basis:e.source===`benchmark`?i(`pipeline.clusterLoadBalancingTab.measuredByNodeBenchmarksOr`,`measured by node benchmarks, or from the hardware table where a node has no results`):i(`pipeline.clusterLoadBalancingTab.atTheModelsAutoTune`,`at the models Auto tune picks (at least {{minSessionsPerDevice}} per accelerator), from the measured speed of each node's hardware`,{minSessionsPerDevice:e.minSessionsPerDevice})}),` `,r===void 0?i(`pipeline.clusterLoadBalancingTab.automaticSharesAlreadyFollowThis`,`Automatic shares already follow this; the caps are advisory — apply each from its accelerator row.`):i(`pipeline.clusterLoadBalancingTab.applyingWritesTheNodeAnd`,`Applying writes the node and accelerator shares; the caps are advisory — apply each from its accelerator row.`)]})]})}function ha({stats:e,cameraName:t}){let{t:n}=K(),r=l(),i=tn({onSuccess:()=>{r.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPlacementStats`]]}),r.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineDevicePin`]]})}});return f(H,{headingId:`load-balancing-stale-pins`,title:n(`pipeline.clusterLoadBalancingTab.staleDevicePins`,`Stale device pins`),icon:he,children:f(`ul`,{className:`divide-y divide-border`,children:e.stalePins.map(e=>o(`li`,{className:`${C} flex items-center gap-2`,children:[o(`div`,{className:`min-w-0 flex-1`,children:[f(`p`,{className:`truncate text-xs text-foreground`,title:t(e.deviceId),children:t(e.deviceId)}),f(`p`,{className:B,children:qi(e)})]}),f(V,{variant:`outline`,size:`sm`,disabled:i.isPending,onClick:()=>i.mutate({deviceId:e.deviceId,deviceKey:`auto`}),children:n(`pipeline.clusterLoadBalancingTab.clearPin`,`Clear pin`)})]},e.deviceId))})})}function ga({node:e,emphasis:t=!1}){let{t:n}=K(),r=e.isHub?z:g;return o(`div`,{className:`flex items-center gap-2.5 min-w-0`,children:[f(`span`,{className:`h-2 w-2 shrink-0 rounded-full ${e.isOnline?`bg-success`:`bg-danger`}`,"aria-hidden":`true`}),f(r,{className:`h-4 w-4 shrink-0 text-foreground-subtle`,"aria-hidden":`true`}),o(`div`,{className:`min-w-0`,children:[o(`div`,{className:`flex items-center gap-1.5 ${t?`text-sm`:`text-xs`} font-semibold text-foreground`,children:[f(`span`,{className:`truncate`,children:e.name}),e.isHub&&f(U,{variant:`info`,className:`px-1.5 py-0 text-[9px] uppercase tracking-wider`,children:n(`common.hubWord`)}),!e.isOnline&&f(U,{variant:`danger`,className:`px-1.5 py-0 text-[9px] uppercase tracking-wider`,children:n(`common.offline`)})]}),f(`div`,{className:`font-mono text-[10px] text-foreground-subtle truncate`,children:e.id})]})]})}function _a({nodes:e,actions:t}){let{t:n}=K();return f(ht,{columns:[{key:`node`,header:n(`placementBoard.nodeCapabilitiesTable.node`,`Node`),sortValue:e=>e.name,render:e=>f(ga,{node:e})},...On.map(e=>({key:e.key,header:n(e.labelKey),align:`center`,notSortableReason:`A switch — sorting would move the row while it is being changed.`,render:r=>f(Bt,{"aria-label":n(`placementBoard.nodeCapabilitiesTable.on`,`{{label}} on {{name}}`,{label:n(e.labelKey),name:r.name}),title:n(e.hintKey),checked:Sn(r.effective,e.key),disabled:t.capabilityPending,onCheckedChange:n=>t.onToggleCapability(r.id,e.key,n)})}))],rows:e,rowKey:e=>e.id,bordered:!1,minWidthPx:720,rowClassName:e=>e.isOnline?void 0:`opacity-60`,emptyMessage:n(`placementBoard.nodeCapabilitiesTable.noClusterNodesReportingYet`,`No cluster nodes reporting yet.`)})}function va({roleValues:e,options:t,pending:n,onRoleChange:r}){let{t:i}=K(),a=t.map(e=>({value:e.id,label:e.id===`hub`?i(`placementBoard.roleControls.default`,`{{name}} (default)`,{name:e.name}):e.name}));return f(`ul`,{className:`divide-y divide-border`,children:Mn.map(t=>o(`li`,{className:`${C} flex flex-wrap items-center gap-x-3 gap-y-1.5`,children:[o(`div`,{className:`min-w-0 flex-1 basis-56`,children:[f(`div`,{className:`text-xs font-medium text-foreground`,children:wn(t)}),f(`p`,{className:B,children:Tn(t)})]}),f(`div`,{className:`w-full sm:w-48`,children:f(Ze,{"aria-label":i(`placementBoard.roleControls.node`,`{{value1}} node`,{value1:wn(t)}),value:e[t],disabled:n,options:a,onChange:e=>r(t,e.target.value)})})]},t))})}t();function ya(){let{t:e}=K(),t=l(),{nodes:n}=W(),i=mt(void 0),a=Kt({addonId:jn}),s=Kt({addonId:xn}),c=Kt({addonId:Nn}),u=()=>Dn(t),d=St({onSuccess:u}),p=Dt({onSuccess:u}),m=r(()=>{let e=new Map;for(let t of i.data??[])e.set(t.nodeId,t.settings);return e},[i.data]),h=r(()=>n.map(e=>{let t=m.get(e.id),n=Hn(t,e.isHub);return{id:e.id,name:e.name,isHub:e.isHub,isOnline:e.isOnline,settings:t,effective:n}}),[n,m]),g={ingestNode:An(a.data,`ingestNode`,`hub`),recordingNode:An(s.data,kn,`hub`),audioNode:An(a.data,`audioNode`,`hub`),motionNode:An(a.data,`motionNode`,`hub`),postProcessingNode:An(c.data,En,`hub`)},_=r(()=>{let e=n.filter(e=>e.isOnline).map(e=>e.id),t=e=>n.find(t=>t.id===e)?.name||e;return[...new Set([`hub`,...Mn.map(e=>g[e]),...e])].filter(e=>e.length>0).map(e=>({id:e,name:t(e)}))},[n,g]),v=i.isLoading||a.isLoading||s.isLoading||c.isLoading,y=(e,t,n)=>{d.mutate({agentNodeId:e,[t]:n})},b=(e,t)=>{if(e===`recordingNode`){p.mutate({addonId:xn,patch:{[kn]:t}});return}if(e===`postProcessingNode`){p.mutate({addonId:Nn,patch:{[En]:t}});return}p.mutate({addonId:jn,patch:{[e]:t}})},x={capabilityPending:d.isPending,onToggleCapability:y},S=v?f(A,{className:`h-3.5 w-3.5 animate-spin text-foreground-subtle`,"aria-label":e(`pipeline.clusterRolesNodesTab.loading`,`Loading`)}):null;return o(`div`,{className:`space-y-3 sm:space-y-4`,children:[o(H,{headingId:`roles-nodes-cluster-roles`,title:e(`pipeline.clusterRolesNodesTab.clusterRoles`,`Cluster roles`),icon:pe,actions:S,children:[f(`p`,{className:`${B} border-b border-border px-3 py-1.5 sm:px-4`,children:e(`pipeline.clusterRolesNodesTab.oneNodeHoldsEachRole`,`One node holds each role for every camera. Detection shares and caps are on Load balancing.`)}),f(va,{roleValues:g,options:_,pending:p.isPending,onRoleChange:b})]}),f(H,{headingId:`roles-nodes-node-capabilities`,title:e(`pipeline.clusterRolesNodesTab.nodeCapabilities`,`Node capabilities`),icon:z,children:f(_a,{nodes:h,actions:x})})]})}var ba=`pipeline-analytics`,xa=`face-gallery`,Sa=`pipeline-orchestrator`,Ca=`pipeline-runner`,wa=`audio-analyzer`;function Ta(e){return[...De.filter(t=>t.stepId===e).map(e=>be(e.stepId)),...xe.filter(t=>t.stepId===e).map(e=>Ae(e.stepId,e.key))]}var Ea=`faces`,Da=`semantic-search`,Oa=[{id:Ea,get title(){return G.t(`helpers.clusterSettingsSections.facesTitle`)},get hint(){return G.t(`helpers.clusterSettingsSections.facesHint`)},panels:[{addonId:Sa,fieldKeys:Ta(`face-embedding`)},{addonId:ba,capability:xa}]},{id:Da,get title(){return G.t(`helpers.clusterSettingsSections.semanticTitle`)},get hint(){return G.t(`helpers.clusterSettingsSections.semanticHint`)},panels:[{addonId:Sa,fieldKeys:Ta(`clip-embedding`)}]},{id:je,get title(){return G.t(`helpers.clusterSettingsSections.cropTitle`)},get hint(){return G.t(`helpers.clusterSettingsSections.cropHint`)},panels:[{addonId:Sa,sectionIds:[je]}]},{id:Oe,get title(){return G.t(`helpers.clusterSettingsSections.nativeTitle`)},get hint(){return G.t(`helpers.clusterSettingsSections.nativeHint`)},panels:[{addonId:Sa,sectionIds:[Oe]}]},{id:`runner-defaults`,get title(){return G.t(`helpers.clusterSettingsSections.runnerTitle`)},get hint(){return G.t(`helpers.clusterSettingsSections.runnerHint`)},panels:[{addonId:Ca,fieldScope:`cluster`},{addonId:wa,fieldScope:`cluster`}]},{id:`failover`,get title(){return G.t(`helpers.clusterSettingsSections.failoverTitle`)},get hint(){return G.t(`helpers.clusterSettingsSections.failoverHint`)},panels:[{addonId:Sa,sectionIds:[`failover`]}]}],ka={"cluster-step-models":Ea};function Aa(e){return e===`clip-embedding`?Da:Ea}t();var ja=2500,Ma={faces:ne,"semantic-search":E,"detail-crop":_e,"native-lease":ve,"runner-defaults":g,failover:R};function Na(e){n(()=>{if(e===null)return;let t=ka[e]??e,n=`[data-cluster-settings-card="${CSS.escape(t)}"]`,r=()=>{let e=document.querySelector(n);return e===null?!1:(e.scrollIntoView({block:`start`,behavior:`smooth`}),e.classList.add(`ring-2`,`ring-primary/60`),setTimeout(()=>e.classList.remove(`ring-2`,`ring-primary/60`),ja),!0)};if(r())return;let i=new MutationObserver(()=>{r()&&i.disconnect()});return i.observe(document.body,{childList:!0,subtree:!0}),()=>i.disconnect()},[e])}function Pa({section:e}){let{t}=K();return f(`div`,{"data-cluster-settings-card":e.id,className:`rounded-lg`,children:f(H,{headingId:`cluster-settings-${e.id}`,title:e.title,...Ma[e.id]===void 0?{}:{icon:Ma[e.id]},children:o(`div`,{className:`${m} space-y-3`,children:[f(`p`,{className:B,children:e.hint}),e.panels.map(e=>f(bn,{nodeId:`hub`,addonIds:[e.addonId],level:`global`,hideSectionChrome:!0,omitSectionIds:[`cluster`,`load`],emptyMessage:t(`pipeline.clusterSettingsTab.notAvailableTheAddonThat`,`Not available — the addon that owns these settings did not answer.`),...e.capability===void 0?{}:{capability:e.capability},...e.sectionIds===void 0?{}:{sectionIds:e.sectionIds},...e.fieldKeys===void 0?{}:{fieldKeys:e.fieldKeys},...e.fieldScope===void 0?{}:{fieldScope:e.fieldScope}},`${e.addonId}:${e.capability??``}`))]})})})}function Fa({refreshToken:e}){let[t]=yn();return Na(t.get(Lo)),f(`div`,{className:`space-y-3 sm:space-y-4`,children:Oa.map(e=>f(Pa,{section:e},e.id))})}var Ia=`pipeline-orchestrator`,La=200;function Ra(){let{t:e}=K();return o(`div`,{className:`flex flex-col gap-3`,children:[o(`div`,{children:[f(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:e(`pipeline.clusterOrchestratorLogsTab.orchestratorLogs`,`Orchestrator logs`)}),f(`p`,{className:`text-[11px] text-foreground-subtle`,children:e(`pipeline.clusterOrchestratorLogsTab.dispatchDecisionsBalancerMovesAnd`,`Dispatch decisions, balancer moves and failover events from the pipeline orchestrator. Streaming live; the device chip on a line tells which camera it refers to.`)})]}),f(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:f(pt,{addonId:Ia,limit:La,maxHeight:`max-h-[calc(100vh-360px)]`,showScope:!0,showDeviceChip:!0,showFilters:!1})})]})}var za=[{id:`assignments`,labelKey:`pipeline.clusterDetail.tabAssignments`},{id:`load-balancing`,labelKey:`pipeline.clusterDetail.tabLoadBalancing`},{id:`auto-tune`,labelKey:`pipeline.clusterDetail.tabAutoTune`},{id:`roles-nodes`,labelKey:`pipeline.clusterDetail.tabRoles`},{id:`settings`,labelKey:`common.settings`},{id:`logs`,labelKey:`common.logs`}];function Ba(e){return za.some(t=>t.id===e)}function Va({refreshToken:e}){let{t}=K(),[n,r]=yn(),i=n.get(Io),a=Ba(i)?i:`assignments`,s=e=>{r(t=>{let n=new URLSearchParams(t);return n.set(Io,e),n.delete(Lo),n},{replace:!0})};return o(`div`,{className:`flex flex-col h-full`,children:[o(`div`,{className:`px-4 sm:px-6 py-4 border-b border-border`,children:[f(`h2`,{className:`text-base font-semibold text-foreground`,children:t(`pipeline.clusterDetail.clusterOrchestration`,`Cluster Orchestration`)}),f(`div`,{className:`text-[11px] text-foreground-subtle mt-1`,children:t(`pipeline.clusterDetail.cameraAssignmentsLoadBalancingThe`,`Camera assignments, load balancing, the detector recommendation, cluster roles and settings.`)})]}),f(`div`,{className:`flex items-center gap-1 px-4 sm:px-6 border-b border-border overflow-x-auto`,children:za.map(e=>f(`button`,{type:`button`,onClick:()=>s(e.id),className:`shrink-0 whitespace-nowrap px-3 py-2 text-xs font-medium border-b-2 transition-colors ${a===e.id?`border-primary text-primary`:`border-transparent text-foreground-subtle hover:text-foreground`}`,children:t(e.labelKey)},e.id))}),o(`div`,{className:`flex-1 min-h-0 overflow-y-auto p-4 sm:p-6 @container/clustertab`,children:[a===`assignments`&&f(pi,{}),a===`load-balancing`&&f(pa,{refreshToken:e,onOpenAutoTune:()=>s(`auto-tune`)}),a===`auto-tune`&&f(Mi,{}),a===`roles-nodes`&&f(ya,{}),a===`settings`&&f(Fa,{refreshToken:e}),a===`logs`&&f(Ra,{})]})]})}var Ha=`armed:`;function Ua(e){return e.assignment.reasons.detection?.startsWith(Ha)===!0}function Wa(e){let{assignment:t,detection:n}=e;return n!==null&&n.provisioning.state===`failed`||t.detectionNodeId===null&&n===null&&!Ua(e)?`error`:n!==null&&n.phase===`active`?`healthy`:`idle`}function Ga(e){let t=[],n=[],{assignment:r,detection:i,broker:a}=e;i!==null&&i.provisioning.state===`failed`&&t.push({code:`provisioning-failed`,severity:`error`,message:i.provisioning.error!==void 0&&i.provisioning.error.length>0?G.t(`helpers.cameraCardModel.provisioningFailedWith`,{error:i.provisioning.error}):G.t(`helpers.cameraCardModel.provisioningFailed`)}),i!==null&&i.phase===`active`&&i.actualFps===0&&t.push({code:`detection-black-hole`,severity:`error`,message:G.t(`helpers.cameraCardModel.blackHole`)}),r.detectionNodeId===null&&i===null&&!Ua(e)&&n.push({code:`unassigned`,severity:`warning`,message:G.t(`helpers.cameraCardModel.unassigned`)});let o=e.degraded??[];if(o.length>0){let e=[...new Set(o.map(e=>e.stage))].join(`, `);n.push({code:`status-unreadable`,severity:`warning`,message:G.t(`helpers.cameraCardModel.statusUnreadable`,{stages:e})})}n.push(...Ja(e.cameraSensors));for(let e of a?.profiles??[])e.status===`streaming`&&e.inFps===0&&n.push({code:`broker-stalled`,severity:`warning`,message:G.t(`helpers.cameraCardModel.brokerStalled`,{profile:e.profile})});return[...t,...n]}function Ka(e){return e.state===`unreadable`&&we.state===`unreadable`&&e.reason===we.reason}function qa(e){switch(e.state){case`ready`:return null;case`missing`:return{code:`camera-sensor-missing`,severity:`warning`,message:G.t(`helpers.cameraCardModel.sensorMissing`,{addonId:e.addonId,stableId:e.stableId})};case`offline`:return{code:`camera-sensor-offline`,severity:`warning`,message:G.t(`helpers.cameraCardModel.sensorOffline`,{name:e.name,deviceId:e.deviceId,reason:e.reason})};case`unsupported`:return{code:`camera-sensor-unsupported`,severity:`warning`,message:G.t(`helpers.cameraCardModel.sensorUnsupported`,{name:e.name,deviceId:e.deviceId,reason:e.reason})};case`unreadable`:return{code:`camera-sensor-unreadable`,severity:`warning`,message:G.t(`helpers.cameraCardModel.sensorUnreadable`,{addonId:e.addonId,stableId:e.stableId,reason:e.reason})}}}function Ja(e){if(e===void 0||e.state===`not-configured`)return[];if(e.state===`unreadable`)return Ka(e)?[]:[{code:`camera-sensors-unreadable`,severity:`warning`,message:G.t(`helpers.cameraCardModel.sensorsUnreadable`,{reason:e.reason})}];let t=e.sensors.flatMap(e=>{let t=qa(e);return t===null?[]:[t]}),n=e.notForwarded===void 0?t:[Ya(e.notForwarded),...t];return e.notEnforced===void 0?n:[{code:`camera-sensors-not-enforced`,severity:`warning`,message:G.t(`helpers.cameraCardModel.notEnforced`)},...n]}function Ya(e){return{code:`camera-sensors-not-forwarded`,severity:`warning`,message:e===`onboard-not-listed`?G.t(`helpers.cameraCardModel.notForwardedOnboard`):G.t(`helpers.cameraCardModel.notForwardedNoDetection`)}}function Xa(e){return e===void 0?G.t(`helpers.cameraCardModel.summaryUnavailable`):e.state===`not-configured`?G.t(`helpers.cameraCardModel.summaryNone`):e.state===`unreadable`?G.t(`helpers.cameraCardModel.summaryUnknown`,{reason:e.reason}):e.sensors.map(Qa).join(`, `)}function Za(e){return e.mode===`in-addition`?``:` · ${e.mode}`}function Qa(e){return`${$a(e)}${Za(e)}`}function $a(e){switch(e.state){case`ready`:return`${e.name} (#${e.deviceId})`;case`offline`:return`${e.name} (#${e.deviceId}) — ${e.reason}`;case`unsupported`:return G.t(`helpers.cameraCardModel.summaryUnsupported`,{name:e.name,deviceId:e.deviceId});case`missing`:case`unreadable`:return`${e.addonId}/${e.stableId} — ${e.state}`}}function eo(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Y(e){return typeof e==`string`&&e.length>0?e:null}function to(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function no(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function ro(e,t){return e==null?!1:JSON.stringify(e)!==JSON.stringify(t??null)}var io={detectionMode:null,detectionStreamProfile:null,detectionFps:null,motionSources:[],motionFps:null,motionCooldownMs:null,motionStreamProfile:null,audioMode:null,pipelineNodeId:null,decoderNodeId:null,audioNodeId:null,overriddenKeys:new Set};function ao(e){if(!eo(e)||!Array.isArray(e.sections))return io;let t=Ne(e),n=e=>{let n=t.get(e);if(n!==void 0)return n.value??n.default},r=new Set;for(let[e,n]of t)ro(n.value,n.default)&&r.add(e);return{detectionMode:Y(n(`detectionMode`)),detectionStreamProfile:Y(n(`detectionStreamProfile`)),detectionFps:to(n(`detectionFps`)),motionSources:no(n(`motionSources`)),motionFps:to(n(`motionFps`)),motionCooldownMs:to(n(`motionCooldownMs`)),motionStreamProfile:Y(n(`motionStreamProfile`)),audioMode:Y(n(`audioMode`)),pipelineNodeId:Y(n(`pipelineNodeId`)),decoderNodeId:Y(n(`decoderNodeId`)),audioNodeId:Y(n(`audioNodeId`)),overriddenKeys:r}}function oo(e,t=0){let n=[];for(let r of e)n.push({addonId:r.addonId,modelId:r.modelId??null,enabled:r.enabled,depth:t}),r.children!==void 0&&r.children.length>0&&n.push(...oo(r.children,t+1));return n}function X({title:e,children:t}){return o(`div`,{className:`bg-background px-3.5 py-3 min-w-0`,children:[f(`div`,{className:`text-[9px] font-semibold uppercase tracking-[0.14em] text-foreground-subtle mb-2`,children:e}),f(`div`,{className:`flex flex-col gap-1 min-w-0`,children:t})]})}function Z({label:e,children:t,overridden:n=!1}){return o(`div`,{className:`flex items-baseline gap-2 text-[11px] leading-snug min-w-0`,children:[f(`span`,{className:`text-foreground-subtle shrink-0 w-24 truncate`,title:e,children:e}),f(`span`,{className:`font-mono tabular-nums text-foreground min-w-0 truncate flex-1`,children:t}),n&&f(so,{})]})}function so(){let{t:e}=K();return f(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full bg-warning shrink-0 self-center`,title:e(`cameras.cardPrimitives.deviceLevelOverrideActive`,`Device-level override active`),"aria-label":e(`cameras.cardPrimitives.deviceLevelOverrideActive`,`Device-level override active`),role:`img`})}var co={neutral:`border-border text-foreground-muted`,success:`border-success/40 text-success`,warning:`border-warning/40 text-warning`,danger:`border-danger/40 text-danger`,info:`border-info/40 text-info`};function Q({tone:e=`neutral`,children:t,title:n}){return f(`span`,{title:n,className:`inline-flex items-center gap-1 rounded border px-1.5 py-px text-[10px] font-medium leading-tight whitespace-nowrap ${co[e]}`,children:t})}function $({children:e}){return f(`div`,{className:`text-[11px] text-foreground-subtle italic`,children:e})}function lo({icon:e,label:t,nodeId:n,pinned:r,reason:i,overridden:a}){let{t:c}=K();return o(`div`,{className:`flex items-center gap-2 text-[11px] leading-snug min-w-0`,children:[f(e,{className:`h-3 w-3 text-foreground-subtle shrink-0`}),f(`span`,{className:`text-foreground-subtle w-[4.5rem] shrink-0`,children:t}),n===null?f(`span`,{className:`text-foreground-subtle italic`,children:c(`cameras.configBlocks.unassigned`)}):o(s,{children:[f(`span`,{className:`font-mono text-foreground truncate`,title:n,children:n}),r?o(`span`,{className:`inline-flex items-center gap-0.5 text-[10px] text-warning shrink-0`,title:c(`cameras.configBlocks.manuallyPinned`,`Manually pinned`),children:[f(_,{className:`h-2.5 w-2.5`}),` `,c(`cameras.configBlocks.manual`)]}):f(`span`,{className:`text-[10px] text-foreground-subtle shrink-0 truncate`,children:c(`cameras.configBlocks.autoReason`,{reason:i!==void 0&&i.length>0?i:c(`cameras.configBlocks.capacity`)})}),a&&f(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full bg-warning shrink-0`,title:c(`cameras.configBlocks.persistedSettingsPinForThis`,`Persisted settings pin for this role`)})]})]})}function uo({assignment:e,settings:t,onlineNodes:n,pinPending:r,onDetectionPinChange:i}){let{t:a}=K(),s=e.pinned.detection&&e.detectionNodeId!==null?e.detectionNodeId:`auto`,c=[...new Set([...e.detectionNodeId===null?[]:[e.detectionNodeId],...n.map(e=>e.id)])];return o(X,{title:a(`cameras.configBlocks.whereItRuns`,`Where it runs`),children:[f(lo,{icon:g,label:a(`cameras.configBlocks.detection`,`Detection`),nodeId:e.detectionNodeId,pinned:e.pinned.detection,reason:e.reasons.detection,overridden:t.overriddenKeys.has(`pipelineNodeId`)}),f(lo,{icon:y,label:a(`cameras.configBlocks.decoder`,`Decoder`),nodeId:e.decoderNodeId,pinned:e.pinned.decoder,reason:e.reasons.decoder,overridden:t.overriddenKeys.has(`decoderNodeId`)}),f(lo,{icon:D,label:a(`cameras.configBlocks.audio`,`Audio`),nodeId:e.audioNodeId,pinned:e.pinned.audio,reason:e.reasons.audio,overridden:t.overriddenKeys.has(`audioNodeId`)}),f(lo,{icon:M,label:a(`cameras.configBlocks.source`,`Source`),nodeId:e.sourceNodeId,pinned:!1,reason:`ingest owner`,overridden:!1}),f(`div`,{className:`mt-1.5`,children:o(`select`,{value:s,disabled:r,"aria-label":a(`cameras.configBlocks.detectionPlacementPin`,`Detection placement pin`),onChange:e=>i(e.target.value),className:`w-full min-w-0 rounded-md border border-border bg-background px-2 py-1 text-[11px] text-foreground disabled:opacity-50`,children:[f(`option`,{value:`auto`,children:a(`cameras.configBlocks.autoLoadBalanced`,`Auto (load balanced)`)}),c.map(e=>f(`option`,{value:e,children:a(`cameras.configBlocks.pinDetection`,{node:n.find(t=>t.id===e)?.name??e})},e))]})})]})}function fo(e){return`${e.width}×${e.height} ${e.codec} @${e.fps}fps`}function po(e,t){if(!(t===null||e===void 0))return e.find(e=>e.profile===t)}function mo(e){return e===null?G.t(`pipeline.configBlocks.fpsDefault`):e===0?G.t(`pipeline.configBlocks.fpsNative`):`${e} fps`}function ho({streams:e,brokerProfiles:t,settings:n,motionEnabled:r,motionFpsLive:i,cameraSensors:a}){let{t:c}=K(),l=po(t,n.detectionStreamProfile),u=po(t,n.motionStreamProfile),d=n.motionSources.includes(`analyzer`);return o(X,{title:c(`cameras.configBlocks.streamsMotion`,`Streams & motion`),children:[o(Z,{label:c(`cameras.configBlocks.detectStream`,`Detect stream`),overridden:n.overriddenKeys.has(`detectionStreamProfile`),children:[n.detectionStreamProfile??`—`,l!==void 0&&` · ${l.width}×${l.height} ${l.codec}`]}),f(Z,{label:c(`cameras.configBlocks.detectFps`,`Detect FPS`),overridden:n.overriddenKeys.has(`detectionFps`),children:mo(n.detectionFps)}),o(Z,{label:c(`cameras.configBlocks.motionSrc`,`Motion src`),overridden:n.overriddenKeys.has(`motionSources`),children:[n.motionSources.length>0?n.motionSources.map(Pe).join(` + `):c(`cameras.configBlocks.none`),r===!1&&` · ${c(`cameras.configBlocks.inactive`)}`]}),f(Z,{label:c(`cameras.configBlocks.cameraSensors`,`Camera sensors`),children:Xa(a)}),d&&o(s,{children:[o(Z,{label:c(`cameras.configBlocks.motionStream`,`Motion stream`),overridden:n.overriddenKeys.has(`motionStreamProfile`),children:[n.motionStreamProfile??`—`,u!==void 0&&` · ${u.width}×${u.height} ${u.codec}`]}),o(Z,{label:c(`cameras.configBlocks.motionFps`,`Motion FPS`),overridden:n.overriddenKeys.has(`motionFps`),children:[mo(n.motionFps),i!==null&&` · ${c(`cameras.configBlocks.liveFps`,{fps:i.toFixed(1)})}`]})]}),f(Z,{label:c(`cameras.configBlocks.cooldown`,`Cooldown`),overridden:n.overriddenKeys.has(`motionCooldownMs`),children:n.motionCooldownMs===null?c(`cameras.configBlocks.defaultValue`):`${n.motionCooldownMs/1e3}s`}),f(`div`,{className:`mt-1.5 flex flex-col gap-0.5`,children:e.length===0?f($,{children:c(`cameras.configBlocks.noStreamsRegistered`,`No streams registered`)}):e.map(e=>o(`div`,{className:`text-[10px] font-mono text-foreground-subtle truncate`,title:e.camStreamId,children:[f(`span`,{className:`text-foreground-muted`,children:e.kind}),` `,fo(e)]},e.camStreamId))})]})}function go({steps:e,audioModelId:t,audioEnabled:n,audioMode:r}){let{t:i}=K();return o(X,{title:i(`cameras.configBlocks.pipelineSteps`,`Pipeline steps`),children:[e===void 0?f($,{children:i(`cameras.configBlocks.resolving`,`Resolving…`)}):e.length===0?f($,{children:i(`cameras.configBlocks.noStepsConfigured`,`No steps configured`)}):f(`div`,{className:`flex flex-wrap gap-1`,children:e.map((e,t)=>f(Q,{tone:e.enabled&&e.depth===0?`info`:`neutral`,title:e.modelId??e.addonId,children:o(`span`,{className:e.enabled?``:`line-through opacity-60`,children:[e.depth>0&&f(`span`,{className:`opacity-50`,children:`↳ `}),e.addonId,e.modelId!==null&&o(`span`,{className:`font-mono opacity-75`,children:[` · `,e.modelId]})]})},`${e.addonId}-${t}`))}),f(`div`,{className:`mt-1`,children:o(Z,{label:i(`cameras.configBlocks.audioClass`,`Audio class.`),children:[r??`—`,n!==null&&` · ${i(n?`cameras.configBlocks.running`:`cameras.configBlocks.off`)}`,t!==null&&` · ${t}`]})})]})}var _o={ready:`success`,installing:`info`,verifying:`info`,idle:`neutral`,failed:`danger`};function vo({detection:e,live:t,detectionMode:n,modeOverridden:r}){let i=P(),{t:a}=K();if(e===null)return o(X,{title:a(`cameras.runtimeBlocks.detectionRuntime`,`Detection runtime`),children:[f(Z,{label:a(`cameras.runtimeBlocks.mode`,`Mode`),overridden:r,children:n??`—`}),f($,{children:a(`cameras.runtimeBlocks.detectionStageInactiveOrUnreachable`,`Detection stage inactive or unreachable`)})]});let s=t?.phase??e.phase,c=t?.actualFps??e.actualFps,l=t?.configuredFps??e.configuredFps,u=t?.avgInferenceTimeMs??e.avgInferenceMs,d=t?.queueDepth??e.queueDepth,p=rt(s,i),m=s===`active`&&c===0;return o(X,{title:a(`cameras.runtimeBlocks.detectionRuntime`,`Detection runtime`),children:[o(`div`,{className:`flex items-center gap-1.5 mb-0.5`,children:[o(`span`,{className:`inline-flex items-center gap-1 rounded border px-1.5 py-px text-[10px] font-semibold uppercase tracking-wider ${p.badgeClass}`,children:[f(Ke,{phase:s,className:`h-2.5 w-2.5`}),p.label]}),t!==void 0&&f(`span`,{className:`text-[9px] text-foreground-subtle uppercase tracking-wider`,children:a(`common.live`)})]}),f(Z,{label:a(`cameras.runtimeBlocks.mode`,`Mode`),overridden:r,children:n??`—`}),o(Z,{label:`FPS`,children:[f(`span`,{className:m?`text-danger font-semibold`:``,children:c.toFixed(1)}),f(`span`,{className:`ml-1 text-foreground-subtle`,children:a(`cameras.runtimeBlocks.configuredFps`,{fps:l.toFixed(0)})})]}),o(Z,{label:a(`cameras.runtimeBlocks.inference`,`Inference`),children:[u.toFixed(0),` ms`,d>0&&f(`span`,{className:`ml-1 text-warning`,children:a(`cameras.runtimeBlocks.queue`,{depth:d})}),t!==void 0&&t.droppedFrames>0&&f(`span`,{className:`ml-1 text-warning`,children:a(`cameras.runtimeBlocks.drops`,{count:t.droppedFrames})})]}),o(Z,{label:a(`cameras.runtimeBlocks.engine`,`Engine`),children:[e.engine.backend,` · `,e.engine.device]}),o(Z,{label:a(`cameras.runtimeBlocks.provisioning`,`Provisioning`),children:[f(Q,{tone:_o[e.provisioning.state]??`neutral`,children:e.provisioning.state}),e.provisioning.error!==void 0&&o(`span`,{className:`text-danger text-[10px]`,children:[` `,e.provisioning.error]})]})]})}function yo({broker:e}){let{t}=K();return e===null?f(X,{title:t(`cameras.runtimeBlocks.streamBroker`,`Stream broker`),children:f($,{children:t(`cameras.runtimeBlocks.brokerStageInactiveOrUnreachable`,`Broker stage inactive or unreachable`)})}):o(X,{title:t(`cameras.runtimeBlocks.streamBroker`,`Stream broker`),children:[e.profiles.length===0?f($,{children:t(`cameras.runtimeBlocks.noBrokerProfiles`,`No broker profiles`)}):f(`div`,{className:`flex flex-col gap-1`,children:e.profiles.map(e=>{let n=e.status===`streaming`,r=n&&e.inFps===0;return o(`div`,{className:`flex items-center gap-2 text-[11px] font-mono tabular-nums min-w-0`,children:[f(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full shrink-0 ${r?`bg-danger`:n?`bg-success animate-pulse`:`bg-border`}`,title:e.status}),f(`span`,{className:`text-foreground w-10 shrink-0 truncate`,title:e.profile,children:e.profile}),o(`span`,{className:`text-foreground-subtle truncate`,children:[e.width,`×`,e.height,` `,e.codec]}),f(`span`,{className:`ml-auto shrink-0 ${r?`text-danger`:`text-foreground`}`,children:t(`cameras.runtimeBlocks.fpsValue`,{value:e.inFps===null?`—`:e.inFps.toFixed(0)})}),o(`span`,{className:`text-foreground-subtle shrink-0`,title:t(`cameras.runtimeBlocks.subscribers`,`Subscribers`),children:[`×`,e.subscribers]})]},e.profile)})}),o(`div`,{className:`mt-1.5 flex flex-wrap gap-1`,children:[f(Q,{tone:e.webrtcSessions>0?`info`:`neutral`,children:t(`cameras.runtimeBlocks.webrtc`,{count:e.webrtcSessions})}),f(Q,{tone:e.rtspRestream?`success`:`neutral`,children:e.rtspRestream?t(`cameras.runtimeBlocks.restreamOn`):t(`cameras.runtimeBlocks.restreamOff`)})]})]})}function bo({decoder:e}){let{t}=K();return e===null?f(X,{title:t(`cameras.runtimeBlocks.decoder`,`Decoder`),children:f($,{children:t(`cameras.runtimeBlocks.decoderStageInactiveOrUnreachable`,`Decoder stage inactive or unreachable`)})}):f(X,{title:t(`cameras.runtimeBlocks.decoder`,`Decoder`),children:f(Z,{label:t(`cameras.runtimeBlocks.node`,`Node`),children:e.nodeId})})}t();var xo=`pipeline-orchestrator`,So={healthy:`bg-success`,idle:`bg-warning`,error:`bg-danger`},Co={healthy:`pipeline.cameraPipelineCard.healthHealthy`,idle:`pipeline.cameraPipelineCard.healthIdle`,error:`pipeline.cameraPipelineCard.healthError`};function wo({problems:e}){return f(`div`,{role:`alert`,className:`flex flex-col border-b border-border`,children:e.map(e=>o(`div`,{className:`flex items-start gap-2 px-4 py-1.5 text-[11px] font-medium ${e.severity===`error`?`bg-danger/10 text-danger`:`bg-warning/10 text-warning`}`,children:[f(b,{className:`h-3.5 w-3.5 shrink-0 mt-px`}),f(`span`,{className:`min-w-0`,children:e.message})]},e.code))})}function To({deviceId:e,name:t,online:n,status:i,live:a,onlineNodes:s}){let{t:c}=K(),u=l(),{data:d}=Zt({addonId:xo,deviceId:e,nodeId:`hub`},{staleTime:3e4}),{data:p}=Qe({deviceId:e},{staleTime:3e4}),m=r(()=>ao(d),[d]),h=r(()=>p===void 0?void 0:oo(p.steps),[p]),g=r(()=>i===void 0?[]:Ga(i),[i]),_=()=>{u.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCameraStatuses`]]}),u.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineAssignments`]]})},v=ft({onSuccess:_}),y=Nt({onSuccess:_}),b=t=>{t===`auto`?y.mutate({deviceId:e}):v.mutate({deviceId:e,agentNodeId:t})},x=i===void 0?`idle`:Wa(i),S=g.some(e=>e.severity===`error`),C=g.length>0,w=S?`border-danger/50`:C?`border-warning/40`:`border-border`;return o(`article`,{"aria-label":c(`cameras.cameraPipelineCard.pipelineStatus`,`{{name}} pipeline status`,{name:t}),className:`rounded-lg border ${w} bg-background overflow-hidden`,children:[o(`header`,{className:`flex items-center gap-2.5 px-4 py-2.5 border-b border-border bg-surface/50 min-w-0`,children:[f(`span`,{className:`inline-block h-2 w-2 rounded-full shrink-0 ${S?`bg-danger`:So[x]}`,title:S?c(`common.error`,`Error`):c(Co[x]),"aria-label":S?c(`common.error`,`Error`):c(Co[x]),role:`img`}),f(`h3`,{className:`text-[13px] font-semibold text-foreground truncate`,title:t,children:t}),o(`span`,{className:`text-[10px] text-foreground-subtle shrink-0`,children:[`#`,e]}),!n&&f(Q,{tone:`danger`,children:c(`common.offline`)}),o(`span`,{className:`ml-auto flex items-center gap-1.5 shrink-0`,children:[m.detectionMode!==null&&f(Q,{tone:m.detectionMode===`disabled`?`warning`:m.detectionMode===`always-on`?`info`:`neutral`,title:c(`cameras.cameraPipelineCard.objectDetectionMode`,`Object detection mode`),children:m.detectionMode===`disabled`?c(`cameras.cameraPipelineCard.detectionOff`,`detection off`):m.detectionMode}),i?.recording!=null&&(i.recording.active?o(Q,{tone:`danger`,title:c(`cameras.cameraPipelineCard.recording`,`Recording ({{mode}})`,{mode:i.recording.mode}),children:[f(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full bg-danger animate-pulse`}),`REC`]}):i.recording.mode!==`off`&&f(Q,{tone:`neutral`,title:c(`cameras.cameraPipelineCard.recordingMode`,`Recording mode`),children:c(`pipeline.cameraPipelineCard.recMode`,{mode:i.recording.mode})}))]})]}),g.length>0&&f(wo,{problems:g}),i===void 0?f(`div`,{className:`px-4 py-5 text-[11px] text-foreground-subtle italic`,children:c(`cameras.cameraPipelineCard.noPipelineStatusYetThe`,`No pipeline status yet — the orchestrator has not composed a snapshot for this camera.`)}):o(`div`,{className:`grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-px bg-border`,children:[f(uo,{assignment:i.assignment,settings:m,onlineNodes:s,pinPending:v.isPending||y.isPending,onDetectionPinChange:b}),f(vo,{detection:i.detection,live:a,detectionMode:m.detectionMode,modeOverridden:m.overriddenKeys.has(`detectionMode`)}),f(go,{steps:h,audioModelId:p?.audio?.modelId??null,audioEnabled:i.audio?.enabled??p?.audio?.enabled??null,audioMode:m.audioMode}),f(ho,{streams:i.source.streams,brokerProfiles:i.broker?.profiles,settings:m,motionEnabled:i.motion?.enabled??null,motionFpsLive:i.motion?.fps??null,cameraSensors:i.cameraSensors}),f(yo,{broker:i.broker}),f(bo,{decoder:i.decoder})]})]})}t();var Eo=5e3,Do=1e4,Oo=5e3;function ko(e){let t=l(),{data:a,isLoading:o}=gn(),{data:s,isLoading:c}=nt({},{refetchInterval:Eo}),{nodes:u}=W();n(()=>{e!==0&&t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCameraStatuses`]]})},[e,t]);let[d,f]=i(new Map);ln(Ee.PipelineCameraMetricsSnapshot,e=>{let t=e.data;typeof t.deviceId==`number`&&f(e=>{let n=new Map(e);return n.set(t.deviceId,{phase:t.metrics.phase,configuredFps:t.metrics.configuredFps,actualFps:t.metrics.actualFps,queueDepth:t.metrics.queueDepth,avgInferenceTimeMs:t.metrics.avgInferenceTimeMs,droppedFrames:t.metrics.droppedFrames,timestamp:t.timestamp}),n})}),n(()=>{if(d.size===0)return;let e=setInterval(()=>{f(e=>{let t=Date.now()-Do,n=!1,r=new Map(e);for(let[i,a]of e)a.timestamp<t&&(r.delete(i),n=!0);return n?r:e})},Oo);return()=>clearInterval(e)},[d.size]);let p=r(()=>{let e=new Map;for(let t of s??[])e.set(t.deviceId,t);return e},[s]);return{rows:r(()=>(a??[]).filter(e=>e.isCamera).map(e=>({deviceId:e.id,name:e.name,online:e.online,status:p.get(e.id)})).sort((e,t)=>e.name.localeCompare(t.name)),[a,p]),liveMetrics:d,onlineNodes:r(()=>(u??[]).filter(e=>e.isOnline).map(e=>({id:e.id,name:e.name})),[u]),isLoading:o||c}}t();function Ao({refreshToken:e}){let{t}=K(),{rows:n,liveMetrics:i,onlineNodes:a,isLoading:s}=ko(e),c=r(()=>[...n.map(e=>{let t=e.status===void 0?[]:Ga(e.status);return{row:e,errorCount:t.filter(e=>e.severity===`error`).length,warningCount:t.filter(e=>e.severity===`warning`).length}})].sort((e,t)=>e.errorCount===t.errorCount?e.warningCount===t.warningCount?0:t.warningCount-e.warningCount:t.errorCount-e.errorCount),[n]),l=r(()=>{let e=0,t=0;for(let n of c)(n.errorCount>0||n.warningCount>0)&&(t+=1),(i.get(n.row.deviceId)?.phase??n.row.status?.detection?.phase)===`active`&&(e+=1);return{total:c.length,active:e,issues:t}},[c,i]);return s&&n.length===0?f(`div`,{className:`flex items-center justify-center h-full text-sm text-foreground-subtle`,children:t(`cameras.camerasOverview.loadingCameraPipelines`,`Loading camera pipelines…`)}):n.length===0?f(`div`,{className:`flex items-center justify-center h-full text-sm text-foreground-subtle`,children:t(`cameras.camerasOverview.noCamerasFound`,`No cameras found`)}):f(`div`,{className:`h-full overflow-y-auto`,children:o(`div`,{className:`max-w-6xl mx-auto flex flex-col gap-3 px-4 py-4`,children:[o(`div`,{className:`flex items-center gap-4 text-[11px] text-foreground-subtle px-1`,children:[f(`span`,{children:f(vn,{i18nKey:`pipeline.camerasOverview.camerasTotal`,values:{count:l.total},components:{b:f(`span`,{className:`font-semibold text-foreground`})}})}),f(`span`,{children:f(vn,{i18nKey:`pipeline.camerasOverview.activelyInferring`,values:{count:l.active},components:{b:f(`span`,{className:`font-semibold text-success`})}})}),o(`span`,{children:[f(`span`,{className:`font-semibold ${l.issues>0?`text-danger`:`text-foreground`}`,children:l.issues}),` `,t(`cameras.camerasOverview.withIssues`,`with issues`)]}),f(`span`,{className:`ml-auto hidden sm:inline text-[10px]`,children:t(`cameras.camerasOverview.polledEvery5SDetection`,`polled every 5 s · detection metrics live at 1 Hz`)})]}),c.map(({row:e})=>f(To,{deviceId:e.deviceId,name:e.name,online:e.online,status:e.status,live:i.get(e.deviceId),onlineNodes:a},e.deviceId))]})})}var jo=e({CLUSTER_NODE_ID:()=>Mo,PipelinePage:()=>Fo});t();var Mo=`__cluster__`;function No(e){return e===`cameras`?`cameras`:`nodes`}function Po({viewMode:e,onNodes:t,onCameras:n}){let{t:r}=K();return o(`div`,{className:`flex items-center gap-1 rounded-lg border border-border bg-surface p-0.5`,role:`tablist`,"aria-label":r(`pipeline.pipelineView`,`Pipeline view`),children:[f(`button`,{type:`button`,role:`tab`,"aria-selected":e===`nodes`,onClick:t,className:[`rounded-md px-3 py-1 text-[11px] font-medium transition-colors`,e===`nodes`?`bg-background text-foreground shadow-sm`:`text-foreground-subtle hover:text-foreground`].join(` `),children:r(`pipeline.nodes`,`Nodes`)}),f(`button`,{type:`button`,role:`tab`,"aria-selected":e===`cameras`,onClick:n,className:[`rounded-md px-3 py-1 text-[11px] font-medium transition-colors`,e===`cameras`?`bg-background text-foreground shadow-sm`:`text-foreground-subtle hover:text-foreground`].join(` `),children:r(`pipeline.cameras`,`Cameras`)})]})}function Fo(){let{t:e}=K(),[t,r]=yn(),a=No(t.get(`view`)),c=t.get(`node`)??`__cluster__`,[l,u]=i(0),[d,p]=i(!1);return n(()=>{a===`nodes`&&!t.get(`node`)&&r({view:`nodes`,node:Mo},{replace:!0})},[a,t,r]),o(Je,{icon:ue,title:e(`pipeline.pipeline`,`Pipeline`),subtitle:e(`pipeline.detectionPlacementLoadAndPer`,`Detection placement, load and per-camera runtime across the cluster.`),actions:o(V,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>u(e=>e+1),title:e(`common.refresh`,`Refresh`),children:[f(ce,{className:`h-3.5 w-3.5`}),e(`common.refresh`,`Refresh`)]}),nav:f(Po,{viewMode:a,onNodes:()=>{r({view:`nodes`,node:c},{replace:!0})},onCameras:()=>{r({view:`cameras`},{replace:!0})}}),className:`flex h-full min-h-0 flex-col overflow-hidden`,children:[a===`nodes`&&o(V,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>p(e=>!e),"aria-expanded":d,className:`flex w-full shrink-0 justify-between border-b border-border md:hidden`,children:[f(`span`,{children:e(d?`pipeline.hideNodeList`:`pipeline.showNodeList`)}),f(se,{className:[`h-4 w-4 transition-transform`,d?`rotate-180`:``].join(` `)})]}),f(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden md:flex-row`,children:a===`nodes`?o(s,{children:[f(`aside`,{className:[d?`block`:`hidden`,`md:block w-full md:w-72 shrink-0 border-b border-border md:border-b-0 md:border-r`,`max-h-[60vh] overflow-y-auto md:max-h-none`].join(` `),children:f(Wn,{selectedNodeId:c,onSelect:e=>{r({view:`nodes`,node:e},{replace:!0}),p(!1)},refreshToken:l})}),f(`section`,{className:`min-h-0 flex-1 overflow-hidden`,children:c===`__cluster__`?f(Va,{refreshToken:l}):f(fi,{nodeId:c,refreshToken:l})})]}):f(`section`,{className:`min-h-0 flex-1 overflow-hidden`,children:f(Ao,{refreshToken:l})})})]})}var Io=`ctab`,Lo=`section`;function Ro(e,t){let n=new URLSearchParams({view:`nodes`,node:Mo,[Io]:e});return t!==void 0&&n.set(Lo,t),`/system/pipeline?${n.toString()}`}function zo(e){return Ro(`settings`,Aa(e))}function Bo(){return Ro(`load-balancing`)}var Vo=`pipeline-orchestrator`;function Ho(e){return De.find(t=>t.stepId===e)??null}function Uo({step:e,engineFormat:t,runnableModelIds:n}){let{t:r}=K(),{data:i}=Kt({addonId:Vo}),a=ye(i??null)[e.stepId]??e.defaultModelId,s=e.options.find(e=>e.id===a)?.label??a,c=n.length>0&&!n.includes(a);return o(`div`,{className:`space-y-2 rounded-md border border-primary/30 bg-primary/5 px-3 py-2`,children:[o(`div`,{className:`flex flex-wrap items-center gap-2 text-xs`,children:[f(`span`,{className:`font-medium text-foreground`,children:e.label}),f(`span`,{className:`font-mono text-foreground`,children:s}),f(`span`,{title:r(`pipeline.clusterStepModel.oneValueForTheWhole`,`One value for the whole cluster — this step writes into a shared vector index, where two encoders make similarity scores meaningless.`),className:`rounded border border-primary/40 bg-primary/10 px-1 py-px text-[9px] font-medium uppercase tracking-wide text-primary`,children:r(`pipeline.clusterStepModel.clusterWide`)}),f(_n,{to:zo(e.stepId),className:`ml-auto text-[11px] text-primary hover:underline`,children:r(`pipeline.clusterStepModel.changeInClusterSettings`,`Change in Cluster → Settings ›`)})]}),o(`p`,{className:B,children:[r(`pipeline.clusterStepModel.oneModelForEveryNode`,`One model for every node and camera:`),` `,r(`pipeline.clusterStepModel.indexNote`,{index:e.indexName})]}),c&&f(`p`,{className:`rounded border border-warning/40 bg-warning/10 px-2 py-1 text-[10px] leading-snug text-warning`,children:f(vn,{i18nKey:`pipeline.clusterStepModel.noBuild`,values:{engine:t,model:a,index:e.indexName},components:{b:f(`b`,{})}})})]})}export{Pr as _,Qr as a,Lr as c,Ur as d,Gr as f,Fr as g,Wr as h,$r as i,Yr as l,Hr as m,Ho as n,Vr as o,Jr as p,jo as r,Kr as s,Uo as t,qr as u,jr as v,Fn as y};