@camstack/addon-admin-ui 1.2.349 → 1.2.351
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{AddonCollectionPage-jXCbcMZu.js → AddonCollectionPage-BwMkNEOp.js} +1 -1
- package/dist/assets/Addons-80LT7Kq1.js +4 -0
- package/dist/assets/{AdminTabs-DcYKYXzK.js → AdminTabs-CLXyClcg.js} +1 -1
- package/dist/assets/AiProfiles-ChIr3l8J.js +3 -0
- package/dist/assets/{BrokerForm-rRXdhvBg.js → BrokerForm-DGnvvf1S.js} +1 -1
- package/dist/assets/Build-ByqfAJAw.js +40 -0
- package/dist/assets/{Calendars-BhTVLKHz.js → Calendars-B4BPsOl1.js} +1 -1
- package/dist/assets/{Capabilities-CvhnCl7c.js → Capabilities-70q-pu5f.js} +1 -1
- package/dist/assets/Cluster-2DoknXyA.js +11 -0
- package/dist/assets/ClusterStepModel-B-xVF7M9.js +1 -0
- package/dist/assets/{CompositionEditor-gkHb7ZT2.js → CompositionEditor-DewhGunb.js} +1 -1
- package/dist/assets/{CompositionEditorPage-UrJerX9A.js → CompositionEditorPage-DTanATOp.js} +1 -1
- package/dist/assets/{Data-CRMaoAvA.js → Data-ovpjy5aC.js} +1 -1
- package/dist/assets/DetectionIntelligence-CJMGXsWL.js +1 -0
- package/dist/assets/DeviceDetail-BuLCyjcK.js +2 -0
- package/dist/assets/{DeviceDoActionFields-Qp-mdQoy.js → DeviceDoActionFields-DBwevgKK.js} +1 -1
- package/dist/assets/{Devices-D0X5ZMil.js → Devices-DvSDZeG9.js} +1 -1
- package/dist/assets/{EmbedPlayerPage-BCohm6GU.js → EmbedPlayerPage-enhtADF7.js} +1 -1
- package/dist/assets/Events-Dv_1XIVc.js +1 -0
- package/dist/assets/Identity-Cc3G2Fa0.js +1 -0
- package/dist/assets/IntegrationDetail-DSqCZO4S.js +1 -0
- package/dist/assets/Integrations-Beb2EhOS.js +1 -0
- package/dist/assets/Integrations-DYhW5V60.js +1 -0
- package/dist/assets/Locations-BNBOCArW.js +3 -0
- package/dist/assets/{Logs-4q8jFD5i.js → Logs-CScz1BkD.js} +1 -1
- package/dist/assets/{MotionZonesSettings-M2UAaOLw.js → MotionZonesSettings-aDMRPb0C.js} +1 -1
- package/dist/assets/MyAccess-bpwJEqEY.js +2 -0
- package/dist/assets/Network-Bx7uEVdz.js +1 -0
- package/dist/assets/NodeAddonsSettingsPanel-BgxOJU3d.js +1 -0
- package/dist/assets/Notifications-ML8zmn39.js +1 -0
- package/dist/assets/Plates-DIoGtVsY.js +1 -0
- package/dist/assets/{PrivacyMaskSettings-8lVg2P1M.js → PrivacyMaskSettings-DFTAA5dg.js} +1 -1
- package/dist/assets/Recordings-CoOwir1H.js +1 -0
- package/dist/assets/{ScanNetworkModal-B59h5xvq.js → ScanNetworkModal-BPZGLiZQ.js} +1 -1
- package/dist/assets/{SceneMonitorEditor-B1E8n6ou.js → SceneMonitorEditor-rhbNHUiH.js} +1 -1
- package/dist/assets/{Scenes-CR29v0gZ.js → Scenes-B6vGKWeX.js} +1 -1
- package/dist/assets/{Settings-BvzufFl5.js → Settings-PKIvMwLh.js} +1 -1
- package/dist/assets/{Showroom-BnjdRdKN.js → Showroom-CiPParUW.js} +1 -1
- package/dist/assets/{Terminal-aUzk1uKX.js → Terminal-yp9gTtPT.js} +2 -2
- package/dist/assets/{Viewer-M6qlWxs9.js → Viewer-CrwFaVq7.js} +1 -1
- package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-BsOXjLIp.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-Cc2A3Ptb.js} +1 -1
- package/dist/assets/{archive-D-Y4i_R_.js → archive-D5jN_xRr.js} +1 -1
- package/dist/assets/{authed-media-_X4FXSBp.js → authed-media-DIbw4JLn.js} +1 -1
- package/dist/assets/{boxes-DXM8dtQJ.js → boxes-Cz0W-SHm.js} +1 -1
- package/dist/assets/circle-slash-tZFznooZ.js +1 -0
- package/dist/assets/client-DWiaUxRQ.js +357 -0
- package/dist/assets/crop-B8tpwR6u.js +1 -0
- package/dist/assets/debounced-invalidate-BhgMMKYH.js +1 -0
- package/dist/assets/{device-integration-icon-BXFJAjbm.js → device-integration-icon-BnWP0LSQ.js} +1 -1
- package/dist/assets/device-picker-model-D1aOGj40.js +1 -0
- package/dist/assets/{dist-BoA-02Ta.js → dist-BvHPU1Ls.js} +1 -1
- package/dist/assets/dist-brqlsTXV.js +357 -0
- package/dist/assets/face-bbox--pttun6Q.js +1 -0
- package/dist/assets/{hard-drive-download-DI78Qxnu.js → hard-drive-download-DvX0zc41.js} +1 -1
- package/dist/assets/{hostInit-CjZNBAf2.js → hostInit-BxEpkmct.js} +1 -1
- package/dist/assets/index-Buq71VHG.js +4 -0
- package/dist/assets/index-CFu9bpWo.css +2 -0
- package/dist/assets/{layers-BYuVbzVs.js → layers-CTxykl5p.js} +1 -1
- package/dist/assets/{location-owned-usage-Bj5-khSs.js → location-owned-usage-CV2yEH4j.js} +1 -1
- package/dist/assets/{mf-entry-bootstrap-0-ea91eb80.js → mf-entry-bootstrap-0-9f9ea6de.js} +2 -2
- package/dist/assets/mount-D1aOGj40.js +1 -0
- package/dist/assets/notification-schedule-field-CQPEDiDO.js +1 -0
- package/dist/assets/{player-overlays-BddRivLE.js → player-overlays-CrKWnjLj.js} +1 -1
- package/dist/assets/remoteEntry-BFpE5_8_.js +1 -0
- package/dist/assets/{send-CyJGX9-U.js → send-SN1L0Kiz.js} +1 -1
- package/dist/assets/{settings-2-BOGh_wO6.js → settings-2-BY8TSBhz.js} +1 -1
- package/dist/assets/src-Bkpo8B0D.js +67 -0
- package/dist/assets/{use-scenes-feed-B4UtvXrE.js → use-scenes-feed-Dwp-15g8.js} +1 -1
- package/dist/assets/{use-stationary-objects-QRm4Gn4u.js → use-stationary-objects-CCknD3DG.js} +1 -1
- package/dist/assets/useEventInvalidation-D1aOGj40.js +1 -0
- package/dist/assets/{useNodeUrlSelection-BDv33pGy.js → useNodeUrlSelection-NjZtQ6mH.js} +1 -1
- package/dist/assets/user-round-DCIxbUZ9.js +1 -0
- package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-C2YrzRgM.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-Cok7af3G.js} +2 -2
- package/dist/index.html +8 -8
- package/dist/server/addon.js +100 -329
- package/package.json +1 -1
- package/dist/assets/Addons-rr7aue1z.js +0 -1
- package/dist/assets/AiProfiles-CxBtibtD.js +0 -3
- package/dist/assets/Build-Tu52RNi0.js +0 -40
- package/dist/assets/Cluster-Bq5YAagB.js +0 -11
- package/dist/assets/ClusterStepModel-BXuKvfKQ.js +0 -1
- package/dist/assets/DetectionIntelligence-hpln0NzF.js +0 -1
- package/dist/assets/DeviceDetail-DA9kIkj-.js +0 -2
- package/dist/assets/Events-DJqXUhGE.js +0 -1
- package/dist/assets/Identity-CMHAJE1i.js +0 -1
- package/dist/assets/IntegrationDetail-D6CPV8I0.js +0 -1
- package/dist/assets/Integrations-C3v7m_pV.js +0 -1
- package/dist/assets/Integrations-CrSI1y99.js +0 -1
- package/dist/assets/Locations-BXxpBY8V.js +0 -3
- package/dist/assets/MyAccess-Brzl2xif.js +0 -2
- package/dist/assets/Network-UpHA2zPn.js +0 -1
- package/dist/assets/NodeAddonsSettingsPanel-D7Ope1My.js +0 -1
- package/dist/assets/Notifications-3jCEMiJT.js +0 -1
- package/dist/assets/Plates-DnKm0uO5.js +0 -1
- package/dist/assets/Recordings-C8Dz8QdA.js +0 -1
- package/dist/assets/circle-slash-Bh6ndID4.js +0 -1
- package/dist/assets/client-BVesZTvN.js +0 -357
- package/dist/assets/debounced-invalidate-On21l1Xj.js +0 -1
- package/dist/assets/device-picker-model-Br0xkUVQ.js +0 -1
- package/dist/assets/dist-CXTK9bJc.js +0 -357
- package/dist/assets/face-bbox-3mjLW0O1.js +0 -1
- package/dist/assets/index-DP2qgRL_.css +0 -2
- package/dist/assets/index-NHwA6Zmb.js +0 -4
- package/dist/assets/mount-Br0xkUVQ.js +0 -1
- package/dist/assets/notification-schedule-field-Bho2AfCu.js +0 -1
- package/dist/assets/remoteEntry-CJLM9B1W.js +0 -1
- package/dist/assets/square-check-big-CpCHNAfP.js +0 -1
- package/dist/assets/src-DnQxdAYg.js +0 -67
- package/dist/assets/useEventInvalidation-Br0xkUVQ.js +0 -1
- package/dist/assets/user-round-1jRRPQok.js +0 -1
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import{I as e,K as t,Q as n,S as r,V as i,W as a,b as o,o as s,q as c,x as l,z as u}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{at as d,gt as f,ht as p,st as m,vt as h}from"./player-overlays-BddRivLE.js";import{Ao as g,As as _,Au as v,Bl as y,Bo as b,Bt as x,Ct as S,Gu as C,Iu as w,Jd as T,Kl as E,Lo as D,Lu as O,Mc as ee,Nc as te,Pc as ne,Qn as re,Ro as k,Ru as ie,St as ae,Ud as oe,Vl as A,da as se,dr as ce,ec as le,fr as ue,jc as de,jo as fe,ju as pe,kd as me,ku as he,lf as ge,lr as _e,rd as j,su as ve,tl as ye,ur as be,zo as xe,zt as Se}from"./src-DnQxdAYg.js";import{t as Ce}from"./hard-drive-download-DI78Qxnu.js";import{Br as we}from"./client-BVesZTvN.js";import{t as M}from"./useTranslation-Bc5yH9V9.js";import{t as Te}from"./NodeAddonsSettingsPanel-D7Ope1My.js";import{t as N}from"./format-size-DIxKXxtj.js";import{n as Ee,r as De,t as Oe}from"./useNodeUrlSelection-BDv33pGy.js";var P=h(`memory-stick`,[[`path`,{d:`M12 12v-2`,key:`fwoke6`}],[`path`,{d:`M12 18v-2`,key:`qj6yno`}],[`path`,{d:`M16 12v-2`,key:`heuere`}],[`path`,{d:`M16 18v-2`,key:`s1ct0w`}],[`path`,{d:`M2 11h1.5`,key:`15p63e`}],[`path`,{d:`M20 18v-2`,key:`12ehxp`}],[`path`,{d:`M20.5 11H22`,key:`khsy7a`}],[`path`,{d:`M4 18v-2`,key:`1c3oqr`}],[`path`,{d:`M8 12v-2`,key:`1mwtfd`}],[`path`,{d:`M8 18v-2`,key:`qcmpov`}],[`rect`,{x:`2`,y:`6`,width:`20`,height:`10`,rx:`2`,key:`1qcswk`}]]);n();function ke(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 Ae({state:e}){return l(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded-full ${e===`running`?`bg-success/10 text-success`:e===`crashed`||e===`failed`?`bg-destructive/10 text-destructive`:`bg-muted text-muted-foreground`}`,children:e})}var je=[`trace`,`debug`,`info`,`warn`,`error`];function Me({proc:e,nodeId:t,defaultExpanded:n,activePanel:i,onTogglePanel:a}){let o=e.services??[],s=o.length===1,[u,d]=c(s||n),[m,h]=c(null),[g,_]=c(`info`),v=e.name.includes(`(core)`),y=k(),x=xe(),C=b(),E=async e=>{h(e);try{await y.mutateAsync({nodeId:t,addonId:e})}catch(e){console.error(`Failed to restart addon:`,e)}finally{h(null)}},D=async()=>{h(e.name);try{await x.mutateAsync({nodeId:t,processName:e.name})}catch(e){console.error(`Failed to restart process:`,e)}finally{h(null)}},O=async n=>{let r=`${t}/${e.name}`;try{await C.mutateAsync({nodeId:r,level:n}),_(n)}catch(e){console.error(`Failed to set log level:`,e)}};return r(`div`,{className:`border border-border/50 rounded-lg overflow-hidden`,children:[r(`div`,{role:s?void 0:`button`,tabIndex:s?void 0:0,onClick:s?void 0:()=>d(!u),onKeyDown:s?void 0:e=>{(e.key===`Enter`||e.key===` `)&&d(!u)},className:`flex items-center gap-2 w-full px-3 py-2 bg-muted/20 transition-colors text-left select-none ${s?``:`hover:bg-muted/40 cursor-pointer`}`,children:[s?l(`span`,{className:`h-3 w-3 shrink-0`}):l(u?f:p,{className:`h-3 w-3 text-muted-foreground shrink-0`}),v?l(he,{className:`h-3.5 w-3.5 text-primary shrink-0`}):l(T,{className:`h-3.5 w-3.5 text-amber-500 shrink-0`}),l(`span`,{className:`text-xs font-semibold flex-1`,children:e.name}),r(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:[`PID `,e.pid]}),l(Ae,{state:e.state}),r(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:[e.cpuPercent,`% CPU`]}),l(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:N(e.memoryRss)}),l(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:ke(e.uptimeSeconds)}),!v&&r(`div`,{className:`flex items-center gap-1`,onClick:e=>e.stopPropagation(),children:[r(_e,{children:[l(ue,{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:`Set log level`,children:g}),l(be,{align:`end`,className:`min-w-[70px] py-0.5`,children:je.map(e=>l(ce,{onClick:()=>O(e),className:`h-auto px-2 py-1 text-[10px] font-mono ${e===g?`text-primary font-semibold`:``}`,children:e},e))})]}),l(`button`,{onClick:D,disabled:m===e.name,className:`p-1 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50`,title:`Restart process`,children:l(w,{className:`h-3 w-3 ${m===e.name?`animate-spin`:``}`})})]})]}),u&&o.length>0&&l(`div`,{className:`divide-y divide-border/30`,children:o.map(e=>r(`div`,{children:[r(`div`,{className:`flex items-center gap-2 px-3 py-1.5 pl-9 hover:bg-muted/10 transition-colors`,children:[l(`div`,{className:`h-1.5 w-1.5 rounded-full shrink-0 ${e.status===`running`?`bg-success`:`bg-muted-foreground/30`}`}),l(`span`,{className:`text-xs font-medium flex-1 min-w-0 truncate`,children:e.addonId}),e.capabilities.length>0&&r(`div`,{className:`flex gap-1 flex-shrink-0`,children:[e.capabilities.slice(0,3).map(e=>l(`span`,{className:`text-[9px] px-1 py-0.5 rounded bg-blue-500/10 text-blue-400 truncate max-w-[80px]`,children:e},e)),e.capabilities.length>3&&r(`span`,{className:`text-[9px] text-muted-foreground`,children:[`+`,e.capabilities.length-3]})]}),r(`div`,{className:`flex items-center gap-1 shrink-0`,children:[l(`button`,{onClick:()=>a(e.addonId,`logs`),className:`p-0.5 rounded transition-colors ${i?.addonId===e.addonId&&i.type===`logs`?`bg-primary/10 text-primary`:`hover:bg-muted text-muted-foreground hover:text-foreground`}`,title:`Show logs for ${e.addonId}`,children:l(pe,{className:`h-3 w-3`})}),l(`button`,{onClick:()=>a(e.addonId,`events`),className:`p-0.5 rounded transition-colors ${i?.addonId===e.addonId&&i.type===`events`?`bg-primary/10 text-primary`:`hover:bg-muted text-muted-foreground hover:text-foreground`}`,title:`Show events for ${e.addonId}`,children:l(ie,{className:`h-3 w-3`})}),l(`button`,{onClick:()=>E(e.addonId),disabled:m===e.addonId,className:`p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50`,title:`Restart ${e.addonId}`,children:l(w,{className:`h-3 w-3 ${m===e.addonId?`animate-spin`:``}`})})]})]}),i?.addonId===e.addonId&&i.type===`logs`&&l(`div`,{className:`border-t border-border/40 bg-muted/5`,children:l(S,{addonId:e.addonId,agentId:t,maxHeight:`max-h-48`,showFilters:!1,onClose:()=>a(e.addonId,`logs`)})}),i?.addonId===e.addonId&&i.type===`events`&&l(`div`,{className:`border-t border-border/40 bg-muted/5`,children:l(ae,{addonId:e.addonId,category:`addon.*`,maxHeight:`max-h-48`,onClose:()=>a(e.addonId,`events`)})})]},e.addonId))}),u&&o.length===0&&l(`div`,{className:`px-3 py-2 pl-9 text-[10px] text-muted-foreground`,children:`No services`})]})}function Ne({nodeId:e,processes:t}){let[n,r]=c(null),i=(e,t)=>{r(n=>n?.addonId===e&&n.type===t?null:{addonId:e,type:t})};return t.length===0?l(`div`,{className:`py-4 text-xs text-muted-foreground text-center`,children:`No processes on this node`}):l(`div`,{className:`space-y-2 py-1`,children:t.map((t,r)=>l(Me,{proc:t,nodeId:e,defaultExpanded:r===0,activePanel:n,onTogglePanel:i},t.name))})}var Pe={system:0,managed:1,root:2};n();function Fe(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 Ie(e,t=80){return e.length<=t?e:`…${e.slice(e.length-t+1)}`}function Le({nodeId:e}){let t=s(),n=A(`metrics.node-processes-snapshot`,t=>t.nodeId===e),{data:i}=fe({nodeId:e}),o=n?.processes??i,c=a(()=>o?[...o]:[],[o]),u=a(()=>[{key:`classification`,header:`Class`,sortValue:e=>Pe[e.classification],render:e=>l(`span`,{className:`inline-block rounded-full px-1.5 py-0.5 text-[10px] font-medium ${e.classification===`root`?`bg-sky-500/20 text-sky-400`:e.classification===`system`?`bg-foreground-subtle/20 text-foreground-subtle`:`bg-success/20 text-success`}`,children:e.classification})},{key:`pid`,header:`PID`,align:`right`,sortValue:e=>e.pid,render:e=>l(`span`,{className:`font-mono`,children:e.pid})},{key:`ppid`,header:`PPID`,align:`right`,sortValue:e=>e.ppid,render:e=>l(`span`,{className:`font-mono text-foreground-subtle`,children:e.ppid})},{key:`addonId`,header:`Addon`,sortValue:e=>e.addonId,render:e=>l(`span`,{className:`text-foreground-subtle text-[11px]`,children:e.addonId??`—`})},{key:`command`,header:`Command`,nowrap:!1,render:e=>l(`span`,{className:`font-mono text-[10px] text-foreground-subtle break-all`,children:Ie(e.command)})},{key:`cpuPercent`,header:`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=>N(e.memoryRssBytes)},{key:`uptimeSec`,header:`Uptime`,align:`right`,sortValue:e=>e.uptimeSec,render:e=>l(`span`,{className:`text-foreground-subtle`,children:Fe(e.uptimeSec)})}],[]);return r(`div`,{className:`space-y-4`,children:[l(`div`,{className:`flex items-start justify-end gap-4`,children:r(`button`,{type:`button`,onClick:()=>t.invalidateQueries({queryKey:[[`metricsProvider`,`listNodeProcesses`]]}),className:`inline-flex items-center gap-1 rounded border border-border px-2 py-1 text-[11px] text-foreground hover:bg-surface-hover`,children:[l(O,{className:`h-3 w-3`}),` Refresh`]})}),l(Se,{columns:u,rows:c,rowKey:e=>e.pid,minWidthPx:880,mobileMode:`scroll`,maxBodyHeight:x,emptyMessage:`Scanning…`})]})}var F={width:320,height:64},Re=.8,I=Math.ceil(8*Re-3)+1,L=F.width+34,R=F.height+I+1+11,ze=I+F.height+1+3+Math.ceil(8*Re),Be=[1,2,5,10],Ve=[1,2,4,8,16,32,64,128,256,512,1024],He=[1,1.5,2,2.5,3,4,5],z=[4,3,5,2],Ue=1e-9;function We(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 He.some(e=>Math.abs(t-e)<Ue)}let n=e/10**Math.floor(Math.log10(e));return He.some(e=>Math.abs(n-e)<Ue)}function Ge(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 Ve){let n=t*e;if(n>=r)return n}return 1024*e}let i=10**Math.floor(Math.log10(r));for(let e of Be){let t=e*i;if(t>=r)return t}return 10*i}function B(e,t){if(!Number.isFinite(e)||e<=0)return[];let n=z.find(n=>We(e/n,t))??z[z.length-1],r=e/n,i=[];for(let e=1;e<=n;e++)i.push(r*e);return i}var Ke=2.5;function V(e){return e*Ke}function H(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 U(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 W(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 G(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 qe(e){return e.length<2?0:Math.max(0,e.at(-1).atMs-e[0].atMs)}function Je(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 Ye(e,t){if(e.length===0)return null;let n=0,r=1/0;for(let i=0;i<e.length;i++){let a=Math.abs(e[i].x-t);a<r&&(r=a,n=i)}return n}n();var K={main:`var(--load-series-main)`,gc:`var(--load-series-gc)`},Xe=`
|
|
2
|
-
.load-chart-scope { --load-series-main: #2a78d6; --load-series-gc: #e87ba4; }
|
|
3
|
-
@media (prefers-color-scheme: dark) {
|
|
4
|
-
:root:not([data-theme="light"]) .load-chart-scope {
|
|
5
|
-
--load-series-main: #3987e5; --load-series-gc: #d55181;
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
|
-
:root[data-theme="dark"] .load-chart-scope {
|
|
9
|
-
--load-series-main: #3987e5; --load-series-gc: #d55181;
|
|
10
|
-
}
|
|
11
|
-
`,q=F,J={height:R};function Ze({title:e,points:n,mainLabel:s,gcLabel:u,formatValue:d,emptyMessage:f,gapMs:p}){let m=i(),h=t(null),[g,_]=c(null),v=a(()=>{let e=n.map(e=>({atMs:e.atMs,value:e.main===null||e.gc===null?null:e.main+e.gc})),t=n.map(e=>({atMs:e.atMs,value:e.main})),r=Ge(e.map(e=>e.value),25,`linear`),i=H(e,q,r,p),a=H(t,q,r,p),o=a.map(e=>({x:e.x,y:e.y===null?null:q.height,gapBefore:e.gapBefore}));return{max:r,ticks:B(r,`linear`),upper:i,middle:a,base:o,gaps:Je(i),times:G(e,q),spanMs:qe(e)}},[n,p]),y=n.at(-1),b=g===null?void 0:n[g.index],x=b??y;return n.length===0||v.upper.every(e=>e.y===null)?l(X,{title:e,children:l(st,{message:f})}):l(X,{title:e,legend:r(o,{children:[l(ot,{color:K.main,label:s}),l(ot,{color:K.gc,label:u})]}),readout:x&&x.main!==null&&x.gc!==null?r(o,{children:[b!==void 0&&l(at,{atMs:b.atMs,spanMs:v.spanMs}),l(Z,{color:K.main,text:d(x.main)}),l(Z,{color:K.gc,text:d(x.gc)})]}):null,children:r(`svg`,{ref:h,viewBox:`0 0 ${L} ${R}`,preserveAspectRatio:`none`,className:`w-full`,style:J,role:`img`,"aria-label":`${e}: ${s} and ${u} over time`,onMouseLeave:()=>_(null),onMouseMove:e=>{let t=e.currentTarget.getBoundingClientRect();if(t.width===0)return;let n=(e.clientX-t.left)/t.width*L-34,r=Ye(v.upper,n);r!==null&&_({index:r,xPx:v.upper[r].x})},children:[l(Qe,{ticks:v.ticks,max:v.max,formatValue:d}),l(it,{ticks:v.times,spanMs:v.spanMs}),r(`g`,{transform:`translate(34,${I})`,clipPath:`url(#${m})`,children:[l(`clipPath`,{id:m,children:l(`rect`,{x:0,y:0,width:q.width,height:q.height})}),l($e,{spans:v.gaps}),l(`path`,{d:W(v.middle,v.base),fill:K.main,fillOpacity:.85}),l(`path`,{d:W(v.upper,v.middle),fill:K.gc,fillOpacity:.85,stroke:`var(--color-surface, transparent)`,strokeWidth:2}),l(`path`,{d:U(v.upper),fill:`none`,stroke:K.gc,strokeWidth:2}),g!==null&&l(`line`,{x1:g.xPx,x2:g.xPx,y1:0,y2:q.height,stroke:`currentColor`,strokeWidth:1,className:`text-foreground-subtle`})]})]})})}function Y({title:e,points:n,formatValue:i,emptyMessage:s,axisFloor:u,axisScale:d=`linear`,gapMs:f}){let p=t(null),[m,h]=c(null),g=a(()=>{let e=Ge(n.map(e=>e.value),u,d),t=H(n,q,e,f);return{max:e,ticks:B(e,d),projected:t,gaps:Je(t),times:G(n,q),spanMs:qe(n)}},[n,u,d,f]),_=m===null?void 0:n[m.index],v=_??n.at(-1)??void 0;return n.length===0||g.projected.every(e=>e.y===null)?l(X,{title:e,children:l(st,{message:s})}):l(X,{title:e,readout:v&&v.value!==null?r(o,{children:[_!==void 0&&l(at,{atMs:_.atMs,spanMs:g.spanMs}),l(Z,{color:K.main,text:i(v.value)})]}):null,children:r(`svg`,{ref:p,viewBox:`0 0 ${L} ${R}`,preserveAspectRatio:`none`,className:`w-full`,style:J,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*L-34,r=Ye(g.projected,n);r!==null&&h({index:r,xPx:g.projected[r].x})},children:[l(Qe,{ticks:g.ticks,max:g.max,formatValue:i}),l(it,{ticks:g.times,spanMs:g.spanMs}),r(`g`,{transform:`translate(34,${I})`,children:[l($e,{spans:g.gaps}),l(`path`,{d:U(g.projected),fill:`none`,stroke:K.main,strokeWidth:2}),m!==null&&l(`line`,{x1:m.xPx,x2:m.xPx,y1:0,y2:q.height,stroke:`currentColor`,strokeWidth:1,className:`text-foreground-subtle`})]})]})})}function Qe({ticks:e,max:t,formatValue:n}){let i=t<=0?1:t;return l(`g`,{className:`text-foreground-subtle`,children:e.map(e=>{let t=I+q.height-e/i*q.height;return r(`g`,{children:[l(`line`,{x1:34,x2:34+q.width,y1:t,y2:t,stroke:`currentColor`,strokeWidth:.5,strokeOpacity:.3}),l(`text`,{x:0,y:t+3,fontSize:8,fill:`currentColor`,children:n(e)})]},e)})})}function $e({spans:e}){return e.length===0?null:l(`g`,{className:`text-foreground-subtle`,children:e.map(e=>l(`rect`,{x:e.fromX,y:0,width:Math.max(1,e.toX-e.fromX),height:q.height,fill:`currentColor`,fillOpacity:.12,children:l(`title`,{children:`No samples in this interval — nothing was measured, nothing is drawn.`})},`${e.fromX}-${e.toX}`))})}var et=10*6e4,tt={hour:`2-digit`,minute:`2-digit`},nt={hour:`2-digit`,minute:`2-digit`,second:`2-digit`};function rt(e,t){return new Date(e).toLocaleTimeString(void 0,t<et?nt:tt)}function it({ticks:e,spanMs:t}){return e.length===0?null:l(`g`,{className:`text-foreground-subtle`,children:e.map(e=>l(`text`,{x:34+e.x,y:ze,fontSize:8,textAnchor:e.anchor,fill:`currentColor`,children:rt(e.atMs,t)},e.atMs))})}function at({atMs:e,spanMs:t}){return l(`span`,{className:`text-[10px] tabular-nums text-foreground-subtle`,children:rt(e,t)})}function X({title:e,legend:t,readout:n,children:i}){return r(`div`,{className:`load-chart-scope min-w-0`,children:[r(`div`,{className:`flex items-baseline justify-between gap-2 mb-1`,children:[l(`span`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle`,children:e}),l(`div`,{className:`flex items-center gap-2`,children:n})]}),i,t&&l(`div`,{className:`flex items-center gap-3 mt-1`,children:t})]})}function ot({color:e,label:t}){return r(`span`,{className:`inline-flex items-center gap-1 text-[9px] text-foreground-subtle`,children:[l(`span`,{className:`inline-block h-2 w-2 rounded-[2px]`,style:{backgroundColor:e}}),t]})}function Z({color:e,text:t}){return r(`span`,{className:`inline-flex items-center gap-1 text-[11px] tabular-nums text-foreground`,children:[l(`span`,{className:`inline-block h-2 w-2 rounded-[2px]`,style:{backgroundColor:e}}),t]})}function st({message:e}){return l(`div`,{className:`h-16 flex items-center justify-center rounded border border-dashed border-border text-[10px] text-foreground-subtle text-center px-2`,children:e})}function ct(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 lt(e,t,n,r){let i=e.get(t),a=ct(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 ut(e,t,n){let r=e;for(let e of we(t,n))r=lt(r,e.key,e.kind,e.point);return r}function dt(e,t){let n=e;for(let e of t)for(let t of e.points)n=lt(n,e.key,e.kind,t);return n}function ft(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 pt=12e4;function mt(e,t){return e===null?!1:t-e>pt}function ht(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 gt(e){for(let t of e.values()){let e=t.points.at(-1);if(e&&e.cpuMainPercent!==null)return!0}return!1}var _t={key:`cpu`,dir:`desc`};function vt(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 yt(e){return e.points.at(-1)?.memoryRssBytes??null}function bt(e,t,n){let r=n.trim().toLowerCase();return r===``?!0:e.toLowerCase().includes(r)||t.toLowerCase().includes(r)}function xt(e,t){return t===`memory`?yt(e):vt(e)}function St(e,t,n){let r=e.filter(e=>t.selectedKeys.size>0&&!t.selectedKeys.has(e.key)?!1:bt(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=xt(e,t.sort.key),o=xt(r,t.sort.key);if(a===null&&o===null)return i(e,r);if(a===null)return 1;if(o===null)return-1;let s=t.sort.dir===`desc`?o-a:a-o;return s===0?i(e,r):s})}n();function Ct(e,n=720){let r=A(`metrics.node-processes-snapshot`,t=>t.nodeId===e),[i,a]=c(new Map),[o,s]=c(void 0),l=t(null),{data:d,isPending:f}=g({forNodeId:e,sinceMs:o,maxPoints:n});u(()=>{d!==void 0&&a(e=>{let t=dt(e,d.series);return l.current=ft(t),t})},[d]);let p=r?.timestamp;u(()=>{r==null||p===void 0||(mt(l.current,p)&&s(l.current??0),a(e=>{let t=ut(e,r.processes,p);return l.current=ft(t),t}))},[p]),u(()=>{a(new Map),s(void 0),l.current=null},[e]);let m=0;for(let e of i.values())m=Math.max(m,e.points.length);return{series:ht(i),sampleCount:m,threadSplitAvailable:gt(i),loadingRetained:f,durable:d?.durable??null,bucketMs:d?.bucketMs??null,cadenceMs:d?.cadenceMs??null,retainedSamples:d?.retainedSamples??null}}var wt=`__unclaimed__`;function Tt(e,t){return{kind:e,deviceId:t,cpu:0,cpuKnown:!0,rss:0,rssKnown:!0,count:0,roles:new Set}}function Et(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 Dt(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)??Tt(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])=>Et(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=Tt(`unclaimed`,null);for(let e of a)o.count+=1,o.rss+=e.memoryRssBytes;return o.cpuKnown=!1,[...i,Et(wt,o)]}var Ot=[{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 kt(e){return e.attribution===`measured`&&e.wiredToday}function At(){let e=new Set;for(let t of Ot)kt(t)&&e.add(t.family);return e}var jt=At();function Mt(e){return!jt.has(e.role)||e.deviceId===null?!1:e.attribution===`measured`}function Nt(e){return`${e.addonId}${e.role}${e.unit}${e.pid??`-`}`}function Pt(){return{cpuSeconds:0,cpuKnown:!0,rssBytes:0,rssKnown:!0,unitCount:0,roles:new Set}}function Ft(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 It(e){return Math.round(e*10)/10}function Lt(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)Mt(t)&&i.set(Nt(t),t);let a=new Map,o=new Set;for(let n of t.entries){if(!Mt(n)||n.deviceId===null)continue;let t=Nt(n);o.add(t);let r=a.get(n.deviceId)??Pt();r.unitCount+=1,r.roles.add(n.role);let s=Ft(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?It(n.cpuSeconds/r*100):null,rssBytes:n.rssKnown?n.rssBytes:null,unitCount:n.unitCount,roles:[...n.roles].toSorted()}}))}function Rt(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 zt(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 Bt(e){let t=e.indexOf(`@`);return t===-1?{addonId:e,nodeId:null}:{addonId:e.slice(0,t),nodeId:e.slice(t+1)}}function Vt(e,t){let n=Bt(e);return n.nodeId===null?t.isHub:n.nodeId===t.nodeId}function Ht(e,t){return e.filter(e=>Vt(e.addonId,t))}n();function Ut(e){let n=A(`metrics.node-processes-snapshot`,t=>t.nodeId===e.nodeId),r=ye(void 0,{staleTime:1/0,refetchOnWindowFocus:!1}),[i,a]=c(new Map),o=t(null),s=t(r.refetch);s.current=r.refetch;let l=n?.timestamp;u(()=>{l!==void 0&&s.current()},[l]),u(()=>{a(new Map),o.current=null},[e.nodeId,e.isHub]);let d=r.data,f=r.dataUpdatedAt;u(()=>{if(d===void 0||f===0)return;let t={atMs:f,entries:Ht(d,e)},n=o.current;if(o.current=t,n===null)return;let r=Lt(n,t);r.length!==0&&a(e=>Rt(e,r))},[d,f,e.nodeId,e.isHub]);let p=d===void 0?[]:Ht(d,e),m=n?.processes,h=Dt(p,m);return{series:zt(i),unclaimed:h.find(e=>e.kind===`unclaimed`)??null,loading:r.isPending,error:r.error===null?null:r.error.message}}function Wt(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 Gt=25,Kt=64*1024*1024,qt=1e4;function Jt({scope:e,cadenceMs:t}){let{t:n}=M(),i=Ut(e),{data:a=[]}=se({isCamera:!0,projection:`slim`}),o=Wt(a),s=V(t??qt);return r(`section`,{className:`space-y-3`,children:[i.error!==null&&r(`div`,{className:`flex items-start gap-2 rounded-md border border-destructive/40 bg-destructive/5 px-3 py-2 text-[11px] text-destructive`,children:[l(ve,{className:`h-3 w-3 mt-0.5 shrink-0`}),l(`span`,{children:n(`cameraLoad.readFailed`,`Could not read the load contributions: {{error}}. This is a failed read, NOT an idle cluster.`,{error:i.error})})]}),l(Xt,{unclaimed:i.unclaimed}),i.series.length===0&&i.error===null&&l(`div`,{className:`rounded-md border border-dashed border-border px-3 py-6 text-center text-[11px] text-foreground-subtle`,children:i.loading?n(`cameraLoad.loading`,`Reading what the addons report…`):n(`cameraLoad.waitingWindow`,`No per-camera window yet.`)}),l(`div`,{className:`space-y-3`,children:i.series.map(e=>r(`div`,{className:`rounded-lg border border-border p-3`,children:[r(`div`,{className:`flex items-baseline justify-between gap-2 mb-2`,children:[l(Yt,{deviceId:e.deviceId,name:o.get(e.deviceId)}),l(`span`,{className:`text-[10px] text-foreground-subtle`,children:n(`cameraLoad.unitCount`,`{{count}} unit(s): {{roles}}`,{count:e.points.at(-1)?.unitCount??0,roles:(e.points.at(-1)?.roles??[]).join(`, `)})})]}),r(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[l(Y,{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:Gt,gapMs:s,emptyMessage:n(`cameraLoad.cpuUnavailable`,`No measurable window yet.`)}),l(Y,{title:n(`cameraLoad.memoryTitle`,`Memory RSS`),points:e.points.map(e=>({atMs:e.atMs,value:e.rssBytes})),formatValue:N,axisFloor:Kt,axisScale:`bytes`,gapMs:s,emptyMessage:n(`cameraLoad.memoryUnavailable`,`No memory reported.`)})]})]},e.deviceId))})]})}function Yt({deviceId:e,name:t}){let{t:n}=M();return t===void 0?l(`span`,{className:`text-xs font-medium text-foreground`,children:n(`cameraLoad.deviceLabel`,`Camera {{deviceId}}`,{deviceId:e})}):r(`span`,{className:`flex items-baseline gap-1.5 min-w-0`,children:[l(`span`,{className:`text-xs font-medium text-foreground truncate`,children:t}),r(`span`,{className:`shrink-0 text-[10px] font-mono text-foreground-subtle`,children:[`#`,e]})]})}function Xt({unclaimed:e}){let{t}=M();return e===null||e.unitCount===0?null:l(`div`,{className:`flex items-center gap-2`,children:l(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded-full bg-amber-500/10 text-amber-400 font-medium tabular-nums`,children:t(`cameraLoad.unclaimedBadge`,`{{count}} unclaimed · {{rss}}`,{count:e.unitCount,rss:e.rssBytes===null?`—`:N(e.rssBytes)})})})}n();var Zt=256*1024*1024,Qt=1e4;function $t({nodeId:e,isHub:t}){let{t:n}=M(),{series:i,sampleCount:o,threadSplitAvailable:s,loadingRetained:u,bucketMs:d,cadenceMs:f}=Ct(e),[p,m]=c(``),[h,g]=c(new Set),[_,y]=c(_t),b=e=>e.key===`__root__`?n(`clusterLoad.bucketRoot`,`Node supervisor`):e.key===`__unattributed__`?n(`clusterLoad.bucketUnattributed`,`Unattributed processes`):e.key,x=V(d??f??Qt),S=a(()=>St(i,{search:p,selectedKeys:h,sort:_},b),[i,p,h,_]),C=e=>{g(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})};return r(`div`,{className:`space-y-4`,children:[l(`style`,{children:Xe}),l(en,{bucketMs:d,cadenceMs:f}),!s&&o>0&&r(`div`,{className:`flex items-start gap-2 rounded-md border border-amber-500/40 bg-amber-500/5 px-3 py-2 text-[11px] text-amber-400`,children:[l(ve,{className:`h-3 w-3 mt-0.5 shrink-0`}),l(`span`,{children:n(`clusterLoad.noThreadSplit`,`No thread-level CPU split on this node — /proc/<pid>/task is Linux-only, and the first sample after a restart has no window to measure. CPU below falls back to the ps lifetime AVERAGE, which is not a rate.`)})]}),o===0&&l(`div`,{className:`rounded-md border border-dashed border-border px-3 py-6 text-center text-[11px] text-foreground-subtle`,children:u?n(`clusterLoad.loadingRetained`,`Reading the retained series from this node…`):n(`clusterLoad.waitingFirstSample`,`No retained samples for this node — waiting for the next snapshot (up to 20s). The chart needs two to draw a rate.`)}),i.length>0&&r(`div`,{className:`space-y-2`,children:[r(`div`,{className:`flex flex-wrap items-center gap-2`,children:[r(`label`,{className:`relative flex-1 min-w-[160px]`,children:[l(v,{className:`pointer-events-none absolute left-2 top-1/2 h-3 w-3 -translate-y-1/2 text-foreground-subtle`}),l(`input`,{type:`search`,value:p,onChange:e=>m(e.target.value),placeholder:n(`clusterLoad.searchPlaceholder`,`Find a runner…`),"aria-label":n(`clusterLoad.searchLabel`,`Find a runner`),className:`w-full rounded border border-border bg-background py-1 pl-7 pr-2 text-[11px] text-foreground placeholder:text-foreground-subtle`})]}),l(tn,{sort:_,onChange:y})]}),r(`div`,{className:`flex flex-wrap items-center gap-1`,children:[i.map(e=>{let t=h.has(e.key);return l(`button`,{type:`button`,"aria-pressed":t,onClick:()=>C(e.key),className:`rounded-full border px-2 py-0.5 text-[10px] transition-colors ${t?`border-primary bg-primary/10 text-primary`:`border-border text-foreground-subtle hover:text-foreground`}`,children:b(e)},e.key)}),h.size>0&&r(`button`,{type:`button`,onClick:()=>g(new Set),className:`inline-flex items-center gap-1 rounded-full border border-border px-2 py-0.5 text-[10px] text-foreground-subtle hover:text-foreground`,children:[l(E,{className:`h-2.5 w-2.5`}),n(`clusterLoad.clearFilter`,`All runners`)]})]})]}),i.length>0&&S.length===0&&l(`div`,{className:`rounded-md border border-dashed border-border px-3 py-6 text-center text-[11px] text-foreground-subtle`,children:n(`clusterLoad.noMatches`,`No runner matches this search on {{count}} present. The node is reporting — the filter is hiding them.`,{count:i.length})}),l(`div`,{className:`space-y-3`,children:S.map(e=>r(`div`,{className:`rounded-lg border border-border p-3`,children:[r(`div`,{className:`flex items-baseline justify-between gap-2 mb-2`,children:[l(`span`,{className:`text-xs font-medium text-foreground`,children:b(e)}),l(`span`,{className:`text-[10px] text-foreground-subtle`,children:n(`clusterLoad.processCount`,`{{count}} process(es)`,{count:e.points.at(-1)?.processCount??0})})]}),r(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[l(Ze,{title:s?n(`clusterLoad.cpuTitle`,`CPU % of one core`):n(`clusterLoad.cpuTitleLifetime`,`CPU % (ps lifetime average)`),mainLabel:n(`clusterLoad.seriesMain`,`Main threads`),gcLabel:n(`clusterLoad.seriesGc`,`GC / V8 helpers`),points:e.points.map(e=>({atMs:e.atMs,main:e.cpuMainPercent,gc:e.cpuGcPercent})),formatValue:e=>`${e.toFixed(0)}%`,gapMs:x,emptyMessage:n(`clusterLoad.cpuUnavailable`,`No thread split on this node. Lifetime average: {{avg}}%`,{avg:(e.points.at(-1)?.cpuLifetimePercent??0).toFixed(1)})}),l(Y,{title:n(`clusterLoad.memoryTitle`,`Memory RSS`),points:e.points.map(e=>({atMs:e.atMs,value:e.memoryRssBytes})),formatValue:N,axisFloor:Zt,axisScale:`bytes`,gapMs:x,emptyMessage:n(`clusterLoad.memoryUnavailable`,`No memory samples yet.`)})]})]},e.key))}),l(Jt,{scope:{nodeId:e,isHub:t},cadenceMs:f})]})}function en({bucketMs:e,cadenceMs:t}){let{t:n}=M();return e===null?null:l(`p`,{className:`text-[10px] text-foreground-subtle`,children:t!==null&&e>t?n(`clusterLoad.captionBucket`,`1 point = {{bucket}}s (bucket MAXIMUM, not a mean)`,{bucket:Math.round(e/1e3)}):n(`clusterLoad.captionRaw`,`1 point = 1 snapshot`)})}function tn({sort:e,onChange:t}){let{t:n}=M(),i=[{key:`cpu`,label:n(`clusterLoad.sortCpu`,`CPU`)},{key:`memory`,label:n(`clusterLoad.sortMemory`,`Memory`)},{key:`name`,label:n(`clusterLoad.sortName`,`Name`)}];return r(`div`,{className:`flex items-center gap-1`,children:[l(`span`,{className:`text-[10px] text-foreground-subtle`,children:n(`clusterLoad.sortBy`,`Sort by`)}),i.map(n=>{let i=e.key===n.key;return r(`button`,{type:`button`,"aria-pressed":i,onClick:()=>t(i?{key:n.key,dir:e.dir===`desc`?`asc`:`desc`}:{key:n.key,dir:n.key===`name`?`asc`:`desc`}),className:`rounded border px-1.5 py-0.5 text-[10px] transition-colors ${i?`border-primary bg-primary/10 text-primary`:`border-border text-foreground-subtle hover:text-foreground`}`,children:[n.label,i&&(e.dir===`desc`?` ↓`:` ↑`)]},n.key)})]})}var nn=`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 rn({nodeId:e,addonIds:t}){return t.length===0?l(`div`,{className:`py-4 text-xs text-muted-foreground text-center`,children:`No addons on this node`}):l(`div`,{className:`w-full py-2`,children:l(Te,{nodeId:e,addonIds:t,level:`global`,fieldScope:`perNode`,emptyMessage:nn,selfTabbed:!0})})}n();function an({nodeId:e,addons:t}){let n=s(),{data:r,isLoading:i}=_({nodeId:e}),o=a(()=>{let e=new Map;for(let n of t)for(let t of n.capabilities){let r=e.get(t)??[];r.push(n.id),e.set(t,r)}return[...e.entries()].toSorted(([e],[t])=>e.localeCompare(t)).map(([e,t])=>({capName:e,providers:t}))},[t]),c=le({onSuccess:()=>{n.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCapabilityBindings`]]})}});return o.length===0?l(`div`,{className:`py-4 text-xs text-muted-foreground text-center`,children:`No capabilities on this node`}):l(Se,{columns:[{key:`capName`,header:`Capability`,width:`w-1/2`,sortValue:e=>e.capName,render:e=>l(`span`,{className:`font-medium`,children:e.capName})},{key:`provider`,header:`Bound provider`,render:t=>{let n=r?.[t.capName]??t.providers[0]??``,a=t.providers.length===1;return l(`select`,{value:n,onChange:n=>c.mutate({nodeId:e,capName:t.capName,addonId:n.target.value}),disabled:a||c.isPending||i,className:`w-full rounded-md border border-border bg-surface px-2 py-1 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary disabled:opacity-60`,title:a?`Only one provider installed — choice becomes available once a second addon registers this capability`:void 0,children:t.providers.map(e=>l(`option`,{value:e,children:e},e))})}}],rows:o,rowKey:e=>e.capName,minWidthPx:520,mobileMode:`scroll`,maxBodyHeight:x})}n();function on(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 sn(e){let[t,n]=c(!1),[i,a]=c(e.name),o=s(),u=D({onSuccess:()=>{o.invalidateQueries({queryKey:[[`nodes`,`topology`]]})}}),d=(e.localIps??[]).filter(e=>!e.includes(`:`)),f=(e.localIps??[]).filter(e=>e.includes(`:`)),p=async()=>{if(!i.trim()||i===e.name){n(!1);return}try{await u.mutateAsync({nodeId:e.nodeId,name:i.trim()}),n(!1)}catch(e){console.error(`Rename failed:`,e)}},m=[[`Node ID`,l(`span`,{className:`font-mono text-xs`,children:e.nodeId})],[`Display Name`,t?r(`div`,{className:`flex items-center gap-1.5`,children:[l(`input`,{type:`text`,className:`flex-1 px-2 py-0.5 text-xs border border-border rounded bg-background focus:outline-none focus:ring-1 focus:ring-primary`,value:i,onChange:e=>a(e.target.value),onKeyDown:e=>{e.key===`Enter`&&p(),e.key===`Escape`&&n(!1)},disabled:u.isPending,autoFocus:!0}),l(`button`,{onClick:()=>void p(),disabled:u.isPending,className:`p-0.5 text-success hover:bg-success/10 rounded`,title:`Save`,children:l(oe,{className:`h-3.5 w-3.5`})}),l(`button`,{onClick:()=>n(!1),className:`p-0.5 text-muted-foreground hover:bg-muted rounded`,title:`Cancel`,children:l(E,{className:`h-3.5 w-3.5`})})]}):r(`div`,{className:`flex items-center gap-1.5`,children:[l(`span`,{className:`text-xs`,children:e.name}),!e.isHub&&l(`button`,{onClick:()=>{a(e.name),n(!0)},className:`p-0.5 text-muted-foreground hover:text-primary rounded`,title:`Rename`,children:l(C,{className:`h-3 w-3`})})]})],[`Hostname`,l(`span`,{className:`text-xs`,children:e.hostname})],[`Role`,e.isHub?l(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-primary/10 text-primary font-medium`,children:`Hub`}):l(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-muted text-muted-foreground font-medium`,children:`Agent`})],[`Root Package`,e.rootPackage?r(`span`,{className:`font-mono text-xs`,children:[e.rootPackage.name,`@`,e.rootPackage.version]}):l(`span`,{className:`text-xs text-muted-foreground`,children:`—`})],[`Platform`,r(`span`,{className:`text-xs`,children:[e.platform,` / `,e.arch]})],[`CPU`,r(`span`,{className:`text-xs`,children:[e.cpuModel??`—`,` (`,e.cpuCores,` cores)`]})],[`Memory`,l(`span`,{className:`text-xs`,children:e.memoryMB>0?`${(e.memoryMB/1024).toFixed(1)} GB`:`—`})],[`Uptime`,l(`span`,{className:`text-xs`,children:on(e.uptime)})],[`Engines`,e.engines.length>0?l(`div`,{className:`flex flex-wrap gap-1`,children:e.engines.map(e=>l(`span`,{className:`text-[9px] px-1.5 py-0.5 rounded-full bg-purple-500/10 text-purple-400 font-medium`,children:e},e))}):l(`span`,{className:`text-xs text-muted-foreground`,children:`—`})]];return d.length>0&&m.push([`IPv4`,l(`div`,{className:`flex flex-wrap gap-1.5`,children:d.map((e,t)=>l(`span`,{className:`font-mono text-xs px-1.5 py-0.5 rounded bg-muted`,children:e},`${e}-${t}`))})]),f.length>0&&m.push([`IPv6`,l(`div`,{className:`flex flex-wrap gap-1.5`,children:f.map((e,t)=>l(`span`,{className:`font-mono text-[10px] px-1.5 py-0.5 rounded bg-muted truncate max-w-[280px]`,title:e,children:e},`${e}-${t}`))})]),l(`div`,{className:`py-2`,children:l(`table`,{className:`w-full text-sm`,children:l(`tbody`,{children:m.map(([e,t],n)=>r(`tr`,{className:n%2==0?`bg-muted/20`:``,children:[l(`td`,{className:`py-1.5 px-2 text-xs font-medium text-muted-foreground w-28 align-top whitespace-nowrap`,children:e}),l(`td`,{className:`py-1.5 px-2`,children:t})]},e))})})})}n();var cn=[[`serverManagement`,`getServerPackageStatus`]];function ln({label:e,tone:t}){return l(`span`,{className:`inline-flex items-center rounded px-2 py-0.5 text-[11px] font-medium ${{neutral:`bg-surface-muted text-foreground-subtle`,ok:`bg-emerald-500/15 text-emerald-500`,info:`bg-sky-500/15 text-sky-500`,warn:`bg-amber-500/15 text-amber-500`,error:`bg-red-500/15 text-red-500`}[t]}`,children:e})}function Q({label:e,value:t}){return r(`div`,{className:`flex items-center justify-between gap-4 text-sm`,children:[l(`span`,{className:`text-foreground-subtle`,children:e}),l(`span`,{className:`font-mono text-foreground`,children:t??`—`})]})}var un={ok:`border-emerald-500/40 bg-emerald-500/10 text-emerald-500`,warn:`border-amber-500/40 bg-amber-500/10 text-amber-500`,error:`border-red-500/40 bg-red-500/10 text-red-500`};function dn(e){return e.outcome===`failed`?`error`:(e.outcome,e.accepted?`ok`:`warn`)}function fn(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 pn({node:t}){let{t:n}=M(),i=s(),a=re(),[o,u]=c(!1),[d,f]=c(null),p=t.isHub?void 0:{nodeId:t.id},m=te(p,{refetchInterval:1e4,enabled:t.isOnline,retry:1}),h=m.data??null,g=e(()=>{i.invalidateQueries({queryKey:cn})},[i]),_=ee({onSettled:g}),v=de({onSettled:g}),y=ne({onSettled:g}),b=e(async()=>{if(h?.latestVersion==null){f({tone:`warn`,text:n(`serverManagement.outcomeNoTarget`,`No target version is known for this node — run "Check for update" first.`)});return}if(await a({title:n(`serverManagement.confirmUpdateTitle`,`Update node root package`),message:n(`serverManagement.confirmUpdateBody`,`Install {{pkg}}@{{version}} on "{{node}}" and restart to apply.`,{pkg:h.packageName,version:h.latestVersion,node:t.name}),confirmLabel:n(`serverManagement.confirmUpdateAction`,`Update & restart`)})){f(null);try{let e=await v.mutateAsync({version:h.latestVersion,...p});f({tone:dn(e),text:e.message}),e.restarting&&u(!0)}catch(e){f({tone:`warn`,text:fn(n,e)})}}},[v,a,t.name,p,h,n]),x=e(async()=>{if(await a({title:n(`serverManagement.confirmRestartTitle`,`Restart node`),message:n(`serverManagement.confirmRestartBody`,`Restart "{{node}}"? In-flight requests to this node are dropped.`,{node:t.name}),confirmLabel:n(`serverManagement.confirmRestartAction`,`Restart`),variant:`warning`})){f(null);try{let e=await y.mutateAsync(p);f({tone:dn(e),text:e.message}),e.restarting&&u(!0)}catch(e){f({tone:`warn`,text:fn(n,e)})}}},[a,t.name,y,p,n]),S=()=>{switch(h?.bootMode){case`data-root`:return{label:n(`serverManagement.bootDataRoot`,`runtime-updatable`),tone:`ok`};case`workspace`:return{label:n(`serverManagement.bootWorkspace`,`dev workspace`),tone:`info`};default:return{label:n(`serverManagement.bootBaked`,`baked image seed`),tone:`neutral`}}},C=()=>{if(h==null)return null;switch(h.updateState){case`checking`:return{label:n(`serverManagement.stateChecking`,`checking…`),tone:`info`};case`staging`:return{label:n(`serverManagement.stateStaging`,`updating…`),tone:`info`};case`pending-restart`:return{label:n(`serverManagement.statePending`,`restart pending`),tone:`warn`};default:return h.restartRequired===!0?{label:n(`serverManagement.stateRestartRequired`,`restart required`),tone:`warn`}:h.updateAvailable?{label:n(`serverManagement.stateUpdateAvailable`,`update available`),tone:`warn`}:{label:n(`serverManagement.stateUpToDate`,`up to date`),tone:`ok`}}},T=h?.bootMode===`workspace`,E=t.isOnline&&h!=null&&!T&&h.updateAvailable&&h.updateState===`idle`&&!v.isPending,D=t.isOnline&&h!=null&&h.updateState===`idle`&&!y.isPending,k=t.isOnline?C():null;return r(`div`,{className:`space-y-4 py-2`,children:[r(`div`,{className:`flex items-center justify-between gap-3`,children:[r(`div`,{className:`flex items-center gap-2 min-w-0`,children:[l(`span`,{className:`font-mono text-xs text-foreground-subtle truncate`,children:h?.packageName??t.rootPackage?.name??`@camstack/server`}),t.isOnline&&h!=null&&l(ln,{...S()})]}),k!=null&&l(ln,{...k})]}),!t.isOnline&&l(Q,{label:n(`serverManagement.lastReportedVersion`,`Last reported version`),value:t.rootPackage?.version??null}),t.isOnline&&m.isLoading&&r(`div`,{className:`flex items-center gap-2 text-sm text-foreground-subtle`,children:[l(j,{className:`h-4 w-4 animate-spin`}),n(`common.loading`,`Loading…`)]}),t.isOnline&&m.isError&&r(`div`,{className:`space-y-1.5`,children:[l(`p`,{className:`text-sm text-red-500`,children:n(`serverManagement.loadError`,`Could not load the node root-package status.`)}),t.rootPackage!=null&&l(Q,{label:n(`serverManagement.lastReportedVersion`,`Last reported version`),value:t.rootPackage.version})]}),t.isOnline&&h!=null&&r(`div`,{className:`space-y-1.5`,children:[l(Q,{label:n(`serverManagement.runningVersion`,`Running version`),value:h.runningVersion}),l(Q,{label:n(`serverManagement.latestVersion`,`Latest on registry`),value:h.latestVersion}),l(Q,{label:n(`serverManagement.imageSeedVersion`,`Image seed (baked)`),value:h.seedVersion}),l(Q,{label:n(`serverManagement.nodeRuntimeVersion`,`Node.js runtime`),value:h.nodeRuntimeVersion}),h.pendingVersion!=null&&l(Q,{label:n(`serverManagement.pendingVersion`,`Staged (applies on restart)`),value:h.pendingVersion}),h.installedVersion!=null&&h.installedVersion!==h.runningVersion&&l(Q,{label:n(`serverManagement.installedVersion`,`Installed on disk (runs after restart)`),value:h.installedVersion})]}),t.isOnline&&h?.imageContract?.state===`behind-series`&&r(`div`,{className:`rounded-md border border-red-500/40 bg-red-500/10 px-3 py-2 text-xs leading-relaxed text-red-500`,children:[l(`p`,{className:`mb-0.5 font-semibold`,children:n(`serverManagement.imageContractDiverged`,`Container image diverges from the deployment contract`)}),l(`p`,{children:h.imageContract.message})]}),t.isOnline&&T&&l(`p`,{className:`text-xs text-foreground-subtle`,children:n(`serverManagement.workspaceNote`,`Development workspace detected — runtime updates are disabled (the dev loop resolves code from the workspace).`)}),d!=null&&l(`p`,{role:`status`,className:`rounded border px-2 py-1.5 text-xs leading-relaxed ${un[d.tone]}`,children:d.text}),o&&r(`div`,{className:`flex items-center gap-2 text-sm text-amber-500`,children:[l(j,{className:`h-4 w-4 animate-spin`}),n(`serverManagement.nodeRestarting`,`The node is restarting to apply the change…`)]}),t.isOnline&&r(`div`,{className:`flex flex-wrap items-center gap-2 pt-1`,children:[r(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded border border-border px-2.5 py-1.5 text-xs font-medium text-foreground hover:bg-surface-muted disabled:opacity-50`,disabled:_.isPending||h?.updateState===`staging`,onClick:()=>_.mutate(p),children:[_.isPending?l(j,{className:`h-3.5 w-3.5 animate-spin`}):l(O,{className:`h-3.5 w-3.5`}),n(`serverManagement.checkForUpdate`,`Check for update`)]}),E&&r(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded bg-primary px-2.5 py-1.5 text-xs font-medium text-primary-foreground hover:opacity-90 disabled:opacity-50`,onClick:()=>void b(),children:[v.isPending?l(j,{className:`h-3.5 w-3.5 animate-spin`}):l(ge,{className:`h-3.5 w-3.5`}),n(`serverManagement.updateTo`,`Update to {{version}}`,{version:h?.latestVersion??``})]}),r(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded border border-border px-2.5 py-1.5 text-xs font-medium text-foreground hover:bg-surface-muted disabled:opacity-50`,disabled:!D,onClick:()=>void x(),children:[y.isPending?l(j,{className:`h-3.5 w-3.5 animate-spin`}):l(w,{className:`h-3.5 w-3.5`}),n(`serverManagement.restart`,`Restart`)]})]}),t.isOnline&&h?.lastCheckedAtMs!=null&&r(`p`,{className:`flex items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[l(Ce,{className:`h-3 w-3`}),n(`serverManagement.lastChecked`,`Last checked: {{when}}`,{when:new Date(h.lastCheckedAtMs).toLocaleString()})]})]})}n();function mn({node:e}){let t=d(),[n,i]=c(`info`),[a,o]=c(!1),[s,u]=c(null),f=e.processes??[],p=e.addons.map(e=>e.id),h=async()=>{if(!a){o(!0),u(null);try{await t.trpcClient.pipelineOrchestrator.removeAgentSettings.mutate({agentNodeId:e.id}).catch(()=>void 0);let n=await t.trpcClient.clusterNodes.forgetNode.mutate({nodeId:e.id});u({tone:n.stillListed?`warn`:`ok`,text:n.message})}catch(e){u({tone:`warn`,text:`Forget failed: ${e instanceof Error?e.message:String(e)}`})}finally{o(!1)}}};return e.isOnline?r(`div`,{className:`border border-border rounded-xl`,children:[r(`div`,{className:`flex items-center gap-3 px-4 py-3 bg-muted/30 border-b border-border rounded-t-xl`,children:[l(`div`,{className:`w-2.5 h-2.5 rounded-full bg-success`}),l(`span`,{className:`text-sm font-semibold`,children:e.name}),r(`span`,{className:`text-xs text-muted-foreground`,children:[e.cpuModel??e.platform,` ·`,` `,e.memoryMB>0?`${Math.round(e.memoryMB/1024)}GB`:``,` · `,e.arch]}),e.engines.map(e=>l(`span`,{className:`text-[9px] px-1.5 py-0.5 rounded-full bg-purple-500/10 text-purple-400 font-medium`,children:e},e)),r(`div`,{className:`ml-auto flex gap-3 text-xs text-muted-foreground`,children:[r(`span`,{className:`flex items-center gap-1`,children:[l(me,{className:`h-3 w-3`}),` `,e.cpuPercent,`%`]}),r(`span`,{className:`flex items-center gap-1`,children:[l(P,{className:`h-3 w-3`}),` `,e.memoryPercent,`%`]})]})]}),l(`div`,{className:`sticky top-0 z-20 flex border-b border-border px-4 bg-background overflow-x-auto`,children:[`info`,`forks`,`processes`,`load`,`settings`,`capabilities`].map(e=>l(`button`,{onClick:()=>i(e),className:`shrink-0 whitespace-nowrap px-3 py-2 text-xs font-medium border-b-2 transition-colors ${n===e?`border-primary text-primary`:`border-transparent text-muted-foreground hover:text-foreground`}`,children:e===`info`?`General`:e===`forks`?`Forks (${f.length})`:e===`processes`?`Processes`:e===`load`?`Load`:e===`settings`?`Settings`:`Capabilities`},e))}),r(`div`,{className:`px-4 py-2`,children:[n===`info`&&r(`div`,{className:`space-y-3`,children:[l(sn,{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}),l(`div`,{className:`border-t border-border pt-1`,children:l(pn,{node:{id:e.id,name:e.name,isHub:e.isHub,isOnline:e.isOnline,rootPackage:e.rootPackage??null}})})]}),n===`forks`&&l(Ne,{nodeId:e.id,processes:f}),n===`processes`&&l(Le,{nodeId:e.id}),n===`load`&&l($t,{nodeId:e.id,isHub:e.isHub}),n===`settings`&&l(rn,{nodeId:e.id,addonIds:p}),n===`capabilities`&&l(an,{nodeId:e.id,addons:e.addons})]})]}):r(`div`,{className:`border border-border rounded-xl overflow-hidden opacity-60`,children:[r(`div`,{className:`flex items-center gap-3 px-4 py-3 bg-muted/30`,children:[l(`div`,{className:`w-2.5 h-2.5 rounded-full bg-destructive`}),l(`span`,{className:`text-sm font-semibold`,children:e.name}),r(`span`,{className:`text-xs text-muted-foreground`,children:[e.cpuModel??e.platform,` ·`,` `,e.memoryMB>0?`${Math.round(e.memoryMB/1024)}GB`:``,` · `,e.arch]}),e.engines.map(e=>l(`span`,{className:`text-[9px] px-1.5 py-0.5 rounded-full bg-purple-500/10 text-purple-400 font-medium`,children:e},e)),e.rootPackage&&r(`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]}),l(`span`,{className:`ml-auto text-xs px-2 py-0.5 rounded-full bg-destructive/10 text-destructive`,children:`offline`})]}),r(`div`,{className:`flex items-center justify-between gap-3 px-4 py-3`,children:[r(`span`,{className:`text-xs text-muted-foreground`,children:[e.lastSeen?`Last seen ${new Date(e.lastSeen).toLocaleString()} — `:``,e.addons.length,` addon`,e.addons.length===1?``:`s`,` assigned; will resume when node reconnects`]}),r(`button`,{type:`button`,onClick:()=>void h(),disabled:a,title:`Forget this node — removes its saved history and pipeline assignments`,className:`flex items-center gap-1 text-xs px-2 py-1 rounded-md border border-border text-muted-foreground hover:text-destructive hover:border-destructive/50 disabled:opacity-50 transition-colors`,children:[l(m,{className:`h-3 w-3`}),a?`Forgetting…`:`Forget node`]})]}),s!=null&&l(`p`,{role:`status`,className:`px-4 pb-3 text-xs leading-relaxed ${s.tone===`ok`?`text-emerald-500`:`text-amber-500`}`,children:s.text})]})}function hn({nodes:e,selected:t,onSelect:n}){let{t:i}=M(),a=Ee(e);return t===null?l(`div`,{className:`rounded-md border border-dashed border-border px-3 py-6 text-center text-xs text-foreground-subtle`,children:i(`cluster.noNodes`,`No nodes in this cluster yet.`)}):r(`div`,{className:`flex flex-col gap-3`,children:[a.length>1&&l(`div`,{className:`flex flex-wrap items-center gap-1.5`,role:`tablist`,"aria-label":i(`cluster.nodeSelectorLabel`,`Nodes`),children:a.map(e=>l(gn,{node:e,active:e.id===t.id,onSelect:()=>n(e.id)},e.id))}),l(mn,{node:t})]})}function gn({node:e,active:t,onSelect:n}){let{t:i}=M();return r(`button`,{type:`button`,role:`tab`,"aria-selected":t,onClick:n,className:`inline-flex items-center gap-1.5 rounded-full border px-2.5 py-1 text-xs transition-colors ${t?`border-primary bg-primary/10 text-primary`:`border-border text-muted-foreground hover:text-foreground`}`,children:[l(`span`,{className:`h-2 w-2 shrink-0 rounded-full ${e.isOnline?`bg-success`:`bg-destructive`}`}),l(`span`,{className:`font-medium`,children:e.name}),e.isOnline?r(`span`,{className:`inline-flex items-center gap-1 text-[10px] tabular-nums text-muted-foreground`,children:[l(me,{className:`h-3 w-3`}),e.cpuPercent,`%`,l(P,{className:`h-3 w-3`}),e.memoryPercent,`%`]}):l(`span`,{className:`text-[10px] text-destructive`,children:i(`cluster.offline`,`offline`)})]})}var $=3,_n=7e3;function vn(e){return[...e].sort((e,t)=>e.isHub===t.isHub?0:e.isHub?1:-1)}function yn(e){return e.isHub?{}:{nodeId:e.id}}function bn(e){return e.updateState===`staging`||e.updateState===`pending-restart`||e.pendingVersion!==null?!0:!e.updateAvailable}async function xn(e,t){let n=yn(e),r=`no answer`;for(let i=1;i<=$;i+=1)try{let r=await t.readStatus(n);return bn(r)?{nodeId:e.id,nodeName:e.name,outcome:`applied`,detail:`Connection dropped, and the node confirms the update landed (state ${r.updateState}, running ${r.runningVersion??`unknown`}).`}:{nodeId:e.id,nodeName:e.name,outcome:`failed`,detail:`Connection dropped and the node came back unchanged (still ${r.runningVersion??`unknown`}, update still available). Nothing was staged.`}}catch(e){r=e instanceof Error?e.message:String(e),i<$&&await t.wait(_n)}return{nodeId:e.id,nodeName:e.name,outcome:`unconfirmed`,detail:`Connection dropped and the node could not be confirmed after ${$} attempts (${r}). It may be restarting — re-check this node.`}}function Sn(e){return e.accepted?`applied`:e.outcome===`failed`?`failed`:`refused`}async function Cn(e,t){let n=[];for(let r of vn(e))try{let e=await t.apply(yn(r));n.push({nodeId:r.id,nodeName:r.name,outcome:Sn(e),detail:e.message})}catch{n.push(await xn(r,t))}return n}n();function wn(){let{nodes:e,isLoading:t}=y(),n=a(()=>e??[],[e]);return{nodes:n,isLoading:t&&n.length===0}}var Tn={applied:`border-emerald-500/40 bg-emerald-500/10 text-emerald-500`,refused:`border-amber-500/40 bg-amber-500/10 text-amber-500`,failed:`border-red-500/40 bg-red-500/10 text-red-500`,unconfirmed:`border-amber-500/40 bg-amber-500/10 text-amber-500`};function En(){let{t}=M(),n=re(),{nodes:i,isLoading:o}=wn(),{selection:s,selectNode:u}=Oe(i),f=s.node,p=a(()=>i.filter(e=>e.isOnline),[i]),m=p.length,h=i.filter(e=>!e.isOnline).length,g=de(),_=d(),[v,y]=c(!1),[b,x]=c([]),S=e(async()=>{let e=p.map(e=>({id:e.id,name:e.name,isHub:e.isHub}));if(await n({title:t(`serverManagement.confirmUpdateAllTitle`,`Update all nodes`),message:t(`serverManagement.confirmUpdateAllBody`,`Update and restart every online node, agents first, hub last. Up-to-date nodes are skipped; this page reconnects when the hub comes back.`),confirmLabel:t(`serverManagement.confirmUpdateAllAction`,`Update all & restart`),variant:`warning`})){y(!0),x([]);try{x(await Cn(e,{apply:e=>g.mutateAsync(e),readStatus:e=>_.trpcClient.serverManagement.getServerPackageStatus.query(e),wait:e=>new Promise(t=>setTimeout(t,e))}))}finally{y(!1)}}},[g,n,p,_,t]);return r(`div`,{className:`flex flex-col h-full gap-4 p-4`,children:[r(`div`,{className:`flex items-center justify-between gap-2 flex-wrap`,children:[r(`div`,{className:`flex items-center gap-2`,children:[m>0&&r(`span`,{className:`text-xs px-2 py-0.5 rounded-full bg-success/10 text-success`,children:[m,` online`]}),h>0&&r(`span`,{className:`text-xs px-2 py-0.5 rounded-full bg-destructive/10 text-destructive`,children:[h,` offline`]})]}),l(`div`,{className:`flex items-center gap-2`,children:m>1&&r(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:opacity-90 disabled:opacity-50`,disabled:v,title:t(`serverManagement.updateAllHint`,`Sequenced agents-first, hub-last — up-to-date nodes are skipped.`),onClick:()=>void S(),children:[v?l(j,{className:`h-3.5 w-3.5 animate-spin`}):l(ge,{className:`h-3.5 w-3.5`}),t(`serverManagement.updateAll`,`Update all nodes`)]})})]}),b.length>0&&l(`ul`,{"aria-label":`update-all-report`,className:`flex flex-col gap-1 text-xs`,children:b.map(e=>r(`li`,{"data-outcome":e.outcome,className:`rounded border px-2 py-1 ${Tn[e.outcome]}`,children:[l(`span`,{className:`font-medium`,children:e.nodeName}),l(`span`,{className:`mx-1 uppercase tracking-wide`,children:e.outcome}),l(`span`,{className:`opacity-80`,children:e.detail})]},e.nodeId))}),o?l(`div`,{className:`flex items-center justify-center flex-1 text-muted-foreground`,children:`Loading cluster topology...`}):r(`div`,{className:`flex-1 overflow-auto flex flex-col gap-3`,children:[l(De,{staleNodeId:s.staleNodeId,shownNodeName:f?.name??``}),l(hn,{nodes:i,selected:f,onSelect:u})]})]})}export{En as ClusterPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-Cyuzqnbw.js";import{I as t,K as n,Q as r,S as i,T as a,W as o,b as s,i as c,o as l,p as u,q as d,x as f,z as p}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{A as m,B as h,D as g,E as _,M as v,O as y,R as b,T as x,at as S,ct as C,gt as w,ht as T,k as E,st as D,ut as O,vt as k}from"./player-overlays-BddRivLE.js";import{Bd as A,Bl as j,Bn as M,Bs as N,C as P,Cd as F,Cn as I,Cs as L,Ct as R,Ds as ee,E as te,En as z,F as ne,Fs as re,Gl as B,Gs as ie,H as ae,Hl as oe,Hs as se,Is as ce,Js as V,Kl as le,Ks as ue,Lu as de,M as fe,Mn as pe,Ms as me,O as he,Ps as ge,Qn as _e,Rn as ve,Rs as ye,Rt as be,Ru as xe,S as Se,Sn as Ce,Ss as we,T as Te,Tn as Ee,Ud as De,Ul as Oe,Us as ke,V as Ae,Vl as je,Vn as H,Wl as Me,Ws as Ne,Xl as Pe,Zu as Fe,_n as Ie,_s as Le,ac as Re,an as ze,bs as Be,cc as Ve,cn as He,dn as Ue,en as We,eu as Ge,ff as Ke,fn as qe,gn as Je,gr as U,gs as Ye,gt as Xe,gu as Ze,hd as Qe,hn as $e,hr as et,ic as tt,in as nt,js as rt,kd as W,kt as it,ku as at,ln as ot,mn as st,nc as ct,nd as lt,oc as ut,od as dt,on as ft,or as G,pn as pt,qs as mt,r as ht,rc as gt,rd as _t,sn as vt,su as yt,tc as bt,td as xt,un as St,vd as Ct,vn as wt,vs as Tt,w as Et,ws as Dt,xn as Ot,xs as kt,yn as At,yr as jt,ys as Mt,zl as K,zn as Nt,zs as Pt}from"./src-DnQxdAYg.js";import{t as Ft}from"./layers-BYuVbzVs.js";import{t as It}from"./square-check-big-CpCHNAfP.js";import{n as Lt}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_trpc_mf_1_react_mf_2_query__loadShare__.js-DX7sYWrs.js";import{Cn as Rt,Dn as zt,En as Bt,Mr as Vt,Sn as Ht,Tn as Ut,f as Wt,jr as Gt,ni as Kt,ti as qt,wn as Jt,xn as Yt}from"./client-BVesZTvN.js";import{B as Xt,E as Zt,F as Qt,M as $t}from"./index-NHwA6Zmb.js";import"./useEventInvalidation-Br0xkUVQ.js";import{t as en}from"./NodeAddonsSettingsPanel-D7Ope1My.js";var tn=k(`circuit-board`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M11 9h4a2 2 0 0 0 2-2V3`,key:`1ve2rv`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`M7 21v-4a2 2 0 0 1 2-2h4`,key:`1fwkro`}],[`circle`,{cx:`15`,cy:`15`,r:`2`,key:`3i40o0`}]]),nn=k(`pin-off`,[[`path`,{d:`M12 17v5`,key:`bb1du9`}],[`path`,{d:`M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89`,key:`znwnzq`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11`,key:`c9qhm2`}]]),rn=k(`pin`,[[`path`,{d:`M12 17v5`,key:`bb1du9`}],[`path`,{d:`M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z`,key:`1nkz8b`}]]),an=k(`scale`,[[`path`,{d:`M12 3v18`,key:`108xh3`}],[`path`,{d:`m19 8 3 8a5 5 0 0 1-6 0zV7`,key:`zcdpyk`}],[`path`,{d:`M3 7h1a17 17 0 0 0 8-2 17 17 0 0 0 8 2h1`,key:`1yorad`}],[`path`,{d:`m5 8 3 8a5 5 0 0 1-6 0zV7`,key:`eua70x`}],[`path`,{d:`M7 21h10`,key:`1b0cd5`}]]),on=k(`usb`,[[`circle`,{cx:`10`,cy:`7`,r:`1`,key:`dypaad`}],[`circle`,{cx:`4`,cy:`20`,r:`1`,key:`22iqad`}],[`path`,{d:`M4.7 19.3 19 5`,key:`1enqfc`}],[`path`,{d:`m21 3-3 1 2 2Z`,key:`d3ov82`}],[`path`,{d:`M9.26 7.68 5 12l2 5`,key:`1esawj`}],[`path`,{d:`m10 14 5 2 3.5-3.5`,key:`v8oal5`}],[`path`,{d:`m18 12 1-1 1 1-1 1Z`,key:`1bh22v`}]]),sn=`step`,cn=[sn,`acc`];function ln(e,t){return`${e}/${t}`}function un(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:t[0]??null,staleStepId:n.step!==null&&n.step!==``&&!r&&e.length>0?n.step:null}}function dn(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 fn(e){return e}function pn(e,t){for(let[n,r]of Object.entries(e??{}))if(n===t)return r}function mn(e,t){return typeof e==`boolean`?e:fn(t)}function hn(e,t){return{pipeline:mn(pn(e,`detect`),t),audio:mn(pn(e,`audio`),t),ingest:mn(pn(e,`ingest`),t)}}function gn(e,t,n){let r=e?.find(e=>e.nodeId===t);return hn(r?.settings,n)}function _n({selectedNodeId:e,onSelect:t,refreshToken:n}){let{nodes:r}=j(),{data:a}=ge(void 0),{data:o}=ye(void 0),c=new Map;for(let e of a??[])c.set(e.agentNodeId,(c.get(e.agentNodeId)??0)+1);let l=r??[],u=l.filter(e=>e.isOnline).length,d=l.filter(e=>!e.isOnline).length;return i(`div`,{className:`flex flex-col h-full`,children:[i(`button`,{type:`button`,onClick:()=>t(no),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(Xt,{className:`h-4 w-4 flex-shrink-0`}),i(`div`,{className:`min-w-0 flex-1`,children:[f(`div`,{className:`text-xs font-semibold truncate`,children:`Cluster`}),f(`div`,{className:`text-[10px] text-foreground-subtle`,children:`Assignments, load balancing, roles`})]})]}),f(`div`,{className:`flex-1 overflow-y-auto`,children:l.map(n=>{let r=e===n.id,a=c.get(n.id)??0,l=n.isHub?at:W,u=gn(o,n.id,n.isHub),d=n.isOnline?null:Xe(dn(n.lastSeen));return i(`button`,{type:`button`,onClick:()=>t(n.id),className:`flex items-center gap-3 w-full px-4 py-3 border-b border-border text-left transition-colors ${r?`bg-primary/10 text-primary`:`text-foreground hover:bg-surface-hover`}${n.isOnline?``:` opacity-60`}`,children:[f(l,{className:`h-4 w-4 flex-shrink-0`}),i(`div`,{className:`min-w-0 flex-1`,children:[i(`div`,{className:`flex items-center gap-2`,children:[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:`hub`}),!n.isOnline&&f(`span`,{className:`h-1.5 w-1.5 rounded-full bg-destructive flex-shrink-0`}),n.isOnline&&f(`span`,{className:`h-1.5 w-1.5 rounded-full bg-success flex-shrink-0`})]}),i(`div`,{className:`text-[10px] text-foreground-subtle flex items-center gap-2 mt-0.5`,children:[i(`span`,{children:[n.cpuCores,` cores`]}),f(`span`,{children:`•`}),i(`span`,{children:[Math.round(n.memoryMB/1024),` GB`]}),a>0&&i(s,{children:[f(`span`,{children:`•`}),i(`span`,{className:`inline-flex items-center gap-0.5 text-foreground`,children:[f(Ge,{className:`h-2.5 w-2.5`}),a]})]}),!n.isOnline&&i(s,{children:[f(`span`,{children:`•`}),i(`span`,{className:`text-destructive`,children:[`offline`,d===null?``:` · ${d}`]})]})]}),i(`div`,{className:`mt-0.5 flex items-center gap-1`,children:[f(G,{variant:u.pipeline?`success`:`danger`,className:`px-1 py-0 text-[9px] leading-3`,title:u.pipeline?`Pipeline: enabled`:`Pipeline: not enabled (agent capability)`,children:`Pipe`}),f(G,{variant:u.audio?`success`:`danger`,className:`px-1 py-0 text-[9px] leading-3`,title:u.audio?`Audio: enabled`:`Audio: not enabled (agent capability)`,children:`Aud`})]})]})]},n.id)})}),i(`div`,{className:`px-4 py-2 border-t border-border text-[10px] text-foreground-subtle flex items-center justify-between`,children:[i(`span`,{children:[u,` online`]}),d>0&&i(`span`,{className:`text-destructive`,children:[d,` offline`]})]})]})}function vn({nodeId:e,refreshToken:t}){let{nodes:n}=j(),r=n?.find(t=>t.id===e),a=je(`pipeline.runner-load-snapshot`,t=>t.nodeId===e)?.load??null;return r?i(`div`,{className:`px-6 py-4 border-b border-border`,children:[i(`div`,{className:`flex items-center gap-2 mb-1`,children:[f(`h2`,{className:`text-base font-semibold text-foreground`,children:r.name}),r.isOnline?f(`span`,{className:`text-[10px] px-2 py-0.5 rounded-full bg-success/10 text-success`,children:`online`}):f(`span`,{className:`text-[10px] px-2 py-0.5 rounded-full bg-destructive/10 text-destructive`,children:`offline`}),r.isHub&&f(`span`,{className:`text-[9px] uppercase tracking-wider text-foreground-subtle border border-border rounded px-1 py-0.5`,children:`hub`})]}),i(`div`,{className:`text-[11px] text-foreground-subtle flex items-center gap-2 flex-wrap`,children:[f(`span`,{children:r.cpuModel??`CPU`}),f(`span`,{children:`•`}),i(`span`,{children:[r.cpuCores,` cores`]}),f(`span`,{children:`•`}),i(`span`,{children:[Math.round(r.memoryMB/1024),` GB`]}),a&&i(s,{children:[f(`span`,{children:`•`}),i(`span`,{children:[a.attachedCameras,` cameras (`,a.activeCameras,` active)`]}),f(`span`,{children:`•`}),i(`span`,{children:[a.avgInferenceTimeMs.toFixed(0),`ms avg inference`]}),f(`span`,{children:`•`}),i(`span`,{children:[`queue `,a.queueDepthTotal]}),a.hardware.hasGpu&&i(s,{children:[f(`span`,{children:`•`}),f(`span`,{className:`text-success`,children:`GPU`})]})]})]})]}):f(`div`,{className:`px-6 py-4 border-b border-border`,children:i(`div`,{className:`text-xs text-foreground-subtle`,children:[`Node not found: `,e]})})}var yn=[`assignments`,`tree`,`engines`,`logs`];r();function bn({refreshToken:e,nodeId:t}){let[n,r]=d(new Map),{nodes:a}=K();Oe(`pipeline.camera-metrics-snapshot`,e=>{let t=e.data;typeof t?.deviceId==`number`&&r(e=>{let n=new Map(e);return n.set(t.deviceId,t),n})});let{data:s}=Dt(void 0),c=o(()=>{let e=new Map;for(let t of s??[])e.set(t.nodeId,t.deviceCount);return e},[s]),l=o(()=>{let e=new Map,t=Date.now()-3e4;for(let r of n.values()){if(r.timestamp<t)continue;let n=r.nodeId??`hub`,i=e.get(n)??{attachedCameras:0,activeCameras:0,totalFps:0,totalInferenceWeighted:0,queueDepth:0};i.attachedCameras++,r.metrics.phase===`active`&&i.activeCameras++,i.totalFps+=r.metrics.actualFps,i.totalInferenceWeighted+=r.metrics.avgInferenceTimeMs,i.queueDepth+=r.metrics.queueDepth,e.set(n,i)}return e},[n]),u=o(()=>{let e=new Map;for(let t of a)e.set(t.id,t.shortName);return e},[a]),p=o(()=>{let e=0,t=0,n=0,r=0,i=0;for(let a of l.values())e+=a.attachedCameras,t+=a.activeCameras,n+=a.totalFps,r+=a.totalInferenceWeighted,i+=a.queueDepth;let o=e>0?r/e:0;return{totalAgents:a.length,onlineAgents:a.filter(e=>e.isOnline).length,attachedCameras:e,activeCameras:t,avgInferenceTimeMs:o,queueDepth:i,totalFps:n}},[l,a]);if(t){let e=l.get(t);return i(`div`,{className:`@container/liveload`,children:[f(`h3`,{className:`text-sm font-semibold text-foreground mb-2`,children:`Live load`}),i(`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:`Active / Attached`,value:e?`${e.activeCameras}/${e.attachedCameras}`:`—`}),f(q,{label:`Avg infer ms`,value:e&&e.attachedCameras>0?(e.totalInferenceWeighted/e.attachedCameras).toFixed(0):`—`}),f(q,{label:`Queue`,value:e?String(e.queueDepth):`—`}),f(q,{label:`Audio`,value:String(c.get(t)??`—`)})]})]})}let m=[...l.entries()].toSorted(([e],[t])=>e===`hub`?-1:t===`hub`?1:e.localeCompare(t));return i(`div`,{className:`@container/liveload`,children:[f(`h3`,{className:`text-sm font-semibold text-foreground mb-2`,children:`Live load`}),i(`div`,{className:`grid grid-cols-2 @md/liveload:grid-cols-3 @3xl/liveload:grid-cols-5 gap-2 sm:gap-3 mb-3`,children:[f(q,{label:`Total agents`,value:`${p.onlineAgents}/${p.totalAgents}`}),f(q,{label:`Active / Attached`,value:`${p.activeCameras}/${p.attachedCameras}`}),f(q,{label:`Total FPS`,value:p.totalFps.toFixed(1)}),f(q,{label:`Avg inference ms`,value:p.avgInferenceTimeMs.toFixed(0)}),f(q,{label:`Queue depth`,value:String(p.queueDepth)})]}),f(`div`,{className:`rounded-lg border border-border overflow-x-auto`,children:i(`table`,{className:`w-full text-xs min-w-[480px]`,children:[f(`thead`,{className:`bg-surface`,children:i(`tr`,{className:`text-foreground-subtle text-[10px] uppercase tracking-wider`,children:[f(`th`,{className:`text-left px-3 py-2`,children:`Agent`}),f(`th`,{className:`text-right px-3 py-2`,children:`FPS`}),f(`th`,{className:`text-right px-3 py-2`,children:`Cameras`}),f(`th`,{className:`text-right px-3 py-2`,children:`Inference ms`}),f(`th`,{className:`text-right px-3 py-2`,children:`Queue`}),f(`th`,{className:`text-right px-3 py-2`,children:`Audio`})]})}),i(`tbody`,{children:[m.map(([e,t])=>i(`tr`,{className:`border-t border-border`,children:[f(`td`,{className:`px-3 py-2 text-foreground font-medium`,children:u.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:c.get(e)??`—`})]},e)),m.length===0&&f(`tr`,{children:f(`td`,{colSpan:6,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:`No camera metrics received yet`})})]})]})})]})}function q({label:e,value:t}){return i(`div`,{className:`rounded-lg border border-border bg-surface/60 p-3`,children:[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})]})}function xn(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 Sn(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 Cn(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}r();function wn(e,t,n){return Math.min(Math.max(e,t),n)}function Tn(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 En(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:wn(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 Dn(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 On({nodes:e,pending:t,onCommitWeights:n,weightLabel:r=`Detection weight`,emptyHint:a,footnote:o,readOnly:c=!1}){let[l,u]=d(()=>Tn(e)),[m,h]=d(new Set);p(()=>{u(Tn(e)),h(t=>new Set([...t].filter(t=>e.some(e=>e.id===t))))},[e.map(e=>`${e.id}:${e.weight}`).join(`|`)]);let g=e.map(e=>e.id),_=e=>{h(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},v=(e,t)=>{u(n=>En(n,e,t,m,g))},y=()=>{let t=Dn(l,g,m),r=e.filter(e=>(t[e.id]??0)!==e.weight).map(e=>e.id);if(r.length===0)return;let i=new Set([...r,...m]);n(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:a??`No detect-enabled nodes. Enable “Detect” on a node above to distribute detection weight.`});let b=e.length===1;return i(`div`,{className:`space-y-3`,children:[e.map(e=>{let n=l[e.id]??0,a=m.has(e.id);return i(`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":`${r} for ${e.name}`,type:`range`,min:0,max:100,step:1,value:Math.round(n),disabled:c||t||a||b,onChange:t=>v(e.id,Number(t.target.value)),onPointerUp:()=>y(),onKeyUp:()=>y(),className:`h-1.5 flex-1 cursor-pointer accent-primary disabled:cursor-not-allowed disabled:opacity-50`}),i(`span`,{className:`w-10 shrink-0 text-right font-mono text-xs tabular-nums text-foreground`,children:[Math.round(n),`%`]}),!c&&f(`button`,{type:`button`,onClick:()=>_(e.id),disabled:t||b,"aria-pressed":a,title:a?`Unlock — allow rebalancing`:`Lock this share when others change`,className:`shrink-0 rounded p-1 hover:bg-surface-hover disabled:opacity-40 ${a?`text-amber-400`:`text-foreground-subtle`}`,children:f(a?xt:lt,{className:`h-3.5 w-3.5`})})]},e.id)}),f(`p`,{className:`text-[10px] leading-tight text-foreground-subtle`,children:o??f(s,{children:`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.`})})]})}r();function kn(e){let t=Ee(e),n=e.backend.toLowerCase(),r=e.device.toLowerCase();return e.key===`cpu`||r===`cpu`?{label:t,Icon:W,hue:`slate`}:r===`npu`?{label:t,Icon:B,hue:`sky`}:r===`gpu`||r===`igpu`?{label:t,Icon:tn,hue:`violet`}:n===`edgetpu`?{label:t,Icon:on,hue:`emerald`}:{label:t,Icon:W,hue:`slate`}}var An={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 jn({nodeId:e,nodeName:t,isOnline:n,suggestedMaxSessions:r,autoDeviceShares:a}){let c=l(),{data:u,isLoading:m}=me({nodeId:e},{refetchInterval:15e3}),h=ue({onSettled:()=>{c.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getNodeInferenceDevices`]]})}}),g=u?.devices??[],_=u?.reachable??n,[v,y]=d({});p(()=>{y(Object.fromEntries(g.map(e=>[e.key,{enabled:e.enabled,weight:e.weight,maxSessions:e.maxSessions,steps:e.steps??{}}])))},[g.map(e=>`${e.key}:${e.enabled}:${e.weight}:${e.maxSessions}:${JSON.stringify(e.steps??{})}`).join(`|`)]);let b=o(()=>g.filter(e=>v[e.key]?.enabled??e.enabled).length,[g,v]),[x,S]=d(null),C=x??b>0,w=t=>{let n=g.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}});h.mutate({agentNodeId:e,inferenceDevices:Cn(n)})},E=e=>({enabled:e.enabled,weight:e.weight,maxSessions:e.maxSessions,steps:e.steps??{}}),D=e=>{if(!e.available)return;let t=v[e.key]??E(e),n={...v,[e.key]:{...t,enabled:!t.enabled}};y(n),w(n)},O=(e,t)=>{let n=v[e.key]??E(e),r={...v,[e.key]:{...n,maxSessions:t}};y(r),w(r)},k=o(()=>g.filter(e=>(v[e.key]?.enabled??e.enabled)&&e.available),[g,v]),A=o(()=>k.map(e=>({id:e.key,name:kn(e).label,weight:a===void 0?v[e.key]?.weight??e.weight:Math.round(a[e.key]??0)})),[k,v,a]);return i(`div`,{className:`rounded-lg border border-border bg-surface/60`,children:[i(`button`,{type:`button`,onClick:()=>S(!C),className:`flex w-full items-center gap-2.5 px-3.5 py-2.5 text-left`,"aria-expanded":C,children:[f(T,{className:`h-4 w-4 shrink-0 text-foreground-subtle transition-transform ${C?`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:_?b>=2?i(`span`,{className:`inline-flex items-center gap-1 text-emerald-400`,children:[f(Ft,{className:`h-3.5 w-3.5`}),b,` accelerators`]}):b===1?f(`span`,{className:`text-foreground-subtle`,children:`single default`}):f(`span`,{className:`text-foreground-subtle/70`,children:`auto default`}):i(`span`,{className:`inline-flex items-center gap-1 text-foreground-subtle`,children:[f(Pe,{className:`h-3.5 w-3.5`}),` unreachable`]})})]}),C&&i(`div`,{className:`space-y-3 border-t border-border px-3.5 py-3`,children:[_?m&&g.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:`Probing accelerators…`}):g.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:`No inference devices reported by this node's platform probe.`}):f(`ul`,{className:`space-y-2`,children:g.map(e=>{let t=kn(e),n=v[e.key]??E(e),a=n.enabled&&e.available;return i(`li`,{className:`flex items-center gap-3 rounded-lg border px-3 py-2.5 transition-colors ${e.available?a?`border-primary/40 bg-primary/[0.04] ring-1 ring-inset ring-primary/20`:`border-border bg-surface`:`border-border/60 bg-background opacity-55`}`,children:[f(`span`,{className:`grid h-9 w-9 shrink-0 place-items-center rounded-md ring-1 ring-inset ${An[t.hue]}`,children:f(t.Icon,{className:`h-4.5 w-4.5`})}),i(`div`,{className:`min-w-0 flex-1`,children:[i(`div`,{className:`flex items-center gap-2`,children:[f(`span`,{className:`truncate text-[13px] font-medium text-foreground`,children:t.label}),f(G,{variant:`default`,style:`outline`,className:`font-mono text-[9px]`,children:e.format}),!e.available&&f(G,{variant:`warning`,className:`text-[9px]`,children:`unavailable`})]}),i(`div`,{className:`mt-0.5 flex items-center gap-1.5 text-[10px] text-foreground-subtle`,children:[f(`span`,{className:`font-mono`,children:e.key}),!a&&i(s,{children:[f(`span`,{"aria-hidden":!0,children:`·`}),i(`span`,{children:[`default model`,` `,f(`span`,{className:`font-mono text-foreground/80`,children:e.defaultModelId})]})]})]})]}),a&&i(`label`,{className:`flex shrink-0 items-center gap-1 text-[10px] text-foreground-subtle`,children:[f(`span`,{className:`hidden @sm/clustertab:inline`,children:`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);O(e,r!=null&&r>0?r:null)},disabled:h.isPending,"aria-label":`Max concurrent sessions for ${t.label}`,className:`w-14 rounded border border-border bg-background px-1.5 py-1 text-right font-mono text-[11px] text-foreground focus:border-primary focus:outline-none`})]}),a&&f(Mn,{suggested:r?.[e.key]??null,current:n.maxSessions,pending:h.isPending,onApply:t=>O(e,t)}),f(Ue,{checked:a,onCheckedChange:()=>D(e),disabled:!e.available||h.isPending,"aria-label":`Enable ${t.label}`,className:e.available?``:`cursor-not-allowed opacity-50`})]},e.key)})}):f(Nn,{}),_&&k.length>=2&&i(`div`,{className:`space-y-3 rounded-lg border border-border bg-background/60 p-3.5`,children:[i(`h4`,{className:`flex items-center gap-1.5 text-xs font-semibold uppercase tracking-wide text-foreground-subtle`,children:[f(an,{className:`h-3.5 w-3.5`}),`Accelerator share`]}),f(On,{nodes:A,pending:h.isPending,onCommitWeights:e=>{let t={...v};for(let n of e){let e=t[n.nodeId];e&&(t[n.nodeId]={...e,weight:n.weight})}y(t),w(t)},weightLabel:`Accelerator share`,readOnly:a!==void 0,footnote:a===void 0?f(s,{children:`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:`Automatic: each accelerator's share follows its measured throughput at its model. Switch the node shares to manual to set them yourself.`})})]}),h.isError&&i(`div`,{className:`rounded-md border border-danger/30 bg-danger/5 px-3 py-2 text-[11px] text-danger`,children:[`Failed to save inference devices:`,` `,h.error instanceof Error?h.error.message:`unknown error`]})]})]})}function Mn({suggested:e,current:t,pending:n,onApply:r}){return e===null||e<1||e===t?null:i(H,{variant:`ghost`,size:`sm`,onClick:()=>r(e),disabled:n,title:`Advisory cap from the measured throughput at the suggested model, with the headroom kept free. Applying it writes this device's cap.`,children:[`use `,e]})}function Nn(){return i(`div`,{className:`flex flex-col items-center gap-2 rounded-lg border border-dashed border-border bg-background px-4 py-8 text-center`,children:[f(Pe,{className:`h-6 w-6 text-foreground-subtle/60`}),f(`p`,{className:`text-xs font-medium text-foreground`,children:`Node unreachable`}),f(`p`,{className:`max-w-sm text-[11px] text-foreground-subtle`,children:`The platform probe couldn't be reached, so its live accelerator set is unavailable. Settings resume once the node reconnects.`})]})}r();var Pn={active:!1,pinned:!1,nodeId:null,reason:``},Fn=[`pipeline.camera-assigned`,`pipeline.camera-unassigned`,`pipeline.camera-updated`,`agent.online`,`agent.offline`],In=3e5,Ln={pipeline:W,decoder:Ct,audio:O},Rn={pipeline:`Pipeline`,decoder:`Decoder`,audio:`Audio`};function zn({mode:e,nodeId:t,compact:n=!1}){if(e===`agent`&&!t)throw Error(`CameraAssignmentsTable: nodeId is required when mode === "agent"`);let r=l(),[c,u]=d(null),[m,h]=d(null),[g,_]=d(new Map);ht([`pipelineOrchestrator`,`getPipelineAssignments`],Fn),ht([`pipelineOrchestrator`,`getAudioAssignments`],Fn),ht([`pipelineOrchestrator`,`getCameraStatuses`],Fn);let{data:v}=ge(void 0),{data:y}=L(void 0),{data:b}=ee({},{enabled:e===`agent`}),{nodes:x}=K(),{data:S}=Zt();Oe(`pipeline.camera-metrics-snapshot`,e=>{let t=e.data;typeof t.deviceId==`number`&&_(e=>{let n=new Map(e);return n.set(t.deviceId,t),n})}),p(()=>{if(g.size===0)return;let e=setInterval(()=>{_(e=>{let t=Date.now()-1e4,n=!1,r=new Map(e);for(let[i,a]of e)a.timestamp<t&&(r.delete(i),n=!0);return n?r:e})},5e3);return()=>clearInterval(e)},[g.size]);let C=o(()=>{let e=new Map;for(let t of S??[])e.set(t.id,t.name);return e},[S]),E=o(()=>{if(e===`agent`){let e=[];for(let n of b??[]){let r=n.assignment,i=(e,n,r)=>({active:e!==null&&e===t,pinned:n,nodeId:e,reason:r??``}),a=i(r.detectionNodeId,r.pinned.detection,r.reasons.detection),o=i(r.decoderNodeId,r.pinned.decoder,r.reasons.decoder),s=i(r.audioNodeId,r.pinned.audio,r.reasons.audio);!a.active&&!o.active&&!s.active||e.push({deviceId:n.deviceId,deviceName:C.get(n.deviceId)??`Device ${n.deviceId}`,pipeline:a,decoder:o,audio:s})}return e.sort((e,t)=>e.deviceId-t.deviceId),e}let n=new Map,r=e=>{let t=n.get(e);if(t)return t;let r={deviceId:e,deviceName:C.get(e)??`Device ${e}`,pipeline:Pn,decoder:Pn,audio:Pn};return n.set(e,r),r};for(let i of v??[]){let a=r(i.deviceId);n.set(i.deviceId,{...a,pipeline:{active:!0,pinned:i.pinned,nodeId:i.agentNodeId,reason:i.reason??``},decoder:{active:e===`cluster`?!0:i.agentNodeId===t,pinned:!1,nodeId:i.agentNodeId,reason:`co-located`}})}for(let e of y??[]){let t=r(e.deviceId);n.set(e.deviceId,{...t,audio:{active:!0,pinned:e.pinned,nodeId:e.nodeId,reason:`capacity`}})}let i=[...n.values()];return i.sort((e,t)=>e.deviceId-t.deviceId),i},[v,y,b,C,e,t]),D=o(()=>(x??[]).filter(e=>e.isOnline).map(e=>({id:e.id,name:e.name})),[x]),O=()=>{r.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineAssignments`]]}),r.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getAudioAssignments`]]}),r.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCameraStatuses`]]})},k=kt({onSuccess:O}),A=ut({onSuccess:O}),j=Be({onSuccess:O}),M=Re({onSuccess:O}),N=(e,t,n)=>{t===`pipeline`?k.mutate({deviceId:e,agentNodeId:n}):j.mutate({deviceId:e,nodeId:n}),u(null)},P=(e,t)=>{t===`pipeline`?A.mutate({deviceId:e}):M.mutate({deviceId:e}),u(null)};return f(`div`,{className:`rounded-lg border border-border overflow-x-auto`,children:i(`table`,{className:`w-full text-xs min-w-[760px] table-fixed`,children:[f(`thead`,{className:`bg-surface`,children:i(`tr`,{className:`text-foreground-subtle text-[10px] uppercase tracking-wider`,children:[!n&&f(`th`,{className:`w-10`}),f(`th`,{className:`min-w-[200px] text-left px-3 py-2 align-middle`,children:`Camera`}),e===`cluster`?i(s,{children:[f(`th`,{className:`w-[168px] text-left px-3 py-2 align-middle`,children:`Auto | Pin`}),f(`th`,{className:`w-[188px] text-left px-3 py-2 align-middle`,children:`Resolved placement`})]}):i(s,{children:[f(`th`,{className:`w-[120px] text-left px-3 py-2 align-middle`,children:`Pipeline`}),f(`th`,{className:`w-[120px] text-left px-3 py-2 align-middle`,children:`Decoder`}),f(`th`,{className:`w-[120px] text-left px-3 py-2 align-middle`,children:`Audio`})]}),f(`th`,{className:`w-[132px] text-left px-3 py-2 align-middle`,children:`Status`})]})}),i(`tbody`,{children:[E.map(t=>{let r=g.get(t.deviceId),o=m===t.deviceId;return i(a.Fragment,{children:[i(`tr`,{className:`border-t border-border align-middle relative`,children:[!n&&f(`td`,{className:`px-2 py-2 align-middle`,children:f(`button`,{type:`button`,onClick:()=>h(o?null:t.deviceId),className:`p-1 rounded hover:bg-surface-hover text-foreground-subtle`,"aria-label":o?`Collapse broker details`:`Expand broker details`,children:f(o?w:T,{className:`h-3.5 w-3.5`})})}),i(`td`,{className:`px-3 py-2 align-middle min-w-0`,children:[f(`div`,{className:`text-foreground font-medium leading-tight line-clamp-2 break-words`,title:t.deviceName,children:t.deviceName}),i(`div`,{className:`text-[10px] text-foreground-subtle leading-tight`,children:[`#`,t.deviceId]})]}),e===`cluster`?i(s,{children:[f(`td`,{className:`px-3 py-2 align-middle`,children:f(Vn,{state:t.pipeline,onlineNodes:D,pending:k.isPending||A.isPending,onChange:e=>{e===`auto`?P(t.deviceId,`pipeline`):N(t.deviceId,`pipeline`,e)}})}),f(`td`,{className:`px-3 py-2 align-middle`,children:f(Un,{state:t.pipeline,deviceId:t.deviceId})})]}):i(s,{children:[f(Gn,{role:`pipeline`,state:t.pipeline,mode:e,deviceId:t.deviceId,onlineNodes:D,isMenuOpen:c?.deviceId===t.deviceId&&c.role===`pipeline`,onToggleMenu:()=>u(c?.deviceId===t.deviceId&&c.role===`pipeline`?null:{deviceId:t.deviceId,role:`pipeline`}),onCloseMenu:()=>u(null),onMove:e=>N(t.deviceId,`pipeline`,e),onUnpin:()=>P(t.deviceId,`pipeline`)}),f(Gn,{role:`decoder`,state:t.decoder,mode:e,deviceId:t.deviceId,onlineNodes:D,readOnly:!0,isMenuOpen:!1,onToggleMenu:()=>void 0,onCloseMenu:()=>void 0,onMove:()=>void 0,onUnpin:()=>void 0}),f(Gn,{role:`audio`,state:t.audio,mode:e,deviceId:t.deviceId,onlineNodes:D,isMenuOpen:c?.deviceId===t.deviceId&&c.role===`audio`,onToggleMenu:()=>u(c?.deviceId===t.deviceId&&c.role===`audio`?null:{deviceId:t.deviceId,role:`audio`}),onCloseMenu:()=>u(null),onMove:e=>N(t.deviceId,`audio`,e),onUnpin:()=>P(t.deviceId,`audio`)})]}),f(`td`,{className:`px-3 py-2 align-middle`,children:f(Yn,{snap:r})})]}),o&&!n&&i(`tr`,{className:`bg-surface/50`,children:[f(`td`,{}),i(`td`,{colSpan:e===`cluster`?4:5,className:`px-3 py-2 space-y-3`,children:[t.pipeline.nodeId&&f(Bn,{deviceId:t.deviceId,nodeId:t.pipeline.nodeId}),f(pe,{widgetId:`stream-broker/stream-broker-panel`,host:`device-tab`,deviceId:t.deviceId,instanceId:`pipeline-row/${t.deviceId}`,config:{variant:`compact`,title:`Stream brokers & clients`}})]})]})]},t.deviceId)}),E.length===0&&f(`tr`,{children:f(`td`,{colSpan:n?e===`cluster`?4:5:e===`cluster`?5:6,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:e===`agent`?`No cameras assigned to this node`:`No cameras currently assigned`})})]})]})})}function Bn({deviceId:e,nodeId:t}){let n=l(),{data:r}=me({nodeId:t}),{data:a}=re({deviceId:e}),o=ct({onSuccess:()=>{n.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineDevicePin`]]})}}),s=r?.devices??[],c=a?.deviceKey??`auto`,u=c!==`auto`&&!s.some(e=>e.key===c);return i(`label`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[f(`span`,{className:`shrink-0 font-medium text-foreground`,children:`Inference device`}),i(`select`,{value:c,disabled:o.isPending,"aria-label":`Inference device pin`,onChange:t=>o.mutate({deviceId:e,deviceKey:t.target.value}),className:`rounded-md border border-border bg-background px-2 py-1 text-xs text-foreground`,children:[f(`option`,{value:`auto`,children:`Auto (balanced)`}),u&&i(`option`,{value:c,children:[`Pin → `,c,` (not on this node)`]}),s.map(e=>i(`option`,{value:e.key,children:[`Pin → `,e.key,e.available?``:` (unavailable)`]},e.key))]}),o.isPending&&f(`span`,{className:`text-[10px] opacity-70`,children:`saving…`})]})}function Vn({state:e,onlineNodes:t,pending:n,onChange:r}){let a=e.pinned&&e.nodeId?e.nodeId:`auto`,o=[...new Set([...e.nodeId?[e.nodeId]:[],...t.map(e=>e.id)])];return i(`select`,{value:a,disabled:n,"aria-label":`Pipeline placement pin`,onChange:e=>r(e.target.value),className:`w-full min-w-0 rounded-md border border-border bg-background px-2 py-1 text-xs text-foreground`,children:[f(`option`,{value:`auto`,children:`Auto`}),o.map(e=>i(`option`,{value:e,children:[`Pin → `,t.find(t=>t.id===e)?.name??e]},e))]})}function Hn(e){let t=n(null);return e.nodeId!==null&&(t.current=e),t.current}function Un({state:e,deviceId:t}){let n=Hn(e),r=e.active&&e.nodeId!==null;if(n===null||n.nodeId===null)return f(`span`,{className:`text-[10px] text-foreground-subtle italic`,children:`— · no session yet`});let a=n.pinned?`pinned · manual`:`auto · ${n.reason||`capacity`}`;return i(`div`,{className:`flex flex-col leading-tight min-w-0`,children:[f(`span`,{className:`font-mono text-[11px] truncate ${r?`text-foreground`:`text-foreground-subtle`}`,title:n.pinned?n.nodeId:`${n.nodeId} — an unpinned camera is re-elected per on-motion session, so this can change between sessions`,children:n.nodeId}),f(`span`,{className:`truncate ${n.pinned?`text-amber-400 text-[10px]`:`text-foreground-subtle text-[10px]`}`,title:a,children:a}),f(`span`,{className:`truncate text-[10px] ${r?`text-emerald-400`:`text-foreground-subtle/70`}`,children:r?`● running here`:`○ idle · last session here`}),f(Wn,{deviceId:t,nodeId:n.nodeId})]})}function Wn({deviceId:e,nodeId:t}){let n=l(),{data:r}=re({deviceId:e},{refetchOnMount:`always`}),{data:a}=me({nodeId:t},{staleTime:In}),o=ct({onSuccess:()=>{n.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineDevicePin`]]})}});if(r===void 0||a===void 0)return f(`span`,{className:`mt-0.5 text-[10px] text-foreground-subtle italic`,children:`device: …`});let s=a.devices??[],c=s.filter(e=>e.enabled),u=r.deviceKey??`auto`,d=u!==`auto`&&!c.some(e=>e.key===u),p=s.find(e=>e.key===u);return i(`select`,{value:u,disabled:o.isPending,"aria-label":`Inference device pin`,onChange:t=>o.mutate({deviceId:e,deviceKey:t.target.value}),className:`mt-0.5 w-full min-w-0 rounded border border-border bg-background px-1 py-0.5 text-[10px] text-foreground disabled:opacity-50`,children:[f(`option`,{value:`auto`,children:`Auto (balanced)`}),d&&i(`option`,{value:u,children:[p?`${kn(p).label} (${u})`:u,` (not enabled)`]}),c.map(e=>i(`option`,{value:e.key,children:[kn(e).label,` · `,e.format]},e.key))]})}function Gn({role:e,state:t,mode:n,onlineNodes:r,readOnly:a=!1,isMenuOpen:o,onToggleMenu:s,onCloseMenu:c,onMove:l,onUnpin:u}){let d=Ln[e],p=r.filter(e=>e.id!==(t.nodeId??``)),m=!a&&(t.active||n===`cluster`)&&(p.length>0||t.pinned);return i(`td`,{className:`px-3 py-2 align-middle relative min-w-0`,children:[i(`div`,{className:`flex items-center gap-2 min-w-0`,children:[f(n===`agent`?Kn:qn,{state:t,Icon:d}),f(`div`,{className:`ml-auto shrink-0`,children:m&&f(`button`,{type:`button`,onClick:s,className:`p-1 rounded hover:bg-surface-hover`,"aria-label":`${Rn[e]} actions`,children:f(F,{className:`h-3 w-3 text-foreground-subtle`})})})]}),o&&m&&f(Xn,{title:Rn[e],targets:p,pinned:t.pinned,onMove:l,onUnpin:u,onClose:c})]})}function Kn({state:e,Icon:t}){return i(`div`,{className:`flex items-center gap-1.5`,children:[f(e.active?It:C,{className:`h-3.5 w-3.5 ${e.active?`text-success`:`text-foreground-subtle/50`}`}),f(t,{className:`h-3 w-3 ${e.active?`text-foreground-subtle`:`text-foreground-subtle/40`}`}),e.pinned&&f(rn,{className:`h-2.5 w-2.5 text-amber-400`})]})}function qn({state:e,Icon:t}){return!e.active||!e.nodeId?i(`div`,{className:`flex items-center gap-1.5 text-foreground-subtle/60`,children:[f(t,{className:`h-3 w-3`}),f(`span`,{className:`text-[10px] italic`,children:`—`})]}):i(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[f(t,{className:`h-3 w-3 text-foreground-subtle shrink-0`}),i(`div`,{className:`flex flex-col leading-tight min-w-0`,children:[f(`span`,{className:`font-mono text-[11px] text-foreground truncate`,children:e.nodeId}),f(`span`,{className:`flex items-center gap-1 text-[10px]`,children:e.pinned?i(`span`,{className:`inline-flex items-center gap-0.5 text-amber-400`,children:[f(rn,{className:`h-2.5 w-2.5`}),` manual`]}):i(`span`,{className:`text-foreground-subtle truncate`,children:[`auto · `,e.reason||`capacity`]})})]})]})}var Jn=`min-h-[3.25rem]`;function Yn({snap:e}){if(!e)return f(`div`,{className:`flex items-center ${Jn}`,children:f(`span`,{className:`text-[10px] text-foreground-subtle italic`,children:`—`})});let{phase:t,actualFps:n,avgInferenceTimeMs:r,queueDepth:a,configuredFps:o,droppedFrames:s}=e.metrics,c=it(t);return i(`div`,{className:`flex flex-col justify-center gap-0.5 font-mono text-[10px] tabular-nums leading-tight min-w-0 ${Jn}`,children:[i(`span`,{className:`inline-flex items-center gap-1 min-w-0 ${c.textColor}`,children:[f(ne,{phase:t,className:`h-2.5 w-2.5 shrink-0`}),f(`span`,{className:`font-semibold uppercase tracking-wider truncate`,children:c.label})]}),i(`span`,{className:`text-foreground-subtle whitespace-nowrap truncate`,children:[f(`span`,{className:`text-foreground`,children:n.toFixed(1)}),i(`span`,{children:[`/`,o.toFixed(0),` fps`]})]}),i(`span`,{className:`text-foreground-subtle whitespace-nowrap truncate`,children:[f(`span`,{className:`text-foreground`,children:r.toFixed(0)}),f(`span`,{children:` ms`}),a>0&&i(`span`,{className:`text-warning ml-1`,children:[`q`,a]})]}),i(`span`,{className:`whitespace-nowrap truncate ${s>0?`text-warning`:`text-foreground-subtle`}`,children:[`drops `,f(`span`,{className:`text-foreground`,children:s})]})]})}function Xn({title:e,targets:t,pinned:r,onMove:a,onUnpin:o,onClose:s}){let c=n(null);return p(()=>{let e=e=>{c.current?.contains(e.target)||s()};return window.addEventListener(`mousedown`,e),()=>window.removeEventListener(`mousedown`,e)},[s]),i(`div`,{ref:c,className:`absolute right-2 top-full mt-1 w-48 rounded-lg border border-border bg-surface shadow-lg z-20 text-left`,children:[f(`div`,{className:`px-3 py-1 text-[9px] uppercase tracking-wider text-foreground-subtle border-b border-border`,children:e}),t.length>0&&f(`div`,{className:`py-1`,children:t.map(e=>i(`button`,{type:`button`,onClick:()=>a(e.id),className:`block w-full text-left px-3 py-1 text-[11px] text-foreground hover:bg-surface-hover`,children:[`Move to `,e.name]},e.id))}),r&&i(`button`,{type:`button`,onClick:o,className:`block w-full text-left px-3 py-1.5 text-[11px] text-destructive hover:bg-destructive/10 border-t border-border`,children:[`Unpin `,e.toLowerCase()]}),t.length===0&&!r&&f(`div`,{className:`px-3 py-1.5 text-[10px] text-foreground-subtle italic`,children:`Already auto · no other nodes online`})]})}function Zn({nodeId:e,refreshToken:t}){return i(`div`,{className:`space-y-6`,children:[f(bn,{refreshToken:t,nodeId:e}),i(`div`,{children:[f(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Cameras on this node`}),i(`p`,{className:`text-[11px] text-foreground-subtle`,children:[`Checkboxes mark the roles currently running on `,e,`. Use the kebab to move a role to another node or unpin it; live KPIs come from the runner snapshot stream.`]})]}),f(zn,{mode:`agent`,nodeId:e,compact:!0})]})}r();function Qn(e,t){let n=Math.max(0,t-e);return`${Math.floor(e/1e3)}s idle · ${Math.floor(n/1e3)}s left`}function $n({nodeId:e,refreshToken:t}){let n=l(),r=_e(),a=Le({onSettled:()=>{n.invalidateQueries({queryKey:[`pipelineExecutor`,`listLoadedEngines`]})}}),{data:s}=Tt({nodeId:e}),c=je(`pipeline.engine-metrics-snapshot`,t=>t.nodeId===e)?.engines??s??null,u=c===null;ht([`pipelineRunner`,`getLocalCameras`],[`pipeline.camera-assigned`,`pipeline.camera-unassigned`]);let{data:d}=Ve({nodeId:e}),{values:p}=oe(`pipeline.camera-metrics-snapshot`,e=>e.deviceId,t=>t.nodeId===e),m=o(()=>p.filter(e=>e.metrics.phase===`active`).length,[p]),h=t=>{let n=d??[];if(n.length===0){a.mutate({nodeId:e,engine:t,force:!1});return}(async()=>{await r({title:`Kill engine`,message:`${String(n.length)} camera(s) are dispatching through this engine. Killing it drops their in-flight work and forces a respawn on the next frame.`,confirmLabel:`Kill engine`,variant:`danger`})&&a.mutate({nodeId:e,engine:t,force:!0})})()};return i(`div`,{className:`space-y-6`,children:[i(`div`,{children:[f(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Inference engines on this node`}),i(`p`,{className:`text-[11px] text-foreground-subtle`,children:[(c??[]).length,` engine(s) resident in RAM. `,(d??[]).length,` `,`camera(s) attached, `,m,` actively dispatching frames. Refreshes every 5s.`]})]}),f(`div`,{className:`rounded-lg border border-border overflow-x-auto`,children:i(`table`,{className:`w-full text-xs min-w-[640px]`,children:[f(`thead`,{className:`bg-surface`,children:i(`tr`,{className:`text-foreground-subtle text-[10px] uppercase tracking-wider`,children:[f(`th`,{className:`text-left px-3 py-2 whitespace-nowrap`,children:`Kind`}),f(`th`,{className:`text-left px-3 py-2 whitespace-nowrap`,children:`Runtime / Backend / Device`}),f(`th`,{className:`text-left px-3 py-2`,children:`Models`}),f(`th`,{className:`text-right px-3 py-2 whitespace-nowrap`,children:`Pool PID`}),f(`th`,{className:`text-right px-3 py-2 whitespace-nowrap`,children:`Auto-kill`}),f(`th`,{className:`text-right px-3 py-2 whitespace-nowrap`,children:`In use`}),f(`th`,{className:`w-20`})]})}),i(`tbody`,{children:[u&&f(`tr`,{children:f(`td`,{colSpan:7,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:`Loading…`})}),!u&&(c??[]).map(e=>{let t=e.kind===`device-pool`;return i(`tr`,{className:`border-t border-border ${t?`bg-primary/[0.05]`:``}`,children:[f(`td`,{className:`px-3 py-2`,children:i(`span`,{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded-full text-[10px] font-medium ${t?`bg-primary/15 text-primary`:`bg-success/15 text-success`}`,children:[f(t?Ft:W,{className:`h-3 w-3`}),t?`pool`:`runtime`]})}),f(`td`,{className:`px-3 py-2`,children:i(`span`,{className:`inline-flex items-center gap-1 text-[11px] text-sky-400`,children:[f(B,{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:Qn(e.idleMs,e.idleTtlMs)}):f(`span`,{className:`text-foreground-subtle/50`,children:`never`})}),f(`td`,{className:`px-3 py-2 text-right text-foreground`,children:(d??[]).length}),f(`td`,{className:`px-3 py-2 text-right`,children:t?f(`span`,{className:`text-[11px] text-foreground-subtle`,children:`auto`}):i(`button`,{type:`button`,disabled:a.isPending,onClick:()=>h(e.engine),className:`inline-flex items-center gap-1 px-2 py-1 rounded border border-destructive/30 text-destructive text-[11px] hover:bg-destructive/10 disabled:opacity-50`,children:[f(D,{className:`h-3 w-3`}),`Kill`]})})]},e.engineKey)}),!u&&(c??[]).length===0&&f(`tr`,{children:f(`td`,{colSpan:7,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:`No engines resident — the factory spins up on the first pipeline run.`})})]})]})}),i(`div`,{className:`text-[10px] text-foreground-subtle leading-relaxed`,children:[f(`strong`,{className:`text-foreground`,children:`runtime`}),`: main camera-serving engine; never auto-killed while cameras attached. `,f(`strong`,{className:`text-foreground`,children:`warm`}),`: benchmark/test override held in cache for fast re-use; auto-disposed after the idle TTL.`,` `,f(`strong`,{className:`text-foreground`,children:`pool`}),`: a per-device balanced inference pool (one per enabled accelerator, running concurrently); reaper-managed on its own idle TTL.`]}),a.isError&&i(`div`,{className:`rounded-md border border-destructive/30 bg-destructive/5 px-3 py-2 text-[11px] text-destructive`,children:[`Kill failed:`,` `,a.error instanceof Error?a.error.message:`unknown`]})]})}var er=`pipeline-runner`,tr=200;function nr({nodeId:e}){return i(`div`,{className:`flex flex-col gap-3`,children:[i(`div`,{children:[f(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Runner logs`}),i(`p`,{className:`text-[11px] text-foreground-subtle`,children:[`pipeline-runner activity on `,e,` — camera attach/detach, engine phases and pipeline errors. Streaming live; the device chip on a line tells which camera it refers to.`]})]}),f(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:f(R,{agentId:e,addonId:er,limit:tr,maxHeight:`max-h-[calc(100vh-360px)]`,showScope:!0,showDeviceChip:!0,showFilters:!1})})]})}r();function rr({nodeId:e,title:t}){let{data:n}=Zt(),{data:r}=ge(void 0),a=o(()=>{let e=new Map;for(let t of n??[])e.set(t.id,t.name);return e},[n]),s=o(()=>{if(!e)return null;let t=new Set;for(let n of r??[])n.agentNodeId===e&&t.add(n.deviceId);return t},[e,r]),[c,l]=d(new Map);Oe(`pipeline.camera-metrics-snapshot`,t=>{let n=t.data;typeof n.deviceId==`number`&&(e&&n.nodeId!==e||l(e=>{let t=new Map(e);return t.set(n.deviceId,n),t}))}),p(()=>{if(c.size===0)return;let e=setInterval(()=>{l(e=>{let t=Date.now()-1e4,n=!1,r=new Map(e);for(let[i,a]of e)a.timestamp<t&&(r.delete(i),n=!0);return n?r:e})},5e3);return()=>clearInterval(e)},[c.size]);let u=o(()=>{let e=[];for(let t of c.values())s&&!s.has(t.deviceId)||e.push(t);return e.sort((e,t)=>e.deviceId-t.deviceId),e},[c,s]);return u.length===0?i(`div`,{className:`rounded-md border border-border bg-surface px-3 py-2 text-[11px] text-foreground-subtle italic`,children:[t??`Cameras`,`: no live snapshots yet`]}):i(`div`,{className:`rounded-md border border-border bg-surface px-3 py-2`,children:[i(`div`,{className:`flex items-center gap-2 mb-1.5`,children:[f(`span`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle`,children:t??`Cameras`}),f(`span`,{className:`text-[10px] text-foreground-subtle`,children:u.length})]}),f(`div`,{className:`flex flex-wrap gap-1.5`,children:u.map(e=>{let t=a.get(e.deviceId)??`#${e.deviceId}`,n=it(e.metrics.phase);return i(`div`,{title:`${t} · ${n.label} · ${e.metrics.actualFps.toFixed(1)} fps · ${e.metrics.avgInferenceTimeMs.toFixed(0)}ms infer · q=${e.metrics.queueDepth}`,className:`inline-flex items-center gap-1 rounded border px-1.5 py-0.5 text-[10px] ${n.badgeClass}`,children:[f(ne,{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:`fps`})]},e.deviceId)})})]})}var ir=`pipeline-orchestrator`;function ar({addonId:e,highlightLabel:t}){let n=Jt(e),{data:r}=U({addonId:ir});if(n.length===0)return null;let a=Bt(r??null)[e]??{};return i(`section`,{className:`space-y-1.5 border-t border-border/60 pt-3`,"aria-label":`Cluster-wide settings`,children:[i(`div`,{className:`flex flex-wrap items-center gap-2`,children:[f(`h3`,{className:h,children:`Cluster-wide settings`}),f($t,{to:co(),className:`ml-auto text-[11px] text-primary hover:underline`,children:`Edit in Cluster → Settings → Enrichment models ›`})]}),n.map(e=>i(`div`,{className:`${E} rounded px-2 ${t===e.label?`bg-primary/5 ring-1 ring-primary/40`:``}`,children:[f(`span`,{className:m,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:`One value for every node and camera — this step writes into a shared index.`})]})}r();function or(e,n){let[r,i]=Qt(),a=r.get(sn),s=r.get(`acc`),c=o(()=>un(e,n,{step:a,acc:s}),[e,n,a,s]),l=t(e=>{i(t=>{let n=new URLSearchParams(t);return e(n),n},{replace:!0})},[i]);return{selection:c,open:t(e=>l(t=>{t.set(sn,e.stepId),e.acceleratorId!==void 0&&t.set(`acc`,e.acceleratorId)}),[l]),selectAccelerator:t(e=>l(t=>t.set(`acc`,e)),[l]),close:t(()=>l(e=>e.delete(sn)),[l])}}function sr(e,t){for(let n of e?.slots??[])for(let e of n.addons)if(e.id===t)return e;return null}function cr(e){return e.split(`.`)[0]??e}function lr(e,t,n){return{id:ln(e,n.key),nodeId:e,deviceKey:n.key,device:n,label:`${cr(t)} · ${Ee(n)}`,shortLabel:`${cr(t)} · ${z(n)}`,nodeLabel:cr(t),disabled:!n.enabled}}function ur(e,t,n,r=!1){return n.filter(e=>r||e.enabled).map(n=>lr(e,t,n))}function dr(e,t,n=!1){return e.flatMap(e=>{let r=t[e.id]??[];if(n)return r.map(t=>lr(e.id,e.name,t));let i=r.filter(e=>e.enabled&&e.available);if(i.length>0)return i.map(t=>lr(e.id,e.name,t));let a=r.find(e=>e.available)??r[0];return a===void 0?[]:[lr(e.id,e.name,a)]})}function fr(e,t,n){return{modelId:Ot({catalog:e,device:t.device,base:n.nodePin,override:n.cameraPin}),source:n.cameraPin===void 0?n.nodePin===void 0?`default`:`node`:`camera`}}function pr(e,t,n){let r=sr(e,`object-detection`);if(r===null)return;let i=Ot({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 mr(e,t,n){return!Gt(e)||n===void 0?!1:Vt(e,t,n.supplies).effective}function hr(e,t){return e!==null&&Ce(e.models,t.device.format)}function gr(e){return hr(e.addon,e.acc)?e.clusterModelId===void 0?{kind:`enabled`,modelId:e.model.modelId??`Auto`,overridden:e.model.source===`camera`,...e.rootName===void 0?{}:{suppliedByRoot:e.rootName},...e.jumpTo===void 0?{}:{jumpTo:e.jumpTo}}:{kind:`enabled`,modelId:e.clusterModelId,clusterWide:!0}:e.gatedOn?e.jumpTo===void 0?{kind:`skip`}:{kind:`skip`,jumpTo:e.jumpTo}:{kind:`na`}}function _r(e){return Object.values(e).reduce((e,t)=>e+t.filter(e=>!e.enabled).length,0)}function vr(e){if(e===null)return[];let t=(e.configSchema??[]).flatMap(e=>`label`in e&&typeof e.label==`string`?[e.label]:[]),n=Jt(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 br(e,t){return e.flatMap(e=>{let n=br(e.children,t);return t.has(e.addonId)||n.length>0?[{...e,children:n}]:[]})}r();function xr(e){return{agentNodeId:e.nodeId,nodeLabel:e.nodeLabel,engineLabel:e.device.format,deviceKey:e.deviceKey,deviceLabel:Ee(e.device),detail:e.device.defaultModelId,disabled:e.disabled}}function Sr({tree:e,searchRows:r,accelerators:a,cellState:s,stepBadge:c,disabledCount:l,showDisabled:u,onShowDisabledChange:p,dirty:m,onDiscard:h,summary:g,toolbar:_,label:v,renderDetail:y}){let x=_e(),S=We(),{selection:C,open:w,selectAccelerator:T,close:E}=or(o(()=>yr(e).map(e=>e.node.addonId),[e]),o(()=>a.map(e=>e.id),[a])),[D,O]=d(``),[k,A]=d(null),[j,M]=d(null),N=n(null),F=n(null),I=n(null),L=n(null),R=o(()=>P(r,D),[r,D]),ee=o(()=>D.trim()===``?e:br(e,new Set(R.map(e=>e.addonId))),[e,R,D]),z=e=>R.find(t=>t.addonId===e)?.matchedField??null,ne=o(()=>a.map(xr),[a]),re=e=>a.find(t=>t.nodeId===e.agentNodeId&&t.deviceKey===e.deviceKey),B=a.find(e=>e.id===C.acceleratorId)??a[0],ie=C.stepId!==null,oe=t(async e=>{if(m){if(!await x({title:`Discard unsaved changes?`,message:`This step has changes that are not saved yet.`,confirmLabel:`Discard`,variant:`danger`}))return;h()}e()},[x,m,h]),se=()=>{requestAnimationFrame(()=>L.current?.focus())},ce=(e,t,n=!1)=>{if(e===C.stepId&&(t===void 0||t.id===C.acceleratorId)){n&&se();return}let r=()=>{A(z(e)),w({stepId:e,...t===void 0?{}:{acceleratorId:t.id}}),n&&se()};e===C.stepId?r():oe(r)},V=()=>{let e=C.stepId;oe(()=>{if(E(),e!==null){let t=B?ae({agentNodeId:B.nodeId,deviceKey:B.deviceKey}):null;requestAnimationFrame(()=>N.current?.focusCell(e,t))}})},ue=e=>{if(e.key===`Enter`){let t=R[0];if(t===void 0)return;e.preventDefault(),ce(t.addonId,void 0,!0)}else e.key===`Escape`&&O(``)},de=S?f(te,{onClick:V}):f(st,{icon:le,variant:`ghost`,size:`sm`,"aria-label":`Close`,onClick:V});return i(`div`,{ref:F,className:`space-y-2`,onKeyDown:e=>{let t=e.target instanceof HTMLElement&&e.target.dataset.r!==void 0;e.key===`/`&&t&&(e.preventDefault(),I.current?.focus()),e.key===`Escape`&&t&&ie&&(e.preventDefault(),V())},children:[i(`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:I,type:`search`,value:D,onChange:e=>O(e.target.value),onKeyDown:ue,placeholder:`Filter steps or settings /`,"aria-label":`Filter steps or settings`,className:`h-9 w-56 rounded-md border border-border bg-background px-2 text-xs text-foreground outline-none focus:border-primary focus:ring-1 focus:ring-primary/30 md:h-7`}),l>0&&i(`label`,{className:`inline-flex items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[f(qe,{checked:u,onChange:e=>p(e.target.checked)}),`Show disabled accelerators (`,l,`)`]}),_]}),C.staleStepId!==null&&i(`p`,{className:`rounded-md border border-warning/40 bg-warning/10 px-3 py-1.5 text-[11px] text-warning`,children:[`The link names a step this pipeline does not have (`,C.staleStepId,`).`]}),ee.length===0?i(`p`,{className:`${b} rounded-md border border-dashed border-border px-3 py-4 text-center`,children:[`No step matches “`,D,`”.`]}):f(Ae,{ref:N,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)=>ce(e,re(t),n),onStepClick:(e,t)=>ce(e,void 0,t),...c===void 0?{}:{stepBadge:c},selectedCell:ie&&C.stepId!==null&&B!==void 0?{addonId:C.stepId,agentNodeId:B.nodeId,deviceKey:B.deviceKey}:null,fallbackNodeId:j,onFallbackNodeChange:M,reserveRightPx:ie&&!S?432:0}),f(he,{open:ie,anchor:F,onClose:V,label:`Step settings`,children:C.stepId!==null&&y({stepId:C.stepId,acceleratorId:C.acceleratorId,matchedField:k,selectAccelerator:T,closeButton:de,onEscape:V,headingRef:e=>{L.current=e}})})]})}r();function Cr(e){p(()=>{if(e===null)return;let t=document.getElementById(e);t===null||typeof t.scrollIntoView!=`function`||t.scrollIntoView({block:`center`,behavior:`smooth`})},[e])}r();function wr(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 Tr(e,t){let n=t.settings===void 0?void 0:wr(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:xn(r,n,t.stepId)}function Er(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=>!Wt(n[e],t.settings?.[e])).length;return r+i+o}function Dr({nodeId:e,nodeName:t,toolbar:n}){let r=l(),a=me({nodeId:e},{refetchOnMount:`always`}),c=Ye({nodeId:e},{refetchOnMount:`always`}),u=Ut(U({addonId:`pipeline-orchestrator`}).data??null),p=a.data?.devices??[],m=c.data??null,[g,_]=d(null),[v,y]=d(null),[x,S]=d(null),C=ue({onSuccess:()=>{r.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getNodeInferenceDevices`]]})}}),w=o(()=>m?Se(m):[],[m]),T=o(()=>yr(w),[w]),[E,D]=d(!1),O=o(()=>ur(e,t,p,E),[e,t,p,E]),k=o(()=>ur(e,t,p),[e,t,p]),A=k.length>=2,j=(e,t)=>(t===void 0?void 0:Sn(p,t.deviceKey,e))??{},M=(e,t,n)=>{let r=n??t.device.steps?.[e?.id??``]?.jumpDeviceKey;if(r!==void 0&&r!==``)return k.find(e=>e.deviceKey===r);if(!hr(e,t))return k.filter(n=>n.id!==t.id&&hr(e,n)).toSorted((e,t)=>e.deviceKey.localeCompare(t.deviceKey))[0]},N=(e,t)=>{let n=sr(m,e),r=fo(e),i=pr(m,t),a=j(e,t),o=M(n,t);return gr({addon:n,acc:t,gatedOn:n?.enabledByDefault??!0,model:n?fr(n,t,{nodePin:t.device.steps?.[e]?.modelId}):{modelId:void 0,source:`default`},...mr(e,a,i)&&i?{rootName:i.name}:{},...r?{clusterModelId:u[e]??r.defaultModelId}:{},...o?{jumpTo:z(o.device)}:{}})},P=T.map(({node:e})=>({addonId:e.addonId,name:e.addonName,fieldLabels:vr(sr(m,e.addonId))}));if(a.isLoading||c.isLoading)return f(`div`,{className:`animate-pulse p-4 text-xs text-foreground-subtle`,children:`Loading pipeline…`});if(m===null)return f(`div`,{className:`p-4 text-xs text-foreground-subtle`,children:`Catalog unavailable.`});let F=i(`span`,{className:b,children:[`Accelerators:`,` `,f(`span`,{className:`text-foreground`,children:k.length>0?k.map(e=>z(e.device)).join(` · `):`none enabled`}),p.some(e=>!e.enabled)&&i(s,{children:[` `,`— off:`,` `,p.filter(e=>!e.enabled).map(z).join(`, `)]}),` `,`·`,` `,f($t,{to:lo(),className:`text-primary hover:underline`,children:`Cluster → Load balancing ›`})]});return f(Sr,{tree:w,searchRows:P,accelerators:O,cellState:N,disabledCount:p.filter(e=>!e.enabled).length,showDisabled:E,onShowDisabledChange:D,dirty:g!==null&&Er(p,g,j(g.stepId,O[0]))>0,onDiscard:()=>_(null),summary:F,...n===void 0?{}:{toolbar:n},label:`Detection steps`,renderDetail:({stepId:n,acceleratorId:r,matchedField:a,selectAccelerator:o,closeButton:c,onEscape:l,headingRef:u})=>{let d=sr(m,n);if(d===null)return f(`div`,{className:`p-4 text-xs text-foreground-subtle`,children:`No step selected.`});let w=g?.stepId===n?g:null,T=O.find(e=>e.id===r)??O[0],E=j(n,T),D=w?.settings??E,k=Er(p,w,E),N=e=>{S(null),_(t=>({...t?.stepId===n?t:{stepId:n,models:{},jumps:{}},...e}))},P=fo(n),F=Ie(d),L=T===void 0?void 0:pr(m,T),R=e=>{let t=w?.models[e.deviceKey];return t===void 0?e.device.steps?.[n]?.modelId:t??void 0},ee=T===void 0?void 0:fr(d,T,{nodePin:R(T)}).modelId,te=O.length>1&&O.some(e=>!Wt(j(n,e),E)),z=()=>{w!==null&&C.mutate({agentNodeId:e,inferenceDevices:Cn(Tr(p,w))},{onSuccess:()=>{_(null),S({kind:`saved`})},onError:e=>S({kind:`error`,error:e.message})})};return f(Te,{ref:u,title:d.name,subtitle:`${d.slot} · base for every camera that lands on ${t}`,leading:c,onEscape:l,headerExtra:A&&F.length>0&&P===null?i(`div`,{className:`flex flex-wrap items-center gap-2`,children:[f(`span`,{className:b,children:`Values as they run on`}),f(fe,{items:O.map(e=>({id:e.id,label:e.shortLabel})),selectedId:T?.id??null,onSelect:o})]}):void 0,saveBar:{dirtyCount:k,saving:C.isPending,status:x?.kind??null,...x?.error===void 0?{}:{error:x.error},onSave:z,onDiscard:()=>_(null)},children:i(`div`,{className:`space-y-3`,children:[i(`section`,{className:`space-y-2`,"aria-label":`Model`,children:[f(`h3`,{className:h,children:`Model`}),P!==null&&T!==void 0?f(po,{step:P,engineFormat:T.device.format,runnableModelIds:I(d.models??[],T.device.format).map(e=>e.id)}):O.length===0?i(`p`,{className:b,children:[`No accelerator is enabled on this node —`,` `,f($t,{to:lo(),className:`text-primary hover:underline`,children:`enable one in Cluster → Load balancing`}),`.`]}):f(Et,{rows:O.map(e=>{let t=w?.models[e.deviceKey],r=R(e),a=fr(d,e,{nodePin:r}),o=pr(m,e),c=mr(n,w?.settings??j(n,e),o),l=w?.jumps[e.deviceKey],u=M(d,e,l),p=hr(d,e)?c&&o?f($e,{rootModel:o,stepModelId:a.modelId}):void 0:i(s,{children:[`No `,e.device.format,` build of this step.`,` `,u?`It runs on ${u.shortLabel} instead.`:`It does not run here.`]}),h=A?i(`label`,{className:`block space-y-1`,children:[f(`span`,{className:`text-[11px] font-medium text-foreground`,children:`Run on`}),i(`select`,{className:`h-9 w-full rounded-md border border-border bg-surface px-2 text-xs md:h-8`,value:l??e.device.steps?.[n]?.jumpDeviceKey??``,onChange:t=>N({jumps:{...w?.jumps,[e.deviceKey]:t.target.value}}),children:[f(`option`,{value:``,children:`Auto (this accelerator, or the next one that can run it)`}),O.filter(t=>t.id!==e.id).map(e=>i(`option`,{value:e.deviceKey,children:[e.label,` · `,e.device.format]},e.id))]}),f(`span`,{className:b,children:`Routes this step (and its child steps) to another accelerator of this node.`})]}):void 0;return{id:e.id,label:e.label,format:e.device.format,modelId:a.modelId,source:a.source===`node`?`node`:`default`,sourceLabel:a.source===`node`?`node pin`:`hardware default`,models:I(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:{...w?.models,[e.deviceKey]:t}}),...r===void 0?{}:{onReset:()=>N({models:{...w?.models,[e.deviceKey]:null}}),resetLabel:`Reset to hardware default`},...p===void 0?{}:{note:p},...h===void 0?{}:{extra:h},changed:t!==void 0||l!==void 0}})},n)]}),(F.length>0||L!==void 0)&&P===null&&i(`section`,{"aria-label":`Settings`,className:`border-t border-border/60 pt-2`,children:[te&&f(`p`,{className:`mb-2 rounded-md border border-amber-500/40 bg-amber-500/10 px-2 py-1 text-[11px] text-amber-500`,children:`This step's settings differ between this node's accelerators. Saving makes the values shown here node-wide.`}),f(Or,{addon:d,fields:F,settings:D,modelId:Je(d,ee,D,L),root:L,highlight:a,onChange:e=>N({settings:e})})]}),f(ar,{addonId:n,highlightLabel:a})]})})}})}function Or({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 Cr(s===null?null:At(s)),f(wt,{addon:e,fields:t,layers:{node:n},target:`node`,labels:{node:`Node`},modelId:r,...i===void 0?{}:{rootModel:i},highlightKey:s,onChangeLayer:o})}r();function kr({nodeId:e,refreshToken:t}){let n=_e(),[r,a]=d(null),{nodes:o}=K(),c=o.find(t=>t.id===e)?.name??e,l=se({onSuccess:e=>{a(e.effectiveModelId===null?`Reset done — model config cleared (node offline: effective model resolves on reconnect)`:`Reset done — effective detection model: ${e.effectiveModelId} (Auto)`)}}),u=async()=>{await n({title:`Reset ${c} to hardware-aware defaults?`,message:`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:`Reset`,variant:`danger`})&&(a(null),l.mutate({agentNodeId:e}))};return i(`div`,{className:`space-y-2`,children:[f(rr,{nodeId:e}),f(Dr,{nodeId:e,nodeName:c,toolbar:i(s,{children:[r&&f(`span`,{className:`text-[11px] text-success`,children:r}),l.isError&&f(`span`,{className:`text-[11px] text-danger`,children:l.error instanceof Error?l.error.message:`Reset failed`}),f(H,{variant:`outline`,size:`sm`,onClick:()=>{u()},disabled:l.isPending,title:`Clear this node's per-device model defaults + per-camera overrides scoped to this node`,children:l.isPending?`Resetting…`:`Reset to default`})]})})]})}var Ar=[`detection-pipeline`,`audio-analyzer`,`pipeline-runner`],jr=`decoder-nodeav`,Mr=`ntab`;function Nr({nodeId:e,refreshToken:t}){let[n,r]=Qt(),{nodes:a}=K(),o=a.find(t=>t.id===e)?.addons.find(e=>e.capabilities.includes(`decoder`))?.addonId??jr,s=[...Ar,o],c={assignments:{id:`assignments`,label:`Assignments`,order:-10,content:f(Zn,{nodeId:e,refreshToken:t})},tree:{id:`tree`,label:`Pipeline`,order:39,content:f(kr,{nodeId:e,refreshToken:t})},engines:{id:`engines`,label:`Warm instances`,order:180,content:f($n,{nodeId:e,refreshToken:t})},logs:{id:`logs`,label:`Logs`,order:300,content:f(nr,{nodeId:e})}},l=yn.map(e=>c[e]);return i(`div`,{className:`flex flex-col h-full`,children:[f(vn,{nodeId:e,refreshToken:t}),f(`div`,{className:`flex-1 min-h-0 overflow-y-auto p-6`,children:f(en,{nodeId:e,addonIds:s,level:`global`,extraTabs:l,activeTab:n.get(Mr),onActiveTabChange:e=>r(t=>{let n=new URLSearchParams(t);n.set(Mr,e);for(let e of cn)n.delete(e);return n},{replace:!0})})})]})}function Pr(){return i(`div`,{className:`space-y-6`,children:[f(rr,{title:`Cluster cameras`}),i(`div`,{className:`min-w-0`,children:[f(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Placement matrix`}),f(`p`,{className:`text-[11px] text-foreground-subtle`,children:`Pipeline · audio assignments per camera (decode always runs co-located with the pipeline). Use the Auto | Pin control to pin a camera to a node, the inference-device select to pin it to an accelerator, or the kebab to move a role; expand the chevron for the per-camera broker drill-down. Load, shares, caps and Rebalance live on the Load balancing tab.`})]}),f(zn,{mode:`cluster`})]})}function Fr(e){return`${Math.round(e*100)}%`}function Ir(e){return`${e} session${e===1?``:`s`}`}var Lr={"intel-npu":`Intel NPU`,"intel-igpu":`Intel iGPU`,"x86-cpu":`CPU`,"arm-cpu":`CPU`,"apple-ane":`Apple Neural Engine`,coral:`Coral Edge TPU`},Rr={"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`,unknown:`Not measured`};function zr(e){return e===null?`—`:Lr[e]??e}function Br(e){return e===null?`—`:Rr[e]??e}function Vr(e){switch(e.kind){case`capacity`:return`Capacity ${Ir(e.sessions)} ≥ min ${e.minSessions}.`;case`tie-faster`:return`As accurate as ${e.over} (within ${Fr(e.recallDelta)} recall) and faster.`;case`stepped-down`:return`${e.from} would not fit the load on ${e.limitedBy}; ${e.to} is the most accurate that does.`;case`no-fit-lightest`:return`No model reaches ${Ir(e.minSessions)} per device; the one with the most capacity (${Ir(e.sessions)}) is used.`;case`derived-latency`:return`${e.modelId}: latency estimated from a similar chip, not measured on this one.`;case`cpu-device`:return`CPU fallback device: picked on its own.`;case`coral-untouched`:return`Coral: left as is (no YOLOv9 build exists for it).`;case`device-disabled`:return`Disabled: not changed.`;case`device-unavailable`:return`Not available on the node right now: not changed.`;case`node-offline`:return`Node offline: nothing on it will change.`;case`no-hardware-facts`:return`Hardware could not be read: nothing on this node will change.`;case`no-measured-data`:return`This hardware has no measured data: nothing on this node will change.`;case`no-family-build`:return`No YOLOv9 build for the ${e.format} format: not changed.`}}function Hr(e){switch(e.kind){case`detector-store-cluster-wide`:return`Per-camera detector thresholds are not tied to a node, so they are cleared for every camera — including cameras that run on skipped nodes (${e.skippedNodes.join(`, `)}).`;case`detector-store-unreadable`:return`Per-camera detector thresholds could not be read (${e.error}); those will not be cleared.`;case`coral-enabled`:return`${e.nodeId}: the Coral (${e.deviceKey}) is enabled and keeps running its SSD model, which finds far fewer people than YOLOv9. Consider disabling it.`}}function Ur(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 Wr(e){let t=Ur(e);return t.modelChanges+t.thresholdClears+t.cameraOverrideClears+t.detectorStoreClears===0}function Gr(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}}r();var Kr=[.3,.4,.5];function qr(e){return Kr.some(t=>t===e)}var Jr=[1,2,3,4,6,8];function Yr({plan:e,node:t}){return i(`section`,{className:g,"data-testid":`auto-tune-node-${t.nodeId}`,children:[i(`header`,{className:`${y} flex flex-wrap items-center gap-2`,children:[f(W,{className:`h-3.5 w-3.5 shrink-0 text-foreground-subtle`,"aria-hidden":!0}),f(`h3`,{className:`${h} min-w-0 flex-1`,children:t.nodeId}),i(`span`,{className:`text-[11px] text-foreground-subtle`,children:[Br(t.hardwareClass),t.cpuModel===null?``:` · ${t.cpuModel}`]}),t.skipped?f(G,{variant:`warning`,children:`Not changed`}):t.acceleratorModelId!==null&&f(G,{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:Vr(e)},t))}),f(`div`,{className:`overflow-x-auto`,children:i(`table`,{className:`w-full text-xs`,children:[f(`thead`,{children:i(`tr`,{className:`text-left text-[11px] text-foreground-subtle`,children:[f(`th`,{className:`px-3 py-1.5 font-medium`,children:`Device`}),f(`th`,{className:`px-3 py-1.5 font-medium`,children:`Capacity`}),f(`th`,{className:`px-3 py-1.5 font-medium`,children:`Detector`}),f(`th`,{className:`px-3 py-1.5 font-medium`,children:`Why`})]})}),f(`tbody`,{children:t.devices.map(n=>{let r=Gr(e,t.nodeId,n.deviceKey);return i(`tr`,{className:`border-t border-border align-top`,children:[i(`td`,{className:`px-3 py-1.5`,children:[f(`div`,{className:`font-mono text-foreground`,children:n.deviceKey}),f(`div`,{className:`text-[11px] text-foreground-subtle`,children:zr(n.accelerator)})]}),i(`td`,{className:`px-3 py-1.5 text-foreground-muted`,children:[n.chosen===null?`—`:`${n.chosen.capacitySessions} session${n.chosen.capacitySessions===1?``:`s`} at ${e.cameraFps} fps`,n.chosen!==null&&i(`div`,{className:`text-[11px] text-foreground-subtle`,children:[n.chosen.fps,` fps, `,Math.round(e.headroom*100),`% kept free`]})]}),f(`td`,{className:`px-3 py-1.5`,children:n.chosen===null?f(`span`,{className:`text-foreground-subtle`,children:`unchanged`}):r!==null&&r.before!==r.after?i(`span`,{children:[f(`span`,{className:`text-foreground-subtle`,children:r.before??`default`}),` → `,f(`span`,{className:`font-medium text-foreground`,children:r.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:Vr(e)},t))})]},n.deviceKey)})})]})})]})}function Xr({plan:e,nameOf:t}){return i(`div`,{className:`flex flex-col gap-3 text-xs`,"data-testid":`auto-tune-change-list`,children:[i(`div`,{children:[f(`div`,{className:h,children:`Node settings`}),e.nodeChanges.length===0?f(`div`,{className:`text-foreground-subtle`,children:`No change.`}):f(`ul`,{className:`mt-1 flex flex-col gap-0.5`,children:e.nodeChanges.flatMap(e=>[...e.modelPins.map(t=>i(`li`,{children:[i(`span`,{className:`font-mono`,children:[e.nodeId,` · `,e.deviceKey]}),` `,`— `,t.stepId,`: `,t.before??`default`,` → `,t.after??`step default`]},`${e.nodeId}/${e.deviceKey}/${t.stepId}/pin`)),...e.thresholds.map(t=>i(`li`,{children:[i(`span`,{className:`font-mono`,children:[e.nodeId,` · `,e.deviceKey]}),` `,`— `,t.stepId,`: reset `,t.keys.join(`, `),` to the model default`]},`${e.nodeId}/${e.deviceKey}/${t.stepId}/thr`))])})]}),i(`div`,{children:[f(`div`,{className:h,children:`Camera overrides cleared`}),e.cameraClears.length===0&&e.detectorStoreClears.length===0?f(`div`,{className:`text-foreground-subtle`,children:`None.`}):i(`ul`,{className:`mt-1 flex flex-col gap-0.5`,children:[e.cameraClears.map((e,n)=>i(`li`,{children:[t(e.deviceId),` — `,e.nodeId,e.deviceKey===null?` (whole pipeline)`:` · ${e.deviceKey}`,` — `,e.stepId,e.modelIdBefore===null?``:`: model ${e.modelIdBefore} removed`,e.keys.length>0?`; ${e.keys.join(`, `)} reset`:``]},`c${n}`)),e.detectorStoreClears.map(e=>i(`li`,{children:[t(e.deviceId),` — detector thresholds: `,e.keys.join(`, `),` reset`]},`d${e.deviceId}`))]})]})]})}function Zr({result:e}){return e.kind===`refused`?f(`div`,{className:`text-xs text-warning`,children:`Another apply is already running.`}):e.kind===`stale`?f(`div`,{className:`text-xs text-warning`,children:`The configuration changed since the plan was shown. Review the updated plan below and apply again.`}):i(`ul`,{className:`text-xs`,"data-testid":`auto-tune-result`,children:[e.kind===`aborted`&&f(`li`,{className:`text-danger`,children:`A model could not be downloaded: nothing was changed.`}),e.phases.map(e=>i(`li`,{className:e.ok?`text-foreground-muted`:`text-danger`,children:[e.ok?`✓`:`✗`,` `,e.phase,`: `,e.detail]},e.phase))]})}function Qr(){let e=l(),[t,n]=d(.4),[r,a]=d(2),[s,c]=d(!1),[u,p]=d(!1),[m,_]=d(null),{data:v}=Zt(),b=o(()=>new Map((v??[]).map(e=>[e.id,e.name])),[v]),x=e=>b.get(e)??`Device ${e}`,S=Pt({headroom:t,minSessionsPerDevice:r},{enabled:s,refetchOnWindowFocus:!1}),C=Mt({onSuccess:t=>{_(t),p(!1),e.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getNodeInferenceDevices`]]}),e.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCameraStepOverrides`]]}),e.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCameraSettings`]]}),t.kind===`applied`&&S.refetch()}}),w=m?.kind===`stale`?m.plan:S.data,T=w===void 0?null:Ur(w);return i(`div`,{className:`flex flex-col gap-3`,"data-testid":`cluster-auto-tune`,children:[i(`section`,{className:g,children:[i(`header`,{className:`${y} flex flex-wrap items-center gap-2`,children:[f(Ze,{className:`h-3.5 w-3.5 shrink-0 text-foreground-subtle`,"aria-hidden":!0}),f(`h3`,{className:`${h} min-w-0 flex-1`,children:`Auto tune`})]}),i(`div`,{className:`flex flex-col gap-2 px-3 py-2 text-xs text-foreground-muted`,children:[f(`p`,{children:`Picks, for every accelerator, the most accurate YOLOv9 detector that still carries at least the chosen number of cameras at once, from the node's hardware and measured speeds. Nothing is measured or estimated about your cameras' activity. Applying it sets those models and clears every model and threshold override — node level and per camera — so each model runs its own default thresholds. Enabled steps, devices, pins, recording, notifications, zones and rules are not touched. There is no undo.`}),i(`div`,{className:`flex flex-wrap items-center gap-2`,children:[i(`label`,{className:`flex items-center gap-1.5`,children:[f(`span`,{className:`whitespace-nowrap`,children:`Keep free`}),f(M,{"aria-label":`Share of each accelerator kept free`,value:String(t),options:Kr.map(e=>({value:String(e),label:`${Math.round(e*100)}% of each accelerator`})),onChange:e=>{let t=Number(e.target.value);qr(t)&&n(t)}})]}),i(`label`,{className:`flex items-center gap-1.5`,children:[f(`span`,{className:`whitespace-nowrap`,children:`At least`}),f(M,{"aria-label":`Minimum parallel sessions per device`,value:String(r),options:Jr.map(e=>({value:String(e),label:`${e} camera${e===1?``:`s`} at once per accelerator`})),onChange:e=>{let t=Number(e.target.value);Jr.some(e=>e===t)&&a(t)}})]}),f(H,{size:`sm`,variant:`secondary`,onClick:()=>{_(null),c(!0),s&&S.refetch()},children:S.isFetching?`Computing…`:w===void 0?`Compute plan`:`Recompute`}),w!==void 0&&f(H,{size:`sm`,disabled:Wr(w),onClick:()=>p(!0),children:`Apply…`})]}),S.error!==null&&f(`div`,{className:`text-danger`,children:S.error.message}),m!==null&&f(Zr,{result:m}),T!==null&&i(`div`,{className:`text-[11px] text-foreground-subtle`,children:[T.modelChanges,` model change(s), `,T.thresholdClears,` node threshold reset(s), `,T.cameraOverrideClears+T.detectorStoreClears,` camera override(s) on `,T.camerasTouched,` camera(s).`]})]})]}),w?.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:Hr(e)},t)),w?.nodes.map(e=>f(Yr,{plan:w,node:e},e.nodeId)),w!==void 0&&f(nt,{open:u,onOpenChange:p,children:i(ft,{width:`lg`,scroll:`body`,children:[i(ot,{children:[f(St,{children:`Apply auto tune?`}),f(vt,{children:`These are all the changes. Every override listed is removed and cannot be restored.`})]}),f(ze,{children:f(Xr,{plan:w,nameOf:x})}),i(He,{children:[f(H,{variant:`ghost`,onClick:()=>p(!1),children:`Cancel`}),f(H,{variant:`danger`,disabled:C.isPending,onClick:()=>C.mutate({planHash:w.planHash,headroom:t,minSessionsPerDevice:r}),children:C.isPending?`Applying…`:`Apply`})]})]})})]})}var $r={disabled:`switched off — not a dispatch target`,unavailable:`the node probe does not see it (unplugged or still provisioning)`,"cannot-host-camera-root":`its engine format has no object-detection root model`,"accelerator-preferred":`CPU fallback — it never competes while an accelerator is serving`};function ei(e,t){return t<=0?0:Math.round(e/t*1e3)/10}function ti(e,t){let n=e.filter(e=>e.exclusion===null).reduce((e,t)=>e+(t.weight>0?t.weight:1),0);return e.map(e=>{let r=t.get(e.key),i=r?.sessions??0,a=e.weight>0?e.weight:1;return{key:e.key,label:Ee(e),format:e.format,sessions:i,queueDepth:r?.queueDepth??0,weight:a,weightSharePct:e.exclusion===null?ei(a,n):null,maxSessions:e.maxSessions,atCap:e.maxSessions!==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 ni(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=ti(e.devicesByNode[r.id]??[],new Map((i?.load.devices??[]).map(e=>[e.deviceKey,{sessions:e.attachedCameras,queueDepth:e.queueDepthTotal}]))),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?ei(c,r.maxCameras):null,queueDepthTotal:i?.load.queueDepthTotal??null,avgInferenceTimeMs:i?.load.avgInferenceTimeMs??null,score:i?.score??null,weight:s,weightSharePct:o?ei(s,n):null,decodeHwaccel:i?.decodeHwaccel??null,devices:a,eligibleDeviceCount:a.filter(e=>e.exclusion===null).length}})}var ri=`pipeline-orchestrator`,ii=`recorder`,ai=`recordingNodeId`,oi=`pipeline-analytics`,si=`postProcessingNodeId`,ci=[`ingestNode`,`recordingNode`,`audioNode`,`motionNode`,`postProcessingNode`],li=[{key:`detect`,label:`Detect`,hint:`Runs the detection pipeline (decode + inference) for assigned cameras`}];function ui(e,t){for(let n of e?.sections??[])for(let e of n.fields??[])if(e.key===t)return e.value}function di(e,t){for(let[n,r]of Object.entries(e??{}))if(n===t)return r}function fi(e,t,n){let r=ui(e,t);return typeof r==`string`&&r.length>0?r:n}function pi(e,t){let n=di(e,t);return typeof n==`number`&&Number.isFinite(n)?n:null}function mi(e,t){let n=di(e,t);return typeof n==`string`&&n.length>0?n:null}function hi(e){return e===`ingestNode`?`Ingest`:e===`recordingNode`?`Recording`:e===`audioNode`?`Audio`:e===`postProcessingNode`?`Post-processing`:`Motion Node`}function gi(e){return e===`ingestNode`?`Node that terminates default camera ingest`:e===`recordingNode`?`Node that owns the recorder (recording-node)`:e===`audioNode`?`Node that runs singleton audio work`:e===`postProcessingNode`?`Runs detection post-processing (events, media, audio & motion)`:`Runs software (analyzer) motion-watch. Onboard cameras are unaffected.`}function _i(e,t){switch(t){case`detect`:return e.pipeline}}function vi(e){return e instanceof Error?e.message:`Failed to save`}function yi(e){e.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`listAgentSettings`]]}),e.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getAgentSettings`]]}),e.invalidateQueries({queryKey:[[`addonSettings`,`getGlobalSettings`]]})}r();var bi=2e4,xi=3e5;function Si({stats:e,targetWeights:t}){let{nodes:n}=K(),r=S().trpcClient,a=we(void 0,{placeholderData:u,staleTime:bi,refetchInterval:bi,refetchOnWindowFocus:!0}),s=ye(void 0,{staleTime:xi}),l=o(()=>n.map(e=>e.id),[n]),d=c({queries:l.map(e=>({queryKey:Lt(Me.pipelineOrchestrator.getNodeInferenceDevices,{nodeId:e},`query`),queryFn:()=>r.pipelineOrchestrator.getNodeInferenceDevices.query({nodeId:e}),staleTime:xi,refetchOnWindowFocus:!1,placeholderData:u}))}),p=o(()=>{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(`|`)]),m=o(()=>{let e=new Map;for(let t of s.data??[])e.set(t.nodeId,t.settings);return e},[s.data]),h=o(()=>n.map(e=>{let n=m.get(e.id);return{id:e.id,name:e.name,isOnline:e.isOnline,detectEnabled:hn(n,e.isHub).pipeline,weight:t?.[e.id]??pi(n,`detectWeight`)??1,maxCameras:pi(n,`maxCameras`)}}),[n,m,t]),g=a.data??[],v=o(()=>ni({nodes:h,loads:g,devicesByNode:p}),[h,g,p]),y=v.reduce((e,t)=>e+(t.attachedCameras??0),0),b=v.reduce((e,t)=>e+(t.activeCameras??0),0),x=a.dataUpdatedAt>0?Date.now()-a.dataUpdatedAt:null,C=new Map((e?.nodes??[]).map(e=>[e.nodeId,e]));return f(be,{headingId:`load-balancing-node-load`,title:`Node load`,icon:Ke,actions:i(`span`,{className:`text-[10px] text-foreground-subtle tabular-nums`,children:[b,` running · `,y,` attached ·`,` `,a.data===void 0?`reading…`:`${x===null?`—`:`${Math.round(x/1e3)}s`} old`]}),children:f(`div`,{className:_,children:v.length===0?f(`p`,{className:`text-[11px] italic text-foreground-subtle`,children:`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(Ci,{row:e,placed:C.get(e.nodeId)},e.nodeId))})})})}function Ci({row:e,placed:t}){let n=e.attachedCameras===null?`—`:`${e.activeCameras??0} / ${e.attachedCameras}${e.maxCameras===null?``:` of ${e.maxCameras}`}`;return i(`div`,{className:`rounded-lg border border-border bg-surface/60 p-2.5 min-w-0`,children:[i(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[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:`no detect`}),!e.reported&&e.isOnline&&i(`span`,{className:`ml-auto inline-flex shrink-0 items-center gap-1 text-[9px] text-amber-400`,title:`Online, but it did not answer the last load read — its numbers below are unknown, not zero.`,children:[f(yt,{className:`h-2.5 w-2.5`}),` no reading`]}),!e.isOnline&&i(`span`,{className:`ml-auto inline-flex shrink-0 items-center gap-1 text-[9px] text-foreground-subtle`,children:[f(Pe,{className:`h-2.5 w-2.5`}),` offline`]})]}),i(`dl`,{className:`mt-1.5 grid grid-cols-2 gap-x-2 gap-y-0.5 text-[10px]`,children:[f(J,{label:`Running / attached`,value:n,title:`Sessions in inference now / cameras attached to this runner (the balancer's committed load) / operator cap.`}),f(J,{label:`Target share`,value:e.weightSharePct===null?`out of play`:`${e.weightSharePct}%`,title:`The node share (automatic or manual) normalised over the nodes the balancer actually ranks (online AND detect-enabled).`}),f(J,{label:`Actual share (1 h)`,value:t?.observedShare===null||t===void 0?`—`:`${Math.round(t.observedShare*100)}%`,title:`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:`Peak · yields`,value:t===void 0?`—`:`${t.peakSessions} · ${t.yieldsAway}`,title:`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:`Score · queue`,value:e.score===null?`—`:`${e.score} · ${e.queueDepthTotal??0}`,title:`The capacity score balance() minimises (attached + queue depth), and the raw queue depth.`}),e.capacityPct!==null&&f(J,{label:`Cap fill`,value:`${e.capacityPct}%`,title:`attached / maxCameras.`}),e.avgInferenceTimeMs!==null&&f(J,{label:`Avg infer`,value:`${Math.round(e.avgInferenceTimeMs)} ms`,title:`Mean inference time across this node's attached cameras.`}),e.decodeHwaccel!==null&&f(J,{label:`Decode`,value:e.decodeHwaccel,title:`This node's probed decode hwaccel.`})]}),f(wi,{row:e})]})}function wi({row:e}){return e.devices.length===0?f(`p`,{className:`mt-2 text-[10px] italic text-foreground-subtle`,children:`Accelerators not read yet.`}):i(`div`,{className:`mt-2 border-t border-border pt-1.5`,children:[i(`div`,{className:`flex items-center gap-1 text-[9px] uppercase tracking-wider text-foreground-subtle`,children:[f(Qe,{className:`h-2.5 w-2.5`}),`Accelerators`,e.eligibleDeviceCount===0&&f(`span`,{className:`ml-1 normal-case tracking-normal text-amber-400`,title:`No device is a camera-root candidate on this node — sessions run on the runner's default (CPU) pool.`,children:`none in play · runner default pool`})]}),f(`ul`,{className:`mt-1 space-y-0.5`,children:e.devices.map(e=>f(Ti,{device:e},e.key))})]})}function Ti({device:e}){let t=e.exclusion;return i(`li`,{className:`flex items-baseline gap-1.5 text-[10px] min-w-0`,children:[f(W,{className:`h-2.5 w-2.5 shrink-0 ${t===null?`text-foreground-subtle`:`text-foreground-subtle/50`}`}),f(`span`,{className:`shrink-0 font-medium ${t===null?`text-foreground`:`text-foreground-subtle`}`,title:`${e.key} · ${e.format}`,children:e.label}),t===null?i(s,{children:[i(`span`,{className:`shrink-0 tabular-nums text-foreground-subtle`,children:[e.weightSharePct,`% share`]}),i(`span`,{className:`shrink-0 tabular-nums text-foreground-subtle`,children:[`· `,e.sessions,` session`,e.sessions===1?``:`s`,e.maxSessions===null?``:`/${e.maxSessions}`]}),e.queueDepth>0&&i(`span`,{className:`shrink-0 tabular-nums text-amber-400`,children:[`· q`,e.queueDepth]}),e.atCap&&f(`span`,{className:`shrink-0 text-amber-400`,title:`At its maxSessions cap — the balancer skips it until a session ends.`,children:`· at cap`})]}):i(`span`,{className:`truncate text-foreground-subtle/80`,title:$r[t],children:[`excluded — `,$r[t]]})]})}function J({label:e,value:t,title:n}){return i(`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 Ei(e){return{nodes:Object.fromEntries(e.map(e=>[e.nodeId,Math.max(1,e.weight)])),devices:{}}}function Di(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 Oi(e){return Object.fromEntries(e.nodes.map(e=>[e.nodeId,Object.fromEntries(e.devices.map(e=>[e.deviceKey,e.suggestedMaxSessions]))]))}function ki(e){return e.reason===`disabled`?`${e.deviceKey} is not enabled on any node — sessions ignore this pin`:`no node offers ${e.deviceKey} — sessions ignore this pin`}function Ai(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 ji(e,t){let n=e.nodes.filter(e=>!e.eligible);if(n.length===0)return null;let r=e.nodes.filter(e=>e.eligible).map(e=>`${t(e.nodeId)} ${Math.round(e.effectivePct)}%`).join(`, `);return`${n.map(e=>t(e.nodeId)).join(`, `)} cannot take sessions — ${n.length===1?`its share goes`:`their shares go`} to the others: ${r}`}var Mi=[{value:`hardware`,label:`Hardware`,hint:`Each node’s share follows what its accelerators can carry at their Auto tune models, from the measured speed of its hardware. No load is measured or estimated.`},{value:`benchmark`,label:`Benchmark`,hint:`Each node’s share follows its own node-benchmark results. A node without results uses its hardware capacity instead, and says so.`},{value:`manual`,label:`Manual`,hint:`The sliders below, as you set them.`}];function Ni(e){return e===`no-benchmark-results`?`no benchmark results yet — sized from hardware`:e===`partial-benchmark-results`?`benchmark results miss some of its accelerators — sized from hardware`:null}function Pi(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)}: ${Ni(e.capacityFallback)??``}`).join(` · `)}r();var Fi=3600*1e3,Ii=2e4,Li=.4;function Ri({refreshToken:e,onOpenAutoTune:t}){let n=l(),{nodes:r}=K(),a=ye(void 0),c=ce({windowMs:Fi},{refetchInterval:Ii,placeholderData:u}).data,p=rt(void 0,{refetchInterval:Ii,placeholderData:u}).data,m=()=>{yi(n),n.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getNodeInferenceDevices`]]})},h=bt({onSuccess:m}),g=gt({onSuccess:()=>{m(),n.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getEffectiveShares`]]})}}),v=mt({onSuccess:m}),y=N(),[S,C]=d(!1),w=p?.source,T=w===`benchmark`?`benchmark`:`hardware`,E=tt({headroom:Li,source:T},{enabled:S,staleTime:1/0}),D=E.data,O=o(()=>{let e=new Map((a.data??[]).map(e=>[e.nodeId,e.settings]));return r.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:pi(n,`detectWeight`)??1,maxCameras:pi(n,`maxCameras`)}})},[r,a.data]),k=e=>r.find(t=>t.id===e)?.name??e,A=D?Oi(D):void 0,j=Ai(O,p),M=w!==`manual`,P=e=>{if(p===void 0||p.source===`manual`||p.autoPending)return;let t=p.nodes.find(t=>t.nodeId===e);return t===void 0?void 0:Object.fromEntries(t.devices.map(e=>[e.deviceKey,e.configuredPct]))},F=p?ji(p,k):null,I=p?Pi(p,k):null,L=Mi.find(e=>e.value===w)?.hint;return i(`div`,{className:`space-y-3 sm:space-y-4`,children:[f(en,{nodeId:`hub`,addonIds:[ri],level:`global`,sectionIds:[`load`],title:`Placement policy`,description:`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(bn,{refreshToken:e}),f(Si,{stats:c,...p!==void 0&&p.source!==`manual`&&!p.autoPending?{targetWeights:Object.fromEntries(p.nodes.map(e=>[e.nodeId,e.configuredPct]))}:{}}),f(be,{headingId:`load-balancing-node-shares`,title:`Node shares`,icon:an,actions:i(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[f(`div`,{role:`radiogroup`,"aria-label":`Share source`,className:`flex items-center gap-1`,children:Mi.map(e=>f(H,{role:`radio`,"aria-checked":w===e.value,variant:w===e.value?`primary`:`outline`,size:`sm`,title:e.hint,disabled:g.isPending||p===void 0,onClick:()=>{w!==e.value&&g.mutate({source:e.value})},children:e.label},e.value))}),i(H,{variant:`outline`,size:`sm`,onClick:()=>{C(!0),S&&E.refetch()},disabled:E.isFetching,children:[f(dt,{className:`h-3.5 w-3.5`}),E.isFetching?`Suggesting…`:T===`benchmark`?`Suggest from benchmark`:`Suggest from hardware`]}),i(H,{variant:`ghost`,size:`sm`,onClick:t,children:[f(Ze,{className:`h-3.5 w-3.5`}),`Auto tune`]}),i(H,{variant:`outline`,size:`sm`,onClick:()=>y.mutate(void 0),disabled:y.isPending,title:`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(B,{className:`h-3.5 w-3.5`}),y.isPending?`Rebalancing…`:`Rebalance`]})]}),children:i(`div`,{className:`${_} space-y-3`,children:[L!==void 0&&f(`p`,{className:`text-[10px] text-foreground-subtle`,children:L}),c&&i(`p`,{className:`text-[10px] text-foreground-subtle`,children:[`Policy:`,` `,f(G,{variant:c.policy===`share`?`info`:`default`,children:c.policy===`share`?`honour shares`:`least-loaded`}),` `,`· cluster peak `,c.clusterPeakSessions,` parallel sessions in the last hour`,c.policy===`least-loaded`&&` · under least-loaded an idle node always wins, so shares only bite once nodes are busy`]}),f(On,{nodes:j.nodes,pending:h.isPending,readOnly:j.readOnly,onCommitWeights:e=>h.mutate(Ei(e)),weightLabel:`Node share`,...j.readOnly?{footnote:p?.autoPending?f(s,{children:`Automatic shares are being computed from the cluster's measured capacity; the stored values are used meanwhile.`}):i(s,{children:[w===`benchmark`?`Benchmark: each node's share follows its measured capacity from node benchmark results (hardware capacity where it has none)`:`Hardware: each node's share follows its capacity at its Auto tune model, from the measured speed of its hardware`,`, recomputed whenever a node or accelerator is added, removed, switched on or off, or changes model`,p?.computedAt==null?``:` — last at ${new Date(p.computedAt).toLocaleTimeString()}${p.trigger===null?``:` (${p.trigger})`}`,`.`]})}:{}}),F!==null&&f(`p`,{className:`text-[10px] text-foreground-subtle`,children:F}),I!==null&&f(`p`,{className:`text-[10px] text-foreground-subtle`,"data-testid":`benchmark-fallback-note`,children:I}),g.isError&&f(ve,{message:`Failed to switch shares: ${g.error instanceof Error?g.error.message:`unknown error`}`}),h.isError&&f(ve,{message:`Failed to save shares: ${h.error instanceof Error?h.error.message:`unknown error`}`}),i(`details`,{className:`rounded-md border border-border`,children:[f(`summary`,{className:`${x} cursor-pointer text-xs text-foreground`,children:`Max concurrent sessions (advanced)`}),f(`ul`,{className:`divide-y divide-border border-t border-border`,children:O.map(e=>i(`li`,{className:`${x} flex items-center gap-2`,children:[f(`span`,{className:`min-w-0 flex-1 truncate text-xs text-foreground`,children:e.name}),f(pt,{type:`number`,min:1,placeholder:`∞`,defaultValue:e.maxCameras??``,"aria-label":`Max concurrent sessions for ${e.name}`,className:`w-20 text-right`,disabled:v.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&&v.mutate({agentNodeId:e.id,maxCameras:i})}})]},e.id))}),f(`p`,{className:`${x} ${b} border-t border-border`,children:`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.`})]})]})}),E.isError&&f(ve,{message:`Suggestion failed: ${E.error instanceof Error?E.error.message:`unknown error`}`}),D&&f(zi,{suggestion:D,nameOf:k,pending:h.isPending,...M?{}:{onApply:()=>h.mutate(Di(D))}}),f(be,{headingId:`load-balancing-accelerators`,title:`Accelerators`,icon:W,children:f(`div`,{className:`${_} space-y-2`,children:O.length===0?f(Nt,{title:`No detect-capable nodes`,description:`Enable detection on a node in Roles & nodes to configure its accelerators.`}):O.map(e=>f(jn,{nodeId:e.id,nodeName:e.name,isOnline:e.isOnline,...A?.[e.id]===void 0?{}:{suggestedMaxSessions:A[e.id]},...P(e.id)===void 0?{}:{autoDeviceShares:P(e.id)}},e.id))})}),c!==void 0&&c.stalePins.length>0&&f(Bi,{stats:c})]})}function zi({suggestion:e,nameOf:t,pending:n,onApply:r}){return i(be,{headingId:`load-balancing-suggestion`,title:e.source===`benchmark`?`Suggested from benchmark`:`Suggested from hardware`,icon:dt,...r===void 0?{}:{actions:f(H,{size:`sm`,onClick:r,disabled:n,children:`Apply suggested shares`})},children:[f(`ul`,{className:`divide-y divide-border`,children:e.nodes.map(e=>i(`li`,{className:`${x} space-y-0.5`,children:[i(`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?`skipped`:`${e.share}%`})]}),i(`p`,{className:b,children:[Ni(e.capacityFallback)===null?``:`${Ni(e.capacityFallback)} · `,e.skippedReason===null?`≈ ${e.capacitySessions} parallel sessions · ${e.devices.map(e=>`${e.deviceKey} ${e.share}% (${e.modelId??`—`}${e.measured?``:`, estimated`}, cap ${e.suggestedMaxSessions??`—`})`).join(` · `)}`:`not part of the suggestion — ${e.skippedReason}`]})]},e.nodeId))}),i(`p`,{className:`${x} ${b} border-t border-border`,children:[`Shares in proportion to each node's capacity in parallel sessions —`,` `,e.source===`benchmark`?`measured by node benchmarks, or from the hardware table where a node has no results`:`at the models Auto tune picks (at least ${e.minSessionsPerDevice} per accelerator), from the measured speed of each node's hardware`,`, counted in `,e.cameraFps,` fps sessions with`,` `,Math.round(e.headroom*100),`% kept free. No load is measured or estimated.`,r===void 0?`Automatic shares already follow this; the caps are advisory — apply each from its accelerator row.`:`Applying writes the node and accelerator shares; the caps are advisory — apply each from its accelerator row.`]})]})}function Bi({stats:e}){let t=l(),n=ct({onSuccess:()=>{t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPlacementStats`]]}),t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineDevicePin`]]})}});return f(be,{headingId:`load-balancing-stale-pins`,title:`Stale device pins`,icon:nn,children:f(`ul`,{className:`divide-y divide-border`,children:e.stalePins.map(e=>i(`li`,{className:`${x} flex items-center gap-2`,children:[i(`div`,{className:`min-w-0 flex-1`,children:[i(`p`,{className:`text-xs text-foreground`,children:[`Camera `,e.deviceId]}),f(`p`,{className:b,children:ki(e)})]}),f(H,{variant:`outline`,size:`sm`,disabled:n.isPending,onClick:()=>n.mutate({deviceId:e.deviceId,deviceKey:`auto`}),children:`Clear pin`})]},e.deviceId))})})}function Vi({capability:e,label:t,hint:n,nodeId:r,active:a,pending:o,layout:s,onToggle:c}){let l=a?`border-success/30 bg-success/15 text-success hover:bg-success/25`:`border-border bg-surface-hover text-foreground-subtle hover:bg-surface hover:text-foreground`,u=s===`card`?`w-full justify-center px-3 py-2 text-xs`:`px-2.5 py-1 text-[11px]`,d=a?De:Fe;return i(`button`,{type:`button`,role:`switch`,"aria-checked":a,"aria-label":`${t} capability for ${r}`,title:`${t} — ${n}`,disabled:o,onClick:()=>c(e,!a),className:`inline-flex items-center gap-1.5 rounded-full border font-medium transition-colors disabled:opacity-50 focus:outline-none focus-visible:ring-2 focus-visible:ring-primary/40 ${l} ${u}`,children:[f(d,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":`true`}),f(`span`,{children:t})]})}function Hi({node:e,emphasis:t=!1}){let n=e.isHub?at:W;return i(`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(n,{className:`h-4 w-4 shrink-0 text-foreground-subtle`,"aria-hidden":`true`}),i(`div`,{className:`min-w-0`,children:[i(`div`,{className:`flex items-center gap-1.5 ${t?`text-sm`:`text-xs`} font-semibold text-foreground`,children:[f(`span`,{className:`truncate`,children:e.name}),e.isHub&&f(G,{variant:`info`,className:`px-1.5 py-0 text-[9px] uppercase tracking-wider`,children:`hub`}),!e.isOnline&&f(G,{variant:`danger`,className:`px-1.5 py-0 text-[9px] uppercase tracking-wider`,children:`offline`})]}),f(`div`,{className:`font-mono text-[10px] text-foreground-subtle truncate`,children:e.id})]})]})}r();function Ui({nodeId:e,value:t,detectedHosts:n,status:r,errorMessage:a,onCommit:o}){let[s,c]=d(t??``);p(()=>{c(t??``)},[t]);let l=n[0],u=l===void 0?`auto-detect`:`auto: ${l}`,m=r===`pending`,h=s.trim(),g=h!==(t??``),_=g&&!m,v=()=>{_&&o(e,h.length>0?h:null)};return i(`div`,{className:`flex items-center gap-1.5`,children:[f(`input`,{"aria-label":`Reachable host for ${e}`,type:`text`,inputMode:`url`,autoComplete:`off`,spellCheck:!1,placeholder:u,value:s,disabled:m,onChange:e=>c(e.target.value),onBlur:v,onKeyDown:e=>{e.key===`Enter`&&v(),e.key===`Escape`&&c(t??``)},className:`w-40 rounded-md border border-border bg-background px-2.5 py-1.5 text-sm text-foreground placeholder:text-foreground-subtle focus:border-primary focus:outline-none disabled:opacity-50`}),i(`button`,{type:`button`,onClick:v,disabled:!_,"aria-label":`Save reachable host for ${e}`,title:`Save reachable host`,className:`inline-flex shrink-0 items-center gap-1 rounded-md px-2 py-1.5 text-[11px] font-medium bg-primary text-white hover:bg-primary/90 disabled:opacity-40 disabled:cursor-not-allowed`,children:[m?f(_t,{className:`h-3 w-3 animate-spin`,"aria-hidden":`true`}):f(De,{className:`h-3 w-3`,"aria-hidden":`true`}),`Save`]}),!g&&!m&&r===`success`&&f(De,{className:`h-3.5 w-3.5 shrink-0 text-emerald-400`,"aria-label":`Saved`,role:`img`}),r===`error`&&f(`span`,{title:a??`Failed to save reachable host`,children:f(A,{className:`h-3.5 w-3.5 shrink-0 text-red-400`,"aria-label":a??`Failed to save reachable host`,role:`img`})})]})}r();var Wi=1024,Gi=65536;function Ki(e,t,n){let r=e.trim();if(r.length===0)return{value:null,error:null};let i=Number(r);return Number.isInteger(i)?i<t?{value:null,error:`at least ${t}`}:i>n?{value:null,error:`at most ${n}`}:{value:i,error:null}:{value:null,error:`whole number`}}function qi({nodeId:e,decodeBudgetMb:t,maxLiveDecodeWorkers:n,status:r,errorMessage:a,onCommit:o}){let[s,c]=d(t===null?``:String(t)),[l,u]=d(n===null?``:String(n));p(()=>{c(t===null?``:String(t))},[t]),p(()=>{u(n===null?``:String(n))},[n]);let m=Ki(s,Wi,Gi),h=Ki(l,1,32),g=r===`pending`,_=m.value!==t||h.value!==n,v=m.error!==null||h.error!==null,y=_&&!v&&!g,b=()=>{y&&o(e,{decodeBudgetMb:m.value,maxLiveDecodeWorkers:h.value})},x=`w-24 rounded-md border border-border bg-background px-2.5 py-1.5 text-sm text-foreground placeholder:text-foreground-subtle focus:border-primary focus:outline-none disabled:opacity-50`;return i(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[f(`input`,{"aria-label":`Decode budget MB for ${e}`,type:`number`,inputMode:`numeric`,min:Wi,max:Gi,placeholder:`auto`,value:s,disabled:g,onChange:e=>c(e.target.value),onKeyDown:e=>{e.key===`Enter`&&b()},className:x}),f(`span`,{className:`text-[11px] text-foreground-subtle`,children:`MB`}),f(`input`,{"aria-label":`Max decode workers for ${e}`,type:`number`,inputMode:`numeric`,min:1,max:32,placeholder:`auto`,value:l,disabled:g,onChange:e=>u(e.target.value),onKeyDown:e=>{e.key===`Enter`&&b()},className:x}),f(`span`,{className:`text-[11px] text-foreground-subtle`,children:`workers`}),i(`button`,{type:`button`,onClick:b,disabled:!y,"aria-label":`Save decode limits for ${e}`,title:`Save decode limits`,className:`inline-flex shrink-0 items-center gap-1 rounded-md px-2 py-1.5 text-[11px] font-medium bg-primary text-white hover:bg-primary/90 disabled:opacity-40 disabled:cursor-not-allowed`,children:[g?f(_t,{className:`h-3 w-3 animate-spin`,"aria-hidden":`true`}):f(De,{className:`h-3 w-3`,"aria-hidden":`true`}),`Save`]}),m.error===null?null:i(`span`,{className:`text-[11px] text-red-400`,children:[`budget: `,m.error]}),h.error===null?null:i(`span`,{className:`text-[11px] text-red-400`,children:[`workers: `,h.error]}),!_&&!g&&r===`success`&&f(De,{className:`h-3.5 w-3.5 shrink-0 text-emerald-400`,"aria-label":`Saved`,role:`img`}),r===`error`&&f(`span`,{title:a??`Failed to save decode limits`,children:f(A,{className:`h-3.5 w-3.5 shrink-0 text-red-400`,"aria-label":`Save failed`,role:`img`})})]})}function Ji({label:e,children:t}){return i(`div`,{className:`flex items-center justify-between gap-3`,children:[f(`span`,{className:`text-[11px] font-medium uppercase tracking-wide text-foreground-subtle`,children:e}),t]})}function Yi({node:e,actions:t}){return i(`div`,{className:`rounded-xl border border-border bg-background p-4 space-y-4 ${e.isOnline?``:`opacity-60`}`,children:[f(Hi,{node:e,emphasis:!0}),f(`div`,{className:`grid grid-cols-2 gap-2`,children:li.map(n=>f(Vi,{capability:n.key,label:n.label,hint:n.hint,nodeId:e.id,active:_i(e.effective,n.key),pending:t.capabilityPending,layout:`card`,onToggle:(n,r)=>t.onToggleCapability(e.id,n,r)},n.key))}),i(`div`,{className:`space-y-3 border-t border-border pt-3`,children:[f(Ji,{label:`Reachable host`,children:f(Ui,{nodeId:e.id,value:e.reachableHost,detectedHosts:e.detectedHosts,status:t.reachableHostStatus(e.id),errorMessage:t.reachableHostErrorMessage(e.id),onCommit:t.onCommitReachableHost})}),f(Ji,{label:`Decode limits`,children:f(qi,{nodeId:e.id,decodeBudgetMb:e.decodeBudgetMb,maxLiveDecodeWorkers:e.maxLiveDecodeWorkers,status:t.decodeLimitsStatus(e.id),errorMessage:t.decodeLimitsErrorMessage(e.id),onCommit:t.onCommitDecodeLimits})})]})]})}function Xi(){return i(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1.5 text-[10px] text-foreground-subtle`,children:[i(`span`,{className:`inline-flex items-center gap-1.5`,children:[f(`span`,{className:`h-2.5 w-2.5 rounded-full border border-success/30 bg-success/15`}),`Active capability`]}),i(`span`,{className:`inline-flex items-center gap-1.5`,children:[f(`span`,{className:`h-2.5 w-2.5 rounded-full border border-border bg-surface-hover`}),`Idle`]}),i(`span`,{className:`inline-flex items-center gap-1.5`,children:[f(`span`,{className:`h-2 w-2 rounded-full bg-success`}),`Node online`]}),i(`span`,{className:`inline-flex items-center gap-1.5`,children:[f(`span`,{className:`h-2 w-2 rounded-full bg-danger`}),`Node offline`]})]})}function Zi({nodes:e,actions:t}){return f(`div`,{className:`overflow-x-auto rounded-lg border border-border`,children:i(`table`,{className:`w-full min-w-[720px] border-collapse text-sm`,children:[f(`thead`,{children:i(`tr`,{className:`border-b border-border bg-background text-[10px] uppercase tracking-wider text-foreground-subtle`,children:[f(`th`,{className:`px-4 py-3 text-left font-semibold`,children:`Node`}),li.map(e=>f(`th`,{className:`px-3 py-3 text-center font-semibold`,children:e.label},e.key)),f(`th`,{className:`px-4 py-3 text-left font-semibold`,children:`Reachable host`}),f(`th`,{className:`px-4 py-3 text-left font-semibold`,children:`Decode limits`})]})}),f(`tbody`,{children:e.map(e=>i(`tr`,{className:`border-b border-border last:border-b-0 transition-colors hover:bg-surface-hover/40 ${e.isOnline?``:`opacity-60`}`,children:[f(`td`,{className:`px-4 py-3 align-middle`,children:f(Hi,{node:e})}),li.map(n=>f(`td`,{className:`px-3 py-3 text-center align-middle`,children:f(Vi,{capability:n.key,label:n.label,hint:n.hint,nodeId:e.id,active:_i(e.effective,n.key),pending:t.capabilityPending,layout:`cell`,onToggle:(n,r)=>t.onToggleCapability(e.id,n,r)})},n.key)),f(`td`,{className:`px-4 py-3 align-middle`,children:f(Ui,{nodeId:e.id,value:e.reachableHost,detectedHosts:e.detectedHosts,status:t.reachableHostStatus(e.id),errorMessage:t.reachableHostErrorMessage(e.id),onCommit:t.onCommitReachableHost})}),f(`td`,{className:`px-4 py-3 align-middle`,children:f(qi,{nodeId:e.id,decodeBudgetMb:e.decodeBudgetMb,maxLiveDecodeWorkers:e.maxLiveDecodeWorkers,status:t.decodeLimitsStatus(e.id),errorMessage:t.decodeLimitsErrorMessage(e.id),onCommit:t.onCommitDecodeLimits})})]},e.id))})]})})}function Qi({role:e,value:t,options:n,pending:r,onChange:a}){return i(`label`,{className:`flex flex-col gap-1.5 rounded-lg border border-border bg-background p-3`,children:[f(`span`,{className:`text-xs font-semibold text-foreground`,children:hi(e)}),f(`select`,{value:t,disabled:r,onChange:t=>a(e,t.target.value),className:`rounded-md border border-border bg-surface px-2.5 py-1.5 text-sm text-foreground focus:border-primary focus:outline-none disabled:opacity-50`,children:n.map(e=>f(`option`,{value:e,children:e===`hub`?`hub (default)`:e},e))}),f(`span`,{className:`text-[10px] leading-tight text-foreground-subtle`,children:gi(e)})]})}function $i({roleValues:e,options:t,pending:n,onRoleChange:r}){return f(`div`,{className:`grid gap-3 @lg/clustertab:grid-cols-2 @3xl/clustertab:grid-cols-3`,children:ci.map(i=>f(Qi,{role:i,value:e[i],options:t,pending:n,onChange:r},i))})}r();function ea(){let e=l(),{nodes:t}=K(),n=ye(void 0),r=U({addonId:ri}),a=U({addonId:ii}),c=U({addonId:oi}),u=()=>yi(e),d=Ne({onSuccess:u}),p=V({onSuccess:u}),m=ie({onSuccess:u}),h=jt({onSuccess:u}),g=o(()=>{let e=new Map;for(let t of n.data??[])e.set(t.nodeId,t.settings);return e},[n.data]),_=o(()=>t.map(e=>{let t=g.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,reachableHost:mi(t,`reachableHost`),detectedHosts:e.localIps,decodeBudgetMb:pi(t,`decodeBudgetMb`),maxLiveDecodeWorkers:pi(t,`maxLiveDecodeWorkers`)}}),[t,g]),v={ingestNode:fi(r.data,`ingestNode`,`hub`),recordingNode:fi(a.data,ai,`hub`),audioNode:fi(r.data,`audioNode`,`hub`),motionNode:fi(r.data,`motionNode`,`hub`),postProcessingNode:fi(c.data,si,`hub`)},y=o(()=>{let e=t.filter(e=>e.isOnline).map(e=>e.id);return[...new Set([`hub`,...ci.map(e=>v[e]),...e])].filter(e=>e.length>0)},[t,v]),b=n.isLoading||r.isLoading||a.isLoading||c.isLoading,x=(e,t,n)=>{d.mutate({agentNodeId:e,[t]:n})},S=(e,t)=>{if(e===`recordingNode`){h.mutate({addonId:ii,patch:{[ai]:t}});return}if(e===`postProcessingNode`){h.mutate({addonId:oi,patch:{[si]:t}});return}h.mutate({addonId:ri,patch:{[e]:t}})},C=e=>p.variables?.agentNodeId===e?p.isPending?`pending`:p.isError?`error`:p.isSuccess?`success`:`idle`:`idle`,w=e=>C(e)===`error`?vi(p.error):null,T=e=>m.variables?.agentNodeId===e?m.isPending?`pending`:m.isError?`error`:m.isSuccess?`success`:`idle`:`idle`,E={capabilityPending:d.isPending,onToggleCapability:x,onCommitReachableHost:(e,t)=>p.mutate({agentNodeId:e,reachableHost:t}),reachableHostStatus:C,reachableHostErrorMessage:w,onCommitDecodeLimits:(e,t)=>m.mutate({agentNodeId:e,...t}),decodeLimitsStatus:T,decodeLimitsErrorMessage:e=>T(e)===`error`?vi(m.error):null};return i(`section`,{className:`rounded-xl border border-border bg-surface p-5 @3xl/clustertab:p-6 space-y-6`,children:[i(`header`,{className:`flex items-start justify-between gap-4`,children:[i(`div`,{className:`space-y-1`,children:[f(`h3`,{className:`text-base font-semibold text-foreground`,children:`Roles & nodes`}),f(`p`,{className:`max-w-prose text-xs leading-relaxed text-foreground-subtle`,children:`Choose the singleton cluster roles and which node runs each pipeline capability. Detection shares and caps live on the Load balancing tab.`})]}),b&&f(_t,{className:`h-5 w-5 shrink-0 animate-spin text-foreground-subtle`,"aria-label":`Loading`})]}),i(`div`,{className:`space-y-3`,children:[f(`h4`,{className:`text-xs font-semibold uppercase tracking-wide text-foreground-subtle`,children:`Singleton cluster roles`}),f($i,{roleValues:v,options:y,pending:h.isPending,onRoleChange:S})]}),i(`div`,{className:`space-y-3`,children:[i(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[f(`h4`,{className:`text-xs font-semibold uppercase tracking-wide text-foreground-subtle`,children:`Per-node capabilities`}),f(Xi,{})]}),_.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:`No cluster nodes reporting yet.`}):i(s,{children:[f(`div`,{className:`grid gap-4 @xl/clustertab:grid-cols-2 @3xl/clustertab:hidden`,children:_.map(e=>f(Yi,{node:e,actions:E},e.id))}),f(`div`,{className:`hidden @3xl/clustertab:block`,children:f(Zi,{nodes:_,actions:E})})]})]})]})}var ta=[`pipeline-orchestrator`],na=`pipeline-analytics`,ra=`face-gallery`;r();var ia=2500;function aa(e){p(()=>{if(e===null)return;let t=`[data-settings-section="${CSS.escape(e)}"]`,n=()=>{let e=document.querySelector(t);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`),ia),!0)};if(n())return;let r=new MutationObserver(()=>{n()&&r.disconnect()});return r.observe(document.body,{childList:!0,subtree:!0}),()=>r.disconnect()},[e])}function oa({refreshToken:e}){let[t]=Qt();return aa(t.get(oo)),i(`div`,{className:`space-y-4 max-w-3xl`,children:[f(en,{nodeId:`hub`,addonIds:ta,level:`global`,omitSectionIds:[`cluster`,`load`],title:`Cluster settings`,description:`Cluster-wide orchestration knobs: failover, enrichment models, and the admission settings those models share. Placement and load policies live on Load balancing; node roles on Roles & nodes. Per-camera pipelines live in Device Overrides.`}),f(en,{nodeId:`hub`,addonIds:[na],level:`global`,capability:ra,title:`Face recognition`,description:`Match threshold, ambiguity margin, and auto-assign floors. Same settings as System → Settings → pipeline-analytics — this page asks the face-gallery cap, it does not store a second copy.`})]})}var sa=`pipeline-orchestrator`,ca=200;function la(){return i(`div`,{className:`flex flex-col gap-3`,children:[i(`div`,{children:[f(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Orchestrator logs`}),f(`p`,{className:`text-[11px] text-foreground-subtle`,children:`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(R,{addonId:sa,limit:ca,maxHeight:`max-h-[calc(100vh-360px)]`,showScope:!0,showDeviceChip:!0,showFilters:!1})})]})}var ua=[{id:`assignments`,label:`Assignments`},{id:`load-balancing`,label:`Load balancing`},{id:`auto-tune`,label:`Auto tune`},{id:`roles-nodes`,label:`Roles & nodes`},{id:`settings`,label:`Settings`},{id:`logs`,label:`Logs`}];function da(e){return ua.some(t=>t.id===e)}function fa({refreshToken:e}){let[t,n]=Qt(),r=t.get(ao),a=da(r)?r:`assignments`,o=e=>{n(t=>{let n=new URLSearchParams(t);return n.set(ao,e),n.delete(oo),n},{replace:!0})};return i(`div`,{className:`flex flex-col h-full`,children:[i(`div`,{className:`px-4 sm:px-6 py-4 border-b border-border`,children:[f(`h2`,{className:`text-base font-semibold text-foreground`,children:`Cluster Orchestration`}),f(`div`,{className:`text-[11px] text-foreground-subtle mt-1`,children:`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:ua.map(e=>f(`button`,{type:`button`,onClick:()=>o(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:e.label},e.id))}),i(`div`,{className:`flex-1 min-h-0 overflow-y-auto p-4 sm:p-6 @container/clustertab`,children:[a===`assignments`&&f(Pr,{}),a===`load-balancing`&&f(Ri,{refreshToken:e,onOpenAutoTune:()=>o(`auto-tune`)}),a===`auto-tune`&&f(Qr,{}),a===`roles-nodes`&&f(ea,{}),a===`settings`&&f(oa,{refreshToken:e}),a===`logs`&&f(la,{})]})]})}var pa=`armed:`;function ma(e){return e.assignment.reasons.detection?.startsWith(pa)===!0}function ha(e){let{assignment:t,detection:n}=e;return n!==null&&n.provisioning.state===`failed`||t.detectionNodeId===null&&n===null&&!ma(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?`Engine provisioning failed: ${i.provisioning.error}`:`Engine provisioning failed on the detection node`}),i!==null&&i.phase===`active`&&i.actualFps===0&&t.push({code:`detection-black-hole`,severity:`error`,message:`Detection phase is ACTIVE but 0 fps are being processed — frames are not reaching the detector (cross-node black-hole signature)`}),r.detectionNodeId===null&&i===null&&!ma(e)&&n.push({code:`unassigned`,severity:`warning`,message:`Not placed on any detection node — no pipeline is running for this camera`});let o=e.degraded??[];if(o.length>0){let e=[...new Set(o.map(e=>e.stage))].join(`, `);n.push({code:`status-unreadable`,severity:`warning`,message:`Could not read ${e} for this camera — those blocks are unknown, not empty (a switch read that failed does NOT mean nothing is switched off)`})}n.push(...ya(e.cameraSensors));for(let e of a?.profiles??[])e.status===`streaming`&&e.inFps===0&&n.push({code:`broker-stalled`,severity:`warning`,message:`Broker profile "${e.profile}" reports streaming but 0 in-fps — the source pull may be stalled`});return[...t,...n]}function _a(e){return e.state===`unreadable`&&zt.state===`unreadable`&&e.reason===zt.reason}function va(e){switch(e.state){case`ready`:return null;case`missing`:return{code:`camera-sensor-missing`,severity:`warning`,message:`Camera sensor ${e.addonId}/${e.stableId} is missing`};case`offline`:return{code:`camera-sensor-offline`,severity:`warning`,message:`Camera sensor ${e.name} (#${e.deviceId}) is ${e.reason}`};case`unsupported`:return{code:`camera-sensor-unsupported`,severity:`warning`,message:`Camera sensor ${e.name} (#${e.deviceId}) cannot drive motion: ${e.reason}`};case`unreadable`:return{code:`camera-sensor-unreadable`,severity:`warning`,message:`Camera sensor ${e.addonId}/${e.stableId} is unreadable: ${e.reason}`}}}function ya(e){if(e===void 0||e.state===`not-configured`)return[];if(e.state===`unreadable`)return _a(e)?[]:[{code:`camera-sensors-unreadable`,severity:`warning`,message:`Camera sensors unreadable: ${e.reason}`}];let t=e.sensors.flatMap(e=>{let t=va(e);return t===null?[]:[t]}),n=e.notForwarded===void 0?t:[ba(e.notForwarded),...t];return e.notEnforced===void 0?n:[{code:`camera-sensors-not-enforced`,severity:`warning`,message:`Confirm / Replace cannot suppress this camera's own motion until its provider is updated`},...n]}function ba(e){return{code:`camera-sensors-not-forwarded`,severity:`warning`,message:e===`onboard-not-listed`?`Camera sensors are attached but never fire: add "Camera sensors" (onboard) to this camera's motion sources`:`Camera sensors are attached but never fire: this camera has no active detection`}}function xa(e){return e===void 0?`status unavailable from this node`:e.state===`not-configured`?`none attached`:e.state===`unreadable`?`unknown — ${e.reason}`:e.sensors.map(Ca).join(`, `)}function Sa(e){return e.mode===`in-addition`?``:` · ${e.mode}`}function Ca(e){return`${wa(e)}${Sa(e)}`}function wa(e){switch(e.state){case`ready`:return`${e.name} (#${e.deviceId})`;case`offline`:return`${e.name} (#${e.deviceId}) — ${e.reason}`;case`unsupported`:return`${e.name} (#${e.deviceId}) — unsupported`;case`missing`:case`unreadable`:return`${e.addonId}/${e.stableId} — ${e.state}`}}function Ta(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Y(e){return typeof e==`string`&&e.length>0?e:null}function Ea(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function Da(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function Oa(e,t){return e==null?!1:JSON.stringify(e)!==JSON.stringify(t??null)}var ka={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 Aa(e){if(!Ta(e)||!Array.isArray(e.sections))return ka;let t=qt(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)Oa(n.value,n.default)&&r.add(e);return{detectionMode:Y(n(`detectionMode`)),detectionStreamProfile:Y(n(`detectionStreamProfile`)),detectionFps:Ea(n(`detectionFps`)),motionSources:Da(n(`motionSources`)),motionFps:Ea(n(`motionFps`)),motionCooldownMs:Ea(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 ja(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(...ja(r.children,t+1));return n}function X({title:e,children:t}){return i(`div`,{className:`bg-background px-3.5 py-3 min-w-0`,children:[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 i(`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(Ma,{})]})}function Ma(){return f(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full bg-warning shrink-0 self-center`,title:`Device-level override active`,"aria-label":`Device-level override active`,role:`img`})}var Na={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 ${Na[e]}`,children:t})}function $({children:e}){return f(`div`,{className:`text-[11px] text-foreground-subtle italic`,children:e})}function Pa({icon:e,label:t,nodeId:n,pinned:r,reason:a,overridden:o}){return i(`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:`unassigned`}):i(s,{children:[f(`span`,{className:`font-mono text-foreground truncate`,title:n,children:n}),r?i(`span`,{className:`inline-flex items-center gap-0.5 text-[10px] text-warning shrink-0`,title:`Manually pinned`,children:[f(rn,{className:`h-2.5 w-2.5`}),` manual`]}):i(`span`,{className:`text-[10px] text-foreground-subtle shrink-0 truncate`,children:[`auto · `,a!==void 0&&a.length>0?a:`capacity`]}),o&&f(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full bg-warning shrink-0`,title:`Persisted settings pin for this role`})]})]})}function Fa({assignment:e,settings:t,onlineNodes:n,pinPending:r,onDetectionPinChange:a}){let o=e.pinned.detection&&e.detectionNodeId!==null?e.detectionNodeId:`auto`,s=[...new Set([...e.detectionNodeId===null?[]:[e.detectionNodeId],...n.map(e=>e.id)])];return i(X,{title:`Where it runs`,children:[f(Pa,{icon:W,label:`Detection`,nodeId:e.detectionNodeId,pinned:e.pinned.detection,reason:e.reasons.detection,overridden:t.overriddenKeys.has(`pipelineNodeId`)}),f(Pa,{icon:Ct,label:`Decoder`,nodeId:e.decoderNodeId,pinned:e.pinned.decoder,reason:e.reasons.decoder,overridden:t.overriddenKeys.has(`decoderNodeId`)}),f(Pa,{icon:O,label:`Audio`,nodeId:e.audioNodeId,pinned:e.pinned.audio,reason:e.reasons.audio,overridden:t.overriddenKeys.has(`audioNodeId`)}),f(Pa,{icon:xe,label:`Source`,nodeId:e.sourceNodeId,pinned:!1,reason:`ingest owner`,overridden:!1}),f(`div`,{className:`mt-1.5`,children:i(`select`,{value:o,disabled:r,"aria-label":`Detection placement pin`,onChange:e=>a(e.target.value),className:`w-full min-w-0 rounded-md border border-border bg-background px-2 py-1 text-[11px] text-foreground disabled:opacity-50`,children:[f(`option`,{value:`auto`,children:`Auto (load balanced)`}),s.map(e=>i(`option`,{value:e,children:[`Pin detection → `,n.find(t=>t.id===e)?.name??e]},e))]})})]})}function Ia(e){return`${e.width}×${e.height} ${e.codec} @${e.fps}fps`}function La(e,t){if(!(t===null||e===void 0))return e.find(e=>e.profile===t)}function Ra(e){return e===null?`default`:e===0?`native (no throttle)`:`${e} fps`}function za({streams:e,brokerProfiles:t,settings:n,motionEnabled:r,motionFpsLive:a,cameraSensors:o}){let c=La(t,n.detectionStreamProfile),l=La(t,n.motionStreamProfile),u=n.motionSources.includes(`analyzer`);return i(X,{title:`Streams & motion`,children:[i(Z,{label:`Detect stream`,overridden:n.overriddenKeys.has(`detectionStreamProfile`),children:[n.detectionStreamProfile??`—`,c!==void 0&&` · ${c.width}×${c.height} ${c.codec}`]}),f(Z,{label:`Detect FPS`,overridden:n.overriddenKeys.has(`detectionFps`),children:Ra(n.detectionFps)}),i(Z,{label:`Motion src`,overridden:n.overriddenKeys.has(`motionSources`),children:[n.motionSources.length>0?n.motionSources.map(Yt).join(` + `):`none`,r===!1&&` · inactive`]}),f(Z,{label:`Camera sensors`,children:xa(o)}),u&&i(s,{children:[i(Z,{label:`Motion stream`,overridden:n.overriddenKeys.has(`motionStreamProfile`),children:[n.motionStreamProfile??`—`,l!==void 0&&` · ${l.width}×${l.height} ${l.codec}`]}),i(Z,{label:`Motion FPS`,overridden:n.overriddenKeys.has(`motionFps`),children:[Ra(n.motionFps),a!==null&&` · live ${a.toFixed(1)}`]})]}),f(Z,{label:`Cooldown`,overridden:n.overriddenKeys.has(`motionCooldownMs`),children:n.motionCooldownMs===null?`default`:`${n.motionCooldownMs/1e3}s`}),f(`div`,{className:`mt-1.5 flex flex-col gap-0.5`,children:e.length===0?f($,{children:`No streams registered`}):e.map(e=>i(`div`,{className:`text-[10px] font-mono text-foreground-subtle truncate`,title:e.camStreamId,children:[f(`span`,{className:`text-foreground-muted`,children:e.kind}),` `,Ia(e)]},e.camStreamId))})]})}function Ba({steps:e,audioModelId:t,audioEnabled:n,audioMode:r}){return i(X,{title:`Pipeline steps`,children:[e===void 0?f($,{children:`Resolving…`}):e.length===0?f($,{children:`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:i(`span`,{className:e.enabled?``:`line-through opacity-60`,children:[e.depth>0&&f(`span`,{className:`opacity-50`,children:`↳ `}),e.addonId,e.modelId!==null&&i(`span`,{className:`font-mono opacity-75`,children:[` · `,e.modelId]})]})},`${e.addonId}-${t}`))}),f(`div`,{className:`mt-1`,children:i(Z,{label:`Audio class.`,children:[r??`—`,n!==null&&(n?` · running`:` · off`),t!==null&&` · ${t}`]})})]})}var Va={ready:`success`,installing:`info`,verifying:`info`,idle:`neutral`,failed:`danger`};function Ha({detection:e,live:t,detectionMode:n,modeOverridden:r}){if(e===null)return i(X,{title:`Detection runtime`,children:[f(Z,{label:`Mode`,overridden:r,children:n??`—`}),f($,{children:`Detection stage inactive or unreachable`})]});let a=t?.phase??e.phase,o=t?.actualFps??e.actualFps,s=t?.configuredFps??e.configuredFps,c=t?.avgInferenceTimeMs??e.avgInferenceMs,l=t?.queueDepth??e.queueDepth,u=it(a),d=a===`active`&&o===0;return i(X,{title:`Detection runtime`,children:[i(`div`,{className:`flex items-center gap-1.5 mb-0.5`,children:[i(`span`,{className:`inline-flex items-center gap-1 rounded border px-1.5 py-px text-[10px] font-semibold uppercase tracking-wider ${u.badgeClass}`,children:[f(ne,{phase:a,className:`h-2.5 w-2.5`}),u.label]}),t!==void 0&&f(`span`,{className:`text-[9px] text-foreground-subtle uppercase tracking-wider`,children:`live`})]}),f(Z,{label:`Mode`,overridden:r,children:n??`—`}),i(Z,{label:`FPS`,children:[f(`span`,{className:d?`text-danger font-semibold`:``,children:o.toFixed(1)}),i(`span`,{className:`text-foreground-subtle`,children:[` / `,s.toFixed(0),` configured`]})]}),i(Z,{label:`Inference`,children:[c.toFixed(0),` ms`,l>0&&i(`span`,{className:`text-warning`,children:[` · queue `,l]}),t!==void 0&&t.droppedFrames>0&&i(`span`,{className:`text-warning`,children:[` · drops `,t.droppedFrames]})]}),i(Z,{label:`Engine`,children:[e.engine.backend,` · `,e.engine.device]}),i(Z,{label:`Provisioning`,children:[f(Q,{tone:Va[e.provisioning.state]??`neutral`,children:e.provisioning.state}),e.provisioning.error!==void 0&&i(`span`,{className:`text-danger text-[10px]`,children:[` `,e.provisioning.error]})]})]})}function Ua({broker:e}){return e===null?f(X,{title:`Stream broker`,children:f($,{children:`Broker stage inactive or unreachable`})}):i(X,{title:`Stream broker`,children:[e.profiles.length===0?f($,{children:`No broker profiles`}):f(`div`,{className:`flex flex-col gap-1`,children:e.profiles.map(e=>{let t=e.status===`streaming`,n=t&&e.inFps===0;return i(`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 ${n?`bg-danger`:t?`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}),i(`span`,{className:`text-foreground-subtle truncate`,children:[e.width,`×`,e.height,` `,e.codec]}),i(`span`,{className:`ml-auto shrink-0 ${n?`text-danger`:`text-foreground`}`,children:[e.inFps.toFixed(0),`→`,e.outFps.toFixed(0),`fps`]}),i(`span`,{className:`text-foreground-subtle shrink-0`,title:`Subscribers`,children:[`×`,e.subscribers]})]},e.profile)})}),i(`div`,{className:`mt-1.5 flex flex-wrap gap-1`,children:[i(Q,{tone:e.webrtcSessions>0?`info`:`neutral`,children:[`WebRTC `,e.webrtcSessions]}),i(Q,{tone:e.rtspRestream?`success`:`neutral`,children:[`restream `,e.rtspRestream?`on`:`off`]})]})]})}function Wa({decoder:e}){return e===null?f(X,{title:`Decoder`,children:f($,{children:`Decoder stage inactive or unreachable`})}):f(X,{title:`Decoder`,children:f(Z,{label:`Node`,children:e.nodeId})})}r();var Ga=`pipeline-orchestrator`,Ka={healthy:`bg-success`,idle:`bg-warning`,error:`bg-danger`},qa={healthy:`Healthy`,idle:`Idle`,error:`Error`};function Ja({problems:e}){return f(`div`,{role:`alert`,className:`flex flex-col border-b border-border`,children:e.map(e=>i(`div`,{className:`flex items-start gap-2 px-4 py-1.5 text-[11px] font-medium ${e.severity===`error`?`bg-danger/10 text-danger`:`bg-warning/10 text-warning`}`,children:[f(yt,{className:`h-3.5 w-3.5 shrink-0 mt-px`}),f(`span`,{className:`min-w-0`,children:e.message})]},e.code))})}function Ya({deviceId:e,name:t,online:n,status:r,live:a,onlineNodes:s}){let c=l(),{data:u}=et({addonId:Ga,deviceId:e,nodeId:`hub`},{staleTime:3e4}),{data:d}=ke({deviceId:e},{staleTime:3e4}),p=o(()=>Aa(u),[u]),m=o(()=>d===void 0?void 0:ja(d.steps),[d]),h=o(()=>r===void 0?[]:ga(r),[r]),g=()=>{c.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCameraStatuses`]]}),c.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineAssignments`]]})},_=kt({onSuccess:g}),v=ut({onSuccess:g}),y=t=>{t===`auto`?v.mutate({deviceId:e}):_.mutate({deviceId:e,agentNodeId:t})},b=r===void 0?`idle`:ha(r),x=h.some(e=>e.severity===`error`),S=h.length>0,C=x?`border-danger/50`:S?`border-warning/40`:`border-border`;return i(`article`,{"aria-label":`${t} pipeline status`,className:`rounded-lg border ${C} bg-background overflow-hidden`,children:[i(`header`,{className:`flex items-center gap-2.5 px-4 py-2.5 border-b border-border bg-surface/50 min-w-0`,children:[f(`span`,{className:`inline-block h-2 w-2 rounded-full shrink-0 ${x?`bg-danger`:Ka[b]}`,title:x?`Error`:qa[b],"aria-label":x?`Error`:qa[b],role:`img`}),f(`h3`,{className:`text-[13px] font-semibold text-foreground truncate`,title:t,children:t}),i(`span`,{className:`text-[10px] text-foreground-subtle shrink-0`,children:[`#`,e]}),!n&&f(Q,{tone:`danger`,children:`offline`}),i(`span`,{className:`ml-auto flex items-center gap-1.5 shrink-0`,children:[p.detectionMode!==null&&f(Q,{tone:p.detectionMode===`disabled`?`warning`:p.detectionMode===`always-on`?`info`:`neutral`,title:`Object detection mode`,children:p.detectionMode===`disabled`?`detection off`:p.detectionMode}),r?.recording!=null&&(r.recording.active?i(Q,{tone:`danger`,title:`Recording (${r.recording.mode})`,children:[f(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full bg-danger animate-pulse`}),`REC`]}):r.recording.mode!==`off`&&i(Q,{tone:`neutral`,title:`Recording mode`,children:[`rec `,r.recording.mode]}))]})]}),h.length>0&&f(Ja,{problems:h}),r===void 0?f(`div`,{className:`px-4 py-5 text-[11px] text-foreground-subtle italic`,children:`No pipeline status yet — the orchestrator has not composed a snapshot for this camera.`}):i(`div`,{className:`grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-px bg-border`,children:[f(Fa,{assignment:r.assignment,settings:p,onlineNodes:s,pinPending:_.isPending||v.isPending,onDetectionPinChange:y}),f(Ha,{detection:r.detection,live:a,detectionMode:p.detectionMode,modeOverridden:p.overriddenKeys.has(`detectionMode`)}),f(Ba,{steps:m,audioModelId:d?.audio?.modelId??null,audioEnabled:r.audio?.enabled??d?.audio?.enabled??null,audioMode:p.audioMode}),f(za,{streams:r.source.streams,brokerProfiles:r.broker?.profiles,settings:p,motionEnabled:r.motion?.enabled??null,motionFpsLive:r.motion?.fps??null,cameraSensors:r.cameraSensors}),f(Ua,{broker:r.broker}),f(Wa,{decoder:r.decoder})]})]})}r();var Xa=5e3,Za=1e4,Qa=5e3;function $a(e){let t=l(),{data:n,isLoading:r}=Zt(),{data:i,isLoading:a}=ee({},{refetchInterval:Xa}),{nodes:s}=K();p(()=>{e!==0&&t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCameraStatuses`]]})},[e,t]);let[c,u]=d(new Map);Oe(Kt.PipelineCameraMetricsSnapshot,e=>{let t=e.data;typeof t.deviceId==`number`&&u(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})}),p(()=>{if(c.size===0)return;let e=setInterval(()=>{u(e=>{let t=Date.now()-Za,n=!1,r=new Map(e);for(let[i,a]of e)a.timestamp<t&&(r.delete(i),n=!0);return n?r:e})},Qa);return()=>clearInterval(e)},[c.size]);let f=o(()=>{let e=new Map;for(let t of i??[])e.set(t.deviceId,t);return e},[i]);return{rows:o(()=>(n??[]).filter(e=>e.isCamera).map(e=>({deviceId:e.id,name:e.name,online:e.online,status:f.get(e.id)})).sort((e,t)=>e.name.localeCompare(t.name)),[n,f]),liveMetrics:c,onlineNodes:o(()=>(s??[]).filter(e=>e.isOnline).map(e=>({id:e.id,name:e.name})),[s]),isLoading:r||a}}r();function eo({refreshToken:e}){let{rows:t,liveMetrics:n,onlineNodes:r,isLoading:a}=$a(e),s=o(()=>[...t.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),[t]),c=o(()=>{let e=0,t=0;for(let r of s)(r.errorCount>0||r.warningCount>0)&&(t+=1),(n.get(r.row.deviceId)?.phase??r.row.status?.detection?.phase)===`active`&&(e+=1);return{total:s.length,active:e,issues:t}},[s,n]);return a&&t.length===0?f(`div`,{className:`flex items-center justify-center h-full text-sm text-foreground-subtle`,children:`Loading camera pipelines…`}):t.length===0?f(`div`,{className:`flex items-center justify-center h-full text-sm text-foreground-subtle`,children:`No cameras found`}):f(`div`,{className:`h-full overflow-y-auto`,children:i(`div`,{className:`max-w-6xl mx-auto flex flex-col gap-3 px-4 py-4`,children:[i(`div`,{className:`flex items-center gap-4 text-[11px] text-foreground-subtle px-1`,children:[i(`span`,{children:[f(`span`,{className:`font-semibold text-foreground`,children:c.total}),` cameras`]}),i(`span`,{children:[f(`span`,{className:`font-semibold text-success`,children:c.active}),` actively inferring`]}),i(`span`,{children:[f(`span`,{className:`font-semibold ${c.issues>0?`text-danger`:`text-foreground`}`,children:c.issues}),` `,`with issues`]}),f(`span`,{className:`ml-auto hidden sm:inline text-[10px]`,children:`polled every 5 s · detection metrics live at 1 Hz`})]}),s.map(({row:e})=>f(Ya,{deviceId:e.deviceId,name:e.name,online:e.online,status:e.status,live:n.get(e.deviceId),onlineNodes:r},e.deviceId))]})})}var to=e({CLUSTER_NODE_ID:()=>no,PipelinePage:()=>io});r();var no=`__cluster__`;function ro(e){return e===`cameras`?`cameras`:`nodes`}function io(){let[e,t]=Qt(),n=ro(e.get(`view`)),r=e.get(`node`)??`__cluster__`,[a,o]=d(0),[c,l]=d(!1);return p(()=>{n===`nodes`&&!e.get(`node`)&&t({view:`nodes`,node:no},{replace:!0})},[n,e,t]),i(`div`,{className:`flex flex-col h-full overflow-hidden`,children:[i(`div`,{className:`flex items-center justify-between gap-4 px-4 py-3 border-b border-border shrink-0`,children:[i(`div`,{className:`flex items-center gap-1 rounded-lg border border-border p-0.5 bg-surface`,children:[f(`button`,{type:`button`,onClick:()=>{t({view:`nodes`,node:r},{replace:!0})},className:[`px-3 py-1 rounded-md text-[11px] font-medium transition-colors`,n===`nodes`?`bg-background text-foreground shadow-sm`:`text-foreground-subtle hover:text-foreground`].join(` `),children:`Nodes`}),f(`button`,{type:`button`,onClick:()=>{t({view:`cameras`},{replace:!0})},className:[`px-3 py-1 rounded-md text-[11px] font-medium transition-colors`,n===`cameras`?`bg-background text-foreground shadow-sm`:`text-foreground-subtle hover:text-foreground`].join(` `),children:`Cameras`})]}),f(`div`,{className:`flex items-center gap-2`,children:i(`button`,{type:`button`,onClick:()=>o(e=>e+1),title:`Refresh`,className:`inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-[11px] font-medium border border-border text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,children:[f(de,{className:`h-3.5 w-3.5`}),`Refresh`]})})]}),n===`nodes`&&i(`button`,{type:`button`,onClick:()=>l(e=>!e),"aria-expanded":c,className:`md:hidden flex items-center justify-between gap-2 px-4 py-2 border-b border-border shrink-0 text-[11px] font-medium text-foreground-subtle hover:text-foreground transition-colors`,children:[i(`span`,{children:[c?`Hide`:`Show`,` node list`]}),f(w,{className:[`h-4 w-4 transition-transform`,c?`rotate-180`:``].join(` `)})]}),f(`div`,{className:`flex-1 flex flex-col md:flex-row overflow-hidden min-h-0`,children:n===`nodes`?i(s,{children:[f(`aside`,{className:[c?`block`:`hidden`,`md:block w-full md:w-72 shrink-0 border-b md:border-b-0 md:border-r border-border`,`max-h-[60vh] md:max-h-none overflow-y-auto`].join(` `),children:f(_n,{selectedNodeId:r,onSelect:e=>{t({view:`nodes`,node:e},{replace:!0}),l(!1)},refreshToken:a})}),f(`section`,{className:`flex-1 min-h-0 overflow-hidden`,children:r===`__cluster__`?f(fa,{refreshToken:a}):f(Nr,{nodeId:r,refreshToken:a})})]}):f(`section`,{className:`flex-1 min-h-0 overflow-hidden`,children:f(eo,{refreshToken:a})})})]})}var ao=`ctab`,oo=`section`;function so(e,t){let n=new URLSearchParams({view:`nodes`,node:no,[ao]:e});return t!==void 0&&n.set(oo,t),`/pipeline?${n.toString()}`}function co(){return so(`settings`,Rt)}function lo(){return so(`load-balancing`)}var uo=`pipeline-orchestrator`;function fo(e){return Ht.find(t=>t.stepId===e)??null}function po({step:e,engineFormat:t,runnableModelIds:n}){let{data:r}=U({addonId:uo}),a=Ut(r??null)[e.stepId]??e.defaultModelId,o=e.options.find(e=>e.id===a)?.label??a,s=n.length>0&&!n.includes(a);return i(`div`,{className:`space-y-2 rounded-md border border-primary/30 bg-primary/5 px-3 py-2`,children:[i(`div`,{className:`flex flex-wrap items-center gap-2 text-xs`,children:[f(`span`,{className:`font-medium text-foreground`,children:e.label}),f(`span`,{className:`font-mono text-foreground`,children:o}),f(`span`,{title:`One value for the whole cluster — this step writes into a shared vector index, where two encoders make similarity scores meaningless.`,className:`rounded border border-primary/40 bg-primary/10 px-1 py-px text-[9px] font-medium uppercase tracking-wide text-primary`,children:`cluster-wide`}),f($t,{to:co(),className:`ml-auto text-[11px] text-primary hover:underline`,children:`Change in Cluster → Settings → Enrichment models ›`})]}),i(`p`,{className:b,children:[`One model for every node and camera: `,e.indexName,` only matches vectors from the model that made them.`]}),s&&i(`p`,{className:`rounded border border-warning/40 bg-warning/10 px-2 py-1 text-[10px] leading-snug text-warning`,children:[`This accelerator's engine (`,t,`) ships no build of `,f(`b`,{children:a}),`. It refuses this step rather than run a different encoder — a substitute would put a second feature space into `,e.indexName,`.`]})]})}export{Sn as _,Sr as a,sr as c,pr as d,hr as f,ar as g,mr as h,Cr as i,yr as l,fr as m,fo as n,dr as o,vr as p,to as r,gr as s,po as t,_r as u,cn as v};
|