@camstack/addon-admin-ui 1.2.346 → 1.2.348
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-OuVXUb2R.js → AddonCollectionPage-_yxvmWjA.js} +1 -1
- package/dist/assets/Addons-DBf0ybML.js +1 -0
- package/dist/assets/{AdminTabs-B34HO9SX.js → AdminTabs-DWt_M6h9.js} +1 -1
- package/dist/assets/AiProfiles-B6tEY0ub.js +3 -0
- package/dist/assets/{BrokerForm-BJlbmwvE.js → BrokerForm-DOpzKaSm.js} +1 -1
- package/dist/assets/Build-BvbOrm3e.js +40 -0
- package/dist/assets/{Calendars-D1uzCOhs.js → Calendars-Bh2i5OF6.js} +1 -1
- package/dist/assets/{Capabilities-Cc744HMs.js → Capabilities-BX1hPOMh.js} +1 -1
- package/dist/assets/Cluster-BW2j2nbo.js +11 -0
- package/dist/assets/ClusterStepModel-DrDJCVi8.js +1 -0
- package/dist/assets/CompositionEditor-CwyHZd8k.js +1 -0
- package/dist/assets/{CompositionEditorPage-C96HNxaf.js → CompositionEditorPage-yB19Ht2l.js} +1 -1
- package/dist/assets/Data-C8CpD-Fl.js +1 -0
- package/dist/assets/DetectionIntelligence-dgmPpoOe.js +1 -0
- package/dist/assets/DeviceDetail-DRJ8XNsj.js +2 -0
- package/dist/assets/{DeviceDoActionFields-B7-D15mO.js → DeviceDoActionFields-CbRyrK08.js} +1 -1
- package/dist/assets/{Devices-xB7xhi-x.js → Devices-BRIz5kbZ.js} +1 -1
- package/dist/assets/{EmbedPlayerPage-CdNDOmcH.js → EmbedPlayerPage-CHdjdiM9.js} +1 -1
- package/dist/assets/Events-AcgwtHM-.js +1 -0
- package/dist/assets/Identity-MAV6XDz1.js +1 -0
- package/dist/assets/IntegrationDetail-BTmaVEOq.js +1 -0
- package/dist/assets/Integrations-DFK8_oJD.js +1 -0
- package/dist/assets/{Integrations-Cvpbz2Q-.js → Integrations-Djyge5jf.js} +1 -1
- package/dist/assets/Locations--0b0lrlN.js +3 -0
- package/dist/assets/{Logs-DIyu_pu9.js → Logs-BmOrVKGi.js} +1 -1
- package/dist/assets/{MotionZonesSettings-DXlx1HsV.js → MotionZonesSettings-CRuBx2bU.js} +1 -1
- package/dist/assets/{MyAccess-BwUOBgwC.js → MyAccess-uZ40KxW9.js} +1 -1
- package/dist/assets/Network-XMAONo9L.js +1 -0
- package/dist/assets/NodeAddonsSettingsPanel-cyZHvUKc.js +1 -0
- package/dist/assets/Notifications-CFd9vIhD.js +1 -0
- package/dist/assets/{Plates-D8Y0R51t.js → Plates-Dlezu_05.js} +1 -1
- package/dist/assets/{PrivacyMaskSettings-DVUn8Mky.js → PrivacyMaskSettings-7r3ohoeJ.js} +1 -1
- package/dist/assets/Recordings-DCnF7-Ht.js +1 -0
- package/dist/assets/{ScanNetworkModal-DV9JENky.js → ScanNetworkModal-BKcCVCQB.js} +1 -1
- package/dist/assets/{SceneMonitorEditor-CFMtvITX.js → SceneMonitorEditor-DUj6J57F.js} +1 -1
- package/dist/assets/{Scenes-CMYXE4-i.js → Scenes-DlILP9Pg.js} +1 -1
- package/dist/assets/{Settings-Dz9sRcfS.js → Settings-XaTkHjuF.js} +1 -1
- package/dist/assets/{Showroom-BuM6TkLZ.js → Showroom-DP0OG3G2.js} +1 -1
- package/dist/assets/{StorageLocationsPanel-CA0OuRsI.js → StorageLocationsPanel-DfndCZ76.js} +1 -1
- package/dist/assets/{Terminal-Dyf-hvYE.js → Terminal-CQaz387p.js} +3 -3
- package/dist/assets/{Viewer-DI4esFNH.js → Viewer-TzlNW1dn.js} +1 -1
- package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-CnBJTNz0.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-BTNDfqni.js} +1 -1
- package/dist/assets/{authed-media-DPnSX9WW.js → authed-media-C7bhw1Cr.js} +1 -1
- package/dist/assets/{boxes-IteirEWm.js → boxes-DIq8GWTc.js} +1 -1
- package/dist/assets/circle-slash-DEuk-dgU.js +1 -0
- package/dist/assets/client-BfaYET9G.js +357 -0
- package/dist/assets/{debounced-invalidate-DGOZqOFl.js → debounced-invalidate-cHS7a5Ch.js} +1 -1
- package/dist/assets/{device-integration-icon-BaKyBhuS.js → device-integration-icon-0SOdIPM_.js} +1 -1
- package/dist/assets/device-picker-model-NtdrmZcE.js +1 -0
- package/dist/assets/{dist-CZzcB9mq.js → dist-CXgSnfKu.js} +1 -1
- package/dist/assets/dist-DFXoD3dx.js +357 -0
- package/dist/assets/{face-bbox-CxD-_32k.js → face-bbox-B1lGcIQK.js} +1 -1
- package/dist/assets/{hard-drive-download-BFGgcG_C.js → hard-drive-download-DMR8KZuC.js} +1 -1
- package/dist/assets/{hostInit-Blv7dA1T.js → hostInit-BJPHWu0N.js} +1 -1
- package/dist/assets/index-BKKqO9Cm.js +4 -0
- package/dist/assets/index-C0nNc8D7.css +2 -0
- package/dist/assets/{layers-DgznI9ae.js → layers-C0RBisfX.js} +1 -1
- package/dist/assets/location-owned-usage--sVSZp8e.js +1 -0
- package/dist/assets/{mf-entry-bootstrap-0-fd422fe7.js → mf-entry-bootstrap-0-2d752fc4.js} +2 -2
- package/dist/assets/mount-NtdrmZcE.js +1 -0
- package/dist/assets/notification-schedule-field-BCdd_kV6.js +1 -0
- package/dist/assets/{player-overlays-De87F1cz.js → player-overlays-esCzPnEx.js} +1 -1
- package/dist/assets/remoteEntry-BtiPsjfA.js +1 -0
- package/dist/assets/{send-BBA-I8W_.js → send-DK_hCPRk.js} +1 -1
- package/dist/assets/{settings-2-ojQxHBW1.js → settings-2-BXcTE3EP.js} +1 -1
- package/dist/assets/{square-check-big-BqgK9d0q.js → square-check-big-BZkJ9pRU.js} +1 -1
- package/dist/assets/src-D_GC_nTn.js +67 -0
- package/dist/assets/{use-scenes-feed-C_bCyaAn.js → use-scenes-feed-Dx5H87hi.js} +1 -1
- package/dist/assets/{use-stationary-objects-Xkz9SuUO.js → use-stationary-objects-C6K_lhw5.js} +1 -1
- package/dist/assets/useEventInvalidation-NtdrmZcE.js +1 -0
- package/dist/assets/{useNodeUrlSelection-DIm89qHj.js → useNodeUrlSelection-CV5XbrOD.js} +1 -1
- package/dist/assets/user-round-DKJgggsz.js +1 -0
- package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-BKdHPLEl.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-TsjpXdmA.js} +2 -2
- package/dist/index.html +8 -8
- package/dist/server/addon.js +215 -172
- package/package.json +1 -1
- package/dist/assets/Addons-Br_npl16.js +0 -1
- package/dist/assets/AiProfiles-CaoNEv3v.js +0 -3
- package/dist/assets/Build-CsaPhDE0.js +0 -40
- package/dist/assets/Cluster-DhyF1lLr.js +0 -11
- package/dist/assets/CompositionEditor-Df1FQG4C.js +0 -1
- package/dist/assets/Data-Cffrbsu6.js +0 -1
- package/dist/assets/DetectionIntelligence-B4Jkxnko.js +0 -1
- package/dist/assets/DeviceDetail-Bgf0D4jA.js +0 -2
- package/dist/assets/Events-OAAuCL4P.js +0 -1
- package/dist/assets/Identity-B3kyzNiG.js +0 -1
- package/dist/assets/IntegrationDetail-CVw25eS2.js +0 -1
- package/dist/assets/Integrations-0JZWTTsb.js +0 -1
- package/dist/assets/Locations-4Jpi2tlN.js +0 -3
- package/dist/assets/Network-C7XNAK6J.js +0 -1
- package/dist/assets/NodeAddonsSettingsPanel-CDmJz2k6.js +0 -1
- package/dist/assets/NodeInferenceDevices-uIdS7eZp.js +0 -1
- package/dist/assets/Notifications-B6ArUZ5_.js +0 -1
- package/dist/assets/Pipeline-CFUwjXbD.js +0 -1
- package/dist/assets/Recordings-DolkikUb.js +0 -1
- package/dist/assets/archive-C53IZXYS.js +0 -1
- package/dist/assets/circle-slash-SLdwNdfV.js +0 -1
- package/dist/assets/client-Dc_lJW_Z.js +0 -357
- package/dist/assets/device-picker-model-C9OIAorb.js +0 -1
- package/dist/assets/dist-BlILRcih.js +0 -357
- package/dist/assets/index-BJCZa1JH.css +0 -2
- package/dist/assets/index-CFAN_ihV.js +0 -4
- package/dist/assets/location-owned-usage-BnNZODcS.js +0 -1
- package/dist/assets/mount-C9OIAorb.js +0 -1
- package/dist/assets/notification-schedule-field-D7eyUhAf.js +0 -1
- package/dist/assets/remoteEntry-MYmJJQ7k.js +0 -1
- package/dist/assets/src-Bky8i7mc.js +0 -67
- package/dist/assets/useEventInvalidation-C9OIAorb.js +0 -1
- package/dist/assets/user-round-D58o5nIZ.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Q as e,S as t,W as n,a as r,q as i,t as a,x as o}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 s}from"./player-overlays-De87F1cz.js";import{Ad as c,Ku as l,kd as u,lu as d,wn as f}from"./src-Bky8i7mc.js";import{t as p}from"./AdminPage-CiKtOLQm.js";e();var m={detection:`border-green-500`,detector:`border-green-500`,streaming:`border-blue-500`,decode:`border-blue-500`,decoder:`border-blue-500`,recording:`border-orange-500`,recorder:`border-orange-500`,transcoding:`border-purple-500`,transcoder:`border-purple-500`,restream:`border-cyan-500`,restreamer:`border-cyan-500`,storage:`border-yellow-500`,notification:`border-pink-500`,notifier:`border-pink-500`,faces:`border-indigo-500`},h={detection:`bg-green-500/5`,detector:`bg-green-500/5`,streaming:`bg-blue-500/5`,decode:`bg-blue-500/5`,decoder:`bg-blue-500/5`,recording:`bg-orange-500/5`,recorder:`bg-orange-500/5`,transcoding:`bg-purple-500/5`,transcoder:`bg-purple-500/5`,restream:`bg-cyan-500/5`,restreamer:`bg-cyan-500/5`,storage:`bg-yellow-500/5`,notification:`bg-pink-500/5`,notifier:`bg-pink-500/5`,faces:`bg-indigo-500/5`};function g({entry:e,actions:n}){let r=e.name.toLowerCase(),i=m[r]??`border-primary`,a=h[r]??`bg-primary/5`,s=e.providers.find(e=>e.active),c=n?.pendingCapability===e.name;return t(`div`,{className:`rounded-lg border-t-2 border border-border ${i} ${a} p-3 space-y-2`,children:[t(`div`,{className:`flex items-center justify-between gap-2`,children:[t(`span`,{className:`text-xs font-semibold text-foreground capitalize flex items-center gap-1.5`,children:[e.name,c&&o(l,{className:`h-3 w-3 animate-spin text-primary`})]}),o(`span`,{className:`rounded-full px-2 py-0.5 text-[10px] font-medium ${e.mode===`singleton`?`bg-primary/10 text-primary`:`bg-info/10 text-info`}`,children:e.mode})]}),e.mode===`singleton`?o(_,{entry:e,actions:n,activeProvider:s,isPending:c}):o(v,{entry:e,actions:n,isPending:c})]})}function _({entry:e,actions:n,activeProvider:r,isPending:i}){if(!n)return o(`div`,{children:r?t(`div`,{className:`flex items-center gap-1.5 text-[10px] text-foreground`,children:[o(u,{className:`h-3 w-3 text-green-400 shrink-0`}),o(`span`,{className:`font-medium`,children:r.addonName}),o(`span`,{className:`rounded-full bg-green-500/10 text-green-400 px-1.5 py-0.5 font-medium ml-auto`,children:`ACTIVE`})]}):o(`div`,{className:`text-[10px] text-foreground-subtle italic`,children:`No active provider`})});if(e.providers.length===0)return o(`div`,{className:`text-[10px] text-foreground-subtle italic`,children:`No providers`});let a=`__inherit__`;return t(`div`,{className:`space-y-2`,children:[o(`div`,{className:`space-y-1`,children:e.providers.map(r=>{let a=r.active;return t(`button`,{type:`button`,disabled:i||a,onClick:()=>n.onSelectSingleton(e.name,r.addonId),className:`flex w-full items-center gap-1.5 rounded px-1.5 py-1 text-[10px] text-left transition-colors ${a?`bg-green-500/10 text-foreground cursor-default`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground disabled:opacity-50`}`,children:[o(`span`,{className:`h-2.5 w-2.5 rounded-full border shrink-0 ${a?`border-green-400 bg-green-400`:`border-border`}`}),o(`span`,{className:`font-medium truncate`,children:r.addonName}),a&&o(`span`,{className:`rounded-full bg-green-500/10 text-green-400 px-1.5 py-0.5 font-medium ml-auto shrink-0`,children:`ACTIVE`})]},r.addonId)})}),e.perNode&&e.perNode.length>0&&o(`div`,{className:`space-y-2 pt-1 border-t border-border/40`,children:e.perNode.map(r=>{let s=r.hasOverride&&r.resolvedActive?r.resolvedActive:a,c=[{value:a,label:`Inherit global${r.resolvedActive?` (${r.resolvedActive})`:``}`},...r.providers.map(e=>({value:e,label:e}))],l=t=>{t===a?n.onClearNodeSingleton(e.name,r.nodeId):n.onSelectNodeSingleton(e.name,r.nodeId,t)},u=i;return t(`div`,{className:`space-y-0.5`,children:[t(`div`,{className:`text-[9px] font-semibold uppercase tracking-widest text-foreground-subtle/60 px-1.5`,children:[r.nodeId,r.hasOverride&&o(`span`,{className:`ml-1.5 rounded-full bg-primary/10 text-primary px-1 py-0.5 normal-case tracking-normal font-medium`,children:`override`})]}),c.map(e=>{let n=s===e.value;return t(`button`,{type:`button`,disabled:u||n,onClick:()=>l(e.value),className:`flex w-full items-center gap-1.5 rounded px-1.5 py-1 text-[10px] text-left transition-colors ${n?`bg-green-500/10 text-foreground cursor-default`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground disabled:opacity-50`}`,children:[o(`span`,{className:`h-2.5 w-2.5 rounded-full border shrink-0 ${n?`border-green-400 bg-green-400`:`border-border`}`}),o(`span`,{className:`font-medium truncate`,children:e.label}),n&&e.value!==a&&o(`span`,{className:`rounded-full bg-green-500/10 text-green-400 px-1.5 py-0.5 font-medium ml-auto shrink-0`,children:`ACTIVE`})]},e.value)})]},r.nodeId)})})]})}function v({entry:e,actions:n,isPending:r}){if(e.providers.length===0)return o(`div`,{className:`text-[10px] text-foreground-subtle italic`,children:`No providers`});if(!n)return o(`div`,{className:`space-y-1`,children:e.providers.map(e=>t(`div`,{className:`flex items-center justify-between gap-2 text-[10px]`,children:[o(`span`,{className:`text-foreground-subtle`,children:e.addonName}),e.active&&o(`span`,{className:`rounded-full bg-green-500/10 text-green-400 px-1.5 py-0.5 font-medium`,children:`ACTIVE`})]},e.addonId))});let i=e.providers.filter(e=>e.active).map(e=>e.addonId),a=(t,r)=>{let a=r?[...new Set([...i,t])]:i.filter(e=>e!==t);n.onToggleCollection(e.name,a)};return o(`div`,{className:`space-y-1`,children:e.providers.map(e=>t(`label`,{className:`flex items-center justify-between gap-2 text-[10px] rounded px-1.5 py-1 transition-colors ${r?`opacity-50`:`hover:bg-surface-hover cursor-pointer`}`,children:[t(`span`,{className:`flex items-center gap-1.5 min-w-0`,children:[o(`input`,{type:`checkbox`,checked:e.active,disabled:r,onChange:t=>a(e.addonId,t.target.checked),className:`h-3 w-3 accent-green-500 shrink-0`}),o(`span`,{className:`text-foreground truncate`,children:e.addonName})]}),e.active&&o(`span`,{className:`rounded-full bg-green-500/10 text-green-400 px-1.5 py-0.5 font-medium shrink-0`,children:`ACTIVE`})]},e.addonId))})}function y({capabilities:e,actions:t}){return e.length===0?o(`div`,{className:`text-xs text-foreground-subtle text-center py-8`,children:`No capabilities registered`}):o(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-3`,children:e.map(e=>o(g,{entry:e,actions:t},e.name))})}var b=[`capabilities`,`listCapabilities`];function x(e){return e===`singleton`||e===`collection`}function S(e){let t=e.indexOf(`@`);return t===-1?`${e} (hub)`:`${e.slice(0,t)} (${e.slice(t+1)})`}function C(e,t){return{name:e.name,mode:t,providers:e.providers.map(n=>({addonId:n,addonName:S(n),active:t===`singleton`?e.activeProvider===n:!e.disabledProviders.includes(n)})),...t===`singleton`&&e.perNode?{perNode:e.perNode}:{}}}function w(){let e=s(),[l,m]=i(null),[h,g]=i(null),_=r({queryKey:b,queryFn:()=>e.trpcClient.capabilities.listCapabilities.query()}),v=n(()=>{let e=(_.data??[]).flatMap(e=>x(e.mode)?[C(e,e.mode)]:[]),t=e.filter(e=>e.mode===`singleton`).toSorted((e,t)=>e.name.localeCompare(t.name)),n=e.filter(e=>e.mode===`collection`).toSorted((e,t)=>e.name.localeCompare(t.name));return[...t,...n]},[_.data]),S=n(()=>v.filter(e=>e.mode===`singleton`),[v]),w=n(()=>v.filter(e=>e.mode===`collection`),[v]),T=a({mutationFn:t=>e.trpcClient.capabilities.setActiveSingleton.mutate({capability:t.capName,addonId:t.addonId}),onMutate:e=>{m(e.capName),g(null)},onSuccess:async(e,t)=>{g({kind:`success`,message:`${t.capName} → ${t.addonId} is now active.`}),await _.refetch()},onError:(e,t)=>{g({kind:`error`,message:`Failed to set ${t.capName}: ${e instanceof Error?e.message:`unknown error`}`})},onSettled:()=>m(null)}),E=a({mutationFn:t=>e.trpcClient.capabilities.setActiveSingleton.mutate({capability:t.capName,addonId:t.addonId,nodeId:t.nodeId}),onMutate:e=>{m(e.capName),g(null)},onSuccess:async(e,t)=>{g({kind:`success`,message:`${t.capName} @ ${t.nodeId} → ${t.addonId}.`}),await _.refetch()},onError:(e,t)=>{g({kind:`error`,message:`Failed to set ${t.capName} @ ${t.nodeId}: ${e instanceof Error?e.message:`unknown error`}`})},onSettled:()=>m(null)}),D=a({mutationFn:t=>e.trpcClient.capabilities.clearSingletonNodeOverride.mutate({capability:t.capName,nodeId:t.nodeId}),onMutate:e=>{m(e.capName),g(null)},onSuccess:async(e,t)=>{g({kind:`success`,message:`${t.capName} @ ${t.nodeId} now inherits the global default.`}),await _.refetch()},onError:(e,t)=>{g({kind:`error`,message:`Failed to clear ${t.capName} @ ${t.nodeId}: ${e instanceof Error?e.message:`unknown error`}`})},onSettled:()=>m(null)}),O=a({mutationFn:t=>e.trpcClient.capabilities.setCollectionEnabledProviders.mutate({capability:t.capName,enabledAddonIds:[...t.enabledAddonIds]}),onMutate:e=>{m(e.capName),g(null)},onSuccess:async(e,t)=>{g({kind:`success`,message:`${t.capName}: ${t.enabledAddonIds.length} provider(s) enabled.`}),await _.refetch()},onError:(e,t)=>{g({kind:`error`,message:`Failed to update ${t.capName}: ${e instanceof Error?e.message:`unknown error`}`})},onSettled:()=>m(null)}),k={onSelectSingleton:(e,t)=>T.mutate({capName:e,addonId:t}),onSelectNodeSingleton:(e,t,n)=>E.mutate({capName:e,nodeId:t,addonId:n}),onClearNodeSingleton:(e,t)=>D.mutate({capName:e,nodeId:t}),onToggleCollection:(e,t)=>O.mutate({capName:e,enabledAddonIds:t}),pendingCapability:l};return t(p,{icon:d,title:`Capabilities`,subtitle:`Choose which provider is active for each system capability. Singleton caps pick exactly one provider; collection caps enable a set.`,children:[h&&t(`div`,{className:`flex items-center gap-2 rounded-md border px-3 py-2 text-xs ${h.kind===`success`?`border-green-500/30 bg-green-500/10 text-green-700 dark:text-green-300`:`border-danger/40 bg-danger/10 text-danger`}`,children:[h.kind===`success`?o(u,{className:`h-3.5 w-3.5 shrink-0`}):o(c,{className:`h-3.5 w-3.5 shrink-0`}),o(`span`,{children:h.message})]}),_.isLoading&&o(`div`,{className:`flex items-center justify-center py-16`,children:o(`div`,{className:`animate-spin h-6 w-6 border-2 border-primary border-t-transparent rounded-full`})}),_.isError&&!_.isLoading&&o(f,{title:`Failed to load capabilities`,message:_.error instanceof Error?_.error.message:`Unknown error`,onRetry:()=>void _.refetch()}),!_.isLoading&&!_.isError&&v.length===0&&o(`div`,{className:`text-xs text-foreground-subtle text-center py-16`,children:`No capabilities registered.`}),!_.isLoading&&!_.isError&&v.length>0&&t(`div`,{className:`space-y-6`,children:[S.length>0&&t(`section`,{className:`space-y-2`,children:[o(`h2`,{className:`text-[11px] font-semibold uppercase tracking-widest text-foreground-subtle/70`,children:`Singleton — pick one provider`}),o(y,{capabilities:S,actions:k})]}),w.length>0&&t(`section`,{className:`space-y-2`,children:[o(`h2`,{className:`text-[11px] font-semibold uppercase tracking-widest text-foreground-subtle/70`,children:`Collection — enable a set`}),o(y,{capabilities:w,actions:k})]})]})]})}export{w as CapabilitiesPage,w as default};
|
|
1
|
+
import{Q as e,S as t,W as n,a as r,q as i,t as a,x as o}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 s}from"./player-overlays-esCzPnEx.js";import{Bd as c,Fn as l,Vd as u,bu as d,rd as f}from"./src-D_GC_nTn.js";import{t as p}from"./AdminPage-CiKtOLQm.js";e();var m={detection:`border-green-500`,detector:`border-green-500`,streaming:`border-blue-500`,decode:`border-blue-500`,decoder:`border-blue-500`,recording:`border-orange-500`,recorder:`border-orange-500`,transcoding:`border-purple-500`,transcoder:`border-purple-500`,restream:`border-cyan-500`,restreamer:`border-cyan-500`,storage:`border-yellow-500`,notification:`border-pink-500`,notifier:`border-pink-500`,faces:`border-indigo-500`},h={detection:`bg-green-500/5`,detector:`bg-green-500/5`,streaming:`bg-blue-500/5`,decode:`bg-blue-500/5`,decoder:`bg-blue-500/5`,recording:`bg-orange-500/5`,recorder:`bg-orange-500/5`,transcoding:`bg-purple-500/5`,transcoder:`bg-purple-500/5`,restream:`bg-cyan-500/5`,restreamer:`bg-cyan-500/5`,storage:`bg-yellow-500/5`,notification:`bg-pink-500/5`,notifier:`bg-pink-500/5`,faces:`bg-indigo-500/5`};function g({entry:e,actions:n}){let r=e.name.toLowerCase(),i=m[r]??`border-primary`,a=h[r]??`bg-primary/5`,s=e.providers.find(e=>e.active),c=n?.pendingCapability===e.name;return t(`div`,{className:`rounded-lg border-t-2 border border-border ${i} ${a} p-3 space-y-2`,children:[t(`div`,{className:`flex items-center justify-between gap-2`,children:[t(`span`,{className:`text-xs font-semibold text-foreground capitalize flex items-center gap-1.5`,children:[e.name,c&&o(f,{className:`h-3 w-3 animate-spin text-primary`})]}),o(`span`,{className:`rounded-full px-2 py-0.5 text-[10px] font-medium ${e.mode===`singleton`?`bg-primary/10 text-primary`:`bg-info/10 text-info`}`,children:e.mode})]}),e.mode===`singleton`?o(_,{entry:e,actions:n,activeProvider:s,isPending:c}):o(v,{entry:e,actions:n,isPending:c})]})}function _({entry:e,actions:n,activeProvider:r,isPending:i}){if(!n)return o(`div`,{children:r?t(`div`,{className:`flex items-center gap-1.5 text-[10px] text-foreground`,children:[o(c,{className:`h-3 w-3 text-green-400 shrink-0`}),o(`span`,{className:`font-medium`,children:r.addonName}),o(`span`,{className:`rounded-full bg-green-500/10 text-green-400 px-1.5 py-0.5 font-medium ml-auto`,children:`ACTIVE`})]}):o(`div`,{className:`text-[10px] text-foreground-subtle italic`,children:`No active provider`})});if(e.providers.length===0)return o(`div`,{className:`text-[10px] text-foreground-subtle italic`,children:`No providers`});let a=`__inherit__`;return t(`div`,{className:`space-y-2`,children:[o(`div`,{className:`space-y-1`,children:e.providers.map(r=>{let a=r.active;return t(`button`,{type:`button`,disabled:i||a,onClick:()=>n.onSelectSingleton(e.name,r.addonId),className:`flex w-full items-center gap-1.5 rounded px-1.5 py-1 text-[10px] text-left transition-colors ${a?`bg-green-500/10 text-foreground cursor-default`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground disabled:opacity-50`}`,children:[o(`span`,{className:`h-2.5 w-2.5 rounded-full border shrink-0 ${a?`border-green-400 bg-green-400`:`border-border`}`}),o(`span`,{className:`font-medium truncate`,children:r.addonName}),a&&o(`span`,{className:`rounded-full bg-green-500/10 text-green-400 px-1.5 py-0.5 font-medium ml-auto shrink-0`,children:`ACTIVE`})]},r.addonId)})}),e.perNode&&e.perNode.length>0&&o(`div`,{className:`space-y-2 pt-1 border-t border-border/40`,children:e.perNode.map(r=>{let s=r.hasOverride&&r.resolvedActive?r.resolvedActive:a,c=[{value:a,label:`Inherit global${r.resolvedActive?` (${r.resolvedActive})`:``}`},...r.providers.map(e=>({value:e,label:e}))],l=t=>{t===a?n.onClearNodeSingleton(e.name,r.nodeId):n.onSelectNodeSingleton(e.name,r.nodeId,t)},u=i;return t(`div`,{className:`space-y-0.5`,children:[t(`div`,{className:`text-[9px] font-semibold uppercase tracking-widest text-foreground-subtle/60 px-1.5`,children:[r.nodeId,r.hasOverride&&o(`span`,{className:`ml-1.5 rounded-full bg-primary/10 text-primary px-1 py-0.5 normal-case tracking-normal font-medium`,children:`override`})]}),c.map(e=>{let n=s===e.value;return t(`button`,{type:`button`,disabled:u||n,onClick:()=>l(e.value),className:`flex w-full items-center gap-1.5 rounded px-1.5 py-1 text-[10px] text-left transition-colors ${n?`bg-green-500/10 text-foreground cursor-default`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground disabled:opacity-50`}`,children:[o(`span`,{className:`h-2.5 w-2.5 rounded-full border shrink-0 ${n?`border-green-400 bg-green-400`:`border-border`}`}),o(`span`,{className:`font-medium truncate`,children:e.label}),n&&e.value!==a&&o(`span`,{className:`rounded-full bg-green-500/10 text-green-400 px-1.5 py-0.5 font-medium ml-auto shrink-0`,children:`ACTIVE`})]},e.value)})]},r.nodeId)})})]})}function v({entry:e,actions:n,isPending:r}){if(e.providers.length===0)return o(`div`,{className:`text-[10px] text-foreground-subtle italic`,children:`No providers`});if(!n)return o(`div`,{className:`space-y-1`,children:e.providers.map(e=>t(`div`,{className:`flex items-center justify-between gap-2 text-[10px]`,children:[o(`span`,{className:`text-foreground-subtle`,children:e.addonName}),e.active&&o(`span`,{className:`rounded-full bg-green-500/10 text-green-400 px-1.5 py-0.5 font-medium`,children:`ACTIVE`})]},e.addonId))});let i=e.providers.filter(e=>e.active).map(e=>e.addonId),a=(t,r)=>{let a=r?[...new Set([...i,t])]:i.filter(e=>e!==t);n.onToggleCollection(e.name,a)};return o(`div`,{className:`space-y-1`,children:e.providers.map(e=>t(`label`,{className:`flex items-center justify-between gap-2 text-[10px] rounded px-1.5 py-1 transition-colors ${r?`opacity-50`:`hover:bg-surface-hover cursor-pointer`}`,children:[t(`span`,{className:`flex items-center gap-1.5 min-w-0`,children:[o(`input`,{type:`checkbox`,checked:e.active,disabled:r,onChange:t=>a(e.addonId,t.target.checked),className:`h-3 w-3 accent-green-500 shrink-0`}),o(`span`,{className:`text-foreground truncate`,children:e.addonName})]}),e.active&&o(`span`,{className:`rounded-full bg-green-500/10 text-green-400 px-1.5 py-0.5 font-medium shrink-0`,children:`ACTIVE`})]},e.addonId))})}function y({capabilities:e,actions:t}){return e.length===0?o(`div`,{className:`text-xs text-foreground-subtle text-center py-8`,children:`No capabilities registered`}):o(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-3`,children:e.map(e=>o(g,{entry:e,actions:t},e.name))})}var b=[`capabilities`,`listCapabilities`];function x(e){return e===`singleton`||e===`collection`}function S(e){let t=e.indexOf(`@`);return t===-1?`${e} (hub)`:`${e.slice(0,t)} (${e.slice(t+1)})`}function C(e,t){return{name:e.name,mode:t,providers:e.providers.map(n=>({addonId:n,addonName:S(n),active:t===`singleton`?e.activeProvider===n:!e.disabledProviders.includes(n)})),...t===`singleton`&&e.perNode?{perNode:e.perNode}:{}}}function w(){let e=s(),[f,m]=i(null),[h,g]=i(null),_=r({queryKey:b,queryFn:()=>e.trpcClient.capabilities.listCapabilities.query()}),v=n(()=>{let e=(_.data??[]).flatMap(e=>x(e.mode)?[C(e,e.mode)]:[]),t=e.filter(e=>e.mode===`singleton`).toSorted((e,t)=>e.name.localeCompare(t.name)),n=e.filter(e=>e.mode===`collection`).toSorted((e,t)=>e.name.localeCompare(t.name));return[...t,...n]},[_.data]),S=n(()=>v.filter(e=>e.mode===`singleton`),[v]),w=n(()=>v.filter(e=>e.mode===`collection`),[v]),T=a({mutationFn:t=>e.trpcClient.capabilities.setActiveSingleton.mutate({capability:t.capName,addonId:t.addonId}),onMutate:e=>{m(e.capName),g(null)},onSuccess:async(e,t)=>{g({kind:`success`,message:`${t.capName} → ${t.addonId} is now active.`}),await _.refetch()},onError:(e,t)=>{g({kind:`error`,message:`Failed to set ${t.capName}: ${e instanceof Error?e.message:`unknown error`}`})},onSettled:()=>m(null)}),E=a({mutationFn:t=>e.trpcClient.capabilities.setActiveSingleton.mutate({capability:t.capName,addonId:t.addonId,nodeId:t.nodeId}),onMutate:e=>{m(e.capName),g(null)},onSuccess:async(e,t)=>{g({kind:`success`,message:`${t.capName} @ ${t.nodeId} → ${t.addonId}.`}),await _.refetch()},onError:(e,t)=>{g({kind:`error`,message:`Failed to set ${t.capName} @ ${t.nodeId}: ${e instanceof Error?e.message:`unknown error`}`})},onSettled:()=>m(null)}),D=a({mutationFn:t=>e.trpcClient.capabilities.clearSingletonNodeOverride.mutate({capability:t.capName,nodeId:t.nodeId}),onMutate:e=>{m(e.capName),g(null)},onSuccess:async(e,t)=>{g({kind:`success`,message:`${t.capName} @ ${t.nodeId} now inherits the global default.`}),await _.refetch()},onError:(e,t)=>{g({kind:`error`,message:`Failed to clear ${t.capName} @ ${t.nodeId}: ${e instanceof Error?e.message:`unknown error`}`})},onSettled:()=>m(null)}),O=a({mutationFn:t=>e.trpcClient.capabilities.setCollectionEnabledProviders.mutate({capability:t.capName,enabledAddonIds:[...t.enabledAddonIds]}),onMutate:e=>{m(e.capName),g(null)},onSuccess:async(e,t)=>{g({kind:`success`,message:`${t.capName}: ${t.enabledAddonIds.length} provider(s) enabled.`}),await _.refetch()},onError:(e,t)=>{g({kind:`error`,message:`Failed to update ${t.capName}: ${e instanceof Error?e.message:`unknown error`}`})},onSettled:()=>m(null)}),k={onSelectSingleton:(e,t)=>T.mutate({capName:e,addonId:t}),onSelectNodeSingleton:(e,t,n)=>E.mutate({capName:e,nodeId:t,addonId:n}),onClearNodeSingleton:(e,t)=>D.mutate({capName:e,nodeId:t}),onToggleCollection:(e,t)=>O.mutate({capName:e,enabledAddonIds:t}),pendingCapability:f};return t(p,{icon:d,title:`Capabilities`,subtitle:`Choose which provider is active for each system capability. Singleton caps pick exactly one provider; collection caps enable a set.`,children:[h&&t(`div`,{className:`flex items-center gap-2 rounded-md border px-3 py-2 text-xs ${h.kind===`success`?`border-green-500/30 bg-green-500/10 text-green-700 dark:text-green-300`:`border-danger/40 bg-danger/10 text-danger`}`,children:[h.kind===`success`?o(c,{className:`h-3.5 w-3.5 shrink-0`}):o(u,{className:`h-3.5 w-3.5 shrink-0`}),o(`span`,{children:h.message})]}),_.isLoading&&o(`div`,{className:`flex items-center justify-center py-16`,children:o(`div`,{className:`animate-spin h-6 w-6 border-2 border-primary border-t-transparent rounded-full`})}),_.isError&&!_.isLoading&&o(l,{title:`Failed to load capabilities`,message:_.error instanceof Error?_.error.message:`Unknown error`,onRetry:()=>void _.refetch()}),!_.isLoading&&!_.isError&&v.length===0&&o(`div`,{className:`text-xs text-foreground-subtle text-center py-16`,children:`No capabilities registered.`}),!_.isLoading&&!_.isError&&v.length>0&&t(`div`,{className:`space-y-6`,children:[S.length>0&&t(`section`,{className:`space-y-2`,children:[o(`h2`,{className:`text-[11px] font-semibold uppercase tracking-widest text-foreground-subtle/70`,children:`Singleton — pick one provider`}),o(y,{capabilities:S,actions:k})]}),w.length>0&&t(`section`,{className:`space-y-2`,children:[o(`h2`,{className:`text-[11px] font-semibold uppercase tracking-widest text-foreground-subtle/70`,children:`Collection — enable a set`}),o(y,{capabilities:w,actions:k})]})]})]})}export{w as CapabilitiesPage,w as default};
|
|
@@ -0,0 +1,11 @@
|
|
|
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-esCzPnEx.js";import{$s as g,Au as _,Bl as v,Do as y,Fo as b,Gu as x,Io as S,Iu as C,Kl as w,Lo as T,Lu as E,Mc as ee,Nc as te,Oo as D,Os as ne,Pc as re,Po as O,Rt as ie,Ru as ae,St as oe,Vl as k,Wd as se,Yd as ce,Yn as le,ca as ue,cr as de,jc as A,ju as fe,kd as j,ku as pe,lr as me,or as he,rd as M,sr as ge,su as _e,tl as ve,uf as ye,xt as be,zt as xe}from"./src-D_GC_nTn.js";import{t as Se}from"./hard-drive-download-DMR8KZuC.js";import{Br as Ce}from"./client-BfaYET9G.js";import{t as N}from"./useTranslation-Bc5yH9V9.js";import{t as we}from"./NodeAddonsSettingsPanel-cyZHvUKc.js";import{t as P}from"./format-size-DIxKXxtj.js";import{n as Te,r as Ee,t as De}from"./useNodeUrlSelection-CV5XbrOD.js";var Oe=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=b(),x=S(),w=T(),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)}},ee=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)}},te=async n=>{let r=`${t}/${e.name}`;try{await w.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(pe,{className:`h-3.5 w-3.5 text-primary shrink-0`}):l(ce,{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:P(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(he,{children:[l(me,{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(ge,{align:`end`,className:`min-w-[70px] py-0.5`,children:je.map(e=>l(de,{onClick:()=>te(e),className:`h-auto px-2 py-1 text-[10px] font-mono ${e===g?`text-primary font-semibold`:``}`,children:e},e))})]}),l(`button`,{onClick:ee,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(C,{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(fe,{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(ae,{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(C,{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(oe,{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(be,{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=k(`metrics.node-processes-snapshot`,t=>t.nodeId===e),{data:i}=D({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=>P(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(E,{className:`h-3 w-3`}),` Refresh`]})}),l(ie,{columns:u,rows:c,rowKey:e=>e.pid,minWidthPx:880,mobileMode:`scroll`,maxBodyHeight:xe,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],z=[1,1.5,2,2.5,3,4,5],B=[4,3,5,2],V=1e-9;function He(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 z.some(e=>Math.abs(t-e)<V)}let n=e/10**Math.floor(Math.log10(e));return z.some(e=>Math.abs(n-e)<V)}function H(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 U(e,t){if(!Number.isFinite(e)||e<=0)return[];let n=B.find(n=>He(e/n,t))??B[B.length-1],r=e/n,i=[];for(let e=1;e<=n;e++)i.push(r*e);return i}var Ue=2.5;function W(e){return e*Ue}function G(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 We(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 Ge(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 Ke(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,Ze={height:R};function Qe({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=H(e.map(e=>e.value),25,`linear`),i=G(e,q,r,p),a=G(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:U(r,`linear`),upper:i,middle:a,base:o,gaps:Je(i),times:Ke(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(Y,{title:e,children:l(ct,{message:f})}):l(Y,{title:e,legend:r(o,{children:[l(st,{color:K.main,label:s}),l(st,{color:K.gc,label:u})]}),readout:x&&x.main!==null&&x.gc!==null?r(o,{children:[b!==void 0&&l(ot,{atMs:b.atMs,spanMs:v.spanMs}),l(X,{color:K.main,text:d(x.main)}),l(X,{color:K.gc,text:d(x.gc)})]}):null,children:r(`svg`,{ref:h,viewBox:`0 0 ${L} ${R}`,preserveAspectRatio:`none`,className:`w-full`,style:Ze,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($e,{ticks:v.ticks,max:v.max,formatValue:d}),l(at,{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(et,{spans:v.gaps}),l(`path`,{d:Ge(v.middle,v.base),fill:K.main,fillOpacity:.85}),l(`path`,{d:Ge(v.upper,v.middle),fill:K.gc,fillOpacity:.85,stroke:`var(--color-surface, transparent)`,strokeWidth:2}),l(`path`,{d:We(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 J({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=H(n.map(e=>e.value),u,d),t=G(n,q,e,f);return{max:e,ticks:U(e,d),projected:t,gaps:Je(t),times:Ke(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(Y,{title:e,children:l(ct,{message:s})}):l(Y,{title:e,readout:v&&v.value!==null?r(o,{children:[_!==void 0&&l(ot,{atMs:_.atMs,spanMs:g.spanMs}),l(X,{color:K.main,text:i(v.value)})]}):null,children:r(`svg`,{ref:p,viewBox:`0 0 ${L} ${R}`,preserveAspectRatio:`none`,className:`w-full`,style:Ze,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($e,{ticks:g.ticks,max:g.max,formatValue:i}),l(at,{ticks:g.times,spanMs:g.spanMs}),r(`g`,{transform:`translate(34,${I})`,children:[l(et,{spans:g.gaps}),l(`path`,{d:We(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 $e({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 et({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 tt=10*6e4,nt={hour:`2-digit`,minute:`2-digit`},rt={hour:`2-digit`,minute:`2-digit`,second:`2-digit`};function it(e,t){return new Date(e).toLocaleTimeString(void 0,t<tt?rt:nt)}function at({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:it(e.atMs,t)},e.atMs))})}function ot({atMs:e,spanMs:t}){return l(`span`,{className:`text-[10px] tabular-nums text-foreground-subtle`,children:it(e,t)})}function Y({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 st({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 X({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 ct({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 lt(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 ut(e,t,n,r){let i=e.get(t),a=lt(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 dt(e,t,n){let r=e;for(let e of Ce(t,n))r=ut(r,e.key,e.kind,e.point);return r}function ft(e,t){let n=e;for(let e of t)for(let t of e.points)n=ut(n,e.key,e.kind,t);return n}function pt(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 mt=12e4;function ht(e,t){return e===null?!1:t-e>mt}function gt(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 _t(e){for(let t of e.values()){let e=t.points.at(-1);if(e&&e.cpuMainPercent!==null)return!0}return!1}var vt={key:`cpu`,dir:`desc`};function yt(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 bt(e){return e.points.at(-1)?.memoryRssBytes??null}function xt(e,t,n){let r=n.trim().toLowerCase();return r===``?!0:e.toLowerCase().includes(r)||t.toLowerCase().includes(r)}function St(e,t){return t===`memory`?bt(e):yt(e)}function Ct(e,t,n){let r=e.filter(e=>t.selectedKeys.size>0&&!t.selectedKeys.has(e.key)?!1:xt(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=St(e,t.sort.key),o=St(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 wt(e,n=720){let r=k(`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}=y({forNodeId:e,sinceMs:o,maxPoints:n});u(()=>{d!==void 0&&a(e=>{let t=ft(e,d.series);return l.current=pt(t),t})},[d]);let p=r?.timestamp;u(()=>{r==null||p===void 0||(ht(l.current,p)&&s(l.current??0),a(e=>{let t=dt(e,r.processes,p);return l.current=pt(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:gt(i),sampleCount:m,threadSplitAvailable:_t(i),loadingRetained:f,durable:d?.durable??null,bucketMs:d?.bucketMs??null,cadenceMs:d?.cadenceMs??null,retainedSamples:d?.retainedSamples??null}}var Tt=`__unclaimed__`;function Et(e,t){return{kind:e,deviceId:t,cpu:0,cpuKnown:!0,rss:0,rssKnown:!0,count:0,roles:new Set}}function Dt(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 Ot(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)??Et(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])=>Dt(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=Et(`unclaimed`,null);for(let e of a)o.count+=1,o.rss+=e.memoryRssBytes;return o.cpuKnown=!1,[...i,Dt(Tt,o)]}var kt=[{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 At(e){return e.attribution===`measured`&&e.wiredToday}function jt(){let e=new Set;for(let t of kt)At(t)&&e.add(t.family);return e}var Mt=jt();function Nt(e){return!Mt.has(e.role)||e.deviceId===null?!1:e.attribution===`measured`}function Pt(e){return`${e.addonId}${e.role}${e.unit}${e.pid??`-`}`}function Ft(){return{cpuSeconds:0,cpuKnown:!0,rssBytes:0,rssKnown:!0,unitCount:0,roles:new Set}}function It(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 Lt(e){return Math.round(e*10)/10}function Rt(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)Nt(t)&&i.set(Pt(t),t);let a=new Map,o=new Set;for(let n of t.entries){if(!Nt(n)||n.deviceId===null)continue;let t=Pt(n);o.add(t);let r=a.get(n.deviceId)??Ft();r.unitCount+=1,r.roles.add(n.role);let s=It(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?Lt(n.cpuSeconds/r*100):null,rssBytes:n.rssKnown?n.rssBytes:null,unitCount:n.unitCount,roles:[...n.roles].toSorted()}}))}function zt(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 Bt(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 Vt(e){let t=e.indexOf(`@`);return t===-1?{addonId:e,nodeId:null}:{addonId:e.slice(0,t),nodeId:e.slice(t+1)}}function Ht(e,t){let n=Vt(e);return n.nodeId===null?t.isHub:n.nodeId===t.nodeId}function Z(e,t){return e.filter(e=>Ht(e.addonId,t))}n();function Ut(e){let n=k(`metrics.node-processes-snapshot`,t=>t.nodeId===e.nodeId),r=ve(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:Z(d,e)},n=o.current;if(o.current=t,n===null)return;let r=Rt(n,t);r.length!==0&&a(e=>zt(e,r))},[d,f,e.nodeId,e.isHub]);let p=d===void 0?[]:Z(d,e),m=n?.processes,h=Ot(p,m);return{series:Bt(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}=N(),i=Ut(e),{data:a=[]}=ue({isCamera:!0,projection:`slim`}),o=Wt(a),s=W(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(_e,{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(J,{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(J,{title:n(`cameraLoad.memoryTitle`,`Memory RSS`),points:e.points.map(e=>({atMs:e.atMs,value:e.rssBytes})),formatValue:P,axisFloor:Kt,axisScale:`bytes`,gapMs:s,emptyMessage:n(`cameraLoad.memoryUnavailable`,`No memory reported.`)})]})]},e.deviceId))})]})}function Yt({deviceId:e,name:t}){let{t:n}=N();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}=N();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?`—`:P(e.rssBytes)})})})}n();var Zt=256*1024*1024,Qt=1e4;function $t({nodeId:e,isHub:t}){let{t:n}=N(),{series:i,sampleCount:o,threadSplitAvailable:s,loadingRetained:u,bucketMs:d,cadenceMs:f}=wt(e),[p,m]=c(``),[h,g]=c(new Set),[v,y]=c(vt),b=e=>e.key===`__root__`?n(`clusterLoad.bucketRoot`,`Node supervisor`):e.key===`__unattributed__`?n(`clusterLoad.bucketUnattributed`,`Unattributed processes`):e.key,x=W(d??f??Qt),S=a(()=>Ct(i,{search:p,selectedKeys:h,sort:v},b),[i,p,h,v]),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(_e,{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(_,{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:v,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(w,{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(Qe,{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(J,{title:n(`clusterLoad.memoryTitle`,`Memory RSS`),points:e.points.map(e=>({atMs:e.atMs,value:e.memoryRssBytes})),formatValue:P,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}=N();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}=N(),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(we,{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}=ne({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=g({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(ie,{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:xe})}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=O({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(se,{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(w,{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(x,{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}=N(),i=s(),a=le(),[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=A({onSettled:g}),y=re({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`}}},w=()=>{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`,D=t.isOnline&&h!=null&&!T&&h.updateAvailable&&h.updateState===`idle`&&!v.isPending,ne=t.isOnline&&h!=null&&h.updateState===`idle`&&!y.isPending,O=t.isOnline?w():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()})]}),O!=null&&l(ln,{...O})]}),!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(M,{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(M,{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(M,{className:`h-3.5 w-3.5 animate-spin`}):l(E,{className:`h-3.5 w-3.5`}),n(`serverManagement.checkForUpdate`,`Check for update`)]}),D&&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(M,{className:`h-3.5 w-3.5 animate-spin`}):l(ye,{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:!ne,onClick:()=>void x(),children:[y.isPending?l(M,{className:`h-3.5 w-3.5 animate-spin`}):l(C,{className:`h-3.5 w-3.5`}),n(`serverManagement.restart`,`Restart`)]})]}),t.isOnline&&h?.lastCheckedAtMs!=null&&r(`p`,{className:`flex items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[l(Se,{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(j,{className:`h-3 w-3`}),` `,e.cpuPercent,`%`]}),r(`span`,{className:`flex items-center gap-1`,children:[l(Oe,{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}=N(),a=Te(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}=N();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(j,{className:`h-3 w-3`}),e.cpuPercent,`%`,l(Oe,{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}=v(),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}=N(),n=le(),{nodes:i,isLoading:o}=wn(),{selection:s,selectNode:u}=De(i),f=s.node,p=a(()=>i.filter(e=>e.isOnline),[i]),m=p.length,h=i.filter(e=>!e.isOnline).length,g=A(),_=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(M,{className:`h-3.5 w-3.5 animate-spin`}):l(ye,{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(Ee,{staleNodeId:s.staleNodeId,shownNodeName:f?.name??``}),l(hn,{nodes:i,selected:f,onSelect:u})]})]})}export{En as ClusterPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-Cyuzqnbw.js";import{I as t,K as n,Q as r,S as i,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-esCzPnEx.js";import{$t as A,As as j,Bl as M,C as N,Cd as P,D as F,E as I,F as L,Fn as R,Gl as ee,Gs as te,Gu as ne,Hl as re,Hs as ie,In as ae,Is as oe,Kl as se,Ks as ce,Ln as le,Ls as ue,Lt as de,Lu as fe,M as pe,Ms as me,Ns as he,O as ge,Ot as _e,Ps as ve,Rn as z,Rs as ye,Ru as be,S as xe,Sn as Se,Ss as Ce,St as we,T as Te,Ts as Ee,Ul as De,Us as Oe,Uu as ke,V as Ae,Vd as je,Vl as Me,Vs as Ne,Wd as B,Wl as Pe,Ws as Fe,Xl as Ie,Yn as Le,Zu as Re,_n as ze,_s as Be,ac as Ve,an as He,bn as Ue,bs as We,cc as Ge,cn as Ke,ec as qe,eu as Je,fn as Ye,fr as Xe,gn as Ze,gr as Qe,gs as $e,gu as et,hd as tt,hn as nt,hs as rt,ht as it,ic as at,in as ot,kd as V,kn as st,ks as ct,ku as lt,ln as ut,mn as dt,ms as ft,nc as pt,nd as mt,oc as ht,od as gt,on as _t,pf as vt,pr as H,ps as yt,qs as bt,r as xt,rc as St,rd as Ct,rn as wt,rr as U,sn as Tt,su as Et,tc as Dt,td as Ot,un as kt,vd as At,vn as jt,vs as Mt,w as Nt,xn as Pt,xs as Ft,ys as It,zl as W,zs as Lt}from"./src-D_GC_nTn.js";import{t as Rt}from"./layers-C0RBisfX.js";import{t as zt}from"./square-check-big-BZkJ9pRU.js";import{n as Bt}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 Vt,Dn as Ht,En as Ut,Mr as Wt,Sn as Gt,Tn as Kt,f as qt,jr as Jt,ni as Yt,ti as Xt,wn as Zt,xn as Qt}from"./client-BfaYET9G.js";import{B as $t,E as en,F as G,M as tn}from"./index-BKKqO9Cm.js";import"./useEventInvalidation-NtdrmZcE.js";import{t as nn}from"./NodeAddonsSettingsPanel-cyZHvUKc.js";import{t as rn}from"./StorageLocationsPanel-DfndCZ76.js";var an=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`}]]),on=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`}]]),sn=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`}]]),cn=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`}]]),ln=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`}]]),un=`step`,dn=`compare`,fn=[un,`acc`,dn];function pn(e,t){return`${e}/${t}`}function mn(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:e[0]??null,acceleratorId:i?n.acc:t[0]??null,compare:n.compare===`1`,staleStepId:n.step!==null&&n.step!==``&&!r&&e.length>0?n.step:null}}function hn(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 gn(e){return e}function _n(e,t){for(let[n,r]of Object.entries(e??{}))if(n===t)return r}function vn(e,t){return typeof e==`boolean`?e:gn(t)}function yn(e,t){return{pipeline:vn(_n(e,`detect`),t),audio:vn(_n(e,`audio`),t),ingest:vn(_n(e,`ingest`),t)}}function bn(e,t,n){let r=e?.find(e=>e.nodeId===t);return yn(r?.settings,n)}function xn({selectedNodeId:e,onSelect:t,refreshToken:n}){let{nodes:r}=M(),{data:a}=me(void 0),{data:o}=oe(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(oo),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($t,{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?lt:V,u=bn(o,n.id,n.isHub),d=n.isOnline?null:it(hn(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(Je,{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(U,{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(U,{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 Sn({nodeId:e,refreshToken:t}){let{nodes:n}=M(),r=n?.find(t=>t.id===e),a=Me(`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 Cn=[`assignments`,`tree`,`engines`,`logs`];r();function wn({refreshToken:e,nodeId:t}){let[n,r]=d(new Map),{nodes:a}=W();De(`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}=Ce(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(K,{label:`FPS`,value:e?e.totalFps.toFixed(1):`—`}),f(K,{label:`Active / Attached`,value:e?`${e.activeCameras}/${e.attachedCameras}`:`—`}),f(K,{label:`Avg infer ms`,value:e&&e.attachedCameras>0?(e.totalInferenceWeighted/e.attachedCameras).toFixed(0):`—`}),f(K,{label:`Queue`,value:e?String(e.queueDepth):`—`}),f(K,{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(K,{label:`Total agents`,value:`${p.onlineAgents}/${p.totalAgents}`}),f(K,{label:`Active / Attached`,value:`${p.activeCameras}/${p.attachedCameras}`}),f(K,{label:`Total FPS`,value:p.totalFps.toFixed(1)}),f(K,{label:`Avg inference ms`,value:p.avgInferenceTimeMs.toFixed(0)}),f(K,{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 K({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 Tn(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 En(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 Dn(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 On(e,t,n){return Math.min(Math.max(e,t),n)}function kn(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 An(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:On(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 jn(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 Mn({nodes:e,pending:t,onCommitWeights:n,weightLabel:r=`Detection weight`,emptyHint:a,footnote:o,readOnly:c=!1}){let[l,u]=d(()=>kn(e)),[m,h]=d(new Set);p(()=>{u(kn(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=>An(n,e,t,m,g))},y=()=>{let t=jn(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?Ot:mt,{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 Nn(e){let t=e.backend.toLowerCase(),n=e.device.toLowerCase();return e.key===`cpu`||n===`cpu`?{label:`CPU`,Icon:V,hue:`slate`}:t===`openvino`&&n===`npu`?{label:`Intel NPU (AI Boost)`,Icon:ee,hue:`sky`}:t===`openvino`&&(n===`gpu`||n===`igpu`)?{label:`Intel iGPU`,Icon:an,hue:`violet`}:t===`edgetpu`?{label:`Coral Edge TPU`,Icon:ln,hue:`emerald`}:{label:`${e.backend} ${e.device}`.replace(/\b\w/g,e=>e.toUpperCase()).trim(),Icon:V,hue:`slate`}}var Pn={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 Fn({nodeId:e,nodeName:t,isOnline:n,suggestedMaxSessions:r,autoDeviceShares:a}){let c=l(),{data:u,isLoading:m}=j({nodeId:e},{refetchInterval:15e3}),h=te({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:Dn(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:Nn(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(Rt,{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(Ie,{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=Nn(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 ${Pn[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(U,{variant:`default`,style:`outline`,className:`font-mono text-[9px]`,children:e.format}),!e.available&&f(U,{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(In,{suggested:r?.[e.key]??null,current:n.maxSessions,pending:h.isPending,onApply:t=>O(e,t)}),f(kt,{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(Ln,{}),_&&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(cn,{className:`h-3.5 w-3.5`}),`Accelerator share`]}),f(Mn,{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 In({suggested:e,current:t,pending:n,onApply:r}){return e===null||e<1||e===t?null:i(z,{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 Ln(){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(Ie,{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 Rn={active:!1,pinned:!1,nodeId:null,reason:``},zn=[`pipeline.camera-assigned`,`pipeline.camera-unassigned`,`pipeline.camera-updated`,`agent.online`,`agent.offline`],Bn=3e5,Vn={pipeline:V,decoder:At,audio:O},Hn={pipeline:`Pipeline`,decoder:`Decoder`,audio:`Audio`};function Un({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);xt([`pipelineOrchestrator`,`getPipelineAssignments`],zn),xt([`pipelineOrchestrator`,`getAudioAssignments`],zn),xt([`pipelineOrchestrator`,`getCameraStatuses`],zn);let{data:v}=me(void 0),{data:y}=Ft(void 0),{data:b}=Ee({},{enabled:e===`agent`}),{nodes:x}=W(),{data:S}=en();De(`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:Rn,decoder:Rn,audio:Rn};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=Mt({onSuccess:O}),A=Ve({onSuccess:O}),j=Be({onSuccess:O}),M=at({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(Gn,{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(qn,{state:t.pipeline,deviceId:t.deviceId})})]}):i(s,{children:[f(Yn,{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(Yn,{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(Yn,{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($n,{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(Wn,{deviceId:t.deviceId,nodeId:t.pipeline.nodeId}),f(st,{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 Wn({deviceId:e,nodeId:t}){let n=l(),{data:r}=j({nodeId:t}),{data:a}=he({deviceId:e}),o=Dt({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 Gn({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 Kn(e){let t=n(null);return e.nodeId!==null&&(t.current=e),t.current}function qn({state:e,deviceId:t}){let n=Kn(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(Jn,{deviceId:t,nodeId:n.nodeId})]})}function Jn({deviceId:e,nodeId:t}){let n=l(),{data:r}=he({deviceId:e},{refetchOnMount:`always`}),{data:a}=j({nodeId:t},{staleTime:Bn}),o=Dt({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?`${Nn(p).label} (${u})`:u,` (not enabled)`]}),c.map(e=>i(`option`,{value:e.key,children:[Nn(e).label,` · `,e.format]},e.key))]})}function Yn({role:e,state:t,mode:n,onlineNodes:r,readOnly:a=!1,isMenuOpen:o,onToggleMenu:s,onCloseMenu:c,onMove:l,onUnpin:u}){let d=Vn[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`?Xn:Zn,{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":`${Hn[e]} actions`,children:f(P,{className:`h-3 w-3 text-foreground-subtle`})})})]}),o&&m&&f(er,{title:Hn[e],targets:p,pinned:t.pinned,onMove:l,onUnpin:u,onClose:c})]})}function Xn({state:e,Icon:t}){return i(`div`,{className:`flex items-center gap-1.5`,children:[f(e.active?zt: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(sn,{className:`h-2.5 w-2.5 text-amber-400`})]})}function Zn({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(sn,{className:`h-2.5 w-2.5`}),` manual`]}):i(`span`,{className:`text-foreground-subtle truncate`,children:[`auto · `,e.reason||`capacity`]})})]})]})}var Qn=`min-h-[3.25rem]`;function $n({snap:e}){if(!e)return f(`div`,{className:`flex items-center ${Qn}`,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=_e(t);return i(`div`,{className:`flex flex-col justify-center gap-0.5 font-mono text-[10px] tabular-nums leading-tight min-w-0 ${Qn}`,children:[i(`span`,{className:`inline-flex items-center gap-1 min-w-0 ${c.textColor}`,children:[f(L,{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 er({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 tr({nodeId:e,refreshToken:t}){return i(`div`,{className:`space-y-6`,children:[f(wn,{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(Un,{mode:`agent`,nodeId:e,compact:!0})]})}r();function nr(e,t){let n=Math.max(0,t-e);return`${Math.floor(e/1e3)}s idle · ${Math.floor(n/1e3)}s left`}function rr({nodeId:e,refreshToken:t}){let n=l(),r=Le(),a=ft({onSettled:()=>{n.invalidateQueries({queryKey:[`pipelineExecutor`,`listLoadedEngines`]})}}),{data:s}=rt({nodeId:e}),c=Me(`pipeline.engine-metrics-snapshot`,t=>t.nodeId===e)?.engines??s??null,u=c===null;xt([`pipelineRunner`,`getLocalCameras`],[`pipeline.camera-assigned`,`pipeline.camera-unassigned`]);let{data:d}=Ge({nodeId:e}),{values:p}=re(`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?Rt:V,{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(ee,{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:nr(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 ir=`pipeline-runner`,ar=200;function or({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(we,{agentId:e,addonId:ir,limit:ar,maxHeight:`max-h-[calc(100vh-360px)]`,showScope:!0,showDeviceChip:!0,showFilters:!1})})]})}r();function sr({nodeId:e,title:t}){let{data:n}=en(),{data:r}=me(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);De(`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=_e(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(L,{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 cr=`pipeline-orchestrator`;function lr({addonId:e,highlightLabel:t}){let n=Zt(e),{data:r}=H({addonId:cr});if(n.length===0)return null;let a=Ut(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(tn,{to:po(),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 ur(e,n){let[r,i]=G(),a=r.get(un),s=r.get(`acc`),c=r.get(dn);return{selection:o(()=>mn(e,n,{step:a,acc:s,compare:c}),[e,n,a,s,c]),select:t(e=>{i(t=>{let n=new URLSearchParams(t);return e.stepId!==void 0&&n.set(un,e.stepId),e.acceleratorId!==void 0&&n.set(`acc`,e.acceleratorId),e.compare!==void 0&&(e.compare?n.set(dn,`1`):n.delete(dn)),n},{replace:!0})},[i])}}r();function dr(e){return{agentNodeId:e.nodeId,engineLabel:e.device.format,deviceKey:e.deviceKey,deviceLabel:e.label.split(` · `).slice(1).join(` · `)}}function fr({tree:e,rows:r,accelerators:a,cellState:s,dirty:c,onDiscard:l,toolbar:u,summary:p,listLabel:m,renderDetail:h}){let g=Le(),_=A(),{selection:v,select:y}=ur(o(()=>r.map(e=>e.addonId),[r]),o(()=>a.map(e=>e.id),[a])),[b,x]=d(null),[S,C]=d(!1),[w,T]=d(null),E=n(null),D=n(null),O=t(async e=>{if(c){if(!await g({title:`Discard unsaved changes?`,message:`This step has changes that are not saved yet.`,confirmLabel:`Discard`,variant:`danger`}))return;l()}e()},[g,c,l]),k=(e,t)=>{if(e===v.stepId){x(t??null);return}O(()=>{x(t??null),y({stepId:e})})},j=()=>{C(!0),requestAnimationFrame(()=>D.current?.focus())},M=o(()=>a.map(dr),[a]),N=e=>a.find(t=>t.nodeId===e.agentNodeId&&t.deviceKey===e.deviceKey),P=h({selection:v,matchedField:b,selectAccelerator:e=>y({acceleratorId:e}),backButton:_&&S?f(I,{onClick:()=>C(!1)}):null,onEscape:()=>{C(!1),E.current?.focusSelected()},headingRef:e=>{D.current=e}});return i(`div`,{className:`space-y-2`,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 sm:flex-1`,children:p}),f(z,{variant:v.compare?`secondary`:`outline`,size:`sm`,"aria-pressed":v.compare,onClick:()=>y({compare:!v.compare}),className:v.compare?`ring-1 ring-primary/60 text-primary`:void 0,children:`Compare accelerators`}),u]}),v.staleStepId!==null&&i(`p`,{className:`rounded-md border border-amber-500/40 bg-amber-500/10 px-3 py-1.5 text-[11px] text-amber-500`,children:[`The link names a step this pipeline does not have (`,v.staleStepId,`) — showing the first step instead.`]}),v.compare?f(Ae,{tree:e,agents:M,getCellState:(e,t)=>{let n=N(t);return n===void 0?{kind:`na`}:s(e,n)},onCellClick:(e,t)=>{let n=N(t);O(()=>{x(null),y({stepId:e,...n?{acceleratorId:n.id}:{},compare:!1})})},selectedCell:v.stepId===null?null:{addonId:v.stepId,agentNodeId:a.find(e=>e.id===v.acceleratorId)?.nodeId??``,...v.acceleratorId===null?{}:{deviceKey:a.find(e=>e.id===v.acceleratorId)?.deviceKey}},fallbackNodeId:w,onFallbackNodeChange:T}):f(F,{list:f(Nt,{ref:E,rows:r,selectedId:v.stepId,onSelect:k,onPick:()=>C(!0),onActivate:()=>j(),label:m}),detail:P,mobileDetailOpen:S,onMobileClose:()=>C(!1)})]})}function pr(e,t){for(let n of e?.slots??[])for(let e of n.addons)if(e.id===t)return e;return null}function mr(e){let t=e.backend.toLowerCase(),n=e.device.toLowerCase();return e.key===`cpu`||n===`cpu`?`CPU`:n===`npu`?`NPU`:n===`gpu`||n===`igpu`?`iGPU`:t===`edgetpu`?`Coral`:t===`coreml`?`CoreML`:e.backend}function hr(e){return e.split(`.`)[0]??e}function gr(e,t,n){return{id:pn(e,n.key),nodeId:e,deviceKey:n.key,device:n,label:`${hr(t)} · ${Nn(n).label}`,shortLabel:`${hr(t)} · ${mr(n)}`}}function _r(e,t,n){return n.filter(e=>e.enabled).map(n=>gr(e,t,n))}function vr(e,t){return e.flatMap(e=>{let n=t[e.id]??[],r=n.filter(e=>e.enabled&&e.available);if(r.length>0)return r.map(t=>gr(e.id,e.name,t));let i=n.find(e=>e.available)??n[0];return i===void 0?[]:[gr(e.id,e.name,i)]})}function yr(e,t,n){return{modelId:Ue({catalog:e,device:t.device,base:n.nodePin,override:n.cameraPin}),source:n.cameraPin===void 0?n.nodePin===void 0?`default`:`node`:`camera`}}function br(e,t,n){let r=pr(e,`object-detection`);if(r===null)return;let i=Ue({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 xr(e,t,n){return!Jt(e)||n===void 0?!1:Wt(e,t,n.supplies).effective}function Sr(e,t){return e!==null&&Pt(e.models,t.device.format)}function Cr(e){return Sr(e.addon,e.acc)?e.clusterModelId===void 0?{kind:`enabled`,modelId:e.model.modelId??`Auto`,overridden:e.model.source===`camera`,...e.rootName===void 0?{}:{suppliedByRoot:e.rootName},...e.jumpTo===void 0?{}:{jumpTo:e.jumpTo}}:{kind:`enabled`,modelId:e.clusterModelId,clusterWide:!0}:e.gatedOn?e.jumpTo===void 0?{kind:`skip`}:{kind:`skip`,jumpTo:e.jumpTo}:{kind:`na`}}function wr(e){if(e===null)return[];let t=(e.configSchema??[]).flatMap(e=>`label`in e&&typeof e.label==`string`?[e.label]:[]),n=Zt(e.id).map(e=>e.label);return[...new Set([...t,...n])]}function Tr(e){return e.flatMap(e=>[{node:e,depth:0},...Tr(e.children).map(e=>({node:e.node,depth:e.depth+1}))])}r();function Er(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 Dr(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 Or(e,t){let n=t.settings===void 0?void 0:Dr(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:Tn(r,n,t.stepId)}function kr(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=>!qt(n[e],t.settings?.[e])).length;return r+i+o}function Ar({nodeId:e,nodeName:t,toolbar:n}){let r=l(),a=j({nodeId:e},{refetchOnMount:`always`}),c=yt({nodeId:e},{refetchOnMount:`always`}),u=Kt(H({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=te({onSuccess:()=>{r.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getNodeInferenceDevices`]]})}}),w=o(()=>m?xe(m):[],[m]),T=o(()=>Tr(w),[w]),E=o(()=>_r(e,t,p),[e,t,p]),D=E.length>=2,O=(e,t)=>(t===void 0?void 0:En(p,t.deviceKey,e))??{},k=(e,t,n)=>{let r=n??t.device.steps?.[e?.id??``]?.jumpDeviceKey;if(r!==void 0&&r!==``)return E.find(e=>e.deviceKey===r);if(!Sr(e,t))return E.filter(n=>n.id!==t.id&&Sr(e,n)).toSorted((e,t)=>e.deviceKey.localeCompare(t.deviceKey))[0]},A=(e,t)=>{let n=pr(m,e),r=go(e),i=br(m,t),a=O(e,t),o=k(n,t);return Cr({addon:n,acc:t,gatedOn:n?.enabledByDefault??!0,model:n?yr(n,t,{nodePin:t.device.steps?.[e]?.modelId}):{modelId:void 0,source:`default`},...xr(e,a,i)&&i?{rootName:i.name}:{},...r?{clusterModelId:u[e]??r.defaultModelId}:{},...o?{jumpTo:mr(o.device)}:{}})},M=T.map(({node:e,depth:t})=>{let n=pr(m,e.addonId);return{addonId:e.addonId,name:e.addonName,slot:e.slot,depth:t,fieldLabels:wr(n),detail:f(ge,{chips:E.map(t=>({id:t.id,label:t.shortLabel,state:A(e.addonId,t)}))})}});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 P=i(`span`,{className:b,children:[`Accelerators:`,` `,f(`span`,{className:`text-foreground`,children:E.length>0?E.map(e=>mr(e.device)).join(` · `):`none enabled`}),p.some(e=>!e.enabled)&&i(s,{children:[` `,`— off:`,` `,p.filter(e=>!e.enabled).map(mr).join(`, `)]}),` `,`·`,` `,f(tn,{to:mo(),className:`text-primary hover:underline`,children:`Cluster → Load balancing ›`})]});return f(fr,{tree:w,rows:M,accelerators:E,cellState:A,dirty:g!==null&&kr(p,g,O(g.stepId,E[0]))>0,onDiscard:()=>_(null),summary:P,...n===void 0?{}:{toolbar:n},listLabel:`Detection steps`,renderDetail:({selection:n,matchedField:r,selectAccelerator:a,backButton:o,onEscape:c,headingRef:l})=>{let u=n.stepId,d=u===null?null:pr(m,u);if(u===null||d===null)return f(`div`,{className:`p-4 text-xs text-foreground-subtle`,children:`No step selected.`});let w=g?.stepId===u?g:null,T=E.find(e=>e.id===n.acceleratorId)??E[0],A=O(u,T),j=w?.settings??A,M=kr(p,w,A),P=e=>{S(null),_(t=>({...t?.stepId===u?t:{stepId:u,models:{},jumps:{}},...e}))},F=go(u),I=Ze(d),L=T===void 0?void 0:br(m,T),R=e=>{let t=w?.models[e.deviceKey];return t===void 0?e.device.steps?.[u]?.modelId:t??void 0},ee=T===void 0?void 0:yr(d,T,{nodePin:R(T)}).modelId,te=E.length>1&&E.some(e=>!qt(O(u,e),A)),ne=()=>{w!==null&&C.mutate({agentNodeId:e,inferenceDevices:Dn(Or(p,w))},{onSuccess:()=>{_(null),S({kind:`saved`})},onError:e=>S({kind:`error`,error:e.message})})};return f(Te,{ref:l,title:d.name,subtitle:`${d.slot} · base for every camera that lands on ${t}`,leading:o,onEscape:c,headerExtra:D&&I.length>0&&F===null?i(`div`,{className:`flex flex-wrap items-center gap-2`,children:[f(`span`,{className:b,children:`Values as they run on`}),f(pe,{items:E.map(e=>({id:e.id,label:e.shortLabel})),selectedId:T?.id??null,onSelect:a})]}):void 0,saveBar:{dirtyCount:M,saving:C.isPending,status:x?.kind??null,...x?.error===void 0?{}:{error:x.error},onSave:ne,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`}),F!==null&&T!==void 0?f(_o,{step:F,engineFormat:T.device.format,runnableModelIds:Se(d.models??[],T.device.format).map(e=>e.id)}):E.length===0?i(`p`,{className:b,children:[`No accelerator is enabled on this node —`,` `,f(tn,{to:mo(),className:`text-primary hover:underline`,children:`enable one in Cluster → Load balancing`}),`.`]}):f(N,{rows:E.map(e=>{let t=w?.models[e.deviceKey],n=R(e),r=yr(d,e,{nodePin:n}),a=br(m,e),o=xr(u,w?.settings??O(u,e),a),c=w?.jumps[e.deviceKey],l=k(d,e,c),p=Sr(d,e)?o&&a?f(dt,{rootModel:a,stepModelId:r.modelId}):void 0:i(s,{children:[`No `,e.device.format,` build of this step.`,` `,l?`It runs on ${l.shortLabel} instead.`:`It does not run here.`]}),h=D?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:c??e.device.steps?.[u]?.jumpDeviceKey??``,onChange:t=>P({jumps:{...w?.jumps,[e.deviceKey]:t.target.value}}),children:[f(`option`,{value:``,children:`Auto (this accelerator, or the next one that can run it)`}),E.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:r.modelId,source:r.source===`node`?`node`:`default`,sourceLabel:r.source===`node`?`node pin`:`hardware default`,models:Se(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=>P({models:{...w?.models,[e.deviceKey]:t}}),...n===void 0?{}:{onReset:()=>P({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||c!==void 0}})},u)]}),(I.length>0||L!==void 0)&&F===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(jr,{addon:d,fields:I,settings:j,modelId:nt(d,ee,j,L),root:L,highlight:r,onChange:e=>P({settings:e})})]}),f(lr,{addonId:u,highlightLabel:r})]})})}})}function jr({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 Er(s===null?null:jt(s)),f(ze,{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 Mr({nodeId:e,refreshToken:t}){let n=Le(),[r,a]=d(null),{nodes:o}=W(),c=o.find(t=>t.id===e)?.name??e,l=Ne({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(sr,{nodeId:e}),f(Ar,{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(z,{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 Nr=[`detection-pipeline`,`audio-analyzer`,`pipeline-runner`],Pr=`decoder-nodeav`,Fr=`ntab`;function Ir({nodeId:e,refreshToken:t}){let[n,r]=G(),{nodes:a}=W(),o=a.find(t=>t.id===e)?.addons.find(e=>e.capabilities.includes(`decoder`))?.addonId??Pr,s=[...Nr,o],c={assignments:{id:`assignments`,label:`Assignments`,order:-10,content:f(tr,{nodeId:e,refreshToken:t})},tree:{id:`tree`,label:`Pipeline`,order:39,content:f(Mr,{nodeId:e,refreshToken:t})},engines:{id:`engines`,label:`Warm instances`,order:180,content:f(rr,{nodeId:e,refreshToken:t})},logs:{id:`logs`,label:`Logs`,order:300,content:f(or,{nodeId:e})}},l=Cn.map(e=>c[e]);return i(`div`,{className:`flex flex-col h-full`,children:[f(Sn,{nodeId:e,refreshToken:t}),f(`div`,{className:`flex-1 min-h-0 overflow-y-auto p-6`,children:f(nn,{nodeId:e,addonIds:s,level:`global`,extraTabs:l,activeTab:n.get(Fr),onActiveTabChange:e=>r(t=>{let n=new URLSearchParams(t);n.set(Fr,e);for(let e of fn)n.delete(e);return n},{replace:!0})})})]})}function Lr(){return i(`div`,{className:`space-y-6`,children:[f(sr,{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(Un,{mode:`cluster`})]})}function Rr(e){return`${Math.round(e*100)}%`}function zr(e){return`${e} session${e===1?``:`s`}`}var Br={"intel-npu":`Intel NPU`,"intel-igpu":`Intel iGPU`,"x86-cpu":`CPU`,"arm-cpu":`CPU`,"apple-ane":`Neural Engine`,coral:`Coral`},Vr={"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 Hr(e){return e===null?`—`:Br[e]??e}function Ur(e){return e===null?`—`:Vr[e]??e}function Wr(e){switch(e.kind){case`capacity`:return`Capacity ${zr(e.sessions)} ≥ min ${e.minSessions}.`;case`tie-faster`:return`As accurate as ${e.over} (within ${Rr(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 ${zr(e.minSessions)} per device; the one with the most capacity (${zr(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 Gr(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 Kr(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 qr(e){let t=Kr(e);return t.modelChanges+t.thresholdClears+t.cameraOverrideClears+t.detectorStoreClears===0}function Jr(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 Yr=[.3,.4,.5];function Xr(e){return Yr.some(t=>t===e)}var Zr=[1,2,3,4,6,8];function Qr({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(V,{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:[Ur(t.hardwareClass),t.cpuModel===null?``:` · ${t.cpuModel}`]}),t.skipped?f(U,{variant:`warning`,children:`Not changed`}):t.acceleratorModelId!==null&&f(U,{variant:`info`,children:t.acceleratorModelId})]}),t.reasons.length>0&&f(`ul`,{className:`px-3 pt-2 text-[11px] text-foreground-muted`,children:t.reasons.map((e,t)=>f(`li`,{children:Wr(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=Jr(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:Hr(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:Wr(e)},t))})]},n.deviceKey)})})]})})]})}function $r({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 ei({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 ti(){let e=l(),[t,n]=d(.4),[r,a]=d(2),[s,c]=d(!1),[u,p]=d(!1),[m,_]=d(null),{data:v}=en(),b=o(()=>new Map((v??[]).map(e=>[e.id,e.name])),[v]),x=e=>b.get(e)??`Device ${e}`,S=ye({headroom:t,minSessionsPerDevice:r},{enabled:s,refetchOnWindowFocus:!1}),C=$e({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:Kr(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(et,{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(le,{"aria-label":`Share of each accelerator kept free`,value:String(t),options:Yr.map(e=>({value:String(e),label:`${Math.round(e*100)}% of each accelerator`})),onChange:e=>{let t=Number(e.target.value);Xr(t)&&n(t)}})]}),i(`label`,{className:`flex items-center gap-1.5`,children:[f(`span`,{className:`whitespace-nowrap`,children:`At least`}),f(le,{"aria-label":`Minimum parallel sessions per device`,value:String(r),options:Zr.map(e=>({value:String(e),label:`${e} camera${e===1?``:`s`} at once per accelerator`})),onChange:e=>{let t=Number(e.target.value);Zr.some(e=>e===t)&&a(t)}})]}),f(z,{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(z,{size:`sm`,disabled:qr(w),onClick:()=>p(!0),children:`Apply…`})]}),S.error!==null&&f(`div`,{className:`text-danger`,children:S.error.message}),m!==null&&f(ei,{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:Gr(e)},t)),w?.nodes.map(e=>f(Qr,{plan:w,node:e},e.nodeId)),w!==void 0&&f(wt,{open:u,onOpenChange:p,children:i(He,{width:`lg`,scroll:`body`,children:[i(Ke,{children:[f(ut,{children:`Apply auto tune?`}),f(_t,{children:`These are all the changes. Every override listed is removed and cannot be restored.`})]}),f(ot,{children:f($r,{plan:w,nameOf:x})}),i(Tt,{children:[f(z,{variant:`ghost`,onClick:()=>p(!1),children:`Cancel`}),f(z,{variant:`danger`,disabled:C.isPending,onClick:()=>C.mutate({planHash:w.planHash,headroom:t,minSessionsPerDevice:r}),children:C.isPending?`Applying…`:`Apply`})]})]})})]})}function ni(e){let t=e.backend.toLowerCase(),n=e.device.toLowerCase();return e.key===`cpu`||n===`cpu`?`CPU`:t===`openvino`&&n===`npu`?`Intel NPU`:t===`openvino`&&(n===`gpu`||n===`igpu`)?`Intel iGPU`:t===`edgetpu`?`Coral Edge TPU`:t===`coreml`?`Apple ANE`:`${e.backend} ${e.device}`.trim()}var ri={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 ii(e,t){return t<=0?0:Math.round(e/t*1e3)/10}function ai(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:ni(e),format:e.format,sessions:i,queueDepth:r?.queueDepth??0,weight:a,weightSharePct:e.exclusion===null?ii(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 oi(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=ai(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?ii(c,r.maxCameras):null,queueDepthTotal:i?.load.queueDepthTotal??null,avgInferenceTimeMs:i?.load.avgInferenceTimeMs??null,score:i?.score??null,weight:s,weightSharePct:o?ii(s,n):null,decodeHwaccel:i?.decodeHwaccel??null,devices:a,eligibleDeviceCount:a.filter(e=>e.exclusion===null).length}})}var si=`pipeline-orchestrator`,ci=`recorder`,li=`recordingNodeId`,ui=`pipeline-analytics`,di=`postProcessingNodeId`,fi=[`ingestNode`,`recordingNode`,`audioNode`,`motionNode`,`postProcessingNode`],pi=[{key:`detect`,label:`Detect`,hint:`Runs the detection pipeline (decode + inference) for assigned cameras`}];function mi(e,t){for(let n of e?.sections??[])for(let e of n.fields??[])if(e.key===t)return e.value}function hi(e,t){for(let[n,r]of Object.entries(e??{}))if(n===t)return r}function gi(e,t,n){let r=mi(e,t);return typeof r==`string`&&r.length>0?r:n}function q(e,t){let n=hi(e,t);return typeof n==`number`&&Number.isFinite(n)?n:null}function _i(e,t){let n=hi(e,t);return typeof n==`string`&&n.length>0?n:null}function vi(e){return e===`ingestNode`?`Ingest`:e===`recordingNode`?`Recording`:e===`audioNode`?`Audio`:e===`postProcessingNode`?`Post-processing`:`Motion Node`}function yi(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 bi(e,t){switch(t){case`detect`:return e.pipeline}}function xi(e){return e instanceof Error?e.message:`Failed to save`}function Si(e){e.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`listAgentSettings`]]}),e.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getAgentSettings`]]}),e.invalidateQueries({queryKey:[[`addonSettings`,`getGlobalSettings`]]})}r();var Ci=2e4,wi=3e5;function Ti({stats:e,targetWeights:t}){let{nodes:n}=W(),r=S().trpcClient,a=We(void 0,{placeholderData:u,staleTime:Ci,refetchInterval:Ci,refetchOnWindowFocus:!0}),s=oe(void 0,{staleTime:wi}),l=o(()=>n.map(e=>e.id),[n]),d=c({queries:l.map(e=>({queryKey:Bt(Pe.pipelineOrchestrator.getNodeInferenceDevices,{nodeId:e},`query`),queryFn:()=>r.pipelineOrchestrator.getNodeInferenceDevices.query({nodeId:e}),staleTime:wi,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:yn(n,e.isHub).pipeline,weight:t?.[e.id]??q(n,`detectWeight`)??1,maxCameras:q(n,`maxCameras`)}}),[n,m,t]),g=a.data??[],v=o(()=>oi({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(de,{headingId:`load-balancing-node-load`,title:`Node load`,icon:vt,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(Ei,{row:e,placed:C.get(e.nodeId)},e.nodeId))})})})}function Ei({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(Et,{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(Ie,{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(Di,{row:e})]})}function Di({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(tt,{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(Oi,{device:e},e.key))})]})}function Oi({device:e}){let t=e.exclusion;return i(`li`,{className:`flex items-baseline gap-1.5 text-[10px] min-w-0`,children:[f(V,{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:ri[t],children:[`excluded — `,ri[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 ki(e){return{nodes:Object.fromEntries(e.map(e=>[e.nodeId,Math.max(1,e.weight)])),devices:{}}}function Ai(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 ji(e){return Object.fromEntries(e.nodes.map(e=>[e.nodeId,Object.fromEntries(e.devices.map(e=>[e.deviceKey,e.suggestedMaxSessions]))]))}function Mi(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 Ni(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 Pi(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 Fi=[{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 Ii(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 Li(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)}: ${Ii(e.capacityFallback)??``}`).join(` · `)}r();var Ri=3600*1e3,zi=2e4,Bi=.4;function Vi({refreshToken:e,onOpenAutoTune:t}){let n=l(),{nodes:r}=W(),a=oe(void 0),c=ve({windowMs:Ri},{refetchInterval:zi,placeholderData:u}).data,p=ct(void 0,{refetchInterval:zi,placeholderData:u}).data,m=()=>{Si(n),n.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getNodeInferenceDevices`]]})},h=qe({onSuccess:m}),g=pt({onSuccess:()=>{m(),n.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getEffectiveShares`]]})}}),v=ce({onSuccess:m}),y=Lt(),[S,C]=d(!1),w=p?.source,T=w===`benchmark`?`benchmark`:`hardware`,E=St({headroom:Bi,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=>yn(e.get(t.id),t.isHub).pipeline).map(t=>{let n=e.get(t.id);return{id:t.id,name:t.name,isOnline:t.isOnline,weight:q(n,`detectWeight`)??1,maxCameras:q(n,`maxCameras`)}})},[r,a.data]),k=e=>r.find(t=>t.id===e)?.name??e,A=D?ji(D):void 0,j=Ni(O,p),M=w!==`manual`,N=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]))},P=p?Pi(p,k):null,F=p?Li(p,k):null,I=Fi.find(e=>e.value===w)?.hint;return i(`div`,{className:`space-y-3 sm:space-y-4`,children:[f(nn,{nodeId:`hub`,addonIds:[si],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(wn,{refreshToken:e}),f(Ti,{stats:c,...p!==void 0&&p.source!==`manual`&&!p.autoPending?{targetWeights:Object.fromEntries(p.nodes.map(e=>[e.nodeId,e.configuredPct]))}:{}}),f(de,{headingId:`load-balancing-node-shares`,title:`Node shares`,icon:cn,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:Fi.map(e=>f(z,{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(z,{variant:`outline`,size:`sm`,onClick:()=>{C(!0),S&&E.refetch()},disabled:E.isFetching,children:[f(gt,{className:`h-3.5 w-3.5`}),E.isFetching?`Suggesting…`:T===`benchmark`?`Suggest from benchmark`:`Suggest from hardware`]}),i(z,{variant:`ghost`,size:`sm`,onClick:t,children:[f(et,{className:`h-3.5 w-3.5`}),`Auto tune`]}),i(z,{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(ee,{className:`h-3.5 w-3.5`}),y.isPending?`Rebalancing…`:`Rebalance`]})]}),children:i(`div`,{className:`${_} space-y-3`,children:[I!==void 0&&f(`p`,{className:`text-[10px] text-foreground-subtle`,children:I}),c&&i(`p`,{className:`text-[10px] text-foreground-subtle`,children:[`Policy:`,` `,f(U,{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(Mn,{nodes:j.nodes,pending:h.isPending,readOnly:j.readOnly,onCommitWeights:e=>h.mutate(ki(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})`}`,`.`]})}:{}}),P!==null&&f(`p`,{className:`text-[10px] text-foreground-subtle`,children:P}),F!==null&&f(`p`,{className:`text-[10px] text-foreground-subtle`,"data-testid":`benchmark-fallback-note`,children:F}),g.isError&&f(R,{message:`Failed to switch shares: ${g.error instanceof Error?g.error.message:`unknown error`}`}),h.isError&&f(R,{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(Ye,{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(R,{message:`Suggestion failed: ${E.error instanceof Error?E.error.message:`unknown error`}`}),D&&f(Hi,{suggestion:D,nameOf:k,pending:h.isPending,...M?{}:{onApply:()=>h.mutate(Ai(D))}}),f(de,{headingId:`load-balancing-accelerators`,title:`Accelerators`,icon:V,children:f(`div`,{className:`${_} space-y-2`,children:O.length===0?f(ae,{title:`No detect-capable nodes`,description:`Enable detection on a node in Roles & nodes to configure its accelerators.`}):O.map(e=>f(Fn,{nodeId:e.id,nodeName:e.name,isOnline:e.isOnline,...A?.[e.id]===void 0?{}:{suggestedMaxSessions:A[e.id]},...N(e.id)===void 0?{}:{autoDeviceShares:N(e.id)}},e.id))})}),c!==void 0&&c.stalePins.length>0&&f(Ui,{stats:c})]})}function Hi({suggestion:e,nameOf:t,pending:n,onApply:r}){return i(de,{headingId:`load-balancing-suggestion`,title:e.source===`benchmark`?`Suggested from benchmark`:`Suggested from hardware`,icon:gt,...r===void 0?{}:{actions:f(z,{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:[Ii(e.capacityFallback)===null?``:`${Ii(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 Ui({stats:e}){let t=l(),n=Dt({onSuccess:()=>{t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPlacementStats`]]}),t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineDevicePin`]]})}});return f(de,{headingId:`load-balancing-stale-pins`,title:`Stale device pins`,icon:on,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:Mi(e)})]}),f(z,{variant:`outline`,size:`sm`,disabled:n.isPending,onClick:()=>n.mutate({deviceId:e.deviceId,deviceKey:`auto`}),children:`Clear pin`})]},e.deviceId))})})}function Wi({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?B:Re;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 Gi({node:e,emphasis:t=!1}){let n=e.isHub?lt:V;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(U,{variant:`info`,className:`px-1.5 py-0 text-[9px] uppercase tracking-wider`,children:`hub`}),!e.isOnline&&f(U,{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 Ki({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(Ct,{className:`h-3 w-3 animate-spin`,"aria-hidden":`true`}):f(B,{className:`h-3 w-3`,"aria-hidden":`true`}),`Save`]}),!g&&!m&&r===`success`&&f(B,{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(je,{className:`h-3.5 w-3.5 shrink-0 text-red-400`,"aria-label":a??`Failed to save reachable host`,role:`img`})})]})}r();var qi=1024,Ji=65536;function Yi(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 Xi({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=Yi(s,qi,Ji),h=Yi(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:qi,max:Ji,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(Ct,{className:`h-3 w-3 animate-spin`,"aria-hidden":`true`}):f(B,{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(B,{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(je,{className:`h-3.5 w-3.5 shrink-0 text-red-400`,"aria-label":`Save failed`,role:`img`})})]})}function Zi({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 Qi({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(Gi,{node:e,emphasis:!0}),f(`div`,{className:`grid grid-cols-2 gap-2`,children:pi.map(n=>f(Wi,{capability:n.key,label:n.label,hint:n.hint,nodeId:e.id,active:bi(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(Zi,{label:`Reachable host`,children:f(Ki,{nodeId:e.id,value:e.reachableHost,detectedHosts:e.detectedHosts,status:t.reachableHostStatus(e.id),errorMessage:t.reachableHostErrorMessage(e.id),onCommit:t.onCommitReachableHost})}),f(Zi,{label:`Decode limits`,children:f(Xi,{nodeId:e.id,decodeBudgetMb:e.decodeBudgetMb,maxLiveDecodeWorkers:e.maxLiveDecodeWorkers,status:t.decodeLimitsStatus(e.id),errorMessage:t.decodeLimitsErrorMessage(e.id),onCommit:t.onCommitDecodeLimits})})]})]})}function $i(){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 ea({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`}),pi.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(Gi,{node:e})}),pi.map(n=>f(`td`,{className:`px-3 py-3 text-center align-middle`,children:f(Wi,{capability:n.key,label:n.label,hint:n.hint,nodeId:e.id,active:bi(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(Ki,{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(Xi,{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 ta({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:vi(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:yi(e)})]})}function na({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:fi.map(i=>f(ta,{role:i,value:e[i],options:t,pending:n,onChange:r},i))})}r();function ra(){let e=l(),{nodes:t}=W(),n=oe(void 0),r=H({addonId:si}),a=H({addonId:ci}),c=H({addonId:ui}),u=()=>Si(e),d=Oe({onSuccess:u}),p=bt({onSuccess:u}),m=Fe({onSuccess:u}),h=Qe({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=yn(t,e.isHub);return{id:e.id,name:e.name,isHub:e.isHub,isOnline:e.isOnline,settings:t,effective:n,reachableHost:_i(t,`reachableHost`),detectedHosts:e.localIps,decodeBudgetMb:q(t,`decodeBudgetMb`),maxLiveDecodeWorkers:q(t,`maxLiveDecodeWorkers`)}}),[t,g]),v={ingestNode:gi(r.data,`ingestNode`,`hub`),recordingNode:gi(a.data,li,`hub`),audioNode:gi(r.data,`audioNode`,`hub`),motionNode:gi(r.data,`motionNode`,`hub`),postProcessingNode:gi(c.data,di,`hub`)},y=o(()=>{let e=t.filter(e=>e.isOnline).map(e=>e.id);return[...new Set([`hub`,...fi.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:ci,patch:{[li]:t}});return}if(e===`postProcessingNode`){h.mutate({addonId:ui,patch:{[di]:t}});return}h.mutate({addonId:si,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`?xi(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`?xi(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(Ct,{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(na,{roleValues:v,options:y,pending:h.isPending,onRoleChange:S})]}),i(`div`,{className:`space-y-3`,children:[f(`h4`,{className:`text-xs font-semibold uppercase tracking-wide text-foreground-subtle`,children:`Events folder`}),f(`p`,{className:`text-[11px] text-foreground-subtle`,children:`Where event crops / full frames are stored. A single folder — no collection / equal-splitting.`}),f(rn,{types:[`eventMedia`]})]}),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($i,{})]}),_.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(Qi,{node:e,actions:E},e.id))}),f(`div`,{className:`hidden @3xl/clustertab:block`,children:f(ea,{nodes:_,actions:E})})]})]})]})}var ia=[`pipeline-orchestrator`],aa=`pipeline-analytics`,oa=`face-gallery`;r();var sa=2500;function ca(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`),sa),!0)};if(n())return;let r=new MutationObserver(()=>{n()&&r.disconnect()});return r.observe(document.body,{childList:!0,subtree:!0}),()=>r.disconnect()},[e])}function la({refreshToken:e}){let[t]=G();return ca(t.get(uo)),i(`div`,{className:`space-y-4 max-w-3xl`,children:[f(nn,{nodeId:`hub`,addonIds:ia,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(nn,{nodeId:`hub`,addonIds:[aa],level:`global`,capability:oa,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.`})]})}r();function ua({refreshToken:e}){let t=l(),n=Le(),{data:r,isLoading:a}=ue(),[o,c]=d(null),[u,p]=d(``),[m,h]=d(``),g=()=>{t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`listTemplates`]]})},_=ht({onSuccess:()=>{c(null),g()}}),v=It({onSuccess:g}),y=e=>{c(e.id),p(e.name),h(e.description??``)},b=()=>{c(null),p(``),h(``)},x=()=>{if(!o)return;let e=m.trim();_.mutate({id:o,name:u.trim()||`Untitled`,...e?{description:e}:{}})};if(a)return f(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:`Loading templates…`});let S=[...r??[]].toSorted((e,t)=>e.name.localeCompare(t.name));return f(`div`,{className:`space-y-6 max-w-4xl`,children:i(`section`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[i(`div`,{className:`border-b border-border px-4 py-3 flex items-center justify-between`,children:[i(`div`,{children:[f(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Templates`}),f(`p`,{className:`text-[11px] text-foreground-subtle mt-0.5`,children:`Curated pipeline presets operators can apply to any camera. Apply-time is a copy — future edits to a template don't retroactively change cameras that were seeded from it. Save a template from the device Pipeline tab.`})]}),i(`div`,{className:`text-[11px] text-foreground-subtle`,children:[S.length,` template`,S.length===1?``:`s`]})]}),S.length===0?i(`div`,{className:`px-4 py-8 text-xs text-foreground-subtle flex flex-col items-center gap-2`,children:[f(ke,{className:`h-6 w-6 opacity-40`}),f(`div`,{children:`No templates yet. Create one from a device Pipeline tab ("Save as template").`})]}):f(`ul`,{className:`divide-y divide-border`,children:S.map(e=>{let t=o===e.id;return f(`li`,{className:`px-4 py-3 text-xs`,children:i(`div`,{className:`flex items-start gap-3`,children:[f(`div`,{className:`flex-1 min-w-0`,children:t?i(`div`,{className:`space-y-2`,children:[f(`input`,{className:`w-full rounded border border-border bg-surface-hover px-2 py-1 text-xs text-foreground focus:outline-none focus:border-primary`,value:u,onChange:e=>p(e.target.value),placeholder:`Template name`,autoFocus:!0}),f(`input`,{className:`w-full rounded border border-border bg-surface-hover px-2 py-1 text-[11px] text-foreground focus:outline-none focus:border-primary`,value:m,onChange:e=>h(e.target.value),placeholder:`Description (optional)`})]}):i(s,{children:[f(`div`,{className:`font-medium text-foreground`,children:e.name}),e.description&&f(`div`,{className:`text-foreground-subtle mt-0.5`,children:e.description}),i(`div`,{className:`mt-1 font-mono text-[10px] text-foreground-subtle`,children:[e.config.steps.length,` step(s)`,e.config.audio?.enabled?` · audio`:``,i(`span`,{className:`ml-2`,children:[`updated `,new Date(e.updatedAt).toLocaleString()]})]})]})}),f(`div`,{className:`flex items-center gap-1 shrink-0`,children:t?i(s,{children:[i(`button`,{type:`button`,onClick:x,disabled:_.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[11px] font-medium bg-primary text-white hover:bg-primary/90 disabled:opacity-50`,children:[f(B,{className:`h-3 w-3`}),`Save`]}),i(`button`,{type:`button`,onClick:b,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[11px] text-foreground-subtle hover:bg-surface-hover`,children:[f(se,{className:`h-3 w-3`}),`Cancel`]})]}):i(s,{children:[f(`button`,{type:`button`,onClick:()=>y(e),title:`Rename`,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[11px] text-foreground-subtle hover:text-foreground hover:bg-surface-hover`,children:f(ne,{className:`h-3 w-3`})}),f(`button`,{type:`button`,onClick:()=>{(async()=>{await n({title:`Delete template`,message:`Delete the cluster pipeline template "${e.name}"? Cameras already using it keep their current pipeline.`,confirmLabel:`Delete`,variant:`danger`})&&v.mutate({id:e.id})})()},disabled:v.isPending,title:`Delete`,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[11px] text-foreground-subtle hover:text-red-400 hover:bg-surface-hover disabled:opacity-50`,children:f(D,{className:`h-3 w-3`})})]})})]})},e.id)})})]})})}var da=`pipeline-orchestrator`,fa=200;function pa(){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(we,{addonId:da,limit:fa,maxHeight:`max-h-[calc(100vh-360px)]`,showScope:!0,showDeviceChip:!0,showFilters:!1})})]})}var ma=[{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:`templates`,label:`Templates`},{id:`logs`,label:`Logs`}];function ha(e){return ma.some(t=>t.id===e)}function ga({refreshToken:e}){let[t,n]=G(),r=t.get(lo),a=ha(r)?r:`assignments`,o=e=>{n(t=>{let n=new URLSearchParams(t);return n.set(lo,e),n.delete(uo),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, settings and the pipeline template library.`})]}),f(`div`,{className:`flex items-center gap-1 px-4 sm:px-6 border-b border-border overflow-x-auto`,children:ma.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(Lr,{}),a===`load-balancing`&&f(Vi,{refreshToken:e,onOpenAutoTune:()=>o(`auto-tune`)}),a===`auto-tune`&&f(ti,{}),a===`roles-nodes`&&f(ra,{}),a===`settings`&&f(la,{refreshToken:e}),a===`templates`&&f(ua,{refreshToken:e}),a===`logs`&&f(pa,{})]})]})}var _a=`armed:`;function va(e){return e.assignment.reasons.detection?.startsWith(_a)===!0}function ya(e){let{assignment:t,detection:n}=e;return n!==null&&n.provisioning.state===`failed`||t.detectionNodeId===null&&n===null&&!va(e)?`error`:n!==null&&n.phase===`active`?`healthy`:`idle`}function ba(e){let t=[],n=[],{assignment:r,detection:i,decoder:a,broker:o}=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)`}),i!==null&&i.phase===`active`&&a!==null&&a.shm.framesWritten===0&&t.push({code:`decoder-black-hole`,severity:`error`,message:`Decoder on ${a.nodeId} has written 0 frames to the shared-memory plane while detection is active — the decode path is stalled`}),r.detectionNodeId===null&&i===null&&!va(e)&&n.push({code:`unassigned`,severity:`warning`,message:`Not placed on any detection node — no pipeline is running for this camera`});let s=e.degraded??[];if(s.length>0){let e=[...new Set(s.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(...Ca(e.cameraSensors));for(let e of o?.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 xa(e){return e.state===`unreadable`&&Ht.state===`unreadable`&&e.reason===Ht.reason}function Sa(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 Ca(e){if(e===void 0||e.state===`not-configured`)return[];if(e.state===`unreadable`)return xa(e)?[]:[{code:`camera-sensors-unreadable`,severity:`warning`,message:`Camera sensors unreadable: ${e.reason}`}];let t=e.sensors.flatMap(e=>{let t=Sa(e);return t===null?[]:[t]}),n=e.notForwarded===void 0?t:[wa(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 wa(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 Ta(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(Da).join(`, `)}function Ea(e){return e.mode===`in-addition`?``:` · ${e.mode}`}function Da(e){return`${Oa(e)}${Ea(e)}`}function Oa(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 ka(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Y(e){return typeof e==`string`&&e.length>0?e:null}function Aa(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function ja(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function Ma(e,t){return e==null?!1:JSON.stringify(e)!==JSON.stringify(t??null)}var Na={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 Pa(e){if(!ka(e)||!Array.isArray(e.sections))return Na;let t=Xt(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)Ma(n.value,n.default)&&r.add(e);return{detectionMode:Y(n(`detectionMode`)),detectionStreamProfile:Y(n(`detectionStreamProfile`)),detectionFps:Aa(n(`detectionFps`)),motionSources:ja(n(`motionSources`)),motionFps:Aa(n(`motionFps`)),motionCooldownMs:Aa(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 Fa(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(...Fa(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(Ia,{})]})}function Ia(){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 La={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 ${La[e]}`,children:t})}function $({children:e}){return f(`div`,{className:`text-[11px] text-foreground-subtle italic`,children:e})}function Ra({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(sn,{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 za({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(Ra,{icon:V,label:`Detection`,nodeId:e.detectionNodeId,pinned:e.pinned.detection,reason:e.reasons.detection,overridden:t.overriddenKeys.has(`pipelineNodeId`)}),f(Ra,{icon:At,label:`Decoder`,nodeId:e.decoderNodeId,pinned:e.pinned.decoder,reason:e.reasons.decoder,overridden:t.overriddenKeys.has(`decoderNodeId`)}),f(Ra,{icon:O,label:`Audio`,nodeId:e.audioNodeId,pinned:e.pinned.audio,reason:e.reasons.audio,overridden:t.overriddenKeys.has(`audioNodeId`)}),f(Ra,{icon:be,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 Ba(e){return`${e.width}×${e.height} ${e.codec} @${e.fps}fps`}function Va(e,t){if(!(t===null||e===void 0))return e.find(e=>e.profile===t)}function Ha(e){return e===null?`default`:e===0?`native (no throttle)`:`${e} fps`}function Ua({streams:e,brokerProfiles:t,settings:n,motionEnabled:r,motionFpsLive:a,cameraSensors:o}){let c=Va(t,n.detectionStreamProfile),l=Va(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:Ha(n.detectionFps)}),i(Z,{label:`Motion src`,overridden:n.overriddenKeys.has(`motionSources`),children:[n.motionSources.length>0?n.motionSources.map(Qt).join(` + `):`none`,r===!1&&` · inactive`]}),f(Z,{label:`Camera sensors`,children:Ta(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:[Ha(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}),` `,Ba(e)]},e.camStreamId))})]})}function Wa({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 Ga={ready:`success`,installing:`info`,verifying:`info`,idle:`neutral`,failed:`danger`};function Ka({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=_e(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(L,{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:Ga[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 qa({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 Ja({decoder:e,detectionActive:t}){if(e===null)return f(X,{title:`Decoder`,children:f($,{children:`Decoder stage inactive or unreachable`})});let n=t&&e.shm.framesWritten===0;return i(X,{title:`Decoder`,children:[f(Z,{label:`Node`,children:e.nodeId}),f(Z,{label:`Sessions`,children:e.sessionCount}),i(Z,{label:`SHM frames`,children:[f(`span`,{className:n?`text-danger font-semibold`:``,children:e.shm.framesWritten}),f(`span`,{className:`text-foreground-subtle`,children:` written`})]}),i(Z,{label:`SHM reads`,children:[e.shm.getFrameHits,` hits`,e.shm.getFrameMisses>0&&i(`span`,{className:`text-warning`,children:[` · `,e.shm.getFrameMisses,` misses`]})]}),i(Z,{label:`SHM budget`,children:[e.shm.budgetMb,` MB`]}),e.formats.length>0&&f(Z,{label:`Formats`,children:e.formats.join(`, `)})]})}r();var Ya=`pipeline-orchestrator`,Xa={healthy:`bg-success`,idle:`bg-warning`,error:`bg-danger`},Za={healthy:`Healthy`,idle:`Idle`,error:`Error`};function Qa({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(Et,{className:`h-3.5 w-3.5 shrink-0 mt-px`}),f(`span`,{className:`min-w-0`,children:e.message})]},e.code))})}function $a({deviceId:e,name:t,online:n,status:r,live:a,onlineNodes:s}){let c=l(),{data:u}=Xe({addonId:Ya,deviceId:e,nodeId:`hub`},{staleTime:3e4}),{data:d}=ie({deviceId:e},{staleTime:3e4}),p=o(()=>Pa(u),[u]),m=o(()=>d===void 0?void 0:Fa(d.steps),[d]),h=o(()=>r===void 0?[]:ba(r),[r]),g=()=>{c.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCameraStatuses`]]}),c.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineAssignments`]]})},_=Mt({onSuccess:g}),v=Ve({onSuccess:g}),y=t=>{t===`auto`?v.mutate({deviceId:e}):_.mutate({deviceId:e,agentNodeId:t})},b=r===void 0?`idle`:ya(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`:Xa[b]}`,title:x?`Error`:Za[b],"aria-label":x?`Error`:Za[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(Qa,{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(za,{assignment:r.assignment,settings:p,onlineNodes:s,pinPending:_.isPending||v.isPending,onDetectionPinChange:y}),f(Ka,{detection:r.detection,live:a,detectionMode:p.detectionMode,modeOverridden:p.overriddenKeys.has(`detectionMode`)}),f(Wa,{steps:m,audioModelId:d?.audio?.modelId??null,audioEnabled:r.audio?.enabled??d?.audio?.enabled??null,audioMode:p.audioMode}),f(Ua,{streams:r.source.streams,brokerProfiles:r.broker?.profiles,settings:p,motionEnabled:r.motion?.enabled??null,motionFpsLive:r.motion?.fps??null,cameraSensors:r.cameraSensors}),f(qa,{broker:r.broker}),f(Ja,{decoder:r.decoder,detectionActive:r.detection?.phase===`active`})]})]})}r();var eo=5e3,to=1e4,no=5e3;function ro(e){let t=l(),{data:n,isLoading:r}=en(),{data:i,isLoading:a}=Ee({},{refetchInterval:eo}),{nodes:s}=W();p(()=>{e!==0&&t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCameraStatuses`]]})},[e,t]);let[c,u]=d(new Map);De(Yt.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()-to,n=!1,r=new Map(e);for(let[i,a]of e)a.timestamp<t&&(r.delete(i),n=!0);return n?r:e})},no);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 io({refreshToken:e}){let{rows:t,liveMetrics:n,onlineNodes:r,isLoading:a}=ro(e),s=o(()=>[...t.map(e=>{let t=e.status===void 0?[]:ba(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($a,{deviceId:e.deviceId,name:e.name,online:e.online,status:e.status,live:n.get(e.deviceId),onlineNodes:r},e.deviceId))]})})}var ao=e({CLUSTER_NODE_ID:()=>oo,PipelinePage:()=>co});r();var oo=`__cluster__`;function so(e){return e===`cameras`?`cameras`:`nodes`}function co(){let[e,t]=G(),n=so(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:oo},{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(fe,{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(xn,{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(ga,{refreshToken:a}):f(Ir,{nodeId:r,refreshToken:a})})]}):f(`section`,{className:`flex-1 min-h-0 overflow-hidden`,children:f(io,{refreshToken:a})})})]})}var lo=`ctab`,uo=`section`;function fo(e,t){let n=new URLSearchParams({view:`nodes`,node:oo,[lo]:e});return t!==void 0&&n.set(uo,t),`/pipeline?${n.toString()}`}function po(){return fo(`settings`,Vt)}function mo(){return fo(`load-balancing`)}var ho=`pipeline-orchestrator`;function go(e){return Gt.find(t=>t.stepId===e)??null}function _o({step:e,engineFormat:t,runnableModelIds:n}){let{data:r}=H({addonId:ho}),a=Kt(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(tn,{to:po(),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{fn as _,vr as a,Tr as c,wr as d,yr as f,En as g,lr as h,Er as i,br as l,fr as m,go as n,Cr as o,xr as p,ao as r,pr as s,_o as t,Sr as u};
|