@camstack/addon-admin-ui 1.2.702 → 1.2.704

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. package/CHANGELOG.md +14 -2
  2. package/dist/assets/{AccessSection-CNgvvC6Q.js → AccessSection-Bbp4vCnK.js} +1 -1
  3. package/dist/assets/Addons-BfskS1ar.js +5 -0
  4. package/dist/assets/{AdminPage-BkxgjFWW.js → AdminPage-Dyd6hYl8.js} +1 -1
  5. package/dist/assets/{AdminSectionedPage-bGVBepbw.js → AdminSectionedPage-DvahmWYI.js} +1 -1
  6. package/dist/assets/AiProfiles-Di4CMSTf.js +3 -0
  7. package/dist/assets/Archive-B10-SsQm.js +1 -0
  8. package/dist/assets/{BootstrapSettingsForm-jBRoUiPn.js → BootstrapSettingsForm-Cm4-eDgP.js} +1 -1
  9. package/dist/assets/Build-CG3kxG-Q.js +40 -0
  10. package/dist/assets/{Calendars-BBTnm6OG.js → Calendars-BDDqqhdh.js} +1 -1
  11. package/dist/assets/Cluster-BQ_N__Tz.js +1 -0
  12. package/dist/assets/CompositionBlockEditor-CAYxLM7D.js +2 -0
  13. package/dist/assets/{CompositionEditorPage-C5pNxu2M.js → CompositionEditorPage-DX3tmg77.js} +1 -1
  14. package/dist/assets/Data-DdKvcS20.js +2 -0
  15. package/dist/assets/DeviceDetail-DHBkE6sd.js +1 -0
  16. package/dist/assets/{Devices-BJRvDHiT.js → Devices-BzdO_WfX.js} +1 -1
  17. package/dist/assets/EmbedDevicePage-Cyos8BBm.js +1 -0
  18. package/dist/assets/{EmbedPlayerPage-BsxSpEcY.js → EmbedPlayerPage-Cl2Qja7R.js} +1 -1
  19. package/dist/assets/History-CDCxEudX.js +1 -0
  20. package/dist/assets/Identity-C-NUjzGa.js +1 -0
  21. package/dist/assets/InstancesTable-CLf8XbQo.js +1 -0
  22. package/dist/assets/IntegrationDetail-BLtGoHv4.js +1 -0
  23. package/dist/assets/{Integrations-Dpb2V2yu.js → Integrations-D0p7b6sg.js} +1 -1
  24. package/dist/assets/{Integrations-BUOpFqfh.js → Integrations-DKh9soI8.js} +2 -2
  25. package/dist/assets/Library-C5NOjKCt.js +1 -0
  26. package/dist/assets/Locations-CIm3Q3i3.js +3 -0
  27. package/dist/assets/{Logs-CUV00qxb.js → Logs-BdYjeDAx.js} +1 -1
  28. package/dist/assets/{MaskShapeCanvas-D57fCIme.js → MaskShapeCanvas-drW0ZeaQ.js} +1 -1
  29. package/dist/assets/{MotionZonesSettings-w1kFM_O4.js → MotionZonesSettings-VF9WJZWR.js} +1 -1
  30. package/dist/assets/{MyAccess-D87gqxHt.js → MyAccess-bBE9o8UP.js} +1 -1
  31. package/dist/assets/{Network-L7e5c9RP.js → Network-CgYpqnsc.js} +1 -1
  32. package/dist/assets/{NewExportModal-CHwUJ26P.js → NewExportModal-CsSL-XDz.js} +1 -1
  33. package/dist/assets/NodeAddonsSettingsPanel-DNmMoeS5.js +1 -0
  34. package/dist/assets/Notifications-CAl9PqU3.js +1 -0
  35. package/dist/assets/{PanelContent-PhbemYUY.js → PanelContent-Cg1LPl_m.js} +2 -2
  36. package/dist/assets/Pipeline-ffZklufq.js +1 -0
  37. package/dist/assets/{PrivacyMaskSettings-BS29zGkX.js → PrivacyMaskSettings-D-43rQlu.js} +1 -1
  38. package/dist/assets/{SceneMonitorEditor-CosxkmPM.js → SceneMonitorEditor-CIMZOhg6.js} +1 -1
  39. package/dist/assets/SessionsList-BPJsMXCC.js +2 -0
  40. package/dist/assets/{Showroom-0iJ0CCe5.js → Showroom-DrnOtUc4.js} +1 -1
  41. package/dist/assets/StorageLocationsTable-CBvJJKcK.js +1 -0
  42. package/dist/assets/System-CiNhZGIk.js +2 -0
  43. package/dist/assets/TemplateEditorDialog-CPEjtVgr.js +1 -0
  44. package/dist/assets/{Terminal-Cvw2rPrb.js → Terminal-CVqdDb0A.js} +4 -4
  45. package/dist/assets/{TrainingProviders-DcThiLnE.js → TrainingProviders-dcBFMHwS.js} +1 -1
  46. package/dist/assets/{Viewer-BUfnqb0c.js → Viewer-D5ct12iH.js} +1 -1
  47. package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-CNNET8uz.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-DO_LtV7q.js} +1 -1
  48. package/dist/assets/{action-draft-BTVZLATm.js → action-draft-C0aEYbbJ.js} +1 -1
  49. package/dist/assets/{ai-page.helpers-qxf7BP-v.js → ai-page.helpers-5EBfVv-0.js} +1 -1
  50. package/dist/assets/{assignment-candidates-d-6NU8po.js → assignment-candidates-Cu7cpUBu.js} +1 -1
  51. package/dist/assets/{authed-media-Bqh0pB9D.js → authed-media-CU1WIjD1.js} +1 -1
  52. package/dist/assets/{board-model-CPA2IZpg.js → board-model-Cwi5O7EF.js} +1 -1
  53. package/dist/assets/{camera-block-model-CJ0e2m0o.js → camera-block-model-Dll1DsHk.js} +1 -1
  54. package/dist/assets/client-BDuXx1QP.js +1122 -0
  55. package/dist/assets/{command-vocab-BzBhzE7i.js → command-vocab-BvTOW30-.js} +1 -1
  56. package/dist/assets/{device-integration-icon-VMxiVsqd.js → device-integration-icon-DyN7a2xu.js} +1 -1
  57. package/dist/assets/device-picker-model-CB3W-Dnv.js +1 -0
  58. package/dist/assets/{dist-D7Gew3v3.js → dist-UoOeKkgf.js} +1 -1
  59. package/dist/assets/dist-i_V6azZ-.js +1122 -0
  60. package/dist/assets/{format-BopmTOzZ.js → format-BkE2SPtY.js} +1 -1
  61. package/dist/assets/{hostInit-DuH1KOuD.js → hostInit-Bl-sNtRa.js} +1 -1
  62. package/dist/assets/i18n-CjRpxC0U.js +1 -0
  63. package/dist/assets/{icons-bi-mcO5N.js → icons-BLYFUXaZ.js} +1 -1
  64. package/dist/assets/{index-4KLN9ueQ.css → index-BHfNOQzs.css} +1 -1
  65. package/dist/assets/index-Dx4xn5Ud.js +6 -0
  66. package/dist/assets/{linked-devices-model-Bnz1douR.js → linked-devices-model-BheLRl2H.js} +1 -1
  67. package/dist/assets/{mf-entry-bootstrap-0-ddbe056c.js → mf-entry-bootstrap-0-4f6c0152.js} +2 -2
  68. package/dist/assets/mount-CB3W-Dnv.js +1 -0
  69. package/dist/assets/{notification-rule-status-ai5zWyzt.js → notification-rule-status-CqF6M-em.js} +1 -1
  70. package/dist/assets/{player-overlays-fpbPSPqT.js → player-overlays-BKR7fWEx.js} +1 -1
  71. package/dist/assets/remoteEntry-DDpSLsem.js +1 -0
  72. package/dist/assets/src-BnZKlAAn.js +279 -0
  73. package/dist/assets/{sso-popup-Za4GwQBP.js → sso-popup-CZ9VM6-3.js} +1 -1
  74. package/dist/assets/{step-inspector-model-BAgxIyNV.js → step-inspector-model-42AP-SPE.js} +1 -1
  75. package/dist/assets/{use-scenes-feed-BTNdL7JV.js → use-scenes-feed-Ch3TUt2m.js} +1 -1
  76. package/dist/assets/{useAdminDeviceRemoval-COlTnaF7.js → useAdminDeviceRemoval-CJytKQAy.js} +1 -1
  77. package/dist/assets/useEventInvalidation-CB3W-Dnv.js +1 -0
  78. package/dist/assets/{useNodeUrlSelection-DhtJZEtx.js → useNodeUrlSelection-D6xWhfvx.js} +1 -1
  79. package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-R-1W8c6C.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-QyglrCCc.js} +2 -2
  80. package/dist/index.html +9 -9
  81. package/dist/server/addon.js +157 -19
  82. package/package.json +2 -2
  83. package/dist/assets/Addons-Dtx3xcZ2.js +0 -5
  84. package/dist/assets/AiProfiles-BLj-ic5N.js +0 -3
  85. package/dist/assets/Archive-y1aPYCx8.js +0 -1
  86. package/dist/assets/Build-BoiB-nPA.js +0 -40
  87. package/dist/assets/Cluster-DN0Cwciw.js +0 -1
  88. package/dist/assets/CompositionBlockEditor-BloGManS.js +0 -2
  89. package/dist/assets/Data-LT-PQ05n.js +0 -2
  90. package/dist/assets/DeviceDetail-DAvmtNN2.js +0 -1
  91. package/dist/assets/EmbedDevicePage-CyKS-rmB.js +0 -1
  92. package/dist/assets/History-BPF9alct.js +0 -1
  93. package/dist/assets/Identity-dLFVHYZR.js +0 -1
  94. package/dist/assets/InstancesTable-LVQWfz07.js +0 -1
  95. package/dist/assets/IntegrationDetail-C_vN9X7q.js +0 -1
  96. package/dist/assets/Library-D4-BDy54.js +0 -1
  97. package/dist/assets/Locations-DGZ_lrp3.js +0 -3
  98. package/dist/assets/NodeAddonsSettingsPanel-Kqe8X8RH.js +0 -1
  99. package/dist/assets/Notifications-CucZNxjj.js +0 -1
  100. package/dist/assets/Pipeline-9O3YfaWk.js +0 -1
  101. package/dist/assets/SessionsList-OHo3GJ72.js +0 -2
  102. package/dist/assets/StorageLocationsTable-DqTWO4k1.js +0 -1
  103. package/dist/assets/System-DZXA2QSs.js +0 -2
  104. package/dist/assets/TemplateEditorDialog-8D78AUfO.js +0 -1
  105. package/dist/assets/client-Cng2SeYA.js +0 -1122
  106. package/dist/assets/device-detail-Cg2Zt8FL.js +0 -1
  107. package/dist/assets/device-picker-model-B-FI9413.js +0 -1
  108. package/dist/assets/dist-CxrdebAP.js +0 -1122
  109. package/dist/assets/i18n--GTAj4mB.js +0 -1
  110. package/dist/assets/index-DbXFHmBJ.js +0 -6
  111. package/dist/assets/mount-B-FI9413.js +0 -1
  112. package/dist/assets/remoteEntry-g0NfB_lk.js +0 -1
  113. package/dist/assets/src-eL0OacoB.js +0 -279
  114. package/dist/assets/useEventInvalidation-B-FI9413.js +0 -1
@@ -1 +0,0 @@
1
- import{C as e,J as t,K as n,R as r,S as i,V as a,Y as o,et as s,i as c,o as l,p as u,x as d}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{$a as f,A as p,D as m,Dr as h,Hn as g,Ir as _,Lr as v,N as y,O as b,Pn as x,Qa as S,Rn as C,Rt as w,T,Tt as E,Ur as ee,V as D,Xn as O,Yn as k,Za as A,Zt as j,aa as te,b as M,ci as ne,cr as N,ct as P,eo as F,ft as I,hi as L,j as R,ji as z,jt as B,k as V,oo as H,tn as U,v as re,wt as ie,y as ae,yn as oe,yt as se,z as W,zr as ce}from"./player-overlays-fpbPSPqT.js";import{Gn as le,Ji as ue,Ki as de,Xi as fe,Yi as pe,Zi as me,_ as he,_i as ge,bi as _e,fi as ve,g as ye,gi as be,h as xe,hi as Se,mi as Ce,ul as we,vi as Te,y as Ee,yi as De}from"./client-Cng2SeYA.js";import{t as Oe}from"./chevron-down-CBb-F8DT.js";import{d as ke,u as Ae}from"./terminal-DZ5OZpgC.js";import{a as je,i as Me,n as Ne,r as Pe,t as Fe}from"./usb-P4R9CjYI.js";import{t as Ie}from"./crop-B-t0rzRY.js";import{t as Le}from"./layers-BH9u1mrE.js";import{n as Re}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_trpc_mf_1_react_mf_2_query__loadShare__.js-DzoL8nR8.js";import{$a as ze,$u as Be,Ai as Ve,An as He,Au as Ue,B as We,Br as Ge,Cp as Ke,Cu as qe,Da as Je,Di as Ye,Du as Xe,Eu as Ze,Fc as Qe,Gi as $e,Gr as et,Gu as tt,H as nt,Ir as G,Iu as rt,Ji as it,Jp as at,Ju as ot,K as st,Ki as ct,Mn as lt,Mu as ut,Nc as dt,Ni as ft,Ou as pt,Pc as mt,Qa as ht,Qp as gt,Qu as _t,Sp as vt,Su as yt,U as bt,Ui as xt,Ur as St,Uu as Ct,V as wt,Vi as Tt,Vu as Et,W as Dt,Wi as Ot,Wr as kt,Wu as At,Xp as jt,Yi as Mt,Yp as Nt,Yu as Pt,Zp as Ft,Zs as It,Zu as Lt,_d as Rt,_i as zt,a as Bt,ai as Vt,bi as Ht,ci as Ut,dd as Wt,ed as Gt,et as Kt,fd as qt,ft as Jt,hd as Yt,jp as Xt,ju as Zt,ka as K,ki as Qt,kp as $t,kr as en,ku as tn,la as nn,ld as rn,md as an,mp as q,mr as on,pd as sn,pi as cn,pt as ln,qi as un,qp as J,qu as dn,si as fn,st as pn,td as mn,to as hn,ud as gn,vi as _n,wu as vn,xi as yn,xr as bn,xu as xn,yi as Sn,zr as Cn,zu as wn}from"./src-eL0OacoB.js";import{t as Y}from"./i18n--GTAj4mB.js";import{t as X}from"./useTranslation-BJr-n0es.js";import{H as Tn,vi as En,wi as Dn,yi as On}from"./index-DbXFHmBJ.js";import{t as kn}from"./NodeAddonsSettingsPanel-Kqe8X8RH.js";import"./useEventInvalidation-B-FI9413.js";import{_ as An,a as jn,b as Mn,c as Nn,d as Pn,f as Fn,g as In,h as Ln,i as Rn,l as zn,m as Bn,n as Vn,p as Hn,r as Un,s as Wn,u as Gn,v as Kn,y as qn}from"./step-inspector-model-BAgxIyNV.js";import{a as Jn,c as Yn,d as Xn,f as Zn,g as Qn,i as $n,l as er,m as tr,n as nr,o as rr,r as ir,s as ar,t as or,u as sr,v as cr,y as lr}from"./board-model-CPA2IZpg.js";s();function ur(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 dr(e,t){for(let[n,r]of Object.entries(e??{}))if(n===t)return r}function fr(e){return e!==!1}function pr(e){return{pipeline:fr(dr(e,`detect`)),audio:fr(dr(e,`audio`)),ingest:fr(dr(e,`ingest`))}}function mr(e,t){let n=e?.find(e=>e.nodeId===t);return pr(n?.settings)}function hr({selectedNodeId:t,onSelect:n,refreshToken:r}){let a=H(),{t:o}=X(),{nodes:s}=at(),{data:c}=Ct(void 0),{data:l}=dn(void 0),u=new Map;for(let e of c??[])u.set(e.agentNodeId,(u.get(e.agentNodeId)??0)+1);let f=s??[],p=f.filter(e=>e.isOnline).length,m=f.filter(e=>!e.isOnline).length;return e(`div`,{className:`flex flex-col h-full`,children:[e(q,{variant:`unstyled`,type:`button`,onClick:()=>n(ss),className:`flex items-center gap-3 px-4 py-3 border-b border-border text-left transition-colors ${t===`__cluster__`?`bg-primary/10 text-primary`:`text-foreground hover:bg-surface-hover`}`,children:[i(Ae,{className:`h-4 w-4 flex-shrink-0`}),e(`div`,{className:`min-w-0 flex-1`,children:[i(`div`,{className:`text-xs font-semibold truncate`,children:o(`pipeline.nodeList.cluster`,`Cluster`)}),i(`div`,{className:`text-[10px] text-foreground-subtle`,children:o(`pipeline.nodeList.assignmentsLoadBalancingRoles`,`Assignments, load balancing, roles`)})]})]}),i(`div`,{className:`flex-1 overflow-y-auto`,children:f.map(r=>{let s=t===r.id,c=u.get(r.id)??0,f=r.isHub?C:z,p=mr(l,r.id),m=r.isOnline?null:lt(ur(r.lastSeen),a);return e(q,{variant:`unstyled`,type:`button`,onClick:()=>n(r.id),className:`flex items-center gap-3 w-full px-4 py-3 border-b border-border text-left transition-colors ${s?`bg-primary/10 text-primary`:`text-foreground hover:bg-surface-hover`}${r.isOnline?``:` opacity-60`}`,children:[i(f,{className:`h-4 w-4 flex-shrink-0`}),e(`div`,{className:`min-w-0 flex-1`,children:[e(`div`,{className:`flex items-center gap-2`,children:[i(`span`,{className:`text-xs font-semibold truncate`,children:r.name}),r.isHub&&i(`span`,{className:`text-[9px] uppercase tracking-wider text-foreground-subtle border border-border rounded px-1 py-0.5`,children:o(`common.hubWord`)}),!r.isOnline&&i(`span`,{className:`h-1.5 w-1.5 rounded-full bg-danger flex-shrink-0`}),r.isOnline&&i(`span`,{className:`h-1.5 w-1.5 rounded-full bg-success flex-shrink-0`})]}),e(`div`,{className:`text-[10px] text-foreground-subtle flex items-center gap-2 mt-0.5`,children:[i(`span`,{children:o(`common.coresCount`,{count:r.cpuCores})}),i(`span`,{children:`•`}),e(`span`,{children:[Math.round(r.memoryMB/1024),` GB`]}),c>0&&e(d,{children:[i(`span`,{children:`•`}),e(`span`,{className:`inline-flex items-center gap-0.5 text-foreground`,children:[i(w,{className:`h-2.5 w-2.5`}),c]})]}),!r.isOnline&&e(d,{children:[i(`span`,{children:`•`}),e(`span`,{className:`text-danger`,children:[o(`common.offline`),m===null?``:` · ${m}`]})]})]}),e(`div`,{className:`mt-0.5 flex items-center gap-1`,children:[i(K,{variant:p.pipeline?`success`:`danger`,className:`px-1 py-0 text-[9px] leading-3`,title:p.pipeline?o(`pipeline.nodeList.pipelineEnabled`,`Pipeline: enabled`):o(`pipeline.nodeList.pipelineNotEnabledAgentCapability`,`Pipeline: not enabled (agent capability)`),children:o(`pipeline.nodeList.pipe`,`Pipe`)}),i(K,{variant:p.audio?`success`:`danger`,className:`px-1 py-0 text-[9px] leading-3`,title:p.audio?o(`pipeline.nodeList.audioEnabled`,`Audio: enabled`):o(`pipeline.nodeList.audioNotEnabledAgentCapability`,`Audio: not enabled (agent capability)`),children:o(`pipeline.nodeList.aud`,`Aud`)})]})]})]},r.id)})}),e(`div`,{className:`px-4 py-2 border-t border-border text-[10px] text-foreground-subtle flex items-center justify-between`,children:[i(`span`,{children:o(`common.onlineCount`,{count:p})}),m>0&&i(`span`,{className:`text-danger`,children:o(`common.offlineCount`,{count:m})})]})]})}function gr({nodeId:t,refreshToken:n}){let{t:r}=X(),{nodes:a}=at(),o=a?.find(e=>e.id===t),s=Nt(`pipeline.runner-load-snapshot`,e=>e.nodeId===t)?.load??null;return o?e(`div`,{className:`px-6 py-4 border-b border-border`,children:[e(`div`,{className:`flex items-center gap-2 mb-1`,children:[i(`h2`,{className:`text-base font-semibold text-foreground`,children:o.name}),o.isOnline?i(`span`,{className:`text-[10px] px-2 py-0.5 rounded-full bg-success/10 text-success`,children:r(`common.online`)}):i(`span`,{className:`text-[10px] px-2 py-0.5 rounded-full bg-danger/10 text-danger`,children:r(`common.offline`)}),o.isHub&&i(`span`,{className:`text-[9px] uppercase tracking-wider text-foreground-subtle border border-border rounded px-1 py-0.5`,children:r(`common.hubWord`)})]}),e(`div`,{className:`text-[11px] text-foreground-subtle flex items-center gap-2 flex-wrap`,children:[i(`span`,{children:o.cpuModel??`CPU`}),i(`span`,{children:`•`}),i(`span`,{children:r(`common.coresCount`,{count:o.cpuCores})}),i(`span`,{children:`•`}),e(`span`,{children:[Math.round(o.memoryMB/1024),` GB`]}),s&&e(d,{children:[i(`span`,{children:`•`}),i(`span`,{children:r(`pipeline.nodeDetailHeader.cameras`,{attached:s.attachedCameras,active:s.activeCameras})}),i(`span`,{children:`•`}),i(`span`,{children:r(`pipeline.nodeDetailHeader.avgInference`,{ms:s.avgInferenceTimeMs.toFixed(0)})}),i(`span`,{children:`•`}),i(`span`,{children:r(`pipeline.nodeDetailHeader.queue`,{depth:s.queueDepthTotal})}),s.hardware.hasGpu&&e(d,{children:[i(`span`,{children:`•`}),i(`span`,{className:`text-success`,children:`GPU`})]})]})]})]}):i(`div`,{className:`px-6 py-4 border-b border-border`,children:e(`div`,{className:`text-xs text-foreground-subtle`,children:[r(`pipeline.nodeDetailHeader.nodeNotFound`,`Node not found:`),` `,t]})})}var _r=[`assignments`,`tree`,`engines`,`logs`];function vr({refreshToken:t,nodeId:r}){let{t:a}=X(),[s,c]=o(new Map),{nodes:l}=J();Ft(`pipeline.camera-metrics-snapshot`,e=>{let t=e.data;typeof t?.deviceId==`number`&&c(e=>{let n=new Map(e);return n.set(t.deviceId,t),n})});let{data:u}=ut(void 0),d=n(()=>{let e=new Map;for(let t of u??[])e.set(t.nodeId,t.deviceCount);return e},[u]),f=n(()=>{let e=new Map,t=Date.now()-3e4;for(let n of s.values()){if(n.timestamp<t)continue;let r=n.nodeId??`hub`,i=e.get(r)??{attachedCameras:0,activeCameras:0,totalFps:0,totalInferenceWeighted:0,queueDepth:0};i.attachedCameras++,n.metrics.phase===`active`&&i.activeCameras++,i.totalFps+=n.metrics.actualFps,i.totalInferenceWeighted+=n.metrics.avgInferenceTimeMs,i.queueDepth+=n.metrics.queueDepth,e.set(r,i)}return e},[s]),p=n(()=>{let e=new Map;for(let t of l)e.set(t.id,t.shortName);return e},[l]),m=n(()=>{let e=0,t=0,n=0,r=0,i=0;for(let a of f.values())e+=a.attachedCameras,t+=a.activeCameras,n+=a.totalFps,r+=a.totalInferenceWeighted,i+=a.queueDepth;let a=e>0?r/e:0;return{totalAgents:l.length,onlineAgents:l.filter(e=>e.isOnline).length,attachedCameras:e,activeCameras:t,avgInferenceTimeMs:a,queueDepth:i,totalFps:n}},[f,l]);if(r){let t=f.get(r);return e(`div`,{className:`@container/liveload`,children:[i(`h3`,{className:`text-sm font-semibold text-foreground mb-2`,children:a(`pipeline.liveLoadPanel.liveLoad`,`Live load`)}),e(`div`,{className:`grid grid-cols-2 @md/liveload:grid-cols-3 @3xl/liveload:grid-cols-5 gap-2 mb-3`,children:[i(Z,{label:`FPS`,value:t?t.totalFps.toFixed(1):`—`}),i(Z,{label:a(`pipeline.liveLoadPanel.activeAttached`,`Active / Attached`),value:t?`${t.activeCameras}/${t.attachedCameras}`:`—`}),i(Z,{label:a(`pipeline.liveLoadPanel.avgInferMs`,`Avg infer ms`),value:t&&t.attachedCameras>0?(t.totalInferenceWeighted/t.attachedCameras).toFixed(0):`—`}),i(Z,{label:a(`pipeline.liveLoadPanel.queue`,`Queue`),value:t?String(t.queueDepth):`—`}),i(Z,{label:a(`pipeline.liveLoadPanel.audio`,`Audio`),value:String(d.get(r)??`—`)})]})]})}let h=[...f.entries()].toSorted(([e],[t])=>e===`hub`?-1:t===`hub`?1:e.localeCompare(t));return e(`div`,{className:`@container/liveload`,children:[i(`h3`,{className:`text-sm font-semibold text-foreground mb-2`,children:a(`pipeline.liveLoadPanel.liveLoad`,`Live load`)}),e(`div`,{className:`grid grid-cols-2 @md/liveload:grid-cols-3 @3xl/liveload:grid-cols-5 gap-2 sm:gap-3 mb-3`,children:[i(Z,{label:a(`pipeline.liveLoadPanel.totalAgents`,`Total agents`),value:`${m.onlineAgents}/${m.totalAgents}`}),i(Z,{label:a(`pipeline.liveLoadPanel.activeAttached`,`Active / Attached`),value:`${m.activeCameras}/${m.attachedCameras}`}),i(Z,{label:a(`pipeline.liveLoadPanel.totalFps`,`Total FPS`),value:m.totalFps.toFixed(1)}),i(Z,{label:a(`pipeline.liveLoadPanel.avgInferenceMs`,`Avg inference ms`),value:m.avgInferenceTimeMs.toFixed(0)}),i(Z,{label:a(`pipeline.liveLoadPanel.queueDepth`,`Queue depth`),value:String(m.queueDepth)})]}),i(`div`,{className:`rounded-lg border border-border overflow-x-auto`,children:e(`table`,{className:`w-full text-xs min-w-[480px]`,children:[i(`thead`,{className:`bg-surface`,children:e(`tr`,{className:`text-foreground-subtle text-[10px] uppercase tracking-wider`,children:[i(`th`,{className:`text-left px-3 py-2`,children:a(`pipeline.liveLoadPanel.agent`,`Agent`)}),i(`th`,{className:`text-right px-3 py-2`,children:`FPS`}),i(`th`,{className:`text-right px-3 py-2`,children:a(`pipeline.liveLoadPanel.cameras`,`Cameras`)}),i(`th`,{className:`text-right px-3 py-2`,children:a(`pipeline.liveLoadPanel.inferenceMs`,`Inference ms`)}),i(`th`,{className:`text-right px-3 py-2`,children:a(`pipeline.liveLoadPanel.queue`,`Queue`)}),i(`th`,{className:`text-right px-3 py-2`,children:a(`pipeline.liveLoadPanel.audio`,`Audio`)})]})}),e(`tbody`,{children:[h.map(([t,n])=>e(`tr`,{className:`border-t border-border`,children:[i(`td`,{className:`px-3 py-2 text-foreground font-medium`,children:p.get(t)??t}),i(`td`,{className:`px-3 py-2 text-right text-foreground`,children:n.totalFps.toFixed(1)}),i(`td`,{className:`px-3 py-2 text-right text-foreground`,children:n.attachedCameras}),i(`td`,{className:`px-3 py-2 text-right text-foreground`,children:n.attachedCameras>0?(n.totalInferenceWeighted/n.attachedCameras).toFixed(0):`—`}),i(`td`,{className:`px-3 py-2 text-right text-foreground`,children:n.queueDepth}),i(`td`,{className:`px-3 py-2 text-right text-foreground`,children:d.get(t)??`—`})]},t)),h.length===0&&i(`tr`,{children:i(`td`,{colSpan:6,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:a(`pipeline.liveLoadPanel.noCameraMetricsReceivedYet`,`No camera metrics received yet`)})})]})]})})]})}function Z({label:t,value:n}){return e(`div`,{className:`rounded-lg border border-border bg-surface/60 p-3`,children:[i(`div`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle mb-1`,children:t}),i(`div`,{className:`text-lg font-semibold text-foreground`,children:n})]})}var yr={active:!1,pinned:!1,nodeId:null,reason:``};function br(e,t){return e.deviceName.localeCompare(t.deviceName)||e.deviceId-t.deviceId}function xr(e,t,n){let r=new Map(t.map(e=>[e.deviceId,e])),i=new Map(n.map(e=>[e.deviceId,e]));return e.map(e=>{let t=r.get(e.id),n=i.get(e.id),a=t?{active:!0,pinned:t.pinned,nodeId:t.agentNodeId,reason:t.reason??``}:yr,o=n?{active:!0,pinned:n.pinned,nodeId:n.nodeId,reason:``}:yr;return{deviceId:e.id,deviceName:e.name,disabled:e.disabled===!0,pipeline:a,detection:a,decoder:yr,audio:o}}).toSorted(br)}function Sr(e,t,n){return{active:e!==null,pinned:t,nodeId:e,reason:n??``}}function Cr(e,t){let n=new Map(t.map(e=>[e.deviceId,e.assignment]));return e.map(e=>{let t=n.get(e.deviceId);return t===void 0?e:{...e,detection:Sr(t.detectionNodeId,t.pinned.detection,t.reasons.detection),decoder:Sr(t.decoderNodeId,t.pinned.decoder,t.reasons.decoder),audio:Sr(t.audioNodeId,t.pinned.audio,t.reasons.audio)}})}function wr(e,t,n){let r=(t,n,r)=>({active:t!==null&&t===e,pinned:n,nodeId:t,reason:r??``});return t.map(({deviceId:e,assignment:t})=>({deviceId:e,deviceName:n(e),detection:r(t.detectionNodeId,t.pinned.detection,t.reasons.detection),decoder:r(t.decoderNodeId,t.pinned.decoder,t.reasons.decoder),audio:r(t.audioNodeId,t.pinned.audio,t.reasons.audio)})).filter(e=>e.detection.active||e.decoder.active||e.audio.active).toSorted(br)}function Tr(e){let t=new Map(e.map(e=>[e.id,e.name]));return e=>{let n=t.get(e);return n!==void 0&&n!==``?n:e}}function Er(e){let t=new Map(e.map(e=>[e.id,e.name]));return e=>t.get(e)??Y.t(`helpers.assignmentRows.cameraFallback`,{id:e})}function Dr(e,t,n){let r=[...new Set([...e.nodeId===null?[]:[e.nodeId],...t.map(e=>e.id)])];return[{value:`auto`,label:Y.t(`helpers.assignmentRows.auto`)},...r.map(e=>({value:e,label:Y.t(`helpers.assignmentRows.pinTo`,{node:n(e)})}))]}function Or({roleId:e,roleLabel:t,state:n,nameOf:r,colorByNodeId:a,emphasizeOnNodeId:o}){if(n.nodeId===null)return null;let s=n.nodeId,c=o===void 0?!1:n.active&&s===o;return i(St,{roleId:e,roleLabel:t,nodeName:r(s),colorId:et(a,s),emphasized:c,pinned:n.pinned})}function kr({detection:t,decoder:n,audio:r,nameOf:a,colorByNodeId:o,emphasizeOnNodeId:s}){let c=(e,t,n)=>i(Or,{roleId:e,roleLabel:t,state:n,nameOf:a,colorByNodeId:o,emphasizeOnNodeId:s},e);return e(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1.5`,children:[c(`detection`,`Detection`,t),c(`decode`,`Decode`,n),c(`audio`,`Audio`,r)]})}function Ar({snap:t}){let n=H(),{t:r}=X();if(t===void 0)return i(`div`,{className:`flex h-8 items-center text-[11px] text-foreground-subtle`,title:r(`assignments.assignmentStatusCell.noMetricsInTheLast`,`No metrics in the last 10 s — the camera has no session running`),children:r(`assignments.assignmentStatusCell.noLiveData`,`no live data`)});let{phase:a,actualFps:o,avgInferenceTimeMs:s,queueDepth:c,configuredFps:l,droppedFrames:u}=t.metrics,d=bn(a,n);return e(`div`,{className:`flex h-8 min-w-0 flex-col justify-center font-mono text-[10px] leading-tight tabular-nums`,children:[e(`span`,{className:`inline-flex min-w-0 items-center gap-1 ${d.textColor}`,children:[i(Kt,{phase:a,className:`h-2.5 w-2.5 shrink-0`}),i(`span`,{className:`truncate font-semibold uppercase tracking-wider`,children:d.label}),i(`span`,{className:`text-foreground`,children:o.toFixed(1)}),i(`span`,{className:`text-foreground-subtle`,children:r(`pipeline.assignmentStatusCell.configuredFps`,{fps:l.toFixed(0)})})]}),e(`span`,{className:`truncate text-foreground-subtle`,children:[i(`span`,{className:`text-foreground`,children:s.toFixed(0)}),` ms`,c>0&&e(`span`,{className:`ml-1 text-warning`,children:[`q`,c]}),i(`span`,{className:u>0?`ml-1 text-warning`:`ml-1`,children:r(`pipeline.assignmentStatusCell.drops`,{count:u})})]})]})}s();var jr=1e4,Mr=5e3;function Nr(e){let[t,n]=o(new Map);return Ft(`pipeline.camera-metrics-snapshot`,t=>{let r=t.data;typeof r.deviceId==`number`&&(e!==void 0&&r.nodeId!==e||n(e=>new Map(e).set(r.deviceId,r)))}),a(()=>{if(t.size===0)return;let e=setInterval(()=>{n(e=>{let t=Date.now()-jr,n=[...e].filter(([,e])=>e.timestamp>=t);return n.length===e.size?e:new Map(n)})},Mr);return()=>clearInterval(e)},[t.size]),t}var Pr=3e5;function Fr({state:e,onlineNodes:t,nameOf:n,pending:r,onChange:a}){let{t:o}=X();return i(I,{"aria-label":o(`assignments.placementControls.nodePin`,`Node pin`),title:o(`assignments.placementControls.autoLetsEachSessionPick`,`Auto lets each session pick its node; a pin keeps the camera on one node.`),value:e.pinned&&e.nodeId!==null?e.nodeId:`auto`,disabled:r,options:[...Dr(e,t,n)],onChange:e=>a(e.target.value)})}function Ir({deviceId:e,nodeId:t}){let{t:n}=X(),r=l(),{data:a}=At({deviceId:e},{refetchOnMount:`always`}),{data:o}=Et({nodeId:t},{staleTime:Pr}),s=Wt({onSuccess:()=>{r.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineDevicePin`]]})}});if(a===void 0||o===void 0)return i(`span`,{className:`text-[10px] italic text-foreground-subtle`,children:n(`assignments.placementControls.accelerator`,`accelerator: …`)});let c=o.devices??[],u=c.filter(e=>e.enabled),d=a?.deviceKey??`auto`,f=d!==`auto`&&!u.some(e=>e.key===d),p=c.find(e=>e.key===d),m=[{value:`auto`,label:n(`assignments.placementControls.anyAccelerator`,`Any accelerator`)},...f?[{value:d,label:n(`pipeline.placementControls.notEnabled`,{name:p?`${Qt(p)} (${d})`:d})}]:[],...u.map(e=>({value:e.key,label:`${Qt(e)} · ${e.format}`}))];return i(I,{"aria-label":n(`assignments.placementControls.inferenceDevicePin`,`Inference device pin`),title:n(`assignments.placementControls.pinDetectionToOneAccelerator`,`Pin detection to one accelerator of the node, or let each session pick.`),value:d,disabled:s.isPending,options:m,onChange:t=>s.mutate({deviceId:e,deviceKey:t.target.value})})}s();function Lr(e){let n=t(null);return e.nodeId!==null&&(n.current=e),n.current}function Rr({deviceId:t,state:n,...r}){let{t:a}=X(),o=Lr(n);return e(`div`,{className:`grid w-80 grid-cols-2 gap-1.5`,children:[i(Fr,{state:n,...r}),o?.nodeId==null?i(I,{"aria-label":a(`assignments.clusterRowCells.inferenceDevicePinNoNode`,`Inference device pin (no node yet)`),title:a(`assignments.clusterRowCells.anAcceleratorIsPinnedOn`,`An accelerator is pinned on the camera's node; this camera has not run on one yet.`),disabled:!0,defaultValue:`auto`,options:[{value:`auto`,label:a(`assignments.clusterRowCells.anyAccelerator`,`Any accelerator`)}]}):i(Ir,{deviceId:t,nodeId:o.nodeId})]})}function zr({state:t,nameOf:n}){let{t:r}=X(),a=Lr(t);if(a?.nodeId==null)return i(`span`,{className:`text-[11px] text-foreground-subtle`,children:r(`assignments.clusterRowCells.noSessionYet`,`— no session yet`)});let o=t.active&&t.nodeId!==null,s=a.pinned?`pinned`:`auto · ${a.reason||`capacity`}`;return e(`div`,{"data-testid":`resolved-placement`,className:`flex w-40 min-w-0 flex-col leading-tight`,title:a.pinned?void 0:r(`assignments.clusterRowCells.anUnpinnedCameraIsPlaced`,`An unpinned camera is placed again at every session start, so this can change between sessions.`),children:[e(`span`,{className:`flex min-w-0 items-center gap-1.5 text-xs`,children:[i(`span`,{"aria-hidden":!0,className:`h-1.5 w-1.5 shrink-0 rounded-full ${o?`bg-success`:`bg-foreground-subtle/40`}`}),i(`span`,{"data-testid":`resolved-placement-node`,className:`truncate font-medium ${o?`text-foreground`:`text-foreground-muted`}`,children:n(a.nodeId)})]}),i(`span`,{className:`truncate pl-3 text-[10px] ${a.pinned?`text-warning`:`text-foreground-subtle`}`,children:o?s:r(`assignments.clusterRowCells.idleLastSession`,`{{how}} · idle, last session`,{how:s})})]})}function Br({deviceId:t,deviceName:n}){let{t:r}=X(),[a,s]=o(!1);return e(d,{children:[i(Ke,{icon:O,variant:`ghost`,size:`sm`,"aria-label":r(`assignments.clusterRowCells.streamBrokersOf`,`Stream brokers of {{deviceName}}`,{deviceName:n}),title:r(`assignments.clusterRowCells.streamBrokersClients`,`Stream brokers & clients`),onClick:()=>s(!0)}),i(xt,{open:a,onOpenChange:s,children:e($e,{width:`lg`,scroll:`body`,placement:`sheet-on-mobile`,children:[i(it,{children:i(Mt,{children:r(`pipeline.clusterRowCells.brokersTitle`,{device:n})})}),i(Ot,{children:a&&i(Tt,{widgetId:`stream-broker/stream-broker-panel`,host:`device-tab`,deviceId:t,instanceId:`pipeline-row/${t}`,config:{variant:`compact`}})})]})})]})}function Vr(e){return e.hasFreshMetrics?`active`:e.hasPipelineAssignment?`recently-active`:`inactive`}function Hr(e,t){return t.size===0?!0:t.has(e)}var Ur=[{value:`active`,get label(){return Y.t(`helpers.cameraActivity.active`)}},{value:`recently-active`,get label(){return Y.t(`helpers.cameraActivity.recentlyActive`)}},{value:`inactive`,get label(){return Y.t(`helpers.cameraActivity.inactive`)}}];s();var Wr=[`pipeline.camera-assigned`,`pipeline.camera-unassigned`,`pipeline.camera-updated`,`agent.online`,`agent.offline`];function Gr(e){for(let t of[`getPipelineAssignments`,`getAudioAssignments`,`getCameraStatuses`])e.invalidateQueries({queryKey:[[`pipelineOrchestrator`,t]]})}function Kr(){let{t}=X(),r=l();Bt([`pipelineOrchestrator`,`getPipelineAssignments`],Wr),Bt([`pipelineOrchestrator`,`getAudioAssignments`],Wr),Bt([`pipelineOrchestrator`,`getCameraStatuses`],Wr);let{data:a}=It({isCamera:!0,projection:`slim`}),{data:s}=Ct(void 0),{data:c}=Zt(void 0),{data:u}=rt({}),{data:d}=dn(void 0),{nodes:f}=J(),p=Nr(),m=n(()=>Tr(f),[f]),h=n(()=>kt(d),[d]),g=n(()=>f.filter(e=>e.isOnline).map(e=>({id:e.id,name:e.name})),[f]),_=n(()=>Cr(xr((a??[]).map(e=>({id:e.id,name:e.name,disabled:e.disabled})),s??[],c??[]),u??[]),[a,s,c,u]),[v,y]=o(()=>new Set),b=n(()=>_.filter(e=>Hr(Vr({hasPipelineAssignment:e.pipeline.active,hasFreshMetrics:p.has(e.deviceId)}),v)),[_,p,v]),x=e=>{y(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},S=()=>Gr(r),C=Xe({onSuccess:S}),w=Yt({onSuccess:S}),T=C.isPending||w.isPending,E=[{key:`camera`,header:t(`pipeline.cameraAssignmentsTable.camera`,`Camera`),width:`w-44`,sortValue:e=>e.deviceName,render:n=>e(`div`,{className:`flex w-44 min-w-0 items-center gap-1.5`,children:[i(On,{to:`/devices/${String(n.deviceId)}`,className:`min-w-0 truncate text-xs font-medium text-primary hover:underline`,title:n.deviceName,children:n.deviceName}),n.disabled&&i(K,{variant:`default`,children:t(`common.off`)})]})},{key:`placement`,header:t(`pipeline.cameraAssignmentsTable.placement`,`Placement`),width:`w-80`,notSortableReason:`A pair of controls — editing one would move the row under the cursor.`,render:e=>i(Rr,{deviceId:e.deviceId,state:e.pipeline,onlineNodes:g,nameOf:m,pending:T,onChange:t=>t===`auto`?w.mutate({deviceId:e.deviceId}):C.mutate({deviceId:e.deviceId,agentNodeId:t})})},{key:`roles`,header:t(`pipeline.cameraAssignmentsTable.rolesHere`,`Roles here`),notSortableReason:`A set of roles has no single order.`,render:e=>i(kr,{detection:e.detection,decoder:e.decoder,audio:e.audio,nameOf:m,colorByNodeId:h})},{key:`resolved`,header:t(`pipeline.cameraAssignmentsTable.runningOn`,`Running on`),width:`w-40`,sortValue:e=>e.pipeline.nodeId===null?null:m(e.pipeline.nodeId),render:e=>i(zr,{state:e.pipeline,nameOf:m})},{key:`status`,header:t(`pipeline.cameraAssignmentsTable.status`,`Status`),width:`w-40`,sortValue:e=>p.get(e.deviceId)?.metrics.actualFps??null,render:e=>i(Ar,{snap:p.get(e.deviceId)})},{key:`brokers`,header:``,align:`right`,width:`w-10`,notSortableReason:`An action`,render:e=>i(Br,{deviceId:e.deviceId,deviceName:e.deviceName})}],ee=a===void 0?`Loading cameras…`:_.length===0?`No cameras`:`No cameras match this activity filter.`;return e(`div`,{className:`flex flex-col gap-2`,children:[i(`nav`,{"aria-label":t(`pipeline.cameraAssignmentsTable.filterByCameraActivity`,`Filter by camera activity`),"data-testid":`assignments-activity-filter`,children:i(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1.5`,children:Ur.map(e=>{let t=v.has(e.value);return i(`button`,{type:`button`,"aria-pressed":t,"data-testid":`assignments-activity-${e.value}`,className:F(ae,t?re:M),onClick:()=>x(e.value),children:e.label},e.value)})})}),i(Cn,{columns:E,rows:b,rowKey:e=>e.deviceId,minWidthPx:920,maxBodyHeight:Ge,emptyMessage:ee})]})}s();function qr({nodeId:e}){let{t}=X(),r=l();Bt([`pipelineOrchestrator`,`getCameraStatuses`],Wr);let{data:a}=rt({}),{data:o}=dn(void 0),{data:s}=It({isCamera:!0,projection:`slim`}),{nodes:c}=J(),u=Nr(),d=n(()=>Tr(c),[c]),f=n(()=>kt(o),[o]),p=n(()=>wr(e,a??[],Er((s??[]).map(e=>({id:e.id,name:e.name})))),[e,a,s]),m=c.filter(t=>t.isOnline&&t.id!==e),h=()=>Gr(r),g=Xe({onSuccess:h}),_=Yt({onSuccess:h}),v=Ze({onSuccess:h}),y=an({onSuccess:h}),b=e=>[...e.detection.active?m.map(n=>({id:`detect-${n.id}`,label:t(`pipeline.nodeCameraAssignmentsTable.moveDetectionTo`,`Move detection to {{name}}`,{name:n.name}),onClick:()=>g.mutate({deviceId:e.deviceId,agentNodeId:n.id})})):[],...e.audio.active?m.map(n=>({id:`audio-${n.id}`,label:t(`pipeline.nodeCameraAssignmentsTable.moveAudioTo`,`Move audio to {{name}}`,{name:n.name}),onClick:()=>v.mutate({deviceId:e.deviceId,nodeId:n.id})})):[],{id:`unpin-detect`,label:t(`pipeline.nodeCameraAssignmentsTable.unpinDetection`,`Unpin detection`),hidden:!(e.detection.active&&e.detection.pinned),separatorBefore:!0,onClick:()=>_.mutate({deviceId:e.deviceId})},{id:`unpin-audio`,label:t(`pipeline.nodeCameraAssignmentsTable.unpinAudio`,`Unpin audio`),hidden:!(e.audio.active&&e.audio.pinned),onClick:()=>y.mutate({deviceId:e.deviceId})}];return i(Cn,{columns:[{key:`camera`,header:t(`pipeline.nodeCameraAssignmentsTable.camera`,`Camera`),width:`w-44`,sortValue:e=>e.deviceName,render:e=>i(On,{to:`/devices/${String(e.deviceId)}`,className:`block w-44 truncate text-xs font-medium text-primary hover:underline`,title:e.deviceName,children:e.deviceName})},{key:`roles`,header:t(`pipeline.nodeCameraAssignmentsTable.rolesHere`,`Roles here`),notSortableReason:`A set of roles has no single order.`,render:t=>i(kr,{detection:t.detection,decoder:t.decoder,audio:t.audio,nameOf:d,colorByNodeId:f,emphasizeOnNodeId:e})},{key:`status`,header:t(`pipeline.nodeCameraAssignmentsTable.status`,`Status`),width:`w-40`,sortValue:e=>u.get(e.deviceId)?.metrics.actualFps??null,render:e=>i(Ar,{snap:u.get(e.deviceId)})},{key:`actions`,header:``,align:`right`,width:`w-10`,notSortableReason:`Actions`,render:e=>i(He,{items:b(e),title:t(`pipeline.nodeCameraAssignmentsTable.move`,`Move {{deviceName}}`,{deviceName:e.deviceName})})}],rows:p,rowKey:e=>e.deviceId,minWidthPx:560,maxBodyHeight:Ge,emptyMessage:a===void 0?t(`pipeline.nodeCameraAssignmentsTable.loadingCameras`,`Loading cameras…`):t(`pipeline.nodeCameraAssignmentsTable.noCameraRunsOnThis`,`No camera runs on this node right now`)})}function Jr({nodeId:t,refreshToken:n}){let{t:r}=X(),{nodes:a}=J(),o=a.find(e=>e.id===t)?.name??t;return e(`div`,{className:`space-y-3 sm:space-y-4`,children:[i(vr,{refreshToken:n,nodeId:t}),e(`div`,{className:`space-y-2`,children:[e(`div`,{children:[i(`h3`,{className:`text-sm font-semibold text-foreground`,children:r(`pipeline.nodeCamerasTab.camerasOn`,{node:o})}),i(`p`,{className:`text-[11px] text-foreground-subtle`,children:r(`pipeline.nodeCamerasTab.theRolesEachCameraRuns`,`The roles each camera runs here right now. Move a role or unpin it from the row menu; pins for every camera are on Cluster → Assignments.`)})]}),i(qr,{nodeId:t})]})]})}s();function Yr(e,t){let n=Math.max(0,t-e),r=Math.floor(e/1e3),i=Math.floor(n/1e3);return Y.t(`pipeline.nodeEnginesTab.idleLeft`,{idle:r,left:i})}function Xr({nodeId:t,refreshToken:r}){let{t:a}=X(),o=l(),s=P(),c=yt({onSettled:()=>{o.invalidateQueries({queryKey:[`pipelineExecutor`,`listLoadedEngines`]})}}),{data:u}=qe({nodeId:t}),d=Nt(`pipeline.engine-metrics-snapshot`,e=>e.nodeId===t)?.engines??u??null,f=d===null;Bt([`pipelineRunner`,`getLocalCameras`],[`pipeline.camera-assigned`,`pipeline.camera-unassigned`]);let{data:p}=Rt({nodeId:t}),{values:m}=jt(`pipeline.camera-metrics-snapshot`,e=>e.deviceId,e=>e.nodeId===t),h=n(()=>m.filter(e=>e.metrics.phase===`active`).length,[m]),g=e=>{let n=p??[];if(n.length===0){c.mutate({nodeId:t,engine:e,force:!1});return}(async()=>{await s({title:a(`pipeline.nodeEnginesTab.killEngine`,`Kill engine`),message:`${String(n.length)} camera(s) are dispatching through this engine. Killing it drops their in-flight work and forces a respawn on the next frame.`,confirmLabel:a(`pipeline.nodeEnginesTab.killEngine`,`Kill engine`),variant:`danger`})&&c.mutate({nodeId:t,engine:e,force:!0})})()};return e(`div`,{className:`space-y-6`,children:[e(`div`,{children:[i(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:a(`pipeline.nodeEnginesTab.inferenceEnginesOnThisNode`,`Inference engines on this node`)}),i(`p`,{className:`text-[11px] text-foreground-subtle`,children:a(`pipeline.nodeEnginesTab.summary`,{engines:(d??[]).length,cameras:(p??[]).length,active:h})})]}),i(`div`,{className:`rounded-lg border border-border overflow-x-auto`,children:e(`table`,{className:`w-full text-xs min-w-[640px]`,children:[i(`thead`,{className:`bg-surface`,children:e(`tr`,{className:`text-foreground-subtle text-[10px] uppercase tracking-wider`,children:[i(`th`,{className:`text-left px-3 py-2 whitespace-nowrap`,children:a(`pipeline.nodeEnginesTab.kind`,`Kind`)}),i(`th`,{className:`text-left px-3 py-2 whitespace-nowrap`,children:a(`pipeline.nodeEnginesTab.runtimeBackendDevice`,`Runtime / Backend / Device`)}),i(`th`,{className:`text-left px-3 py-2`,children:a(`pipeline.nodeEnginesTab.models`,`Models`)}),i(`th`,{className:`text-right px-3 py-2 whitespace-nowrap`,children:a(`pipeline.nodeEnginesTab.poolPid`,`Pool PID`)}),i(`th`,{className:`text-right px-3 py-2 whitespace-nowrap`,children:a(`pipeline.nodeEnginesTab.autoKill`,`Auto-kill`)}),i(`th`,{className:`text-right px-3 py-2 whitespace-nowrap`,children:a(`pipeline.nodeEnginesTab.inUse`,`In use`)}),i(`th`,{className:`w-20`})]})}),e(`tbody`,{children:[f&&i(`tr`,{children:i(`td`,{colSpan:7,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:a(`common.loading`,`Loading…`)})}),!f&&(d??[]).map(t=>{let n=t.kind===`device-pool`;return e(`tr`,{className:`border-t border-border ${n?`bg-primary/[0.05]`:``}`,children:[i(`td`,{className:`px-3 py-2`,children:e(`span`,{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded-full text-[10px] font-medium ${n?`bg-primary/15 text-primary`:`bg-success/15 text-success`}`,children:[i(n?Le:z,{className:`h-3 w-3`}),a(n?`pipeline.nodeEnginesTab.pool`:`pipeline.nodeEnginesTab.runtime`)]})}),i(`td`,{className:`px-3 py-2`,children:e(`span`,{className:`inline-flex items-center gap-1 text-[11px] text-sky-400`,children:[i(ie,{className:`h-3 w-3`}),t.engine.runtime,`/`,t.engine.backend,t.engine.device?`/${t.engine.device}`:``,t.engine.format?` · ${t.engine.format}`:``]})}),i(`td`,{className:`px-3 py-2`,children:t.modelsLoaded.length===0?i(`span`,{className:`text-foreground-subtle text-[11px]`,children:`—`}):i(`div`,{className:`flex flex-wrap gap-1`,children:t.modelsLoaded.map(e=>i(`span`,{className:`inline-block rounded bg-surface px-1.5 py-0.5 text-[10px] font-mono text-foreground-subtle`,children:e},e))})}),i(`td`,{className:`px-3 py-2 text-right font-mono text-foreground`,children:t.poolPid??`—`}),i(`td`,{className:`px-3 py-2 text-right text-[11px]`,children:t.idleMs!==null&&t.idleTtlMs!==null?i(`span`,{className:`text-foreground-subtle`,children:Yr(t.idleMs,t.idleTtlMs)}):i(`span`,{className:`text-foreground-subtle/50`,children:a(`common.never`)})}),i(`td`,{className:`px-3 py-2 text-right text-foreground`,children:(p??[]).length}),i(`td`,{className:`px-3 py-2 text-right`,children:n?i(`span`,{className:`text-[11px] text-foreground-subtle`,children:a(`common.auto`)}):e(q,{variant:`ghost`,size:`sm`,disabled:c.isPending,onClick:()=>g(t.engine),className:`text-danger hover:bg-danger/10 hover:text-danger`,children:[i(U,{className:`h-3.5 w-3.5`}),a(`pipeline.nodeEnginesTab.kill`,`Kill`)]})})]},t.engineKey)}),!f&&(d??[]).length===0&&i(`tr`,{children:i(`td`,{colSpan:7,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:a(`pipeline.nodeEnginesTab.noEnginesResidentTheFactory`,`No engines resident — the factory spins up on the first pipeline run.`)})})]})]})}),i(`div`,{className:`text-[10px] text-foreground-subtle leading-relaxed`,children:i(En,{i18nKey:`pipeline.nodeEnginesTab.legend`,components:{strong:i(`strong`,{className:`text-foreground`})}})}),c.isError&&i(Je,{message:a(`pipeline.nodeEnginesTab.killFailed`,{message:c.error instanceof Error?c.error.message:a(`common.unknownError`)})})]})}var Zr=`pipeline-runner`,Qr=200;function $r({nodeId:t}){let{t:n}=X();return e(`div`,{className:`flex flex-col gap-3`,children:[e(`div`,{children:[i(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:n(`pipeline.nodeLogsTab.runnerLogs`,`Runner logs`)}),i(`p`,{className:`text-[11px] text-foreground-subtle`,children:n(`pipeline.nodeLogsTab.description`,{node:t})})]}),i(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:i(on,{agentId:t,addonId:Zr,limit:Qr,maxHeight:`max-h-[calc(100vh-360px)]`,showScope:!0,showDeviceChip:!0,showFilters:!1,showSourceSelect:!0})})]})}s();function ei({nodeId:t,title:r}){let a=H(),{t:o}=X(),{data:s}=Tn(),{data:c}=Ct(void 0),l=n(()=>{let e=new Map;for(let t of s??[])e.set(t.id,t.name);return e},[s]),u=n(()=>{if(!t)return null;let e=new Set;for(let n of c??[])n.agentNodeId===t&&e.add(n.deviceId);return e},[t,c]),d=Nr(t),f=n(()=>{let e=[];for(let t of d.values())u&&!u.has(t.deviceId)||e.push(t);return e.sort((e,t)=>e.deviceId-t.deviceId),e},[d,u]);return f.length===0?e(`div`,{className:`rounded-md border border-border bg-surface px-3 py-2 text-[11px] text-foreground-subtle italic`,children:[r??o(`pipeline.cameraStatusStrip.cameras`,`Cameras`),`: no live snapshots yet`]}):e(`div`,{className:`rounded-md border border-border bg-surface px-3 py-2`,children:[e(`div`,{className:`flex items-center gap-2 mb-1.5`,children:[i(`span`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle`,children:r??o(`pipeline.cameraStatusStrip.cameras`,`Cameras`)}),i(`span`,{className:`text-[10px] text-foreground-subtle`,children:f.length})]}),i(`div`,{className:`flex flex-wrap gap-1.5`,children:f.map(t=>{let n=l.get(t.deviceId)??`#${t.deviceId}`,r=bn(t.metrics.phase,a);return e(`div`,{title:o(`pipeline.cameraStatusStrip.fpsMsInferQ`,`{{name}} · {{label}} · {{value3}} fps · {{value4}}ms infer · q={{queueDepth}}`,{name:n,label:r.label,value3:t.metrics.actualFps.toFixed(1),value4:t.metrics.avgInferenceTimeMs.toFixed(0),queueDepth:t.metrics.queueDepth}),className:`inline-flex items-center gap-1 rounded border px-1.5 py-0.5 text-[10px] ${r.badgeClass}`,children:[i(Kt,{phase:t.metrics.phase,className:`h-2.5 w-2.5`}),i(`span`,{className:`font-medium text-foreground/90 max-w-[220px] truncate`,children:n}),i(`span`,{className:`font-mono tabular-nums`,children:t.metrics.actualFps.toFixed(1)}),i(`span`,{className:`opacity-60`,children:o(`common.fpsWord`)})]},t.deviceId)})})]})}function ti(e,t,n,r){let i=t===void 0?void 0:e.find(e=>e.key===t)?.steps?.[n]?.settings,a={...r?.[n],...i};return Object.keys(a).length>0?a:void 0}function ni(e){let t={};for(let n of e){let e=Object.keys(n.steps).length>0;t[n.key]={enabled:n.enabled,weight:Math.max(1,n.weight),...n.maxSessions!==null&&n.maxSessions>0?{maxSessions:n.maxSessions}:{},...e?{steps:n.steps}:{}}}return t}var ri=`pipeline-analytics`,ii=`face-gallery`,ai=`pipeline-orchestrator`,oi=`pipeline-runner`,si=`audio-analyzer`,ci=`stream-broker`,li=`snapshot`,ui=`recorder`,di=`embedding-encoder`,fi=`recordingNodeId`;function pi(e){return[...Ce.filter(t=>t.stepId===e).map(e=>be(e.stepId)),...Se.filter(t=>t.stepId===e).map(e=>Te(e.stepId,e.key))]}var mi=`faces`,hi=`semantic-search`,gi=`load-balancer`,_i=`streaming`,vi=`recorder`,yi=`load`,bi=[{id:mi,get title(){return Y.t(`helpers.clusterSettingsSections.facesTitle`)},get hint(){return Y.t(`helpers.clusterSettingsSections.facesHint`)},panels:[{addonId:ai,fieldKeys:pi(`face-embedding`)},{addonId:ri,capability:ii},{addonId:ai,sectionIds:[ye]}]},{id:hi,get title(){return Y.t(`helpers.clusterSettingsSections.semanticTitle`)},get hint(){return Y.t(`helpers.clusterSettingsSections.semanticHint`)},panels:[{addonId:ai,fieldKeys:pi(`clip-embedding`)},{addonId:di,capability:`embedding-encoder`,fieldScope:`cluster`}]},{id:he,get title(){return Y.t(`helpers.clusterSettingsSections.cropTitle`)},get hint(){return Y.t(`helpers.clusterSettingsSections.cropHint`)},panels:[{addonId:ai,sectionIds:[he]}]},{id:xe,get title(){return Y.t(`helpers.clusterSettingsSections.nativeTitle`)},get hint(){return Y.t(`helpers.clusterSettingsSections.nativeHint`)},panels:[{addonId:ai,sectionIds:[xe]}]},{id:_i,get title(){return Y.t(`helpers.clusterSettingsSections.streamingTitle`)},get hint(){return Y.t(`helpers.clusterSettingsSections.streamingHint`)},panels:[{addonId:ci,capability:`stream-broker`,fieldScope:`cluster`},{addonId:li,capability:`snapshot`,fieldScope:`cluster`}]},{id:vi,get title(){return Y.t(`helpers.clusterSettingsSections.recorderTitle`)},get hint(){return Y.t(`helpers.clusterSettingsSections.recorderHint`)},panels:[{addonId:ui,capability:`recording`,fieldScope:`cluster`,omitFieldKeys:[fi]}]},{id:`runner-defaults`,get title(){return Y.t(`helpers.clusterSettingsSections.runnerTitle`)},get hint(){return Y.t(`helpers.clusterSettingsSections.runnerHint`)},panels:[{addonId:oi,fieldScope:`cluster`},{addonId:si,fieldScope:`cluster`}]},{id:gi,get title(){return Y.t(`helpers.clusterSettingsSections.loadTitle`)},get hint(){return Y.t(`helpers.clusterSettingsSections.loadHint`)},panels:[{addonId:ai,sectionIds:[yi]}]},{id:`failover`,get title(){return Y.t(`helpers.clusterSettingsSections.failoverTitle`)},get hint(){return Y.t(`helpers.clusterSettingsSections.failoverHint`)},panels:[{addonId:ai,sectionIds:[`failover`]}]}],xi={"cluster-step-models":mi};function Si(e){return e===`clip-embedding`?hi:mi}var Ci=`ctab`,wi=`section`;function Ti(e,t){let n=new URLSearchParams({view:`nodes`,node:ss,[Ci]:e});return t!==void 0&&n.set(wi,t),`/system/pipeline?${n.toString()}`}function Ei(e){return Ti(`settings`,Si(e))}function Di(){return Ti(`load-balancing`)}var Oi=`pipeline-orchestrator`;function ki(e){return Ce.find(t=>t.stepId===e)??null}function Ai({step:t,engineFormat:n,runnableModelIds:r}){let{t:a}=X(),{data:o}=ze({addonId:Oi,cap:Oi,scope:`cluster`}),s=De(o??null)[t.stepId]??t.defaultModelId,c=t.options.find(e=>e.id===s)?.label??s,l=r.length>0&&!r.includes(s);return e(`div`,{className:`space-y-2 rounded-md border border-primary/30 bg-primary/5 px-3 py-2`,children:[e(`div`,{className:`flex flex-wrap items-center gap-2 text-xs`,children:[i(`span`,{className:`font-medium text-foreground`,children:t.label}),i(`span`,{className:`font-mono text-foreground`,children:c}),i(`span`,{title:a(`pipeline.clusterStepModel.oneValueForTheWhole`,`One value for the whole cluster — this step writes into a shared vector index, where two encoders make similarity scores meaningless.`),className:`rounded border border-primary/40 bg-primary/10 px-1 py-px text-[9px] font-medium uppercase tracking-wide text-primary`,children:a(`pipeline.clusterStepModel.clusterWide`)}),i(On,{to:Ei(t.stepId),className:`ml-auto text-[11px] text-primary hover:underline`,children:a(`pipeline.clusterStepModel.changeInClusterSettings`,`Change in Cluster → Settings ›`)})]}),e(`p`,{className:W,children:[a(`pipeline.clusterStepModel.oneModelForEveryNode`,`One model for every node and camera:`),` `,a(`pipeline.clusterStepModel.indexNote`,{index:t.indexName})]}),l&&i(`p`,{className:`rounded border border-warning/40 bg-warning/10 px-2 py-1 text-[10px] leading-snug text-warning`,children:i(En,{i18nKey:`pipeline.clusterStepModel.noBuild`,values:{engine:n,model:s,index:t.indexName},components:{b:i(`b`,{})}})})]})}var ji=`pipeline-orchestrator`;function Mi({addonId:t,highlightLabel:n}){let{t:r}=X(),a=ge(t),{data:o}=ze({addonId:ji,cap:ji,scope:`cluster`});if(a.length===0)return null;let s=_e(o??null)[t]??{};return e(`section`,{className:`space-y-1.5 border-t border-border/60 pt-3`,"aria-label":r(`stepInspector.clusterOwnedSettings.clusterWideSettings`,`Cluster-wide settings`),children:[e(`div`,{className:`flex flex-wrap items-center gap-2`,children:[i(`h3`,{className:D,children:r(`stepInspector.clusterOwnedSettings.clusterWideSettings`,`Cluster-wide settings`)}),i(On,{to:Ei(t),className:`ml-auto text-[11px] text-primary hover:underline`,children:r(`stepInspector.clusterOwnedSettings.editInClusterSettings`,`Edit in Cluster → Settings ›`)})]}),a.map(t=>e(`div`,{className:`${p} rounded px-2 ${n===t.label?`bg-primary/5 ring-1 ring-primary/40`:``}`,children:[i(`span`,{className:R,children:t.label}),i(`span`,{className:y,children:i(`span`,{className:`font-mono text-xs text-foreground`,children:String(s[t.key]??t.default)})})]},t.key)),i(`p`,{className:W,children:r(`stepInspector.clusterOwnedSettings.oneValueForEveryNode`,`One value for every node and camera — this step writes into a shared index.`)})]})}function Ni({rows:t,hint:n}){let{t:r}=X();return e(`div`,{className:`space-y-1.5`,"data-testid":`effective-models`,children:[i(`ul`,{className:`divide-y divide-border rounded-md border border-border`,children:t.map(t=>e(`li`,{className:`${T} flex flex-wrap items-baseline gap-x-2 text-xs`,children:[i(`span`,{className:t.href===void 0?`min-w-0 flex-1 truncate text-foreground-muted`:`basis-full text-foreground-muted`,children:t.label}),i(`span`,{className:`font-mono text-foreground`,children:t.modelId??`—`}),i(`span`,{className:`text-[10px] text-foreground-subtle`,children:t.sourceLabel}),t.href!==void 0&&i(On,{to:t.href,className:`ml-auto text-[11px] text-primary hover:underline`,children:r(`stepInspector.effectiveModelSummary.changeOnAccelerator`)})]},t.id))}),i(`p`,{className:W,children:n??r(`stepInspector.effectiveModelSummary.toChangeAModelOpen`,`To change a model, open that accelerator's cell in the table.`)})]})}s();function Pi(e){return{agentNodeId:e.nodeId,nodeLabel:e.nodeLabel,engineLabel:e.device.format,deviceKey:e.deviceKey,deviceLabel:Qt(e.device),detail:e.device.defaultModelId,disabled:e.disabled}}function Fi({tree:a,searchRows:s,accelerators:c,cellState:l,stepBadge:u,disabledCount:d,showDisabled:f,onShowDisabledChange:p,dirty:m,onDiscard:h,summary:g,toolbar:_,label:v,renderDetail:y}){let{t:b}=X(),x=P(),C=$t(),{selection:w,open:T,close:ee}=Bn(n(()=>jn(a).map(e=>e.node.addonId),[a]),n(()=>c.map(e=>e.id),[c])),[D,O]=o(``),[k,A]=o(null),[j,te]=o(null),M=t(null),ne=t(null),N=t(null);Xt(N);let F=t(null),I=n(()=>wt(s,D),[s,D]),L=n(()=>D.trim()===``?a:Un(a,new Set(I.map(e=>e.addonId))),[a,I,D]),R=e=>I.find(t=>t.addonId===e)?.matchedField??null,z=n(()=>c.map(Pi),[c]),B=e=>c.find(t=>t.nodeId===e.agentNodeId&&t.deviceKey===e.deviceKey),V=c.find(e=>e.id===w.acceleratorId)??null,H=w.stepId!==null,U=r(async e=>{if(m){if(!await x({title:b(`stepInspector.stepMatrixFrame.discardUnsavedChanges`,`Discard unsaved changes?`),message:b(`stepInspector.stepMatrixFrame.thisStepHasChangesThat`,`This step has changes that are not saved yet.`),confirmLabel:b(`stepInspector.stepMatrixFrame.discard`,`Discard`),variant:`danger`}))return;h()}e()},[x,m,h,b]),re=()=>{requestAnimationFrame(()=>F.current?.focus())},ie=(e,t,n=!1)=>{if(e===w.stepId&&(t?.id??null)===w.acceleratorId){n&&re();return}let r=()=>{A(R(e)),T({stepId:e,...t===void 0?{}:{acceleratorId:t.id}}),n&&re()};e===w.stepId?r():U(r)},ae=()=>{let e=w.stepId;U(()=>{if(ee(),e!==null){let t=V===null?null:ln({agentNodeId:V.nodeId,deviceKey:V.deviceKey});requestAnimationFrame(()=>M.current?.focusCell(e,t))}})},oe=e=>{if(e.key===`Enter`){let t=I[0];if(t===void 0)return;e.preventDefault(),ie(t.addonId,void 0,!0)}else e.key===`Escape`&&O(``)},se=C?i(Dt,{onClick:ae}):i(Ke,{icon:E,variant:`ghost`,size:`sm`,"aria-label":b(`common.close`,`Close`),onClick:ae});return e(`div`,{ref:ne,className:`space-y-2`,onKeyDown:e=>{let t=e.target instanceof HTMLElement&&e.target.dataset.r!==void 0;e.key===`/`&&t&&(e.preventDefault(),N.current?.focus()),e.key===`Escape`&&t&&H&&(e.preventDefault(),ae())},children:[e(`div`,{className:`flex flex-wrap items-center gap-2 text-xs`,children:[i(`div`,{className:`min-w-0 basis-full sm:basis-auto`,children:g}),i(vt,{ref:N,type:`search`,value:D,onChange:e=>O(e.target.value),onKeyDown:oe,placeholder:b(`stepInspector.stepMatrixFrame.filterStepsOrSettings`,`Filter steps or settings /`),"aria-label":b(`stepInspector.stepMatrixFrame.filterStepsOrSettings2`,`Filter steps or settings`),className:`h-9 w-56 rounded-md border border-border bg-background px-2 text-xs text-foreground outline-none focus:border-primary focus:ring-1 focus:ring-primary/30 md:h-7`}),d>0&&e(`label`,{className:`inline-flex items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[i(S,{checked:f,onChange:e=>p(e.target.checked)}),b(`stepInspector.stepMatrixFrame.showDisabled`,{count:d})]}),_]}),w.staleStepId!==null&&i(`p`,{className:`rounded-md border border-warning/40 bg-warning/10 px-3 py-1.5 text-[11px] text-warning`,children:b(`stepInspector.stepMatrixFrame.staleStep`,{id:w.staleStepId})}),L.length===0?i(`p`,{className:`${W} rounded-md border border-dashed border-border px-3 py-4 text-center`,children:b(`stepInspector.stepMatrixFrame.noStepMatches`,{query:D})}):i(Jt,{ref:M,tree:L,agents:z,label:v,getCellState:(e,t)=>{let n=B(t);return n===void 0?{kind:`na`}:l(e,n)},onCellClick:(e,t,n)=>ie(e,B(t),n),onStepClick:(e,t)=>ie(e,void 0,t),...u===void 0?{}:{stepBadge:u},selectedCell:H&&w.stepId!==null&&V!==null?{addonId:w.stepId,agentNodeId:V.nodeId,deviceKey:V.deviceKey}:null,fallbackNodeId:j,onFallbackNodeChange:te,reserveRightPx:H&&!C?432:0}),i(st,{open:H,anchor:ne,onClose:ae,label:b(`stepInspector.stepMatrixFrame.stepSettings`,`Step settings`),children:w.stepId!==null&&y({stepId:w.stepId,accelerator:V,matchedField:k,closeButton:se,onEscape:ae,headingRef:e=>{F.current=e}})})]})}s();function Ii(e){a(()=>{if(e===null)return;let t=document.getElementById(e);t===null||typeof t.scrollIntoView!=`function`||t.scrollIntoView({block:`center`,behavior:`smooth`})},[e])}s();function Li(e,t,n){return e.map(e=>{let r={...e.steps},i=r[t.stepId]??{},a=t.models[e.key],o=t.jumps[e.key],s=t.accelerator?.deviceKey===e.key?{...Object.fromEntries(Object.entries(i.settings??{}).filter(([e])=>!n(e))),...t.accelerator.settings}:i.settings,c=s!==void 0&&Object.keys(s).length>0?s:void 0,l=a===void 0?i.modelId:a??void 0,u=o===void 0?i.jumpDeviceKey:o||void 0,d={...l===void 0?{}:{modelId:l},...c===void 0?{}:{settings:c},...u===void 0?{}:{jumpDeviceKey:u}};return Object.keys(d).length>0?r[t.stepId]=d:delete r[t.stepId],{key:e.key,enabled:e.enabled,weight:e.weight,maxSessions:e.maxSessions,steps:r}})}function Ri(e,t){return t===void 0?0:[...new Set([...Object.keys(e),...Object.keys(t)])].filter(n=>!Ee(e[n],t[n])).length}function zi(e,t,n,r){if(t===null)return 0;let i=Object.entries(t.models).filter(([n,r])=>(r??void 0)!==e.find(e=>e.key===n)?.steps?.[t.stepId]?.modelId).length,a=Object.entries(t.jumps).filter(([n,r])=>(r||void 0)!==e.find(e=>e.key===n)?.steps?.[t.stepId]?.jumpDeviceKey).length,o=Ri(n,t.nodeSettings),s=t.accelerator===void 0?0:Ri(r(t.accelerator.deviceKey),t.accelerator.settings);return i+a+o+s}function Bi({nodeId:t,nodeName:r,toolbar:a}){let{t:s}=X(),c=l(),u=Et({nodeId:t},{refetchOnMount:`always`}),f=xn({nodeId:t},{refetchOnMount:`always`}),p=Ue({agentNodeId:t},{refetchOnMount:`always`}),m=p.data?.stepSettings,h=De(ze({addonId:`pipeline-orchestrator`,cap:`pipeline-orchestrator`,scope:`cluster`}).data??null),g=u.data?.devices??[],_=f.data??null,[v,y]=o(null),[b,x]=o(null),[S,C]=o(null),w=Gt({onSuccess:()=>{c.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getNodeInferenceDevices`]]})}}),T=gn({onSuccess:()=>{c.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getAgentSettings`]]})}}),[E,ee]=o(!1),O=n(()=>_?We(_):[],[_]),k=n(()=>jn(O),[O]),[A,j]=o(!1),te=n(()=>Wn(t,r,g,A),[t,r,g,A]),M=n(()=>Wn(t,r,g),[t,r,g]),ne=M.length>=2,N=(e,t)=>ti(g,t?.deviceKey,e,m)??{},P=e=>m?.[e]??{},F=(e,t)=>g.find(e=>e.key===t)?.steps?.[e]?.settings??{},L=(e,t,n)=>{let r=n??t.device.steps?.[e?.id??``]?.jumpDeviceKey;if(r!==void 0&&r!==``)return M.find(e=>e.deviceKey===r);if(!zn(e,t))return M.filter(n=>n.id!==t.id&&zn(e,n)).toSorted((e,t)=>e.deviceKey.localeCompare(t.deviceKey))[0]},R=(e,t)=>{let n=Rn(_,e),r=ki(e),i=Nn(_,t),a=N(e,t),o=L(n,t);return Vn({addon:n,acc:t,gatedOn:n?.enabledByDefault??!0,model:n?Fn(n,t,{nodePin:t.device.steps?.[e]?.modelId}):{modelId:void 0,source:`default`},...Hn(e,a,i)&&i?{rootName:i.name}:{},...r?{clusterModelId:h[e]??r.defaultModelId}:{},...o?{jumpTo:Ve(o.device)}:{}})},z=k.map(({node:e})=>({addonId:e.addonId,name:e.addonName,fieldLabels:Pn(Rn(_,e.addonId))}));if(u.isLoading||f.isLoading||p.isLoading)return i(`div`,{className:`animate-pulse p-4 text-xs text-foreground-subtle`,children:s(`stepInspector.nodeStepInspector.loadingPipeline`,`Loading pipeline…`)});if(_===null)return i(`div`,{className:`p-4 text-xs text-foreground-subtle`,children:s(`stepInspector.nodeStepInspector.catalogUnavailable`,`Catalog unavailable.`)});let B=e(`span`,{className:W,children:[s(`stepInspector.nodeStepInspector.accelerators`,`Accelerators:`),` `,i(`span`,{className:`text-foreground`,children:M.length>0?M.map(e=>Ve(e.device)).join(` · `):s(`stepInspector.nodeStepInspector.noneEnabled`,`none enabled`)}),g.some(e=>!e.enabled)&&e(d,{children:[` `,s(`stepInspector.nodeStepInspector.off`,`— off:`),` `,g.filter(e=>!e.enabled).map(Ve).join(`, `)]}),` `,`·`,` `,i(On,{to:Di(),className:`text-primary hover:underline`,children:s(`stepInspector.nodeStepInspector.clusterLoadBalancing`,`Cluster → Load balancing ›`)})]});return i(Fi,{tree:O,searchRows:z,accelerators:te,cellState:R,disabledCount:g.filter(e=>!e.enabled).length,showDisabled:A,onShowDisabledChange:j,dirty:v!==null&&zi(g,v,P(v.stepId),e=>F(v.stepId,e))>0,onDiscard:()=>y(null),summary:B,...a===void 0?{}:{toolbar:a},label:s(`stepInspector.nodeStepInspector.detectionSteps`,`Detection steps`),renderDetail:({stepId:n,accelerator:a,matchedField:o,closeButton:c,onEscape:l,headingRef:u})=>{let f=Rn(_,n);if(f===null)return i(`div`,{className:`p-4 text-xs text-foreground-subtle`,children:s(`stepInspector.nodeStepInspector.noStepSelected`,`No step selected.`)});let p=v?.stepId===n?v:null,m=a??M[0]??te[0],h=p?.nodeSettings??P(n),O=a===null?{}:p?.accelerator?.deviceKey===a.deviceKey?p.accelerator.settings:F(n,a.deviceKey),k={...h,...O},A=zi(g,p,P(n),e=>F(n,e)),j=e=>{C(null),y(t=>({...t?.stepId===n?t:{stepId:n,models:{},jumps:{}},...e}))},R=ki(n),z=Sn(f),{nodeFields:B,acceleratorFields:V}=Gn(z),H=new Set(V.flatMap(e=>`key`in e?[e.key,`${e.key}ModelId`]:[])),U=m===void 0?void 0:Nn(_,m),re=e=>{let t=p?.models[e.deviceKey];return t===void 0?e.device.steps?.[n]?.modelId:t??void 0},ie=m===void 0?void 0:Fn(f,m,{nodePin:re(m)}).modelId,ae=t=>{let r=re(t),o=Fn(f,t,{nodePin:r}),c=Nn(_,t),l=Hn(n,a?.id===t.id?k:N(n,t),c),u=p?.jumps[t.deviceKey],m=L(f,t,u),h=zn(f,t)?l&&c?i(zt,{rootModel:c,stepModelId:o.modelId}):void 0:e(d,{children:[s(`stepInspector.nodeStepInspector.noBuild`,{format:t.device.format}),` `,m?s(`stepInspector.nodeStepInspector.itRunsOnInstead`,`It runs on {{shortLabel}} instead.`,{shortLabel:m.shortLabel}):s(`stepInspector.nodeStepInspector.itDoesNotRunHere`,`It does not run here.`)]}),g=ne?e(`label`,{className:`block space-y-1`,children:[i(`span`,{className:`text-[11px] font-medium text-foreground`,children:s(`stepInspector.nodeStepInspector.runOn`,`Run on`)}),i(I,{"aria-label":s(`stepInspector.nodeStepInspector.runOn`,`Run on`),value:u??t.device.steps?.[n]?.jumpDeviceKey??``,options:[{value:``,label:s(`stepInspector.nodeStepInspector.autoThisAcceleratorOrThe`,`Auto (this accelerator, or the next one that can run it)`)},...M.filter(e=>e.id!==t.id).map(e=>({value:e.deviceKey,label:`${e.label} · ${e.device.format}`}))],onChange:e=>j({jumps:{...p?.jumps,[t.deviceKey]:e.target.value}})}),i(`span`,{className:W,children:s(`stepInspector.nodeStepInspector.routesThisStepAndIts`,`Routes this step (and its child steps) to another accelerator of this node.`)})]}):void 0;return{label:t.label,format:t.device.format,modelId:o.modelId,source:o.source===`node`?`node`:`default`,sourceLabel:o.source===`node`?`node pin`:`hardware default`,models:Ye(f.models??[],t.device.format),defaultModelId:f.defaultModelIdByFormat?.[t.device.format]??f.defaultModelId,expanded:b===t.id,onToggle:()=>x(e=>e===t.id?null:t.id),onChangeModel:e=>j({models:{...p?.models,[t.deviceKey]:e}}),...r===void 0?{}:{onReset:()=>j({models:{...p?.models,[t.deviceKey]:null}}),resetLabel:`Reset to hardware default`},...h===void 0?{}:{note:h},...g===void 0?{}:{extra:g},changed:p?.models[t.deviceKey]!==void 0||u!==void 0}},oe=async()=>{if(p!==null){ee(!0);try{(Object.keys(p.models).length>0||Object.keys(p.jumps).length>0||p.accelerator!==void 0)&&await w.mutateAsync({agentNodeId:t,inferenceDevices:ni(Li(g,p,e=>H.has(e)))}),p.nodeSettings!==void 0&&Ri(P(n),p.nodeSettings)>0&&await T.mutateAsync({agentNodeId:t,addonId:n,settings:Object.keys(p.nodeSettings).length>0?{...p.nodeSettings}:null}),y(null),C({kind:`saved`})}catch(e){C({kind:`error`,error:e instanceof Error?e.message:String(e)})}finally{ee(!1)}}};return i(bt,{ref:u,title:a===null?`${f.name} · ${r}`:`${f.name} · ${a.label}`,subtitle:a===null?s(`stepInspector.nodeStepInspector.everyAcceleratorOf`,`{{slot}} · every accelerator of {{nodeName}}`,{slot:f.slot,nodeName:r}):s(`stepInspector.nodeStepInspector.baseForEveryCameraThat`,`{{slot}} · {{format}} · base for every camera that lands here`,{slot:f.slot,format:a.device.format}),leading:c,onEscape:l,saveBar:{dirtyCount:A,saving:E,status:S?.kind??null,...S?.error===void 0?{}:{error:S.error},onSave:()=>void oe(),onDiscard:()=>y(null)},children:e(`div`,{className:`space-y-3`,children:[e(`section`,{className:`space-y-2`,"aria-label":s(`stepInspector.nodeStepInspector.model`,`Model`),children:[i(`h3`,{className:D,children:s(`stepInspector.nodeStepInspector.model`,`Model`)}),R!==null&&m!==void 0?i(Ai,{step:R,engineFormat:m.device.format,runnableModelIds:Ye(f.models??[],m.device.format).map(e=>e.id)}):te.length===0?i(`p`,{className:W,children:i(En,{i18nKey:`stepInspector.nodeStepInspector.noAcceleratorEnabled`,components:{link:i(On,{to:Di(),className:`text-primary hover:underline`})}})}):a===null?i(Ni,{rows:te.map(e=>{let t=Fn(f,e,{nodePin:re(e)});return{id:e.id,label:e.label,modelId:t.modelId,sourceLabel:t.source===`node`?`node pin`:`hardware default`}})}):i(nt,{...ae(a)},a.id)]}),(z.length>0||U!==void 0)&&R===null&&e(`section`,{"aria-label":s(`stepInspector.nodeStepInspector.settings`,`Settings`),className:`space-y-2 border-t border-border/60 pt-2`,children:[i(`p`,{className:`text-[10px] text-foreground-subtle`,"data-testid":`settings-scope`,children:s(`stepInspector.nodeStepInspector.nodeWideSettings`,{node:r})}),(B.length>0||U!==void 0)&&i(Vi,{addon:f,fields:B,settings:h,layerLabel:s(`stepInspector.nodeStepInspector.nodeLayer`,`Node`),modelId:_n(f,ie,k,U),root:U,highlight:o,onChange:e=>j({nodeSettings:e})}),V.length>0&&(a===null?i(`p`,{className:`text-[10px] text-foreground-subtle`,"data-testid":`accelerator-settings-hint`,children:s(`stepInspector.nodeStepInspector.thresholdsPerAccelerator`,`Confidence thresholds belong to the model, so they are set per accelerator: open that accelerator's cell.`)}):e(`div`,{className:`space-y-1 border-t border-border/60 pt-2`,children:[i(`p`,{className:`text-[10px] text-foreground-subtle`,"data-testid":`accelerator-settings-scope`,children:s(`stepInspector.nodeStepInspector.acceleratorSettings`,{accelerator:a.label})}),i(Vi,{addon:f,fields:V,settings:O,layerLabel:s(`stepInspector.nodeStepInspector.acceleratorLayer`,`This accelerator`),modelId:_n(f,ie,k,U),root:void 0,highlight:o,onChange:e=>j({accelerator:{deviceKey:a.deviceKey,settings:e}})})]}))]}),i(Mi,{addonId:n,highlightLabel:o})]})})}})}function Vi({addon:e,fields:t,settings:n,layerLabel:r,modelId:a,root:o,highlight:s,onChange:c}){let l=t.find(e=>`label`in e&&e.label===s)?.key??null;return Ii(l===null?null:yn(l)),i(Ht,{addon:e,fields:t,layers:{node:n},target:`node`,labels:{node:r},modelId:a,...o===void 0?{}:{rootModel:o},highlightKey:l,onChangeLayer:c})}s();function Hi({nodeId:t,refreshToken:n}){let{t:r}=X(),a=P(),[s,c]=o(null),{nodes:l}=J(),u=l.find(e=>e.id===t)?.name??t,f=Lt({onSuccess:e=>{c(e.effectiveModelId===null?`Reset done — model config cleared (node offline: effective model resolves on reconnect)`:`Reset done — effective detection model: ${e.effectiveModelId} (Auto)`)}}),p=async()=>{await a({title:r(`pipeline.nodePipelineTab.resetToHardwareAwareDefaults`,`Reset {{nodeName}} to hardware-aware defaults?`,{nodeName:u}),message:r(`pipeline.nodePipelineTab.thisClearsEveryPerDevice`,`This clears every per-device model default on this node (back to the format default) and every per-camera step override scoped to it. Existing per-camera customisations on this node are lost.`),confirmLabel:r(`common.reset`,`Reset`),variant:`danger`})&&(c(null),f.mutate({agentNodeId:t}))};return e(`div`,{className:`space-y-2`,children:[i(ei,{nodeId:t}),i(Bi,{nodeId:t,nodeName:u,toolbar:e(d,{children:[s&&i(`span`,{className:`text-[11px] text-success`,children:s}),f.isError&&i(`span`,{className:`text-[11px] text-danger`,children:f.error instanceof Error?f.error.message:r(`pipeline.nodePipelineTab.resetFailed`,`Reset failed`)}),i(q,{variant:`outline`,size:`sm`,onClick:()=>{p()},disabled:f.isPending,title:r(`pipeline.nodePipelineTab.clearThisNodeSPer`,`Clear this node's per-device model defaults + per-camera overrides scoped to this node`),children:f.isPending?r(`pipeline.nodePipelineTab.resetting`,`Resetting…`):r(`pipeline.nodePipelineTab.resetToDefault`,`Reset to default`)})]})})]})}var Ui=[`detection-pipeline`,`audio-analyzer`,`pipeline-runner`],Wi=`decoder-nodeav`,Gi=`ntab`,Ki={decoder:`engine`},qi={engine:`Engine & decoder`},Ji=`Nothing here is set per node. Cluster-wide values are on Cluster → Settings.`;function Yi({nodeId:t,refreshToken:n}){let{t:r}=X(),[a,o]=Dn(),{nodes:s}=J(),c=s.find(e=>e.id===t)?.addons.find(e=>e.capabilities.includes(`decoder`))?.addonId??Wi,l=[...Ui,c],u=a.get(Gi),d={assignments:{id:`assignments`,label:r(`pipeline.nodeDetail.assignments`,`Assignments`),order:-10,content:i(Jr,{nodeId:t,refreshToken:n})},tree:{id:`tree`,label:r(`pipeline.nodeDetail.pipeline`,`Pipeline`),order:39,content:i(Hi,{nodeId:t,refreshToken:n})},engines:{id:`engines`,label:r(`pipeline.nodeDetail.warmInstances`,`Warm instances`),order:180,content:i(Xr,{nodeId:t,refreshToken:n})},logs:{id:`logs`,label:r(`pipeline.nodeDetail.logs`,`Logs`),order:300,content:i($r,{nodeId:t})}},f=_r.map(e=>d[e]);return e(`div`,{className:`flex flex-col h-full`,children:[i(gr,{nodeId:t,refreshToken:n}),i(`div`,{className:`flex-1 min-h-0 overflow-y-auto p-4 sm:p-6`,children:i(kn,{nodeId:t,addonIds:l,level:`global`,fieldScope:`perNode`,emptyMessage:Ji,tabAliases:Ki,tabLabelOverrides:qi,extraTabs:f,activeTab:u===null?null:Ki[u]??u,onActiveTabChange:e=>o(t=>{let n=new URLSearchParams(t);n.set(Gi,e);for(let e of Ln)n.delete(e);return n},{replace:!0})})})]})}function Xi(){let{t}=X();return e(`div`,{className:`space-y-2`,children:[e(`div`,{className:`min-w-0`,children:[i(`h3`,{className:`text-sm font-semibold text-foreground`,children:t(`pipeline.clusterAssignmentsTab.cameraPlacement`,`Camera placement`)}),i(`p`,{className:`text-[11px] text-foreground-subtle`,children:t(`pipeline.clusterAssignmentsTab.pinACameraToA`,`Pin a camera to a node, or to one accelerator of its node; Auto lets each session pick. Decode always runs with detection. Load, shares and caps are on Load balancing.`)})]}),i(Kr,{})]})}function Zi(e){return`${Math.round(e*100)}%`}function Qi(e){return Y.t(`helpers.autoTuneViewModel.sessions`,{count:e})}var $i={"intel-npu":`Intel NPU`,"intel-igpu":`Intel iGPU`,"amd-igpu":`AMD iGPU (WebGPU)`,"amd-npu":`AMD XDNA NPU`,"x86-cpu":`CPU`,"arm-cpu":`CPU`,"apple-ane":`Apple Neural Engine`,coral:`Coral Edge TPU`},ea={"intel-core-ultra":`Intel Core Ultra`,"intel-n-series":`Intel N-series`,"apple-m-base":`Apple M (base)`,"apple-m-pro":`Apple M Pro / Max / Ultra`,"amd-phoenix":`AMD Ryzen Phoenix / Hawk Point`,unknown:`Not measured`};function ta(e){return e===null?`—`:$i[e]??e}function na(e){return e===null?`—`:ea[e]??e}function ra(e){switch(e.kind){case`capacity`:return Y.t(`helpers.autoTuneViewModel.capacity`,{sessions:Qi(e.sessions),min:e.minSessions});case`tie-faster`:return Y.t(`helpers.autoTuneViewModel.tieFaster`,{over:e.over,recall:Zi(e.recallDelta)});case`stepped-down`:return Y.t(`helpers.autoTuneViewModel.steppedDown`,{from:e.from,limitedBy:e.limitedBy,to:e.to});case`no-fit-lightest`:return Y.t(`helpers.autoTuneViewModel.noFitLightest`,{min:Qi(e.minSessions),sessions:Qi(e.sessions)});case`derived-latency`:return Y.t(`helpers.autoTuneViewModel.derivedLatency`,{modelId:e.modelId});case`cpu-device`:return Y.t(`helpers.autoTuneViewModel.cpuDevice`);case`device-disabled`:return Y.t(`helpers.autoTuneViewModel.deviceDisabled`);case`device-unavailable`:return Y.t(`helpers.autoTuneViewModel.deviceUnavailable`);case`node-offline`:return Y.t(`helpers.autoTuneViewModel.nodeOffline`);case`no-hardware-facts`:return Y.t(`helpers.autoTuneViewModel.noHardwareFacts`);case`no-measured-data`:return Y.t(`helpers.autoTuneViewModel.noMeasuredData`);case`no-family-build`:return Y.t(`helpers.autoTuneViewModel.noFamilyBuild`,{format:e.format});case`kept-custom-pin`:return Y.t(`helpers.autoTuneViewModel.keptCustomPin`,{modelId:e.modelId,deviceKey:e.deviceKey})}}function ia(e,t){switch(e.kind){case`custom-pin-kept`:return Y.t(`helpers.autoTuneViewModel.customPinNode`,{node:t(e.nodeId),modelId:e.modelId,deviceKey:e.deviceKey});case`custom-registry-unreadable`:return Y.t(`helpers.autoTuneViewModel.customRegistryUnreadable`,{error:e.error})}}function aa(e){return{modelChanges:e.nodeChanges.reduce((e,t)=>e+t.modelPins.length,0),thresholdClears:e.nodeChanges.reduce((e,t)=>e+t.thresholds.length,0)}}function oa(e){let t=aa(e);return t.modelChanges+t.thresholdClears===0}function sa(e,t,n){let r=e.nodeChanges.find(e=>e.nodeId===t&&e.deviceKey===n)?.modelPins.find(e=>e.stepId===`object-detection`);return r===void 0?null:{before:r.before,after:r.after}}function ca(e,t){return e?.kind===`node-benchmark`?Y.t(`helpers.autoTuneViewModel.latencyMeasured`,{date:new Date(e.measuredAtMs).toLocaleDateString(t,{day:`numeric`,month:`short`})}):e?.kind===`estimated`?Y.t(`helpers.autoTuneViewModel.latencyEstimated`,{hardware:na(e.estimatedFrom)}):Y.t(`helpers.autoTuneViewModel.latencyTable`)}s();var la=[.3,.4,.5];function ua(e){return la.some(t=>t===e)}var da=[1,2,3,4,6,8];function fa({plan:t,node:n,nodeName:r}){let{t:a}=X();return e(`section`,{className:b,"data-testid":`auto-tune-node-${n.nodeId}`,children:[e(`header`,{className:`${V} flex flex-wrap items-center gap-2`,children:[i(z,{className:`h-3.5 w-3.5 shrink-0 text-foreground-subtle`,"aria-hidden":!0}),i(`h3`,{className:`${D} min-w-0 flex-1`,children:r(n.nodeId)}),e(`span`,{className:`text-[11px] text-foreground-subtle`,children:[na(n.hardwareClass),n.cpuModel===null?``:` · ${n.cpuModel}`]}),n.skipped?i(K,{variant:`warning`,children:a(`pipeline.clusterAutoTuneTab.notChanged`,`Not changed`)}):n.acceleratorModelId!==null&&i(K,{variant:`info`,children:n.acceleratorModelId})]}),n.reasons.length>0&&i(`ul`,{className:`px-3 pt-2 text-[11px] text-foreground-muted`,children:n.reasons.map((e,t)=>i(`li`,{children:ra(e)},t))}),i(`div`,{className:`overflow-x-auto`,children:e(`table`,{className:`w-full text-xs`,children:[i(`thead`,{children:e(`tr`,{className:`text-left text-[11px] text-foreground-subtle`,children:[i(`th`,{className:`px-3 py-1.5 font-medium`,children:a(`pipeline.clusterAutoTuneTab.device`,`Device`)}),i(`th`,{className:`px-3 py-1.5 font-medium`,children:a(`pipeline.clusterAutoTuneTab.capacity`,`Capacity`)}),i(`th`,{className:`px-3 py-1.5 font-medium`,children:a(`pipeline.clusterAutoTuneTab.detector`,`Detector`)}),i(`th`,{className:`px-3 py-1.5 font-medium`,children:a(`pipeline.clusterAutoTuneTab.why`,`Why`)})]})}),i(`tbody`,{children:n.devices.map(r=>{let o=sa(t,n.nodeId,r.deviceKey);return e(`tr`,{className:`border-t border-border align-top`,children:[e(`td`,{className:`px-3 py-1.5`,children:[i(`div`,{className:`font-mono text-foreground`,children:r.deviceKey}),i(`div`,{className:`text-[11px] text-foreground-subtle`,children:ta(r.accelerator)})]}),e(`td`,{className:`px-3 py-1.5 text-foreground-muted`,children:[r.chosen===null?`—`:a(`pipeline.clusterAutoTuneTab.sessionsAtFps`,{count:r.chosen.capacitySessions,fps:t.cameraFps}),r.chosen!==null&&e(`div`,{className:`text-[11px] text-foreground-subtle`,children:[a(`pipeline.clusterAutoTuneTab.fpsKeptFree`,{fps:r.chosen.fps,percent:Math.round(t.headroom*100)}),i(`div`,{children:ca(r.chosen.source)})]})]}),i(`td`,{className:`px-3 py-1.5`,children:r.chosen===null?i(`span`,{className:`text-foreground-subtle`,children:a(`common.unchanged`)}):o!==null&&o.before!==o.after?e(`span`,{children:[i(`span`,{className:`text-foreground-subtle`,children:o.before??a(`common.defaultWord`)}),` → `,i(`span`,{className:`font-medium text-foreground`,children:o.after})]}):i(`span`,{className:`text-foreground`,children:r.chosen.modelId})}),i(`td`,{className:`px-3 py-1.5 text-[11px] text-foreground-muted`,children:r.reasons.map((e,t)=>i(`div`,{children:ra(e)},t))})]},r.deviceKey)})})]})})]})}function pa({plan:t,nodeName:n}){let{t:r}=X();return i(`div`,{className:`flex flex-col gap-3 text-xs`,"data-testid":`auto-tune-change-list`,children:e(`div`,{children:[i(`div`,{className:D,children:r(`pipeline.clusterAutoTuneTab.nodeSettings`,`Node settings`)}),t.nodeChanges.length===0?i(`div`,{className:`text-foreground-subtle`,children:r(`pipeline.clusterAutoTuneTab.noChange`,`No change.`)}):i(`ul`,{className:`mt-1 flex flex-col gap-0.5`,children:t.nodeChanges.flatMap(t=>[...t.modelPins.map(i=>e(`li`,{children:[e(`span`,{className:`font-mono`,children:[n(t.nodeId),` · `,t.deviceKey]}),` `,`— `,i.stepId,`: `,i.before??r(`pipeline.clusterAutoTuneTab.defaultModel`),` →`,` `,i.after??r(`pipeline.clusterAutoTuneTab.stepDefault`,`step default`)]},`${t.nodeId}/${t.deviceKey}/${i.stepId}/pin`)),...t.thresholds.map(i=>e(`li`,{children:[e(`span`,{className:`font-mono`,children:[n(t.nodeId),` · `,t.deviceKey]}),` `,`—`,` `,r(`pipeline.clusterAutoTuneTab.thresholdReset`,{step:i.stepId,keys:i.keys.join(`, `)})]},`${t.nodeId}/${t.deviceKey}/${i.stepId}/thr`))])})]})})}function ma({result:t}){let{t:n}=X();return t.kind===`refused`?i(`div`,{className:`text-xs text-warning`,children:n(`pipeline.clusterAutoTuneTab.anotherApplyIsAlreadyRunning`,`Another apply is already running.`)}):t.kind===`stale`?i(`div`,{className:`text-xs text-warning`,children:n(`pipeline.clusterAutoTuneTab.theConfigurationChangedSinceThe`,`The configuration changed since the plan was shown. Review the updated plan below and apply again.`)}):e(`ul`,{className:`text-xs`,"data-testid":`auto-tune-result`,children:[t.kind===`aborted`&&i(`li`,{className:`text-danger`,children:n(`pipeline.clusterAutoTuneTab.aModelCouldNotBe`,`A model could not be downloaded: nothing was changed.`)}),t.phases.map(t=>e(`li`,{className:t.ok?`text-foreground-muted`:`text-danger`,children:[t.ok?`✓`:`✗`,` `,t.phase,`: `,t.detail]},t.phase))]})}function ha(){let{t}=X(),r=l(),[a,s]=o(.4),[c,u]=o(2),[d,f]=o(!1),[p,m]=o(!1),[h,g]=o(null),{nodes:_}=J(),v=n(()=>Tr(_),[_]),y=ot({headroom:a,minSessionsPerDevice:c},{enabled:d,refetchOnWindowFocus:!1}),x=vn({onSuccess:e=>{g(e),m(!1),r.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getNodeInferenceDevices`]]}),e.kind===`applied`&&y.refetch()}}),S=h?.kind===`stale`?h.plan:y.data,C=S===void 0?null:aa(S);return e(`div`,{className:`flex flex-col gap-3`,"data-testid":`cluster-auto-tune`,children:[e(`section`,{className:b,children:[e(`header`,{className:`${V} flex flex-wrap items-center gap-2`,children:[i(oe,{className:`h-3.5 w-3.5 shrink-0 text-foreground-subtle`,"aria-hidden":!0}),i(`h3`,{className:`${D} min-w-0 flex-1`,children:t(`pipeline.clusterAutoTuneTab.autoTune`,`Auto tune`)})]}),e(`div`,{className:`flex flex-col gap-2 px-3 py-2 text-xs text-foreground-muted`,children:[i(`p`,{children:t(`pipeline.clusterAutoTuneTab.picksForEveryAcceleratorThe`,`Picks, for every accelerator, the most accurate YOLOv9 detector that still carries at least the chosen number of cameras at once, from the node's hardware and measured speeds. Nothing is measured or estimated about your cameras' activity. Applying it sets those models on the accelerators and clears their threshold overrides, so each model runs its own default thresholds. Cameras carry no model or threshold of their own. Enabled steps, devices, pins, recording, notifications, zones and rules are not touched. There is no undo.`)}),e(`div`,{className:`flex flex-wrap items-center gap-2`,children:[e(`label`,{className:`flex items-center gap-1.5`,children:[i(`span`,{className:`whitespace-nowrap`,children:t(`pipeline.clusterAutoTuneTab.keepFree`,`Keep free`)}),i(I,{"aria-label":t(`pipeline.clusterAutoTuneTab.shareOfEachAcceleratorKept`,`Share of each accelerator kept free`),value:String(a),options:la.map(e=>({value:String(e),label:t(`pipeline.clusterAutoTuneTab.ofEachAccelerator`,`{{value1}}% of each accelerator`,{value1:Math.round(e*100)})})),onChange:e=>{let t=Number(e.target.value);ua(t)&&s(t)}})]}),e(`label`,{className:`flex items-center gap-1.5`,children:[i(`span`,{className:`whitespace-nowrap`,children:t(`pipeline.clusterAutoTuneTab.atLeast`,`At least`)}),i(I,{"aria-label":t(`pipeline.clusterAutoTuneTab.minimumParallelSessionsPerDevice`,`Minimum parallel sessions per device`),value:String(c),options:da.map(e=>({value:String(e),label:t(`pipeline.clusterAutoTuneTab.camerasAtOnce`,{count:e})})),onChange:e=>{let t=Number(e.target.value);da.some(e=>e===t)&&u(t)}})]}),i(q,{size:`sm`,variant:`secondary`,onClick:()=>{g(null),f(!0),d&&y.refetch()},children:y.isFetching?t(`pipeline.clusterAutoTuneTab.computing`,`Computing…`):S===void 0?t(`pipeline.clusterAutoTuneTab.computePlan`,`Compute plan`):t(`pipeline.clusterAutoTuneTab.recompute`,`Recompute`)}),S!==void 0&&i(q,{size:`sm`,disabled:oa(S),onClick:()=>m(!0),children:t(`pipeline.clusterAutoTuneTab.apply`,`Apply…`)})]}),y.error!==null&&i(`div`,{className:`text-danger`,children:y.error.message}),h!==null&&i(ma,{result:h}),C!==null&&i(`div`,{className:`text-[11px] text-foreground-subtle`,children:t(`pipeline.clusterAutoTuneTab.planSummary`,{modelChanges:C.modelChanges,thresholdClears:C.thresholdClears})})]})]}),S?.warnings.map((e,t)=>i(`div`,{className:`rounded-md border border-warning/40 bg-warning/10 px-3 py-2 text-xs text-warning`,children:ia(e,v)},t)),S?.nodes.map(e=>i(fa,{plan:S,node:e,nodeName:v},e.nodeId)),S!==void 0&&i(xt,{open:p,onOpenChange:m,children:e($e,{width:`lg`,scroll:`body`,children:[e(it,{children:[i(Mt,{children:t(`pipeline.clusterAutoTuneTab.applyAutoTune`,`Apply auto tune?`)}),i(ct,{children:t(`pipeline.clusterAutoTuneTab.theseAreAllTheChanges`,`These are all the changes. Every override listed is removed and cannot be restored.`)})]}),i(Ot,{children:i(pa,{plan:S,nodeName:v})}),e(un,{children:[i(q,{variant:`ghost`,onClick:()=>m(!1),children:t(`common.cancel`,`Cancel`)}),i(q,{variant:`danger`,disabled:x.isPending,onClick:()=>x.mutate({planHash:S.planHash,headroom:a,minSessionsPerDevice:c}),children:x.isPending?t(`pipeline.clusterAutoTuneTab.applying`,`Applying…`):t(`common.apply`,`Apply`)})]})]})})]})}var ga={disabled:`pipeline.nodeLoadOverview.exclusion.disabled`,unavailable:`pipeline.nodeLoadOverview.exclusion.unavailable`,"cannot-host-camera-root":`pipeline.nodeLoadOverview.exclusion.cannotHostCameraRoot`,"accelerator-preferred":`pipeline.nodeLoadOverview.exclusion.acceleratorPreferred`,"root-switched-off":`pipeline.nodeLoadOverview.exclusion.rootSwitchedOff`};function _a(e,t){return t<=0?0:Math.round(e/t*1e3)/10}function va(e){return e===void 0?!1:e.load.devices.reduce((e,t)=>e+t.attachedCameras,0)>=e.load.attachedCameras}function ya(e,t,n){let r=e.filter(e=>e.exclusion===null).reduce((e,t)=>e+(t.weight>0?t.weight:1),0);return e.map(e=>{let i=t.get(e.key)??(n?0:null),a=e.weight>0?e.weight:1;return{key:e.key,label:Qt(e),format:e.format,sessions:i,weight:a,weightSharePct:e.exclusion===null?_a(a,r):null,maxSessions:e.maxSessions,atCap:e.maxSessions!==null&&i!==null&&i>=e.maxSessions,available:e.available,enabled:e.enabled,exclusion:e.exclusion}}).toSorted((e,t)=>e.exclusion===null==(t.exclusion===null)?e.key.localeCompare(t.key):e.exclusion===null?-1:1)}function ba(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=ya(e.devicesByNode[r.id]??[],new Map((i?.load.devices??[]).map(e=>[e.deviceKey,e.attachedCameras])),va(i)),o=r.isOnline&&r.detectEnabled,s=r.weight>0?r.weight:1,c=i?.load.attachedCameras??null;return{nodeId:r.id,name:r.name,isOnline:r.isOnline,detectEnabled:r.detectEnabled,reported:i!==void 0,attachedCameras:c,activeCameras:i?.load.activeCameras??null,maxCameras:r.maxCameras,capacityPct:c!==null&&r.maxCameras!==null&&r.maxCameras>0?_a(c,r.maxCameras):null,queueDepthTotal:i?.load.queueDepthTotal??null,avgInferenceTimeMs:i?.load.avgInferenceTimeMs??null,score:i?.score??null,weight:s,weightSharePct:o?_a(s,n):null,decodeHwaccel:i?.decodeHwaccel??null,devices:a,eligibleDeviceCount:a.filter(e=>e.exclusion===null).length}})}s();var xa=2e4,Sa=3e5;function Ca({stats:e,targetWeights:t,showAccelerators:r=!0}){let{t:a}=X(),{nodes:o}=J(),s=se().trpcClient,l=tn(void 0,{placeholderData:u,staleTime:xa,refetchInterval:xa,refetchOnWindowFocus:!0}),d=dn(void 0,{staleTime:Sa}),f=n(()=>o.map(e=>e.id),[o]),p=c({queries:f.map(e=>({queryKey:Re(gt.pipelineOrchestrator.getNodeInferenceDevices,{nodeId:e},`query`),queryFn:()=>s.pipelineOrchestrator.getNodeInferenceDevices.query({nodeId:e}),staleTime:Sa,refetchOnWindowFocus:!1,placeholderData:u}))}),h=n(()=>{let e={};return f.forEach((t,n)=>{let r=p[n]?.data;r&&(e[t]=r.devices)}),e},[f,p.map(e=>e.dataUpdatedAt).join(`|`)]),g=n(()=>{let e=new Map;for(let t of d.data??[])e.set(t.nodeId,t.settings);return e},[d.data]),_=n(()=>o.map(e=>{let n=g.get(e.id);return{id:e.id,name:e.name,isOnline:e.isOnline,detectEnabled:pr(n).pipeline,weight:t?.[e.id]??tr(n,`detectWeight`)??1,maxCameras:tr(n,`maxCameras`)}}),[o,g,t]),v=l.data??[],y=n(()=>ba({nodes:_,loads:v,devicesByNode:h}),[_,v,h]),b=y.reduce((e,t)=>e+(t.attachedCameras??0),0),x=y.reduce((e,t)=>e+(t.activeCameras??0),0),S=l.dataUpdatedAt>0?Date.now()-l.dataUpdatedAt:null,C=new Map((e?.nodes??[]).map(e=>[e.nodeId,e]));return i(G,{headingId:`load-balancing-node-load`,title:a(`pipeline.nodeLoadOverview.nodeLoad`,`Node load`),icon:A,actions:i(`span`,{className:`text-[10px] text-foreground-subtle tabular-nums`,children:a(`pipeline.nodeLoadOverview.summaryLine`,{active:x,attached:b,reading:l.data===void 0?a(`pipeline.nodeLoadOverview.reading`,`reading…`):a(`pipeline.nodeLoadOverview.readingAge`,{age:S===null?`—`:`${Math.round(S/1e3)}s`})})}),children:i(`div`,{className:m,children:y.length===0?i(`p`,{className:`text-[11px] italic text-foreground-subtle`,children:a(`pipeline.nodeLoadOverview.noClusterNodesReportedYet`,`No cluster nodes reported yet.`)}):i(`div`,{className:`grid gap-2 @2xl/clustertab:grid-cols-2 @5xl/clustertab:grid-cols-3`,children:y.map(e=>i(wa,{row:e,placed:C.get(e.nodeId),showAccelerators:r},e.nodeId))})})})}function wa({row:t,placed:n,showAccelerators:r}){let{t:a}=X(),o=t.attachedCameras===null?`—`:`${t.activeCameras??0} / ${t.attachedCameras}${t.maxCameras===null?``:` of ${t.maxCameras}`}`;return e(`div`,{className:`rounded-lg border border-border bg-surface/60 p-2.5 min-w-0`,children:[e(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[i(`span`,{className:`h-1.5 w-1.5 shrink-0 rounded-full ${t.isOnline?`bg-emerald-400`:`bg-foreground-subtle/40`}`}),i(`span`,{className:`truncate text-xs font-medium text-foreground`,title:t.nodeId,children:t.name}),!t.detectEnabled&&i(`span`,{className:`shrink-0 rounded bg-surface-hover px-1 text-[9px] uppercase tracking-wide text-foreground-subtle`,children:a(`pipeline.nodeLoadOverview.noDetect`,`no detect`)}),!t.reported&&t.isOnline&&e(`span`,{className:`ml-auto inline-flex shrink-0 items-center gap-1 text-[9px] text-amber-400`,title:a(`pipeline.nodeLoadOverview.onlineButItDidNot`,`Online, but it did not answer the last load read — its numbers below are unknown, not zero.`),children:[i(j,{className:`h-2.5 w-2.5`}),` `,a(`pipeline.nodeLoadOverview.noReading`)]}),!t.isOnline&&e(`span`,{className:`ml-auto inline-flex shrink-0 items-center gap-1 text-[9px] text-foreground-subtle`,children:[i(B,{className:`h-2.5 w-2.5`}),` `,a(`common.offline`)]})]}),e(`dl`,{className:`mt-1.5 grid grid-cols-2 gap-x-2 gap-y-0.5 text-[10px]`,children:[i(Da,{label:a(`pipeline.nodeLoadOverview.runningAttached`,`Running / attached`),value:o,title:a(`pipeline.nodeLoadOverview.sessionsInInferenceNowCameras`,`Sessions in inference now / cameras attached to this runner (the balancer's committed load) / operator cap.`)}),i(Da,{label:a(`pipeline.nodeLoadOverview.targetShare`,`Target share`),value:t.weightSharePct===null?`out of play`:`${t.weightSharePct}%`,title:a(`pipeline.nodeLoadOverview.theNodeShareAutomaticOr`,`The node share (automatic or manual) normalised over the nodes the balancer actually ranks (online AND detect-enabled).`)}),i(Da,{label:a(`pipeline.nodeLoadOverview.actualShare1H`,`Actual share (1 h)`),value:n?.observedShare===null||n===void 0?`—`:`${Math.round(n.observedShare*100)}%`,title:a(`pipeline.nodeLoadOverview.timeWeightedShareOfThe`,`Time-weighted share of the cluster's PARALLEL detection sessions this node carried over the last hour — the quantity a share holds. '—' = no session ran here in the window.`)}),i(Da,{label:a(`pipeline.nodeLoadOverview.peakYields`,`Peak · yields`),value:n===void 0?`—`:`${n.peakSessions} · ${n.yieldsAway}`,title:a(`pipeline.nodeLoadOverview.mostSessionsThisNodeRan`,`Most sessions this node ran at once in the last hour, and how many share turns it handed to another node because it was full or drowning.`)}),i(Da,{label:a(`pipeline.nodeLoadOverview.scoreQueue`,`Score · queue`),value:t.score===null?`—`:`${t.score} · ${t.queueDepthTotal??0}`,title:a(`pipeline.nodeLoadOverview.theCapacityScoreBalanceMinimises`,`The capacity score balance() minimises (attached + queue depth), and the raw queue depth.`)}),t.capacityPct!==null&&i(Da,{label:a(`pipeline.nodeLoadOverview.capFill`,`Cap fill`),value:`${t.capacityPct}%`,title:a(`pipeline.nodeLoadOverview.attachedMaxcameras`,`attached / maxCameras.`)}),t.avgInferenceTimeMs!==null&&i(Da,{label:a(`pipeline.nodeLoadOverview.avgInfer`,`Avg infer`),value:`${Math.round(t.avgInferenceTimeMs)} ms`,title:a(`pipeline.nodeLoadOverview.meanInferenceTimeAcrossThis`,`Mean inference time across this node's attached cameras.`)}),t.decodeHwaccel!==null&&i(Da,{label:a(`pipeline.nodeLoadOverview.decode`,`Decode`),value:t.decodeHwaccel,title:a(`pipeline.nodeLoadOverview.thisNodeSProbedDecode`,`This node's probed decode hwaccel.`)})]}),r&&i(Ta,{row:t})]})}function Ta({row:t}){let{t:n}=X();return t.devices.length===0?i(`p`,{className:`mt-2 text-[10px] italic text-foreground-subtle`,children:n(`pipeline.nodeLoadOverview.acceleratorsNotReadYet`,`Accelerators not read yet.`)}):e(`div`,{className:`mt-2 border-t border-border pt-1.5`,children:[e(`div`,{className:`flex items-center gap-1 text-[9px] uppercase tracking-wider text-foreground-subtle`,children:[i(ne,{className:`h-2.5 w-2.5`}),n(`pipeline.nodeLoadOverview.accelerators`,`Accelerators`),t.eligibleDeviceCount===0&&i(`span`,{className:`ml-1 normal-case tracking-normal text-amber-400`,title:n(`pipeline.nodeLoadOverview.noDeviceIsACamera`,`No device is a camera-root candidate on this node — sessions run on the runner's default (CPU) pool.`),children:n(`pipeline.nodeLoadOverview.noneInPlayRunnerDefault`,`none in play · runner default pool`)})]}),i(`ul`,{className:`mt-1 space-y-0.5`,children:t.devices.map(e=>i(Ea,{device:e},e.key))})]})}function Ea({device:t}){let{t:n}=X(),r=t.exclusion;return e(`li`,{className:`flex items-baseline gap-1.5 text-[10px] min-w-0`,children:[i(z,{className:`h-2.5 w-2.5 shrink-0 ${r===null?`text-foreground-subtle`:`text-foreground-subtle/50`}`}),i(`span`,{className:`shrink-0 font-medium ${r===null?`text-foreground`:`text-foreground-subtle`}`,title:`${t.key} · ${t.format}`,children:t.label}),r===null?e(d,{children:[i(`span`,{className:`shrink-0 tabular-nums text-foreground-subtle`,children:n(`pipeline.nodeLoadOverview.sharePct`,{pct:t.weightSharePct})}),e(`span`,{className:`shrink-0 tabular-nums text-foreground-subtle`,title:t.sessions===null?n(`pipeline.nodeLoadOverview.notKnownTheNodeDid`,`Not known: the node did not report, or runs a session no device accounts for.`):void 0,children:[`· `,n(`common.sessionsCount`,{count:t.sessions??0}),t.maxSessions===null?``:`/${t.maxSessions}`]}),t.atCap&&i(`span`,{className:`shrink-0 text-amber-400`,title:n(`pipeline.nodeLoadOverview.atItsMaxsessionsCapThe`,`At its maxSessions cap — the balancer skips it until a session ends.`),children:n(`pipeline.nodeLoadOverview.atCap`,`· at cap`)})]}):i(`span`,{className:`truncate text-foreground-subtle/80`,title:n(ga[r]),children:n(`pipeline.nodeLoadOverview.excludedWith`,{reason:n(ga[r])})})]})}function Da({label:t,value:n,title:r}){return e(`div`,{className:`min-w-0`,title:r,children:[i(`dt`,{className:`text-[9px] uppercase tracking-wide text-foreground-subtle`,children:t}),i(`dd`,{className:`truncate font-medium tabular-nums text-foreground`,children:n})]})}function Oa(e){return{nodes:Object.fromEntries(e.map(e=>[e.nodeId,Math.max(1,e.weight)])),devices:{}}}function ka(e){let t={},n={};for(let r of e.nodes){if(r.share===null||r.share<=0)continue;t[r.nodeId]=r.share;let e=Object.fromEntries(r.devices.filter(e=>e.share>0).map(e=>[e.deviceKey,e.share]));Object.keys(e).length>0&&(n[r.nodeId]=e)}return{nodes:t,devices:n}}function Aa(e){return Object.fromEntries(e.nodes.map(e=>[e.nodeId,Object.fromEntries(e.devices.map(e=>[e.deviceKey,e.suggestedMaxSessions]))]))}function ja(e){return e.reason===`disabled`?Y.t(`helpers.loadBalancingViewModel.stalePinDisabled`,{deviceKey:e.deviceKey}):Y.t(`helpers.loadBalancingViewModel.stalePinMissing`,{deviceKey:e.deviceKey})}function Ma(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 Na(e,t){let n=e.nodes.filter(e=>!e.eligible);if(n.length===0)return null;let r=e.nodes.filter(e=>e.eligible).map(e=>`${t(e.nodeId)} ${Math.round(e.effectivePct)}%`).join(`, `),i=n.map(e=>t(e.nodeId)).join(`, `);return Y.t(`helpers.loadBalancingViewModel.shareNote`,{count:n.length,names:i,into:r})}var Pa=[{value:`hardware`,get label(){return Y.t(`helpers.loadBalancingViewModel.hardwareLabel`)},get hint(){return Y.t(`helpers.loadBalancingViewModel.hardwareHint`)}},{value:`benchmark`,get label(){return Y.t(`helpers.loadBalancingViewModel.benchmarkLabel`)},get hint(){return Y.t(`helpers.loadBalancingViewModel.benchmarkHint`)}},{value:`manual`,get label(){return Y.t(`helpers.loadBalancingViewModel.manualLabel`)},get hint(){return Y.t(`helpers.loadBalancingViewModel.manualHint`)}}];function Fa(e){return e===`no-benchmark-results`?Y.t(`helpers.loadBalancingViewModel.fallbackNone`):e===`partial-benchmark-results`?Y.t(`helpers.loadBalancingViewModel.fallbackPartial`):null}function Ia(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)}: ${Fa(e.capacityFallback)??``}`).join(` · `)}s();function La(e,t,n){return Math.min(Math.max(e,t),n)}function Ra(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 za(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:La(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 Ba(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 Va({nodes:t,pending:n,onCommitWeights:r,weightLabel:s=`Detection weight`,emptyHint:c,footnote:l,readOnly:u=!1}){let{t:p}=X(),[m,h]=o(()=>Ra(t)),[g,y]=o(new Set);a(()=>{h(Ra(t)),y(e=>new Set([...e].filter(e=>t.some(t=>t.id===e))))},[t.map(e=>`${e.id}:${e.weight}`).join(`|`)]);let b=t.map(e=>e.id),x=e=>{y(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},S=(e,t)=>{h(n=>za(n,e,t,g,b))},C=()=>{let e=Ba(m,b,g),n=t.filter(t=>(e[t.id]??0)!==t.weight).map(e=>e.id);if(n.length===0)return;let i=new Set([...n,...g]);r(t.filter(e=>i.has(e.id)).map(t=>({nodeId:t.id,weight:e[t.id]??0})))};if(t.length===0)return i(`p`,{className:`rounded-lg border border-dashed border-border bg-background px-4 py-6 text-center text-xs text-foreground-subtle`,children:c??p(`placementBoard.weightSliderStack.noDetectEnabledNodesEnable`,`No detect-enabled nodes. Enable “Detect” on a node above to distribute detection weight.`)});let w=t.length===1;return e(`div`,{className:`space-y-3`,children:[t.map(t=>{let r=m[t.id]??0,a=g.has(t.id);return e(`div`,{className:`flex items-center gap-3`,children:[i(`span`,{className:`w-28 shrink-0 truncate text-xs font-medium text-foreground`,title:t.name,children:t.name}),i(f,{"aria-label":p(`placementBoard.weightSliderStack.for`,`{{weightLabel}} for {{name}}`,{weightLabel:s,name:t.name}),min:0,max:100,step:1,value:Math.round(r),disabled:u||n||a||w,onChange:e=>S(t.id,Number(e.target.value)),onPointerUp:()=>C(),onKeyUp:()=>C(),className:`h-1.5 flex-1 cursor-pointer accent-primary disabled:cursor-not-allowed disabled:opacity-50`}),e(`span`,{className:`w-10 shrink-0 text-right font-mono text-xs tabular-nums text-foreground`,children:[Math.round(r),`%`]}),!u&&i(q,{variant:`unstyled`,type:`button`,onClick:()=>x(t.id),disabled:n||w,"aria-pressed":a,title:a?p(`placementBoard.weightSliderStack.unlockAllowRebalancing`,`Unlock — allow rebalancing`):p(`placementBoard.weightSliderStack.lockThisShareWhenOthers`,`Lock this share when others change`),className:`shrink-0 rounded p-1 hover:bg-surface-hover disabled:opacity-40 ${a?`text-amber-400`:`text-foreground-subtle`}`,children:i(a?_:v,{className:`h-3.5 w-3.5`})})]},t.id)}),i(`p`,{className:`text-[10px] leading-tight text-foreground-subtle`,children:l??i(d,{children:p(`placementBoard.weightSliderStack.draggingOneSliderSplitsThe`,`Dragging one slider splits the rest equally across the unlocked nodes; lock a node to pin its share — locked nodes never move and the total always stays at 100%, so a drag is bounded by the room the unlocked nodes leave. Detection only distributes across nodes that can source a camera’s frames.`)})})]})}function Ha(e){let t=e.steps?.[`object-detection`]?.modelId;return typeof t==`string`&&t.length>0?t:typeof e.defaultModelId==`string`&&e.defaultModelId.length>0?e.defaultModelId:null}function Ua(e){if(e.presence===`absent`)return`absent`;if(e.presence===`unknown`)return`unknown`;switch(e.exclusion){case null:return`active`;case`disabled`:return`disabled`;case`unavailable`:return e.available?`backoff`:`unavailable`;case`cannot-host-camera-root`:return`root-incapable`;case`accelerator-preferred`:return`standby`;case`root-switched-off`:return`root-off`}}function Wa(e,t,n){let r=new Map((t?.devices??[]).map(e=>[e.deviceKey,e])),i=new Map((n?.devices??[]).map(e=>[e.deviceKey,e.sessionsNow]));return e.map(e=>{let t=r.get(e.key),a=n===void 0?null:i.get(e.key)??0;return{device:e,state:Ua(e),share:t===void 0?null:{configuredPct:t.configuredPct,effectivePct:t.effectivePct},sessionsNow:a,atCap:a!==null&&e.maxSessions!==null&&a>=e.maxSessions}})}var Ga={active:`success`,disabled:`neutral`,absent:`danger`,unknown:`neutral`,unavailable:`warning`,backoff:`warning`,"root-incapable":`info`,"root-off":`neutral`,standby:`neutral`};s();function Ka(e){let t=Qt(e),n=e.backend.toLowerCase(),r=e.device.toLowerCase();return e.key===`cpu`||r===`cpu`?{label:t,Icon:z,hue:`slate`}:r===`npu`?{label:t,Icon:ie,hue:`sky`}:r===`gpu`||r===`igpu`?{label:t,Icon:je,hue:`violet`}:n===`edgetpu`?{label:t,Icon:Fe,hue:`emerald`}:{label:t,Icon:z,hue:`slate`}}var qa={active:[`placementBoard.nodeInferenceDevices.state.active`,`in use`],disabled:[`placementBoard.nodeInferenceDevices.state.disabled`,`switched off`],absent:[`placementBoard.nodeInferenceDevices.state.absent`,`absent`],unknown:[`placementBoard.nodeInferenceDevices.state.unknown`,`unknown`],unavailable:[`placementBoard.nodeInferenceDevices.state.unavailable`,`unavailable`],backoff:[`placementBoard.nodeInferenceDevices.state.backoff`,`pool down`],"root-incapable":[`placementBoard.nodeInferenceDevices.state.rootIncapable`,`no root model`],"root-off":[`placementBoard.nodeInferenceDevices.state.rootOff`,`detection off`],standby:[`placementBoard.nodeInferenceDevices.state.standby`,`fallback`]},Ja={active:[`placementBoard.nodeInferenceDevices.stateHint.active`,`A camera-root candidate: placement may start sessions on it.`],disabled:[`placementBoard.nodeInferenceDevices.stateHint.disabled`,`Switched off: it takes no sessions.`],absent:[`placementBoard.nodeInferenceDevices.stateHint.absent`,`The node no longer reports this device (unplugged, or moved to another node). Its settings are kept; it is never used. Forget it to delete them.`],unknown:[`placementBoard.nodeInferenceDevices.stateHint.unknown`,`The node's probe did not answer, so whether the device is there is not known.`],unavailable:[`placementBoard.nodeInferenceDevices.stateHint.unavailable`,`On the node, but the probe reports it unusable.`],backoff:[`placementBoard.nodeInferenceDevices.stateHint.backoff`,`Reported by the node, but its inference pool is down or backing off.`],"root-incapable":[`placementBoard.nodeInferenceDevices.stateHint.rootIncapable`,`Its format cannot run the camera root detector; it serves enrichment steps only.`],"root-off":[`placementBoard.nodeInferenceDevices.stateHint.rootOff`,`Object detection is switched off on this device, its node or the cluster: it hosts no camera and serves enrichment steps only.`],standby:[`placementBoard.nodeInferenceDevices.stateHint.standby`,`The CPU fallback: it takes no sessions while an accelerator is serving this node.`]};function Ya({nodeId:t,nodeName:r,isOnline:s,suggestedMaxSessions:c,shareSource:u,sharesAutomatic:f,share:p,placed:m}){let{t:h}=X(),g=l(),{data:_,isLoading:v}=Et({nodeId:t},{refetchInterval:15e3}),y=()=>{g.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getNodeInferenceDevices`]]})},b=Gt({onSettled:y}),x=pt({onSettled:y}),S=gt.platformProbe.rescanAccelerators.useMutation({onSettled:y}),C=_?.devices??[],w=_?.reachable??s,[T,E]=o({});a(()=>{E(Object.fromEntries(C.map(e=>[e.key,Xa(e)])))},[C.map(e=>`${e.key}:${e.enabled}:${e.weight}:${e.maxSessions}:${JSON.stringify(e.steps??{})}`).join(`|`)]);let ee=n(()=>C.filter(e=>(T[e.key]?.enabled??e.enabled)&&e.available).length,[C,T]),[D,O]=o(null),A=D??!0,j=e=>{let n=C.map(t=>{let n=e[t.key]??Xa(t);return{key:t.key,enabled:n.enabled,weight:n.weight,maxSessions:n.maxSessions,steps:n.steps}});b.mutate({agentNodeId:t,inferenceDevices:ni(n)})},M=(e,t)=>{let n=T[e.key]??Xa(e),r={...T,[e.key]:{...n,...t}};E(r),j(r)},ne=n(()=>Wa(C,p,m),[C,p,m]),N=n(()=>C.filter(e=>(T[e.key]?.enabled??e.enabled)&&e.available),[C,T]),P=n(()=>N.map(e=>({id:e.key,name:Ka(e).label,weight:T[e.key]?.weight??e.weight})),[N,T]),F=e=>{let t={...T};for(let n of e){let e=t[n.nodeId];e&&(t[n.nodeId]={...e,weight:n.weight})}E(t),j(t)},I=b.isPending||x.isPending,L=Za(h,f?u:`manual`),R=[{key:`device`,header:h(`placementBoard.nodeInferenceDevices.colDevice`,`Device`),nowrap:!1,sortValue:e=>Ka(e.device).label,render:e=>i($a,{row:e,steps:T[e.device.key]?.steps})},{key:`state`,header:h(`placementBoard.nodeInferenceDevices.colState`,`State`),sortValue:e=>e.state,render:e=>i(`span`,{title:h(Ja[e.state][0],Ja[e.state][1]),children:i(K,{variant:Ga[e.state],size:`sm`,children:h(qa[e.state][0],qa[e.state][1])})})},{key:`share`,header:h(`placementBoard.nodeInferenceDevices.colShare`,`Share`),align:`right`,sortValue:e=>e.share?.effectivePct??null,render:e=>i(eo,{row:e,sourceLabel:L})},{key:`sessions`,header:h(`placementBoard.nodeInferenceDevices.colSessions`,`Sessions`),align:`right`,sortValue:e=>e.sessionsNow,render:t=>e(`span`,{className:`tabular-nums text-xs text-foreground`,children:[t.sessionsNow??`—`,t.atCap&&i(K,{variant:`warning`,size:`sm`,className:`ml-1`,children:h(`placementBoard.nodeInferenceDevices.atCap`,`at cap`)})]})},{key:`cap`,header:h(`placementBoard.nodeInferenceDevices.colCap`,`Max sessions`),notSortableReason:h(`placementBoard.nodeInferenceDevices.capNotSortable`,`An editable field: sort by Sessions instead.`),render:t=>{let n=T[t.device.key]??Xa(t.device);if(!(n.enabled&&t.device.available))return i(`span`,{className:`text-xs text-foreground-subtle`,children:`—`});let r=Ka(t.device).label;return e(`div`,{className:`flex items-center justify-end gap-1`,children:[i(vt,{type:`number`,min:1,placeholder:`∞`,value:n.maxSessions??``,onChange:e=>{let n=e.target.value.trim(),r=n===``?null:Number.parseInt(n,10);M(t.device,{maxSessions:r!==null&&r>0?r:null})},disabled:I,"aria-label":h(`placementBoard.nodeInferenceDevices.maxConcurrentSessionsFor`,`Max concurrent sessions for {{label}}`,{label:r}),className:`w-16 text-right`}),i(to,{suggested:c?.[t.device.key]??null,current:n.maxSessions,pending:I,onApply:e=>M(t.device,{maxSessions:e})})]})}},{key:`enabled`,header:h(`placementBoard.nodeInferenceDevices.colEnabled`,`Enabled`),align:`right`,notSortableReason:h(`placementBoard.nodeInferenceDevices.enabledNotSortable`,`A switch: sort by State instead.`),render:e=>{let n=Ka(e.device).label;if(e.state===`absent`)return i(en,{label:h(`placementBoard.nodeInferenceDevices.forget`,`Forget`),icon:U,size:`sm`,triggerVariant:`ghost`,disabled:I,title:h(`placementBoard.nodeInferenceDevices.forgetTitle`,`Forget {{label}} on {{node}}?`,{label:n,node:r}),description:h(`placementBoard.nodeInferenceDevices.forgetDescription`,`Its stored settings (switch, weight, cap, step models) are deleted. If the device comes back it starts from the defaults.`),action:()=>x.mutateAsync({agentNodeId:t,deviceKey:e.device.key})});let a=T[e.device.key]??Xa(e.device);return i(cn,{checked:a.enabled&&e.device.available,onCheckedChange:()=>M(e.device,{enabled:!a.enabled}),disabled:!e.device.available||I,"aria-label":h(`placementBoard.nodeInferenceDevices.enable`,`Enable {{label}}`,{label:n})})}}],z=b.error??x.error??S.error;return e(`div`,{className:`rounded-lg border border-border bg-surface`,children:[e(`div`,{className:`flex items-center gap-2 px-3 py-2`,children:[e(q,{variant:`ghost`,size:`sm`,onClick:()=>O(!A),className:`min-w-0 flex-1 justify-start`,"aria-expanded":A,children:[i(te,{className:`h-4 w-4 shrink-0 text-foreground-subtle transition-transform ${A?`rotate-90`:``}`}),i(`span`,{className:`truncate text-sm font-medium text-foreground`,children:r}),i(`span`,{className:`ml-auto flex items-center gap-1 text-xs text-foreground-subtle`,children:w?e(d,{children:[i(Le,{className:`h-3.5 w-3.5`}),h(`pipeline.nodeInferenceDevices.accelerators`,{count:ee})]}):e(d,{children:[i(B,{className:`h-3.5 w-3.5`}),` `,h(`common.unreachable`)]})})]}),e(q,{variant:`ghost`,size:`sm`,onClick:()=>S.mutate({nodeId:t}),disabled:S.isPending||!w,title:h(`placementBoard.nodeInferenceDevices.rescanTitle`,`Probe this node for accelerators now (a Coral plugged in or pulled out). The node also re-probes every minute.`),children:[i(k,{className:`h-3.5 w-3.5 ${S.isPending?`animate-spin`:``}`}),h(`placementBoard.nodeInferenceDevices.rescan`,`Rescan`)]})]}),A&&e(`div`,{className:`space-y-3 border-t border-border p-3`,children:[w?v&&C.length===0?i(`p`,{className:`text-center text-xs text-foreground-subtle`,children:h(`placementBoard.nodeInferenceDevices.probingAccelerators`,`Probing accelerators…`)}):i(Cn,{columns:R,rows:ne,rowKey:e=>e.device.key,minWidthPx:640,bordered:!1,emptyMessage:h(`placementBoard.nodeInferenceDevices.noInferenceDevicesReportedBy`,`No inference devices reported by this node's platform probe.`)}):i(no,{}),S.data!==void 0&&i(`p`,{className:`text-xs text-foreground-subtle`,children:Qa(h,S.data.appeared,S.data.disappeared)}),w&&!f&&N.length>=2&&e(`div`,{className:`space-y-3 rounded-lg border border-border p-3`,children:[e(`h4`,{className:`flex items-center gap-1.5 text-xs font-semibold uppercase tracking-wide text-foreground-subtle`,children:[i(Ne,{className:`h-3.5 w-3.5`}),h(`placementBoard.nodeInferenceDevices.acceleratorShare`,`Accelerator share`)]}),i(Va,{nodes:P,pending:I,onCommitWeights:F,weightLabel:`Accelerator share`,footnote:h(`placementBoard.nodeInferenceDevices.dragToShiftTheShare`,`Drag to shift the share of detection sessions each accelerator handles; lock one to pin its share while the others rebalance. Shares always sum to 100%.`)})]}),z!=null&&e(`div`,{className:`rounded-md border border-danger/30 bg-danger/5 px-3 py-2 text-xs text-danger`,children:[h(`placementBoard.nodeInferenceDevices.failedToSaveInferenceDevices`,`Failed to save inference devices:`),` `,z.message]})]})]})}function Xa(e){return{enabled:e.enabled,weight:e.weight,maxSessions:e.maxSessions,steps:e.steps??{}}}function Za(e,t){switch(t){case`benchmark`:return e(`placementBoard.nodeInferenceDevices.sourceBenchmark`,`benchmark`);case`hardware`:return e(`placementBoard.nodeInferenceDevices.sourceHardware`,`hardware`);case`manual`:return e(`placementBoard.nodeInferenceDevices.sourceManual`,`manual`);case void 0:return null}}function Qa(e,t,n){return t.length===0&&n.length===0?e(`placementBoard.nodeInferenceDevices.rescanNoChange`,`Rescanned: no change.`):e(`placementBoard.nodeInferenceDevices.rescanChanged`,`Rescanned: appeared {{appeared}} · disappeared {{disappeared}}`,{appeared:t.length>0?t.join(`, `):`—`,disappeared:n.length>0?n.join(`, `):`—`})}function $a({row:t,steps:n}){let r=Ka(t.device),a=Ha({defaultModelId:t.device.defaultModelId,steps:n??t.device.steps??{}});return e(`div`,{className:`flex min-w-0 items-center gap-2`,children:[i(r.Icon,{className:`h-4 w-4 shrink-0 text-foreground-subtle`}),e(`div`,{className:`min-w-0`,children:[e(`div`,{className:`flex items-center gap-1.5`,children:[i(`span`,{className:`text-sm font-medium text-foreground`,children:r.label}),i(K,{variant:`neutral`,size:`sm`,className:`font-mono`,children:t.device.format})]}),e(`div`,{className:`flex flex-wrap items-center gap-x-1.5 text-xs text-foreground-subtle`,children:[i(`span`,{className:`font-mono`,children:t.device.key}),a!==null&&e(d,{children:[i(`span`,{"aria-hidden":!0,children:`·`}),i(`span`,{children:i(En,{i18nKey:`pipeline.nodeInferenceDevices.rootModel`,values:{model:a},components:{mono:i(`span`,{className:`font-mono text-foreground-muted`})}})})]})]})]})]})}function eo({row:t,sourceLabel:n}){let{t:r}=X();if(t.share===null)return i(`span`,{className:`text-xs text-foreground-subtle`,children:`—`});let{configuredPct:a,effectivePct:o}=t.share,s=Math.round(a)!==Math.round(o);return e(`div`,{className:`text-right`,children:[e(`div`,{className:`tabular-nums text-sm text-foreground`,children:[Math.round(o),`%`]}),e(`div`,{className:`text-xs text-foreground-subtle`,children:[s?r(`placementBoard.nodeInferenceDevices.shareConfigured`,`set {{pct}}%`,{pct:Math.round(a)}):null,s&&n!==null?` · `:null,n]})]})}function to({suggested:e,current:t,pending:n,onApply:r}){let{t:a}=X();return e===null||e<1||e===t?null:i(q,{variant:`ghost`,size:`sm`,onClick:()=>r(e),disabled:n,title:a(`placementBoard.nodeInferenceDevices.advisoryCapFromTheMeasured`,`Advisory cap from the measured throughput at the suggested model, with the headroom kept free. Applying it writes this device's cap.`),children:a(`pipeline.nodeInferenceDevices.use`,{value:e})})}function no(){let{t}=X();return e(`div`,{className:`flex flex-col items-center gap-2 px-4 py-6 text-center`,children:[i(B,{className:`h-6 w-6 text-foreground-subtle`}),i(`p`,{className:`text-xs font-medium text-foreground`,children:t(`placementBoard.nodeInferenceDevices.nodeUnreachable`,`Node unreachable`)}),i(`p`,{className:`max-w-sm text-xs text-foreground-subtle`,children:t(`placementBoard.nodeInferenceDevices.thePlatformProbeCouldnT`,`The platform probe couldn't be reached, so its live accelerator set is unavailable. Settings resume once the node reconnects.`)})]})}s();var ro=3600*1e3,io=2e4,ao=.4;function oo({refreshToken:t,onOpenAutoTune:r}){let{t:a}=X(),s=l(),{nodes:c}=J(),f=dn(void 0),p=It({isCamera:!0,projection:`slim`}),h=tt({windowMs:ro},{refetchInterval:io,placeholderData:u}).data,g=wn(void 0,{refetchInterval:io,placeholderData:u}).data,_=()=>{Zn(s),s.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getNodeInferenceDevices`]]})},v=rn({onSuccess:_}),y=qt({onSuccess:()=>{_(),s.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getEffectiveShares`]]})}}),b=mn({onSuccess:_}),x=Pt(),[S,C]=o(!1),w=g?.source,E=w===`benchmark`?`benchmark`:`hardware`,D=sn({headroom:ao,source:E},{enabled:S,staleTime:1/0}),O=D.data,k=n(()=>{let e=new Map((f.data??[]).map(e=>[e.nodeId,e.settings]));return c.filter(t=>pr(e.get(t.id)).pipeline).map(t=>{let n=e.get(t.id);return{id:t.id,name:t.name,isOnline:t.isOnline,weight:tr(n,`detectWeight`)??1,maxCameras:tr(n,`maxCameras`)}})},[c,f.data]),A=e=>c.find(t=>t.id===e)?.name??e,j=Er((p.data??[]).map(e=>({id:e.id,name:e.name}))),te=O?Aa(O):void 0,M=Ma(k,g),ne=w!==`manual`,N=g!==void 0&&g.source!==`manual`&&!g.autoPending,P=e=>g?.nodes.find(t=>t.nodeId===e),F=e=>h?.nodes.find(t=>t.nodeId===e),I=g?Na(g,A):null,L=g?Ia(g,A):null,R=Pa.find(e=>e.value===w)?.hint;return e(`div`,{className:`space-y-3 sm:space-y-4`,children:[i(vr,{refreshToken:t}),i(Ca,{stats:h,showAccelerators:!1,...g!==void 0&&g.source!==`manual`&&!g.autoPending?{targetWeights:Object.fromEntries(g.nodes.map(e=>[e.nodeId,e.configuredPct]))}:{}}),i(G,{headingId:`load-balancing-node-shares`,title:a(`pipeline.clusterLoadBalancingTab.nodeShares`,`Node shares`),icon:Ne,actions:e(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[i(`div`,{role:`radiogroup`,"aria-label":a(`pipeline.clusterLoadBalancingTab.shareSource`,`Share source`),className:`flex items-center gap-1`,children:Pa.map(e=>i(q,{role:`radio`,"aria-checked":w===e.value,variant:w===e.value?`primary`:`outline`,size:`sm`,title:e.hint,disabled:y.isPending||g===void 0,onClick:()=>{w!==e.value&&y.mutate({source:e.value})},children:e.label},e.value))}),e(q,{variant:`outline`,size:`sm`,onClick:()=>{C(!0),S&&D.refetch()},disabled:D.isFetching,children:[i(ee,{className:`h-3.5 w-3.5`}),D.isFetching?a(`pipeline.clusterLoadBalancingTab.suggesting`,`Suggesting…`):E===`benchmark`?a(`pipeline.clusterLoadBalancingTab.suggestFromBenchmark`,`Suggest from benchmark`):a(`pipeline.clusterLoadBalancingTab.suggestFromHardware`,`Suggest from hardware`)]}),e(q,{variant:`ghost`,size:`sm`,onClick:r,children:[i(oe,{className:`h-3.5 w-3.5`}),a(`pipeline.clusterLoadBalancingTab.autoTune`,`Auto tune`)]}),e(q,{variant:`outline`,size:`sm`,onClick:()=>x.mutate(void 0),disabled:x.isPending,title:a(`pipeline.clusterLoadBalancingTab.moveStandingAlwaysOnCameras`,`Move standing (always-on) cameras that are no longer on their best node. Pinned cameras never move; on-motion sessions are placed per session anyway.`),children:[i(ie,{className:`h-3.5 w-3.5`}),x.isPending?a(`pipeline.clusterLoadBalancingTab.rebalancing`,`Rebalancing…`):a(`pipeline.clusterLoadBalancingTab.rebalance`,`Rebalance`)]})]}),children:e(`div`,{className:`${m} space-y-3`,children:[R!==void 0&&i(`p`,{className:`text-[10px] text-foreground-subtle`,children:R}),h&&e(`p`,{className:`text-[10px] text-foreground-subtle`,children:[a(`pipeline.clusterLoadBalancingTab.policy`,`Policy:`),` `,i(K,{variant:h.policy===`share`?`info`:`default`,children:h.policy===`share`?a(`pipeline.clusterLoadBalancingTab.honourShares`,`honour shares`):`least-loaded`}),` `,` · ${a(`pipeline.clusterLoadBalancingTab.clusterPeak`,{count:h.clusterPeakSessions})}`,h.policy===`least-loaded`&&` · ${a(`pipeline.clusterLoadBalancingTab.leastLoadedNote`)}`]}),i(Va,{nodes:M.nodes,pending:v.isPending,readOnly:M.readOnly,onCommitWeights:e=>v.mutate(Oa(e)),weightLabel:`Node share`,...M.readOnly?{footnote:g?.autoPending?i(d,{children:a(`pipeline.clusterLoadBalancingTab.automaticSharesAreBeingComputed`,`Automatic shares are being computed from the cluster's measured capacity; the stored values are used meanwhile.`)}):e(d,{children:[w===`benchmark`?a(`pipeline.clusterLoadBalancingTab.benchmarkEachNodeSShare`,`Benchmark: each node's share follows its measured capacity from node benchmark results (hardware capacity where it has none)`):a(`pipeline.clusterLoadBalancingTab.hardwareEachNodeSShare`,`Hardware: each node's share follows its capacity at its Auto tune model, from the measured speed of its hardware`),a(`pipeline.clusterLoadBalancingTab.recomputedWheneverANodeOr`,`, recomputed whenever a node or accelerator is added, removed, switched on or off, or changes model`),g?.computedAt!=null&&i(`span`,{className:`ml-1`,children:a(g.trigger===null?`pipeline.clusterLoadBalancingTab.lastAt`:`pipeline.clusterLoadBalancingTab.lastAtTrigger`,{time:new Date(g.computedAt).toLocaleTimeString(),trigger:g.trigger??``})}),`.`]})}:{}}),I!==null&&i(`p`,{className:`text-[10px] text-foreground-subtle`,children:I}),L!==null&&i(`p`,{className:`text-[10px] text-foreground-subtle`,"data-testid":`benchmark-fallback-note`,children:L}),y.isError&&i(Je,{message:a(`pipeline.clusterLoadBalancingTab.switchFailed`,{message:y.error instanceof Error?y.error.message:a(`common.unknownError`)})}),v.isError&&i(Je,{message:a(`pipeline.clusterLoadBalancingTab.saveFailed`,{message:v.error instanceof Error?v.error.message:a(`common.unknownError`)})}),e(`details`,{className:`rounded-md border border-border`,children:[i(`summary`,{className:`${T} cursor-pointer text-xs text-foreground`,children:a(`pipeline.clusterLoadBalancingTab.maxConcurrentSessionsAdvanced`,`Max concurrent sessions (advanced)`)}),i(`ul`,{className:`divide-y divide-border border-t border-border`,children:k.map(t=>e(`li`,{className:`${T} flex items-center gap-2`,children:[i(`span`,{className:`min-w-0 flex-1 truncate text-xs text-foreground`,children:t.name}),i(vt,{type:`number`,min:1,placeholder:`∞`,defaultValue:t.maxCameras??``,"aria-label":a(`pipeline.clusterLoadBalancingTab.maxConcurrentSessionsFor`,`Max concurrent sessions for {{name}}`,{name:t.name}),className:`w-20 text-right`,disabled:b.isPending,onBlur:e=>{let n=e.target.value.trim(),r=n===``?null:Number.parseInt(n,10),i=r!==null&&r>0?r:null;i!==t.maxCameras&&b.mutate({agentNodeId:t.id,maxCameras:i})}})]},t.id))}),i(`p`,{className:`${T} ${W} border-t border-border`,children:a(`pipeline.clusterLoadBalancingTab.aHardCapOnThe`,`A hard cap on the sessions a node runs at once (always-on cameras count too). A node at its cap is never chosen; under shares its turn goes to a free node. Empty = unlimited.`)})]})]})}),D.isError&&i(Je,{message:a(`pipeline.clusterLoadBalancingTab.suggestionFailed`,{message:D.error instanceof Error?D.error.message:a(`common.unknownError`)})}),O&&i(so,{suggestion:O,nameOf:A,pending:v.isPending,...ne?{}:{onApply:()=>v.mutate(ka(O))}}),i(G,{headingId:`load-balancing-accelerators`,title:a(`pipeline.clusterLoadBalancingTab.accelerators`,`Accelerators`),icon:z,children:i(`div`,{className:`${m} space-y-2`,children:k.length===0?i(nn,{title:a(`pipeline.clusterLoadBalancingTab.noDetectCapableNodes`,`No detect-capable nodes`),description:a(`pipeline.clusterLoadBalancingTab.enableDetectionOnANode`,`Enable detection on a node in Roles & nodes to configure its accelerators.`)}):k.map(e=>i(Ya,{nodeId:e.id,nodeName:e.name,isOnline:e.isOnline,...te?.[e.id]===void 0?{}:{suggestedMaxSessions:te[e.id]},sharesAutomatic:N,...g===void 0?{}:{shareSource:g.source},...P(e.id)===void 0?{}:{share:P(e.id)},...F(e.id)===void 0?{}:{placed:F(e.id)}},e.id))})}),h!==void 0&&h.stalePins.length>0&&i(co,{stats:h,cameraName:j})]})}function so({suggestion:t,nameOf:n,pending:r,onApply:a}){let{t:o}=X();return e(G,{headingId:`load-balancing-suggestion`,title:t.source===`benchmark`?o(`pipeline.clusterLoadBalancingTab.suggestedFromBenchmark`,`Suggested from benchmark`):o(`pipeline.clusterLoadBalancingTab.suggestedFromHardware`,`Suggested from hardware`),icon:ee,...a===void 0?{}:{actions:i(q,{size:`sm`,onClick:a,disabled:r,children:o(`pipeline.clusterLoadBalancingTab.applySuggestedShares`,`Apply suggested shares`)})},children:[i(`ul`,{className:`divide-y divide-border`,children:t.nodes.map(t=>e(`li`,{className:`${T} space-y-0.5`,children:[e(`div`,{className:`flex items-baseline gap-2 text-xs`,children:[i(`span`,{className:`min-w-0 flex-1 truncate font-medium text-foreground`,children:n(t.nodeId)}),i(`span`,{className:`tabular-nums text-foreground`,children:t.share===null?o(`common.skipped`):`${t.share}%`})]}),e(`p`,{className:W,children:[Fa(t.capacityFallback)===null?``:`${Fa(t.capacityFallback)} · `,t.skippedReason===null?o(`pipeline.clusterLoadBalancingTab.parallelSessions`,`≈ {{capacitySessions}} parallel sessions · {{value2}}`,{capacitySessions:t.capacitySessions,value2:t.devices.map(e=>`${e.deviceKey} ${e.share}% (${e.modelId??`—`}${e.measured?``:`, estimated`}, cap ${e.suggestedMaxSessions??`—`})`).join(` · `)}):o(`pipeline.clusterLoadBalancingTab.notPartOfTheSuggestion`,`not part of the suggestion — {{skippedReason}}`,{skippedReason:t.skippedReason})]})]},t.nodeId))}),e(`p`,{className:`${T} ${W} border-t border-border`,children:[o(`pipeline.clusterLoadBalancingTab.sharesIntro`,{fps:t.cameraFps,headroom:Math.round(t.headroom*100),basis:t.source===`benchmark`?o(`pipeline.clusterLoadBalancingTab.measuredByNodeBenchmarksOr`,`measured by node benchmarks, or from the hardware table where a node has no results`):o(`pipeline.clusterLoadBalancingTab.atTheModelsAutoTune`,`at the models Auto tune picks (at least {{minSessionsPerDevice}} per accelerator), from the measured speed of each node's hardware`,{minSessionsPerDevice:t.minSessionsPerDevice})}),` `,a===void 0?o(`pipeline.clusterLoadBalancingTab.automaticSharesAlreadyFollowThis`,`Automatic shares already follow this; the caps are advisory — apply each from its accelerator row.`):o(`pipeline.clusterLoadBalancingTab.applyingWritesTheNodeAnd`,`Applying writes the node and accelerator shares; the caps are advisory — apply each from its accelerator row.`)]})]})}function co({stats:t,cameraName:n}){let{t:r}=X(),a=l(),o=Wt({onSuccess:()=>{a.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPlacementStats`]]}),a.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineDevicePin`]]})}});return i(G,{headingId:`load-balancing-stale-pins`,title:r(`pipeline.clusterLoadBalancingTab.staleDevicePins`,`Stale device pins`),icon:Pe,children:i(`ul`,{className:`divide-y divide-border`,children:t.stalePins.map(t=>e(`li`,{className:`${T} flex items-center gap-2`,children:[e(`div`,{className:`min-w-0 flex-1`,children:[i(`p`,{className:`truncate text-xs text-foreground`,title:n(t.deviceId),children:n(t.deviceId)}),i(`p`,{className:W,children:ja(t)})]}),i(q,{variant:`outline`,size:`sm`,disabled:o.isPending,onClick:()=>o.mutate({deviceId:t.deviceId,deviceKey:`auto`}),children:r(`pipeline.clusterLoadBalancingTab.clearPin`,`Clear pin`)})]},t.deviceId))})})}function lo({node:t,emphasis:n=!1}){let{t:r}=X(),a=t.isHub?C:z;return e(`div`,{className:`flex items-center gap-2.5 min-w-0`,children:[i(`span`,{className:`h-2 w-2 shrink-0 rounded-full ${t.isOnline?`bg-success`:`bg-danger`}`,"aria-hidden":`true`}),i(a,{className:`h-4 w-4 shrink-0 text-foreground-subtle`,"aria-hidden":`true`}),e(`div`,{className:`min-w-0`,children:[e(`div`,{className:`flex items-center gap-1.5 ${n?`text-sm`:`text-xs`} font-semibold text-foreground`,children:[i(`span`,{className:`truncate`,children:t.name}),t.isHub&&i(K,{variant:`info`,className:`px-1.5 py-0 text-[9px] uppercase tracking-wider`,children:r(`common.hubWord`)}),!t.isOnline&&i(K,{variant:`danger`,className:`px-1.5 py-0 text-[9px] uppercase tracking-wider`,children:r(`common.offline`)})]}),i(`div`,{className:`font-mono text-[10px] text-foreground-subtle truncate`,children:t.id})]})]})}function uo({nodes:e,actions:t}){let{t:n}=X();return i(Cn,{columns:[{key:`node`,header:n(`placementBoard.nodeCapabilitiesTable.node`,`Node`),sortValue:e=>e.name,render:e=>i(lo,{node:e})},...ir.map(e=>({key:e.key,header:n(e.labelKey),align:`center`,notSortableReason:`A switch — sorting would move the row while it is being changed.`,render:r=>i(cn,{"aria-label":n(`placementBoard.nodeCapabilitiesTable.on`,`{{label}} on {{name}}`,{label:n(e.labelKey),name:r.name}),title:n(e.hintKey),checked:Xn(r.effective,e.key),disabled:t.capabilityPending,onCheckedChange:n=>t.onToggleCapability(r.id,e.key,n)})}))],rows:e,rowKey:e=>e.id,bordered:!1,minWidthPx:720,rowClassName:e=>e.isOnline?void 0:`opacity-60`,emptyMessage:n(`placementBoard.nodeCapabilitiesTable.noClusterNodesReportingYet`,`No cluster nodes reporting yet.`)})}function fo({roleValues:t,options:n,pending:r,onRoleChange:a}){let{t:o}=X(),s=n.map(e=>({value:e.id,label:e.id===`hub`?o(`placementBoard.roleControls.default`,`{{name}} (default)`,{name:e.name}):e.name}));return i(`ul`,{className:`divide-y divide-border`,children:sr.map(n=>e(`li`,{className:`${T} flex flex-wrap items-center gap-x-3 gap-y-1.5`,children:[e(`div`,{className:`min-w-0 flex-1 basis-56`,children:[i(`div`,{className:`text-xs font-medium text-foreground`,children:lr(n)}),i(`p`,{className:W,children:cr(n)})]}),i(`div`,{className:`w-full sm:w-48`,children:i(I,{"aria-label":o(`placementBoard.roleControls.node`,`{{value1}} node`,{value1:lr(n)}),value:t[n],disabled:r,options:s,onChange:e=>a(n,e.target.value)})})]},n))})}s();function po(){let{t}=X(),r=l(),{nodes:a}=J(),o=dn(void 0),s=ze({addonId:$n,cap:Jn,scope:`cluster`}),c=ze({addonId:ar,cap:Yn,scope:`cluster`}),u=ze({addonId:or,cap:nr,scope:`cluster`}),d=()=>Zn(r),f=Be({onSuccess:d}),p=hn({onSuccess:d}),m=n(()=>{let e=new Map;for(let t of o.data??[])e.set(t.nodeId,t.settings);return e},[o.data]),h=n(()=>a.map(e=>{let t=m.get(e.id),n=pr(t);return{id:e.id,name:e.name,isHub:e.isHub,isOnline:e.isOnline,settings:t,effective:n}}),[a,m]),g={ingestNode:Qn(s.data,`ingestNode`,`hub`),recordingNode:Qn(c.data,er,`hub`),audioNode:Qn(s.data,`audioNode`,`hub`),motionNode:Qn(s.data,`motionNode`,`hub`),postProcessingNode:Qn(u.data,rr,`hub`)},_=n(()=>{let e=a.filter(e=>e.isOnline).map(e=>e.id),t=e=>a.find(t=>t.id===e)?.name||e;return[...new Set([`hub`,...sr.map(e=>g[e]),...e])].filter(e=>e.length>0).map(e=>({id:e,name:t(e)}))},[a,g]),v=o.isLoading||s.isLoading||c.isLoading||u.isLoading,y=(e,t,n)=>{f.mutate({agentNodeId:e,[t]:n})},b=(e,t)=>{if(e===`recordingNode`){p.mutate({addonId:ar,cap:Yn,scope:`cluster`,patch:{[er]:t}});return}if(e===`postProcessingNode`){p.mutate({addonId:or,cap:nr,scope:`cluster`,patch:{[rr]:t}});return}p.mutate({addonId:$n,cap:Jn,scope:`cluster`,patch:{[e]:t}})},x={capabilityPending:f.isPending,onToggleCapability:y},S=v?i(ce,{className:`h-3.5 w-3.5 animate-spin text-foreground-subtle`,"aria-label":t(`pipeline.clusterRolesNodesTab.loading`,`Loading`)}):null;return e(`div`,{className:`space-y-3 sm:space-y-4`,children:[e(G,{headingId:`roles-nodes-cluster-roles`,title:t(`pipeline.clusterRolesNodesTab.clusterRoles`,`Cluster roles`),icon:Me,actions:S,children:[i(`p`,{className:`${W} border-b border-border px-3 py-1.5 sm:px-4`,children:t(`pipeline.clusterRolesNodesTab.oneNodeHoldsEachRole`,`One node holds each role for every camera. Detection shares and caps are on Load balancing.`)}),i(fo,{roleValues:g,options:_,pending:p.isPending,onRoleChange:b})]}),i(G,{headingId:`roles-nodes-node-capabilities`,title:t(`pipeline.clusterRolesNodesTab.nodeCapabilities`,`Node capabilities`),icon:C,children:i(uo,{nodes:h,actions:x})})]})}s();var mo=2500,ho={faces:g,"semantic-search":oe,"detail-crop":Ie,"native-lease":Le,streaming:O,recorder:L,"runner-defaults":z,"load-balancer":Ne,failover:x},go=[`cluster`,yi];function _o(e){a(()=>{if(e===null)return;let t=xi[e]??e,n=`[data-cluster-settings-card="${CSS.escape(t)}"]`,r=()=>{let e=document.querySelector(n);return e===null?!1:(e.scrollIntoView({block:`start`,behavior:`smooth`}),e.classList.add(`ring-2`,`ring-primary/60`),setTimeout(()=>e.classList.remove(`ring-2`,`ring-primary/60`),mo),!0)};if(r())return;let i=new MutationObserver(()=>{r()&&i.disconnect()});return i.observe(document.body,{childList:!0,subtree:!0}),()=>i.disconnect()},[e])}function vo({section:t}){let{t:n}=X();return i(`div`,{"data-cluster-settings-card":t.id,className:`rounded-lg`,children:i(G,{headingId:`cluster-settings-${t.id}`,title:t.title,...ho[t.id]===void 0?{}:{icon:ho[t.id]},children:e(`div`,{className:`${m} space-y-3`,children:[i(`p`,{className:W,children:t.hint}),t.panels.map(e=>i(kn,{nodeId:`hub`,addonIds:[e.addonId],level:`global`,hideSectionChrome:!0,omitSectionIds:go.filter(t=>!(e.sectionIds??[]).includes(t)),emptyMessage:n(`pipeline.clusterSettingsTab.notAvailableTheAddonThat`,`Not available — the addon that owns these settings did not answer.`),...e.capability===void 0?{}:{capability:e.capability},...e.sectionIds===void 0?{}:{sectionIds:e.sectionIds},...e.fieldKeys===void 0?{}:{fieldKeys:e.fieldKeys},...e.omitFieldKeys===void 0?{}:{omitFieldKeys:e.omitFieldKeys},...e.fieldScope===void 0?{}:{fieldScope:e.fieldScope}},`${e.addonId}:${e.capability??``}:${(e.sectionIds??e.fieldKeys??[]).join(`,`)}`))]})})})}function yo({refreshToken:e}){let[t]=Dn();return _o(t.get(wi)),i(`div`,{className:`space-y-3 sm:space-y-4`,children:bi.map(e=>i(vo,{section:e},e.id))})}function bo(e){return e?.hex}function xo({hex:e}){return i(`span`,{className:`inline-block h-3 w-3 shrink-0 rounded-sm border border-border`,style:{backgroundColor:e}})}function So({id:t,label:n,swatch:r}){let a=bo(r);return a===void 0?null:e(`span`,{className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-0.5 text-xs`,"data-testid":`palette-entry-${t}`,children:[r?.form===`gradient`?i(`span`,{className:`flex h-4 overflow-hidden rounded-sm`,children:fe.map(e=>i(`span`,{className:`h-4 w-2`,style:{backgroundColor:a,opacity:e}},e))}):i(`span`,{className:`h-4 w-3 shrink-0 rounded-sm`,style:{backgroundColor:a}}),i(`span`,{children:n}),i(`span`,{className:`font-mono text-[11px] opacity-80`,children:a})]})}function Co({ground:t,group:n,swatches:r}){let{t:a}=X();return e(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[i(So,{id:n.id,label:n.label,swatch:r[n.id]}),n.children.length>0&&e(`details`,{"data-testid":`palette-subs-${t}-${n.id}`,children:[i(`summary`,{className:`cursor-pointer text-[11px] opacity-80`,children:a(`pipeline.palette.subclasses`,`Subclasses`)}),i(`div`,{className:`mt-1 flex flex-col gap-1 pl-4`,children:n.children.map(e=>i(So,{id:e.id,label:e.label,swatch:r[e.id]},e.id))})]})]})}function wo({swatches:t}){let{t:n}=X(),r=le(),a=[{id:`dark`,background:pe.dark,ink:pe.light},{id:`light`,background:pe.light,ink:pe.dark}];return e(`div`,{className:`flex flex-col gap-2`,"data-testid":`palette-preview`,children:[i(`div`,{className:`text-[11px] text-foreground-subtle`,children:n(`pipeline.palette.preview`,`Timeline marks`)}),a.map(e=>i(`div`,{className:`grid grid-cols-1 gap-x-4 gap-y-2 rounded-md border border-border p-2 sm:grid-cols-2`,"data-testid":`palette-ground-${e.id}`,style:{backgroundColor:e.background,color:e.ink},children:r.map(n=>i(Co,{ground:e.id,group:n,swatches:t},n.id))},e.id))]})}function To(e){for(let t of le()){if(t.id===e)return t.label;let n=t.children.find(t=>t.id===e);if(n!==void 0)return n.label}return e}s();function Eo(e){return/^#[0-9a-f]{6}$/.test(e)}function Do(e,t){let n={};for(let r of me){let i=t[r],a=e[r];i===void 0||a===void 0||i.hex!==a.hex&&(n[r]=i)}return n}function Oo({status:t,reason:r,source:a,presetId:s,customized:c,swatches:l,presets:u,saving:d,onApply:f}){let{t:p}=X(),[m,h]=o(c===!0),[g,_]=o(s??u[0]?.id??`camstack`),[v,y]=o(l??u[0]?.swatches??{}),b=u.find(e=>e.id===g)??u[0],x=n(()=>b===void 0?null:ue(v,b.fallbacks),[b,v]);if(t===`pending`)return i(`p`,{className:`text-xs text-foreground-subtle`,role:`status`,children:p(`pipeline.palette.pending`,`Reading the cluster palette…`)});let S=e=>{let t=u.find(t=>t.id===e);t!==void 0&&(h(!1),_(e),y(t.swatches),f({presetId:e}))},C=()=>{b!==void 0&&(h(!0),y(b.swatches))},w=(e,t)=>{if(typeof t!=`string`)return;let n=t.trim().toLowerCase();if(!Eo(n))return;let r=v[e],i=r?.form===`gradient`?{...r,hex:n}:{form:`solid`,hex:n};y({...v,[e]:i})};return e(`div`,{className:`flex flex-col gap-4`,children:[t===`unknown`&&i(`p`,{className:`text-xs text-warning`,role:`status`,"data-testid":`palette-unknown`,children:p(`pipeline.palette.unknown`,`The stored palette cannot be read ({{reason}}). Boxes use the bundled CamStack preset.`,{reason:r??``})}),t===`ready`&&a===`unconfigured`&&i(`p`,{className:`text-xs text-foreground-subtle`,children:p(`pipeline.palette.sourceUnconfigured`,`CamStack preset (cluster default)`)}),i(G,{headingId:`palette-presets`,title:p(`pipeline.palette.presets`,`Presets`),children:e(`div`,{className:`flex flex-wrap gap-2 p-3`,children:[u.map(t=>i(q,{type:`button`,size:`sm`,variant:!m&&t.id===g?`primary`:`outline`,onClick:()=>S(t.id),disabled:d,children:e(`span`,{className:`inline-flex items-center gap-1`,children:[[`person`,`vehicle`,`animal`].map(e=>{let n=bo(t.swatches[e]);return n===void 0?null:i(xo,{hex:n},e)}),t.name]})},t.id)),i(q,{type:`button`,size:`sm`,variant:m?`primary`:`outline`,onClick:C,disabled:d||b===void 0,children:p(`pipeline.palette.custom`,`Custom`)})]})}),i(wo,{swatches:v}),x!==null&&x.ok&&i(`p`,{className:`text-xs text-success`,"data-testid":`palette-verdict`,children:p(`pipeline.palette.valid`,`Every colour is distinct on both themes.`)}),x!==null&&!x.ok&&i(`p`,{className:`text-xs text-danger`,"data-testid":`palette-verdict`,children:p(`pipeline.palette.invalid`,`This palette is refused: {{reason}}`,{reason:de(x.violations)})}),m&&b!==void 0&&i(G,{headingId:`palette-custom`,title:p(`pipeline.palette.custom`,`Custom`),children:e(`div`,{className:`flex flex-col gap-2 p-3`,children:[me.map(e=>{let t=bo(v[e]);return t===void 0?null:i(ft,{field:{type:`color`,key:e,label:To(e)},values:{[e]:t},onChange:(t,n)=>w(e,n)},e)}),i(q,{type:`button`,size:`sm`,onClick:()=>{if(b===void 0||x===null||!x.ok)return;let e=Do(b.swatches,v);f(Object.keys(e).length>0?{presetId:b.id,overrides:e}:{presetId:b.id})},disabled:d||x===null||!x.ok,children:p(`pipeline.palette.save`,`Save custom palette`)})]})})]})}function ko(){let e=dt({}),t=mt({}),n=Qe(),r=r=>{n.mutate(r,{onSuccess:()=>{e.refetch(),t.refetch()}})};if(e.isPending||t.isPending)return i(Oo,{status:`pending`,presets:[],onApply:r});if(e.isError||e.data===void 0)return i(Oo,{status:`unknown`,reason:e.isError?String(e.error):`no palette`,presets:t.data??[],saving:n.isPending,onApply:r});if(t.isError||t.data===void 0)return i(Oo,{status:`unknown`,reason:String(t.error),presets:[],saving:n.isPending,onApply:r});if(e.data.status===`unknown`)return i(Oo,{status:`unknown`,reason:e.data.reason,presets:t.data,saving:n.isPending,onApply:r});let a=e.data;return i(Oo,{status:`ready`,source:a.source,presetId:a.presetId,customized:a.customized,swatches:a.swatches,presets:t.data,saving:n.isPending,onApply:r},`${a.presetId}:${String(a.customized)}`)}var Ao=`pipeline-orchestrator`,jo=200;function Mo(){let{t}=X();return e(`div`,{className:`flex flex-col gap-3`,children:[e(`div`,{children:[i(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:t(`pipeline.clusterOrchestratorLogsTab.orchestratorLogs`,`Orchestrator logs`)}),i(`p`,{className:`text-[11px] text-foreground-subtle`,children:t(`pipeline.clusterOrchestratorLogsTab.dispatchDecisionsBalancerMovesAnd`,`Dispatch decisions, balancer moves and failover events from the pipeline orchestrator. Streaming live; the device chip on a line tells which camera it refers to.`)})]}),i(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:i(on,{addonId:Ao,limit:jo,maxHeight:`max-h-[calc(100vh-360px)]`,showScope:!0,showDeviceChip:!0,showFilters:!1,showSourceSelect:!0})})]})}var No=[{id:`assignments`,labelKey:`pipeline.clusterDetail.tabAssignments`},{id:`load-balancing`,labelKey:`pipeline.clusterDetail.tabLoadBalancing`},{id:`auto-tune`,labelKey:`pipeline.clusterDetail.tabAutoTune`},{id:`roles-nodes`,labelKey:`pipeline.clusterDetail.tabRoles`},{id:`settings`,labelKey:`common.settings`},{id:`logs`,labelKey:`common.logs`},{id:`palette`,labelKey:`pipeline.clusterDetail.tabPalette`}];function Po(e){return No.some(t=>t.id===e)}function Fo({refreshToken:t}){let{t:n}=X(),[r,a]=Dn(),o=r.get(Ci),s=Po(o)?o:`assignments`,c=e=>{a(t=>{let n=new URLSearchParams(t);return n.set(Ci,e),n.delete(wi),n},{replace:!0})};return e(`div`,{className:`flex flex-col h-full`,children:[e(`div`,{className:`px-4 sm:px-6 py-4 border-b border-border`,children:[i(`h2`,{className:`text-base font-semibold text-foreground`,children:n(`pipeline.clusterDetail.clusterOrchestration`,`Cluster Orchestration`)}),i(`div`,{className:`text-[11px] text-foreground-subtle mt-1`,children:n(`pipeline.clusterDetail.cameraAssignmentsLoadBalancingThe`,`Camera assignments, load balancing, the detector recommendation, cluster roles, settings and the display palette.`)})]}),i(Vt,{value:s,onValueChange:e=>{Po(e)&&c(e)},className:`px-4 sm:px-6`,children:i(fn,{className:`border-border`,children:No.map(e=>i(Ut,{value:e.id,className:`h-auto py-2 border-b-2`,children:n(e.labelKey)},e.id))})}),e(`div`,{className:`flex-1 min-h-0 overflow-y-auto p-4 sm:p-6 @container/clustertab`,children:[s===`assignments`&&i(Xi,{}),s===`load-balancing`&&i(oo,{refreshToken:t,onOpenAutoTune:()=>c(`auto-tune`)}),s===`auto-tune`&&i(ha,{}),s===`roles-nodes`&&i(po,{}),s===`settings`&&i(yo,{refreshToken:t}),s===`logs`&&i(Mo,{}),s===`palette`&&i(ko,{})]})]})}function Q({title:t,children:n}){return e(`div`,{className:`bg-background px-3.5 py-3 min-w-0`,children:[i(`div`,{className:`text-[9px] font-semibold uppercase tracking-[0.14em] text-foreground-subtle mb-2`,children:t}),i(`div`,{className:`flex flex-col gap-1 min-w-0`,children:n})]})}function $({label:t,children:n,overridden:r=!1}){return e(`div`,{className:`flex items-baseline gap-2 text-[11px] leading-snug min-w-0`,children:[i(`span`,{className:`text-foreground-subtle shrink-0 w-24 truncate`,title:t,children:t}),i(`span`,{className:`font-mono tabular-nums text-foreground min-w-0 truncate flex-1`,children:n}),r&&i(Io,{})]})}function Io(){let{t:e}=X();return i(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full bg-warning shrink-0 self-center`,title:e(`cameras.cardPrimitives.deviceLevelOverrideActive`,`Device-level override active`),"aria-label":e(`cameras.cardPrimitives.deviceLevelOverrideActive`,`Device-level override active`),role:`img`})}var Lo={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 Ro({tone:e=`neutral`,children:t,title:n}){return i(`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 ${Lo[e]}`,children:t})}function zo({children:e}){return i(`div`,{className:`text-[11px] text-foreground-subtle italic`,children:e})}function Bo({icon:t,label:n,nodeId:r,pinned:a,reason:o,overridden:s}){let{t:c}=X();return e(`div`,{className:`flex items-center gap-2 text-[11px] leading-snug min-w-0`,children:[i(t,{className:`h-3 w-3 text-foreground-subtle shrink-0`}),i(`span`,{className:`text-foreground-subtle w-[4.5rem] shrink-0`,children:n}),r===null?i(`span`,{className:`text-foreground-subtle italic`,children:c(`cameras.configBlocks.unassigned`)}):e(d,{children:[i(`span`,{className:`font-mono text-foreground truncate`,title:r,children:r}),a?e(`span`,{className:`inline-flex items-center gap-0.5 text-[10px] text-warning shrink-0`,title:c(`cameras.configBlocks.manuallyPinned`,`Manually pinned`),children:[i(N,{className:`h-2.5 w-2.5`}),` `,c(`cameras.configBlocks.manual`)]}):i(`span`,{className:`text-[10px] text-foreground-subtle shrink-0 truncate`,children:c(`cameras.configBlocks.autoReason`,{reason:o!==void 0&&o.length>0?o:c(`cameras.configBlocks.capacity`)})}),s&&i(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full bg-warning shrink-0`,title:c(`cameras.configBlocks.persistedSettingsPinForThis`,`Persisted settings pin for this role`)})]})]})}function Vo({assignment:t,settings:n,onlineNodes:r,pinPending:a,onDetectionPinChange:o}){let{t:s}=X(),c=t.pinned.detection&&t.detectionNodeId!==null?t.detectionNodeId:`auto`,l=[...new Set([...t.detectionNodeId===null?[]:[t.detectionNodeId],...r.map(e=>e.id)])];return e(Q,{title:s(`cameras.configBlocks.whereItRuns`,`Where it runs`),children:[i(Bo,{icon:z,label:s(`cameras.configBlocks.detection`,`Detection`),nodeId:t.detectionNodeId,pinned:t.pinned.detection,reason:t.reasons.detection,overridden:n.overriddenKeys.has(`pipelineNodeId`)}),i(Bo,{icon:L,label:s(`cameras.configBlocks.decoder`,`Decoder`),nodeId:t.decoderNodeId,pinned:t.pinned.decoder,reason:t.reasons.decoder,overridden:n.overriddenKeys.has(`decoderNodeId`)}),i(Bo,{icon:h,label:s(`cameras.configBlocks.audio`,`Audio`),nodeId:t.audioNodeId,pinned:t.pinned.audio,reason:t.reasons.audio,overridden:n.overriddenKeys.has(`audioNodeId`)}),i(Bo,{icon:O,label:s(`cameras.configBlocks.source`,`Source`),nodeId:t.sourceNodeId,pinned:!1,reason:`ingest owner`,overridden:!1}),i(`div`,{className:`mt-1.5`,children:e(I,{value:c,disabled:a,"aria-label":s(`cameras.configBlocks.detectionPlacementPin`,`Detection placement pin`),onChange:e=>o(e.target.value),className:`w-full min-w-0`,children:[i(`option`,{value:`auto`,children:s(`cameras.configBlocks.autoLoadBalanced`,`Auto (load balanced)`)}),l.map(e=>i(`option`,{value:e,children:s(`cameras.configBlocks.pinDetection`,{node:r.find(t=>t.id===e)?.name??e})},e))]})})]})}function Ho(e){return`${e.width}×${e.height} ${e.codec} @${e.fps}fps`}function Uo(e,t){if(!(t===null||e===void 0))return e.find(e=>e.profile===t)}function Wo(e){return e===null?Y.t(`pipeline.configBlocks.fpsDefault`):e===0?Y.t(`pipeline.configBlocks.fpsNative`):`${e} fps`}function Go({streams:t,brokerProfiles:n,settings:r,motionEnabled:a,motionFpsLive:o,cameraSensors:s}){let{t:c}=X(),l=Uo(n,r.detectionStreamProfile),u=Uo(n,r.motionStreamProfile),f=r.motionSources.includes(`analyzer`);return e(Q,{title:c(`cameras.configBlocks.streamsMotion`,`Streams & motion`),children:[e($,{label:c(`cameras.configBlocks.detectStream`,`Detect stream`),overridden:r.overriddenKeys.has(`detectionStreamProfile`),children:[r.detectionStreamProfile??`—`,l!==void 0&&` · ${l.width}×${l.height} ${l.codec}`]}),i($,{label:c(`cameras.configBlocks.detectFps`,`Detect FPS`),overridden:r.overriddenKeys.has(`detectionFps`),children:Wo(r.detectionFps)}),e($,{label:c(`cameras.configBlocks.motionSrc`,`Motion src`),overridden:r.overriddenKeys.has(`motionSources`),children:[r.motionSources.length>0?r.motionSources.map(ve).join(` + `):c(`cameras.configBlocks.none`),a===!1&&` · ${c(`cameras.configBlocks.inactive`)}`]}),i($,{label:c(`cameras.configBlocks.cameraSensors`,`Camera sensors`),children:In(s)}),f&&e(d,{children:[e($,{label:c(`cameras.configBlocks.motionStream`,`Motion stream`),overridden:r.overriddenKeys.has(`motionStreamProfile`),children:[r.motionStreamProfile??`—`,u!==void 0&&` · ${u.width}×${u.height} ${u.codec}`]}),e($,{label:c(`cameras.configBlocks.motionFps`,`Motion FPS`),overridden:r.overriddenKeys.has(`motionFps`),children:[Wo(r.motionFps),o!==null&&` · ${c(`cameras.configBlocks.liveFps`,{fps:o.toFixed(1)})}`]})]}),i($,{label:c(`cameras.configBlocks.cooldown`,`Cooldown`),overridden:r.overriddenKeys.has(`motionCooldownMs`),children:r.motionCooldownMs===null?c(`cameras.configBlocks.defaultValue`):`${r.motionCooldownMs/1e3}s`}),i(`div`,{className:`mt-1.5 flex flex-col gap-0.5`,children:t.length===0?i(zo,{children:c(`cameras.configBlocks.noStreamsRegistered`,`No streams registered`)}):t.map(t=>e(`div`,{className:`text-[10px] font-mono text-foreground-subtle truncate`,title:t.camStreamId,children:[i(`span`,{className:`text-foreground-muted`,children:t.kind}),` `,Ho(t)]},t.camStreamId))})]})}function Ko({steps:t,audioModelId:n,audioEnabled:r,audioMode:a}){let{t:o}=X();return e(Q,{title:o(`cameras.configBlocks.pipelineSteps`,`Pipeline steps`),children:[t===void 0?i(zo,{children:o(`cameras.configBlocks.resolving`,`Resolving…`)}):t.length===0?i(zo,{children:o(`cameras.configBlocks.noStepsConfigured`,`No steps configured`)}):i(`div`,{className:`flex flex-wrap gap-1`,children:t.map((t,n)=>i(Ro,{tone:t.enabled&&t.depth===0?`info`:`neutral`,title:t.modelId??t.addonId,children:e(`span`,{className:t.enabled?``:`line-through opacity-60`,children:[t.depth>0&&i(`span`,{className:`opacity-50`,children:`↳ `}),t.addonId,t.modelId!==null&&e(`span`,{className:`font-mono opacity-75`,children:[` · `,t.modelId]})]})},`${t.addonId}-${n}`))}),i(`div`,{className:`mt-1`,children:e($,{label:o(`cameras.configBlocks.audioClass`,`Audio class.`),children:[a??`—`,r!==null&&` · ${o(r?`cameras.configBlocks.running`:`cameras.configBlocks.off`)}`,n!==null&&` · ${n}`]})})]})}var qo={ready:`success`,installing:`info`,verifying:`info`,idle:`neutral`,failed:`danger`};function Jo({detection:t,live:n,detectionMode:r,modeOverridden:a}){let o=H(),{t:s}=X();if(t===null)return e(Q,{title:s(`cameras.runtimeBlocks.detectionRuntime`,`Detection runtime`),children:[i($,{label:s(`cameras.runtimeBlocks.mode`,`Mode`),overridden:a,children:r??`—`}),i(zo,{children:s(`cameras.runtimeBlocks.detectionStageInactiveOrUnreachable`,`Detection stage inactive or unreachable`)})]});let c=n?.phase??t.phase,l=n?.actualFps??t.actualFps,u=n?.configuredFps??t.configuredFps,d=n?.avgInferenceTimeMs??t.avgInferenceMs,f=n?.queueDepth??t.queueDepth,p=bn(c,o),m=c===`active`&&l===0;return e(Q,{title:s(`cameras.runtimeBlocks.detectionRuntime`,`Detection runtime`),children:[e(`div`,{className:`flex items-center gap-1.5 mb-0.5`,children:[e(`span`,{className:`inline-flex items-center gap-1 rounded border px-1.5 py-px text-[10px] font-semibold uppercase tracking-wider ${p.badgeClass}`,children:[i(Kt,{phase:c,className:`h-2.5 w-2.5`}),p.label]}),n!==void 0&&i(`span`,{className:`text-[9px] text-foreground-subtle uppercase tracking-wider`,children:s(`common.live`)})]}),i($,{label:s(`cameras.runtimeBlocks.mode`,`Mode`),overridden:a,children:r??`—`}),e($,{label:`FPS`,children:[i(`span`,{className:m?`text-danger font-semibold`:``,children:l.toFixed(1)}),i(`span`,{className:`ml-1 text-foreground-subtle`,children:s(`cameras.runtimeBlocks.configuredFps`,{fps:u.toFixed(0)})})]}),e($,{label:s(`cameras.runtimeBlocks.inference`,`Inference`),children:[d.toFixed(0),` ms`,f>0&&i(`span`,{className:`ml-1 text-warning`,children:s(`cameras.runtimeBlocks.queue`,{depth:f})}),n!==void 0&&n.droppedFrames>0&&i(`span`,{className:`ml-1 text-warning`,children:s(`cameras.runtimeBlocks.drops`,{count:n.droppedFrames})})]}),e($,{label:s(`cameras.runtimeBlocks.engine`,`Engine`),children:[t.engine.backend,` · `,t.engine.device]}),e($,{label:s(`cameras.runtimeBlocks.provisioning`,`Provisioning`),children:[i(Ro,{tone:qo[t.provisioning.state]??`neutral`,children:t.provisioning.state}),t.provisioning.error!==void 0&&e(`span`,{className:`text-danger text-[10px]`,children:[` `,t.provisioning.error]})]})]})}function Yo({broker:t}){let{t:n}=X();return t===null?i(Q,{title:n(`cameras.runtimeBlocks.streamBroker`,`Stream broker`),children:i(zo,{children:n(`cameras.runtimeBlocks.brokerStageInactiveOrUnreachable`,`Broker stage inactive or unreachable`)})}):e(Q,{title:n(`cameras.runtimeBlocks.streamBroker`,`Stream broker`),children:[t.profiles.length===0?i(zo,{children:n(`cameras.runtimeBlocks.noBrokerProfiles`,`No broker profiles`)}):i(`div`,{className:`flex flex-col gap-1`,children:t.profiles.map(t=>{let r=t.status===`streaming`,a=r&&t.inFps===0;return e(`div`,{className:`flex items-center gap-2 text-[11px] font-mono tabular-nums min-w-0`,children:[i(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full shrink-0 ${a?`bg-danger`:r?`bg-success animate-pulse`:`bg-border`}`,title:t.status}),i(`span`,{className:`text-foreground w-10 shrink-0 truncate`,title:t.profile,children:t.profile}),e(`span`,{className:`text-foreground-subtle truncate`,children:[t.width,`×`,t.height,` `,t.codec]}),i(`span`,{className:`ml-auto shrink-0 ${a?`text-danger`:`text-foreground`}`,children:n(`cameras.runtimeBlocks.fpsValue`,{value:t.inFps===null?`—`:t.inFps.toFixed(0)})}),e(`span`,{className:`text-foreground-subtle shrink-0`,title:n(`cameras.runtimeBlocks.subscribers`,`Subscribers`),children:[`×`,t.subscribers]})]},t.profile)})}),e(`div`,{className:`mt-1.5 flex flex-wrap gap-1`,children:[i(Ro,{tone:t.webrtcSessions>0?`info`:`neutral`,children:n(`cameras.runtimeBlocks.webrtc`,{count:t.webrtcSessions})}),i(Ro,{tone:t.rtspRestream?`success`:`neutral`,children:t.rtspRestream?n(`cameras.runtimeBlocks.restreamOn`):n(`cameras.runtimeBlocks.restreamOff`)})]})]})}function Xo({decoder:e}){let{t}=X();return e===null?i(Q,{title:t(`cameras.runtimeBlocks.decoder`,`Decoder`),children:i(zo,{children:t(`cameras.runtimeBlocks.decoderStageInactiveOrUnreachable`,`Decoder stage inactive or unreachable`)})}):i(Q,{title:t(`cameras.runtimeBlocks.decoder`,`Decoder`),children:i($,{label:t(`cameras.runtimeBlocks.node`,`Node`),children:e.nodeId})})}s();var Zo=`pipeline-orchestrator`,Qo={healthy:`bg-success`,idle:`bg-warning`,error:`bg-danger`},$o={healthy:`pipeline.cameraPipelineCard.healthHealthy`,idle:`pipeline.cameraPipelineCard.healthIdle`,error:`pipeline.cameraPipelineCard.healthError`};function es({problems:t}){return i(`div`,{role:`alert`,className:`flex flex-col border-b border-border`,children:t.map(t=>e(`div`,{className:`flex items-start gap-2 px-4 py-1.5 text-[11px] font-medium ${t.severity===`error`?`bg-danger/10 text-danger`:`bg-warning/10 text-warning`}`,children:[i(j,{className:`h-3.5 w-3.5 shrink-0 mt-px`}),i(`span`,{className:`min-w-0`,children:t.message})]},t.code))})}function ts({deviceId:t,name:r,online:a,status:o,live:s,onlineNodes:c}){let{t:u}=X(),d=l(),{data:f}=ht({addonId:Zo,deviceId:t,nodeId:`hub`},{staleTime:3e4}),{data:p}=_t({deviceId:t},{staleTime:3e4}),m=n(()=>Kn(f),[f]),h=n(()=>p===void 0?void 0:qn(p.steps),[p]),g=n(()=>o===void 0?[]:An(o),[o]),_=()=>{d.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCameraStatuses`]]}),d.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineAssignments`]]})},v=Xe({onSuccess:_}),y=Yt({onSuccess:_}),b=e=>{e===`auto`?y.mutate({deviceId:t}):v.mutate({deviceId:t,agentNodeId:e})},x=o===void 0?`idle`:Mn(o),S=g.some(e=>e.severity===`error`),C=g.length>0,w=S?`border-danger/50`:C?`border-warning/40`:`border-border`;return e(`article`,{"aria-label":u(`cameras.cameraPipelineCard.pipelineStatus`,`{{name}} pipeline status`,{name:r}),className:`rounded-lg border ${w} bg-background overflow-hidden`,children:[e(`header`,{className:`flex items-center gap-2.5 px-4 py-2.5 border-b border-border bg-surface/50 min-w-0`,children:[i(`span`,{className:`inline-block h-2 w-2 rounded-full shrink-0 ${S?`bg-danger`:Qo[x]}`,title:S?u(`common.error`,`Error`):u($o[x]),"aria-label":S?u(`common.error`,`Error`):u($o[x]),role:`img`}),i(`h3`,{className:`text-[13px] font-semibold text-foreground truncate`,title:r,children:r}),e(`span`,{className:`text-[10px] text-foreground-subtle shrink-0`,children:[`#`,t]}),!a&&i(Ro,{tone:`danger`,children:u(`common.offline`)}),e(`span`,{className:`ml-auto flex items-center gap-1.5 shrink-0`,children:[m.detectionMode!==null&&i(Ro,{tone:m.detectionMode===`disabled`?`warning`:m.detectionMode===`always-on`?`info`:`neutral`,title:u(`cameras.cameraPipelineCard.objectDetectionMode`,`Object detection mode`),children:m.detectionMode===`disabled`?u(`cameras.cameraPipelineCard.detectionOff`,`detection off`):m.detectionMode}),o?.recording!=null&&(o.recording.active?e(Ro,{tone:`danger`,title:u(`cameras.cameraPipelineCard.recording`,`Recording ({{mode}})`,{mode:o.recording.mode}),children:[i(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full bg-danger animate-pulse`}),`REC`]}):o.recording.mode!==`off`&&i(Ro,{tone:`neutral`,title:u(`cameras.cameraPipelineCard.recordingMode`,`Recording mode`),children:u(`pipeline.cameraPipelineCard.recMode`,{mode:o.recording.mode})}))]})]}),g.length>0&&i(es,{problems:g}),o===void 0?i(`div`,{className:`px-4 py-5 text-[11px] text-foreground-subtle italic`,children:u(`cameras.cameraPipelineCard.noPipelineStatusYetThe`,`No pipeline status yet — the orchestrator has not composed a snapshot for this camera.`)}):e(`div`,{className:`grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-px bg-border`,children:[i(Vo,{assignment:o.assignment,settings:m,onlineNodes:c,pinPending:v.isPending||y.isPending,onDetectionPinChange:b}),i(Jo,{detection:o.detection,live:s,detectionMode:m.detectionMode,modeOverridden:m.overriddenKeys.has(`detectionMode`)}),i(Ko,{steps:h,audioModelId:p?.audio?.modelId??null,audioEnabled:o.audio?.enabled??p?.audio?.enabled??null,audioMode:m.audioMode}),i(Go,{streams:o.source.streams,brokerProfiles:o.broker?.profiles,settings:m,motionEnabled:o.motion?.enabled??null,motionFpsLive:o.motion?.fps??null,cameraSensors:o.cameraSensors}),i(Yo,{broker:o.broker}),i(Xo,{decoder:o.decoder})]})]})}s();var ns=5e3,rs=1e4,is=5e3;function as(e){let t=l(),{data:r,isLoading:i}=Tn(),{data:s,isLoading:c}=rt({},{refetchInterval:ns}),{nodes:u}=J();a(()=>{e!==0&&t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCameraStatuses`]]})},[e,t]);let[d,f]=o(new Map);Ft(we.PipelineCameraMetricsSnapshot,e=>{let t=e.data;typeof t.deviceId==`number`&&f(e=>{let n=new Map(e);return n.set(t.deviceId,{phase:t.metrics.phase,configuredFps:t.metrics.configuredFps,actualFps:t.metrics.actualFps,queueDepth:t.metrics.queueDepth,avgInferenceTimeMs:t.metrics.avgInferenceTimeMs,droppedFrames:t.metrics.droppedFrames,timestamp:t.timestamp}),n})}),a(()=>{if(d.size===0)return;let e=setInterval(()=>{f(e=>{let t=Date.now()-rs,n=!1,r=new Map(e);for(let[i,a]of e)a.timestamp<t&&(r.delete(i),n=!0);return n?r:e})},is);return()=>clearInterval(e)},[d.size]);let p=n(()=>{let e=new Map;for(let t of s??[])e.set(t.deviceId,t);return e},[s]);return{rows:n(()=>(r??[]).filter(e=>e.isCamera).map(e=>({deviceId:e.id,name:e.name,online:e.online,status:p.get(e.id)})).sort((e,t)=>e.name.localeCompare(t.name)),[r,p]),liveMetrics:d,onlineNodes:n(()=>(u??[]).filter(e=>e.isOnline).map(e=>({id:e.id,name:e.name})),[u]),isLoading:i||c}}s();function os({refreshToken:t}){let{t:r}=X(),{rows:a,liveMetrics:o,onlineNodes:s,isLoading:c}=as(t),l=n(()=>[...a.map(e=>{let t=e.status===void 0?[]:An(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),[a]),u=n(()=>{let e=0,t=0;for(let n of l)(n.errorCount>0||n.warningCount>0)&&(t+=1),(o.get(n.row.deviceId)?.phase??n.row.status?.detection?.phase)===`active`&&(e+=1);return{total:l.length,active:e,issues:t}},[l,o]);return c&&a.length===0?i(`div`,{className:`flex items-center justify-center h-full text-sm text-foreground-subtle`,children:r(`cameras.camerasOverview.loadingCameraPipelines`,`Loading camera pipelines…`)}):a.length===0?i(`div`,{className:`flex items-center justify-center h-full text-sm text-foreground-subtle`,children:r(`cameras.camerasOverview.noCamerasFound`,`No cameras found`)}):i(`div`,{className:`h-full overflow-y-auto`,children:e(`div`,{className:`max-w-6xl mx-auto flex flex-col gap-3 px-4 py-4`,children:[e(`div`,{className:`flex items-center gap-4 text-[11px] text-foreground-subtle px-1`,children:[i(`span`,{children:i(En,{i18nKey:`pipeline.camerasOverview.camerasTotal`,values:{count:u.total},components:{b:i(`span`,{className:`font-semibold text-foreground`})}})}),i(`span`,{children:i(En,{i18nKey:`pipeline.camerasOverview.activelyInferring`,values:{count:u.active},components:{b:i(`span`,{className:`font-semibold text-success`})}})}),e(`span`,{children:[i(`span`,{className:`font-semibold ${u.issues>0?`text-danger`:`text-foreground`}`,children:u.issues}),` `,r(`cameras.camerasOverview.withIssues`,`with issues`)]}),i(`span`,{className:`ml-auto hidden sm:inline text-[10px]`,children:r(`cameras.camerasOverview.polledEvery5SDetection`,`polled every 5 s · detection metrics live at 1 Hz`)})]}),l.map(({row:e})=>i(ts,{deviceId:e.deviceId,name:e.name,online:e.online,status:e.status,live:o.get(e.deviceId),onlineNodes:s},e.deviceId))]})})}s();var ss=`__cluster__`;function cs(e){return e===`cameras`?`cameras`:`nodes`}function ls({viewMode:t,onNodes:n,onCameras:r}){let{t:a}=X();return e(`div`,{className:`flex items-center gap-1 rounded-lg border border-border bg-surface p-0.5`,role:`tablist`,"aria-label":a(`pipeline.pipelineView`,`Pipeline view`),children:[i(`button`,{type:`button`,role:`tab`,"aria-selected":t===`nodes`,onClick:n,className:[`rounded-md px-3 py-1 text-[11px] font-medium transition-colors`,t===`nodes`?`bg-background text-foreground shadow-sm`:`text-foreground-subtle hover:text-foreground`].join(` `),children:a(`pipeline.nodes`,`Nodes`)}),i(`button`,{type:`button`,role:`tab`,"aria-selected":t===`cameras`,onClick:r,className:[`rounded-md px-3 py-1 text-[11px] font-medium transition-colors`,t===`cameras`?`bg-background text-foreground shadow-sm`:`text-foreground-subtle hover:text-foreground`].join(` `),children:a(`pipeline.cameras`,`Cameras`)})]})}function us(){let{t}=X(),[n,r]=Dn(),s=cs(n.get(`view`)),c=n.get(`node`)??`__cluster__`,[l,u]=o(0),[f,p]=o(!1);return a(()=>{s===`nodes`&&!n.get(`node`)&&r(e=>{let t=new URLSearchParams(e);return t.set(`view`,`nodes`),t.set(`node`,ss),t},{replace:!0})},[s,n,r]),e(pn,{icon:ke,title:t(`pipeline.pipeline`,`Pipeline`),subtitle:t(`pipeline.detectionPlacementLoadAndPer`,`Detection placement, load and per-camera runtime across the cluster.`),actions:e(q,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>u(e=>e+1),title:t(`common.refresh`,`Refresh`),children:[i(k,{className:`h-3.5 w-3.5`}),t(`common.refresh`,`Refresh`)]}),nav:i(ls,{viewMode:s,onNodes:()=>{r({view:`nodes`,node:c},{replace:!0})},onCameras:()=>{r({view:`cameras`},{replace:!0})}}),className:`flex h-full min-h-0 flex-col overflow-hidden`,children:[s===`nodes`&&e(q,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>p(e=>!e),"aria-expanded":f,className:`flex w-full shrink-0 justify-between border-b border-border md:hidden`,children:[i(`span`,{children:t(f?`pipeline.hideNodeList`:`pipeline.showNodeList`)}),i(Oe,{className:[`h-4 w-4 transition-transform`,f?`rotate-180`:``].join(` `)})]}),i(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden md:flex-row`,children:s===`nodes`?e(d,{children:[i(`aside`,{className:[f?`block`:`hidden`,`md:block w-full md:w-72 shrink-0 border-b border-border md:border-b-0 md:border-r`,`max-h-[60vh] overflow-y-auto md:max-h-none`].join(` `),children:i(hr,{selectedNodeId:c,onSelect:e=>{r({view:`nodes`,node:e},{replace:!0}),p(!1)},refreshToken:l})}),i(`section`,{className:`min-h-0 flex-1 overflow-hidden`,children:c===`__cluster__`?i(Fo,{refreshToken:l}):i(Yi,{nodeId:c,refreshToken:l})})]}):i(`section`,{className:`min-h-0 flex-1 overflow-hidden`,children:i(os,{refreshToken:l})})})]})}export{us as PipelinePage};
@@ -1,2 +0,0 @@
1
- import{C as e,K as t,S as n,V as r,Y as i,et as a}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Cr as o,Nn as s,Pn as c,Qa as l,Tt as u,_i as d,ct as f,ft as p,oo as m,tn as h,ut as g,zr as _}from"./player-overlays-fpbPSPqT.js";import{Xs as v}from"./client-Cng2SeYA.js";import{a as y,l as b}from"./terminal-DZ5OZpgC.js";import{Br as x,Da as S,Dr as C,Gi as w,Ji as T,Or as E,Q as D,Qi as ee,Qp as O,Sp as te,Tr as k,Ui as A,Wi as j,Yi as M,Z as N,Zi as P,Zs as ne,ai as re,ci as F,gi as I,ka as L,mp as R,mt as z,nt as B,qi as V,rt as H,si as ie,tp as ae,wa as oe,zr as U}from"./src-eL0OacoB.js";import{t as W}from"./i18n--GTAj4mB.js";import{t as G}from"./useTranslation-BJr-n0es.js";import{F as se,n as K,vi as ce}from"./index-DbXFHmBJ.js";import{n as le,r as q,t as J}from"./AccessSection-CNgvvC6Q.js";a();var ue={active:`access.credentialColumns.statusActive`,expired:`access.credentialColumns.statusExpired`,revoked:`access.credentialColumns.statusRevoked`,current:`access.credentialColumns.statusCurrent`};function Y(e){return W.t(ue[e])}var de={active:`success`,expired:`warning`,revoked:`default`,current:`info`},fe={current:0,active:1,expired:2,revoked:3};function X(e,t){if(e===null)return t;let n=new Date(e);return Number.isNaN(n.getTime())?`—`:n.toLocaleString()}function Z({status:e}){return n(L,{variant:de[e],className:`text-[10px]`,children:Y(e)})}function pe({row:t,action:r}){if(!r.isAvailable(t))return null;let i=r.icon,a=r.busyId===t.id;return e(R,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>r.onRun(t),disabled:r.disabled,"aria-label":W.t(`access.credentialColumns.actionOn`,{action:r.label,name:t.name}),className:r.tone===`neutral`?void 0:`text-danger hover:bg-danger/10`,children:[a?n(_,{className:`h-3 w-3 animate-spin`,"aria-hidden":!0}):n(i,{className:`h-3 w-3`,"aria-hidden":!0}),r.label]})}function me(t){return[{key:`name`,header:W.t(`access.credentialColumns.name`,`Name`),sortValue:e=>e.name.toLowerCase(),render:t=>e(`div`,{className:`min-w-0 max-w-[18rem]`,children:[n(`div`,{className:`truncate font-medium text-foreground`,title:t.name,children:t.name}),t.detail!==null&&n(`div`,{className:`truncate font-mono text-[10px] text-foreground-subtle`,title:t.detail,children:t.detail})]})},t.hideOwner?null:{key:`owner`,header:W.t(`access.credentialColumns.owner`,`Owner`),sortValue:e=>e.ownerName.toLowerCase(),render:e=>e.ownerName},{key:`kind`,header:W.t(`access.credentialColumns.kindScope`,`Kind / scope`),sortValue:e=>e.kind.toLowerCase(),nowrap:!1,render:t=>e(`div`,{className:`min-w-[8rem] max-w-[16rem]`,children:[n(`div`,{className:`text-foreground`,children:t.kind}),t.scope!==null&&n(`div`,{className:`line-clamp-2 text-[10px] text-foreground-subtle`,title:t.scope,children:t.scope})]})},{key:`status`,header:W.t(`access.credentialColumns.status`,`Status`),sortValue:e=>fe[e.status],render:e=>n(Z,{status:e.status})},{key:`created`,header:W.t(`access.credentialColumns.created`,`Created`),sortValue:e=>e.createdAt,render:e=>n(`span`,{className:`text-foreground-subtle`,children:X(e.createdAt,`—`)})},{key:`lastUsed`,header:W.t(`access.credentialColumns.lastUsed`,`Last used`),sortValue:e=>e.lastUsedAt,render:e=>n(`span`,{className:`text-foreground-subtle`,children:X(e.lastUsedAt,W.t(`access.credentialColumns.never`))})},{key:`expires`,header:W.t(`access.credentialColumns.expires`,`Expires`),sortValue:e=>e.expiresAt,render:e=>n(`span`,{className:`text-foreground-subtle`,children:X(e.expiresAt,t.expiresNone)})},t.action===null?null:{key:`actions`,header:``,align:`right`,notSortableReason:W.t(`access.credentialColumns.actionsHeader`),render:e=>n(`div`,{className:`flex items-center justify-end gap-1`,children:[...t.extraActions??[],t.action].map(t=>t===null?null:n(pe,{row:e,action:t},t.label))})}].filter(e=>e!==null)}var he=6,ge={"current-session":`access.bulk.skipCurrentSession`,"not-active":`access.bulk.skipNotActive`};function _e(e){let t=ge[e];return t===void 0?e:W.t(t)}function ve(e,t){return W.t(t.key,{count:e})}function Q(e,t){return W.t(`access.bulk.countOf`,{count:e,noun:ve(e,t)})}function ye(e){let t=new Map;for(let n of e)t.set(n.status,(t.get(n.status)??0)+1);return[...t.entries()].map(([e,t])=>W.t(`access.bulk.statusCount`,{count:t,status:Y(e).toLowerCase()})).join(`, `)}function be(e,t){let n=e.slice(0,he).map(e=>`• ${e.name} — ${e.ownerName}`),r=e.length>he?[W.t(`access.bulk.previewMore`,{count:e.length-he})]:[];return[W.t(`access.bulk.previewIntro`,{what:Q(e.length,t),breakdown:ye(e)}),``,...n,...r].join(`
2
- `)}async function xe(e,t,n){let r=String(t.length),i=await e({title:W.t(`access.bulk.confirmTitle`,{what:Q(t.length,n)}),message:be(t,n),label:W.t(`access.bulk.confirmLabel`,{expected:r}),placeholder:r,confirmLabel:W.t(`access.bulk.confirmButton`,{expected:r}),variant:`danger`,validate:e=>e.trim()===r?null:W.t(`access.bulk.confirmMismatch`,{expected:r,noun:ve(2,n)})});return i!==null&&i.trim()===r}function Se(e,t){let n=g(),r=O.auth.revokeCredentials.useMutation(),[a,o]=i(null);return{run:async i=>{if(i.length===0||!await xe(n,i,e))return!1;o(null);try{let t=await r.mutateAsync({ids:i.map(e=>e.id),confirmCount:i.length}),n=t.skipped.map(e=>_e(e.reason));return o({tone:`success`,message:n.length>0?W.t(`access.bulk.revokedSkipped`,{what:Q(t.revoked.length,e),count:n.length,reasons:[...new Set(n)].join(`, `)}):W.t(`access.bulk.revoked`,{what:Q(t.revoked.length,e)})}),!0}catch(e){return o({tone:`danger`,message:W.t(`access.bulk.revokeFailed`,{error:e instanceof Error?e.message:W.t(`access.bulk.requestFailed`)})}),!1}finally{t()}},busy:r.isPending,outcome:a,dismiss:()=>o(null)}}function Ce(e,t,n){let r=g(),[a,o]=i(!1),[s,c]=i(null);return{run:async i=>{if(i.length===0||!await xe(r,i,e))return!1;c(null),o(!0);let a=[],s=0;for(let e of i)try{await t(e.id),s+=1}catch(t){a.push(`${e.name}: ${t instanceof Error?t.message:W.t(`access.bulk.requestFailed`)}`)}return o(!1),n(),a.length===0?(c({tone:`success`,message:W.t(`access.bulk.revoked`,{what:Q(s,e)})}),!0):(c({tone:`danger`,message:W.t(a.length>3?`access.bulk.eachPartialMore`:`access.bulk.eachPartial`,{what:Q(s,e),count:a.length,details:a.slice(0,3).join(`; `)})}),s>0)},busy:a,outcome:s,dismiss:()=>c(null)}}a();var we={searchText:e=>[e.name,e.detail??``,e.ownerName,e.kind,e.scope??``],facetGroups:[{id:`status`,value:e=>e.status},{id:`owner`,value:e=>e.ownerName},{id:`kind`,value:e=>e.kind}]},Te={status:`access.credentialTable.groupStatus`,owner:`access.credentialTable.groupOwner`,kind:`access.credentialTable.groupKind`},Ee=e=>e.status!==`current`,De=[`active`,`current`];function Oe({rows:r,label:a,isLoading:o,loadError:s,emptyText:c,hideOwner:l=!1,expiresNone:u,action:d,extraActions:f,bulk:p,defaultStatus:m=De}){let{t:h}=G(),[g]=i(()=>m.length===0?{search:``,facets:[]}:{search:``,facets:[],groups:{status:[...m]}}),v=k(r,we,g),[y,b]=i(()=>new Set),w=u??h(`access.credentialColumns.never`),T=t(()=>me({hideOwner:l,expiresNone:w,action:d??null,...f===void 0?{}:{extraActions:f}}),[l,w,d,f,h]),E=t(()=>p===void 0?()=>!1:e=>Ee(e)&&p.isSelectable(e),[p]),D=t(()=>v.rows.filter(e=>y.has(e.id)&&E(e)),[v.rows,y,E]);return o?e(`div`,{className:`flex items-center gap-2 py-4 text-xs text-foreground-subtle`,children:[n(_,{className:`h-3.5 w-3.5 animate-spin`,"aria-hidden":!0}),h(`access.credentialTable.loading`,{label:a})]}):s===null?e(`div`,{className:`space-y-3`,children:[n(C,{state:v.state,facets:v.facets,groups:v.groups.filter(e=>!(l&&e.id===`owner`)).map(e=>({...e,label:Te[e.id]===void 0?e.id:h(Te[e.id]),...e.id===`status`?{facetLabel:e=>Y(e)}:{}})),labels:{searchPlaceholder:h(`access.credentialTable.searchPlaceholder`,{label:a}),searchLabel:h(`access.credentialTable.searchLabel`,{label:a}),facetsLabel:h(`access.credentialTable.facetsLabel`,{label:a}),clearLabel:h(`access.credentialTable.clearFilters`)},onSearch:v.setSearch,onToggleFacet:v.toggleFacet,onToggleGroupFacet:v.toggleGroupFacet,onClear:v.clear}),p!==void 0&&n(ke,{bulk:p,shown:v.rows.filter(E),targets:D,onSelect:b}),n(U,{columns:T,rows:v.rows,rowKey:e=>e.id,minWidthPx:l?760:860,maxBodyHeight:x,defaultSort:{columnKey:`created`,dir:`desc`},pageSize:25,paginationLabels:{navLabel:h(`access.credentialTable.pagesLabel`,{label:a}),previous:h(`access.credentialTable.previousPage`),next:h(`access.credentialTable.nextPage`),range:(e,t,n)=>h(`access.credentialTable.range`,{from:e,to:t,total:n})},emptyMessage:v.active?h(`access.credentialTable.noMatchTheFilters`,`No {{label}} match the filters.`,{label:a}):c,rowClassName:e=>e.status===`revoked`||e.status===`expired`?`opacity-70`:void 0,...p===void 0?{}:{selection:{selected:y,onChange:b,isSelectable:E,rowLabel:e=>h(`access.credentialTable.rowLabel`,{name:e.name,owner:e.ownerName}),pageLabel:h(`access.credentialTable.pageLabel`,{noun:ve(1,p.noun)})}}})]}):n(S,{title:h(`access.credentialTable.couldNotLoad`,`Could not load {{label}}`,{label:a}),message:s})}function ke({bulk:t,shown:r,targets:i,onSelect:a}){let{t:o}=G(),{revoke:s,noun:c}=t,l=(t.quickSelect??[]).map(e=>({...e,rows:r.filter(e.match)})).filter(e=>e.rows.length>0),d=async()=>{await s.run(i)&&a(new Set)};return e(`div`,{className:`flex flex-wrap items-center gap-2`,"data-testid":`bulk-bar`,children:[r.length>0&&n(R,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>a(new Set(r.map(e=>e.id))),children:o(`access.credentialTable.selectAllShown`,{count:r.length})}),l.map(t=>e(R,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>a(new Set(t.rows.map(e=>e.id))),children:[t.label,` (`,String(t.rows.length),`)`]},t.label)),i.length>0&&e(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[n(`span`,{className:`text-[11px] tabular-nums text-foreground`,"aria-live":`polite`,children:o(`access.credentialTable.selectedLabel`,{what:Q(i.length,c)})}),e(R,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>a(new Set),children:[n(u,{className:`h-3 w-3`,"aria-hidden":!0}),o(`access.credentialTable.clearSelection`,`Clear selection`)]}),e(R,{type:`button`,variant:`danger`,size:`sm`,disabled:s.busy,onClick:()=>void d(),children:[s.busy?n(_,{className:`h-3 w-3 animate-spin`,"aria-hidden":!0}):n(h,{className:`h-3 w-3`,"aria-hidden":!0}),o(`access.credentialTable.revoke`,{what:Q(i.length,c)})]})]})]})}var Ae=(e,t)=>t===null?`—`:e.get(t)??t;function je(e,t){return e!=null&&e<=t?`expired`:`active`}function Me(e,t,n){return{id:e.id,name:n.client(e.client),detail:e.ip,ownerId:e.userId,ownerName:Ae(t,e.userId),kind:n.method(e.method),scope:null,status:e.current?`current`:`active`,createdAt:e.createdAt,lastUsedAt:e.lastUsedAt,expiresAt:e.expiresAt}}function Ne(e,t){return{id:e.id,name:e.integrationId,detail:null,ownerId:e.userId,ownerName:e.username,kind:e.integrationId,scope:t,status:e.revokedAt===null?`active`:`revoked`,createdAt:e.createdAt,lastUsedAt:e.lastUsedAt,expiresAt:null}}var Pe=`All permissions`,Fe=`View link`,Ie=`Scoped`,Le={"grid-view":`Grid`,"events-view":`Events`};function Re(e,t){return e.map(e=>t.get(e)??`#${String(e)}`).join(`, `)}function ze(e){return e!==`*`&&e.type===`share-view`&&`grant`in e}function Be(e,t,n){return e===`*`?Pe:ze(e)?`${`${Le[e.grant.kind]} view${e.grant.talk===!0?` + talk`:``}`}: ${Re(e.grant.deviceIds,t)}`:n(e)}function Ve(e){return e.includes(`*`)?Pe:e.some(ze)?Fe:Ie}function He(e,t,n,r){return{id:e.id,name:e.label,detail:null,ownerId:e.subjectId,ownerName:Ae(t,e.subjectId),kind:Ve(e.scopes),scope:n,status:e.revokedAt===null?je(e.expiresAt,r):`revoked`,createdAt:e.createdAt,lastUsedAt:e.lastUsedAt,expiresAt:e.expiresAt}}function Ue(e){return`${e.provider}\u0000${e.subject}`}function We(e,t){return{id:Ue(e),name:e.label??e.subject,detail:e.issuer,ownerId:e.userId,ownerName:Ae(t,e.userId),kind:e.provider,scope:null,status:`active`,createdAt:e.linkedAt,lastUsedAt:null,expiresAt:null}}var Ge=40,Ke=[{test:/Electron\//,name:`CamStack desktop`},{test:/Edg(e|A|iOS)?\//,name:`Edge`},{test:/OPR\/|Opera/,name:`Opera`},{test:/Firefox\/|FxiOS\//,name:`Firefox`},{test:/Chrome\/|CriOS\//,name:`Chrome`},{test:/Version\/[\d.]+.*Safari\//,name:`Safari`}],qe=[{test:/iPhone/,name:`iPhone`},{test:/iPad/,name:`iPad`},{test:/Android/,name:`Android`},{test:/Mac OS X|Macintosh/,name:`macOS`},{test:/Windows/,name:`Windows`},{test:/CrOS/,name:`ChromeOS`},{test:/Linux/,name:`Linux`}],Je=[{test:/CFNetwork\/.*Darwin\//,name:`CamStack app on iOS`},{test:/^okhttp\//i,name:`CamStack app on Android`},{test:/^(node|undici)\b/i,name:`Script (Node.js)`},{test:/^curl\//i,name:`curl`}];function Ye(e,t){return e.find(e=>e.test.test(t))?.name??null}function Xe(e){return e.length<=Ge?e:`${e.slice(0,Ge)}…`}function Ze(e){if(e===null||e.trim().length===0)return{label:W.t(`helpers.sessionClient.unknownDevice`),raw:null};let t=e.trim(),n=Ye(Je,t);if(n!==null)return{label:n,raw:t};let r=Ye(Ke,t),i=Ye(qe,t);return r!==null&&i!==null?{label:W.t(`helpers.sessionClient.browserOnSystem`,{browser:r,system:i}),raw:t}:r===null?{label:Xe(t),raw:t}:{label:r,raw:t}}var Qe={password:`helpers.sessionClient.method.password`,passkey:`helpers.sessionClient.method.passkey`,sso:`helpers.sessionClient.method.sso`,handoff:`helpers.sessionClient.method.handoff`,"cli-approval":`helpers.sessionClient.method.cliApproval`,exchange:`helpers.sessionClient.method.exchange`};function $e(e){let t=Qe[e];return t===void 0?e:W.t(t)}function et(e){if(e==null)return`—`;let t=new Date(e);return Number.isNaN(t.getTime())?`—`:t.toLocaleString()}function tt({token:t,label:r,onClose:i}){let{t:a}=G();return n(A,{open:!0,onOpenChange:e=>!e&&i(),children:e(w,{width:`md`,scroll:`body`,children:[n(T,{children:n(M,{children:a(`auth.tokenModals.token`,`Token: {{label}}`,{label:r})})}),e(j,{className:`space-y-3`,children:[n(`div`,{className:`rounded-md border border-warning/30 bg-warning/10 px-3 py-2 text-xs text-warning`,children:a(`auth.tokenModals.copyThisTokenNowOnce`,`Copy this token now. Once you close this dialog the secret cannot be displayed again.`)}),n(`div`,{className:`select-all break-all rounded-md border border-border bg-background p-2 font-mono text-[11px] text-foreground`,children:t})]}),e(V,{children:[n(E,{value:t,label:a(`common.copy`,`Copy`),srLabel:`token`}),n(R,{type:`button`,variant:`primary`,size:`sm`,onClick:i,children:a(`auth.tokenModals.done`,`Done`)})]})]})})}var nt={token:`newToken`,scoped:`newScoped`,admin:`newAdmin`};a();var rt=80,$=86400,it=[{value:`1`,seconds:$},{value:`7`,seconds:7*$},{value:`30`,seconds:30*$},{value:`90`,seconds:90*$},{value:`never`,seconds:`never`}],at=[v.Camera],ot=64,st={type:`capability`,target:``,access:[`view`,`create`]};function ct({open:a,users:o,onClose:u,onSubmit:f,submitting:h,formError:g,awaitingProof:v}){let{t:y}=G(),x=m(),{user:S}=se(),C=S?.isAdmin===!0,w=C?null:S?.scopes??[],[T,E]=i(`scopes`),[O,k]=i(S?.id??``),[A,j]=i(``),[M,ne]=i([st]),[L,z]=i([]),[B,V]=i(`grid-view`),[ae,U]=i(!1),[W,K]=i(`30`);r(()=>{a||(E(`scopes`),k(S?.id??``),j(``),ne([st]),z([]),V(`grid-view`),U(!1),K(`30`))},[a,S?.id]),r(()=>{T!==`view-link`&&W===`never`&&K(`30`)},[T,W]);let le=t(()=>it.filter(e=>e.seconds!==`never`||T===`view-link`).map(e=>({value:e.value,label:e.seconds===`never`?y(`access.createTokenModal.never`,`Never (until revoked)`):y(`access.createTokenModal.days`,{count:Number(e.value)})})),[T,y]),q=A.trim(),J=T===`scopes`?D(M,x):null,ue=[...L],Y=it.find(e=>e.value===W)?.seconds??30*$,de=()=>T===`all`?[`*`]:T===`view-link`?[{type:`share-view`,grant:{kind:B,deviceIds:ue,...ae?{talk:!0}:{}}}]:M,fe=q.length>0&&q.length<=rt&&!h&&!v&&(T===`all`?C:T===`view-link`?ue.length>0:M.length>0&&J===null),X=()=>{if(!fe)return;let e=C&&T!==`all`&&O!==``&&O!==S?.id;f({scopes:de(),expiresIn:Y,label:q,...e?{subjectId:O}:{}})},Z=T===`all`,pe=Z?c:s;return n(H,{open:a,onClose:u,title:y(`access.createTokenModal.createToken`,`Create token`),icon:Z?c:b,error:g,width:`md`,testId:`create-token-dialog`,footer:e(R,{type:`button`,variant:Z?`danger`:`primary`,size:`sm`,onClick:X,disabled:!fe,"data-testid":`create-token-submit`,children:[h||v?n(_,{className:`h-3.5 w-3.5 animate-spin`,"aria-hidden":!0}):n(pe,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),y(`access.createTokenModal.issueToken`,`Issue token`)]}),children:e(`div`,{className:`space-y-3`,children:[e(`div`,{className:`space-y-1`,children:[n(I,{children:y(`access.createTokenModal.whatItMayDo`,`What it may do`)}),n(re,{appearance:`pills`,value:T,onValueChange:e=>{(e===`scopes`||e===`view-link`||e===`all`)&&E(e)},children:e(ie,{"aria-label":y(`access.createTokenModal.whatItMayDo`,`What it may do`),children:[e(F,{value:`scopes`,"data-testid":`token-reach-scopes`,children:[n(s,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),y(`access.createTokenModal.reachScopes`,`Scopes`)]}),e(F,{value:`view-link`,"data-testid":`token-reach-view-link`,children:[n(d,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),y(`access.createTokenModal.reachViewLink`,`View link`)]}),C?e(F,{value:`all`,"data-testid":`token-reach-all`,children:[n(c,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),y(`access.createTokenModal.reachAll`,`All permissions`)]}):null]})})]}),Z?n(`div`,{className:`space-y-1 rounded-md border border-danger/30 bg-danger/5 px-3 py-2 text-[11px] leading-relaxed text-foreground`,"data-testid":`admin-token-warning`,children:n(`p`,{children:n(ce,{i18nKey:`auth.adminTokenNoticeShort`,components:{strong:n(`strong`,{})}})})}):null,C&&T!==`all`&&o.length>1?e(`div`,{className:`space-y-1`,children:[n(I,{htmlFor:`token-user`,children:y(`access.createTokenModal.onBehalfOfUser`,`On behalf of user`)}),n(p,{id:`token-user`,value:O,onChange:e=>k(e.target.value),options:o.map(e=>({value:e.id,label:e.username}))})]}):null,e(`div`,{className:`space-y-1`,children:[n(I,{htmlFor:`token-name`,children:y(`access.createTokenModal.label`,`Label`)}),n(te,{id:`token-name`,value:A,maxLength:rt,required:!0,onChange:e=>j(e.target.value),placeholder:T===`view-link`?`kitchen-wall`:`nightly-backup`,autoFocus:!0})]}),T===`scopes`?e(`div`,{className:`space-y-1`,children:[n(I,{children:y(`access.createTokenModal.scopes`,`Scopes`)}),n(N,{value:M,onChange:ne,clampToParent:w}),J&&n(`p`,{className:`text-[10px] text-danger`,children:J}),n(`p`,{className:`text-[10px] text-foreground-subtle`,children:y(`access.createTokenModal.eachScopePicksACap`,`Each scope picks a (cap or addon) target + one or more access flavours. The token can access ONLY what's listed.`)})]}):null,T===`view-link`?e(`div`,{className:`space-y-2`,"data-testid":`token-view-link`,children:[e(`div`,{className:`space-y-1`,children:[n(I,{htmlFor:`token-view-cameras`,children:y(`access.createTokenModal.cameras`,`Cameras`)}),n(oe,{id:`token-view-cameras`,multiple:!0,pick:`device`,noun:`camera`,fixedTypes:at,maxItems:ot,recentKey:`token-view-cameras`,testId:`token-view-cameras`,value:ee(L),onChange:e=>z(P(e))})]}),e(`div`,{className:`space-y-1`,children:[n(I,{htmlFor:`token-view-kind`,children:y(`access.createTokenModal.viewKind`,`Shows`)}),n(p,{id:`token-view-kind`,value:B,onChange:e=>V(e.target.value===`events-view`?`events-view`:`grid-view`),options:[{value:`grid-view`,label:y(`access.createTokenModal.viewGrid`,`Live grid`)},{value:`events-view`,label:y(`access.createTokenModal.viewEvents`,`Events`)}]})]}),B===`grid-view`?e(`label`,{className:`flex items-start gap-2 text-sm text-foreground`,children:[n(l,{className:`mt-0.5`,checked:ae,onChange:e=>U(e.target.checked),"data-testid":`token-view-talk`}),n(`span`,{children:y(`access.createTokenModal.talk`,`Allow talk-back on these cameras`)})]}):null]}):null,e(`div`,{className:`space-y-1`,children:[n(I,{htmlFor:`token-lifetime`,children:y(`access.createTokenModal.expires`,`Expires after`)}),n(p,{id:`token-lifetime`,value:W,onChange:e=>K(e.target.value),options:le})]})]})})}a();var lt={key:`access.nouns.token`};function ut(e){return typeof e==`object`&&!!e&&`kind`in e}function dt(e,t){let n=e.access===void 0?``:` [${e.access.join(`, `)}]`;return e.type===`device`?`device:[${ut(e.selector)?z(e.selector,t):`?`}]${n}`:e.type===`addon-routes`?`${t(`access.tokensSection.everyAddonRoutes`,`every addon's routes`)}${n}`:`${e.type}:${e.target??``}${n}`}function ft({headerOwnsCreate:a=!1,createRequested:o=!1,onCreateConsumed:s,ownOnly:c=!1}){let{t:l}=G(),u=m(),{user:d}=se(),p=f(),g=O.useUtils(),_=q(),{data:v}=ae(),y=t(()=>v??[],[v]),{data:x}=ne({}),S=t(()=>{let e=new Map;for(let t of x??[])e.set(t.id,t.name);return e},[x]),C=O.auth.listTokens.useQuery(void 0),{requestProof:w,dialog:T}=K(`Creating a token with all permissions`),{state:E,openNew:D,close:ee}=B({newKey:nt.token}),[te,k]=i(null),[A,j]=i(null),[M,N]=i(!1),[P,re]=i(null),[F,I]=i(null);r(()=>{o&&(D(),s?.())},[o,D,s]);let L=()=>{g.auth.listTokens.invalidate(),g.auth.listAuthAudit.invalidate()},z=O.auth.mintToken.useMutation({onSuccess:({token:e,record:t})=>{L(),ee(),j(null),N(!1),re({token:e,label:t.label})},onError:e=>{j(`Create failed: ${e.message}`),N(!1)}}),V=O.auth.revokeToken.useMutation({onSuccess:()=>{I(null),L()},onError:e=>{I(null),k(`Revoke failed: ${e.message}`)}}),H=Se(lt,L),ie=Date.now(),oe=(C.data??[]).filter(e=>!c||e.subjectId===d?.id).map(e=>He(e,_,e.scopes.includes(`*`)?null:e.scopes.map(e=>Be(e,S,e=>dt(e,u))).join(`, `),ie)),U=async e=>{await p({title:l(`access.tokensSection.revoke`,`Revoke "{{name}}"?`,{name:e.name}),message:e.kind===`All permissions`?l(`access.tokensSection.everyScriptUsingItLoses`,`Every script using it loses access immediately. This cannot be undone.`):l(`access.tokensSection.stopsWorking`,`Whoever holds it loses access immediately. This cannot be undone.`),confirmLabel:l(`access.tokensSection.revoke2`,`Revoke`),variant:`danger`})&&(k(null),I(e.id),V.mutate({id:e.id}))},W=e=>{(async()=>{k(null),j(null);let t;if(e.scopes.includes(`*`)){N(!0);let e=await w();if(N(!1),e===null)return;t=e}z.mutate({scopes:[...e.scopes],expiresIn:e.expiresIn,label:e.label,...e.subjectId===void 0?{}:{subjectId:e.subjectId},...t===void 0?{}:{reauthToken:t}})})()};return e(`div`,{"data-testid":`tokens`,children:[T,n(J,{notice:le(te,H.outcome),onDismissNotice:()=>{k(null),H.dismiss()},id:c?`my-tokens`:`tokens`,title:c?l(`access.tokensSection.myTokens`,`My tokens`):l(`access.tokensSection.tokens`,`Tokens`),icon:b,actions:a?void 0:e(R,{size:`sm`,type:`button`,"data-testid":`tokens-new`,onClick:D,children:[n(b,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),l(`system.access.newToken`,`New token`)]}),description:l(`access.tokensSection.oneFormat`,`Every token is its scopes: a few permissions for a script, all permissions for an admin script, or a view of some cameras for a share link. Revoking one stops it on its next use.`),children:n(Oe,{rows:oe,label:l(`common.tokensLabel`),isLoading:C.isLoading,loadError:C.isError?C.error?.message??`Request failed`:null,emptyText:l(`access.tokensSection.noTokens`,`No tokens.`),action:{label:l(`access.tokensSection.revoke2`,`Revoke`),icon:h,isAvailable:e=>e.status===`active`,onRun:e=>void U(e),busyId:F,disabled:H.busy||F!==null},...d?.isAdmin===!0?{bulk:{revoke:H,noun:lt,isSelectable:e=>e.status===`active`}}:{}})}),n(ct,{open:E.mode===`new`,users:y.map(e=>({id:e.id,username:e.username})),onClose:()=>{ee(),j(null),N(!1)},submitting:z.isPending,formError:A,awaitingProof:M,onSubmit:W}),P&&n(tt,{token:P.token,label:P.label,onClose:()=>re(null)})]})}var pt=864e5,mt={qr:`QR (by an admin)`,self:`Self-enrolled`},ht={ios:`iOS`,android:`Android`,web:`Web`,other:`Other`};function gt(e){return e.status===`revoked`}function _t(e){return e.status!==`revoked`}function vt(e,t=`—`){if(e===null)return t;let n=new Date(e);return Number.isNaN(n.getTime())?t:n.toLocaleString()}function yt(e,t){return e===null||Number.isNaN(e)?null:Math.floor((e-t)/pt)}function bt(e,t){let n=yt(e,t);return n===null?`unknown`:n<0?`expired`:n<30?`soon`:`ok`}function xt(e,t){let n=yt(e,t);return n===null?W.t(`helpers.certificateModel.unknown`):n===0?W.t(`helpers.certificateModel.today`):n>0?W.t(`helpers.certificateModel.inDays`,{count:n}):W.t(`helpers.certificateModel.daysAgo`,{count:-n})}function St(e){if(e===null)return null;let t=Date.parse(e);return Number.isNaN(t)?null:t}function Ct(e){return e===null||e.length===0?`—`:e.length<=17?e:`${e.slice(0,8)}…${e.slice(-8)}`}function wt(e){return e.length<=10?e:`${e.slice(0,10)}…`}function Tt(e){if(!e.online)return{allowed:!1,reason:W.t(`helpers.certificateModel.nodeOffline`)};if(e.isHub&&e.https.kind===`served`){if(e.https.status.mode===`uploaded`)return{allowed:!1,reason:W.t(`helpers.certificateModel.uploadedCert`)};if(e.https.status.mode===`disabled`)return{allowed:!1,reason:W.t(`helpers.certificateModel.tlsDisabled`)}}return{allowed:!0,reason:null}}var Et={prepare:`helpers.certificateModel.stage.prepare`,issue:`helpers.certificateModel.stage.issue`,install:`helpers.certificateModel.stage.install`,reconnect:`helpers.certificateModel.stage.reconnect`,confirm:`helpers.certificateModel.stage.confirm`};function Dt(e){if(e.ok)return{tone:`success`,message:W.t(`helpers.certificateModel.renewed`,{nodeId:e.nodeId,serial:wt(e.newSerial)})};let t=e.keptPreviousLeaf?W.t(`helpers.certificateModel.keptPrevious`):W.t(`helpers.certificateModel.maybeNoCert`);return{tone:`danger`,message:W.t(`helpers.certificateModel.renewalFailed`,{nodeId:e.nodeId,stage:W.t(Et[e.stage]),reason:e.reason,kept:t})}}function Ot(e,t){let n=Math.max(0,e-t),r=Math.ceil(n/1e3),i=Math.floor(r/60),a=r%60;return{expired:n===0,label:`${String(i)}:${String(a).padStart(2,`0`)}`}}var kt=11;function At(e,t){let n=e.slice(0,kt);return t===null?n:`${n} · ${t}`}function jt(e){return{id:e.id,name:e.deviceName,detail:At(e.fingerprint,e.lastUsedFrom),ownerId:e.userId,ownerName:e.username??e.userId,kind:ht[e.platform],scope:mt[e.enrolledVia],status:e.status,createdAt:e.issuedAt,lastUsedAt:e.lastUsedAt,expiresAt:e.expiresAt}}function Mt(e,t){return{id:e.id,name:e.deviceName,detail:null,ownerId:null,ownerName:t,kind:ht[e.platform],scope:null,status:e.status,createdAt:e.issuedAt,lastUsedAt:e.lastUsedAt,expiresAt:e.expiresAt}}function Nt({sessions:t,isLoading:r,loadError:i,emptyText:a,onRevoke:o,revokingId:s}){let{t:c}=G();return r?e(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[n(_,{className:`h-3.5 w-3.5 animate-spin`}),c(`auth.sessionsList.loadingSessions`,`Loading sessions…`)]}):i===null?t.length===0?n(`div`,{className:`rounded border border-dashed border-border px-3 py-4 text-xs text-foreground-subtle text-center`,children:a}):n(`ul`,{className:`divide-y divide-border rounded-md border border-border`,children:t.map(e=>n(Pt,{session:e,revoking:s===e.id,onRevoke:()=>o(e)},e.id))}):e(`div`,{className:`text-[11px] text-danger`,children:[c(`auth.sessionsList.couldNotLoadSessions`,`Could not load sessions:`),` `,i]})}function Pt({session:t,revoking:r,onRevoke:i}){let{t:a}=G(),s=Ze(t.client);return e(`li`,{"data-testid":`session-row`,className:`flex items-start gap-3 px-3 py-2 text-xs`,children:[n(o,{className:`h-3.5 w-3.5 mt-0.5 shrink-0 text-foreground-subtle`}),e(`div`,{className:`flex-1 min-w-0 space-y-0.5`,children:[e(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[n(`span`,{className:`font-medium text-foreground truncate`,title:s.raw??void 0,children:s.label}),t.current&&n(`span`,{className:`rounded bg-primary/10 px-1.5 py-0.5 text-[10px] font-medium text-primary`,children:a(`auth.sessionsList.thisDevice`,`This device`)})]}),e(`div`,{className:`flex flex-wrap gap-x-3 text-[11px] text-foreground-subtle`,children:[n(`span`,{children:$e(t.method)}),n(`span`,{className:`font-mono`,children:t.ip??a(`auth.sessionsList.ipUnknown`,`IP unknown`)}),n(`span`,{children:a(`auth.sessionsList.lastActive`,{when:et(t.lastUsedAt)})}),n(`span`,{children:a(`auth.sessionsList.expires`,{when:et(t.expiresAt)})})]})]}),!t.current&&e(R,{variant:`unstyled`,onClick:i,disabled:r,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] text-danger hover:bg-danger/10 disabled:opacity-50`,children:[r?n(_,{className:`h-3 w-3 animate-spin`}):n(y,{className:`h-3 w-3`}),a(`auth.sessionsList.signOut`,`Sign out`)]})]})}export{Me as C,Ce as E,Ne as S,Se as T,Ze as _,_t as a,Ue as b,xt as c,vt as d,Tt as f,nt as g,ft as h,gt as i,Dt as l,wt as m,jt as n,Ot as o,Ct as p,Mt as r,St as s,Nt as t,bt as u,$e as v,Oe as w,We as x,et as y};
@@ -1 +0,0 @@
1
- import{C as e,K as t,R as n,S as r,V as i,Y as a,et as o,o as s}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Tt as c,ct as l,ti as u,tr as d,vi as f,zr as p}from"./player-overlays-fpbPSPqT.js";import{Ac as m}from"./client-Cng2SeYA.js";import{t as h}from"./chevron-down-CBb-F8DT.js";import{_ as g}from"./terminal-DZ5OZpgC.js";import{t as _}from"./eraser-B3lnG9yK.js";import{t as v}from"./hard-drive-download-C6N6tovA.js";import{Ld as y,al as b,df as x,ff as S,ka as C,mp as w,pf as ee,ro as T}from"./src-eL0OacoB.js";import{t as E}from"./i18n--GTAj4mB.js";import{t as D}from"./useTranslation-BJr-n0es.js";import{Rt as O,St as k}from"./index-DbXFHmBJ.js";import{t as A}from"./format-size-DIxKXxtj.js";import{t as te}from"./InstancesTable-LVQWfz07.js";o();var j=[`ok`,`warn`,`critical`];function M(e){return e>=.95?`critical`:e>=.85?`warn`:`ok`}function N(e){return Math.min(1,Math.max(0,e))}function P(e){let{availableBytes:t,totalBytes:n}=e;if(n===null||n<=0||t===null)return null;let r=N((n-t)/n);return{fraction:r,severity:M(r),recordingsFraction:N(e.usedBytes/n),freeBytes:t,totalBytes:n}}function ne(e){if(e.length===0)return null;let t=0,n=0,r=0,i=0,a=null;for(let o of e){let e=P(o);if(e===null){n+=1;continue}t+=1,r+=e.totalBytes,i+=e.freeBytes,(a===null||j.indexOf(e.severity)>j.indexOf(a))&&(a=e.severity)}return{knownVolumes:t,unknownVolumes:n,totalBytes:r,freeBytes:i,severity:a}}function re(e){return`${(e/1024**3).toFixed(e>=100*1024**3?0:1)} GB`}function ie(e){return new Date(e).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`})}function F({drain:t}){let{t:n}=D();if(t.kind===`idle`)return null;if(t.kind===`unreported`)return r(`span`,{"data-testid":`drain-unreported`,className:`text-[10px] text-foreground-subtle`,title:n(`storage.drainProgressLine.thisLocationIsDrainingThe`,`This location is draining. The hub has not reported how much is left yet — either the drain has just been set, or this hub predates the drain-progress report.`),children:n(`storage.drainProgressLine.drainingRemainingNotReportedYet`,`Draining · remaining not reported yet`)});if(t.kind===`drained`)return r(`span`,{"data-testid":`drain-done`,className:`text-[10px] text-success`,title:n(`storage.drainProgressLine.everythingThatWasHereHas`,`Everything that was here has been moved. The location is still in drain mode — it receives no new writes until you change that.`),children:n(`storage.drainProgressLine.drainedNothingLeftToMove`,`Drained · nothing left to move`)});let i=t.drainedFraction===null?null:Math.round(t.drainedFraction*100);return e(`span`,{"data-testid":`drain-progress`,className:`flex items-center gap-1.5 text-[10px] text-foreground-subtle tabular-nums`,children:[i!==null&&r(`span`,{"data-testid":`drain-bar`,className:`inline-block h-1 w-10 rounded-full bg-border overflow-hidden`,role:`progressbar`,"aria-label":n(`storage.drainProgressLine.drainProgress`,`Drain progress`),"aria-valuenow":i,"aria-valuemin":0,"aria-valuemax":100,children:r(`span`,{className:`block h-full bg-warning`,style:{width:`${i}%`}})}),e(`span`,{children:[n(`storage.drainProgressLine.left`,{size:re(t.bytesRemaining)}),i!==null&&` · ${n(`storage.drainProgressLine.moved`,{percent:i})}`]}),t.estimatedEmptyAtMs===null?r(`span`,{"data-testid":`drain-eta-absent`,title:n(`storage.drainProgressLine.theDrainIsPacedBy`,`The drain is paced by how fast this class of data is still growing, and that has not been observed yet. There is no date to give.`),children:n(`storage.drainProgressLine.emptyTimeNotKnownYet`,`· empty time not known yet`)}):e(`span`,{"data-testid":`drain-eta`,children:[`·`,` `,n(`storage.drainProgressLine.empty`,{when:ie(t.estimatedEmptyAtMs)})]})]})}function I(e){return Math.min(1,Math.max(0,e))}function L(e){return Math.round(I(e)*1e3)/10}function R(e){return`${String(Math.round(I(e)*100))}%`}function ae(e,t,n={}){let{totalBytes:r,availableBytes:i}=e;if(r===null||r<=0||i===null){let e=n.ownedBytes===void 0||n.ownedBytes===null||!Number.isFinite(n.ownedBytes)||n.ownedBytes<0?null:A(n.ownedBytes);return{kind:`unknown`,owned:e,summary:e===null?E.t(`helpers.locationCapacityBar.unknownSummary`):E.t(`helpers.locationCapacityBar.unknownSummaryOwned`,{size:e})}}let a=Math.min(Math.max(i,0),r),o=r-a,s=t===null||t<=0?0:t,c=Math.min(s,a),l=s>a,u=a-c,d=n.ownedBytes,f=d==null||!Number.isFinite(d)||d<0?null:Math.min(d,o),p=o-(f??0),m=P({usedBytes:f??o,availableBytes:a,totalBytes:r}),h=m===null?I(o/r):m.fraction,g=m===null?M(h):m.severity,_=f===null?null:m===null?I(f/r):m.recordingsFraction,v=n.cap??null,y=v===null?null:I((c+v.bytes)/r),b=v!==null&&f!==null&&f>v.bytes,x={total:A(r),freeTotal:A(a),freeTotalPercent:R(a/r),used:A(p),usedPercent:R(p/r),free:A(u),freePercent:R(u/r),reserve:s===0?null:E.t(`helpers.locationCapacityBar.reserveKept`,{size:A(s)}),owned:f===null||_===null?null:E.t(`helpers.locationCapacityBar.ownedOfRecordings`,{size:A(f),percent:R(_)}),cap:v===null?null:v.reason===`drain`?E.t(`helpers.locationCapacityBar.capDrain`,{size:A(v.bytes)}):E.t(`helpers.locationCapacityBar.capCap`,{size:A(v.bytes)})},S=[E.t(`helpers.locationCapacityBar.summaryFree`,{free:x.freeTotal,total:x.total,percent:x.freeTotalPercent}),x.owned===null?null:E.t(`helpers.locationCapacityBar.summaryOwned`,{owned:x.owned}),x.reserve===null?null:l?E.t(`helpers.locationCapacityBar.summaryReserveShort`,{reserve:x.reserve}):x.reserve,x.cap===null?null:b?E.t(`helpers.locationCapacityBar.summaryCapBelow`,{cap:x.cap}):x.cap].filter(e=>e!==null).join(` · `),C=[];return c>0&&C.push({segment:`reserve`,label:E.t(`helpers.locationCapacityBar.legendKeptFree`),value:A(s),alarming:l}),x.owned!==null&&C.push({segment:`owned`,label:E.t(`helpers.locationCapacityBar.legendCamstack`),value:x.owned,alarming:!1}),C.push({segment:`used`,label:f===null?E.t(`helpers.locationCapacityBar.legendUsed`):E.t(`helpers.locationCapacityBar.legendOtherData`),value:`${x.used} (${x.usedPercent})`,alarming:g===`critical`}),C.push({segment:`free`,label:E.t(`helpers.locationCapacityBar.legendFree`),value:`${x.free} (${x.freePercent})`,alarming:l}),v!==null&&C.push({segment:`cap`,label:v.reason===`drain`?E.t(`helpers.locationCapacityBar.legendDrainTarget`):E.t(`helpers.locationCapacityBar.legendCap`),value:E.t(`helpers.locationCapacityBar.legendCapValue`,{size:A(v.bytes)}),alarming:b}),{kind:`known`,severity:g,legend:C,segments:{reservePercent:L(c/r),ownedPercent:f===null?null:L(f/r),usedPercent:L(p/r),freePercent:L(u/r),capPercent:y===null?null:L(y)},labels:x,reserveExceedsFree:l,capBelowOwned:b,summary:S}}function z(e){return m(e)}function B(e){return e===`active`}var V=[{mode:`active`,get label(){return E.t(`helpers.locationMode.activeLabel`)},get consequence(){return E.t(`helpers.locationMode.activeConsequence`)},requiresConfirmation:!1},{mode:`readonly`,get label(){return E.t(`helpers.locationMode.readonlyLabel`)},get consequence(){return E.t(`helpers.locationMode.readonlyConsequence`)},requiresConfirmation:!1},{mode:`drain`,get label(){return E.t(`helpers.locationMode.drainLabel`)},get consequence(){return E.t(`helpers.locationMode.drainConsequence`)},requiresConfirmation:!1},{mode:`disabled`,get label(){return E.t(`helpers.locationMode.disabledLabel`)},get consequence(){return E.t(`helpers.locationMode.disabledConsequence`)},requiresConfirmation:!0}];function H(e){return V.find(t=>t.mode===e)??V[0]}function oe(e){return H(e).requiresConfirmation}var se=`Blocked: this is the last location of its type still accepting writes — new data would have nowhere to go.`;function U(e,t,n){return B(n)||!B(z(e))||t.some(t=>t.id!==e.id&&B(z(t)))?{blocked:!1,reason:``}:{blocked:!0,reason:se}}function ce(e,t){return{active:U(e,t,`active`).reason,readonly:U(e,t,`readonly`).reason,drain:U(e,t,`drain`).reason,disabled:U(e,t,`disabled`).reason}}var W=1024**3;function G(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function le(e){let t=G(e.minFreeGb);if(t!==null)return{unit:`gb`,value:t};let n=G(e.minFreePercent);return n===null?{unit:`percent`,value:null}:{unit:`percent`,value:n}}function ue(e,t,n=10){if(e.unit===`gb`&&e.value!==null)return e.value*W;let r=e.value??n;return t===null||t<=0?null:t*Math.min(100,Math.max(0,r))/100}function de(e,t){let n=G(e.maxUsedGb);return n===null||n<0?null:{bytes:n*W,reason:t===`drain`?`drain`:`legacy`}}var K={ok:`bg-primary`,warn:`bg-warning`,critical:`bg-danger`},q={reserve:`bg-danger/40`,owned:`bg-foreground/50`,free:`bg-border`,cap:`bg-foreground`};function fe(e,t){return e===`used`?K[t]:q[e]}function J({location:t,ownedBytes:n}){let{t:i}=D(),a=t.capacity??null,o=ue(le(t.config),a?.totalBytes??null),s=ae({totalBytes:a?.totalBytes??null,availableBytes:a?.availableBytes??null},o,{ownedBytes:n??null,cap:de(t.config,z(t))});return s.kind===`unknown`?r(`div`,{className:`text-[10px] text-foreground-subtle italic`,title:s.summary,children:s.owned===null?i(`storage.locationCapacityBar.capacityUnknown`,`Capacity unknown`):i(`storage.locationCapacityBar.capacityUnknownCamstackHolds`,`Capacity unknown · CamStack holds {{owned}}`,{owned:s.owned})}):e(`div`,{className:`mt-1 space-y-1`,title:s.summary,children:[e(`div`,{className:`relative flex h-2 w-full max-w-md overflow-hidden rounded-full bg-border`,children:[s.segments.reservePercent>0&&r(`div`,{className:q.reserve,style:{width:`${String(s.segments.reservePercent)}%`}}),s.segments.ownedPercent!==null&&r(`div`,{className:q.owned,style:{width:`${String(s.segments.ownedPercent)}%`}}),r(`div`,{className:K[s.severity],style:{width:`${String(s.segments.usedPercent)}%`}}),r(`div`,{className:q.free,style:{width:`${String(s.segments.freePercent)}%`}}),s.segments.capPercent!==null&&r(`div`,{className:`absolute inset-y-0 w-px ${s.capBelowOwned?`bg-danger`:q.cap}`,style:{left:`${String(s.segments.capPercent)}%`}})]}),r(`ul`,{className:`flex flex-wrap items-center gap-x-3 gap-y-0.5`,children:s.legend.map(t=>e(`li`,{className:`flex items-center gap-1`,children:[r(`span`,{"aria-hidden":`true`,className:`inline-block h-2 w-2 shrink-0 rounded-sm ${fe(t.segment,s.severity)}`}),e(`span`,{className:`text-[10px] tabular-nums ${t.alarming?`text-danger`:`text-foreground-subtle`}`,children:[t.label,` `,t.value]})]},t.segment))})]})}var pe={eventMedia:[`events`],recordingsLow:[`low`],recordings:[`high`,`mid`]},me={eventMedia:`pipeline-analytics`,recordingsLow:`recorder`,recordings:`recorder`},he=`storage.discardLocation`,Y=`storage.discardLocationStatus`,ge=`storage.discardLocationCancel`;function _e(e){return pe[e]??null}function ve(e){return me[e]??null}function ye(e){return!B(z(e))}function be(e,t){return _e(e.type)===null||!ye(e)?!1:t.some(t=>t.id!==e.id&&B(z(t)))}var xe=new Set([`idle`,`scanning`,`wiping-fs`,`wiping-db`,`cascading`,`complete`,`cancelled`,`error`]);function X(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function Z(e){return typeof e==`string`?e:null}function Se(e){if(typeof e!=`object`||!e)return null;let t=e;if(typeof t.running!=`boolean`)return null;let n=t.phase;if(typeof n!=`string`||!xe.has(n))return null;let r=X(t.camerasTotal),i=X(t.camerasDone),a=X(t.foldersRemoved),o=X(t.dbRowsDeleted),s=X(t.ownersCascaded);return r===null||i===null||a===null||o===null||s===null?null:{running:t.running,locationId:Z(t.locationId),jobId:Z(t.jobId),phase:n,camerasTotal:r,camerasDone:i,foldersRemoved:a,dbRowsDeleted:o,ownersCascaded:s,detail:Z(t.detail)??``,startedAtMs:X(t.startedAtMs),finishedAtMs:X(t.finishedAtMs),error:Z(t.error)}}function Ce(e){if(e.phase===`complete`)return 100;if(e.phase===`cancelled`||e.phase===`error`||e.phase===`idle`)return e.camerasTotal>0?Math.min(99,Math.round(e.camerasDone/e.camerasTotal*100)):0;if(e.camerasTotal>0){let t=e.camerasDone/e.camerasTotal*85;return e.phase===`wiping-db`?Math.min(95,Math.round(t+8)):e.phase===`cascading`?Math.min(99,Math.round(t+12)):Math.min(85,Math.round(t))}return e.phase===`scanning`?2:5}var we=2e3;function Te({location:e,siblings:t}){return be(e,t)?r(Ee,{location:e}):null}function Ee({location:t}){let{t:n}=D(),o=l(),s=T(),u=ve(t.type),[d,f]=a(null),[m,h]=a(null),[g,v]=a(!1);if(i(()=>{if(u===null)return;let e=!1,t=async()=>{try{let t=await s.mutateAsync({addonId:u,action:Y,input:{}});if(e)return;f(Se(t))}catch{}};t();let n=setInterval(()=>void t(),we);return()=>{e=!0,clearInterval(n)}},[u,t.id]),u===null)return null;let y=d!==null&&d.locationId===t.id,b=y&&d.running,x=y&&d.phase!==`idle`,S=async()=>{if(await o({title:n(`storage.locationDiscardControl.discardLeftoversOn`,`Discard leftovers on "{{displayName}}"?`,{displayName:t.displayName}),message:n(`storage.locationDiscardControl.permanentlyDeletesLeftoverFilesAnd`,`Permanently deletes leftover files and records on this location. Other locations are not affected. This cannot be undone and may take hours.`),confirmLabel:n(`storage.locationDiscardControl.discardLeftovers`,`Discard leftovers`),variant:`danger`})){h(null),v(!0);try{await s.mutateAsync({addonId:u,action:he,input:{locationId:t.id}}),f(Se(await s.mutateAsync({addonId:u,action:Y,input:{}})))}catch(e){h(e instanceof Error?e.message:String(e))}finally{v(!1)}}},C=async()=>{try{await s.mutateAsync({addonId:u,action:ge,input:{}})}catch(e){h(e instanceof Error?e.message:String(e))}};return e(`div`,{className:`flex flex-col gap-1 min-w-[9rem] max-w-[16rem]`,children:[b?e(w,{variant:`unstyled`,type:`button`,onClick:()=>void C(),className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger border border-danger/40 hover:bg-danger/10`,children:[r(c,{className:`h-3 w-3`}),n(`common.cancel`,`Cancel`)]}):e(w,{variant:`unstyled`,type:`button`,onClick:()=>void S(),disabled:g,title:n(`storage.locationDiscardControl.permanentlyDeleteLeftoverFilesOn`,`Permanently delete leftover files on this location. Other locations are not affected.`),className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger border border-danger/40 hover:bg-danger/10 disabled:opacity-50`,children:[g?r(p,{className:`h-3 w-3 animate-spin`}):r(_,{className:`h-3 w-3`}),n(`storage.locationDiscardControl.discardLeftovers`,`Discard leftovers`)]}),x&&d!==null&&e(`div`,{className:`space-y-0.5`,children:[r(`div`,{className:`h-1 rounded bg-border overflow-hidden`,children:r(`div`,{className:`h-full bg-primary transition-[width] duration-300`,style:{width:`${Ce(d)}%`}})}),e(`p`,{className:`text-[10px] text-foreground-subtle leading-tight`,children:[d.phase,d.camerasTotal>0?` · ${n(`storage.locationDiscardControl.camsProgress`,{done:d.camerasDone,total:d.camerasTotal})}`:``,d.dbRowsDeleted>0?` · ${n(`storage.locationDiscardControl.rowsDeleted`,{count:d.dbRowsDeleted})}`:``,d.detail?` · ${d.detail}`:``]})]}),(m||y&&d?.error)&&r(`p`,{className:`text-[10px] text-danger leading-tight`,children:m??d?.error})]})}o();var De={active:d,readonly:g,drain:v,disabled:f},Oe={active:`border-success/30 text-success hover:bg-success/10`,readonly:`border-border text-foreground-subtle hover:text-foreground hover:bg-primary/10`,drain:`border-warning/40 text-warning hover:bg-warning/10`,disabled:`border-danger/40 text-danger hover:bg-danger/10`};function ke({mode:t,open:n,onToggle:i}){let{t:a}=D(),o=H(t),s=De[t];return e(w,{variant:`unstyled`,type:`button`,"aria-expanded":n,"aria-label":a(`storage.locationModeSelector.locationState`,`Location state`),onClick:i,title:o.consequence,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium border ${Oe[t]}`,children:[r(s,{className:`h-3 w-3`}),o.label,r(h,{className:`h-3 w-3 ${n?`rotate-180`:``}`})]})}function Ae({mode:t,blockedReasons:n,onSelect:a,onDismiss:o}){let{t:s}=D();return i(()=>{let e=e=>{e.key===`Escape`&&o()};return window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`keydown`,e)}},[o]),e(`div`,{className:`w-full basis-full rounded-lg border border-border bg-background p-1`,role:`group`,"aria-label":s(`storage.locationModeSelector.locationStateChoices`,`Location state choices`),children:[e(`div`,{className:`flex items-center justify-between px-2 py-1`,children:[r(`span`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:s(`storage.locationModeSelector.locationState`,`Location state`)}),r(w,{variant:`unstyled`,type:`button`,"aria-label":s(`storage.locationModeSelector.closeLocationStateChoices`,`Close location state choices`),onClick:o,className:`text-foreground-subtle hover:text-foreground`,children:r(c,{className:`h-3 w-3`})})]}),V.map(i=>{let c=n[i.mode],l=c!==``,u=De[i.mode],d=i.mode===t;return e(w,{variant:`unstyled`,type:`button`,role:`radio`,"aria-checked":d,"aria-label":i.label,disabled:l,onClick:()=>{l||(o(),d||a(i.mode))},className:`flex w-full flex-col items-start gap-0.5 rounded px-2 py-1.5 text-left ${l?`cursor-not-allowed opacity-60`:d?`bg-primary/10`:`hover:bg-primary/5`}`,children:[e(`span`,{className:`flex items-center gap-1.5 text-[11px] font-medium text-foreground`,children:[r(u,{className:`h-3 w-3`}),i.label,d&&r(`span`,{className:`text-[9px] uppercase text-primary`,children:s(`common.current`)})]}),r(`span`,{className:`text-[10px] leading-snug text-foreground-subtle`,children:i.consequence}),l&&r(`span`,{className:`text-[10px] leading-snug text-warning`,children:c})]},i.mode)})]})}function je(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Q(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function Me(e){if(!je(e))return null;let t=e.locationId;if(typeof t!=`string`||t.length===0)return null;let n=Q(e.startedAtMs),r=Q(e.startBytes),i=Q(e.bytesRemaining);return n===null||r===null||i===null||typeof e.drained!=`boolean`?null:{locationId:t,startedAtMs:n,startBytes:r,bytesRemaining:i,drained:e.drained,estimatedEmptyAtMs:Q(e.estimatedEmptyAtMs)}}function Ne(e){let t=new Map;if(!Array.isArray(e))return t;for(let n of e){let e=Me(n);e!==null&&t.set(e.locationId,e)}return t}function Pe(e){if(e.startBytes<=0||e.bytesRemaining>e.startBytes)return null;let t=e.startBytes-e.bytesRemaining;return Math.min(1,Math.max(0,t/e.startBytes))}function Fe(e,t){return e?t===void 0?{kind:`unreported`}:t.drained||t.bytesRemaining<=0?{kind:`drained`}:{kind:`draining`,bytesRemaining:t.bytesRemaining,drainedFraction:Pe(t),estimatedEmptyAtMs:t.estimatedEmptyAtMs}:{kind:`idle`}}function Ie(e){return m(e)===`drain`}var Le=[`recordings`,`recordingsLow`];function Re(e){return e.locationIds!==void 0&&e.locationIds.length>0?e.locationIds:e.locationId===null?[]:[e.locationId]}function ze(e,t){if(t===void 0||!Le.includes(e.type))return null;let n=t.find(t=>Re(t).includes(e.id));return n===void 0||!Number.isFinite(n.usedBytes)||n.usedBytes<0?null:n.usedBytes}function Be(e,t){let n=new Map;for(let r of e){let e=ze(r,t);e!==null&&n.set(r.id,e)}return n}o();var Ve=[];function $(){let e=ee({}),n=y({},{refetchOnWindowFocus:!1}),r=x({},{refetchOnWindowFocus:!1}),i=e.data??Ve,a=t(()=>Be(i,n.data?.locations),[i,n.data?.locations]),o=t(()=>Ne(r.data),[r.data]);return t(()=>({locations:i,ownedBytesById:a,drainOf:e=>Fe(Ie(e),o.get(e.id))}),[i,a,o])}o();function He({row:t}){let{t:n}=D(),i=l(),o=s(),c=$(),[u,d]=a(!1),f=b({onSuccess:()=>{o.invalidateQueries({queryKey:[k]}),o.invalidateQueries({queryKey:[[`storage`,`listLocations`]]}),d(!1)},onError:e=>O({title:n(`system.storage.modeFailed`,`Could not change the state`),message:`${t.name}: ${e.message}`,severity:`critical`})}),p=c.locations.find(e=>e.id===t.id);if(p===void 0)return null;let m=c.locations.filter(e=>e.type===p.type),h=z(p),g=c.drainOf(p),_=async e=>{oe(e)&&!await i({title:n(`system.storage.disable`,`Disable "{{displayName}}"?`,{displayName:p.displayName}),message:n(`system.storage.nothingIsDeletedSetThe`,`{{consequence}} Nothing is deleted — set the location back to Read-only or Active to bring its footage back.`,{consequence:H(e).consequence}),confirmLabel:n(`common.disable`,`Disable`),variant:`danger`})||f.mutate({addonId:t.addonId,id:t.id,values:{mode:e}})};return e(`div`,{className:`flex flex-wrap items-start gap-x-3 gap-y-2 rounded-lg border border-border bg-surface p-3`,children:[e(`div`,{className:`min-w-0 flex-1 basis-60`,children:[r(J,{location:p,ownedBytes:c.ownedBytesById.get(p.id)??null}),g.kind!==`idle`&&r(F,{drain:g})]}),e(`div`,{className:`flex flex-wrap items-center gap-1`,children:[r(Te,{location:p,siblings:m}),r(ke,{mode:h,open:u,onToggle:()=>d(e=>!e)})]}),u&&r(Ae,{mode:h,blockedReasons:ce(p,m),onSelect:e=>void _(e),onDismiss:()=>d(!1)})]})}function Ue({row:t}){let n=$();if(t.kind!==`instance`)return null;let i=n.locations.find(e=>e.id===t.id);if(i===void 0)return null;let a=n.drainOf(i);return e(`div`,{className:`min-w-48`,children:[r(J,{location:i,ownedBytes:n.ownedBytesById.get(i.id)??null}),a.kind!==`idle`&&r(F,{drain:a})]})}function We({row:e}){let t=$();if(e.kind!==`instance`)return null;let n=t.locations.find(t=>t.id===e.id);if(n===void 0)return null;let i=z(n);return r(C,{variant:i===`active`?`success`:i===`disabled`?`danger`:`default`,children:H(i).label})}function Ge(e){return[{key:`capacity`,header:e.capacity,notSortableReason:e.capacity,render:e=>r(Ue,{row:e})},{key:`mode`,header:e.mode,nowrap:!0,notSortableReason:e.mode,render:e=>r(We,{row:e})}]}function Ke(e,t,n){return!(n===`single`||t.length<=1||B(z(e))&&t.filter(e=>B(z(e))).length<=1)}function qe(e){let t=e instanceof Error?e.message:String(e);return/still holds data — drain it first/.test(t)?`holds-data`:/could not be checked for remaining data/.test(t)?`unverifiable`:null}o();var Je=`forceDeleteLocation`;function Ye(){let{t:e}=D(),t=l(),r=s(),i=T();return n(async(n,a)=>{let o=qe(a);if(o===null)return!1;let s=o===`holds-data`?e(`system.storage.deleteBlockedHoldsData`,`This location still holds data. Drain it first (storage migration or relocate), or force the delete.`):e(`system.storage.deleteBlockedUnverifiable`,`What is stored on this location could not be checked (unreachable provider, another node or an unmounted root). Force the delete only if you are sure it is empty or no longer needed.`);if(!await t({title:e(`system.storage.deleteBlockedTitle`,`Cannot delete {{name}}`,{name:n.name}),message:s,confirmLabel:e(`system.storage.forceDelete`,`Force delete`),variant:`danger`})||!await t({title:e(`system.storage.forceDeleteTitle`,`Force delete "{{name}}"?`,{name:n.name}),message:e(`system.storage.forceDeleteStrands`,`Recordings and media stored on this location will be stranded: the record is deleted, the files stay on disk, and playback of the segments on it stops working.`),confirmLabel:e(`system.storage.forceDeleteConfirm`,`Delete and strand data`),variant:`danger`}))return!0;try{await i.mutateAsync({addonId:n.addonId,action:Je,input:{id:n.id}}),await r.invalidateQueries({queryKey:[k]}),await r.invalidateQueries({queryKey:[[`storage`,`listLocations`]]})}catch(t){O({title:e(`providerInstances.deleteFailed`,`Could not delete`),message:`${n.name}: ${t instanceof Error?t.message:String(t)}`,severity:`critical`})}return!0},[t,i,r,e])}o();var Xe=`storage`;function Ze({kinds:e}){let{t:n}=D(),{locations:i}=$(),a=S({}).data,o=Ye(),s=e=>{let t=i.find(t=>t.id===e.id),n=a?.find(e=>e.id===t?.type);return t===void 0||n===void 0?!1:Ke(t,i.filter(e=>e.type===t.type),n.cardinality)},c=t(()=>Ge({capacity:n(`system.storage.colCapacity`,`Capacity`),mode:n(`system.storage.colMode`,`State`)}),[n]),l=t(()=>e===void 0?void 0:t=>t.kind===`instance`&&t.kindId!==void 0&&e.includes(t.kindId),[e]);return r(te,{functionCap:Xe,icon:u,title:n(`system.storage.title`,`Storage locations`),subtitle:n(`system.storage.subtitle`,`Where recordings, event media, artifacts and backups are kept. Each location is one kind on one provider; the state decides whether it takes writes, is only read, drains or is left alone.`),emptyTitle:n(`system.storage.emptyTitle`,`No storage locations yet`),emptyDescription:n(`system.storage.noStorageLocationsDeclaredBy`,`No storage locations declared by any installed addon.`),addLabel:n(`system.storage.addLocation`,`Add location`),extraColumns:c,lead:e=>r(He,{row:e}),canDelete:s,onDeleteRefused:o,...l===void 0?{}:{rowFilter:l}})}export{z as a,H as i,$ as n,F as o,J as r,ne as s,Ze as t};
@@ -1,2 +0,0 @@
1
- import{C as e,J as t,K as n,R as r,S as i,V as a,Y as o,a as s,et as c,o as l,t as u}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{$i as d,In as f,Jn as p,Nr as m,Qa as h,Yn as g,Z as _,Zi as v,ar as y,ct as b,ft as x,va as S,wn as C,xr as w,yt as T,zr as E}from"./player-overlays-fpbPSPqT.js";import{Vc as D}from"./client-Cng2SeYA.js";import{n as O,t as ee}from"./ruler-Buxogset.js";import{r as te}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_trpc_mf_1_client__loadShare__.js-8kv6pj9W.js";import{Aa as k,Ar as A,Br as ne,Da as j,Dr as re,Fp as ie,Ip as ae,Ir as M,Lp as oe,Lr as N,Of as se,Or as ce,Pf as le,Qp as P,Rr as F,Sp as I,Tr as ue,hi as de,ia as fe,jf as pe,ka as L,kn as me,la as he,mp as R,p as ge,qp as _e,zr as ve}from"./src-eL0OacoB.js";import{t as ye}from"./i18n--GTAj4mB.js";import{t as z}from"./useTranslation-BJr-n0es.js";import"./mount-B-FI9413.js";import{b as be,bi as xe,w as Se,wi as Ce,xi as we}from"./index-DbXFHmBJ.js";import{t as Te}from"./AdminSectionedPage-bGVBepbw.js";import{t as B}from"./AdminPage-BkxgjFWW.js";import{t as Ee}from"./BootstrapSettingsForm-jBRoUiPn.js";c();var V=`method`,H=8;function U(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function W(e){return Array.isArray(e)?e.filter(U):[]}function G(e,t){let n=e.$ref;if(typeof n!=`string`||!n.startsWith(`#/`))return e;let r=t;for(let e of n.slice(2).split(`/`))r=U(r)?r[e]:void 0;return U(r)?r:e}function K(e){let t=e.type;return typeof t==`string`?[t]:Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}function q(e){let t=e.required;return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}function J(e,t,n){let r=G(e,t);if(n>H)return null;if(`default`in r)return r.default;if(`const`in r)return r.const;let i=r.enum;if(Array.isArray(i)&&i.length>0)return i[0];let a=[...W(r.anyOf),...W(r.oneOf)];if(a.length>0){let e=a.find(e=>!K(G(e,t)).includes(`null`))??a[0];return e===void 0?null:J(e,t,n+1)}let o=W(r.allOf);if(o.length>0)return o.reduce((e,r)=>{let i=J(r,t,n+1);return U(e)&&U(i)?{...e,...i}:i},{});switch(K(r).find(e=>e!==`null`)){case`object`:return Y(r,t,n);case`array`:return[];case`string`:return``;case`number`:case`integer`:return typeof r.minimum==`number`?r.minimum:0;case`boolean`:return!1;default:return U(r.properties)?Y(r,t,n):null}}function Y(e,t,n){let r=U(e.properties)?e.properties:{},i={};for(let a of q(e)){let e=r[a];i[a]=U(e)?J(e,t,n+1):null}return i}function De(e){if(e!==null)return J(e,e,0)}function Oe(e){return e===null?`null`:Array.isArray(e)?`array`:typeof e==`number`?Number.isInteger(e)?`integer`:`number`:typeof e}function ke(e,t){let n=Oe(e);return n===t||t===`number`&&n===`integer`}function X(e,t){return e===``?String(t):`${e}.${t}`}function Z(e,t,n,r,i){let a=G(t,n);if(i>H*2)return[];let o=[...W(a.anyOf),...W(a.oneOf)];if(o.length>0&&!o.some(t=>Z(e,t,n,r,i+1).length===0))return[{path:r,code:`no-branch`,expected:`${o.length}`}];let s=[];for(let t of W(a.allOf))s.push(...Z(e,t,n,r,i+1));let c=K(a);if(c.length>0&&!c.some(t=>ke(e,t)))return[...s,{path:r,code:`type`,expected:c.join(` | `)}];`const`in a&&JSON.stringify(a.const)!==JSON.stringify(e)&&s.push({path:r,code:`const`,expected:JSON.stringify(a.const)});let l=a.enum;if(Array.isArray(l)){let t=l.map(e=>JSON.stringify(e));t.includes(JSON.stringify(e))||s.push({path:r,code:`enum`,expected:t.join(`, `)})}if(typeof e==`number`&&s.push(...Ae(e,a,r)),typeof e==`string`&&s.push(...je(e,a,r)),Array.isArray(e)&&U(a.items)){let t=a.items;e.forEach((e,a)=>s.push(...Z(e,t,n,X(r,a),i+1)))}return U(e)&&s.push(...Me(e,a,n,r,i)),s}function Ae(e,t,n){let r=[],i=t.minimum,a=t.maximum;return typeof i==`number`&&e<i&&r.push({path:n,code:`minimum`,expected:`${i}`}),typeof a==`number`&&e>a&&r.push({path:n,code:`maximum`,expected:`${a}`}),r}function je(e,t,n){let r=[],i=t.minLength,a=t.maxLength;return typeof i==`number`&&e.length<i&&r.push({path:n,code:`min-length`,expected:`${i}`}),typeof a==`number`&&e.length>a&&r.push({path:n,code:`max-length`,expected:`${a}`}),r}function Me(e,t,n,r,i){let a=[],o=U(t.properties)?t.properties:{};for(let n of q(t))n in e||a.push({path:X(r,n),code:`required`,expected:n});for(let[s,c]of Object.entries(e)){let e=o[s];U(e)?a.push(...Z(c,e,n,X(r,s),i+1)):t.additionalProperties===!1&&a.push({path:X(r,s),code:`unknown-field`,expected:s})}return a}function Ne(e,t){return t===null?[]:Z(e,t,t,``,0)}function Pe(e){if(e.trim()===``)return{ok:!0,value:void 0};try{return{ok:!0,value:JSON.parse(e)}}catch(e){return{ok:!1,message:e instanceof Error?e.message:String(e)}}}function Q(e){return`'${e.replaceAll(`'`,`'\\''`)}'`}function Fe(e){let t=`${e.hubBase}/trpc/${e.path}`,n=`-H "Authorization: Bearer $CAMSTACK_TOKEN"`,r=e.input===void 0?null:JSON.stringify({json:e.input});if(e.kind===`mutation`){let e=r??JSON.stringify({json:null});return[`curl -sS -X POST ${n} \\`,` -H 'Content-Type: application/json' \\`,` --data ${Q(e)} \\`,` ${Q(t)}`].join(`
2
- `)}return`curl -sS ${n} \\\n ${Q(`${t}${r===null?``:`?input=${encodeURIComponent(r)}`}`)}`}function $(e,t){let n=e[t];return typeof n==`string`?n:null}function Ie(e){let t=e instanceof Error?e.message:String(e),n=U(e)||e instanceof Error?Reflect.get(e,`data`):void 0;if(!U(n))return{message:t,code:null,httpStatus:null,path:null,capRouteReason:null};let r=n.httpStatus;return{message:t,code:$(n,`code`),httpStatus:typeof r==`number`?r:null,path:$(n,`path`),capRouteReason:$(n,`capRouteReason`)}}function Le(e){if(e===void 0)return`undefined`;try{return JSON.stringify(e,null,2)??String(e)}catch{return String(e)}}var Re={searchText:e=>[e.path,e.scope?.capName??``],facetGroups:[{id:`router`,value:e=>e.router},{id:`kind`,value:e=>e.kind},{id:`tier`,value:e=>e.tier},{id:`source`,value:e=>e.source}]},ze={query:`info`,mutation:`warning`,subscription:`neutral`},Be={public:`success`,protected:`neutral`,admin:`primary`};function Ve({kind:e}){let{t}=z();return i(L,{variant:ze[e],size:`sm`,children:t(`system.apiExplorer.kind.${e}`)})}function He({tier:e}){let{t}=z();return i(L,{variant:Be[e],style:`outline`,size:`sm`,children:t(`system.apiExplorer.tier.${e}`)})}function Ue({methods:t,selectedPath:n,onSelect:r}){let{t:a}=z(),o=ue(t,Re),s=e=>a(`system.apiExplorer.group.${e}`),c=e=>t=>e===`router`?t:a(`system.apiExplorer.${e}.${t}`),l=[{key:`path`,header:a(`system.apiExplorer.column.method`),sortValue:e=>e.path,render:t=>e(`span`,{className:`font-mono text-xs`,children:[e(`span`,{className:`text-foreground-muted`,children:[t.router,`.`]}),i(`span`,{className:`text-foreground`,children:t.method})]})},{key:`kind`,header:a(`system.apiExplorer.column.kind`),sortValue:e=>e.kind,render:e=>i(Ve,{kind:e.kind})},{key:`tier`,header:a(`system.apiExplorer.column.tier`),sortValue:e=>e.tier,render:e=>i(He,{tier:e.tier})},{key:`scope`,header:a(`system.apiExplorer.column.scope`),sortValue:e=>e.scope===null?null:`${e.scope.capName}:${e.scope.access}`,render:t=>t.scope===null?i(`span`,{className:`text-xs text-foreground-subtle`,children:a(`system.apiExplorer.coreRoute`)}):e(`span`,{className:`font-mono text-xs text-foreground-muted`,children:[t.scope.capName,` · `,t.scope.access]})}];return e(`div`,{className:`space-y-3`,children:[i(re,{state:o.state,facets:o.facets,groups:o.groups.map(e=>({...e,label:s(e.id),facetLabel:c(e.id),...e.id===`router`?{display:`menu`}:{}})),labels:{searchPlaceholder:a(`system.apiExplorer.searchPlaceholder`),searchLabel:a(`system.apiExplorer.searchLabel`),facetsLabel:a(`system.apiExplorer.facetsLabel`),clearLabel:a(`system.apiExplorer.clearFilters`)},onSearch:o.setSearch,onToggleFacet:o.toggleFacet,onToggleGroupFacet:o.toggleGroupFacet,onClear:o.clear}),i(ve,{columns:l,rows:o.rows,rowKey:e=>e.path,onRowClick:e=>r(e.path),rowClassName:e=>e.path===n?`bg-primary/10`:void 0,minWidthPx:560,maxBodyHeight:ne,defaultSort:{columnKey:`path`,dir:`asc`},emptyMessage:o.active?a(`system.apiExplorer.noMatch`):a(`system.apiExplorer.noMethods`)})]})}var We={yes:`success`,"per-device":`warning`,no:`danger`},Ge={yes:`system.apiExplorer.callableYes`,"per-device":`system.apiExplorer.callablePerDevice`,no:`system.apiExplorer.callableNo`};function Ke(e){let t=De(e);return t===void 0?``:JSON.stringify(t,null,2)}function qe({method:t}){let{t:r}=z(),s=b(),c=te(P.useUtils().client),l=P.apiCatalog.inputSchema.useQuery({path:t.path},{enabled:t.hasInput,staleTime:1/0}),u=l.data?.schema??null,[d,f]=o(``),[m,h]=o(null),[g,v]=o(!1);a(()=>{f(Ke(u))},[u]);let x=n(()=>Pe(d),[d]),C=x.ok?Ne(x.value,u):[],w=t.kind!==`subscription`&&t.callable!==`no`,T=w&&x.ok&&C.length===0&&!g,E=t.kind===`mutation`?`mutation`:`query`,D=Fe({hubBase:_(),path:t.path,kind:E,input:x.ok?x.value:void 0}),O=async()=>{if(!x.ok||t.kind===`mutation`&&!await s({title:r(`system.apiExplorer.confirmTitle`),message:r(`system.apiExplorer.confirmMessage`,{method:t.path}),confirmLabel:r(`system.apiExplorer.run`),variant:`danger`}))return;v(!0);let e=performance.now();try{h({kind:`ok`,value:E===`mutation`?await c.mutation(t.path,x.value):await c.query(t.path,x.value),ms:performance.now()-e})}catch(t){h({kind:`error`,error:Ie(t),ms:performance.now()-e})}finally{v(!1)}};return i(M,{headingId:`api-explorer-method`,title:r(`system.apiExplorer.column.method`),icon:S,actions:e(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[i(Ve,{kind:t.kind}),i(He,{tier:t.tier})]}),children:e(`div`,{className:`space-y-4 p-3 sm:p-4`,children:[i(`p`,{className:`break-all font-mono text-sm text-foreground`,children:t.path}),i(N,{items:[{key:r(`system.apiExplorer.column.scope`),value:t.scope===null?r(`system.apiExplorer.coreRouteLong`):r(`system.apiExplorer.scopeValue`,{cap:t.scope.capName,access:t.scope.access,capScope:t.scope.capScope})},{key:r(`system.apiExplorer.callable`),value:i(L,{variant:We[t.callable],size:`sm`,children:r(Ge[t.callable])})}]}),t.kind===`subscription`&&i(`p`,{className:`text-sm text-foreground-muted`,children:r(`system.apiExplorer.subscriptionNote`)}),t.hasInput&&i(Je,{loading:l.isPending,error:l.error?.message??l.data?.error??null,schema:u}),w&&e(`div`,{className:`space-y-2`,children:[i(`label`,{htmlFor:`api-explorer-input`,className:`text-xs font-medium text-foreground-muted`,children:r(`system.apiExplorer.input`)}),i(de,{id:`api-explorer-input`,value:d,onChange:e=>f(e.target.value),rows:t.hasInput?8:2,spellCheck:!1,placeholder:t.hasInput?void 0:r(`system.apiExplorer.noInput`),state:x.ok&&C.length===0?`default`:`error`,className:`font-mono text-xs`}),i(Ye,{parseError:x.ok?null:x.message,issues:C}),e(`div`,{className:`flex flex-wrap items-center gap-2`,children:[e(R,{onClick:()=>void O(),disabled:!T,children:[i(y,{className:`h-3.5 w-3.5`}),r(g?`system.apiExplorer.running`:`system.apiExplorer.run`)]}),t.hasInput&&e(R,{variant:`ghost`,onClick:()=>f(Ke(u)),children:[i(p,{className:`h-3.5 w-3.5`}),r(`system.apiExplorer.resetInput`)]})]})]}),m!==null&&i(Xe,{outcome:m}),t.kind!==`subscription`&&e(`div`,{className:`space-y-2`,children:[e(`div`,{className:`flex items-center justify-between gap-2`,children:[i(`span`,{className:`text-xs font-medium text-foreground-muted`,children:r(`system.apiExplorer.curl`)}),i(ce,{value:D,label:r(`system.apiExplorer.copy`),srLabel:r(`system.apiExplorer.curl`)})]}),i(A,{maxHeight:200,children:D}),i(`p`,{className:`text-xs text-foreground-subtle`,children:r(`system.apiExplorer.curlHint`)})]})]})})}function Je({loading:t,error:n,schema:r}){let{t:a}=z();return e(`div`,{className:`space-y-2`,children:[i(`span`,{className:`text-xs font-medium text-foreground-muted`,children:a(`system.apiExplorer.inputSchema`)}),t?i(k,{className:`h-24 w-full`}):n===null?i(A,{maxHeight:240,children:Le(r)}):i(j,{variant:`warning`,message:a(`system.apiExplorer.schemaUnavailable`,{error:n})})]})}function Ye({parseError:t,issues:n}){let{t:r}=z();return t===null&&n.length===0?null:e(`ul`,{className:`space-y-0.5 text-xs text-danger`,role:`alert`,children:[t!==null&&i(`li`,{children:r(`system.apiExplorer.invalidJson`,{error:t})}),n.map(e=>i(`li`,{children:r(`system.apiExplorer.issue.${e.code}`,{path:e.path===``?r(`system.apiExplorer.rootPath`):e.path,expected:e.expected})},`${e.path}:${e.code}`))]})}function Xe({outcome:t}){let{t:n}=z(),r=n(`system.apiExplorer.duration`,{ms:Math.round(t.ms)});if(t.kind===`ok`)return e(`div`,{className:`space-y-2`,children:[e(`div`,{className:`flex items-center gap-2`,children:[i(`span`,{className:`text-xs font-medium text-foreground-muted`,children:n(`system.apiExplorer.result`)}),i(L,{variant:`success`,size:`sm`,children:r})]}),i(A,{maxHeight:400,children:Le(t.value)})]});let{error:a}=t,o=[{key:n(`system.apiExplorer.errorCode`),value:a.code},{key:n(`system.apiExplorer.errorStatus`),value:a.httpStatus},{key:n(`system.apiExplorer.errorPath`),value:a.path},{key:n(`system.apiExplorer.errorCapRoute`),value:a.capRouteReason}].flatMap(e=>e.value===null?[]:[{key:e.key,value:String(e.value)}]);return i(j,{title:`${n(`system.apiExplorer.callFailed`)} · ${r}`,message:e(`div`,{className:`space-y-2`,children:[i(`p`,{className:`break-words`,children:a.message}),o.length>0&&i(N,{items:o})]})})}c();function Ze(){let{t:n}=z(),[o,s]=Ce(),c=o.get(V),l=P.apiCatalog.list.useQuery(void 0,{staleTime:1/0}),u=t(null),d=l.data?.methods.find(e=>e.path===c)??null,f=r(e=>{s(t=>{let n=new URLSearchParams(t);return n.set(V,e),n},{replace:!0})},[s]),p=d?.path??null;return a(()=>{p!==null&&u.current?.scrollIntoView?.({block:`start`,behavior:`smooth`})},[p]),i(B,{embedded:!0,icon:S,title:n(`system.apiExplorer.title`),subtitle:n(`system.apiExplorer.subtitle`),children:l.isPending?i(k,{className:`h-64 w-full`}):l.error===null?e(`div`,{className:`grid gap-4 xl:grid-cols-2`,children:[i(M,{headingId:`api-explorer-methods`,title:n(`system.apiExplorer.methodsTitle`,{count:l.data.methods.length}),children:i(`div`,{className:`p-3 sm:p-4`,children:i(Ue,{methods:l.data.methods,selectedPath:c,onSelect:f})})}),i(`div`,{ref:u,className:`min-w-0 scroll-mt-4`,children:d===null?c===null?i(he,{icon:w,title:n(`system.apiExplorer.pickTitle`),description:n(`system.apiExplorer.pickDescription`)}):i(j,{variant:`warning`,message:n(`system.apiExplorer.unknownMethod`,{method:c})}):i(qe,{method:d},d.path)})]}):i(j,{title:n(`system.apiExplorer.couldNotLoad`),message:l.error.message,onRetry:()=>void l.refetch()})})}var Qe={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`},$e={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 et({entry:t,actions:n}){let r=t.name.toLowerCase(),a=Qe[r]??`border-primary`,o=$e[r]??`bg-primary/5`,s=t.providers.find(e=>e.active),c=n?.pendingCapability===t.name;return e(`div`,{className:`rounded-lg border-t-2 border border-border ${a} ${o} p-3 space-y-2`,children:[e(`div`,{className:`flex items-center justify-between gap-2`,children:[e(`span`,{className:`text-xs font-semibold text-foreground capitalize flex items-center gap-1.5`,children:[t.name,c&&i(E,{className:`h-3 w-3 animate-spin text-primary`})]}),i(`span`,{className:`rounded-full px-2 py-0.5 text-[10px] font-medium ${t.mode===`singleton`?`bg-primary/10 text-primary`:`bg-info/10 text-info`}`,children:t.mode})]}),t.mode===`singleton`?i(tt,{entry:t,actions:n,activeProvider:s,isPending:c}):i(nt,{entry:t,actions:n,isPending:c})]})}function tt({entry:t,actions:n,activeProvider:r,isPending:a}){let{t:o}=z();if(!n)return i(`div`,{children:r?e(`div`,{className:`flex items-center gap-1.5 text-[10px] text-foreground`,children:[i(v,{className:`h-3 w-3 text-green-400 shrink-0`}),i(`span`,{className:`font-medium`,children:r.addonName}),i(`span`,{className:`rounded-full bg-green-500/10 text-green-400 px-1.5 py-0.5 font-medium ml-auto`,children:`ACTIVE`})]}):i(`div`,{className:`text-[10px] text-foreground-subtle italic`,children:o(`addons.capabilityMap.noActiveProvider`,`No active provider`)})});if(t.providers.length===0)return i(`div`,{className:`text-[10px] text-foreground-subtle italic`,children:o(`addons.capabilityMap.noProviders`,`No providers`)});let s=`__inherit__`;return e(`div`,{className:`space-y-2`,children:[i(`div`,{className:`space-y-1`,children:t.providers.map(r=>{let o=r.active;return e(R,{variant:`unstyled`,type:`button`,disabled:a||o,onClick:()=>n.onSelectSingleton(t.name,r.addonId),className:`flex w-full items-center gap-1.5 rounded px-1.5 py-1 text-[10px] text-left transition-colors ${o?`bg-green-500/10 text-foreground cursor-default`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground disabled:opacity-50`}`,children:[i(`span`,{className:`h-2.5 w-2.5 rounded-full border shrink-0 ${o?`border-green-400 bg-green-400`:`border-border`}`}),i(`span`,{className:`font-medium truncate`,children:r.addonName}),o&&i(`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)})}),t.perNode&&t.perNode.length>0&&i(`div`,{className:`space-y-2 pt-1 border-t border-border/40`,children:t.perNode.map(r=>{let c=r.hasOverride&&r.resolvedActive?r.resolvedActive:s,l=[{value:s,label:r.resolvedActive?o(`addons.capabilityMap.inheritGlobalWith`,{provider:r.resolvedActive}):o(`addons.capabilityMap.inheritGlobal`)},...r.providers.map(e=>({value:e,label:e}))],u=e=>{e===s?n.onClearNodeSingleton(t.name,r.nodeId):n.onSelectNodeSingleton(t.name,r.nodeId,e)},d=a;return e(`div`,{className:`space-y-0.5`,children:[e(`div`,{className:`text-[9px] font-semibold uppercase tracking-widest text-foreground-subtle/60 px-1.5`,children:[r.nodeId,r.hasOverride&&i(`span`,{className:`ml-1.5 rounded-full bg-primary/10 text-primary px-1 py-0.5 normal-case tracking-normal font-medium`,children:o(`common.override`)})]}),l.map(t=>{let n=c===t.value;return e(R,{variant:`unstyled`,type:`button`,disabled:d||n,onClick:()=>u(t.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:[i(`span`,{className:`h-2.5 w-2.5 rounded-full border shrink-0 ${n?`border-green-400 bg-green-400`:`border-border`}`}),i(`span`,{className:`font-medium truncate`,children:t.label}),n&&t.value!==s&&i(`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`})]},t.value)})]},r.nodeId)})})]})}function nt({entry:t,actions:n,isPending:r}){let{t:a}=z();if(t.providers.length===0)return i(`div`,{className:`text-[10px] text-foreground-subtle italic`,children:a(`addons.capabilityMap.noProviders`,`No providers`)});if(!n)return i(`div`,{className:`space-y-1`,children:t.providers.map(t=>e(`div`,{className:`flex items-center justify-between gap-2 text-[10px]`,children:[i(`span`,{className:`text-foreground-subtle`,children:t.addonName}),t.active&&i(`span`,{className:`rounded-full bg-green-500/10 text-green-400 px-1.5 py-0.5 font-medium`,children:`ACTIVE`})]},t.addonId))});let o=t.providers.filter(e=>e.active).map(e=>e.addonId),s=(e,r)=>{let i=r?[...new Set([...o,e])]:o.filter(t=>t!==e);n.onToggleCollection(t.name,i)};return i(`div`,{className:`space-y-1`,children:t.providers.map(t=>e(`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:[e(`span`,{className:`flex items-center gap-1.5 min-w-0`,children:[i(h,{checked:t.active,disabled:r,onChange:e=>s(t.addonId,e.target.checked),className:`h-3 w-3 accent-green-500 shrink-0`}),i(`span`,{className:`text-foreground truncate`,children:t.addonName})]}),t.active&&i(`span`,{className:`rounded-full bg-green-500/10 text-green-400 px-1.5 py-0.5 font-medium shrink-0`,children:`ACTIVE`})]},t.addonId))})}function rt({capabilities:e,actions:t}){let{t:n}=z();return e.length===0?i(`div`,{className:`text-xs text-foreground-subtle text-center py-8`,children:n(`addons.capabilityMap.noCapabilitiesRegistered`,`No capabilities registered`)}):i(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-3`,children:e.map(e=>i(et,{entry:e,actions:t},e.name))})}c();var it=[`capabilities`,`listCapabilities`];function at(e){return e===`singleton`||e===`collection`}function ot(e){let t=e.indexOf(`@`);return t===-1?ye.t(`system.capabilities.providerHub`,{addonId:e}):`${e.slice(0,t)} (${e.slice(t+1)})`}function st(e,t){return{name:e.name,mode:t,providers:e.providers.map(n=>({addonId:n,addonName:ot(n),active:t===`singleton`?e.activeProvider===n:!e.disabledProviders.includes(n)})),...t===`singleton`&&e.perNode?{perNode:e.perNode}:{}}}function ct(){let{t}=z(),r=T(),[a,c]=o(null),[l,f]=o(null),p=s({queryKey:it,queryFn:()=>r.trpcClient.capabilities.listCapabilities.query()}),m=n(()=>{let e=(p.data??[]).flatMap(e=>at(e.mode)?[st(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]},[p.data]),h=n(()=>m.filter(e=>e.mode===`singleton`),[m]),g=n(()=>m.filter(e=>e.mode===`collection`),[m]),_=u({mutationFn:e=>r.trpcClient.capabilities.setActiveSingleton.mutate({capability:e.capName,addonId:e.addonId}),onMutate:e=>{c(e.capName),f(null)},onSuccess:async(e,n)=>{f({kind:`success`,message:t(`system.capabilities.isNowActive`,`{{capName}} → {{addonId}} is now active.`,{capName:n.capName,addonId:n.addonId})}),await p.refetch()},onError:(e,n)=>{f({kind:`error`,message:t(`system.capabilities.failedToSet`,{cap:n.capName,error:e instanceof Error?e.message:t(`common.unknownError`)})})},onSettled:()=>c(null)}),y=u({mutationFn:e=>r.trpcClient.capabilities.setActiveSingleton.mutate({capability:e.capName,addonId:e.addonId,nodeId:e.nodeId}),onMutate:e=>{c(e.capName),f(null)},onSuccess:async(e,t)=>{f({kind:`success`,message:`${t.capName} @ ${t.nodeId} → ${t.addonId}.`}),await p.refetch()},onError:(e,n)=>{f({kind:`error`,message:t(`system.capabilities.failedToSetOnNode`,{cap:n.capName,node:n.nodeId,error:e instanceof Error?e.message:t(`common.unknownError`)})})},onSettled:()=>c(null)}),b=u({mutationFn:e=>r.trpcClient.capabilities.clearSingletonNodeOverride.mutate({capability:e.capName,nodeId:e.nodeId}),onMutate:e=>{c(e.capName),f(null)},onSuccess:async(e,n)=>{f({kind:`success`,message:t(`system.capabilities.nowInheritsTheGlobalDefault`,`{{capName}} @ {{nodeId}} now inherits the global default.`,{capName:n.capName,nodeId:n.nodeId})}),await p.refetch()},onError:(e,n)=>{f({kind:`error`,message:t(`system.capabilities.failedToClearOnNode`,{cap:n.capName,node:n.nodeId,error:e instanceof Error?e.message:t(`common.unknownError`)})})},onSettled:()=>c(null)}),x=u({mutationFn:e=>r.trpcClient.capabilities.setCollectionEnabledProviders.mutate({capability:e.capName,enabledAddonIds:[...e.enabledAddonIds]}),onMutate:e=>{c(e.capName),f(null)},onSuccess:async(e,n)=>{f({kind:`success`,message:t(`system.capabilities.providerSEnabled`,`{{capName}}: {{length}} provider(s) enabled.`,{capName:n.capName,length:n.enabledAddonIds.length})}),await p.refetch()},onError:(e,n)=>{f({kind:`error`,message:t(`system.capabilities.failedToUpdate`,{cap:n.capName,error:e instanceof Error?e.message:t(`common.unknownError`)})})},onSettled:()=>c(null)}),S={onSelectSingleton:(e,t)=>_.mutate({capName:e,addonId:t}),onSelectNodeSingleton:(e,t,n)=>y.mutate({capName:e,nodeId:t,addonId:n}),onClearNodeSingleton:(e,t)=>b.mutate({capName:e,nodeId:t}),onToggleCollection:(e,t)=>x.mutate({capName:e,enabledAddonIds:t}),pendingCapability:a};return e(B,{embedded:!0,icon:C,title:t(`system.capabilities.capabilities`,`Capabilities`),subtitle:t(`system.capabilities.chooseWhichProviderIsActive`,`Choose which provider is active for each system capability. Singleton caps pick exactly one provider; collection caps enable a set.`),children:[l&&e(`div`,{className:`flex items-center gap-2 rounded-md border px-3 py-2 text-xs ${l.kind===`success`?`border-success/30 bg-success/10 text-success`:`border-danger/40 bg-danger/10 text-danger`}`,children:[l.kind===`success`?i(v,{className:`h-3.5 w-3.5 shrink-0`}):i(d,{className:`h-3.5 w-3.5 shrink-0`}),i(`span`,{children:l.message})]}),p.isLoading&&i(`div`,{className:`flex items-center justify-center py-16`,children:i(`div`,{className:`animate-spin h-6 w-6 border-2 border-primary border-t-transparent rounded-full`})}),p.isError&&!p.isLoading&&i(j,{title:t(`system.capabilities.failedToLoadCapabilities`,`Failed to load capabilities`),message:p.error instanceof Error?p.error.message:t(`system.capabilities.unknownError`,`Unknown error`),onRetry:()=>void p.refetch()}),!p.isLoading&&!p.isError&&m.length===0&&i(`div`,{className:`text-xs text-foreground-subtle text-center py-16`,children:t(`system.capabilities.noCapabilitiesRegistered`,`No capabilities registered.`)}),!p.isLoading&&!p.isError&&m.length>0&&e(`div`,{className:`space-y-6`,children:[h.length>0&&e(`section`,{className:`space-y-2`,children:[i(`h2`,{className:`text-[11px] font-semibold uppercase tracking-widest text-foreground-subtle/70`,children:t(`system.capabilities.singletonPickOneProvider`,`Singleton — pick one provider`)}),i(rt,{capabilities:h,actions:S})]}),g.length>0&&e(`section`,{className:`space-y-2`,children:[i(`h2`,{className:`text-[11px] font-semibold uppercase tracking-widest text-foreground-subtle/70`,children:t(`system.capabilities.collectionEnableASet`,`Collection — enable a set`)}),i(rt,{capabilities:g,actions:S})]})]})]})}var lt={escape:`Esc`,enter:`Enter`};function ut(e,t){let n=oe(e),r=lt[n.key]??n.key.toUpperCase();return t===`mac`?`${n.alt?`⌥`:``}${n.shift?`⇧`:``}${n.mod?`⌘`:``}${r}`:[...n.mod?[`Ctrl`]:[],...n.alt?[`Alt`]:[],...n.shift?[`Shift`]:[],r].join(`+`)}function dt(){let{t}=z(),n=ie(),r=ae();return i(M,{headingId:`settings-hotkeys`,title:t(`systemPage.settings.hotkeys.title`,`Keyboard shortcuts`),icon:O,testId:`settings-hotkeys`,children:e(`div`,{className:`space-y-2 p-3`,children:[i(`p`,{className:`text-xs text-foreground-subtle`,children:t(`systemPage.settings.hotkeys.description`,`The shortcuts active on this page. They cannot be changed.`)}),n.length===0?i(he,{title:t(`systemPage.settings.hotkeys.empty`,`No shortcuts are active on this page.`)}):n.map(e=>i(F,{label:e.label??t(`systemPage.settings.hotkeys.unnamed`,`Shortcut`),children:i(`kbd`,{className:`rounded-md border border-border bg-surface px-1.5 py-0.5 font-mono text-xs text-foreground`,children:ut(e.combo,r)})},`${e.scope}|${e.combo}`))]})})}c();var ft=[[`system`]];function pt(e){return e.toFixed(6).replace(/0+$/,``).replace(/\.$/,``)}function mt(){let{t}=z(),n=l(),r=pe(),s=le(),c=se(),[u,d]=o(``),[f,p]=o(``),[h,_]=o(null),v=r.data?.location??null;a(()=>{d(v===null?``:pt(v.latitude)),p(v===null?``:pt(v.longitude))},[v]);let y=async()=>{await n.invalidateQueries({queryKey:ft})},b=async e=>{e.preventDefault();let t=Number(u),n=Number(f);if(u.trim()===``||f.trim()===``){_(`Enter both a latitude and a longitude, or press Clear.`);return}if(!Number.isFinite(t)||t<-90||t>90){_(`Latitude must be between -90 and 90 decimal degrees.`);return}if(!Number.isFinite(n)||n<-180||n>180){_(`Longitude must be between -180 and 180 decimal degrees.`);return}_(null),await s.mutateAsync({latitude:t,longitude:n}),await y()},x=async()=>{_(null),await s.mutateAsync(null),await y()},S=async()=>{_(null),await c.mutateAsync(),await y()},C=s.isPending||c.isPending||r.isLoading;return e(fe,{className:`space-y-3`,children:[e(`div`,{className:`flex items-start justify-between gap-3`,children:[e(`div`,{className:`flex items-start gap-2`,children:[i(m,{className:`h-4 w-4 mt-0.5 text-muted-foreground shrink-0`}),i(`div`,{children:i(`h3`,{className:`text-sm font-medium`,children:t(`settings.siteLocationCard.siteLocation`,`Site location`)})})]}),v===null?i(L,{variant:`warning`,children:t(`settings.siteLocationCard.notConfigured`,`Not configured`)}):i(L,{variant:v.source===`operator-set`?`success`:`info`,children:v.source===`operator-set`?t(`settings.siteLocationCard.setByYou`,`Set by you`):t(`settings.siteLocationCard.derivedFromIp`,`Derived from IP`)})]}),v?.label!==void 0&&v.label!==``?i(`p`,{className:`text-xs text-muted-foreground`,children:t(`settings.siteLocationCard.detectedNear`,{place:v.label})}):null,v===null&&r.data?.derivationAttemptedAt!==null?e(`p`,{className:`text-xs text-warning`,children:[t(`settings.siteLocationCard.automaticDetectionFromThePublic`,`Automatic detection from the public IP did not succeed`),r.data?.derivationError!==null&&r.data?.derivationError!==void 0?`: ${r.data.derivationError}`:`.`,` `,t(`settings.siteLocationCard.itIsNotRetriedOn`,`It is not retried on its own — enter the coordinates, or press Detect.`)]}):null,e(`form`,{className:`flex flex-wrap items-end gap-3`,onSubmit:b,children:[e(`label`,{className:`flex flex-col gap-1 text-xs`,children:[i(`span`,{className:`text-muted-foreground`,children:t(`settings.siteLocationCard.latitude`,`Latitude`)}),i(I,{className:`w-40`,value:u,inputMode:`decimal`,placeholder:`40.851800`,onChange:e=>d(e.target.value),"aria-label":t(`settings.siteLocationCard.latitude`,`Latitude`)})]}),e(`label`,{className:`flex flex-col gap-1 text-xs`,children:[i(`span`,{className:`text-muted-foreground`,children:t(`settings.siteLocationCard.longitude`,`Longitude`)}),i(I,{className:`w-40`,value:f,inputMode:`decimal`,placeholder:`14.268100`,onChange:e=>p(e.target.value),"aria-label":t(`settings.siteLocationCard.longitude`,`Longitude`)})]}),i(R,{type:`submit`,disabled:C,children:t(`common.save`,`Save`)}),e(R,{type:`button`,variant:`ghost`,disabled:C,onClick:S,children:[i(g,{className:`h-3.5 w-3.5 mr-1`}),t(`settings.siteLocationCard.detectFromIp`,`Detect from IP`)]}),v===null?null:i(R,{type:`button`,variant:`ghost`,disabled:C,onClick:x,children:t(`settings.siteLocationCard.clear`,`Clear`)})]}),h===null?null:i(`p`,{className:`text-xs text-danger`,children:h}),i(`p`,{className:`text-xs text-muted-foreground`,children:t(`settings.siteLocationCard.wgs84DecimalDegreesDetectAsks`,`WGS84 decimal degrees. Detect asks a public geo-IP service once and will not overwrite a value you typed — clear it first.`)})]})}c();function ht(e){return D.some(t=>t===e)}function gt(e){return me.some(t=>t===e)}function _t(){let{t}=z(),n=ge(),[r,a]=o(!1),[s,c]=o(null),l=e=>{a(!0),c(null),n.update(e).catch(e=>c(e instanceof Error?e.message:String(e))).finally(()=>a(!1))},u=n.status!==`ok`||!n.writable||r;return i(M,{headingId:`settings-units`,title:t(`systemPage.myAccess.units.title`,`Units`),icon:ee,testId:`settings-units`,children:e(`div`,{className:`space-y-2 p-3`,children:[i(`p`,{className:`text-xs text-foreground-subtle`,children:t(`systemPage.myAccess.units.description`,`How readings are shown to you, on every device you sign in on. Stored values do not change.`)}),n.status===`error`&&i(j,{message:t(`systemPage.myAccess.units.loadError`,`Your unit preferences could not be read.`)}),n.status===`ok`&&!n.writable&&i(j,{message:t(`systemPage.myAccess.units.unreadable`,`The saved unit preferences are in a format this version cannot read, so they are left untouched.`)}),s!==null&&i(j,{message:s}),i(F,{label:t(`systemPage.myAccess.units.temperature`,`Temperature`),children:i(x,{"aria-label":t(`systemPage.myAccess.units.temperature`,`Temperature`),value:n.value.temperature,disabled:u,onChange:e=>{let t=e.target.value;gt(t)&&l({temperature:t})},options:[{value:`celsius`,label:t(`systemPage.myAccess.units.celsius`,`Celsius (°C)`)},{value:`fahrenheit`,label:t(`systemPage.myAccess.units.fahrenheit`,`Fahrenheit (°F)`)}]})}),i(F,{label:t(`systemPage.myAccess.units.system`,`Other measurements`),children:i(x,{"aria-label":t(`systemPage.myAccess.units.system`,`Other measurements`),value:n.value.system,disabled:u,onChange:e=>{let t=e.target.value;ht(t)&&l({system:t})},options:[{value:`metric`,label:t(`systemPage.myAccess.units.metric`,`Metric (km/h, hPa, mm)`)},{value:`imperial`,label:t(`systemPage.myAccess.units.imperial`,`Imperial (mph, inHg, in)`)}]})})]})})}function vt(){let{t}=z(),{nodes:n,isLoading:r}=_e(),a=n.find(e=>e.isHub&&e.isOnline);return e(B,{embedded:!0,children:[i(mt,{}),r?i(`div`,{className:`text-foreground-subtle text-sm py-12 text-center`,children:t(`admin.system.settings.loadingHubTopology`,`Loading hub topology…`)}):a?i(Ee,{emptyMessage:t(`admin.system.settings.bootstrapUnavailable`,`Not available — the addon that owns the server settings did not answer.`)}):e(`div`,{className:`flex flex-col items-center justify-center text-foreground-subtle text-sm gap-2 py-12`,children:[i(f,{className:`h-8 w-8 opacity-30`}),i(`p`,{children:t(`admin.system.settings.noOnlineHubNodeFound`,`No online hub node found.`)}),i(`p`,{className:`text-xs`,children:t(`admin.system.settings.settingsWillAppearOnceThe`,`Settings will appear once the hub is reachable.`)})]}),e(`section`,{"aria-labelledby":`settings-per-user`,className:`mt-3 sm:mt-4 space-y-3 sm:space-y-4`,children:[i(`h2`,{id:`settings-per-user`,className:`text-xs font-semibold uppercase tracking-wide text-foreground-subtle`,children:t(`systemPage.settings.perUser`,`Your settings`)}),i(_t,{}),i(dt,{})]})]})}function yt(){let{t:e}=z(),t=be(`/system/settings`,{t:e,isAdmin:!0})??{icon:f,title:e(`system.systemNav`,`System`)},{search:n,hash:r}=we();return new URLSearchParams(n).get(`tab`)===`secrets`?i(xe,{replace:!0,to:`${Se(n)}${r}`}):i(Te,{icon:t.icon,title:t.title,defaultSection:`settings`,sectionsLabel:`${t.title} sections`,sections:[{id:`settings`,label:e(`system.system.settings`,`Settings`),content:i(vt,{})},{id:`capabilities`,label:e(`system.system.capabilities`,`Capabilities`),content:i(ct,{})},{id:`api-explorer`,label:e(`system.system.apiExplorer`),content:i(Ze,{}),ownedParams:[`method`]}]})}export{yt as SystemPage};