@camstack/addon-admin-ui 1.2.456 → 1.2.457

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 (132) hide show
  1. package/dist/assets/{AddonAssetIcon-DKGFFkU1.js → AddonAssetIcon-BOcwQMt3.js} +1 -1
  2. package/dist/assets/Addons-BrsHM2rE.js +4 -0
  3. package/dist/assets/{AdminPage-DRcphXBk.js → AdminPage-0E8EpSO9.js} +1 -1
  4. package/dist/assets/{AdminSectionedPage-DSgwWy9V.js → AdminSectionedPage-CxodN1sn.js} +1 -1
  5. package/dist/assets/AiProfiles-EJziTK6H.js +3 -0
  6. package/dist/assets/{BrokerForm-DQh-oQXM.js → BrokerForm-Dbs6DDhN.js} +1 -1
  7. package/dist/assets/Build-G3WNIoIu.js +40 -0
  8. package/dist/assets/{Calendars-BVNS3qJH.js → Calendars-DwIn1aCE.js} +1 -1
  9. package/dist/assets/{Cluster-Bb3ssLVf.js → Cluster-FzZaIb80.js} +1 -1
  10. package/dist/assets/ClusterStepModel-BKwbYUSr.js +1 -0
  11. package/dist/assets/CompositionEditor-Du0918m6.js +1 -0
  12. package/dist/assets/{CompositionEditorPage-UPZOCUTw.js → CompositionEditorPage-I6-ghm-F.js} +1 -1
  13. package/dist/assets/Data-CWXYjuUH.js +2 -0
  14. package/dist/assets/{DeviceDetail-r7xGh0V5.js → DeviceDetail-DEN9C3es.js} +2 -2
  15. package/dist/assets/{DeviceDoActionFields-CK_hotUV.js → DeviceDoActionFields-XK5u9sG-.js} +1 -1
  16. package/dist/assets/{Devices-D9qIPy3j.js → Devices-CPoElWdX.js} +1 -1
  17. package/dist/assets/{EmbedPlayerPage-CnyoNW1O.js → EmbedPlayerPage-CwqeH_Vp.js} +1 -1
  18. package/dist/assets/History-146ywVRO.js +1 -0
  19. package/dist/assets/Identity-NsWnwCVn.js +1 -0
  20. package/dist/assets/IntegrationDetail-CUffTwqo.js +1 -0
  21. package/dist/assets/{IntegrationHub-PQzIoW-z.js → IntegrationHub-DAndpOVJ.js} +1 -1
  22. package/dist/assets/{Integrations-97rH5eud.js → Integrations-DaNoA1oi.js} +1 -1
  23. package/dist/assets/Integrations-DrSNiPXr.js +1 -0
  24. package/dist/assets/Library-BMJeDfUP.js +1 -0
  25. package/dist/assets/Locations-DpWQPPRR.js +3 -0
  26. package/dist/assets/{Logs-CKiP2BRT.js → Logs-ClfIrCg_.js} +1 -1
  27. package/dist/assets/{MaskShapeCanvas-DWXNtDDM.js → MaskShapeCanvas-BACSOVPv.js} +1 -1
  28. package/dist/assets/{MotionZonesSettings-DJd0Y31u.js → MotionZonesSettings-C-BWiqKl.js} +1 -1
  29. package/dist/assets/{MyAccess-B_R_Psa6.js → MyAccess-B2mddc8z.js} +1 -1
  30. package/dist/assets/{Network-T6uv6aRS.js → Network-CCpscaUS.js} +1 -1
  31. package/dist/assets/{NodeAddonsSettingsPanel-UU1LJcnK.js → NodeAddonsSettingsPanel-J8GvbAOS.js} +1 -1
  32. package/dist/assets/Notifications-CJvDmENV.js +1 -0
  33. package/dist/assets/{PrivacyMaskSettings-DxMOo9HB.js → PrivacyMaskSettings-_hgbaRHe.js} +1 -1
  34. package/dist/assets/Recordings-CmuOayrH.js +1 -0
  35. package/dist/assets/{ScanNetworkModal-Cf68s1om.js → ScanNetworkModal-CHpDtEMN.js} +1 -1
  36. package/dist/assets/{SceneMonitorEditor-BiawWZG0.js → SceneMonitorEditor-DNX5LjxD.js} +1 -1
  37. package/dist/assets/{SessionsList-Dt8jP4yn.js → SessionsList-CO2JCtUA.js} +2 -2
  38. package/dist/assets/{Showroom-qUHeS3m7.js → Showroom-C1Cx5rmM.js} +1 -1
  39. package/dist/assets/System-8QdXWXlv.js +1 -0
  40. package/dist/assets/{Terminal-Cju5rV2v.js → Terminal-D-QqW5OC.js} +5 -5
  41. package/dist/assets/{Viewer-YynlXnis.js → Viewer-DEkhIs_o.js} +1 -1
  42. package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-03dAXb2d.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-DXRH_g5-.js} +1 -1
  43. package/dist/assets/{addon-icons-context-BRjz6lXp.js → addon-icons-context-r4-8qNuL.js} +1 -1
  44. package/dist/assets/{archive-C86NKLhj.js → archive-CHNksUXE.js} +1 -1
  45. package/dist/assets/{authed-media-DNvCU5gQ.js → authed-media-CLfNNAcR.js} +1 -1
  46. package/dist/assets/{bell-off-CLM0BeeE.js → bell-off-BQUuLgGa.js} +1 -1
  47. package/dist/assets/{board-model-CGfpWX1e.js → board-model-CCKjMnih.js} +1 -1
  48. package/dist/assets/{boxes-D5kVpHYR.js → boxes-OM3WXXCF.js} +1 -1
  49. package/dist/assets/circle-slash-B-qX3Tzf.js +1 -0
  50. package/dist/assets/client-Tf7DwHzR.js +358 -0
  51. package/dist/assets/{cloud-upload-BzujuqId.js → cloud-upload-DnQzN7Zu.js} +1 -1
  52. package/dist/assets/crop-BXCCBrRT.js +1 -0
  53. package/dist/assets/{device-integration-icon-FcBNNpTA.js → device-integration-icon-T6DuiFIe.js} +1 -1
  54. package/dist/assets/device-picker-model-CJDjbyFR.js +1 -0
  55. package/dist/assets/dist-COc-M7x5.js +358 -0
  56. package/dist/assets/{dist-DfKbyUlI.js → dist-DWpE4F9Y.js} +1 -1
  57. package/dist/assets/{eraser-DbfQdK9E.js → eraser-2zvTICay.js} +1 -1
  58. package/dist/assets/{hard-drive-download-BZLuYqC1.js → hard-drive-download-BuPae4i9.js} +1 -1
  59. package/dist/assets/{hostInit-CkedGVrn.js → hostInit-B0H8YgMs.js} +1 -1
  60. package/dist/assets/i18n-dPXh_JKN.js +1 -0
  61. package/dist/assets/{icons-CR-DXZNQ.js → icons-Bf1g4TTU.js} +1 -1
  62. package/dist/assets/index-BGRimCPP.css +2 -0
  63. package/dist/assets/index-k7RW-84l.js +4 -0
  64. package/dist/assets/{key-round-HqP_LM9P.js → key-round-PVl1EIeU.js} +1 -1
  65. package/dist/assets/{key-Dlm_jdT1.js → key-y1dQIrgn.js} +1 -1
  66. package/dist/assets/{layers-73PWVjHZ.js → layers-BvTBL45e.js} +1 -1
  67. package/dist/assets/{linked-devices-model-CtpdAdgc.js → linked-devices-model-NEAloVak.js} +1 -1
  68. package/dist/assets/{list-ordered-DuUItJBm.js → list-ordered-Cy6LNkX7.js} +1 -1
  69. package/dist/assets/{location-owned-usage-ej64Ij_c.js → location-owned-usage-COJFqP2Z.js} +1 -1
  70. package/dist/assets/{log-in-BnTC3lpA.js → log-in-C8bG6uHT.js} +1 -1
  71. package/dist/assets/{memory-stick-CFvegwjZ.js → memory-stick-DgCbrom_.js} +1 -1
  72. package/dist/assets/{message-square-plus-D19WKqRB.js → message-square-plus-T2Q-JaNP.js} +1 -1
  73. package/dist/assets/{mf-entry-bootstrap-0-8e777e33.js → mf-entry-bootstrap-0-fa03047b.js} +2 -2
  74. package/dist/assets/{mic-off-BikPboNB.js → mic-off-CQXTB132.js} +1 -1
  75. package/dist/assets/{monitor-off-Bg-VBYZ_.js → monitor-off-CvP-Xwqs.js} +1 -1
  76. package/dist/assets/{monitor-smartphone-C--c1kfN.js → monitor-smartphone-DgPyh0bq.js} +1 -1
  77. package/dist/assets/mount-CJDjbyFR.js +1 -0
  78. package/dist/assets/notification-schedule-field-DXLce27m.js +1 -0
  79. package/dist/assets/{player-overlays-CRBEyRbr.js → player-overlays-DTcu3p6k.js} +1 -1
  80. package/dist/assets/{recycle-DOHVzhvg.js → recycle-BgfATMDb.js} +1 -1
  81. package/dist/assets/remoteEntry-T1NwEQgU.js +1 -0
  82. package/dist/assets/{scan-eye-m2aAerVb.js → scan-eye-Cw7uLDDg.js} +1 -1
  83. package/dist/assets/{scissors-C0kFwmt4.js → scissors-GZwoMkJz.js} +1 -1
  84. package/dist/assets/{search-x-C1Zu06fo.js → search-x-mGDaYxQw.js} +1 -1
  85. package/dist/assets/{send-DGFOkxsu.js → send-B4zTG8IX.js} +1 -1
  86. package/dist/assets/{settings-2-B9EvM-5F.js → settings-2-7MkaO5_9.js} +1 -1
  87. package/dist/assets/{speaker-lMBay1CD.js → speaker-iZgcW4qe.js} +1 -1
  88. package/dist/assets/src-CxF5mieK.js +67 -0
  89. package/dist/assets/{timer-reset-DQlkGcOB.js → timer-reset-CZOKA6Qu.js} +1 -1
  90. package/dist/assets/{ungroup-CiuolLZx.js → ungroup-CmTgkman.js} +1 -1
  91. package/dist/assets/{unlink-S1qKy8_1.js → unlink-DgTv7GBL.js} +1 -1
  92. package/dist/assets/{usb-BrpBB1_Y.js → usb-CDpFB3qV.js} +1 -1
  93. package/dist/assets/{use-scenes-feed-91m9645S.js → use-scenes-feed-Xf26vjq3.js} +1 -1
  94. package/dist/assets/{use-stationary-objects-fCdo-oR4.js → use-stationary-objects-piZ9a4go.js} +1 -1
  95. package/dist/assets/useEventInvalidation-CJDjbyFR.js +1 -0
  96. package/dist/assets/{useNodeUrlSelection-CDosE56A.js → useNodeUrlSelection-Bmr7pzZ8.js} +1 -1
  97. package/dist/assets/user-round-XpdQk1Uf.js +1 -0
  98. package/dist/assets/{user-x-DLZWkjil.js → user-x-DG-dacDQ.js} +1 -1
  99. package/dist/assets/{video-Bu3o7z_A.js → video-DSWn6X4v.js} +1 -1
  100. package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-DXKYo8xB.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-9bgJ3bqj.js} +2 -2
  101. package/dist/index.html +11 -11
  102. package/dist/server/addon.js +6757 -1412
  103. package/package.json +1 -1
  104. package/dist/assets/Addons-f6INIGNk.js +0 -4
  105. package/dist/assets/AiProfiles-B6Wxjm7J.js +0 -3
  106. package/dist/assets/Build-C1E3G4Li.js +0 -40
  107. package/dist/assets/ClusterStepModel-BTonEQ8Q.js +0 -1
  108. package/dist/assets/CompositionEditor-ClnrKef1.js +0 -1
  109. package/dist/assets/Data-CMmaSXTq.js +0 -2
  110. package/dist/assets/History-Bu-xlBT6.js +0 -1
  111. package/dist/assets/Identity-uOmwWcOV.js +0 -1
  112. package/dist/assets/IntegrationDetail-0gsMfR07.js +0 -1
  113. package/dist/assets/Integrations-CjQ8VMPF.js +0 -1
  114. package/dist/assets/Library-DlZO8qd2.js +0 -1
  115. package/dist/assets/Locations-C5D3OkBO.js +0 -3
  116. package/dist/assets/Notifications-BW3LX1UG.js +0 -1
  117. package/dist/assets/Recordings-Clc8K8NN.js +0 -1
  118. package/dist/assets/System-CdmK8YJa.js +0 -1
  119. package/dist/assets/circle-slash-D3Ys-mWm.js +0 -1
  120. package/dist/assets/client-Cif6ZNXf.js +0 -358
  121. package/dist/assets/crop-BhaNBRht.js +0 -1
  122. package/dist/assets/device-picker-model-BeeSEnbH.js +0 -1
  123. package/dist/assets/dist-D34XdNk-.js +0 -358
  124. package/dist/assets/i18n-D4s8z86g.js +0 -1
  125. package/dist/assets/index-DLqV2Uxg.css +0 -2
  126. package/dist/assets/index-DbU7nBkH.js +0 -4
  127. package/dist/assets/mount-BeeSEnbH.js +0 -1
  128. package/dist/assets/notification-schedule-field-CqjG-5hF.js +0 -1
  129. package/dist/assets/remoteEntry--AbYLxqH.js +0 -1
  130. package/dist/assets/src-X6CKvVYm.js +0 -67
  131. package/dist/assets/useEventInvalidation-BeeSEnbH.js +0 -1
  132. package/dist/assets/user-round-DegbdwtA.js +0 -1
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-Cyuzqnbw.js";import{$ as t,B as n,G as r,J as i,L as a,S as o,b as s,i as c,o as l,p as u,q as d,x as f}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEHpkaJP.js";import{A as p,D as m,Fr as h,It as g,N as _,Nn as v,Nt as y,O as b,Or as x,T as S,V as C,Xn as w,Xr as T,Zt as E,_t as D,b as O,bn as k,cn as A,dn as j,dt as M,ir as N,j as P,k as F,mn as I,or as L,ot as R,rr as ee,sa as z,ta as te,ur as B,ut as V,v as ne,xi as re,xn as ie,y as ae,yi as oe,z as H}from"./player-overlays-DTcu3p6k.js";import{$i as se,$n as ce,Gn as le,Hi as ue,Jn as de,Qn as fe,Xn as pe,Yn as me,Zn as he,d as ge,er as _e,g as ve,gi as ye,hi as be,qn as xe,u as Se}from"./client-Tf7DwHzR.js";import{l as Ce,t as we,u as Te}from"./video-DSWn6X4v.js";import{a as Ee,i as De,n as Oe,r as ke,t as Ae}from"./usb-CDpFB3qV.js";import{t as je}from"./crop-BXCCBrRT.js";import{t as Me}from"./layers-BvTBL45e.js";import{n as Ne}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_trpc_mf_1_react_mf_2_query__loadShare__.js-DdJYWyu3.js";import{$n as Pe,$u as Fe,Ac as Ie,Ar as Le,Bn as Re,Bu as ze,Cc as Be,Dc as Ve,Ec as He,Fn as Ue,Gc as We,Gn as Ge,Hn as Ke,In as qe,J as Je,Jc as Ye,Jr as Xe,Ju as U,K as Ze,Kc as Qe,Ln as $e,Mc as et,Mn as tt,Nc as nt,Nu as rt,Oc as it,Ou as at,Pc as ot,Pn as st,Pu as ct,Q as lt,Qn as ut,Qu as dt,Rn as ft,Rr as W,Sc as pt,Sn as mt,St as ht,Uc as gt,Vn as _t,Vu as vt,Wc as yt,Wn as bt,Wt as xt,X as St,Xc as Ct,Xu as wt,Y as Tt,Yu as Et,Za as Dt,Zn as Ot,Zr as kt,Zt as At,Zu as jt,_n as Mt,ac as Nt,an as Pt,bc as Ft,bn as It,cc as Lt,dc as Rt,er as zt,fr as Bt,gn as Vt,gt as Ht,hc as Ut,hr as G,ic as Wt,ir as Gt,jc as Kt,jn as qt,lc as Jt,ln as Yt,mn as K,mt as Xt,nc as Zt,nr as Qt,oc as $t,pr as en,q as tn,qc as nn,qr as rn,r as an,rc as on,rr as sn,sc as cn,st as ln,tr as un,uc as dn,wc as fn,xn as pn,xt as mn,yc as hn}from"./src-CxF5mieK.js";import{t as q}from"./i18n-dPXh_JKN.js";import{t as J}from"./useTranslation-D3Is_4B6.js";import{G as gn,Q as _n,Z as vn,nt as yn}from"./index-k7RW-84l.js";import"./useEventInvalidation-CJDjbyFR.js";import{t as bn}from"./NodeAddonsSettingsPanel-J8GvbAOS.js";import{a as xn,c as Sn,d as Cn,g as wn,h as Tn,i as En,l as Dn,n as On,o as kn,p as An,r as jn,s as Mn,t as Nn}from"./board-model-CCKjMnih.js";var Pn=`step`,Fn=[Pn,`acc`];function In(e,t){return`${e}/${t}`}function Ln(e,t,n){let r=n.step!==null&&e.includes(n.step),i=n.acc!==null&&t.includes(n.acc);return{stepId:r?n.step:null,acceleratorId:i?n.acc:null,staleStepId:n.step!==null&&n.step!==``&&!r&&e.length>0?n.step:null}}function Rn(e){if(e==null)return null;if(typeof e==`number`)return e>0?e:null;let t=Date.parse(e);return Number.isNaN(t)?null:t}function zn(e){return e}function Bn(e,t){for(let[n,r]of Object.entries(e??{}))if(n===t)return r}function Vn(e,t){return typeof e==`boolean`?e:zn(t)}function Hn(e,t){return{pipeline:Vn(Bn(e,`detect`),t),audio:Vn(Bn(e,`audio`),t),ingest:Vn(Bn(e,`ingest`),t)}}function Un(e,t,n){let r=e?.find(e=>e.nodeId===t);return Hn(r?.settings,n)}function Wn({selectedNodeId:e,onSelect:t,refreshToken:n}){let r=z(),{t:i}=J(),{nodes:a}=Et(),{data:c}=pt(void 0),{data:l}=He(void 0),u=new Map;for(let e of c??[])u.set(e.agentNodeId,(u.get(e.agentNodeId)??0)+1);let d=a??[],p=d.filter(e=>e.isOnline).length,m=d.filter(e=>!e.isOnline).length;return o(`div`,{className:`flex flex-col h-full`,children:[o(`button`,{type:`button`,onClick:()=>t(Ko),className:`flex items-center gap-3 px-4 py-3 border-b border-border text-left transition-colors ${e===`__cluster__`?`bg-primary/10 text-primary`:`text-foreground hover:bg-surface-hover`}`,children:[f(Ce,{className:`h-4 w-4 flex-shrink-0`}),o(`div`,{className:`min-w-0 flex-1`,children:[f(`div`,{className:`text-xs font-semibold truncate`,children:i(`pipeline.nodeList.cluster`,`Cluster`)}),f(`div`,{className:`text-[10px] text-foreground-subtle`,children:i(`pipeline.nodeList.assignmentsLoadBalancingRoles`,`Assignments, load balancing, roles`)})]})]}),f(`div`,{className:`flex-1 overflow-y-auto`,children:d.map(n=>{let a=e===n.id,c=u.get(n.id)??0,d=n.isHub?j:T,p=Un(l,n.id,n.isHub),m=n.isOnline?null:xt(Rn(n.lastSeen),r);return o(`button`,{type:`button`,onClick:()=>t(n.id),className:`flex items-center gap-3 w-full px-4 py-3 border-b border-border text-left transition-colors ${a?`bg-primary/10 text-primary`:`text-foreground hover:bg-surface-hover`}${n.isOnline?``:` opacity-60`}`,children:[f(d,{className:`h-4 w-4 flex-shrink-0`}),o(`div`,{className:`min-w-0 flex-1`,children:[o(`div`,{className:`flex items-center gap-2`,children:[f(`span`,{className:`text-xs font-semibold truncate`,children:n.name}),n.isHub&&f(`span`,{className:`text-[9px] uppercase tracking-wider text-foreground-subtle border border-border rounded px-1 py-0.5`,children:i(`common.hubWord`)}),!n.isOnline&&f(`span`,{className:`h-1.5 w-1.5 rounded-full bg-danger flex-shrink-0`}),n.isOnline&&f(`span`,{className:`h-1.5 w-1.5 rounded-full bg-success flex-shrink-0`})]}),o(`div`,{className:`text-[10px] text-foreground-subtle flex items-center gap-2 mt-0.5`,children:[f(`span`,{children:i(`common.coresCount`,{count:n.cpuCores})}),f(`span`,{children:`•`}),o(`span`,{children:[Math.round(n.memoryMB/1024),` GB`]}),c>0&&o(s,{children:[f(`span`,{children:`•`}),o(`span`,{className:`inline-flex items-center gap-0.5 text-foreground`,children:[f(we,{className:`h-2.5 w-2.5`}),c]})]}),!n.isOnline&&o(s,{children:[f(`span`,{children:`•`}),o(`span`,{className:`text-danger`,children:[i(`common.offline`),m===null?``:` · ${m}`]})]})]}),o(`div`,{className:`mt-0.5 flex items-center gap-1`,children:[f(W,{variant:p.pipeline?`success`:`danger`,className:`px-1 py-0 text-[9px] leading-3`,title:p.pipeline?i(`pipeline.nodeList.pipelineEnabled`,`Pipeline: enabled`):i(`pipeline.nodeList.pipelineNotEnabledAgentCapability`,`Pipeline: not enabled (agent capability)`),children:i(`pipeline.nodeList.pipe`,`Pipe`)}),f(W,{variant:p.audio?`success`:`danger`,className:`px-1 py-0 text-[9px] leading-3`,title:p.audio?i(`pipeline.nodeList.audioEnabled`,`Audio: enabled`):i(`pipeline.nodeList.audioNotEnabledAgentCapability`,`Audio: not enabled (agent capability)`),children:i(`pipeline.nodeList.aud`,`Aud`)})]})]})]},n.id)})}),o(`div`,{className:`px-4 py-2 border-t border-border text-[10px] text-foreground-subtle flex items-center justify-between`,children:[f(`span`,{children:i(`common.onlineCount`,{count:p})}),m>0&&f(`span`,{className:`text-danger`,children:i(`common.offlineCount`,{count:m})})]})]})}function Gn({nodeId:e,refreshToken:t}){let{t:n}=J(),{nodes:r}=Et(),i=r?.find(t=>t.id===e),a=wt(`pipeline.runner-load-snapshot`,t=>t.nodeId===e)?.load??null;return i?o(`div`,{className:`px-6 py-4 border-b border-border`,children:[o(`div`,{className:`flex items-center gap-2 mb-1`,children:[f(`h2`,{className:`text-base font-semibold text-foreground`,children:i.name}),i.isOnline?f(`span`,{className:`text-[10px] px-2 py-0.5 rounded-full bg-success/10 text-success`,children:n(`common.online`)}):f(`span`,{className:`text-[10px] px-2 py-0.5 rounded-full bg-danger/10 text-danger`,children:n(`common.offline`)}),i.isHub&&f(`span`,{className:`text-[9px] uppercase tracking-wider text-foreground-subtle border border-border rounded px-1 py-0.5`,children:n(`common.hubWord`)})]}),o(`div`,{className:`text-[11px] text-foreground-subtle flex items-center gap-2 flex-wrap`,children:[f(`span`,{children:i.cpuModel??`CPU`}),f(`span`,{children:`•`}),f(`span`,{children:n(`common.coresCount`,{count:i.cpuCores})}),f(`span`,{children:`•`}),o(`span`,{children:[Math.round(i.memoryMB/1024),` GB`]}),a&&o(s,{children:[f(`span`,{children:`•`}),f(`span`,{children:n(`pipeline.nodeDetailHeader.cameras`,{attached:a.attachedCameras,active:a.activeCameras})}),f(`span`,{children:`•`}),f(`span`,{children:n(`pipeline.nodeDetailHeader.avgInference`,{ms:a.avgInferenceTimeMs.toFixed(0)})}),f(`span`,{children:`•`}),f(`span`,{children:n(`pipeline.nodeDetailHeader.queue`,{depth:a.queueDepthTotal})}),a.hardware.hasGpu&&o(s,{children:[f(`span`,{children:`•`}),f(`span`,{className:`text-success`,children:`GPU`})]})]})]})]}):f(`div`,{className:`px-6 py-4 border-b border-border`,children:o(`div`,{className:`text-xs text-foreground-subtle`,children:[n(`pipeline.nodeDetailHeader.nodeNotFound`,`Node not found:`),` `,e]})})}var Kn=[`assignments`,`tree`,`engines`,`logs`];t();function qn({refreshToken:e,nodeId:t}){let{t:n}=J(),[a,s]=i(new Map),{nodes:c}=U();dt(`pipeline.camera-metrics-snapshot`,e=>{let t=e.data;typeof t?.deviceId==`number`&&s(e=>{let n=new Map(e);return n.set(t.deviceId,t),n})});let{data:l}=Rt(void 0),u=r(()=>{let e=new Map;for(let t of l??[])e.set(t.nodeId,t.deviceCount);return e},[l]),d=r(()=>{let e=new Map,t=Date.now()-3e4;for(let n of a.values()){if(n.timestamp<t)continue;let r=n.nodeId??`hub`,i=e.get(r)??{attachedCameras:0,activeCameras:0,totalFps:0,totalInferenceWeighted:0,queueDepth:0};i.attachedCameras++,n.metrics.phase===`active`&&i.activeCameras++,i.totalFps+=n.metrics.actualFps,i.totalInferenceWeighted+=n.metrics.avgInferenceTimeMs,i.queueDepth+=n.metrics.queueDepth,e.set(r,i)}return e},[a]),p=r(()=>{let e=new Map;for(let t of c)e.set(t.id,t.shortName);return e},[c]),m=r(()=>{let e=0,t=0,n=0,r=0,i=0;for(let a of d.values())e+=a.attachedCameras,t+=a.activeCameras,n+=a.totalFps,r+=a.totalInferenceWeighted,i+=a.queueDepth;let a=e>0?r/e:0;return{totalAgents:c.length,onlineAgents:c.filter(e=>e.isOnline).length,attachedCameras:e,activeCameras:t,avgInferenceTimeMs:a,queueDepth:i,totalFps:n}},[d,c]);if(t){let e=d.get(t);return o(`div`,{className:`@container/liveload`,children:[f(`h3`,{className:`text-sm font-semibold text-foreground mb-2`,children:n(`pipeline.liveLoadPanel.liveLoad`,`Live load`)}),o(`div`,{className:`grid grid-cols-2 @md/liveload:grid-cols-3 @3xl/liveload:grid-cols-5 gap-2 mb-3`,children:[f(Y,{label:`FPS`,value:e?e.totalFps.toFixed(1):`—`}),f(Y,{label:n(`pipeline.liveLoadPanel.activeAttached`,`Active / Attached`),value:e?`${e.activeCameras}/${e.attachedCameras}`:`—`}),f(Y,{label:n(`pipeline.liveLoadPanel.avgInferMs`,`Avg infer ms`),value:e&&e.attachedCameras>0?(e.totalInferenceWeighted/e.attachedCameras).toFixed(0):`—`}),f(Y,{label:n(`pipeline.liveLoadPanel.queue`,`Queue`),value:e?String(e.queueDepth):`—`}),f(Y,{label:n(`pipeline.liveLoadPanel.audio`,`Audio`),value:String(u.get(t)??`—`)})]})]})}let h=[...d.entries()].toSorted(([e],[t])=>e===`hub`?-1:t===`hub`?1:e.localeCompare(t));return o(`div`,{className:`@container/liveload`,children:[f(`h3`,{className:`text-sm font-semibold text-foreground mb-2`,children:n(`pipeline.liveLoadPanel.liveLoad`,`Live load`)}),o(`div`,{className:`grid grid-cols-2 @md/liveload:grid-cols-3 @3xl/liveload:grid-cols-5 gap-2 sm:gap-3 mb-3`,children:[f(Y,{label:n(`pipeline.liveLoadPanel.totalAgents`,`Total agents`),value:`${m.onlineAgents}/${m.totalAgents}`}),f(Y,{label:n(`pipeline.liveLoadPanel.activeAttached`,`Active / Attached`),value:`${m.activeCameras}/${m.attachedCameras}`}),f(Y,{label:n(`pipeline.liveLoadPanel.totalFps`,`Total FPS`),value:m.totalFps.toFixed(1)}),f(Y,{label:n(`pipeline.liveLoadPanel.avgInferenceMs`,`Avg inference ms`),value:m.avgInferenceTimeMs.toFixed(0)}),f(Y,{label:n(`pipeline.liveLoadPanel.queueDepth`,`Queue depth`),value:String(m.queueDepth)})]}),f(`div`,{className:`rounded-lg border border-border overflow-x-auto`,children:o(`table`,{className:`w-full text-xs min-w-[480px]`,children:[f(`thead`,{className:`bg-surface`,children:o(`tr`,{className:`text-foreground-subtle text-[10px] uppercase tracking-wider`,children:[f(`th`,{className:`text-left px-3 py-2`,children:n(`pipeline.liveLoadPanel.agent`,`Agent`)}),f(`th`,{className:`text-right px-3 py-2`,children:`FPS`}),f(`th`,{className:`text-right px-3 py-2`,children:n(`pipeline.liveLoadPanel.cameras`,`Cameras`)}),f(`th`,{className:`text-right px-3 py-2`,children:n(`pipeline.liveLoadPanel.inferenceMs`,`Inference ms`)}),f(`th`,{className:`text-right px-3 py-2`,children:n(`pipeline.liveLoadPanel.queue`,`Queue`)}),f(`th`,{className:`text-right px-3 py-2`,children:n(`pipeline.liveLoadPanel.audio`,`Audio`)})]})}),o(`tbody`,{children:[h.map(([e,t])=>o(`tr`,{className:`border-t border-border`,children:[f(`td`,{className:`px-3 py-2 text-foreground font-medium`,children:p.get(e)??e}),f(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t.totalFps.toFixed(1)}),f(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t.attachedCameras}),f(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t.attachedCameras>0?(t.totalInferenceWeighted/t.attachedCameras).toFixed(0):`—`}),f(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t.queueDepth}),f(`td`,{className:`px-3 py-2 text-right text-foreground`,children:u.get(e)??`—`})]},e)),h.length===0&&f(`tr`,{children:f(`td`,{colSpan:6,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:n(`pipeline.liveLoadPanel.noCameraMetricsReceivedYet`,`No camera metrics received yet`)})})]})]})})]})}function Y({label:e,value:t}){return o(`div`,{className:`rounded-lg border border-border bg-surface/60 p-3`,children:[f(`div`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle mb-1`,children:e}),f(`div`,{className:`text-lg font-semibold text-foreground`,children:t})]})}var Jn={active:!1,pinned:!1,nodeId:null,reason:``};function Yn(e,t){return e.deviceName.localeCompare(t.deviceName)||e.deviceId-t.deviceId}function Xn(e,t,n){let r=new Map(t.map(e=>[e.deviceId,e])),i=new Map(n.map(e=>[e.deviceId,e]));return e.map(e=>{let t=r.get(e.id),n=i.get(e.id),a=t?{active:!0,pinned:t.pinned,nodeId:t.agentNodeId,reason:t.reason??``}:Jn,o=n?{active:!0,pinned:n.pinned,nodeId:n.nodeId,reason:``}:Jn;return{deviceId:e.id,deviceName:e.name,disabled:e.disabled===!0,pipeline:a,detection:a,decoder:Jn,audio:o}}).toSorted(Yn)}function Zn(e,t,n){return{active:e!==null,pinned:t,nodeId:e,reason:n??``}}function Qn(e,t){let n=new Map(t.map(e=>[e.deviceId,e.assignment]));return e.map(e=>{let t=n.get(e.deviceId);return t===void 0?e:{...e,detection:Zn(t.detectionNodeId,t.pinned.detection,t.reasons.detection),decoder:Zn(t.decoderNodeId,t.pinned.decoder,t.reasons.decoder),audio:Zn(t.audioNodeId,t.pinned.audio,t.reasons.audio)}})}function $n(e,t,n){let r=(t,n,r)=>({active:t!==null&&t===e,pinned:n,nodeId:t,reason:r??``});return t.map(({deviceId:e,assignment:t})=>({deviceId:e,deviceName:n(e),detection:r(t.detectionNodeId,t.pinned.detection,t.reasons.detection),decoder:r(t.decoderNodeId,t.pinned.decoder,t.reasons.decoder),audio:r(t.audioNodeId,t.pinned.audio,t.reasons.audio)})).filter(e=>e.detection.active||e.decoder.active||e.audio.active).toSorted(Yn)}function er(e){let t=new Map(e.map(e=>[e.id,e.name]));return e=>{let n=t.get(e);return n!==void 0&&n!==``?n:e}}function tr(e){let t=new Map(e.map(e=>[e.id,e.name]));return e=>t.get(e)??q.t(`helpers.assignmentRows.cameraFallback`,{id:e})}function nr(e,t,n){let r=[...new Set([...e.nodeId===null?[]:[e.nodeId],...t.map(e=>e.id)])];return[{value:`auto`,label:q.t(`helpers.assignmentRows.auto`)},...r.map(e=>({value:e,label:q.t(`helpers.assignmentRows.pinTo`,{node:n(e)})}))]}function rr({roleId:e,roleLabel:t,state:n,nameOf:r,colorByNodeId:i,emphasizeOnNodeId:a}){if(n.nodeId===null)return null;let o=n.nodeId,s=a===void 0?!1:n.active&&o===a;return f(It,{roleId:e,roleLabel:t,nodeName:r(o),colorId:mt(i,o),emphasized:s,pinned:n.pinned})}function ir({detection:e,decoder:t,audio:n,nameOf:r,colorByNodeId:i,emphasizeOnNodeId:a}){let s=(e,t,n)=>f(rr,{roleId:e,roleLabel:t,state:n,nameOf:r,colorByNodeId:i,emphasizeOnNodeId:a},e);return o(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1.5`,children:[s(`detection`,`Detection`,e),s(`decode`,`Decode`,t),s(`audio`,`Audio`,n)]})}function ar({snap:e}){let t=z(),{t:n}=J();if(e===void 0)return f(`div`,{className:`flex h-8 items-center text-[11px] text-foreground-subtle`,title:n(`assignments.assignmentStatusCell.noMetricsInTheLast`,`No metrics in the last 10 s — the camera has no session running`),children:n(`assignments.assignmentStatusCell.noLiveData`,`no live data`)});let{phase:r,actualFps:i,avgInferenceTimeMs:a,queueDepth:s,configuredFps:c,droppedFrames:l}=e.metrics,u=Pt(r,t);return o(`div`,{className:`flex h-8 min-w-0 flex-col justify-center font-mono text-[10px] leading-tight tabular-nums`,children:[o(`span`,{className:`inline-flex min-w-0 items-center gap-1 ${u.textColor}`,children:[f(ln,{phase:r,className:`h-2.5 w-2.5 shrink-0`}),f(`span`,{className:`truncate font-semibold uppercase tracking-wider`,children:u.label}),f(`span`,{className:`text-foreground`,children:i.toFixed(1)}),f(`span`,{className:`text-foreground-subtle`,children:n(`pipeline.assignmentStatusCell.configuredFps`,{fps:c.toFixed(0)})})]}),o(`span`,{className:`truncate text-foreground-subtle`,children:[f(`span`,{className:`text-foreground`,children:a.toFixed(0)}),` ms`,s>0&&o(`span`,{className:`ml-1 text-warning`,children:[`q`,s]}),f(`span`,{className:l>0?`ml-1 text-warning`:`ml-1`,children:n(`pipeline.assignmentStatusCell.drops`,{count:l})})]})]})}t();var or=1e4,sr=5e3;function cr(e){let[t,r]=i(new Map);return dt(`pipeline.camera-metrics-snapshot`,t=>{let n=t.data;typeof n.deviceId==`number`&&(e!==void 0&&n.nodeId!==e||r(e=>new Map(e).set(n.deviceId,n)))}),n(()=>{if(t.size===0)return;let e=setInterval(()=>{r(e=>{let t=Date.now()-or,n=[...e].filter(([,e])=>e.timestamp>=t);return n.length===e.size?e:new Map(n)})},sr);return()=>clearInterval(e)},[t.size]),t}var lr=3e5;function ur({state:e,onlineNodes:t,nameOf:n,pending:r,onChange:i}){let{t:a}=J();return f(at,{"aria-label":a(`assignments.placementControls.nodePin`,`Node pin`),title:a(`assignments.placementControls.autoLetsEachSessionPick`,`Auto lets each session pick its node; a pin keeps the camera on one node.`),value:e.pinned&&e.nodeId!==null?e.nodeId:`auto`,disabled:r,options:[...nr(e,t,n)],onChange:e=>i(e.target.value)})}function dr({deviceId:e,nodeId:t}){let{t:n}=J(),r=l(),{data:i}=Be({deviceId:e},{refetchOnMount:`always`}),{data:a}=Ft({nodeId:t},{staleTime:lr}),o=yt({onSuccess:()=>{r.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineDevicePin`]]})}});if(i===void 0||a===void 0)return f(`span`,{className:`text-[10px] italic text-foreground-subtle`,children:n(`assignments.placementControls.accelerator`,`accelerator: …`)});let s=a.devices??[],c=s.filter(e=>e.enabled),u=i?.deviceKey??`auto`,d=u!==`auto`&&!c.some(e=>e.key===u),p=s.find(e=>e.key===u),m=[{value:`auto`,label:n(`assignments.placementControls.anyAccelerator`,`Any accelerator`)},...d?[{value:u,label:n(`pipeline.placementControls.notEnabled`,{name:p?`${bt(p)} (${u})`:u})}]:[],...c.map(e=>({value:e.key,label:`${bt(e)} · ${e.format}`}))];return f(at,{"aria-label":n(`assignments.placementControls.inferenceDevicePin`,`Inference device pin`),title:n(`assignments.placementControls.pinDetectionToOneAccelerator`,`Pin detection to one accelerator of the node, or let each session pick.`),value:u,disabled:o.isPending,options:m,onChange:t=>o.mutate({deviceId:e,deviceKey:t.target.value})})}t();function fr(e){let t=d(null);return e.nodeId!==null&&(t.current=e),t.current}function pr({deviceId:e,state:t,...n}){let{t:r}=J(),i=fr(t);return o(`div`,{className:`grid w-80 grid-cols-2 gap-1.5`,children:[f(ur,{state:t,...n}),i?.nodeId==null?f(at,{"aria-label":r(`assignments.clusterRowCells.inferenceDevicePinNoNode`,`Inference device pin (no node yet)`),title:r(`assignments.clusterRowCells.anAcceleratorIsPinnedOn`,`An accelerator is pinned on the camera's node; this camera has not run on one yet.`),disabled:!0,defaultValue:`auto`,options:[{value:`auto`,label:r(`assignments.clusterRowCells.anyAccelerator`,`Any accelerator`)}]}):f(dr,{deviceId:e,nodeId:i.nodeId})]})}function mr({state:e,nameOf:t}){let{t:n}=J(),r=fr(e);if(r?.nodeId==null)return f(`span`,{className:`text-[11px] text-foreground-subtle`,children:n(`assignments.clusterRowCells.noSessionYet`,`— no session yet`)});let i=e.active&&e.nodeId!==null,a=r.pinned?`pinned`:`auto · ${r.reason||`capacity`}`;return o(`div`,{"data-testid":`resolved-placement`,className:`flex w-40 min-w-0 flex-col leading-tight`,title:r.pinned?void 0:n(`assignments.clusterRowCells.anUnpinnedCameraIsPlaced`,`An unpinned camera is placed again at every session start, so this can change between sessions.`),children:[o(`span`,{className:`flex min-w-0 items-center gap-1.5 text-xs`,children:[f(`span`,{"aria-hidden":!0,className:`h-1.5 w-1.5 shrink-0 rounded-full ${i?`bg-success`:`bg-foreground-subtle/40`}`}),f(`span`,{"data-testid":`resolved-placement-node`,className:`truncate font-medium ${i?`text-foreground`:`text-foreground-muted`}`,children:t(r.nodeId)})]}),f(`span`,{className:`truncate pl-3 text-[10px] ${r.pinned?`text-warning`:`text-foreground-subtle`}`,children:i?a:n(`assignments.clusterRowCells.idleLastSession`,`{{how}} · idle, last session`,{how:a})})]})}function hr({deviceId:e,deviceName:t}){let{t:n}=J(),[r,a]=i(!1);return o(s,{children:[f(ct,{icon:ie,variant:`ghost`,size:`sm`,"aria-label":n(`assignments.clusterRowCells.streamBrokersOf`,`Stream brokers of {{deviceName}}`,{deviceName:t}),title:n(`assignments.clusterRowCells.streamBrokersClients`,`Stream brokers & clients`),onClick:()=>a(!0)}),f(ut,{open:r,onOpenChange:a,children:o(zt,{width:`lg`,scroll:`body`,placement:`sheet-on-mobile`,children:[f(sn,{children:f(Gt,{children:n(`pipeline.clusterRowCells.brokersTitle`,{device:t})})}),f(Pe,{children:r&&f(Ot,{widgetId:`stream-broker/stream-broker-panel`,host:`device-tab`,deviceId:e,instanceId:`pipeline-row/${e}`,config:{variant:`compact`}})})]})})]})}function gr(e){return e.hasFreshMetrics?`active`:e.hasPipelineAssignment?`recently-active`:`inactive`}function _r(e,t){return t.size===0?!0:t.has(e)}var vr=[{value:`active`,get label(){return q.t(`helpers.cameraActivity.active`)}},{value:`recently-active`,get label(){return q.t(`helpers.cameraActivity.recentlyActive`)}},{value:`inactive`,get label(){return q.t(`helpers.cameraActivity.inactive`)}}];t();var yr=[`pipeline.camera-assigned`,`pipeline.camera-unassigned`,`pipeline.camera-updated`,`agent.online`,`agent.offline`];function br(e){for(let t of[`getPipelineAssignments`,`getAudioAssignments`,`getCameraStatuses`])e.invalidateQueries({queryKey:[[`pipelineOrchestrator`,t]]})}function xr(){let{t:e}=J(),t=l();an([`pipelineOrchestrator`,`getPipelineAssignments`],yr),an([`pipelineOrchestrator`,`getAudioAssignments`],yr),an([`pipelineOrchestrator`,`getCameraStatuses`],yr);let{data:n}=Dt({isCamera:!0,projection:`slim`}),{data:a}=pt(void 0),{data:s}=dn(void 0),{data:c}=Ut({}),{data:u}=He(void 0),{nodes:d}=U(),p=cr(),m=r(()=>er(d),[d]),h=r(()=>pn(u),[u]),g=r(()=>d.filter(e=>e.isOnline).map(e=>({id:e.id,name:e.name})),[d]),_=r(()=>Qn(Xn((n??[]).map(e=>({id:e.id,name:e.name,disabled:e.disabled})),a??[],s??[]),c??[]),[n,a,s,c]),[v,y]=i(()=>new Set),b=r(()=>_.filter(e=>_r(gr({hasPipelineAssignment:e.pipeline.active,hasFreshMetrics:p.has(e.deviceId)}),v)),[_,p,v]),x=e=>{y(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},S=()=>br(t),C=cn({onSuccess:S}),w=Ye({onSuccess:S}),T=C.isPending||w.isPending,E=[{key:`camera`,header:e(`pipeline.cameraAssignmentsTable.camera`,`Camera`),width:`w-44`,sortValue:e=>e.deviceName,render:t=>o(`div`,{className:`flex w-44 min-w-0 items-center gap-1.5`,children:[f(_n,{to:`/devices/${String(t.deviceId)}`,className:`min-w-0 truncate text-xs font-medium text-primary hover:underline`,title:t.deviceName,children:t.deviceName}),t.disabled&&f(W,{variant:`default`,children:e(`common.off`)})]})},{key:`placement`,header:e(`pipeline.cameraAssignmentsTable.placement`,`Placement`),width:`w-80`,notSortableReason:`A pair of controls — editing one would move the row under the cursor.`,render:e=>f(pr,{deviceId:e.deviceId,state:e.pipeline,onlineNodes:g,nameOf:m,pending:T,onChange:t=>t===`auto`?w.mutate({deviceId:e.deviceId}):C.mutate({deviceId:e.deviceId,agentNodeId:t})})},{key:`roles`,header:e(`pipeline.cameraAssignmentsTable.rolesHere`,`Roles here`),notSortableReason:`A set of roles has no single order.`,render:e=>f(ir,{detection:e.detection,decoder:e.decoder,audio:e.audio,nameOf:m,colorByNodeId:h})},{key:`resolved`,header:e(`pipeline.cameraAssignmentsTable.runningOn`,`Running on`),width:`w-40`,sortValue:e=>e.pipeline.nodeId===null?null:m(e.pipeline.nodeId),render:e=>f(mr,{state:e.pipeline,nameOf:m})},{key:`status`,header:e(`pipeline.cameraAssignmentsTable.status`,`Status`),width:`w-40`,sortValue:e=>p.get(e.deviceId)?.metrics.actualFps??null,render:e=>f(ar,{snap:p.get(e.deviceId)})},{key:`brokers`,header:``,align:`right`,width:`w-10`,notSortableReason:`An action`,render:e=>f(hr,{deviceId:e.deviceId,deviceName:e.deviceName})}],D=n===void 0?`Loading cameras…`:_.length===0?`No cameras`:`No cameras match this activity filter.`;return o(`div`,{className:`flex flex-col gap-2`,children:[f(`nav`,{"aria-label":e(`pipeline.cameraAssignmentsTable.filterByCameraActivity`,`Filter by camera activity`),"data-testid":`assignments-activity-filter`,children:f(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1.5`,children:vr.map(e=>{let t=v.has(e.value);return f(`button`,{type:`button`,"aria-pressed":t,"data-testid":`assignments-activity-${e.value}`,className:vt(ae,t?ne:O),onClick:()=>x(e.value),children:e.label},e.value)})})}),f(Vt,{columns:E,rows:b,rowKey:e=>e.deviceId,minWidthPx:920,maxBodyHeight:Mt,emptyMessage:D})]})}t();function Sr({nodeId:e}){let{t}=J(),n=l();an([`pipelineOrchestrator`,`getCameraStatuses`],yr);let{data:i}=Ut({}),{data:a}=He(void 0),{data:o}=Dt({isCamera:!0,projection:`slim`}),{nodes:s}=U(),c=cr(),u=r(()=>er(s),[s]),d=r(()=>pn(a),[a]),p=r(()=>$n(e,i??[],tr((o??[]).map(e=>({id:e.id,name:e.name})))),[e,i,o]),m=s.filter(t=>t.isOnline&&t.id!==e),h=()=>br(n),g=cn({onSuccess:h}),_=Ye({onSuccess:h}),v=$t({onSuccess:h}),y=nn({onSuccess:h}),b=e=>[...e.detection.active?m.map(n=>({id:`detect-${n.id}`,label:t(`pipeline.nodeCameraAssignmentsTable.moveDetectionTo`,`Move detection to {{name}}`,{name:n.name}),onClick:()=>g.mutate({deviceId:e.deviceId,agentNodeId:n.id})})):[],...e.audio.active?m.map(n=>({id:`audio-${n.id}`,label:t(`pipeline.nodeCameraAssignmentsTable.moveAudioTo`,`Move audio to {{name}}`,{name:n.name}),onClick:()=>v.mutate({deviceId:e.deviceId,nodeId:n.id})})):[],{id:`unpin-detect`,label:t(`pipeline.nodeCameraAssignmentsTable.unpinDetection`,`Unpin detection`),hidden:!(e.detection.active&&e.detection.pinned),separatorBefore:!0,onClick:()=>_.mutate({deviceId:e.deviceId})},{id:`unpin-audio`,label:t(`pipeline.nodeCameraAssignmentsTable.unpinAudio`,`Unpin audio`),hidden:!(e.audio.active&&e.audio.pinned),onClick:()=>y.mutate({deviceId:e.deviceId})}];return f(Vt,{columns:[{key:`camera`,header:t(`pipeline.nodeCameraAssignmentsTable.camera`,`Camera`),width:`w-44`,sortValue:e=>e.deviceName,render:e=>f(_n,{to:`/devices/${String(e.deviceId)}`,className:`block w-44 truncate text-xs font-medium text-primary hover:underline`,title:e.deviceName,children:e.deviceName})},{key:`roles`,header:t(`pipeline.nodeCameraAssignmentsTable.rolesHere`,`Roles here`),notSortableReason:`A set of roles has no single order.`,render:t=>f(ir,{detection:t.detection,decoder:t.decoder,audio:t.audio,nameOf:u,colorByNodeId:d,emphasizeOnNodeId:e})},{key:`status`,header:t(`pipeline.nodeCameraAssignmentsTable.status`,`Status`),width:`w-40`,sortValue:e=>c.get(e.deviceId)?.metrics.actualFps??null,render:e=>f(ar,{snap:c.get(e.deviceId)})},{key:`actions`,header:``,align:`right`,width:`w-10`,notSortableReason:`Actions`,render:e=>f(Ht,{items:b(e),title:t(`pipeline.nodeCameraAssignmentsTable.move`,`Move {{deviceName}}`,{deviceName:e.deviceName})})}],rows:p,rowKey:e=>e.deviceId,minWidthPx:560,maxBodyHeight:Mt,emptyMessage:i===void 0?t(`pipeline.nodeCameraAssignmentsTable.loadingCameras`,`Loading cameras…`):t(`pipeline.nodeCameraAssignmentsTable.noCameraRunsOnThis`,`No camera runs on this node right now`)})}function Cr({nodeId:e,refreshToken:t}){let{t:n}=J(),{nodes:r}=U(),i=r.find(t=>t.id===e)?.name??e;return o(`div`,{className:`space-y-3 sm:space-y-4`,children:[f(qn,{refreshToken:t,nodeId:e}),o(`div`,{className:`space-y-2`,children:[o(`div`,{children:[f(`h3`,{className:`text-sm font-semibold text-foreground`,children:n(`pipeline.nodeCamerasTab.camerasOn`,{node:i})}),f(`p`,{className:`text-[11px] text-foreground-subtle`,children:n(`pipeline.nodeCamerasTab.theRolesEachCameraRuns`,`The roles each camera runs here right now. Move a role or unpin it from the row menu; pins for every camera are on Cluster → Assignments.`)})]}),f(Sr,{nodeId:e})]})]})}t();function wr(e,t){let n=Math.max(0,t-e),r=Math.floor(e/1e3),i=Math.floor(n/1e3);return q.t(`pipeline.nodeEnginesTab.idleLeft`,{idle:r,left:i})}function Tr({nodeId:e,refreshToken:t}){let{t:n}=J(),i=l(),a=Le(),s=on({onSettled:()=>{i.invalidateQueries({queryKey:[`pipelineExecutor`,`listLoadedEngines`]})}}),{data:c}=Wt({nodeId:e}),u=wt(`pipeline.engine-metrics-snapshot`,t=>t.nodeId===e)?.engines??c??null,d=u===null;an([`pipelineRunner`,`getLocalCameras`],[`pipeline.camera-assigned`,`pipeline.camera-unassigned`]);let{data:p}=Ct({nodeId:e}),{values:m}=jt(`pipeline.camera-metrics-snapshot`,e=>e.deviceId,t=>t.nodeId===e),h=r(()=>m.filter(e=>e.metrics.phase===`active`).length,[m]),_=t=>{let r=p??[];if(r.length===0){s.mutate({nodeId:e,engine:t,force:!1});return}(async()=>{await a({title:n(`pipeline.nodeEnginesTab.killEngine`,`Kill engine`),message:`${String(r.length)} camera(s) are dispatching through this engine. Killing it drops their in-flight work and forces a respawn on the next frame.`,confirmLabel:n(`pipeline.nodeEnginesTab.killEngine`,`Kill engine`),variant:`danger`})&&s.mutate({nodeId:e,engine:t,force:!0})})()};return o(`div`,{className:`space-y-6`,children:[o(`div`,{children:[f(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:n(`pipeline.nodeEnginesTab.inferenceEnginesOnThisNode`,`Inference engines on this node`)}),f(`p`,{className:`text-[11px] text-foreground-subtle`,children:n(`pipeline.nodeEnginesTab.summary`,{engines:(u??[]).length,cameras:(p??[]).length,active:h})})]}),f(`div`,{className:`rounded-lg border border-border overflow-x-auto`,children:o(`table`,{className:`w-full text-xs min-w-[640px]`,children:[f(`thead`,{className:`bg-surface`,children:o(`tr`,{className:`text-foreground-subtle text-[10px] uppercase tracking-wider`,children:[f(`th`,{className:`text-left px-3 py-2 whitespace-nowrap`,children:n(`pipeline.nodeEnginesTab.kind`,`Kind`)}),f(`th`,{className:`text-left px-3 py-2 whitespace-nowrap`,children:n(`pipeline.nodeEnginesTab.runtimeBackendDevice`,`Runtime / Backend / Device`)}),f(`th`,{className:`text-left px-3 py-2`,children:n(`pipeline.nodeEnginesTab.models`,`Models`)}),f(`th`,{className:`text-right px-3 py-2 whitespace-nowrap`,children:n(`pipeline.nodeEnginesTab.poolPid`,`Pool PID`)}),f(`th`,{className:`text-right px-3 py-2 whitespace-nowrap`,children:n(`pipeline.nodeEnginesTab.autoKill`,`Auto-kill`)}),f(`th`,{className:`text-right px-3 py-2 whitespace-nowrap`,children:n(`pipeline.nodeEnginesTab.inUse`,`In use`)}),f(`th`,{className:`w-20`})]})}),o(`tbody`,{children:[d&&f(`tr`,{children:f(`td`,{colSpan:7,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:n(`common.loading`,`Loading…`)})}),!d&&(u??[]).map(e=>{let t=e.kind===`device-pool`;return o(`tr`,{className:`border-t border-border ${t?`bg-primary/[0.05]`:``}`,children:[f(`td`,{className:`px-3 py-2`,children:o(`span`,{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded-full text-[10px] font-medium ${t?`bg-primary/15 text-primary`:`bg-success/15 text-success`}`,children:[f(t?Me:T,{className:`h-3 w-3`}),n(t?`pipeline.nodeEnginesTab.pool`:`pipeline.nodeEnginesTab.runtime`)]})}),f(`td`,{className:`px-3 py-2`,children:o(`span`,{className:`inline-flex items-center gap-1 text-[11px] text-sky-400`,children:[f(V,{className:`h-3 w-3`}),e.engine.runtime,`/`,e.engine.backend,e.engine.device?`/${e.engine.device}`:``,e.engine.format?` · ${e.engine.format}`:``]})}),f(`td`,{className:`px-3 py-2`,children:e.modelsLoaded.length===0?f(`span`,{className:`text-foreground-subtle text-[11px]`,children:`—`}):f(`div`,{className:`flex flex-wrap gap-1`,children:e.modelsLoaded.map(e=>f(`span`,{className:`inline-block rounded bg-surface px-1.5 py-0.5 text-[10px] font-mono text-foreground-subtle`,children:e},e))})}),f(`td`,{className:`px-3 py-2 text-right font-mono text-foreground`,children:e.poolPid??`—`}),f(`td`,{className:`px-3 py-2 text-right text-[11px]`,children:e.idleMs!==null&&e.idleTtlMs!==null?f(`span`,{className:`text-foreground-subtle`,children:wr(e.idleMs,e.idleTtlMs)}):f(`span`,{className:`text-foreground-subtle/50`,children:n(`common.never`)})}),f(`td`,{className:`px-3 py-2 text-right text-foreground`,children:(p??[]).length}),f(`td`,{className:`px-3 py-2 text-right`,children:t?f(`span`,{className:`text-[11px] text-foreground-subtle`,children:n(`common.auto`)}):o(G,{variant:`ghost`,size:`sm`,disabled:s.isPending,onClick:()=>_(e.engine),className:`text-danger hover:bg-danger/10 hover:text-danger`,children:[f(g,{className:`h-3.5 w-3.5`}),n(`pipeline.nodeEnginesTab.kill`,`Kill`)]})})]},e.engineKey)}),!d&&(u??[]).length===0&&f(`tr`,{children:f(`td`,{colSpan:7,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:n(`pipeline.nodeEnginesTab.noEnginesResidentTheFactory`,`No engines resident — the factory spins up on the first pipeline run.`)})})]})]})}),f(`div`,{className:`text-[10px] text-foreground-subtle leading-relaxed`,children:f(vn,{i18nKey:`pipeline.nodeEnginesTab.legend`,components:{strong:f(`strong`,{className:`text-foreground`})}})}),s.isError&&f(Bt,{message:n(`pipeline.nodeEnginesTab.killFailed`,{message:s.error instanceof Error?s.error.message:n(`common.unknownError`)})})]})}var Er=`pipeline-runner`,Dr=200;function Or({nodeId:e}){let{t}=J();return o(`div`,{className:`flex flex-col gap-3`,children:[o(`div`,{children:[f(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:t(`pipeline.nodeLogsTab.runnerLogs`,`Runner logs`)}),f(`p`,{className:`text-[11px] text-foreground-subtle`,children:t(`pipeline.nodeLogsTab.description`,{node:e})})]}),f(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:f(At,{agentId:e,addonId:Er,limit:Dr,maxHeight:`max-h-[calc(100vh-360px)]`,showScope:!0,showDeviceChip:!0,showFilters:!1,showSourceSelect:!0})})]})}t();function kr({nodeId:e,title:t}){let n=z(),{t:i}=J(),{data:a}=gn(),{data:s}=pt(void 0),c=r(()=>{let e=new Map;for(let t of a??[])e.set(t.id,t.name);return e},[a]),l=r(()=>{if(!e)return null;let t=new Set;for(let n of s??[])n.agentNodeId===e&&t.add(n.deviceId);return t},[e,s]),u=cr(e),d=r(()=>{let e=[];for(let t of u.values())l&&!l.has(t.deviceId)||e.push(t);return e.sort((e,t)=>e.deviceId-t.deviceId),e},[u,l]);return d.length===0?o(`div`,{className:`rounded-md border border-border bg-surface px-3 py-2 text-[11px] text-foreground-subtle italic`,children:[t??i(`pipeline.cameraStatusStrip.cameras`,`Cameras`),`: no live snapshots yet`]}):o(`div`,{className:`rounded-md border border-border bg-surface px-3 py-2`,children:[o(`div`,{className:`flex items-center gap-2 mb-1.5`,children:[f(`span`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle`,children:t??i(`pipeline.cameraStatusStrip.cameras`,`Cameras`)}),f(`span`,{className:`text-[10px] text-foreground-subtle`,children:d.length})]}),f(`div`,{className:`flex flex-wrap gap-1.5`,children:d.map(e=>{let t=c.get(e.deviceId)??`#${e.deviceId}`,r=Pt(e.metrics.phase,n);return o(`div`,{title:i(`pipeline.cameraStatusStrip.fpsMsInferQ`,`{{name}} · {{label}} · {{value3}} fps · {{value4}}ms infer · q={{queueDepth}}`,{name:t,label:r.label,value3:e.metrics.actualFps.toFixed(1),value4:e.metrics.avgInferenceTimeMs.toFixed(0),queueDepth:e.metrics.queueDepth}),className:`inline-flex items-center gap-1 rounded border px-1.5 py-0.5 text-[10px] ${r.badgeClass}`,children:[f(ln,{phase:e.metrics.phase,className:`h-2.5 w-2.5`}),f(`span`,{className:`font-medium text-foreground/90 max-w-[220px] truncate`,children:t}),f(`span`,{className:`font-mono tabular-nums`,children:e.metrics.actualFps.toFixed(1)}),f(`span`,{className:`opacity-60`,children:i(`common.fpsWord`)})]},e.deviceId)})})]})}function Ar(e,t,n){return e.map(e=>{if(e.key===t)return e;let r=e.steps[n];if(!r||r.settings===void 0)return e;let{settings:i,...a}=r,o={...e.steps};return Object.keys(a).length>0?o[n]=a:delete o[n],{...e,steps:o}})}function jr(e,t,n){let r=e.filter(e=>e.key!==t).toSorted((e,t)=>e.key.localeCompare(t.key)),i=[...r.filter(e=>!e.enabled),...r.filter(e=>e.enabled),...e.filter(e=>e.key===t)],a;for(let e of i){let t=e.steps?.[n]?.settings;!t||Object.keys(t).length===0||(a={...a,...t})}return a}function Mr(e){let t={};for(let n of e){let e=Object.keys(n.steps).length>0;t[n.key]={enabled:n.enabled,weight:Math.max(1,n.weight),...n.maxSessions!==null&&n.maxSessions>0?{maxSessions:n.maxSessions}:{},...e?{steps:n.steps}:{}}}return t}var Nr=`pipeline-orchestrator`;function Pr({addonId:e,highlightLabel:t}){let{t:n}=J(),r=pe(e),{data:i}=Xe({addonId:Nr});if(r.length===0)return null;let a=ce(i??null)[e]??{};return o(`section`,{className:`space-y-1.5 border-t border-border/60 pt-3`,"aria-label":n(`stepInspector.clusterOwnedSettings.clusterWideSettings`,`Cluster-wide settings`),children:[o(`div`,{className:`flex flex-wrap items-center gap-2`,children:[f(`h3`,{className:C,children:n(`stepInspector.clusterOwnedSettings.clusterWideSettings`,`Cluster-wide settings`)}),f(_n,{to:$o(e),className:`ml-auto text-[11px] text-primary hover:underline`,children:n(`stepInspector.clusterOwnedSettings.editInClusterSettings`,`Edit in Cluster → Settings ›`)})]}),r.map(e=>o(`div`,{className:`${p} rounded px-2 ${t===e.label?`bg-primary/5 ring-1 ring-primary/40`:``}`,children:[f(`span`,{className:P,children:e.label}),f(`span`,{className:_,children:f(`span`,{className:`font-mono text-xs text-foreground`,children:String(a[e.key]??e.default)})})]},e.key)),f(`p`,{className:H,children:n(`stepInspector.clusterOwnedSettings.oneValueForEveryNode`,`One value for every node and camera — this step writes into a shared index.`)})]})}function Fr({rows:e}){let{t}=J();return o(`div`,{className:`space-y-1.5`,"data-testid":`effective-models`,children:[f(`ul`,{className:`divide-y divide-border rounded-md border border-border`,children:e.map(e=>o(`li`,{className:`${S} flex flex-wrap items-baseline gap-x-2 text-xs`,children:[f(`span`,{className:`min-w-0 flex-1 truncate text-foreground-muted`,children:e.label}),f(`span`,{className:`font-mono text-foreground`,children:e.modelId??`—`}),f(`span`,{className:`text-[10px] text-foreground-subtle`,children:e.sourceLabel})]},e.id))}),f(`p`,{className:H,children:t(`stepInspector.effectiveModelSummary.toChangeAModelOpen`,`To change a model, open that accelerator's cell in the table.`)})]})}t();function Ir(e,t){let[n,i]=yn(),o=n.get(Pn),s=n.get(`acc`),c=r(()=>Ln(e,t,{step:o,acc:s}),[e,t,o,s]),l=a(e=>{i(t=>{let n=new URLSearchParams(t);return e(n),n},{replace:!0})},[i]);return{selection:c,open:a(e=>l(t=>{t.set(Pn,e.stepId),e.acceleratorId===void 0?t.delete(`acc`):t.set(`acc`,e.acceleratorId)}),[l]),close:a(()=>l(e=>{e.delete(Pn),e.delete(`acc`)}),[l])}}function Lr(e,t){for(let n of e?.slots??[])for(let e of n.addons)if(e.id===t)return e;return null}function Rr(e){return e.split(`.`)[0]??e}function zr(e,t,n){return{id:In(e,n.key),nodeId:e,deviceKey:n.key,device:n,label:`${Rr(t)} · ${bt(n)}`,shortLabel:`${Rr(t)} · ${Ge(n)}`,nodeLabel:Rr(t),disabled:!n.enabled}}function Br(e,t,n,r=!1){return n.filter(e=>r||e.enabled).map(n=>zr(e,t,n))}function Vr(e,t,n=!1){return e.flatMap(e=>{let r=t[e.id]??[];if(n)return r.map(t=>zr(e.id,e.name,t));let i=r.filter(e=>e.enabled&&e.available);if(i.length>0)return i.map(t=>zr(e.id,e.name,t));let a=r.find(e=>e.available)??r[0];return a===void 0?[]:[zr(e.id,e.name,a)]})}function Hr(e,t,n){return{modelId:Re({catalog:e,device:t.device,base:n.nodePin,override:n.cameraPin}),source:n.cameraPin===void 0?n.nodePin===void 0?`default`:`node`:`camera`}}function Ur(e,t,n){let r=Lr(e,`object-detection`);if(r===null)return;let i=Re({catalog:r,device:t.device,base:t.device.steps?.[`object-detection`]?.modelId,override:n});if(i===void 0)return;let a=r.models.find(e=>e.id===i);return{modelId:i,name:a?.name??i,supplies:a?.suppliesSteps??[]}}function Wr(e,t,n){return!be(e)||n===void 0?!1:ye(e,t,n.supplies).effective}function Gr(e,t){return e!==null&&_t(e.models,t.device.format)}function Kr(e){return Gr(e.addon,e.acc)?e.clusterModelId===void 0?{kind:`enabled`,modelId:e.model.modelId??`Auto`,overridden:e.model.source===`camera`,...e.rootName===void 0?{}:{suppliedByRoot:e.rootName},...e.jumpTo===void 0?{}:{jumpTo:e.jumpTo}}:{kind:`enabled`,modelId:e.clusterModelId,clusterWide:!0}:e.gatedOn?e.jumpTo===void 0?{kind:`skip`}:{kind:`skip`,jumpTo:e.jumpTo}:{kind:`na`}}function qr(e){return Object.values(e).reduce((e,t)=>e+t.filter(e=>!e.enabled).length,0)}function Jr(e){if(e===null)return[];let t=(e.configSchema??[]).flatMap(e=>`label`in e&&typeof e.label==`string`?[e.label]:[]),n=pe(e.id).map(e=>e.label);return[...new Set([...t,...n])]}function Yr(e){return e.flatMap(e=>[{node:e,depth:0},...Yr(e.children).map(e=>({node:e.node,depth:e.depth+1}))])}function Xr(e,t){return e.flatMap(e=>{let n=Xr(e.children,t);return t.has(e.addonId)||n.length>0?[{...e,children:n}]:[]})}t();function Zr(e){return{agentNodeId:e.nodeId,nodeLabel:e.nodeLabel,engineLabel:e.device.format,deviceKey:e.deviceKey,deviceLabel:bt(e.device),detail:e.device.defaultModelId,disabled:e.disabled}}function Qr({tree:e,searchRows:t,accelerators:n,cellState:s,stepBadge:c,disabledCount:l,showDisabled:u,onShowDisabledChange:p,dirty:m,onDiscard:h,summary:g,toolbar:_,label:v,renderDetail:y}){let{t:b}=J(),x=Le(),S=ze(),{selection:C,open:w,close:T}=Ir(r(()=>Yr(e).map(e=>e.node.addonId),[e]),r(()=>n.map(e=>e.id),[n])),[E,D]=i(``),[O,k]=i(null),[A,j]=i(null),N=d(null),P=d(null),F=d(null),I=d(null),L=r(()=>tn(t,E),[t,E]),R=r(()=>E.trim()===``?e:Xr(e,new Set(L.map(e=>e.addonId))),[e,L,E]),ee=e=>L.find(t=>t.addonId===e)?.matchedField??null,z=r(()=>n.map(Zr),[n]),te=e=>n.find(t=>t.nodeId===e.agentNodeId&&t.deviceKey===e.deviceKey),B=n.find(e=>e.id===C.acceleratorId)??null,V=C.stepId!==null,ne=a(async e=>{if(m){if(!await x({title:b(`stepInspector.stepMatrixFrame.discardUnsavedChanges`,`Discard unsaved changes?`),message:b(`stepInspector.stepMatrixFrame.thisStepHasChangesThat`,`This step has changes that are not saved yet.`),confirmLabel:b(`stepInspector.stepMatrixFrame.discard`,`Discard`),variant:`danger`}))return;h()}e()},[x,m,h,b]),re=()=>{requestAnimationFrame(()=>I.current?.focus())},ie=(e,t,n=!1)=>{if(e===C.stepId&&(t?.id??null)===C.acceleratorId){n&&re();return}let r=()=>{k(ee(e)),w({stepId:e,...t===void 0?{}:{acceleratorId:t.id}}),n&&re()};e===C.stepId?r():ne(r)},ae=()=>{let e=C.stepId;ne(()=>{if(T(),e!==null){let t=B===null?null:ht({agentNodeId:B.nodeId,deviceKey:B.deviceKey});requestAnimationFrame(()=>N.current?.focusCell(e,t))}})},oe=e=>{if(e.key===`Enter`){let t=L[0];if(t===void 0)return;e.preventDefault(),ie(t.addonId,void 0,!0)}else e.key===`Escape`&&D(``)},se=S?f(St,{onClick:ae}):f(ct,{icon:M,variant:`ghost`,size:`sm`,"aria-label":b(`common.close`,`Close`),onClick:ae});return o(`div`,{ref:P,className:`space-y-2`,onKeyDown:e=>{let t=e.target instanceof HTMLElement&&e.target.dataset.r!==void 0;e.key===`/`&&t&&(e.preventDefault(),F.current?.focus()),e.key===`Escape`&&t&&V&&(e.preventDefault(),ae())},children:[o(`div`,{className:`flex flex-wrap items-center gap-2 text-xs`,children:[f(`div`,{className:`min-w-0 basis-full sm:basis-auto`,children:g}),f(`input`,{ref:F,type:`search`,value:E,onChange:e=>D(e.target.value),onKeyDown: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`}),l>0&&o(`label`,{className:`inline-flex items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[f(tt,{checked:u,onChange:e=>p(e.target.checked)}),b(`stepInspector.stepMatrixFrame.showDisabled`,{count:l})]}),_]}),C.staleStepId!==null&&f(`p`,{className:`rounded-md border border-warning/40 bg-warning/10 px-3 py-1.5 text-[11px] text-warning`,children:b(`stepInspector.stepMatrixFrame.staleStep`,{id:C.staleStepId})}),R.length===0?f(`p`,{className:`${H} rounded-md border border-dashed border-border px-3 py-4 text-center`,children:b(`stepInspector.stepMatrixFrame.noStepMatches`,{query:E})}):f(mn,{ref:N,tree:R,agents:z,label:v,getCellState:(e,t)=>{let n=te(t);return n===void 0?{kind:`na`}:s(e,n)},onCellClick:(e,t,n)=>ie(e,te(t),n),onStepClick:(e,t)=>ie(e,void 0,t),...c===void 0?{}:{stepBadge:c},selectedCell:V&&C.stepId!==null&&B!==null?{addonId:C.stepId,agentNodeId:B.nodeId,deviceKey:B.deviceKey}:null,fallbackNodeId:A,onFallbackNodeChange:j,reserveRightPx:V&&!S?432:0}),f(lt,{open:V,anchor:P,onClose:ae,label:b(`stepInspector.stepMatrixFrame.stepSettings`,`Step settings`),children:C.stepId!==null&&y({stepId:C.stepId,accelerator:B,matchedField:O,closeButton:se,onEscape:ae,headingRef:e=>{I.current=e}})})]})}t();function $r(e){n(()=>{if(e===null)return;let t=document.getElementById(e);t===null||typeof t.scrollIntoView!=`function`||t.scrollIntoView({block:`center`,behavior:`smooth`})},[e])}t();function ei(e,t){let n=e.filter(e=>e.steps?.[t]?.settings!==void 0),r=e=>e.toSorted((e,t)=>e.key.localeCompare(t.key));return r(n.filter(e=>e.enabled))[0]?.key??r(n)[0]?.key??r(e.filter(e=>e.enabled))[0]?.key??e[0]?.key}function ti(e,t){let n=t.settings===void 0?void 0:ei(e,t.stepId),r=e.map(e=>{let r={...e.steps},i=r[t.stepId]??{},a=t.models[e.key],o=t.jumps[e.key],s=e.key===n&&t.settings!==void 0?Object.keys(t.settings).length>0?t.settings:void 0:i.settings,c=a===void 0?i.modelId:a??void 0,l=o===void 0?i.jumpDeviceKey:o||void 0,u={...c===void 0?{}:{modelId:c},...s===void 0?{}:{settings:s},...l===void 0?{}:{jumpDeviceKey:l}};return Object.keys(u).length>0?r[t.stepId]=u:delete r[t.stepId],{key:e.key,enabled:e.enabled,weight:e.weight,maxSessions:e.maxSessions,steps:r}});return n===void 0?r:Ar(r,n,t.stepId)}function ni(e,t,n){if(t===null)return 0;let r=Object.entries(t.models).filter(([n,r])=>(r??void 0)!==e.find(e=>e.key===n)?.steps?.[t.stepId]?.modelId).length,i=Object.entries(t.jumps).filter(([n,r])=>(r||void 0)!==e.find(e=>e.key===n)?.steps?.[t.stepId]?.jumpDeviceKey).length,a=new Set([...Object.keys(n),...Object.keys(t.settings??{})]),o=t.settings===void 0?0:[...a].filter(e=>!ve(n[e],t.settings?.[e])).length;return r+i+o}function ri({nodeId:e,nodeName:t,toolbar:n}){let{t:a}=J(),c=l(),u=Ft({nodeId:e},{refetchOnMount:`always`}),d=Zt({nodeId:e},{refetchOnMount:`always`}),p=fe(Xe({addonId:`pipeline-orchestrator`}).data??null),m=u.data?.devices??[],h=d.data??null,[g,_]=i(null),[v,y]=i(null),[b,x]=i(null),S=nt({onSuccess:()=>{c.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getNodeInferenceDevices`]]})}}),w=r(()=>h?Ze(h):[],[h]),T=r(()=>Yr(w),[w]),[E,D]=i(!1),O=r(()=>Br(e,t,m,E),[e,t,m,E]),k=r(()=>Br(e,t,m),[e,t,m]),A=k.length>=2,j=(e,t)=>(t===void 0?void 0:jr(m,t.deviceKey,e))??{},M=(e,t,n)=>{let r=n??t.device.steps?.[e?.id??``]?.jumpDeviceKey;if(r!==void 0&&r!==``)return k.find(e=>e.deviceKey===r);if(!Gr(e,t))return k.filter(n=>n.id!==t.id&&Gr(e,n)).toSorted((e,t)=>e.deviceKey.localeCompare(t.deviceKey))[0]},N=(e,t)=>{let n=Lr(h,e),r=ns(e),i=Ur(h,t),a=j(e,t),o=M(n,t);return Kr({addon:n,acc:t,gatedOn:n?.enabledByDefault??!0,model:n?Hr(n,t,{nodePin:t.device.steps?.[e]?.modelId}):{modelId:void 0,source:`default`},...Wr(e,a,i)&&i?{rootName:i.name}:{},...r?{clusterModelId:p[e]??r.defaultModelId}:{},...o?{jumpTo:Ge(o.device)}:{}})},P=T.map(({node:e})=>({addonId:e.addonId,name:e.addonName,fieldLabels:Jr(Lr(h,e.addonId))}));if(u.isLoading||d.isLoading)return f(`div`,{className:`animate-pulse p-4 text-xs text-foreground-subtle`,children:a(`stepInspector.nodeStepInspector.loadingPipeline`,`Loading pipeline…`)});if(h===null)return f(`div`,{className:`p-4 text-xs text-foreground-subtle`,children:a(`stepInspector.nodeStepInspector.catalogUnavailable`,`Catalog unavailable.`)});let F=o(`span`,{className:H,children:[a(`stepInspector.nodeStepInspector.accelerators`,`Accelerators:`),` `,f(`span`,{className:`text-foreground`,children:k.length>0?k.map(e=>Ge(e.device)).join(` · `):a(`stepInspector.nodeStepInspector.noneEnabled`,`none enabled`)}),m.some(e=>!e.enabled)&&o(s,{children:[` `,a(`stepInspector.nodeStepInspector.off`,`— off:`),` `,m.filter(e=>!e.enabled).map(Ge).join(`, `)]}),` `,`·`,` `,f(_n,{to:es(),className:`text-primary hover:underline`,children:a(`stepInspector.nodeStepInspector.clusterLoadBalancing`,`Cluster → Load balancing ›`)})]});return f(Qr,{tree:w,searchRows:P,accelerators:O,cellState:N,disabledCount:m.filter(e=>!e.enabled).length,showDisabled:E,onShowDisabledChange:D,dirty:g!==null&&ni(m,g,j(g.stepId,O[0]))>0,onDiscard:()=>_(null),summary:F,...n===void 0?{}:{toolbar:n},label:a(`stepInspector.nodeStepInspector.detectionSteps`,`Detection steps`),renderDetail:({stepId:n,accelerator:r,matchedField:i,closeButton:c,onEscape:l,headingRef:u})=>{let d=Lr(h,n);if(d===null)return f(`div`,{className:`p-4 text-xs text-foreground-subtle`,children:a(`stepInspector.nodeStepInspector.noStepSelected`,`No step selected.`)});let p=g?.stepId===n?g:null,w=r??k[0]??O[0],T=j(n,w),E=p?.settings??T,D=ni(m,p,T),N=e=>{x(null),_(t=>({...t?.stepId===n?t:{stepId:n,models:{},jumps:{}},...e}))},P=ns(n),F=qe(d),I=w===void 0?void 0:Ur(h,w),L=e=>{let t=p?.models[e.deviceKey];return t===void 0?e.device.steps?.[n]?.modelId:t??void 0},R=w===void 0?void 0:Hr(d,w,{nodePin:L(w)}).modelId,ee=O.length>1&&O.some(e=>!ve(j(n,e),T)),z=e=>{let t=L(e),r=Hr(d,e,{nodePin:t}),i=Ur(h,e),c=Wr(n,p?.settings??j(n,e),i),l=p?.jumps[e.deviceKey],u=M(d,e,l),m=Gr(d,e)?c&&i?f(st,{rootModel:i,stepModelId:r.modelId}):void 0:o(s,{children:[a(`stepInspector.nodeStepInspector.noBuild`,{format:e.device.format}),` `,u?a(`stepInspector.nodeStepInspector.itRunsOnInstead`,`It runs on {{shortLabel}} instead.`,{shortLabel:u.shortLabel}):a(`stepInspector.nodeStepInspector.itDoesNotRunHere`,`It does not run here.`)]}),g=A?o(`label`,{className:`block space-y-1`,children:[f(`span`,{className:`text-[11px] font-medium text-foreground`,children:a(`stepInspector.nodeStepInspector.runOn`,`Run on`)}),f(at,{"aria-label":a(`stepInspector.nodeStepInspector.runOn`,`Run on`),value:l??e.device.steps?.[n]?.jumpDeviceKey??``,options:[{value:``,label:a(`stepInspector.nodeStepInspector.autoThisAcceleratorOrThe`,`Auto (this accelerator, or the next one that can run it)`)},...k.filter(t=>t.id!==e.id).map(e=>({value:e.deviceKey,label:`${e.label} · ${e.device.format}`}))],onChange:t=>N({jumps:{...p?.jumps,[e.deviceKey]:t.target.value}})}),f(`span`,{className:H,children:a(`stepInspector.nodeStepInspector.routesThisStepAndIts`,`Routes this step (and its child steps) to another accelerator of this node.`)})]}):void 0;return{label:e.label,format:e.device.format,modelId:r.modelId,source:r.source===`node`?`node`:`default`,sourceLabel:r.source===`node`?`node pin`:`hardware default`,models:Ke(d.models??[],e.device.format),defaultModelId:d.defaultModelIdByFormat?.[e.device.format]??d.defaultModelId,expanded:v===e.id,onToggle:()=>y(t=>t===e.id?null:e.id),onChangeModel:t=>N({models:{...p?.models,[e.deviceKey]:t}}),...t===void 0?{}:{onReset:()=>N({models:{...p?.models,[e.deviceKey]:null}}),resetLabel:`Reset to hardware default`},...m===void 0?{}:{note:m},...g===void 0?{}:{extra:g},changed:p?.models[e.deviceKey]!==void 0||l!==void 0}},te=()=>{p!==null&&S.mutate({agentNodeId:e,inferenceDevices:Mr(ti(m,p))},{onSuccess:()=>{_(null),x({kind:`saved`})},onError:e=>x({kind:`error`,error:e.message})})};return f(Tt,{ref:u,title:r===null?`${d.name} · ${t}`:`${d.name} · ${r.label}`,subtitle:r===null?a(`stepInspector.nodeStepInspector.everyAcceleratorOf`,`{{slot}} · every accelerator of {{nodeName}}`,{slot:d.slot,nodeName:t}):a(`stepInspector.nodeStepInspector.baseForEveryCameraThat`,`{{slot}} · {{format}} · base for every camera that lands here`,{slot:d.slot,format:r.device.format}),leading:c,onEscape:l,saveBar:{dirtyCount:D,saving:S.isPending,status:b?.kind??null,...b?.error===void 0?{}:{error:b.error},onSave:te,onDiscard:()=>_(null)},children:o(`div`,{className:`space-y-3`,children:[o(`section`,{className:`space-y-2`,"aria-label":a(`stepInspector.nodeStepInspector.model`,`Model`),children:[f(`h3`,{className:C,children:a(`stepInspector.nodeStepInspector.model`,`Model`)}),P!==null&&w!==void 0?f(rs,{step:P,engineFormat:w.device.format,runnableModelIds:Ke(d.models??[],w.device.format).map(e=>e.id)}):O.length===0?f(`p`,{className:H,children:f(vn,{i18nKey:`stepInspector.nodeStepInspector.noAcceleratorEnabled`,components:{link:f(_n,{to:es(),className:`text-primary hover:underline`})}})}):r===null?f(Fr,{rows:O.map(e=>{let t=Hr(d,e,{nodePin:L(e)});return{id:e.id,label:e.label,modelId:t.modelId,sourceLabel:t.source===`node`?`node pin`:`hardware default`}})}):f(Je,{...z(r)},r.id)]}),(F.length>0||I!==void 0)&&P===null&&o(`section`,{"aria-label":a(`stepInspector.nodeStepInspector.settings`,`Settings`),className:`space-y-2 border-t border-border/60 pt-2`,children:[f(`p`,{className:`text-[10px] text-foreground-subtle`,"data-testid":`settings-scope`,children:a(`stepInspector.nodeStepInspector.nodeWideSettings`,{node:t})}),ee&&f(`p`,{className:`rounded-md border border-warning/40 bg-warning/10 px-2 py-1 text-[11px] text-warning`,children:a(`stepInspector.nodeStepInspector.thisStepSSettingsDiffer`,`This step's settings differ between this node's accelerators. Saving makes the values shown here node-wide.`)}),f(ii,{addon:d,fields:F,settings:E,modelId:Ue(d,R,E,I),root:I,highlight:i,onChange:e=>N({settings:e})})]}),f(Pr,{addonId:n,highlightLabel:i})]})})}})}function ii({addon:e,fields:t,settings:n,modelId:r,root:i,highlight:a,onChange:o}){let s=t.find(e=>`label`in e&&e.label===a)?.key??null;return $r(s===null?null:ft(s)),f($e,{addon:e,fields:t,layers:{node:n},target:`node`,labels:{node:`Node`},modelId:r,...i===void 0?{}:{rootModel:i},highlightKey:s,onChangeLayer:o})}t();function ai({nodeId:e,refreshToken:t}){let{t:n}=J(),r=Le(),[a,c]=i(null),{nodes:l}=U(),u=l.find(t=>t.id===e)?.name??e,d=Ie({onSuccess:e=>{c(e.effectiveModelId===null?`Reset done — model config cleared (node offline: effective model resolves on reconnect)`:`Reset done — effective detection model: ${e.effectiveModelId} (Auto)`)}}),p=async()=>{await r({title:n(`pipeline.nodePipelineTab.resetToHardwareAwareDefaults`,`Reset {{nodeName}} to hardware-aware defaults?`,{nodeName:u}),message:n(`pipeline.nodePipelineTab.thisClearsEveryPerDevice`,`This clears every per-device model default on this node (back to the format default) and every per-camera step override scoped to it. Existing per-camera customisations on this node are lost.`),confirmLabel:n(`common.reset`,`Reset`),variant:`danger`})&&(c(null),d.mutate({agentNodeId:e}))};return o(`div`,{className:`space-y-2`,children:[f(kr,{nodeId:e}),f(ri,{nodeId:e,nodeName:u,toolbar:o(s,{children:[a&&f(`span`,{className:`text-[11px] text-success`,children:a}),d.isError&&f(`span`,{className:`text-[11px] text-danger`,children:d.error instanceof Error?d.error.message:n(`pipeline.nodePipelineTab.resetFailed`,`Reset failed`)}),f(G,{variant:`outline`,size:`sm`,onClick:()=>{p()},disabled:d.isPending,title:n(`pipeline.nodePipelineTab.clearThisNodeSPer`,`Clear this node's per-device model defaults + per-camera overrides scoped to this node`),children:d.isPending?n(`pipeline.nodePipelineTab.resetting`,`Resetting…`):n(`pipeline.nodePipelineTab.resetToDefault`,`Reset to default`)})]})})]})}var oi=[`detection-pipeline`,`audio-analyzer`,`pipeline-runner`],si=`decoder-nodeav`,ci=`ntab`,li={decoder:`engine`},ui={engine:`Engine & decoder`},di=`Nothing here is set per node. Cluster-wide values are on Cluster → Settings.`;function fi({nodeId:e,refreshToken:t}){let{t:n}=J(),[r,i]=yn(),{nodes:a}=U(),s=a.find(t=>t.id===e)?.addons.find(e=>e.capabilities.includes(`decoder`))?.addonId??si,c=[...oi,s],l=r.get(ci),u={assignments:{id:`assignments`,label:n(`pipeline.nodeDetail.assignments`,`Assignments`),order:-10,content:f(Cr,{nodeId:e,refreshToken:t})},tree:{id:`tree`,label:n(`pipeline.nodeDetail.pipeline`,`Pipeline`),order:39,content:f(ai,{nodeId:e,refreshToken:t})},engines:{id:`engines`,label:n(`pipeline.nodeDetail.warmInstances`,`Warm instances`),order:180,content:f(Tr,{nodeId:e,refreshToken:t})},logs:{id:`logs`,label:n(`pipeline.nodeDetail.logs`,`Logs`),order:300,content:f(Or,{nodeId:e})}},d=Kn.map(e=>u[e]);return o(`div`,{className:`flex flex-col h-full`,children:[f(Gn,{nodeId:e,refreshToken:t}),f(`div`,{className:`flex-1 min-h-0 overflow-y-auto p-4 sm:p-6`,children:f(bn,{nodeId:e,addonIds:c,level:`global`,fieldScope:`perNode`,emptyMessage:di,tabAliases:li,tabLabelOverrides:ui,extraTabs:d,activeTab:l===null?null:li[l]??l,onActiveTabChange:e=>i(t=>{let n=new URLSearchParams(t);n.set(ci,e);for(let e of Fn)n.delete(e);return n},{replace:!0})})})]})}function pi(){let{t:e}=J();return o(`div`,{className:`space-y-2`,children:[o(`div`,{className:`min-w-0`,children:[f(`h3`,{className:`text-sm font-semibold text-foreground`,children:e(`pipeline.clusterAssignmentsTab.cameraPlacement`,`Camera placement`)}),f(`p`,{className:`text-[11px] text-foreground-subtle`,children:e(`pipeline.clusterAssignmentsTab.pinACameraToA`,`Pin a camera to a node, or to one accelerator of its node; Auto lets each session pick. Decode always runs with detection. Load, shares and caps are on Load balancing.`)})]}),f(xr,{})]})}function mi(e){return`${Math.round(e*100)}%`}function hi(e){return q.t(`helpers.autoTuneViewModel.sessions`,{count:e})}var gi={"intel-npu":`Intel NPU`,"intel-igpu":`Intel iGPU`,"amd-igpu":`AMD iGPU (WebGPU)`,"amd-npu":`AMD XDNA NPU`,"x86-cpu":`CPU`,"arm-cpu":`CPU`,"apple-ane":`Apple Neural Engine`,coral:`Coral Edge TPU`},_i={"intel-core-ultra":`Intel Core Ultra`,"intel-n-series":`Intel N-series`,"apple-m-base":`Apple M (base)`,"apple-m-pro":`Apple M Pro / Max / Ultra`,"amd-phoenix":`AMD Ryzen Phoenix / Hawk Point`,unknown:`Not measured`};function vi(e){return e===null?`—`:gi[e]??e}function yi(e){return e===null?`—`:_i[e]??e}function bi(e){switch(e.kind){case`capacity`:return q.t(`helpers.autoTuneViewModel.capacity`,{sessions:hi(e.sessions),min:e.minSessions});case`tie-faster`:return q.t(`helpers.autoTuneViewModel.tieFaster`,{over:e.over,recall:mi(e.recallDelta)});case`stepped-down`:return q.t(`helpers.autoTuneViewModel.steppedDown`,{from:e.from,limitedBy:e.limitedBy,to:e.to});case`no-fit-lightest`:return q.t(`helpers.autoTuneViewModel.noFitLightest`,{min:hi(e.minSessions),sessions:hi(e.sessions)});case`derived-latency`:return q.t(`helpers.autoTuneViewModel.derivedLatency`,{modelId:e.modelId});case`cpu-device`:return q.t(`helpers.autoTuneViewModel.cpuDevice`);case`device-disabled`:return q.t(`helpers.autoTuneViewModel.deviceDisabled`);case`device-unavailable`:return q.t(`helpers.autoTuneViewModel.deviceUnavailable`);case`node-offline`:return q.t(`helpers.autoTuneViewModel.nodeOffline`);case`no-hardware-facts`:return q.t(`helpers.autoTuneViewModel.noHardwareFacts`);case`no-measured-data`:return q.t(`helpers.autoTuneViewModel.noMeasuredData`);case`no-family-build`:return q.t(`helpers.autoTuneViewModel.noFamilyBuild`,{format:e.format});case`kept-custom-pin`:return q.t(`helpers.autoTuneViewModel.keptCustomPin`,{modelId:e.modelId,deviceKey:e.deviceKey})}}function xi(e,t){switch(e.kind){case`detector-store-cluster-wide`:return q.t(`helpers.autoTuneViewModel.detectorStoreClusterWide`,{nodes:e.skippedNodes.map(t).join(`, `)});case`detector-store-unreadable`:return q.t(`helpers.autoTuneViewModel.detectorStoreUnreadable`,{error:e.error});case`custom-pin-kept`:return e.deviceId===null?q.t(`helpers.autoTuneViewModel.customPinNode`,{node:t(e.nodeId),modelId:e.modelId,deviceKey:e.deviceKey??`—`}):q.t(`helpers.autoTuneViewModel.customPinCamera`,{deviceId:e.deviceId,modelId:e.modelId,node:t(e.nodeId)});case`custom-registry-unreadable`:return q.t(`helpers.autoTuneViewModel.customRegistryUnreadable`,{error:e.error})}}function Si(e){let t=e.nodeChanges.reduce((e,t)=>e+t.modelPins.length,0),n=e.nodeChanges.reduce((e,t)=>e+t.thresholds.length,0),r=new Set([...e.cameraClears.map(e=>e.deviceId),...e.detectorStoreClears.map(e=>e.deviceId)]);return{modelChanges:t,thresholdClears:n,cameraOverrideClears:e.cameraClears.length,detectorStoreClears:e.detectorStoreClears.length,camerasTouched:r.size}}function Ci(e){let t=Si(e);return t.modelChanges+t.thresholdClears+t.cameraOverrideClears+t.detectorStoreClears===0}function wi(e,t,n){let r=e.nodeChanges.find(e=>e.nodeId===t&&e.deviceKey===n)?.modelPins.find(e=>e.stepId===`object-detection`);return r===void 0?null:{before:r.before,after:r.after}}function Ti(e,t){return e?.kind===`node-benchmark`?q.t(`helpers.autoTuneViewModel.latencyMeasured`,{date:new Date(e.measuredAtMs).toLocaleDateString(t,{day:`numeric`,month:`short`})}):q.t(`helpers.autoTuneViewModel.latencyTable`)}t();var Ei=[.3,.4,.5];function Di(e){return Ei.some(t=>t===e)}var Oi=[1,2,3,4,6,8];function ki({plan:e,node:t,nodeName:n}){let{t:r}=J();return o(`section`,{className:b,"data-testid":`auto-tune-node-${t.nodeId}`,children:[o(`header`,{className:`${F} flex flex-wrap items-center gap-2`,children:[f(T,{className:`h-3.5 w-3.5 shrink-0 text-foreground-subtle`,"aria-hidden":!0}),f(`h3`,{className:`${C} min-w-0 flex-1`,children:n(t.nodeId)}),o(`span`,{className:`text-[11px] text-foreground-subtle`,children:[yi(t.hardwareClass),t.cpuModel===null?``:` · ${t.cpuModel}`]}),t.skipped?f(W,{variant:`warning`,children:r(`pipeline.clusterAutoTuneTab.notChanged`,`Not changed`)}):t.acceleratorModelId!==null&&f(W,{variant:`info`,children:t.acceleratorModelId})]}),t.reasons.length>0&&f(`ul`,{className:`px-3 pt-2 text-[11px] text-foreground-muted`,children:t.reasons.map((e,t)=>f(`li`,{children:bi(e)},t))}),f(`div`,{className:`overflow-x-auto`,children:o(`table`,{className:`w-full text-xs`,children:[f(`thead`,{children:o(`tr`,{className:`text-left text-[11px] text-foreground-subtle`,children:[f(`th`,{className:`px-3 py-1.5 font-medium`,children:r(`pipeline.clusterAutoTuneTab.device`,`Device`)}),f(`th`,{className:`px-3 py-1.5 font-medium`,children:r(`pipeline.clusterAutoTuneTab.capacity`,`Capacity`)}),f(`th`,{className:`px-3 py-1.5 font-medium`,children:r(`pipeline.clusterAutoTuneTab.detector`,`Detector`)}),f(`th`,{className:`px-3 py-1.5 font-medium`,children:r(`pipeline.clusterAutoTuneTab.why`,`Why`)})]})}),f(`tbody`,{children:t.devices.map(n=>{let i=wi(e,t.nodeId,n.deviceKey);return o(`tr`,{className:`border-t border-border align-top`,children:[o(`td`,{className:`px-3 py-1.5`,children:[f(`div`,{className:`font-mono text-foreground`,children:n.deviceKey}),f(`div`,{className:`text-[11px] text-foreground-subtle`,children:vi(n.accelerator)})]}),o(`td`,{className:`px-3 py-1.5 text-foreground-muted`,children:[n.chosen===null?`—`:r(`pipeline.clusterAutoTuneTab.sessionsAtFps`,{count:n.chosen.capacitySessions,fps:e.cameraFps}),n.chosen!==null&&o(`div`,{className:`text-[11px] text-foreground-subtle`,children:[r(`pipeline.clusterAutoTuneTab.fpsKeptFree`,{fps:n.chosen.fps,percent:Math.round(e.headroom*100)}),f(`div`,{children:Ti(n.chosen.source)})]})]}),f(`td`,{className:`px-3 py-1.5`,children:n.chosen===null?f(`span`,{className:`text-foreground-subtle`,children:r(`common.unchanged`)}):i!==null&&i.before!==i.after?o(`span`,{children:[f(`span`,{className:`text-foreground-subtle`,children:i.before??r(`common.defaultWord`)}),` → `,f(`span`,{className:`font-medium text-foreground`,children:i.after})]}):f(`span`,{className:`text-foreground`,children:n.chosen.modelId})}),f(`td`,{className:`px-3 py-1.5 text-[11px] text-foreground-muted`,children:n.reasons.map((e,t)=>f(`div`,{children:bi(e)},t))})]},n.deviceKey)})})]})})]})}function Ai({plan:e,nameOf:t,nodeName:n}){let{t:r}=J();return o(`div`,{className:`flex flex-col gap-3 text-xs`,"data-testid":`auto-tune-change-list`,children:[o(`div`,{children:[f(`div`,{className:C,children:r(`pipeline.clusterAutoTuneTab.nodeSettings`,`Node settings`)}),e.nodeChanges.length===0?f(`div`,{className:`text-foreground-subtle`,children:r(`pipeline.clusterAutoTuneTab.noChange`,`No change.`)}):f(`ul`,{className:`mt-1 flex flex-col gap-0.5`,children:e.nodeChanges.flatMap(e=>[...e.modelPins.map(t=>o(`li`,{children:[o(`span`,{className:`font-mono`,children:[n(e.nodeId),` · `,e.deviceKey]}),` `,`— `,t.stepId,`: `,t.before??r(`pipeline.clusterAutoTuneTab.defaultModel`),` →`,` `,t.after??r(`pipeline.clusterAutoTuneTab.stepDefault`,`step default`)]},`${e.nodeId}/${e.deviceKey}/${t.stepId}/pin`)),...e.thresholds.map(t=>o(`li`,{children:[o(`span`,{className:`font-mono`,children:[n(e.nodeId),` · `,e.deviceKey]}),` `,`—`,` `,r(`pipeline.clusterAutoTuneTab.thresholdReset`,{step:t.stepId,keys:t.keys.join(`, `)})]},`${e.nodeId}/${e.deviceKey}/${t.stepId}/thr`))])})]}),o(`div`,{children:[f(`div`,{className:C,children:r(`pipeline.clusterAutoTuneTab.cameraOverridesCleared`,`Camera overrides cleared`)}),e.cameraClears.length===0&&e.detectorStoreClears.length===0?f(`div`,{className:`text-foreground-subtle`,children:r(`pipeline.clusterAutoTuneTab.none`,`None.`)}):o(`ul`,{className:`mt-1 flex flex-col gap-0.5`,children:[e.cameraClears.map((e,i)=>o(`li`,{children:[t(e.deviceId),` — `,n(e.nodeId),e.deviceKey===null?` (${r(`pipeline.clusterAutoTuneTab.wholePipeline`)})`:` · ${e.deviceKey}`,` `,`— `,e.stepId,e.modelIdBefore===null?``:r(`pipeline.clusterAutoTuneTab.modelRemoved`,`: model {{modelIdBefore}} removed`,{modelIdBefore:e.modelIdBefore}),e.keys.length>0?r(`pipeline.clusterAutoTuneTab.reset`,`; {{value1}} reset`,{value1:e.keys.join(`, `)}):``]},`c${i}`)),e.detectorStoreClears.map(e=>o(`li`,{children:[t(e.deviceId),` —`,` `,r(`pipeline.clusterAutoTuneTab.detectorThresholdsReset`,{keys:e.keys.join(`, `)})]},`d${e.deviceId}`))]})]})]})}function ji({result:e}){let{t}=J();return e.kind===`refused`?f(`div`,{className:`text-xs text-warning`,children:t(`pipeline.clusterAutoTuneTab.anotherApplyIsAlreadyRunning`,`Another apply is already running.`)}):e.kind===`stale`?f(`div`,{className:`text-xs text-warning`,children:t(`pipeline.clusterAutoTuneTab.theConfigurationChangedSinceThe`,`The configuration changed since the plan was shown. Review the updated plan below and apply again.`)}):o(`ul`,{className:`text-xs`,"data-testid":`auto-tune-result`,children:[e.kind===`aborted`&&f(`li`,{className:`text-danger`,children:t(`pipeline.clusterAutoTuneTab.aModelCouldNotBe`,`A model could not be downloaded: nothing was changed.`)}),e.phases.map(e=>o(`li`,{className:e.ok?`text-foreground-muted`:`text-danger`,children:[e.ok?`✓`:`✗`,` `,e.phase,`: `,e.detail]},e.phase))]})}function Mi(){let{t:e}=J(),t=l(),[n,a]=i(.4),[s,c]=i(2),[u,d]=i(!1),[p,m]=i(!1),[h,g]=i(null),{data:_}=gn(),v=r(()=>new Map((_??[]).map(e=>[e.id,e.name])),[_]),y=t=>v.get(t)??e(`pipeline.clusterAutoTuneTab.cameraFallback`,{id:t}),{nodes:x}=U(),S=r(()=>er(x),[x]),w=Ve({headroom:n,minSessionsPerDevice:s},{enabled:u,refetchOnWindowFocus:!1}),T=Nt({onSuccess:e=>{g(e),m(!1),t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getNodeInferenceDevices`]]}),t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCameraStepOverrides`]]}),t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCameraSettings`]]}),e.kind===`applied`&&w.refetch()}}),D=h?.kind===`stale`?h.plan:w.data,O=D===void 0?null:Si(D);return o(`div`,{className:`flex flex-col gap-3`,"data-testid":`cluster-auto-tune`,children:[o(`section`,{className:b,children:[o(`header`,{className:`${F} flex flex-wrap items-center gap-2`,children:[f(E,{className:`h-3.5 w-3.5 shrink-0 text-foreground-subtle`,"aria-hidden":!0}),f(`h3`,{className:`${C} min-w-0 flex-1`,children:e(`pipeline.clusterAutoTuneTab.autoTune`,`Auto tune`)})]}),o(`div`,{className:`flex flex-col gap-2 px-3 py-2 text-xs text-foreground-muted`,children:[f(`p`,{children:e(`pipeline.clusterAutoTuneTab.picksForEveryAcceleratorThe`,`Picks, for every accelerator, the most accurate YOLOv9 detector that still carries at least the chosen number of cameras at once, from the node's hardware and measured speeds. Nothing is measured or estimated about your cameras' activity. Applying it sets those models and clears every model and threshold override — node level and per camera — so each model runs its own default thresholds. Enabled steps, devices, pins, recording, notifications, zones and rules are not touched. There is no undo.`)}),o(`div`,{className:`flex flex-wrap items-center gap-2`,children:[o(`label`,{className:`flex items-center gap-1.5`,children:[f(`span`,{className:`whitespace-nowrap`,children:e(`pipeline.clusterAutoTuneTab.keepFree`,`Keep free`)}),f(at,{"aria-label":e(`pipeline.clusterAutoTuneTab.shareOfEachAcceleratorKept`,`Share of each accelerator kept free`),value:String(n),options:Ei.map(t=>({value:String(t),label:e(`pipeline.clusterAutoTuneTab.ofEachAccelerator`,`{{value1}}% of each accelerator`,{value1:Math.round(t*100)})})),onChange:e=>{let t=Number(e.target.value);Di(t)&&a(t)}})]}),o(`label`,{className:`flex items-center gap-1.5`,children:[f(`span`,{className:`whitespace-nowrap`,children:e(`pipeline.clusterAutoTuneTab.atLeast`,`At least`)}),f(at,{"aria-label":e(`pipeline.clusterAutoTuneTab.minimumParallelSessionsPerDevice`,`Minimum parallel sessions per device`),value:String(s),options:Oi.map(t=>({value:String(t),label:e(`pipeline.clusterAutoTuneTab.camerasAtOnce`,{count:t})})),onChange:e=>{let t=Number(e.target.value);Oi.some(e=>e===t)&&c(t)}})]}),f(G,{size:`sm`,variant:`secondary`,onClick:()=>{g(null),d(!0),u&&w.refetch()},children:w.isFetching?e(`pipeline.clusterAutoTuneTab.computing`,`Computing…`):D===void 0?e(`pipeline.clusterAutoTuneTab.computePlan`,`Compute plan`):e(`pipeline.clusterAutoTuneTab.recompute`,`Recompute`)}),D!==void 0&&f(G,{size:`sm`,disabled:Ci(D),onClick:()=>m(!0),children:e(`pipeline.clusterAutoTuneTab.apply`,`Apply…`)})]}),w.error!==null&&f(`div`,{className:`text-danger`,children:w.error.message}),h!==null&&f(ji,{result:h}),O!==null&&f(`div`,{className:`text-[11px] text-foreground-subtle`,children:e(`pipeline.clusterAutoTuneTab.planSummary`,{modelChanges:O.modelChanges,thresholdClears:O.thresholdClears,overrides:O.cameraOverrideClears+O.detectorStoreClears,cameras:O.camerasTouched})})]})]}),D?.warnings.map((e,t)=>f(`div`,{className:`rounded-md border border-warning/40 bg-warning/10 px-3 py-2 text-xs text-warning`,children:xi(e,S)},t)),D?.nodes.map(e=>f(ki,{plan:D,node:e,nodeName:S},e.nodeId)),D!==void 0&&f(ut,{open:p,onOpenChange:m,children:o(zt,{width:`lg`,scroll:`body`,children:[o(sn,{children:[f(Gt,{children:e(`pipeline.clusterAutoTuneTab.applyAutoTune`,`Apply auto tune?`)}),f(un,{children:e(`pipeline.clusterAutoTuneTab.theseAreAllTheChanges`,`These are all the changes. Every override listed is removed and cannot be restored.`)})]}),f(Pe,{children:f(Ai,{plan:D,nameOf:y,nodeName:S})}),o(Qt,{children:[f(G,{variant:`ghost`,onClick:()=>m(!1),children:e(`common.cancel`,`Cancel`)}),f(G,{variant:`danger`,disabled:T.isPending,onClick:()=>T.mutate({planHash:D.planHash,headroom:n,minSessionsPerDevice:s}),children:T.isPending?e(`pipeline.clusterAutoTuneTab.applying`,`Applying…`):e(`common.apply`,`Apply`)})]})]})})]})}var Ni={disabled:`pipeline.nodeLoadOverview.exclusion.disabled`,unavailable:`pipeline.nodeLoadOverview.exclusion.unavailable`,"cannot-host-camera-root":`pipeline.nodeLoadOverview.exclusion.cannotHostCameraRoot`,"accelerator-preferred":`pipeline.nodeLoadOverview.exclusion.acceleratorPreferred`};function Pi(e,t){return t<=0?0:Math.round(e/t*1e3)/10}function Fi(e){return e===void 0?!1:e.load.devices.reduce((e,t)=>e+t.attachedCameras,0)>=e.load.attachedCameras}function Ii(e,t,n){let r=e.filter(e=>e.exclusion===null).reduce((e,t)=>e+(t.weight>0?t.weight:1),0);return e.map(e=>{let i=t.get(e.key)??(n?0:null),a=e.weight>0?e.weight:1;return{key:e.key,label:bt(e),format:e.format,sessions:i,weight:a,weightSharePct:e.exclusion===null?Pi(a,r):null,maxSessions:e.maxSessions,atCap:e.maxSessions!==null&&i!==null&&i>=e.maxSessions,available:e.available,enabled:e.enabled,exclusion:e.exclusion}}).toSorted((e,t)=>e.exclusion===null==(t.exclusion===null)?e.key.localeCompare(t.key):e.exclusion===null?-1:1)}function Li(e){let t=new Map(e.loads.map(e=>[e.nodeId,e])),n=e.nodes.filter(e=>e.isOnline&&e.detectEnabled).reduce((e,t)=>e+(t.weight>0?t.weight:1),0);return e.nodes.map(r=>{let i=t.get(r.id),a=Ii(e.devicesByNode[r.id]??[],new Map((i?.load.devices??[]).map(e=>[e.deviceKey,e.attachedCameras])),Fi(i)),o=r.isOnline&&r.detectEnabled,s=r.weight>0?r.weight:1,c=i?.load.attachedCameras??null;return{nodeId:r.id,name:r.name,isOnline:r.isOnline,detectEnabled:r.detectEnabled,reported:i!==void 0,attachedCameras:c,activeCameras:i?.load.activeCameras??null,maxCameras:r.maxCameras,capacityPct:c!==null&&r.maxCameras!==null&&r.maxCameras>0?Pi(c,r.maxCameras):null,queueDepthTotal:i?.load.queueDepthTotal??null,avgInferenceTimeMs:i?.load.avgInferenceTimeMs??null,score:i?.score??null,weight:s,weightSharePct:o?Pi(s,n):null,decodeHwaccel:i?.decodeHwaccel??null,devices:a,eligibleDeviceCount:a.filter(e=>e.exclusion===null).length}})}t();var Ri=2e4,zi=3e5;function Bi({stats:e,targetWeights:t,showAccelerators:n=!0}){let{t:i}=J(),{nodes:a}=U(),o=R().trpcClient,s=Jt(void 0,{placeholderData:u,staleTime:Ri,refetchInterval:Ri,refetchOnWindowFocus:!0}),l=He(void 0,{staleTime:zi}),d=r(()=>a.map(e=>e.id),[a]),p=c({queries:d.map(e=>({queryKey:Ne(Fe.pipelineOrchestrator.getNodeInferenceDevices,{nodeId:e},`query`),queryFn:()=>o.pipelineOrchestrator.getNodeInferenceDevices.query({nodeId:e}),staleTime:zi,refetchOnWindowFocus:!1,placeholderData:u}))}),h=r(()=>{let e={};return d.forEach((t,n)=>{let r=p[n]?.data;r&&(e[t]=r.devices)}),e},[d,p.map(e=>e.dataUpdatedAt).join(`|`)]),g=r(()=>{let e=new Map;for(let t of l.data??[])e.set(t.nodeId,t.settings);return e},[l.data]),_=r(()=>a.map(e=>{let n=g.get(e.id);return{id:e.id,name:e.name,isOnline:e.isOnline,detectEnabled:Hn(n,e.isHub).pipeline,weight:t?.[e.id]??Cn(n,`detectWeight`)??1,maxCameras:Cn(n,`maxCameras`)}}),[a,g,t]),v=s.data??[],y=r(()=>Li({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=s.dataUpdatedAt>0?Date.now()-s.dataUpdatedAt:null,C=new Map((e?.nodes??[]).map(e=>[e.nodeId,e]));return f(K,{headingId:`load-balancing-node-load`,title:i(`pipeline.nodeLoadOverview.nodeLoad`,`Node load`),icon:te,actions:f(`span`,{className:`text-[10px] text-foreground-subtle tabular-nums`,children:i(`pipeline.nodeLoadOverview.summaryLine`,{active:x,attached:b,reading:s.data===void 0?i(`pipeline.nodeLoadOverview.reading`,`reading…`):i(`pipeline.nodeLoadOverview.readingAge`,{age:S===null?`—`:`${Math.round(S/1e3)}s`})})}),children:f(`div`,{className:m,children:y.length===0?f(`p`,{className:`text-[11px] italic text-foreground-subtle`,children:i(`pipeline.nodeLoadOverview.noClusterNodesReportedYet`,`No cluster nodes reported yet.`)}):f(`div`,{className:`grid gap-2 @2xl/clustertab:grid-cols-2 @5xl/clustertab:grid-cols-3`,children:y.map(e=>f(Vi,{row:e,placed:C.get(e.nodeId),showAccelerators:n},e.nodeId))})})})}function Vi({row:e,placed:t,showAccelerators:n}){let{t:r}=J(),i=e.attachedCameras===null?`—`:`${e.activeCameras??0} / ${e.attachedCameras}${e.maxCameras===null?``:` of ${e.maxCameras}`}`;return o(`div`,{className:`rounded-lg border border-border bg-surface/60 p-2.5 min-w-0`,children:[o(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[f(`span`,{className:`h-1.5 w-1.5 shrink-0 rounded-full ${e.isOnline?`bg-emerald-400`:`bg-foreground-subtle/40`}`}),f(`span`,{className:`truncate text-xs font-medium text-foreground`,title:e.nodeId,children:e.name}),!e.detectEnabled&&f(`span`,{className:`shrink-0 rounded bg-surface-hover px-1 text-[9px] uppercase tracking-wide text-foreground-subtle`,children:r(`pipeline.nodeLoadOverview.noDetect`,`no detect`)}),!e.reported&&e.isOnline&&o(`span`,{className:`ml-auto inline-flex shrink-0 items-center gap-1 text-[9px] text-amber-400`,title:r(`pipeline.nodeLoadOverview.onlineButItDidNot`,`Online, but it did not answer the last load read — its numbers below are unknown, not zero.`),children:[f(y,{className:`h-2.5 w-2.5`}),` `,r(`pipeline.nodeLoadOverview.noReading`)]}),!e.isOnline&&o(`span`,{className:`ml-auto inline-flex shrink-0 items-center gap-1 text-[9px] text-foreground-subtle`,children:[f(D,{className:`h-2.5 w-2.5`}),` `,r(`common.offline`)]})]}),o(`dl`,{className:`mt-1.5 grid grid-cols-2 gap-x-2 gap-y-0.5 text-[10px]`,children:[f(X,{label:r(`pipeline.nodeLoadOverview.runningAttached`,`Running / attached`),value:i,title:r(`pipeline.nodeLoadOverview.sessionsInInferenceNowCameras`,`Sessions in inference now / cameras attached to this runner (the balancer's committed load) / operator cap.`)}),f(X,{label:r(`pipeline.nodeLoadOverview.targetShare`,`Target share`),value:e.weightSharePct===null?`out of play`:`${e.weightSharePct}%`,title:r(`pipeline.nodeLoadOverview.theNodeShareAutomaticOr`,`The node share (automatic or manual) normalised over the nodes the balancer actually ranks (online AND detect-enabled).`)}),f(X,{label:r(`pipeline.nodeLoadOverview.actualShare1H`,`Actual share (1 h)`),value:t?.observedShare===null||t===void 0?`—`:`${Math.round(t.observedShare*100)}%`,title:r(`pipeline.nodeLoadOverview.timeWeightedShareOfThe`,`Time-weighted share of the cluster's PARALLEL detection sessions this node carried over the last hour — the quantity a share holds. '—' = no session ran here in the window.`)}),f(X,{label:r(`pipeline.nodeLoadOverview.peakYields`,`Peak · yields`),value:t===void 0?`—`:`${t.peakSessions} · ${t.yieldsAway}`,title:r(`pipeline.nodeLoadOverview.mostSessionsThisNodeRan`,`Most sessions this node ran at once in the last hour, and how many share turns it handed to another node because it was full or drowning.`)}),f(X,{label:r(`pipeline.nodeLoadOverview.scoreQueue`,`Score · queue`),value:e.score===null?`—`:`${e.score} · ${e.queueDepthTotal??0}`,title:r(`pipeline.nodeLoadOverview.theCapacityScoreBalanceMinimises`,`The capacity score balance() minimises (attached + queue depth), and the raw queue depth.`)}),e.capacityPct!==null&&f(X,{label:r(`pipeline.nodeLoadOverview.capFill`,`Cap fill`),value:`${e.capacityPct}%`,title:r(`pipeline.nodeLoadOverview.attachedMaxcameras`,`attached / maxCameras.`)}),e.avgInferenceTimeMs!==null&&f(X,{label:r(`pipeline.nodeLoadOverview.avgInfer`,`Avg infer`),value:`${Math.round(e.avgInferenceTimeMs)} ms`,title:r(`pipeline.nodeLoadOverview.meanInferenceTimeAcrossThis`,`Mean inference time across this node's attached cameras.`)}),e.decodeHwaccel!==null&&f(X,{label:r(`pipeline.nodeLoadOverview.decode`,`Decode`),value:e.decodeHwaccel,title:r(`pipeline.nodeLoadOverview.thisNodeSProbedDecode`,`This node's probed decode hwaccel.`)})]}),n&&f(Hi,{row:e})]})}function Hi({row:e}){let{t}=J();return e.devices.length===0?f(`p`,{className:`mt-2 text-[10px] italic text-foreground-subtle`,children:t(`pipeline.nodeLoadOverview.acceleratorsNotReadYet`,`Accelerators not read yet.`)}):o(`div`,{className:`mt-2 border-t border-border pt-1.5`,children:[o(`div`,{className:`flex items-center gap-1 text-[9px] uppercase tracking-wider text-foreground-subtle`,children:[f(x,{className:`h-2.5 w-2.5`}),t(`pipeline.nodeLoadOverview.accelerators`,`Accelerators`),e.eligibleDeviceCount===0&&f(`span`,{className:`ml-1 normal-case tracking-normal text-amber-400`,title:t(`pipeline.nodeLoadOverview.noDeviceIsACamera`,`No device is a camera-root candidate on this node — sessions run on the runner's default (CPU) pool.`),children:t(`pipeline.nodeLoadOverview.noneInPlayRunnerDefault`,`none in play · runner default pool`)})]}),f(`ul`,{className:`mt-1 space-y-0.5`,children:e.devices.map(e=>f(Ui,{device:e},e.key))})]})}function Ui({device:e}){let{t}=J(),n=e.exclusion;return o(`li`,{className:`flex items-baseline gap-1.5 text-[10px] min-w-0`,children:[f(T,{className:`h-2.5 w-2.5 shrink-0 ${n===null?`text-foreground-subtle`:`text-foreground-subtle/50`}`}),f(`span`,{className:`shrink-0 font-medium ${n===null?`text-foreground`:`text-foreground-subtle`}`,title:`${e.key} · ${e.format}`,children:e.label}),n===null?o(s,{children:[f(`span`,{className:`shrink-0 tabular-nums text-foreground-subtle`,children:t(`pipeline.nodeLoadOverview.sharePct`,{pct:e.weightSharePct})}),o(`span`,{className:`shrink-0 tabular-nums text-foreground-subtle`,title:e.sessions===null?t(`pipeline.nodeLoadOverview.notKnownTheNodeDid`,`Not known: the node did not report, or runs a session no device accounts for.`):void 0,children:[`· `,t(`common.sessionsCount`,{count:e.sessions??0}),e.maxSessions===null?``:`/${e.maxSessions}`]}),e.atCap&&f(`span`,{className:`shrink-0 text-amber-400`,title:t(`pipeline.nodeLoadOverview.atItsMaxsessionsCapThe`,`At its maxSessions cap — the balancer skips it until a session ends.`),children:t(`pipeline.nodeLoadOverview.atCap`,`· at cap`)})]}):f(`span`,{className:`truncate text-foreground-subtle/80`,title:t(Ni[n]),children:t(`pipeline.nodeLoadOverview.excludedWith`,{reason:t(Ni[n])})})]})}function X({label:e,value:t,title:n}){return o(`div`,{className:`min-w-0`,title:n,children:[f(`dt`,{className:`text-[9px] uppercase tracking-wide text-foreground-subtle`,children:e}),f(`dd`,{className:`truncate font-medium tabular-nums text-foreground`,children:t})]})}function Wi(e){return{nodes:Object.fromEntries(e.map(e=>[e.nodeId,Math.max(1,e.weight)])),devices:{}}}function Gi(e){let t={},n={};for(let r of e.nodes){if(r.share===null||r.share<=0)continue;t[r.nodeId]=r.share;let e=Object.fromEntries(r.devices.filter(e=>e.share>0).map(e=>[e.deviceKey,e.share]));Object.keys(e).length>0&&(n[r.nodeId]=e)}return{nodes:t,devices:n}}function Ki(e){return Object.fromEntries(e.nodes.map(e=>[e.nodeId,Object.fromEntries(e.devices.map(e=>[e.deviceKey,e.suggestedMaxSessions]))]))}function qi(e){return e.reason===`disabled`?q.t(`helpers.loadBalancingViewModel.stalePinDisabled`,{deviceKey:e.deviceKey}):q.t(`helpers.loadBalancingViewModel.stalePinMissing`,{deviceKey:e.deviceKey})}function Ji(e,t){if(t===void 0||t.source===`manual`||t.autoPending)return{nodes:e,readOnly:t!==void 0&&t.source!==`manual`};let n=new Map(t.nodes.map(e=>[e.nodeId,e.configuredPct]));return{nodes:e.map(e=>({...e,weight:Math.round(n.get(e.id)??e.weight)})),readOnly:!0}}function Yi(e,t){let n=e.nodes.filter(e=>!e.eligible);if(n.length===0)return null;let r=e.nodes.filter(e=>e.eligible).map(e=>`${t(e.nodeId)} ${Math.round(e.effectivePct)}%`).join(`, `),i=n.map(e=>t(e.nodeId)).join(`, `);return q.t(`helpers.loadBalancingViewModel.shareNote`,{count:n.length,names:i,into:r})}var Xi=[{value:`hardware`,get label(){return q.t(`helpers.loadBalancingViewModel.hardwareLabel`)},get hint(){return q.t(`helpers.loadBalancingViewModel.hardwareHint`)}},{value:`benchmark`,get label(){return q.t(`helpers.loadBalancingViewModel.benchmarkLabel`)},get hint(){return q.t(`helpers.loadBalancingViewModel.benchmarkHint`)}},{value:`manual`,get label(){return q.t(`helpers.loadBalancingViewModel.manualLabel`)},get hint(){return q.t(`helpers.loadBalancingViewModel.manualHint`)}}];function Zi(e){return e===`no-benchmark-results`?q.t(`helpers.loadBalancingViewModel.fallbackNone`):e===`partial-benchmark-results`?q.t(`helpers.loadBalancingViewModel.fallbackPartial`):null}function Qi(e,t){if(e.source!==`benchmark`)return null;let n=e.nodes.filter(e=>e.capacityFallback!==null);return n.length===0?null:n.map(e=>`${t(e.nodeId)}: ${Zi(e.capacityFallback)??``}`).join(` · `)}t();function $i(e,t,n){return Math.min(Math.max(e,t),n)}function ea(e){let t=e.reduce((e,t)=>e+Math.max(t.weight,0),0);if(t<=0){let t=e.length>0?100/e.length:0;return Object.fromEntries(e.map(e=>[e.id,t]))}return Object.fromEntries(e.map(e=>[e.id,Math.max(e.weight,0)/t*100]))}function ta(e,t,n,r,i){let a=i.filter(e=>e!==t&&r.has(e)).reduce((t,n)=>t+Math.max(e[n]??0,0),0),o=Math.max(0,100-a),s=i.filter(e=>e!==t&&!r.has(e)),c=s.length===0?o:$i(n,0,o),l={...e,[t]:c};if(s.length>0){let e=Math.max(0,o-c)/s.length;for(let t of s)l[t]=e}return l}function na(e,t,n){let r={},i=0,a=[];for(let o of t){let t=Math.max(e[o]??0,0);if(n.has(o)){let e=Math.round(t);r[o]=e,i+=e}else{let e=Math.floor(t);r[o]=e,a.push({id:o,floor:e,frac:t-e})}}let o=Math.max(0,100-i)-a.reduce((e,t)=>e+t.floor,0),s=[...a].sort((e,t)=>t.frac-e.frac);for(let e=0;o>0&&s.length>0;e+=1)r[s[e%s.length].id]+=1,--o;let c=[...a].sort((e,t)=>e.frac-t.frac);for(let e=0;o<0&&c.length>0;e+=1){let t=c[e%c.length].id;r[t]>0&&(--r[t],o+=1)}return r}function ra({nodes:e,pending:t,onCommitWeights:r,weightLabel:a=`Detection weight`,emptyHint:c,footnote:l,readOnly:u=!1}){let{t:d}=J(),[p,m]=i(()=>ea(e)),[h,g]=i(new Set);n(()=>{m(ea(e)),g(t=>new Set([...t].filter(t=>e.some(e=>e.id===t))))},[e.map(e=>`${e.id}:${e.weight}`).join(`|`)]);let _=e.map(e=>e.id),v=e=>{g(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},y=(e,t)=>{m(n=>ta(n,e,t,h,_))},b=()=>{let t=na(p,_,h),n=e.filter(e=>(t[e.id]??0)!==e.weight).map(e=>e.id);if(n.length===0)return;let i=new Set([...n,...h]);r(e.filter(e=>i.has(e.id)).map(e=>({nodeId:e.id,weight:t[e.id]??0})))};if(e.length===0)return f(`p`,{className:`rounded-lg border border-dashed border-border bg-background px-4 py-6 text-center text-xs text-foreground-subtle`,children:c??d(`placementBoard.weightSliderStack.noDetectEnabledNodesEnable`,`No detect-enabled nodes. Enable “Detect” on a node above to distribute detection weight.`)});let x=e.length===1;return o(`div`,{className:`space-y-3`,children:[e.map(e=>{let n=p[e.id]??0,r=h.has(e.id);return o(`div`,{className:`flex items-center gap-3`,children:[f(`span`,{className:`w-28 shrink-0 truncate text-xs font-medium text-foreground`,title:e.name,children:e.name}),f(`input`,{"aria-label":d(`placementBoard.weightSliderStack.for`,`{{weightLabel}} for {{name}}`,{weightLabel:a,name:e.name}),type:`range`,min:0,max:100,step:1,value:Math.round(n),disabled:u||t||r||x,onChange:t=>y(e.id,Number(t.target.value)),onPointerUp:()=>b(),onKeyUp:()=>b(),className:`h-1.5 flex-1 cursor-pointer accent-primary disabled:cursor-not-allowed disabled:opacity-50`}),o(`span`,{className:`w-10 shrink-0 text-right font-mono text-xs tabular-nums text-foreground`,children:[Math.round(n),`%`]}),!u&&f(`button`,{type:`button`,onClick:()=>v(e.id),disabled:t||x,"aria-pressed":r,title:r?d(`placementBoard.weightSliderStack.unlockAllowRebalancing`,`Unlock — allow rebalancing`):d(`placementBoard.weightSliderStack.lockThisShareWhenOthers`,`Lock this share when others change`),className:`shrink-0 rounded p-1 hover:bg-surface-hover disabled:opacity-40 ${r?`text-amber-400`:`text-foreground-subtle`}`,children:f(r?ee:N,{className:`h-3.5 w-3.5`})})]},e.id)}),f(`p`,{className:`text-[10px] leading-tight text-foreground-subtle`,children:l??f(s,{children:d(`placementBoard.weightSliderStack.draggingOneSliderSplitsThe`,`Dragging one slider splits the rest equally across the unlocked nodes; lock a node to pin its share — locked nodes never move and the total always stays at 100%, so a drag is bounded by the room the unlocked nodes leave. Detection only distributes across nodes that can source a camera’s frames.`)})})]})}function ia(e){let t=e.steps?.[`object-detection`]?.modelId;return typeof t==`string`&&t.length>0?t:typeof e.defaultModelId==`string`&&e.defaultModelId.length>0?e.defaultModelId:null}function aa(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`}}function oa(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:aa(e),share:t===void 0?null:{configuredPct:t.configuredPct,effectivePct:t.effectivePct},sessionsNow:a,atCap:a!==null&&e.maxSessions!==null&&a>=e.maxSessions}})}var sa={active:`success`,disabled:`neutral`,absent:`danger`,unknown:`neutral`,unavailable:`warning`,backoff:`warning`,"root-incapable":`info`,standby:`neutral`};t();function ca(e){let t=bt(e),n=e.backend.toLowerCase(),r=e.device.toLowerCase();return e.key===`cpu`||r===`cpu`?{label:t,Icon:T,hue:`slate`}:r===`npu`?{label:t,Icon:V,hue:`sky`}:r===`gpu`||r===`igpu`?{label:t,Icon:Ee,hue:`violet`}:n===`edgetpu`?{label:t,Icon:Ae,hue:`emerald`}:{label:t,Icon:T,hue:`slate`}}var la={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`],standby:[`placementBoard.nodeInferenceDevices.state.standby`,`fallback`]},ua={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.`],standby:[`placementBoard.nodeInferenceDevices.stateHint.standby`,`The CPU fallback: it takes no sessions while an accelerator is serving this node.`]};function da({nodeId:e,nodeName:t,isOnline:a,suggestedMaxSessions:c,shareSource:u,sharesAutomatic:d,share:p,placed:m}){let{t:h}=J(),_=l(),{data:v,isLoading:y}=Ft({nodeId:e},{refetchInterval:15e3}),b=()=>{_.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getNodeInferenceDevices`]]})},x=nt({onSettled:b}),S=Lt({onSettled:b}),C=Fe.platformProbe.rescanAccelerators.useMutation({onSettled:b}),w=v?.devices??[],T=v?.reachable??a,[E,O]=i({});n(()=>{O(Object.fromEntries(w.map(e=>[e.key,fa(e)])))},[w.map(e=>`${e.key}:${e.enabled}:${e.weight}:${e.maxSessions}:${JSON.stringify(e.steps??{})}`).join(`|`)]);let A=r(()=>w.filter(e=>(E[e.key]?.enabled??e.enabled)&&e.available).length,[w,E]),[j,M]=i(null),N=j??!0,P=t=>{let n=w.map(e=>{let n=t[e.key]??fa(e);return{key:e.key,enabled:n.enabled,weight:n.weight,maxSessions:n.maxSessions,steps:n.steps}});x.mutate({agentNodeId:e,inferenceDevices:Mr(n)})},F=(e,t)=>{let n=E[e.key]??fa(e),r={...E,[e.key]:{...n,...t}};O(r),P(r)},I=r(()=>oa(w,p,m),[w,p,m]),L=r(()=>w.filter(e=>(E[e.key]?.enabled??e.enabled)&&e.available),[w,E]),R=r(()=>L.map(e=>({id:e.key,name:ca(e).label,weight:E[e.key]?.weight??e.weight})),[L,E]),ee=e=>{let t={...E};for(let n of e){let e=t[n.nodeId];e&&(t[n.nodeId]={...e,weight:n.weight})}O(t),P(t)},z=x.isPending||S.isPending,te=pa(h,d?u:`manual`),B=[{key:`device`,header:h(`placementBoard.nodeInferenceDevices.colDevice`,`Device`),nowrap:!1,sortValue:e=>ca(e.device).label,render:e=>f(ha,{row:e,steps:E[e.device.key]?.steps})},{key:`state`,header:h(`placementBoard.nodeInferenceDevices.colState`,`State`),sortValue:e=>e.state,render:e=>f(`span`,{title:h(ua[e.state][0],ua[e.state][1]),children:f(W,{variant:sa[e.state],size:`sm`,children:h(la[e.state][0],la[e.state][1])})})},{key:`share`,header:h(`placementBoard.nodeInferenceDevices.colShare`,`Share`),align:`right`,sortValue:e=>e.share?.effectivePct??null,render:e=>f(ga,{row:e,sourceLabel:te})},{key:`sessions`,header:h(`placementBoard.nodeInferenceDevices.colSessions`,`Sessions`),align:`right`,sortValue:e=>e.sessionsNow,render:e=>o(`span`,{className:`tabular-nums text-xs text-foreground`,children:[e.sessionsNow??`—`,e.atCap&&f(W,{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:e=>{let t=E[e.device.key]??fa(e.device);if(!(t.enabled&&e.device.available))return f(`span`,{className:`text-xs text-foreground-subtle`,children:`—`});let n=ca(e.device).label;return o(`div`,{className:`flex items-center justify-end gap-1`,children:[f(rt,{type:`number`,min:1,placeholder:`∞`,value:t.maxSessions??``,onChange:t=>{let n=t.target.value.trim(),r=n===``?null:Number.parseInt(n,10);F(e.device,{maxSessions:r!==null&&r>0?r:null})},disabled:z,"aria-label":h(`placementBoard.nodeInferenceDevices.maxConcurrentSessionsFor`,`Max concurrent sessions for {{label}}`,{label:n}),className:`w-16 text-right`}),f(_a,{suggested:c?.[e.device.key]??null,current:t.maxSessions,pending:z,onApply:t=>F(e.device,{maxSessions:t})})]})}},{key:`enabled`,header:h(`placementBoard.nodeInferenceDevices.colEnabled`,`Enabled`),align:`right`,notSortableReason:h(`placementBoard.nodeInferenceDevices.enabledNotSortable`,`A switch: sort by State instead.`),render:n=>{let r=ca(n.device).label;if(n.state===`absent`)return f(Yt,{label:h(`placementBoard.nodeInferenceDevices.forget`,`Forget`),icon:g,size:`sm`,triggerVariant:`ghost`,disabled:z,title:h(`placementBoard.nodeInferenceDevices.forgetTitle`,`Forget {{label}} on {{node}}?`,{label:r,node:t}),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:()=>S.mutateAsync({agentNodeId:e,deviceKey:n.device.key})});let i=E[n.device.key]??fa(n.device);return f(qt,{checked:i.enabled&&n.device.available,onCheckedChange:()=>F(n.device,{enabled:!i.enabled}),disabled:!n.device.available||z,"aria-label":h(`placementBoard.nodeInferenceDevices.enable`,`Enable {{label}}`,{label:r})})}}],V=x.error??S.error??C.error;return o(`div`,{className:`rounded-lg border border-border bg-surface`,children:[o(`div`,{className:`flex items-center gap-2 px-3 py-2`,children:[o(G,{variant:`ghost`,size:`sm`,onClick:()=>M(!N),className:`min-w-0 flex-1 justify-start`,"aria-expanded":N,children:[f(oe,{className:`h-4 w-4 shrink-0 text-foreground-subtle transition-transform ${N?`rotate-90`:``}`}),f(`span`,{className:`truncate text-sm font-medium text-foreground`,children:t}),f(`span`,{className:`ml-auto flex items-center gap-1 text-xs text-foreground-subtle`,children:T?o(s,{children:[f(Me,{className:`h-3.5 w-3.5`}),h(`pipeline.nodeInferenceDevices.accelerators`,{count:A})]}):o(s,{children:[f(D,{className:`h-3.5 w-3.5`}),` `,h(`common.unreachable`)]})})]}),o(G,{variant:`ghost`,size:`sm`,onClick:()=>C.mutate({nodeId:e}),disabled:C.isPending||!T,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:[f(k,{className:`h-3.5 w-3.5 ${C.isPending?`animate-spin`:``}`}),h(`placementBoard.nodeInferenceDevices.rescan`,`Rescan`)]})]}),N&&o(`div`,{className:`space-y-3 border-t border-border p-3`,children:[T?y&&w.length===0?f(`p`,{className:`text-center text-xs text-foreground-subtle`,children:h(`placementBoard.nodeInferenceDevices.probingAccelerators`,`Probing accelerators…`)}):f(Vt,{columns:B,rows:I,rowKey:e=>e.device.key,minWidthPx:640,bordered:!1,emptyMessage:h(`placementBoard.nodeInferenceDevices.noInferenceDevicesReportedBy`,`No inference devices reported by this node's platform probe.`)}):f(va,{}),C.data!==void 0&&f(`p`,{className:`text-xs text-foreground-subtle`,children:ma(h,C.data.appeared,C.data.disappeared)}),T&&!d&&L.length>=2&&o(`div`,{className:`space-y-3 rounded-lg border border-border p-3`,children:[o(`h4`,{className:`flex items-center gap-1.5 text-xs font-semibold uppercase tracking-wide text-foreground-subtle`,children:[f(Oe,{className:`h-3.5 w-3.5`}),h(`placementBoard.nodeInferenceDevices.acceleratorShare`,`Accelerator share`)]}),f(ra,{nodes:R,pending:z,onCommitWeights:ee,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%.`)})]}),V!=null&&o(`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:`),` `,V.message]})]})]})}function fa(e){return{enabled:e.enabled,weight:e.weight,maxSessions:e.maxSessions,steps:e.steps??{}}}function pa(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 ma(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 ha({row:e,steps:t}){let n=ca(e.device),r=ia({defaultModelId:e.device.defaultModelId,steps:t??e.device.steps??{}});return o(`div`,{className:`flex min-w-0 items-center gap-2`,children:[f(n.Icon,{className:`h-4 w-4 shrink-0 text-foreground-subtle`}),o(`div`,{className:`min-w-0`,children:[o(`div`,{className:`flex items-center gap-1.5`,children:[f(`span`,{className:`text-sm font-medium text-foreground`,children:n.label}),f(W,{variant:`neutral`,size:`sm`,className:`font-mono`,children:e.device.format})]}),o(`div`,{className:`flex flex-wrap items-center gap-x-1.5 text-xs text-foreground-subtle`,children:[f(`span`,{className:`font-mono`,children:e.device.key}),r!==null&&o(s,{children:[f(`span`,{"aria-hidden":!0,children:`·`}),f(`span`,{children:f(vn,{i18nKey:`pipeline.nodeInferenceDevices.rootModel`,values:{model:r},components:{mono:f(`span`,{className:`font-mono text-foreground-muted`})}})})]})]})]})]})}function ga({row:e,sourceLabel:t}){let{t:n}=J();if(e.share===null)return f(`span`,{className:`text-xs text-foreground-subtle`,children:`—`});let{configuredPct:r,effectivePct:i}=e.share,a=Math.round(r)!==Math.round(i);return o(`div`,{className:`text-right`,children:[o(`div`,{className:`tabular-nums text-sm text-foreground`,children:[Math.round(i),`%`]}),o(`div`,{className:`text-xs text-foreground-subtle`,children:[a?n(`placementBoard.nodeInferenceDevices.shareConfigured`,`set {{pct}}%`,{pct:Math.round(r)}):null,a&&t!==null?` · `:null,t]})]})}function _a({suggested:e,current:t,pending:n,onApply:r}){let{t:i}=J();return e===null||e<1||e===t?null:f(G,{variant:`ghost`,size:`sm`,onClick:()=>r(e),disabled:n,title:i(`placementBoard.nodeInferenceDevices.advisoryCapFromTheMeasured`,`Advisory cap from the measured throughput at the suggested model, with the headroom kept free. Applying it writes this device's cap.`),children:i(`pipeline.nodeInferenceDevices.use`,{value:e})})}function va(){let{t:e}=J();return o(`div`,{className:`flex flex-col items-center gap-2 px-4 py-6 text-center`,children:[f(D,{className:`h-6 w-6 text-foreground-subtle`}),f(`p`,{className:`text-xs font-medium text-foreground`,children:e(`placementBoard.nodeInferenceDevices.nodeUnreachable`,`Node unreachable`)}),f(`p`,{className:`max-w-sm text-xs text-foreground-subtle`,children:e(`placementBoard.nodeInferenceDevices.thePlatformProbeCouldnT`,`The platform probe couldn't be reached, so its live accelerator set is unavailable. Settings resume once the node reconnects.`)})]})}t();var ya=3600*1e3,ba=2e4,xa=.4;function Sa({refreshToken:e,onOpenAutoTune:t}){let{t:n}=J(),a=l(),{nodes:c}=U(),d=He(void 0),p=Dt({isCamera:!0,projection:`slim`}),h=fn({windowMs:ya},{refetchInterval:ba,placeholderData:u}).data,g=hn(void 0,{refetchInterval:ba,placeholderData:u}).data,_=()=>{Dn(a),a.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getNodeInferenceDevices`]]})},v=gt({onSuccess:_}),y=We({onSuccess:()=>{_(),a.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getEffectiveShares`]]})}}),b=ot({onSuccess:_}),x=it(),[C,w]=i(!1),D=g?.source,O=D===`benchmark`?`benchmark`:`hardware`,k=Qe({headroom:xa,source:O},{enabled:C,staleTime:1/0}),A=k.data,j=r(()=>{let e=new Map((d.data??[]).map(e=>[e.nodeId,e.settings]));return c.filter(t=>Hn(e.get(t.id),t.isHub).pipeline).map(t=>{let n=e.get(t.id);return{id:t.id,name:t.name,isOnline:t.isOnline,weight:Cn(n,`detectWeight`)??1,maxCameras:Cn(n,`maxCameras`)}})},[c,d.data]),M=e=>c.find(t=>t.id===e)?.name??e,N=tr((p.data??[]).map(e=>({id:e.id,name:e.name}))),P=A?Ki(A):void 0,F=Ji(j,g),I=D!==`manual`,L=g!==void 0&&g.source!==`manual`&&!g.autoPending,R=e=>g?.nodes.find(t=>t.nodeId===e),ee=e=>h?.nodes.find(t=>t.nodeId===e),z=g?Yi(g,M):null,te=g?Qi(g,M):null,ne=Xi.find(e=>e.value===D)?.hint;return o(`div`,{className:`space-y-3 sm:space-y-4`,children:[f(qn,{refreshToken:e}),f(Bi,{stats:h,showAccelerators:!1,...g!==void 0&&g.source!==`manual`&&!g.autoPending?{targetWeights:Object.fromEntries(g.nodes.map(e=>[e.nodeId,e.configuredPct]))}:{}}),f(K,{headingId:`load-balancing-node-shares`,title:n(`pipeline.clusterLoadBalancingTab.nodeShares`,`Node shares`),icon:Oe,actions:o(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[f(`div`,{role:`radiogroup`,"aria-label":n(`pipeline.clusterLoadBalancingTab.shareSource`,`Share source`),className:`flex items-center gap-1`,children:Xi.map(e=>f(G,{role:`radio`,"aria-checked":D===e.value,variant:D===e.value?`primary`:`outline`,size:`sm`,title:e.hint,disabled:y.isPending||g===void 0,onClick:()=>{D!==e.value&&y.mutate({source:e.value})},children:e.label},e.value))}),o(G,{variant:`outline`,size:`sm`,onClick:()=>{w(!0),C&&k.refetch()},disabled:k.isFetching,children:[f(B,{className:`h-3.5 w-3.5`}),k.isFetching?n(`pipeline.clusterLoadBalancingTab.suggesting`,`Suggesting…`):O===`benchmark`?n(`pipeline.clusterLoadBalancingTab.suggestFromBenchmark`,`Suggest from benchmark`):n(`pipeline.clusterLoadBalancingTab.suggestFromHardware`,`Suggest from hardware`)]}),o(G,{variant:`ghost`,size:`sm`,onClick:t,children:[f(E,{className:`h-3.5 w-3.5`}),n(`pipeline.clusterLoadBalancingTab.autoTune`,`Auto tune`)]}),o(G,{variant:`outline`,size:`sm`,onClick:()=>x.mutate(void 0),disabled:x.isPending,title:n(`pipeline.clusterLoadBalancingTab.moveStandingAlwaysOnCameras`,`Move standing (always-on) cameras that are no longer on their best node. Pinned cameras never move; on-motion sessions are placed per session anyway.`),children:[f(V,{className:`h-3.5 w-3.5`}),x.isPending?n(`pipeline.clusterLoadBalancingTab.rebalancing`,`Rebalancing…`):n(`pipeline.clusterLoadBalancingTab.rebalance`,`Rebalance`)]})]}),children:o(`div`,{className:`${m} space-y-3`,children:[ne!==void 0&&f(`p`,{className:`text-[10px] text-foreground-subtle`,children:ne}),h&&o(`p`,{className:`text-[10px] text-foreground-subtle`,children:[n(`pipeline.clusterLoadBalancingTab.policy`,`Policy:`),` `,f(W,{variant:h.policy===`share`?`info`:`default`,children:h.policy===`share`?n(`pipeline.clusterLoadBalancingTab.honourShares`,`honour shares`):`least-loaded`}),` `,` · ${n(`pipeline.clusterLoadBalancingTab.clusterPeak`,{count:h.clusterPeakSessions})}`,h.policy===`least-loaded`&&` · ${n(`pipeline.clusterLoadBalancingTab.leastLoadedNote`)}`]}),f(ra,{nodes:F.nodes,pending:v.isPending,readOnly:F.readOnly,onCommitWeights:e=>v.mutate(Wi(e)),weightLabel:`Node share`,...F.readOnly?{footnote:g?.autoPending?f(s,{children:n(`pipeline.clusterLoadBalancingTab.automaticSharesAreBeingComputed`,`Automatic shares are being computed from the cluster's measured capacity; the stored values are used meanwhile.`)}):o(s,{children:[D===`benchmark`?n(`pipeline.clusterLoadBalancingTab.benchmarkEachNodeSShare`,`Benchmark: each node's share follows its measured capacity from node benchmark results (hardware capacity where it has none)`):n(`pipeline.clusterLoadBalancingTab.hardwareEachNodeSShare`,`Hardware: each node's share follows its capacity at its Auto tune model, from the measured speed of its hardware`),n(`pipeline.clusterLoadBalancingTab.recomputedWheneverANodeOr`,`, recomputed whenever a node or accelerator is added, removed, switched on or off, or changes model`),g?.computedAt!=null&&f(`span`,{className:`ml-1`,children:n(g.trigger===null?`pipeline.clusterLoadBalancingTab.lastAt`:`pipeline.clusterLoadBalancingTab.lastAtTrigger`,{time:new Date(g.computedAt).toLocaleTimeString(),trigger:g.trigger??``})}),`.`]})}:{}}),z!==null&&f(`p`,{className:`text-[10px] text-foreground-subtle`,children:z}),te!==null&&f(`p`,{className:`text-[10px] text-foreground-subtle`,"data-testid":`benchmark-fallback-note`,children:te}),y.isError&&f(Bt,{message:n(`pipeline.clusterLoadBalancingTab.switchFailed`,{message:y.error instanceof Error?y.error.message:n(`common.unknownError`)})}),v.isError&&f(Bt,{message:n(`pipeline.clusterLoadBalancingTab.saveFailed`,{message:v.error instanceof Error?v.error.message:n(`common.unknownError`)})}),o(`details`,{className:`rounded-md border border-border`,children:[f(`summary`,{className:`${S} cursor-pointer text-xs text-foreground`,children:n(`pipeline.clusterLoadBalancingTab.maxConcurrentSessionsAdvanced`,`Max concurrent sessions (advanced)`)}),f(`ul`,{className:`divide-y divide-border border-t border-border`,children:j.map(e=>o(`li`,{className:`${S} flex items-center gap-2`,children:[f(`span`,{className:`min-w-0 flex-1 truncate text-xs text-foreground`,children:e.name}),f(rt,{type:`number`,min:1,placeholder:`∞`,defaultValue:e.maxCameras??``,"aria-label":n(`pipeline.clusterLoadBalancingTab.maxConcurrentSessionsFor`,`Max concurrent sessions for {{name}}`,{name:e.name}),className:`w-20 text-right`,disabled:b.isPending,onBlur:t=>{let n=t.target.value.trim(),r=n===``?null:Number.parseInt(n,10),i=r!==null&&r>0?r:null;i!==e.maxCameras&&b.mutate({agentNodeId:e.id,maxCameras:i})}})]},e.id))}),f(`p`,{className:`${S} ${H} border-t border-border`,children:n(`pipeline.clusterLoadBalancingTab.aHardCapOnThe`,`A hard cap on the sessions a node runs at once (always-on cameras count too). A node at its cap is never chosen; under shares its turn goes to a free node. Empty = unlimited.`)})]})]})}),k.isError&&f(Bt,{message:n(`pipeline.clusterLoadBalancingTab.suggestionFailed`,{message:k.error instanceof Error?k.error.message:n(`common.unknownError`)})}),A&&f(Ca,{suggestion:A,nameOf:M,pending:v.isPending,...I?{}:{onApply:()=>v.mutate(Gi(A))}}),f(K,{headingId:`load-balancing-accelerators`,title:n(`pipeline.clusterLoadBalancingTab.accelerators`,`Accelerators`),icon:T,children:f(`div`,{className:`${m} space-y-2`,children:j.length===0?f(en,{title:n(`pipeline.clusterLoadBalancingTab.noDetectCapableNodes`,`No detect-capable nodes`),description:n(`pipeline.clusterLoadBalancingTab.enableDetectionOnANode`,`Enable detection on a node in Roles & nodes to configure its accelerators.`)}):j.map(e=>f(da,{nodeId:e.id,nodeName:e.name,isOnline:e.isOnline,...P?.[e.id]===void 0?{}:{suggestedMaxSessions:P[e.id]},sharesAutomatic:L,...g===void 0?{}:{shareSource:g.source},...R(e.id)===void 0?{}:{share:R(e.id)},...ee(e.id)===void 0?{}:{placed:ee(e.id)}},e.id))})}),h!==void 0&&h.stalePins.length>0&&f(wa,{stats:h,cameraName:N})]})}function Ca({suggestion:e,nameOf:t,pending:n,onApply:r}){let{t:i}=J();return o(K,{headingId:`load-balancing-suggestion`,title:e.source===`benchmark`?i(`pipeline.clusterLoadBalancingTab.suggestedFromBenchmark`,`Suggested from benchmark`):i(`pipeline.clusterLoadBalancingTab.suggestedFromHardware`,`Suggested from hardware`),icon:B,...r===void 0?{}:{actions:f(G,{size:`sm`,onClick:r,disabled:n,children:i(`pipeline.clusterLoadBalancingTab.applySuggestedShares`,`Apply suggested shares`)})},children:[f(`ul`,{className:`divide-y divide-border`,children:e.nodes.map(e=>o(`li`,{className:`${S} space-y-0.5`,children:[o(`div`,{className:`flex items-baseline gap-2 text-xs`,children:[f(`span`,{className:`min-w-0 flex-1 truncate font-medium text-foreground`,children:t(e.nodeId)}),f(`span`,{className:`tabular-nums text-foreground`,children:e.share===null?i(`common.skipped`):`${e.share}%`})]}),o(`p`,{className:H,children:[Zi(e.capacityFallback)===null?``:`${Zi(e.capacityFallback)} · `,e.skippedReason===null?i(`pipeline.clusterLoadBalancingTab.parallelSessions`,`≈ {{capacitySessions}} parallel sessions · {{value2}}`,{capacitySessions:e.capacitySessions,value2:e.devices.map(e=>`${e.deviceKey} ${e.share}% (${e.modelId??`—`}${e.measured?``:`, estimated`}, cap ${e.suggestedMaxSessions??`—`})`).join(` · `)}):i(`pipeline.clusterLoadBalancingTab.notPartOfTheSuggestion`,`not part of the suggestion — {{skippedReason}}`,{skippedReason:e.skippedReason})]})]},e.nodeId))}),o(`p`,{className:`${S} ${H} border-t border-border`,children:[i(`pipeline.clusterLoadBalancingTab.sharesIntro`,{fps:e.cameraFps,headroom:Math.round(e.headroom*100),basis:e.source===`benchmark`?i(`pipeline.clusterLoadBalancingTab.measuredByNodeBenchmarksOr`,`measured by node benchmarks, or from the hardware table where a node has no results`):i(`pipeline.clusterLoadBalancingTab.atTheModelsAutoTune`,`at the models Auto tune picks (at least {{minSessionsPerDevice}} per accelerator), from the measured speed of each node's hardware`,{minSessionsPerDevice:e.minSessionsPerDevice})}),` `,r===void 0?i(`pipeline.clusterLoadBalancingTab.automaticSharesAlreadyFollowThis`,`Automatic shares already follow this; the caps are advisory — apply each from its accelerator row.`):i(`pipeline.clusterLoadBalancingTab.applyingWritesTheNodeAnd`,`Applying writes the node and accelerator shares; the caps are advisory — apply each from its accelerator row.`)]})]})}function wa({stats:e,cameraName:t}){let{t:n}=J(),r=l(),i=yt({onSuccess:()=>{r.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPlacementStats`]]}),r.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineDevicePin`]]})}});return f(K,{headingId:`load-balancing-stale-pins`,title:n(`pipeline.clusterLoadBalancingTab.staleDevicePins`,`Stale device pins`),icon:ke,children:f(`ul`,{className:`divide-y divide-border`,children:e.stalePins.map(e=>o(`li`,{className:`${S} flex items-center gap-2`,children:[o(`div`,{className:`min-w-0 flex-1`,children:[f(`p`,{className:`truncate text-xs text-foreground`,title:t(e.deviceId),children:t(e.deviceId)}),f(`p`,{className:H,children:qi(e)})]}),f(G,{variant:`outline`,size:`sm`,disabled:i.isPending,onClick:()=>i.mutate({deviceId:e.deviceId,deviceKey:`auto`}),children:n(`pipeline.clusterLoadBalancingTab.clearPin`,`Clear pin`)})]},e.deviceId))})})}function Ta({node:e,emphasis:t=!1}){let{t:n}=J(),r=e.isHub?j:T;return o(`div`,{className:`flex items-center gap-2.5 min-w-0`,children:[f(`span`,{className:`h-2 w-2 shrink-0 rounded-full ${e.isOnline?`bg-success`:`bg-danger`}`,"aria-hidden":`true`}),f(r,{className:`h-4 w-4 shrink-0 text-foreground-subtle`,"aria-hidden":`true`}),o(`div`,{className:`min-w-0`,children:[o(`div`,{className:`flex items-center gap-1.5 ${t?`text-sm`:`text-xs`} font-semibold text-foreground`,children:[f(`span`,{className:`truncate`,children:e.name}),e.isHub&&f(W,{variant:`info`,className:`px-1.5 py-0 text-[9px] uppercase tracking-wider`,children:n(`common.hubWord`)}),!e.isOnline&&f(W,{variant:`danger`,className:`px-1.5 py-0 text-[9px] uppercase tracking-wider`,children:n(`common.offline`)})]}),f(`div`,{className:`font-mono text-[10px] text-foreground-subtle truncate`,children:e.id})]})]})}function Ea({nodes:e,actions:t}){let{t:n}=J();return f(Vt,{columns:[{key:`node`,header:n(`placementBoard.nodeCapabilitiesTable.node`,`Node`),sortValue:e=>e.name,render:e=>f(Ta,{node:e})},...On.map(e=>({key:e.key,header:n(e.labelKey),align:`center`,notSortableReason:`A switch — sorting would move the row while it is being changed.`,render:r=>f(qt,{"aria-label":n(`placementBoard.nodeCapabilitiesTable.on`,`{{label}} on {{name}}`,{label:n(e.labelKey),name:r.name}),title:n(e.hintKey),checked:Sn(r.effective,e.key),disabled:t.capabilityPending,onCheckedChange:n=>t.onToggleCapability(r.id,e.key,n)})}))],rows:e,rowKey:e=>e.id,bordered:!1,minWidthPx:720,rowClassName:e=>e.isOnline?void 0:`opacity-60`,emptyMessage:n(`placementBoard.nodeCapabilitiesTable.noClusterNodesReportingYet`,`No cluster nodes reporting yet.`)})}function Da({roleValues:e,options:t,pending:n,onRoleChange:r}){let{t:i}=J(),a=t.map(e=>({value:e.id,label:e.id===`hub`?i(`placementBoard.roleControls.default`,`{{name}} (default)`,{name:e.name}):e.name}));return f(`ul`,{className:`divide-y divide-border`,children:Mn.map(t=>o(`li`,{className:`${S} flex flex-wrap items-center gap-x-3 gap-y-1.5`,children:[o(`div`,{className:`min-w-0 flex-1 basis-56`,children:[f(`div`,{className:`text-xs font-medium text-foreground`,children:wn(t)}),f(`p`,{className:H,children:Tn(t)})]}),f(`div`,{className:`w-full sm:w-48`,children:f(at,{"aria-label":i(`placementBoard.roleControls.node`,`{{value1}} node`,{value1:wn(t)}),value:e[t],disabled:n,options:a,onChange:e=>r(t,e.target.value)})})]},t))})}t();function Oa(){let{t:e}=J(),t=l(),{nodes:n}=U(),i=He(void 0),a=Xe({addonId:jn}),s=Xe({addonId:xn}),c=Xe({addonId:Nn}),u=()=>Dn(t),d=et({onSuccess:u}),p=kt({onSuccess:u}),m=r(()=>{let e=new Map;for(let t of i.data??[])e.set(t.nodeId,t.settings);return e},[i.data]),h=r(()=>n.map(e=>{let t=m.get(e.id),n=Hn(t,e.isHub);return{id:e.id,name:e.name,isHub:e.isHub,isOnline:e.isOnline,settings:t,effective:n}}),[n,m]),g={ingestNode:An(a.data,`ingestNode`,`hub`),recordingNode:An(s.data,kn,`hub`),audioNode:An(a.data,`audioNode`,`hub`),motionNode:An(a.data,`motionNode`,`hub`),postProcessingNode:An(c.data,En,`hub`)},_=r(()=>{let e=n.filter(e=>e.isOnline).map(e=>e.id),t=e=>n.find(t=>t.id===e)?.name||e;return[...new Set([`hub`,...Mn.map(e=>g[e]),...e])].filter(e=>e.length>0).map(e=>({id:e,name:t(e)}))},[n,g]),v=i.isLoading||a.isLoading||s.isLoading||c.isLoading,y=(e,t,n)=>{d.mutate({agentNodeId:e,[t]:n})},b=(e,t)=>{if(e===`recordingNode`){p.mutate({addonId:xn,patch:{[kn]:t}});return}if(e===`postProcessingNode`){p.mutate({addonId:Nn,patch:{[En]:t}});return}p.mutate({addonId:jn,patch:{[e]:t}})},x={capabilityPending:d.isPending,onToggleCapability:y},S=v?f(L,{className:`h-3.5 w-3.5 animate-spin text-foreground-subtle`,"aria-label":e(`pipeline.clusterRolesNodesTab.loading`,`Loading`)}):null;return o(`div`,{className:`space-y-3 sm:space-y-4`,children:[o(K,{headingId:`roles-nodes-cluster-roles`,title:e(`pipeline.clusterRolesNodesTab.clusterRoles`,`Cluster roles`),icon:De,actions:S,children:[f(`p`,{className:`${H} border-b border-border px-3 py-1.5 sm:px-4`,children:e(`pipeline.clusterRolesNodesTab.oneNodeHoldsEachRole`,`One node holds each role for every camera. Detection shares and caps are on Load balancing.`)}),f(Da,{roleValues:g,options:_,pending:p.isPending,onRoleChange:b})]}),f(K,{headingId:`roles-nodes-node-capabilities`,title:e(`pipeline.clusterRolesNodesTab.nodeCapabilities`,`Node capabilities`),icon:j,children:f(Ea,{nodes:h,actions:x})})]})}var ka=`pipeline-analytics`,Aa=`face-gallery`,ja=`pipeline-orchestrator`,Ma=`pipeline-runner`,Na=`audio-analyzer`;function Pa(e){return[...xe.filter(t=>t.stepId===e).map(e=>me(e.stepId)),...de.filter(t=>t.stepId===e).map(e=>he(e.stepId,e.key))]}var Fa=`faces`,Ia=`semantic-search`,La=`load-balancer`,Ra=`load`,za=[{id:Fa,get title(){return q.t(`helpers.clusterSettingsSections.facesTitle`)},get hint(){return q.t(`helpers.clusterSettingsSections.facesHint`)},panels:[{addonId:ja,fieldKeys:Pa(`face-embedding`)},{addonId:ka,capability:Aa}]},{id:Ia,get title(){return q.t(`helpers.clusterSettingsSections.semanticTitle`)},get hint(){return q.t(`helpers.clusterSettingsSections.semanticHint`)},panels:[{addonId:ja,fieldKeys:Pa(`clip-embedding`)}]},{id:ge,get title(){return q.t(`helpers.clusterSettingsSections.cropTitle`)},get hint(){return q.t(`helpers.clusterSettingsSections.cropHint`)},panels:[{addonId:ja,sectionIds:[ge]}]},{id:Se,get title(){return q.t(`helpers.clusterSettingsSections.nativeTitle`)},get hint(){return q.t(`helpers.clusterSettingsSections.nativeHint`)},panels:[{addonId:ja,sectionIds:[Se]}]},{id:`runner-defaults`,get title(){return q.t(`helpers.clusterSettingsSections.runnerTitle`)},get hint(){return q.t(`helpers.clusterSettingsSections.runnerHint`)},panels:[{addonId:Ma,fieldScope:`cluster`},{addonId:Na,fieldScope:`cluster`}]},{id:La,get title(){return q.t(`helpers.clusterSettingsSections.loadTitle`)},get hint(){return q.t(`helpers.clusterSettingsSections.loadHint`)},panels:[{addonId:ja,sectionIds:[Ra]}]},{id:`failover`,get title(){return q.t(`helpers.clusterSettingsSections.failoverTitle`)},get hint(){return q.t(`helpers.clusterSettingsSections.failoverHint`)},panels:[{addonId:ja,sectionIds:[`failover`]}]}],Ba={"cluster-step-models":Fa};function Va(e){return e===`clip-embedding`?Ia:Fa}t();var Ha=2500,Ua={faces:I,"semantic-search":E,"detail-crop":je,"native-lease":Me,"runner-defaults":T,"load-balancer":Oe,failover:A},Wa=[`cluster`,Ra];function Ga(e){n(()=>{if(e===null)return;let t=Ba[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`),Ha),!0)};if(r())return;let i=new MutationObserver(()=>{r()&&i.disconnect()});return i.observe(document.body,{childList:!0,subtree:!0}),()=>i.disconnect()},[e])}function Ka({section:e}){let{t}=J();return f(`div`,{"data-cluster-settings-card":e.id,className:`rounded-lg`,children:f(K,{headingId:`cluster-settings-${e.id}`,title:e.title,...Ua[e.id]===void 0?{}:{icon:Ua[e.id]},children:o(`div`,{className:`${m} space-y-3`,children:[f(`p`,{className:H,children:e.hint}),e.panels.map(e=>f(bn,{nodeId:`hub`,addonIds:[e.addonId],level:`global`,hideSectionChrome:!0,omitSectionIds:Wa.filter(t=>!(e.sectionIds??[]).includes(t)),emptyMessage:t(`pipeline.clusterSettingsTab.notAvailableTheAddonThat`,`Not available — the addon that owns these settings did not answer.`),...e.capability===void 0?{}:{capability:e.capability},...e.sectionIds===void 0?{}:{sectionIds:e.sectionIds},...e.fieldKeys===void 0?{}:{fieldKeys:e.fieldKeys},...e.fieldScope===void 0?{}:{fieldScope:e.fieldScope}},`${e.addonId}:${e.capability??``}`))]})})})}function qa({refreshToken:e}){let[t]=yn();return Ga(t.get(Zo)),f(`div`,{className:`space-y-3 sm:space-y-4`,children:za.map(e=>f(Ka,{section:e},e.id))})}var Ja=`pipeline-orchestrator`,Ya=200;function Xa(){let{t:e}=J();return o(`div`,{className:`flex flex-col gap-3`,children:[o(`div`,{children:[f(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:e(`pipeline.clusterOrchestratorLogsTab.orchestratorLogs`,`Orchestrator logs`)}),f(`p`,{className:`text-[11px] text-foreground-subtle`,children:e(`pipeline.clusterOrchestratorLogsTab.dispatchDecisionsBalancerMovesAnd`,`Dispatch decisions, balancer moves and failover events from the pipeline orchestrator. Streaming live; the device chip on a line tells which camera it refers to.`)})]}),f(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:f(At,{addonId:Ja,limit:Ya,maxHeight:`max-h-[calc(100vh-360px)]`,showScope:!0,showDeviceChip:!0,showFilters:!1,showSourceSelect:!0})})]})}var Za=[{id:`assignments`,labelKey:`pipeline.clusterDetail.tabAssignments`},{id:`load-balancing`,labelKey:`pipeline.clusterDetail.tabLoadBalancing`},{id:`auto-tune`,labelKey:`pipeline.clusterDetail.tabAutoTune`},{id:`roles-nodes`,labelKey:`pipeline.clusterDetail.tabRoles`},{id:`settings`,labelKey:`common.settings`},{id:`logs`,labelKey:`common.logs`}];function Qa(e){return Za.some(t=>t.id===e)}function $a({refreshToken:e}){let{t}=J(),[n,r]=yn(),i=n.get(Xo),a=Qa(i)?i:`assignments`,s=e=>{r(t=>{let n=new URLSearchParams(t);return n.set(Xo,e),n.delete(Zo),n},{replace:!0})};return o(`div`,{className:`flex flex-col h-full`,children:[o(`div`,{className:`px-4 sm:px-6 py-4 border-b border-border`,children:[f(`h2`,{className:`text-base font-semibold text-foreground`,children:t(`pipeline.clusterDetail.clusterOrchestration`,`Cluster Orchestration`)}),f(`div`,{className:`text-[11px] text-foreground-subtle mt-1`,children:t(`pipeline.clusterDetail.cameraAssignmentsLoadBalancingThe`,`Camera assignments, load balancing, the detector recommendation, cluster roles and settings.`)})]}),f(`div`,{className:`flex items-center gap-1 px-4 sm:px-6 border-b border-border overflow-x-auto`,children:Za.map(e=>f(`button`,{type:`button`,onClick:()=>s(e.id),className:`shrink-0 whitespace-nowrap px-3 py-2 text-xs font-medium border-b-2 transition-colors ${a===e.id?`border-primary text-primary`:`border-transparent text-foreground-subtle hover:text-foreground`}`,children:t(e.labelKey)},e.id))}),o(`div`,{className:`flex-1 min-h-0 overflow-y-auto p-4 sm:p-6 @container/clustertab`,children:[a===`assignments`&&f(pi,{}),a===`load-balancing`&&f(Sa,{refreshToken:e,onOpenAutoTune:()=>s(`auto-tune`)}),a===`auto-tune`&&f(Mi,{}),a===`roles-nodes`&&f(Oa,{}),a===`settings`&&f(qa,{refreshToken:e}),a===`logs`&&f(Xa,{})]})]})}var eo=`armed:`;function to(e){return e.assignment.reasons.detection?.startsWith(eo)===!0}function no(e){let{assignment:t,detection:n}=e;return n!==null&&n.provisioning.state===`failed`||t.detectionNodeId===null&&n===null&&!to(e)?`error`:n!==null&&n.phase===`active`?`healthy`:`idle`}function ro(e){let t=[],n=[],{assignment:r,detection:i,broker:a}=e;i!==null&&i.provisioning.state===`failed`&&t.push({code:`provisioning-failed`,severity:`error`,message:i.provisioning.error!==void 0&&i.provisioning.error.length>0?q.t(`helpers.cameraCardModel.provisioningFailedWith`,{error:i.provisioning.error}):q.t(`helpers.cameraCardModel.provisioningFailed`)}),i!==null&&i.phase===`active`&&i.actualFps===0&&t.push({code:`detection-black-hole`,severity:`error`,message:q.t(`helpers.cameraCardModel.blackHole`)}),r.detectionNodeId===null&&i===null&&!to(e)&&n.push({code:`unassigned`,severity:`warning`,message:q.t(`helpers.cameraCardModel.unassigned`)});let o=e.degraded??[];if(o.length>0){let e=[...new Set(o.map(e=>e.stage))].join(`, `);n.push({code:`status-unreadable`,severity:`warning`,message:q.t(`helpers.cameraCardModel.statusUnreadable`,{stages:e})})}n.push(...oo(e.cameraSensors));for(let e of a?.profiles??[])e.status===`streaming`&&e.inFps===0&&n.push({code:`broker-stalled`,severity:`warning`,message:q.t(`helpers.cameraCardModel.brokerStalled`,{profile:e.profile})});return[...t,...n]}function io(e){return e.state===`unreadable`&&_e.state===`unreadable`&&e.reason===_e.reason}function ao(e){switch(e.state){case`ready`:return null;case`missing`:return{code:`camera-sensor-missing`,severity:`warning`,message:q.t(`helpers.cameraCardModel.sensorMissing`,{addonId:e.addonId,stableId:e.stableId})};case`offline`:return{code:`camera-sensor-offline`,severity:`warning`,message:q.t(`helpers.cameraCardModel.sensorOffline`,{name:e.name,deviceId:e.deviceId,reason:e.reason})};case`unsupported`:return{code:`camera-sensor-unsupported`,severity:`warning`,message:q.t(`helpers.cameraCardModel.sensorUnsupported`,{name:e.name,deviceId:e.deviceId,reason:e.reason})};case`unreadable`:return{code:`camera-sensor-unreadable`,severity:`warning`,message:q.t(`helpers.cameraCardModel.sensorUnreadable`,{addonId:e.addonId,stableId:e.stableId,reason:e.reason})}}}function oo(e){if(e===void 0||e.state===`not-configured`)return[];if(e.state===`unreadable`)return io(e)?[]:[{code:`camera-sensors-unreadable`,severity:`warning`,message:q.t(`helpers.cameraCardModel.sensorsUnreadable`,{reason:e.reason})}];let t=e.sensors.flatMap(e=>{let t=ao(e);return t===null?[]:[t]}),n=e.notForwarded===void 0?t:[so(e.notForwarded),...t];return e.notEnforced===void 0?n:[{code:`camera-sensors-not-enforced`,severity:`warning`,message:q.t(`helpers.cameraCardModel.notEnforced`)},...n]}function so(e){return{code:`camera-sensors-not-forwarded`,severity:`warning`,message:e===`onboard-not-listed`?q.t(`helpers.cameraCardModel.notForwardedOnboard`):q.t(`helpers.cameraCardModel.notForwardedNoDetection`)}}function co(e){return e===void 0?q.t(`helpers.cameraCardModel.summaryUnavailable`):e.state===`not-configured`?q.t(`helpers.cameraCardModel.summaryNone`):e.state===`unreadable`?q.t(`helpers.cameraCardModel.summaryUnknown`,{reason:e.reason}):e.sensors.map(uo).join(`, `)}function lo(e){return e.mode===`in-addition`?``:` · ${e.mode}`}function uo(e){return`${fo(e)}${lo(e)}`}function fo(e){switch(e.state){case`ready`:return`${e.name} (#${e.deviceId})`;case`offline`:return`${e.name} (#${e.deviceId}) — ${e.reason}`;case`unsupported`:return q.t(`helpers.cameraCardModel.summaryUnsupported`,{name:e.name,deviceId:e.deviceId});case`missing`:case`unreadable`:return`${e.addonId}/${e.stableId} — ${e.state}`}}function po(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function mo(e){return typeof e==`string`&&e.length>0?e:null}function ho(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function go(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function _o(e,t){return e==null?!1:JSON.stringify(e)!==JSON.stringify(t??null)}var vo={detectionMode:null,detectionStreamProfile:null,detectionFps:null,motionSources:[],motionFps:null,motionCooldownMs:null,motionStreamProfile:null,audioMode:null,pipelineNodeId:null,decoderNodeId:null,audioNodeId:null,overriddenKeys:new Set};function yo(e){if(!po(e)||!Array.isArray(e.sections))return vo;let t=ue(e),n=e=>{let n=t.get(e);if(n!==void 0)return n.value??n.default},r=new Set;for(let[e,n]of t)_o(n.value,n.default)&&r.add(e);return{detectionMode:mo(n(`detectionMode`)),detectionStreamProfile:mo(n(`detectionStreamProfile`)),detectionFps:ho(n(`detectionFps`)),motionSources:go(n(`motionSources`)),motionFps:ho(n(`motionFps`)),motionCooldownMs:ho(n(`motionCooldownMs`)),motionStreamProfile:mo(n(`motionStreamProfile`)),audioMode:mo(n(`audioMode`)),pipelineNodeId:mo(n(`pipelineNodeId`)),decoderNodeId:mo(n(`decoderNodeId`)),audioNodeId:mo(n(`audioNodeId`)),overriddenKeys:r}}function bo(e,t=0){let n=[];for(let r of e)n.push({addonId:r.addonId,modelId:r.modelId??null,enabled:r.enabled,depth:t}),r.children!==void 0&&r.children.length>0&&n.push(...bo(r.children,t+1));return n}function Z({title:e,children:t}){return o(`div`,{className:`bg-background px-3.5 py-3 min-w-0`,children:[f(`div`,{className:`text-[9px] font-semibold uppercase tracking-[0.14em] text-foreground-subtle mb-2`,children:e}),f(`div`,{className:`flex flex-col gap-1 min-w-0`,children:t})]})}function Q({label:e,children:t,overridden:n=!1}){return o(`div`,{className:`flex items-baseline gap-2 text-[11px] leading-snug min-w-0`,children:[f(`span`,{className:`text-foreground-subtle shrink-0 w-24 truncate`,title:e,children:e}),f(`span`,{className:`font-mono tabular-nums text-foreground min-w-0 truncate flex-1`,children:t}),n&&f(xo,{})]})}function xo(){let{t:e}=J();return f(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full bg-warning shrink-0 self-center`,title:e(`cameras.cardPrimitives.deviceLevelOverrideActive`,`Device-level override active`),"aria-label":e(`cameras.cardPrimitives.deviceLevelOverrideActive`,`Device-level override active`),role:`img`})}var So={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 $({tone:e=`neutral`,children:t,title:n}){return f(`span`,{title:n,className:`inline-flex items-center gap-1 rounded border px-1.5 py-px text-[10px] font-medium leading-tight whitespace-nowrap ${So[e]}`,children:t})}function Co({children:e}){return f(`div`,{className:`text-[11px] text-foreground-subtle italic`,children:e})}function wo({icon:e,label:t,nodeId:n,pinned:r,reason:i,overridden:a}){let{t:c}=J();return o(`div`,{className:`flex items-center gap-2 text-[11px] leading-snug min-w-0`,children:[f(e,{className:`h-3 w-3 text-foreground-subtle shrink-0`}),f(`span`,{className:`text-foreground-subtle w-[4.5rem] shrink-0`,children:t}),n===null?f(`span`,{className:`text-foreground-subtle italic`,children:c(`cameras.configBlocks.unassigned`)}):o(s,{children:[f(`span`,{className:`font-mono text-foreground truncate`,title:n,children:n}),r?o(`span`,{className:`inline-flex items-center gap-0.5 text-[10px] text-warning shrink-0`,title:c(`cameras.configBlocks.manuallyPinned`,`Manually pinned`),children:[f(v,{className:`h-2.5 w-2.5`}),` `,c(`cameras.configBlocks.manual`)]}):f(`span`,{className:`text-[10px] text-foreground-subtle shrink-0 truncate`,children:c(`cameras.configBlocks.autoReason`,{reason:i!==void 0&&i.length>0?i:c(`cameras.configBlocks.capacity`)})}),a&&f(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full bg-warning shrink-0`,title:c(`cameras.configBlocks.persistedSettingsPinForThis`,`Persisted settings pin for this role`)})]})]})}function To({assignment:e,settings:t,onlineNodes:n,pinPending:r,onDetectionPinChange:i}){let{t:a}=J(),s=e.pinned.detection&&e.detectionNodeId!==null?e.detectionNodeId:`auto`,c=[...new Set([...e.detectionNodeId===null?[]:[e.detectionNodeId],...n.map(e=>e.id)])];return o(Z,{title:a(`cameras.configBlocks.whereItRuns`,`Where it runs`),children:[f(wo,{icon:T,label:a(`cameras.configBlocks.detection`,`Detection`),nodeId:e.detectionNodeId,pinned:e.pinned.detection,reason:e.reasons.detection,overridden:t.overriddenKeys.has(`pipelineNodeId`)}),f(wo,{icon:h,label:a(`cameras.configBlocks.decoder`,`Decoder`),nodeId:e.decoderNodeId,pinned:e.pinned.decoder,reason:e.reasons.decoder,overridden:t.overriddenKeys.has(`decoderNodeId`)}),f(wo,{icon:w,label:a(`cameras.configBlocks.audio`,`Audio`),nodeId:e.audioNodeId,pinned:e.pinned.audio,reason:e.reasons.audio,overridden:t.overriddenKeys.has(`audioNodeId`)}),f(wo,{icon:ie,label:a(`cameras.configBlocks.source`,`Source`),nodeId:e.sourceNodeId,pinned:!1,reason:`ingest owner`,overridden:!1}),f(`div`,{className:`mt-1.5`,children:o(`select`,{value:s,disabled:r,"aria-label":a(`cameras.configBlocks.detectionPlacementPin`,`Detection placement pin`),onChange:e=>i(e.target.value),className:`w-full min-w-0 rounded-md border border-border bg-background px-2 py-1 text-[11px] text-foreground disabled:opacity-50`,children:[f(`option`,{value:`auto`,children:a(`cameras.configBlocks.autoLoadBalanced`,`Auto (load balanced)`)}),c.map(e=>f(`option`,{value:e,children:a(`cameras.configBlocks.pinDetection`,{node:n.find(t=>t.id===e)?.name??e})},e))]})})]})}function Eo(e){return`${e.width}×${e.height} ${e.codec} @${e.fps}fps`}function Do(e,t){if(!(t===null||e===void 0))return e.find(e=>e.profile===t)}function Oo(e){return e===null?q.t(`pipeline.configBlocks.fpsDefault`):e===0?q.t(`pipeline.configBlocks.fpsNative`):`${e} fps`}function ko({streams:e,brokerProfiles:t,settings:n,motionEnabled:r,motionFpsLive:i,cameraSensors:a}){let{t:c}=J(),l=Do(t,n.detectionStreamProfile),u=Do(t,n.motionStreamProfile),d=n.motionSources.includes(`analyzer`);return o(Z,{title:c(`cameras.configBlocks.streamsMotion`,`Streams & motion`),children:[o(Q,{label:c(`cameras.configBlocks.detectStream`,`Detect stream`),overridden:n.overriddenKeys.has(`detectionStreamProfile`),children:[n.detectionStreamProfile??`—`,l!==void 0&&` · ${l.width}×${l.height} ${l.codec}`]}),f(Q,{label:c(`cameras.configBlocks.detectFps`,`Detect FPS`),overridden:n.overriddenKeys.has(`detectionFps`),children:Oo(n.detectionFps)}),o(Q,{label:c(`cameras.configBlocks.motionSrc`,`Motion src`),overridden:n.overriddenKeys.has(`motionSources`),children:[n.motionSources.length>0?n.motionSources.map(le).join(` + `):c(`cameras.configBlocks.none`),r===!1&&` · ${c(`cameras.configBlocks.inactive`)}`]}),f(Q,{label:c(`cameras.configBlocks.cameraSensors`,`Camera sensors`),children:co(a)}),d&&o(s,{children:[o(Q,{label:c(`cameras.configBlocks.motionStream`,`Motion stream`),overridden:n.overriddenKeys.has(`motionStreamProfile`),children:[n.motionStreamProfile??`—`,u!==void 0&&` · ${u.width}×${u.height} ${u.codec}`]}),o(Q,{label:c(`cameras.configBlocks.motionFps`,`Motion FPS`),overridden:n.overriddenKeys.has(`motionFps`),children:[Oo(n.motionFps),i!==null&&` · ${c(`cameras.configBlocks.liveFps`,{fps:i.toFixed(1)})}`]})]}),f(Q,{label:c(`cameras.configBlocks.cooldown`,`Cooldown`),overridden:n.overriddenKeys.has(`motionCooldownMs`),children:n.motionCooldownMs===null?c(`cameras.configBlocks.defaultValue`):`${n.motionCooldownMs/1e3}s`}),f(`div`,{className:`mt-1.5 flex flex-col gap-0.5`,children:e.length===0?f(Co,{children:c(`cameras.configBlocks.noStreamsRegistered`,`No streams registered`)}):e.map(e=>o(`div`,{className:`text-[10px] font-mono text-foreground-subtle truncate`,title:e.camStreamId,children:[f(`span`,{className:`text-foreground-muted`,children:e.kind}),` `,Eo(e)]},e.camStreamId))})]})}function Ao({steps:e,audioModelId:t,audioEnabled:n,audioMode:r}){let{t:i}=J();return o(Z,{title:i(`cameras.configBlocks.pipelineSteps`,`Pipeline steps`),children:[e===void 0?f(Co,{children:i(`cameras.configBlocks.resolving`,`Resolving…`)}):e.length===0?f(Co,{children:i(`cameras.configBlocks.noStepsConfigured`,`No steps configured`)}):f(`div`,{className:`flex flex-wrap gap-1`,children:e.map((e,t)=>f($,{tone:e.enabled&&e.depth===0?`info`:`neutral`,title:e.modelId??e.addonId,children:o(`span`,{className:e.enabled?``:`line-through opacity-60`,children:[e.depth>0&&f(`span`,{className:`opacity-50`,children:`↳ `}),e.addonId,e.modelId!==null&&o(`span`,{className:`font-mono opacity-75`,children:[` · `,e.modelId]})]})},`${e.addonId}-${t}`))}),f(`div`,{className:`mt-1`,children:o(Q,{label:i(`cameras.configBlocks.audioClass`,`Audio class.`),children:[r??`—`,n!==null&&` · ${i(n?`cameras.configBlocks.running`:`cameras.configBlocks.off`)}`,t!==null&&` · ${t}`]})})]})}var jo={ready:`success`,installing:`info`,verifying:`info`,idle:`neutral`,failed:`danger`};function Mo({detection:e,live:t,detectionMode:n,modeOverridden:r}){let i=z(),{t:a}=J();if(e===null)return o(Z,{title:a(`cameras.runtimeBlocks.detectionRuntime`,`Detection runtime`),children:[f(Q,{label:a(`cameras.runtimeBlocks.mode`,`Mode`),overridden:r,children:n??`—`}),f(Co,{children:a(`cameras.runtimeBlocks.detectionStageInactiveOrUnreachable`,`Detection stage inactive or unreachable`)})]});let s=t?.phase??e.phase,c=t?.actualFps??e.actualFps,l=t?.configuredFps??e.configuredFps,u=t?.avgInferenceTimeMs??e.avgInferenceMs,d=t?.queueDepth??e.queueDepth,p=Pt(s,i),m=s===`active`&&c===0;return o(Z,{title:a(`cameras.runtimeBlocks.detectionRuntime`,`Detection runtime`),children:[o(`div`,{className:`flex items-center gap-1.5 mb-0.5`,children:[o(`span`,{className:`inline-flex items-center gap-1 rounded border px-1.5 py-px text-[10px] font-semibold uppercase tracking-wider ${p.badgeClass}`,children:[f(ln,{phase:s,className:`h-2.5 w-2.5`}),p.label]}),t!==void 0&&f(`span`,{className:`text-[9px] text-foreground-subtle uppercase tracking-wider`,children:a(`common.live`)})]}),f(Q,{label:a(`cameras.runtimeBlocks.mode`,`Mode`),overridden:r,children:n??`—`}),o(Q,{label:`FPS`,children:[f(`span`,{className:m?`text-danger font-semibold`:``,children:c.toFixed(1)}),f(`span`,{className:`ml-1 text-foreground-subtle`,children:a(`cameras.runtimeBlocks.configuredFps`,{fps:l.toFixed(0)})})]}),o(Q,{label:a(`cameras.runtimeBlocks.inference`,`Inference`),children:[u.toFixed(0),` ms`,d>0&&f(`span`,{className:`ml-1 text-warning`,children:a(`cameras.runtimeBlocks.queue`,{depth:d})}),t!==void 0&&t.droppedFrames>0&&f(`span`,{className:`ml-1 text-warning`,children:a(`cameras.runtimeBlocks.drops`,{count:t.droppedFrames})})]}),o(Q,{label:a(`cameras.runtimeBlocks.engine`,`Engine`),children:[e.engine.backend,` · `,e.engine.device]}),o(Q,{label:a(`cameras.runtimeBlocks.provisioning`,`Provisioning`),children:[f($,{tone:jo[e.provisioning.state]??`neutral`,children:e.provisioning.state}),e.provisioning.error!==void 0&&o(`span`,{className:`text-danger text-[10px]`,children:[` `,e.provisioning.error]})]})]})}function No({broker:e}){let{t}=J();return e===null?f(Z,{title:t(`cameras.runtimeBlocks.streamBroker`,`Stream broker`),children:f(Co,{children:t(`cameras.runtimeBlocks.brokerStageInactiveOrUnreachable`,`Broker stage inactive or unreachable`)})}):o(Z,{title:t(`cameras.runtimeBlocks.streamBroker`,`Stream broker`),children:[e.profiles.length===0?f(Co,{children:t(`cameras.runtimeBlocks.noBrokerProfiles`,`No broker profiles`)}):f(`div`,{className:`flex flex-col gap-1`,children:e.profiles.map(e=>{let n=e.status===`streaming`,r=n&&e.inFps===0;return o(`div`,{className:`flex items-center gap-2 text-[11px] font-mono tabular-nums min-w-0`,children:[f(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full shrink-0 ${r?`bg-danger`:n?`bg-success animate-pulse`:`bg-border`}`,title:e.status}),f(`span`,{className:`text-foreground w-10 shrink-0 truncate`,title:e.profile,children:e.profile}),o(`span`,{className:`text-foreground-subtle truncate`,children:[e.width,`×`,e.height,` `,e.codec]}),f(`span`,{className:`ml-auto shrink-0 ${r?`text-danger`:`text-foreground`}`,children:t(`cameras.runtimeBlocks.fpsValue`,{value:e.inFps===null?`—`:e.inFps.toFixed(0)})}),o(`span`,{className:`text-foreground-subtle shrink-0`,title:t(`cameras.runtimeBlocks.subscribers`,`Subscribers`),children:[`×`,e.subscribers]})]},e.profile)})}),o(`div`,{className:`mt-1.5 flex flex-wrap gap-1`,children:[f($,{tone:e.webrtcSessions>0?`info`:`neutral`,children:t(`cameras.runtimeBlocks.webrtc`,{count:e.webrtcSessions})}),f($,{tone:e.rtspRestream?`success`:`neutral`,children:e.rtspRestream?t(`cameras.runtimeBlocks.restreamOn`):t(`cameras.runtimeBlocks.restreamOff`)})]})]})}function Po({decoder:e}){let{t}=J();return e===null?f(Z,{title:t(`cameras.runtimeBlocks.decoder`,`Decoder`),children:f(Co,{children:t(`cameras.runtimeBlocks.decoderStageInactiveOrUnreachable`,`Decoder stage inactive or unreachable`)})}):f(Z,{title:t(`cameras.runtimeBlocks.decoder`,`Decoder`),children:f(Q,{label:t(`cameras.runtimeBlocks.node`,`Node`),children:e.nodeId})})}t();var Fo=`pipeline-orchestrator`,Io={healthy:`bg-success`,idle:`bg-warning`,error:`bg-danger`},Lo={healthy:`pipeline.cameraPipelineCard.healthHealthy`,idle:`pipeline.cameraPipelineCard.healthIdle`,error:`pipeline.cameraPipelineCard.healthError`};function Ro({problems:e}){return f(`div`,{role:`alert`,className:`flex flex-col border-b border-border`,children:e.map(e=>o(`div`,{className:`flex items-start gap-2 px-4 py-1.5 text-[11px] font-medium ${e.severity===`error`?`bg-danger/10 text-danger`:`bg-warning/10 text-warning`}`,children:[f(y,{className:`h-3.5 w-3.5 shrink-0 mt-px`}),f(`span`,{className:`min-w-0`,children:e.message})]},e.code))})}function zo({deviceId:e,name:t,online:n,status:i,live:a,onlineNodes:s}){let{t:c}=J(),u=l(),{data:d}=rn({addonId:Fo,deviceId:e,nodeId:`hub`},{staleTime:3e4}),{data:p}=Kt({deviceId:e},{staleTime:3e4}),m=r(()=>yo(d),[d]),h=r(()=>p===void 0?void 0:bo(p.steps),[p]),g=r(()=>i===void 0?[]:ro(i),[i]),_=()=>{u.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCameraStatuses`]]}),u.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineAssignments`]]})},v=cn({onSuccess:_}),y=Ye({onSuccess:_}),b=t=>{t===`auto`?y.mutate({deviceId:e}):v.mutate({deviceId:e,agentNodeId:t})},x=i===void 0?`idle`:no(i),S=g.some(e=>e.severity===`error`),C=g.length>0,w=S?`border-danger/50`:C?`border-warning/40`:`border-border`;return o(`article`,{"aria-label":c(`cameras.cameraPipelineCard.pipelineStatus`,`{{name}} pipeline status`,{name:t}),className:`rounded-lg border ${w} bg-background overflow-hidden`,children:[o(`header`,{className:`flex items-center gap-2.5 px-4 py-2.5 border-b border-border bg-surface/50 min-w-0`,children:[f(`span`,{className:`inline-block h-2 w-2 rounded-full shrink-0 ${S?`bg-danger`:Io[x]}`,title:S?c(`common.error`,`Error`):c(Lo[x]),"aria-label":S?c(`common.error`,`Error`):c(Lo[x]),role:`img`}),f(`h3`,{className:`text-[13px] font-semibold text-foreground truncate`,title:t,children:t}),o(`span`,{className:`text-[10px] text-foreground-subtle shrink-0`,children:[`#`,e]}),!n&&f($,{tone:`danger`,children:c(`common.offline`)}),o(`span`,{className:`ml-auto flex items-center gap-1.5 shrink-0`,children:[m.detectionMode!==null&&f($,{tone:m.detectionMode===`disabled`?`warning`:m.detectionMode===`always-on`?`info`:`neutral`,title:c(`cameras.cameraPipelineCard.objectDetectionMode`,`Object detection mode`),children:m.detectionMode===`disabled`?c(`cameras.cameraPipelineCard.detectionOff`,`detection off`):m.detectionMode}),i?.recording!=null&&(i.recording.active?o($,{tone:`danger`,title:c(`cameras.cameraPipelineCard.recording`,`Recording ({{mode}})`,{mode:i.recording.mode}),children:[f(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full bg-danger animate-pulse`}),`REC`]}):i.recording.mode!==`off`&&f($,{tone:`neutral`,title:c(`cameras.cameraPipelineCard.recordingMode`,`Recording mode`),children:c(`pipeline.cameraPipelineCard.recMode`,{mode:i.recording.mode})}))]})]}),g.length>0&&f(Ro,{problems:g}),i===void 0?f(`div`,{className:`px-4 py-5 text-[11px] text-foreground-subtle italic`,children:c(`cameras.cameraPipelineCard.noPipelineStatusYetThe`,`No pipeline status yet — the orchestrator has not composed a snapshot for this camera.`)}):o(`div`,{className:`grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-px bg-border`,children:[f(To,{assignment:i.assignment,settings:m,onlineNodes:s,pinPending:v.isPending||y.isPending,onDetectionPinChange:b}),f(Mo,{detection:i.detection,live:a,detectionMode:m.detectionMode,modeOverridden:m.overriddenKeys.has(`detectionMode`)}),f(Ao,{steps:h,audioModelId:p?.audio?.modelId??null,audioEnabled:i.audio?.enabled??p?.audio?.enabled??null,audioMode:m.audioMode}),f(ko,{streams:i.source.streams,brokerProfiles:i.broker?.profiles,settings:m,motionEnabled:i.motion?.enabled??null,motionFpsLive:i.motion?.fps??null,cameraSensors:i.cameraSensors}),f(No,{broker:i.broker}),f(Po,{decoder:i.decoder})]})]})}t();var Bo=5e3,Vo=1e4,Ho=5e3;function Uo(e){let t=l(),{data:a,isLoading:o}=gn(),{data:s,isLoading:c}=Ut({},{refetchInterval:Bo}),{nodes:u}=U();n(()=>{e!==0&&t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCameraStatuses`]]})},[e,t]);let[d,f]=i(new Map);dt(se.PipelineCameraMetricsSnapshot,e=>{let t=e.data;typeof t.deviceId==`number`&&f(e=>{let n=new Map(e);return n.set(t.deviceId,{phase:t.metrics.phase,configuredFps:t.metrics.configuredFps,actualFps:t.metrics.actualFps,queueDepth:t.metrics.queueDepth,avgInferenceTimeMs:t.metrics.avgInferenceTimeMs,droppedFrames:t.metrics.droppedFrames,timestamp:t.timestamp}),n})}),n(()=>{if(d.size===0)return;let e=setInterval(()=>{f(e=>{let t=Date.now()-Vo,n=!1,r=new Map(e);for(let[i,a]of e)a.timestamp<t&&(r.delete(i),n=!0);return n?r:e})},Ho);return()=>clearInterval(e)},[d.size]);let p=r(()=>{let e=new Map;for(let t of s??[])e.set(t.deviceId,t);return e},[s]);return{rows:r(()=>(a??[]).filter(e=>e.isCamera).map(e=>({deviceId:e.id,name:e.name,online:e.online,status:p.get(e.id)})).sort((e,t)=>e.name.localeCompare(t.name)),[a,p]),liveMetrics:d,onlineNodes:r(()=>(u??[]).filter(e=>e.isOnline).map(e=>({id:e.id,name:e.name})),[u]),isLoading:o||c}}t();function Wo({refreshToken:e}){let{t}=J(),{rows:n,liveMetrics:i,onlineNodes:a,isLoading:s}=Uo(e),c=r(()=>[...n.map(e=>{let t=e.status===void 0?[]:ro(e.status);return{row:e,errorCount:t.filter(e=>e.severity===`error`).length,warningCount:t.filter(e=>e.severity===`warning`).length}})].sort((e,t)=>e.errorCount===t.errorCount?e.warningCount===t.warningCount?0:t.warningCount-e.warningCount:t.errorCount-e.errorCount),[n]),l=r(()=>{let e=0,t=0;for(let n of c)(n.errorCount>0||n.warningCount>0)&&(t+=1),(i.get(n.row.deviceId)?.phase??n.row.status?.detection?.phase)===`active`&&(e+=1);return{total:c.length,active:e,issues:t}},[c,i]);return s&&n.length===0?f(`div`,{className:`flex items-center justify-center h-full text-sm text-foreground-subtle`,children:t(`cameras.camerasOverview.loadingCameraPipelines`,`Loading camera pipelines…`)}):n.length===0?f(`div`,{className:`flex items-center justify-center h-full text-sm text-foreground-subtle`,children:t(`cameras.camerasOverview.noCamerasFound`,`No cameras found`)}):f(`div`,{className:`h-full overflow-y-auto`,children:o(`div`,{className:`max-w-6xl mx-auto flex flex-col gap-3 px-4 py-4`,children:[o(`div`,{className:`flex items-center gap-4 text-[11px] text-foreground-subtle px-1`,children:[f(`span`,{children:f(vn,{i18nKey:`pipeline.camerasOverview.camerasTotal`,values:{count:l.total},components:{b:f(`span`,{className:`font-semibold text-foreground`})}})}),f(`span`,{children:f(vn,{i18nKey:`pipeline.camerasOverview.activelyInferring`,values:{count:l.active},components:{b:f(`span`,{className:`font-semibold text-success`})}})}),o(`span`,{children:[f(`span`,{className:`font-semibold ${l.issues>0?`text-danger`:`text-foreground`}`,children:l.issues}),` `,t(`cameras.camerasOverview.withIssues`,`with issues`)]}),f(`span`,{className:`ml-auto hidden sm:inline text-[10px]`,children:t(`cameras.camerasOverview.polledEvery5SDetection`,`polled every 5 s · detection metrics live at 1 Hz`)})]}),c.map(({row:e})=>f(zo,{deviceId:e.deviceId,name:e.name,online:e.online,status:e.status,live:i.get(e.deviceId),onlineNodes:a},e.deviceId))]})})}var Go=e({CLUSTER_NODE_ID:()=>Ko,PipelinePage:()=>Yo});t();var Ko=`__cluster__`;function qo(e){return e===`cameras`?`cameras`:`nodes`}function Jo({viewMode:e,onNodes:t,onCameras:n}){let{t:r}=J();return o(`div`,{className:`flex items-center gap-1 rounded-lg border border-border bg-surface p-0.5`,role:`tablist`,"aria-label":r(`pipeline.pipelineView`,`Pipeline view`),children:[f(`button`,{type:`button`,role:`tab`,"aria-selected":e===`nodes`,onClick:t,className:[`rounded-md px-3 py-1 text-[11px] font-medium transition-colors`,e===`nodes`?`bg-background text-foreground shadow-sm`:`text-foreground-subtle hover:text-foreground`].join(` `),children:r(`pipeline.nodes`,`Nodes`)}),f(`button`,{type:`button`,role:`tab`,"aria-selected":e===`cameras`,onClick:n,className:[`rounded-md px-3 py-1 text-[11px] font-medium transition-colors`,e===`cameras`?`bg-background text-foreground shadow-sm`:`text-foreground-subtle hover:text-foreground`].join(` `),children:r(`pipeline.cameras`,`Cameras`)})]})}function Yo(){let{t:e}=J(),[t,r]=yn(),a=qo(t.get(`view`)),c=t.get(`node`)??`__cluster__`,[l,u]=i(0),[d,p]=i(!1);return n(()=>{a===`nodes`&&!t.get(`node`)&&r({view:`nodes`,node:Ko},{replace:!0})},[a,t,r]),o(Xt,{icon:Te,title:e(`pipeline.pipeline`,`Pipeline`),subtitle:e(`pipeline.detectionPlacementLoadAndPer`,`Detection placement, load and per-camera runtime across the cluster.`),actions:o(G,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>u(e=>e+1),title:e(`common.refresh`,`Refresh`),children:[f(k,{className:`h-3.5 w-3.5`}),e(`common.refresh`,`Refresh`)]}),nav:f(Jo,{viewMode:a,onNodes:()=>{r({view:`nodes`,node:c},{replace:!0})},onCameras:()=>{r({view:`cameras`},{replace:!0})}}),className:`flex h-full min-h-0 flex-col overflow-hidden`,children:[a===`nodes`&&o(G,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>p(e=>!e),"aria-expanded":d,className:`flex w-full shrink-0 justify-between border-b border-border md:hidden`,children:[f(`span`,{children:e(d?`pipeline.hideNodeList`:`pipeline.showNodeList`)}),f(re,{className:[`h-4 w-4 transition-transform`,d?`rotate-180`:``].join(` `)})]}),f(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden md:flex-row`,children:a===`nodes`?o(s,{children:[f(`aside`,{className:[d?`block`:`hidden`,`md:block w-full md:w-72 shrink-0 border-b border-border md:border-b-0 md:border-r`,`max-h-[60vh] overflow-y-auto md:max-h-none`].join(` `),children:f(Wn,{selectedNodeId:c,onSelect:e=>{r({view:`nodes`,node:e},{replace:!0}),p(!1)},refreshToken:l})}),f(`section`,{className:`min-h-0 flex-1 overflow-hidden`,children:c===`__cluster__`?f($a,{refreshToken:l}):f(fi,{nodeId:c,refreshToken:l})})]}):f(`section`,{className:`min-h-0 flex-1 overflow-hidden`,children:f(Wo,{refreshToken:l})})})]})}var Xo=`ctab`,Zo=`section`;function Qo(e,t){let n=new URLSearchParams({view:`nodes`,node:Ko,[Xo]:e});return t!==void 0&&n.set(Zo,t),`/system/pipeline?${n.toString()}`}function $o(e){return Qo(`settings`,Va(e))}function es(){return Qo(`load-balancing`)}var ts=`pipeline-orchestrator`;function ns(e){return xe.find(t=>t.stepId===e)??null}function rs({step:e,engineFormat:t,runnableModelIds:n}){let{t:r}=J(),{data:i}=Xe({addonId:ts}),a=fe(i??null)[e.stepId]??e.defaultModelId,s=e.options.find(e=>e.id===a)?.label??a,c=n.length>0&&!n.includes(a);return o(`div`,{className:`space-y-2 rounded-md border border-primary/30 bg-primary/5 px-3 py-2`,children:[o(`div`,{className:`flex flex-wrap items-center gap-2 text-xs`,children:[f(`span`,{className:`font-medium text-foreground`,children:e.label}),f(`span`,{className:`font-mono text-foreground`,children:s}),f(`span`,{title:r(`pipeline.clusterStepModel.oneValueForTheWhole`,`One value for the whole cluster — this step writes into a shared vector index, where two encoders make similarity scores meaningless.`),className:`rounded border border-primary/40 bg-primary/10 px-1 py-px text-[9px] font-medium uppercase tracking-wide text-primary`,children:r(`pipeline.clusterStepModel.clusterWide`)}),f(_n,{to:$o(e.stepId),className:`ml-auto text-[11px] text-primary hover:underline`,children:r(`pipeline.clusterStepModel.changeInClusterSettings`,`Change in Cluster → Settings ›`)})]}),o(`p`,{className:H,children:[r(`pipeline.clusterStepModel.oneModelForEveryNode`,`One model for every node and camera:`),` `,r(`pipeline.clusterStepModel.indexNote`,{index:e.indexName})]}),c&&f(`p`,{className:`rounded border border-warning/40 bg-warning/10 px-2 py-1 text-[10px] leading-snug text-warning`,children:f(vn,{i18nKey:`pipeline.clusterStepModel.noBuild`,values:{engine:t,model:a,index:e.indexName},components:{b:f(`b`,{})}})})]})}export{Pr as _,Qr as a,Lr as c,Ur as d,Gr as f,Fr as g,Wr as h,$r as i,Yr as l,Hr as m,ns as n,Vr as o,Jr as p,Go as r,Kr as s,rs as t,qr as u,jr as v,Fn as y};
@@ -0,0 +1 @@
1
+ import{$ as e,B as t,J as n,K as r,L as i,S as a,b as o,q as s,x as c}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEHpkaJP.js";import{D as l,O as u,V as d,ot as f,sa as p}from"./player-overlays-DTcu3p6k.js";import{Br as m,Cn as h,En as g,Gr as _,In as v,Jr as y,Qr as b,Sn as x,Tn as S,Ur as C,Wr as w,Xr as T,Yr as ee,Zr as E,ai as D,di as O,fi as k,oi as te,qr as ne,wn as re}from"./client-Tf7DwHzR.js";import{Ar as ie,Eo as ae,Gu as oe,Nu as se,Rr as ce,Xa as le,Za as A,_a as ue,da as de,fr as j,hr as M,qu as fe,s as pe}from"./src-CxF5mieK.js";import{t as N}from"./i18n-dPXh_JKN.js";import{t as P}from"./useTranslation-D3Is_4B6.js";e();function me(e){return{target:{kind:`new`,type:e},name:``,features:[]}}function he(e){return{target:{kind:`existing`,device:e},name:``,features:[]}}function F(e,t){return{target:e.target,name:t,features:e.features.flatMap(e=>e.kind===`fields`?[e]:[])}}function I(e,t,n){return{...e,features:e.features.map(e=>e.cap===t?n(e):e)}}function L(e,t){return Object.fromEntries(Object.entries(e).filter(([e])=>e!==t))}function ge(e,t){switch(t.type){case`set-new-type`:return e.target.kind===`new`?{...e,target:{...e.target,type:t.deviceType}}:e;case`set-new-role`:{if(e.target.kind!==`new`)return e;let{role:n,...r}=e.target;return{...e,target:t.role===null?r:{...r,role:t.role}}}case`set-name`:return{...e,name:t.name};case`add-feature`:return e.features.some(e=>e.cap===t.cap)?e:{...e,features:[...e.features,{kind:`fields`,cap:t.cap,fields:{}}]};case`remove-feature`:return{...e,features:e.features.filter(e=>e.cap!==t.cap)};case`set-field`:return I(e,t.cap,e=>({...e,fields:{...e.fields,[t.path]:t.source}}));case`clear-field`:return I(e,t.cap,e=>({...e,fields:L(e.fields,t.path)}));case`remove-binding`:return I(e,t.cap,e=>{let n=e.fields[t.path];return n?.kind===`expression`?{...e,fields:{...e.fields,[t.path]:{...n,bindings:L(n.bindings,t.bindingName)}}}:e});case`copy-feature`:return I(e,t.cap,e=>({...e,fields:{...e.fields,...Object.fromEntries(t.paths.map(e=>[e,{kind:`from`,source:t.from,cap:t.sourceCap,fieldPath:e}]))}}))}}function _e(e){let t=_.safeParse({target:e.target,features:e.features});return t.success?{ok:!0,composition:t.data}:{ok:!1,problems:t.error.issues.map(e=>`${e.path.join(`.`)||`composition`}: ${e.message}`)}}function ve(e,t){return JSON.stringify(e)!==JSON.stringify(t)}function ye(e){for(let t=1;;t++){let n=`s${t}`;if(!e.includes(n))return n}}var be=[`room`,`converted-sensor`,`derived-binary`],R={addonId:`provider-homeassistant`,stableId:`sensor.template_source`};function xe(){return F(S({temperatureSources:h,motionSources:x,occupancyWindowMs:re}),`Room`)}function Se(){return F({target:{kind:`new`,type:k.Sensor},features:[{kind:`fields`,cap:`numeric-sensor`,fields:{value:{kind:`expression`,expr:`convert(v, "°C", "°F")`,bindings:{v:{kind:`from`,source:R,cap:`numeric-sensor`,fieldPath:`value`}}},unit:{kind:`expression`,expr:`"°F"`,bindings:{}},lastFetchedAt:{kind:`expression`,expr:`now`,bindings:{}}}}]},`Converted sensor`)}function Ce(){return F({target:{kind:`new`,type:k.Sensor},features:[{kind:`fields`,cap:`binary`,fields:{on:{kind:`expression`,expr:`v > 20`,bindings:{v:{kind:`from`,source:R,cap:`temperature-sensor`,fieldPath:`celsius`}}},lastChangedAt:{kind:`expression`,expr:`now`,bindings:{}}}}]},`Derived binary`)}function we(e){switch(e){case`room`:return xe();case`converted-sensor`:return Se();case`derived-binary`:return Ce()}}function Te(e,t){return typeof t==`number`&&Number.isFinite(t)&&t>0?{kind:`device`,path:`/devices/${t}`}:{kind:`editor`,path:`/build/compositions/${encodeURIComponent(e)}`}}var z=`rounded-lg border border-border bg-surface p-4`,Ee=z;function De(e){return{addonId:e.addonId,stableId:e.stableId}}function B(e){return new Map(e.map(e=>[E(De(e)),e]))}function Oe(e,t,n){let r=e?.features??[],i=r.findIndex(e=>e.cap===n.cap);return{target:e?.target??{kind:`existing`,device:t},features:i===-1?[...r,n]:r.map((e,t)=>t===i?n:e)}}function ke(e,t){let n=e.features.filter(e=>e.cap!==t);return n.length===0?null:{target:e.target,features:n}}function Ae(e,t){let n=e?.features.find(e=>e.cap===t);return n!==void 0&&n.kind===`fields`?n:null}function V(e){return Array.isArray(e)?e.map(V):typeof e!=`object`||!e?e:Object.fromEntries(Object.entries(e).toSorted(([e],[t])=>e.localeCompare(t)).map(([e,t])=>[e,V(t)]))}function H(e){return JSON.stringify(V(e))}function je(e,t){return H(e)===H(t)}function U(e,t){return H(e)===H(t)}function Me(e,t){switch(e.kind){case`pending`:return{kind:`refused`,reason:N.t(`helpers.customizationSave.notReadYet`)};case`unknown`:return{kind:`refused`,reason:`the customization could not be read: ${e.reason}`};case`not-loaded`:return{kind:`refused`,reason:`the customizations are not loaded yet: ${e.reason}`};case`none`:return t===null?{kind:`noop`}:{kind:`create`,input:{enabled:!0,composition:t}};case`present`:{let n=e.view.block.id;return t===null?{kind:`delete`,blockId:n}:H(t)===H(e.composition)?{kind:`noop`}:{kind:`update`,blockId:n,expectedUpdatedAt:e.view.block.updatedAt,composition:t}}}}function W(e,t){let n=e===`enum`?`string`:e,r=t.kind===`enum`?`string`:t.kind,i={source:t.source,cap:t.cap,fieldPath:t.fieldPath};return r===n?{kind:`from`,...i}:n===`number`&&r===`string`?{kind:`expression`,expr:`number(x)`,bindings:{x:{kind:`from`,...i}}}:null}function G(e){return{kind:`expression`,expr:e,bindings:{}}}function K(e){let t=W(`number`,e.percentage);return t===null?null:{kind:`fields`,cap:`battery`,fields:e.mode===`replace`?{percentage:t}:{percentage:t,charging:G(`"unknown"`),sleeping:G(`false`),lastUpdated:G(`now`)}}}var Ne=[`percent`,...v.options];function q(e,t){return t===`percent`?{level:e}:{"remaining.value":e,"remaining.unit":G(JSON.stringify(t))}}function Pe(e,t){let n=W(`number`,t.remaining);if(n===null||!w.test(t.key)||t.label.trim()===``)return null;let r={label:t.label.trim(),fields:q(n,t.unit)};return{kind:`fields`,cap:`consumables`,...e?.enabled===void 0?{}:{enabled:e.enabled},fields:e?.fields??{lastChangedAt:G(`now`),lastFetchedAt:G(`now`)},items:{...e?.items,[t.key]:r}}}function Fe(e){if(e.level!==void 0)return`percent`;let t=e[`remaining.unit`];if(t===void 0||t.kind!==`expression`)return null;try{let e=v.safeParse(JSON.parse(t.expr));return e.success?e.data:null}catch{return null}}function Ie(e){return Object.entries(e?.items??{}).map(([e,t])=>{let n=Fe(t.fields),r=J(t.fields.level??t.fields[`remaining.value`]),i=r===null?null:W(`number`,r);return n!==null&&i!==null&&je(q(i,n),t.fields)?{key:e,label:t.label,unit:n,source:r}:{key:e,label:t.label,unit:null,source:null}})}function Le(e,t){let n=Object.fromEntries(Object.entries(e.items??{}).filter(([e])=>e!==t));return Object.keys(n).length===0?null:{...e,items:n}}function Re(e){return e.toLowerCase().normalize(`NFD`).replace(/[\u0300-\u036f]/g,``).replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,48)}function ze(e){let t=e.fields.lastPressedAt;if(t===void 0||t.kind!==`expression`)return[];let n=Object.entries(t.bindings).filter(([e])=>e.startsWith(`active`)).flatMap(([,e])=>e.kind===`from`?[e.source]:[]);return[...new Map(n.map(e=>[E(e),e])).values()]}function Be(e){let t=e.fields.lastPressedAt;if(t===void 0||t.kind!==`expression`)return[];let n=t.bindings;return Object.entries(n).flatMap(([e,t])=>{if(!e.startsWith(`active`)||t.kind!==`from`)return[];let r=n[`changed${e.slice(6)}`];return r===void 0||r.kind!==`from`?[]:[{source:t.source,cap:t.cap,activeField:t.fieldPath,changedAtField:r.fieldPath}]})}function J(e){if(e===void 0)return null;if(e.kind===`from`){let{kind:t,...n}=e;return{...n,kind:`number`}}if(e.kind!==`expression`||e.expr!==`number(x)`)return null;let t=e.bindings.x;if(t===void 0||t.kind!==`from`||Object.keys(e.bindings).length!==1)return null;let{kind:n,...r}=t;return{...r,kind:`string`}}function Ve(e,t){let n=J(e.fields.percentage);if(n===null)return!1;let r=K({percentage:n,mode:t}),{enabled:i,...a}=e;return r!==null&&U(a,r)}function Y(e){return e.map(e=>({id:e.id,name:e.name,addonId:e.addonId,stableId:e.stableId,location:e.location,type:e.type}))}function He(e,t,n){let r=t.trim().toLowerCase();return r===``?[]:e.filter(e=>!n.includes(e.id)&&[e.name,e.stableId,e.location??``].some(e=>e.toLowerCase().includes(r))).toSorted((e,t)=>e.name.localeCompare(t.name)).slice(0,20)}function X(e,t){let n=e;for(let e of t.split(`.`)){if(typeof n!=`object`||!n||Array.isArray(n))return;n=Object.getOwnPropertyDescriptor(n,e)?.value}return n}function Ue(e,t,n,r){return r===null?{kind:`from`,source:e,cap:t,fieldPath:n.path}:W(r,{source:e,cap:t,fieldPath:n.path,kind:n.kind})}function We(e,t,n,r){let i={addonId:e.addonId,stableId:e.stableId};return t.caps.flatMap(e=>e.fields.filter(e=>e.item!==!0).map(t=>({cap:e.cap,path:t.path,kind:t.kind,value:n===null?void 0:X(n[e.cap],t.path),source:Ue(i,e.cap,t,r)})))}function Z(e,t){return t?e===void 0?`—`:e===null?`null`:typeof e==`string`||typeof e==`number`||typeof e==`boolean`?String(e):JSON.stringify(e):`…`}var Ge=[];function Ke({title:e,targetKind:t,excludeDeviceIds:r=Ge,onPick:i,onCancel:o}){let{t:s}=P(),[f,p]=n(null);return a(`aside`,{"aria-label":e,className:`${u} ${l} flex flex-col gap-2`,children:[c(`h3`,{className:d,children:e}),f===null?c(qe,{excludeDeviceIds:r,onSelect:p}):c(Je,{device:f,targetKind:t,onPick:i,onBack:()=>p(null)}),c(`div`,{children:c(M,{variant:`ghost`,size:`sm`,onClick:o,children:s(`customize.picker.cancel`)})})]})}function qe({excludeDeviceIds:e,onSelect:t}){let{t:r}=P(),[i,s]=n(``),l=A({projection:`slim`});return a(o,{children:[a(`label`,{className:`flex flex-col gap-1 text-[11px] text-foreground-subtle`,children:[r(`customize.picker.search`),c(se,{type:`search`,"aria-label":r(`customize.picker.search`),value:i,onChange:e=>s(e.target.value)})]}),l.status===`pending`&&c(`p`,{role:`status`,className:`text-[11px] text-foreground-subtle`,children:r(`customize.picker.loadingDevices`)}),l.status===`error`&&c(j,{title:r(`customize.picker.devicesFailed`),message:l.error?.message??``}),l.status===`success`&&c(`ul`,{className:`flex flex-col gap-1`,children:He(Y(l.data),i,e).map(e=>c(`li`,{children:a(`button`,{type:`button`,className:`text-left text-[11px] hover:underline`,onClick:()=>t(e),children:[e.name,` `,a(`span`,{className:`text-foreground-subtle`,children:[`· `,e.stableId]})]})},e.id))})]})}function Je({device:e,targetKind:t,selected:n,onPick:r,onBack:i}){let{t:o}=P(),s=le({deviceId:e.id}),l=ae({deviceId:e.id});if(s.status===`pending`)return c(`p`,{role:`status`,className:`text-[11px] text-foreground-subtle`,children:o(`customize.picker.loadingFields`)});if(s.status===`error`)return c(j,{title:o(`customize.picker.fieldsFailed`),message:s.error?.message??``});let u=We(e,s.data,l.status===`success`?l.data:null,t),d=u.filter(e=>e.source===null).length,f={addonId:e.addonId,stableId:e.stableId};return a(`div`,{className:`flex flex-col gap-1`,children:[a(`button`,{type:`button`,className:`text-left text-[11px] text-primary`,onClick:i,children:[`← `,e.name]}),l.status===`error`&&c(`p`,{role:`alert`,className:`text-[10px] text-warning`,children:o(`customize.picker.valuesFailed`,{reason:l.error?.message??``})}),c(`ul`,{role:`listbox`,"aria-label":o(`customize.picker.fields`),className:`flex flex-col gap-1`,children:u.map(t=>{let i=t.source;if(i===null)return null;let o=()=>r({device:e,ref:f,cap:t.cap,path:t.path,kind:t.kind,source:i,value:t.value});return a(`li`,{role:`option`,"aria-selected":n?.cap===t.cap&&n.path===t.path,tabIndex:0,className:`flex justify-between gap-2 text-[11px] cursor-pointer hover:bg-surface-hover rounded px-1`,onClick:o,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&o()},children:[a(`span`,{className:`font-mono`,children:[t.cap,`.`,t.path]}),c(`span`,{children:Z(t.value,l.status===`success`)})]},`${t.cap}.${t.path}`)})}),d>0&&t!==null&&c(`p`,{className:`text-[10px] text-foreground-subtle`,children:o(`customize.picker.hidden`,{count:d,kind:o(`customize.kinds.${t}`)})})]})}var Ye=`integration`;function Q(e,t){switch(e.kind){case`from`:{let n=E(e.source);return`${t.get(n)??n} · ${e.cap}.${e.fieldPath}`}case`expression`:return e.expr;case`code`:return`code`}}function Xe(e,t){if(e.kind===`unreachable`)return{kind:`unknown`,reason:e.error};if(e.state===null)return{kind:`unknown`,reason:N.t(`helpers.fieldsTableRows.composerNotReported`)};let n=e.state.fields.find(t);return n===void 0?{kind:`unknown`,reason:N.t(`helpers.fieldsTableRows.noValue`)}:n.state===`unavailable`?{kind:`unavailable`,reason:n.reason??N.t(`common.unavailable`)}:{kind:`value`,value:n.value,staleReason:n.state===`stale`?n.reason??N.t(`common.stale`):null}}function Ze(e,t,n,r){return{key:`${e.feature.cap}.${t}`,cap:e.feature.cap,field:t,origin:`composed`,mode:e.mode,from:Q(n,e.input.sourceNames),value:e.enabled?Xe(e.input.state,r):{kind:`off`}}}function Qe(e){let t=e.feature.cap;return Object.entries(e.feature.fields).map(([n,r])=>Ze(e,n,r,e=>e.cap===t&&e.path===n&&e.item===void 0))}function $e(e){let t=e.feature.cap;return Object.entries(e.feature.items??{}).flatMap(([n,r])=>Object.entries(r.fields).map(([r,i])=>Ze(e,y(C,n,r),i,e=>e.cap===t&&e.path===r&&e.item?.arrayPath===`items`&&e.item.key===n)))}function et(e,t,n){if(e===null)return{kind:`unknown`,reason:N.t(`helpers.fieldsTableRows.stateUnreadable`)};let r=X(e[t],n),i=r===void 0?void 0:D(r);return i===void 0?{kind:`unknown`,reason:N.t(`helpers.fieldsTableRows.notReported`)}:{kind:`value`,value:i,staleReason:null}}function tt(e){if(e.mode!==`replace`)return[];let t=e.feature.cap,n=new Set(Object.keys(e.feature.fields));return(e.input.nativeFields.get(t)??[]).filter(e=>!n.has(e)).map(n=>({key:`${t}.${n}`,cap:t,field:n,origin:`native`,mode:e.mode,from:Ye,value:et(e.input.snapshot,t,n)}))}function nt(e){return e.composition.features.flatMap(t=>{if(t.kind!==`fields`)return[];let n={feature:t,mode:e.nativeCaps.has(t.cap)?`replace`:`add`,enabled:ne(t),input:e};return[...Qe(n),...$e(n),...tt(n)]})}var rt={min:`min(a, b, …)`,max:`max(a, b, …)`,abs:`abs(x)`,floor:`floor(x)`,ceil:`ceil(x)`,sqrt:`sqrt(x)`,round:`round(x, digits?)`,pow:`pow(x, y)`,clamp:`clamp(x, lo, hi)`,avg:`avg(a, b, …)`,sum:`sum(a, b, …)`,coalesce:`coalesce(a, b, …)`,age:`age(now, ts)`,convert:`convert(x, "from", "to")`,any:`any(a, b, …)`,all:`all(a, b, …)`,within:`within(ts, ms)`,number:`number(x)`,latest:`latest(ts, …)`,rose:`rose(level, changedAt, debounceMs?)`,count:`count(x)`},it=/[A-Za-z_][A-Za-z0-9_]*$/;function at(e,t,n){let r=it.exec(e.slice(0,t))?.[0]??``;if(r===``)return[];let i=n.filter(e=>e.startsWith(r)).toSorted().map(e=>({kind:`binding`,label:e,insert:e,hintKey:null})),a=`now`.startsWith(r)?[{kind:`now`,label:`now`,insert:`now`,hintKey:`compositionEditor.now`}]:[],o=[...te].filter(e=>e.startsWith(r)).toSorted().map(e=>({kind:`builtin`,label:rt[e]??e,insert:`${e}(`,hintKey:`compositionEditor.builtins.${e}`}));return[...i,...a,...o].slice(0,8)}function ot(e,t,n){let r=t-(it.exec(e.slice(0,t))?.[0]??``).length;return{text:`${e.slice(0,r)}${n.insert}${e.slice(t)}`,cursor:r+n.insert.length}}e();function st({label:e,value:t,bindings:r,onChange:i}){let{t:o}=P(),l=s(null),[u,d]=n(t.length),f=at(t,u,r);return a(`div`,{className:`flex flex-col gap-1`,children:[a(`label`,{className:`flex flex-col gap-1 text-[11px]`,children:[e,c(`input`,{ref:l,className:`font-mono px-1.5 py-0.5 text-[11px] bg-background border border-border rounded`,value:t,onChange:e=>{i(e.target.value),d(e.target.selectionStart??e.target.value.length)},onSelect:e=>d(e.currentTarget.selectionStart??t.length)})]}),f.length>0&&c(`ul`,{role:`listbox`,"aria-label":o(`compositionEditor.suggestions`),className:`rounded border border-border bg-surface text-[11px]`,children:f.map(e=>a(`li`,{role:`option`,"aria-selected":!1,tabIndex:0,className:`flex justify-between gap-2 px-1 cursor-pointer hover:bg-surface-hover`,onClick:()=>{let n=ot(t,u,e);i(n.text),d(n.cursor),l.current?.focus()},children:[c(`span`,{className:`font-mono`,children:e.label}),e.hintKey!==null&&c(`span`,{className:`text-foreground-subtle`,children:o(e.hintKey)})]},`${e.kind}:${e.label}`))})]})}function ct(e,t,n){if(e.kind===`code`)return{kind:`unavailable`,reason:N.t(`helpers.fieldPreview.codeFields`)};if(e.kind===`expression`&&(m(e.expr,`rose`)||m(e.expr,`count`)))return{kind:`runtime-only`};let r=b(e).filter(e=>t.get(T(e.source,e.cap))?.kind!==`value`).map(ee);if(r.length>0)return{kind:`waiting`,missing:r};let i=g({source:e,now:n,read:e=>{let n=t.get(T(e.source,e.cap)),r=n?.kind===`value`?X(n.slice,e.fieldPath):void 0,i=r===void 0?void 0:D(r);return i===void 0?{state:`unavailable`,reason:N.t(`helpers.fieldPreview.notReported`,{path:`${e.cap}.${e.fieldPath}`}),fatal:!1}:{state:`fresh`,value:i}}});return i.state===`unavailable`?{kind:`unavailable`,reason:i.reason}:{kind:`value`,value:i.value,stale:i.reason}}e();function lt({sliceKey:e,deviceId:n,capName:r,onReading:i}){let a=pe(f().trpcClient,n,r);return t(()=>{i(e,a===void 0?{kind:`pending`}:{kind:`value`,slice:a})},[e,a,i]),null}function ut(e,t){return[...new Map(b(e).map(e=>[T(e.source,e.cap),e]))].map(([e,n])=>({key:e,read:n,device:t.get(E(n.source))}))}function dt({source:e}){let{t}=P(),r=A({projection:`slim`}),[o,s]=n(new Map),l=i((e,t)=>{s(n=>new Map([...n,[e,t]]))},[]),u=ut(e,B(r.status===`success`?Y(r.data):[])),d=r.status===`success`?u.filter(e=>e.device===void 0).map(e=>E(e.read.source)):[];return a(`div`,{className:`flex flex-wrap items-center gap-2 text-[11px]`,children:[u.map(e=>e.device===void 0?null:c(lt,{sliceKey:e.key,deviceId:e.device.id,capName:e.read.cap,onReading:l},e.key)),c(`span`,{className:`text-foreground-subtle`,children:t(`compositionEditor.preview.label`)}),r.status===`error`?c(`span`,{className:`text-warning`,children:t(`compositionEditor.preview.devicesFailed`,{reason:r.error?.message??``})}):d.length>0?c(`span`,{className:`text-warning`,children:t(`compositionEditor.preview.unknownDevice`,{sources:d.join(`, `)})}):c(ft,{preview:ct(e,o,Date.now())})]})}function ft({preview:e}){let{t}=P();switch(e.kind){case`value`:return a(`strong`,{children:[`→ `,Z(e.value,!0),e.stale===null?``:` (${e.stale})`]});case`unavailable`:return c(`span`,{className:`text-warning`,children:e.reason});case`waiting`:return c(`span`,{className:`text-foreground-subtle`,children:t(`compositionEditor.preview.waiting`,{sources:e.missing.join(`, `)})});case`runtime-only`:return c(`span`,{className:`text-foreground-subtle`,children:t(`compositionEditor.preview.runtimeOnly`)})}}e();function pt({path:e,kind:t,required:r,source:i,onSet:s,onClear:l,onRemoveBinding:u,sourceNames:d}){let{t:f}=P(),[p,m]=n(`idle`),h=i?.kind===`expression`?i:null;return a(`div`,{className:`flex flex-col gap-1 rounded border border-border p-2`,children:[a(`div`,{className:`flex flex-wrap items-center gap-2`,children:[c(`span`,{className:`font-mono text-[11px]`,children:e}),a(`span`,{className:`text-[10px] text-foreground-subtle`,children:[f(`customize.kinds.${t}`),r?` · ${f(`compositionEditor.required`)}`:``]}),c(M,{size:`sm`,variant:`outline`,onClick:()=>m(`take`),children:f(`compositionEditor.takeFrom`)}),c(M,{size:`sm`,variant:`outline`,"aria-pressed":h!==null,onClick:()=>s(h??{kind:`expression`,expr:`null`,bindings:{}}),children:f(`compositionEditor.formula`)}),i!==void 0&&c(M,{size:`sm`,variant:`ghost`,onClick:l,children:f(`compositionEditor.clear`)})]}),i?.kind===`from`&&c(`span`,{className:`text-[11px]`,children:Q(i,d)}),h!==null&&a(o,{children:[c(st,{label:f(`compositionEditor.formulaFor`,{path:e}),value:h.expr,bindings:Object.keys(h.bindings),onChange:e=>s({...h,expr:e})}),c(`ul`,{className:`text-[11px] flex flex-col gap-0.5`,children:Object.entries(h.bindings).map(([e,t])=>a(`li`,{className:`flex flex-wrap items-center gap-2`,children:[c(`span`,{className:`font-mono`,children:e}),c(`span`,{children:t.kind===`from`?Q(t,d):JSON.stringify(t.value)}),c(M,{size:`sm`,variant:`ghost`,"aria-label":f(`compositionEditor.removeBinding`,{name:e}),onClick:()=>u(e),children:`×`})]},e))}),c(M,{size:`sm`,variant:`ghost`,onClick:()=>m(`add-binding`),children:f(`compositionEditor.addSource`)})]}),p!==`idle`&&c(Ke,{title:f(p===`take`?`compositionEditor.takeFrom`:`compositionEditor.addSource`),targetKind:p===`take`?t:null,onCancel:()=>m(`idle`),onPick:e=>{if(p===`take`)s(e.source);else if(h!==null){let t=ye(Object.keys(h.bindings));s({...h,bindings:{...h.bindings,[t]:{kind:`from`,source:e.ref,cap:e.cap,fieldPath:e.path}}})}m(`idle`)}}),i!==void 0&&c(dt,{source:i})]})}e();function mt(e){return e===null||e.kind===`known`?null:e}function ht({draft:e,deviceType:t,nativeCaps:r,targetFields:i,dispatch:s}){let{t:l}=P(),u=de({deviceType:t}),d=A({projection:`slim`}),f=new Map([...B(d.status===`success`?Y(d.data):[])].map(([e,t])=>[e,t.name])),[p,m]=n(null),h=mt(r)??mt(i),g=r?.kind===`known`?r.value:new Set,_=new Set(e.features.map(e=>e.cap)),v=u.status===`success`?u.data.caps.filter(e=>!_.has(e.cap)&&!g.has(e.cap)):[],y=[...g].filter(e=>!_.has(e)),b=e=>g.has(e)?((i?.kind===`known`?i.value.caps.find(t=>t.cap===e):void 0)?.fields??[]).filter(e=>e.item!==!0&&!e.path.includes(`.`)).map(e=>({path:e.path,kind:e.kind,required:!1})):((u.status===`success`?u.data.caps.find(t=>t.cap===e):void 0)?.fields??[]).map(e=>({path:e.path,kind:e.kind,required:e.required}));return h===null?a(o,{children:[a(`section`,{"aria-labelledby":`editor-features`,className:`${z} flex flex-col gap-2`,children:[c(`h2`,{id:`editor-features`,className:`text-sm font-semibold`,children:l(`compositionEditor.steps.features`)}),u.status===`pending`&&c(`p`,{role:`status`,className:`text-[11px] text-foreground-subtle`,children:l(`compositionEditor.checking`)}),u.status===`error`&&c(`p`,{role:`alert`,className:`text-[11px] text-warning`,children:l(`compositionEditor.unknown`,{reason:u.error?.message??``})}),a(`div`,{className:`flex flex-wrap gap-1`,children:[e.features.map(e=>a(`span`,{className:`flex items-center gap-1 rounded border border-border px-1.5 text-[11px]`,children:[e.cap,c(ce,{variant:g.has(e.cap)?`default`:`info`,children:g.has(e.cap)?l(`compositionEditor.replaces`):l(`compositionEditor.added`)}),c(`button`,{type:`button`,"aria-label":l(`compositionEditor.removeFeature`,{cap:e.cap}),onClick:()=>s({type:`remove-feature`,cap:e.cap}),children:`×`})]},e.cap)),v.map(e=>a(M,{size:`sm`,variant:`outline`,onClick:()=>s({type:`add-feature`,cap:e.cap}),children:[`+ `,e.cap]},e.cap)),y.map(e=>c(M,{size:`sm`,variant:`ghost`,onClick:()=>s({type:`add-feature`,cap:e}),children:l(`compositionEditor.replaceIn`,{cap:e})},e))]})]}),e.features.map(e=>a(`section`,{"aria-label":l(`compositionEditor.steps.fieldsOf`,{cap:e.cap}),className:`${z} flex flex-col gap-2`,children:[a(`div`,{className:`flex items-center justify-between`,children:[c(`h2`,{className:`text-sm font-semibold`,children:l(`compositionEditor.steps.fieldsOf`,{cap:e.cap})}),c(M,{size:`sm`,variant:`outline`,onClick:()=>m(e.cap),children:l(`compositionEditor.copyFeature`)})]}),p===e.cap&&c(Ke,{title:l(`compositionEditor.copyFeature`),targetKind:null,onCancel:()=>m(null),onPick:t=>{s({type:`copy-feature`,cap:e.cap,from:t.ref,sourceCap:t.cap,paths:b(e.cap).map(e=>e.path)}),m(null)}}),b(e.cap).map(t=>c(pt,{path:t.path,kind:t.kind,required:t.required,source:e.fields[t.path],onSet:n=>s({type:`set-field`,cap:e.cap,path:t.path,source:n}),onClear:()=>s({type:`clear-field`,cap:e.cap,path:t.path}),onRemoveBinding:n=>s({type:`remove-binding`,cap:e.cap,path:t.path,bindingName:n}),sourceNames:f},t.path))]},e.cap))]}):a(`section`,{"aria-labelledby":`editor-features`,className:`${z} flex flex-col gap-2`,children:[c(`h2`,{id:`editor-features`,className:`text-sm font-semibold`,children:l(`compositionEditor.steps.features`)}),c(`p`,{role:`status`,className:`text-[11px] text-foreground-subtle`,children:h.kind===`unknown`?h.reason:l(`compositionEditor.reading`)})]})}var $=`px-1.5 py-0.5 text-[11px] bg-background border border-border rounded`;function gt({draft:e,targetName:t,dispatch:n}){let r=p(),{t:i}=P(),o=e.target;return a(`section`,{"aria-labelledby":`editor-target`,className:`${z} flex flex-col gap-2`,children:[c(`h2`,{id:`editor-target`,className:`text-sm font-semibold`,children:i(`compositionEditor.steps.target`)}),o.kind===`existing`?c(`p`,{className:`text-[11px]`,children:i(`compositionEditor.existingTarget`,{name:t??`${o.device.addonId}/${o.device.stableId}`})}):a(`div`,{className:`grid grid-cols-3 gap-2`,children:[a(`label`,{className:`flex flex-col gap-1 text-[11px]`,children:[i(`compositionEditor.targetType`),c(`select`,{className:$,value:o.type,onChange:e=>{let t=Object.values(k).find(t=>t===e.target.value);t!==void 0&&n({type:`set-new-type`,deviceType:t})},children:Object.values(k).map(e=>c(`option`,{value:e,children:fe(e,r).label},e))})]}),a(`label`,{className:`flex flex-col gap-1 text-[11px]`,children:[i(`customize.identity.role`),a(`select`,{className:$,value:o.role??``,onChange:e=>n({type:`set-new-role`,role:Object.values(O).find(t=>t===e.target.value)??null}),children:[c(`option`,{value:``,children:i(`customize.identity.noRole`)}),Object.values(O).map(e=>c(`option`,{value:e,children:oe(e,r).label},e))]})]}),a(`label`,{className:`flex flex-col gap-1 text-[11px]`,children:[i(`compositionEditor.name`),c(`input`,{className:$,value:e.name,onChange:e=>n({type:`set-name`,name:e.target.value})})]})]})]})}e();function _t({draft:e,blockId:r,saving:i,onSave:o,onCancel:s}){let{t:l}=P(),u=ue(),d=_e(e),f=d.ok?JSON.stringify(d.composition):``,[p,m]=n({key:``,state:{kind:`checking`}});t(()=>{if(!d.ok)return;let e=d.composition,t=setTimeout(()=>{u.mutateAsync({composition:e,...r===null?{}:{blockId:r}}).then(e=>m({key:f,state:e.ok?{kind:`ok`}:{kind:`refused`,problems:e.problems}})).catch(e=>m({key:f,state:{kind:`unknown`,reason:e instanceof Error?e.message:String(e)}}))},500);return()=>clearTimeout(t)},[f,r]);let h=d.ok?p.key===f?p.state:{kind:`checking`}:{kind:`invalid-draft`,problems:d.problems};return a(`section`,{"aria-labelledby":`editor-verify`,className:`${z} flex flex-col gap-2`,children:[c(`h2`,{id:`editor-verify`,className:`text-sm font-semibold`,children:l(`compositionEditor.steps.verify`)}),h.kind===`checking`&&c(`p`,{role:`status`,className:`text-[11px] text-foreground-subtle`,children:l(`compositionEditor.verify.checking`)}),h.kind===`ok`&&c(`p`,{className:`text-[11px] text-success`,children:l(`compositionEditor.verify.ok`)}),h.kind===`unknown`&&c(`p`,{role:`alert`,className:`text-[11px] text-warning`,children:l(`compositionEditor.verify.unknown`,{reason:h.reason})}),(h.kind===`invalid-draft`||h.kind===`refused`)&&c(`ul`,{role:`alert`,className:`flex flex-col gap-1 text-[11px] text-danger`,children:h.kind===`invalid-draft`?h.problems.map(e=>c(`li`,{children:e},e)):h.problems.map(e=>a(`li`,{children:[c(`span`,{className:`font-mono`,children:e.path}),` — `,e.message]},`${e.path}:${e.code}`))}),a(`div`,{className:`flex gap-2`,children:[c(M,{variant:`ghost`,onClick:s,children:l(`compositionEditor.cancel`)}),c(M,{disabled:h.kind!==`ok`||i||!d.ok,onClick:()=>d.ok&&o(d.composition),children:l(`compositionEditor.save`)})]})]})}e();function vt({initial:e,blockId:t,deviceType:r,targetName:i=null,nativeCaps:a,targetFields:o,save:s,onCancel:l,showTemplates:u=!1}){let[d,f]=n(e),p=`${d.name}:${d.features.map(e=>e.cap).join(`,`)}:${d.target.kind===`new`?d.target.type:`existing`}`;return c(yt,{seed:d,blockId:t,deviceType:r,targetName:i,nativeCaps:a,targetFields:o,showTemplates:u,onApplyTemplate:e=>{f(we(e))},save:s,onCancel:l},p)}function yt({seed:e,blockId:t,deviceType:i,targetName:o,nativeCaps:s,targetFields:l,showTemplates:u,onApplyTemplate:d,save:f,onCancel:p}){let{t:m}=P(),h=ie(),[g,_]=r(ge,e),[v,y]=n(!1),[b,x]=n(null),S=async t=>{ve(e,g)&&!await h({title:m(`compositionEditor.templates.confirmTitle`),message:m(`compositionEditor.templates.confirmMessage`),confirmLabel:m(`compositionEditor.templates.confirmApply`),variant:`danger`})||d(t)},C=g.target.kind===`new`?g.target.type:i,w=async e=>{y(!0);let t=await f(e,g.name);y(!1),x(t.kind===`refused`?t.reason:null)};return a(`div`,{className:`flex flex-col gap-4`,children:[u&&g.target.kind===`new`&&a(`div`,{className:`rounded-lg border border-border bg-surface p-4 flex flex-wrap gap-2`,"data-testid":`composition-templates`,children:[c(`span`,{className:`text-[11px] text-foreground-subtle self-center`,children:m(`compositionEditor.templates.label`)}),be.map(e=>c(M,{size:`sm`,variant:`outline`,onClick:()=>void S(e),children:m(`compositionEditor.templates.${e}`)},e))]}),c(gt,{draft:g,targetName:o,dispatch:_}),c(ht,{draft:g,deviceType:C,nativeCaps:s,targetFields:l,dispatch:_}),c(_t,{draft:g,blockId:t,saving:v,onSave:e=>void w(e),onCancel:p}),b!==null&&c(`p`,{role:`alert`,className:`text-[11px] text-danger break-words`,children:b})]})}export{ke as C,he as D,F as E,me as O,Oe as S,Te as T,J as _,Je as a,Me as b,Y as c,Pe as d,Ie as f,Re as g,Ve as h,nt as i,Ne as l,Be as m,ct as n,Z as o,ze as p,st as r,X as s,vt as t,K as u,Le as v,Ee as w,U as x,Ae as y};
@@ -1 +1 @@
1
- import{S as e,x as t}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEHpkaJP.js";import{Ir as n,di as r}from"./client-Cif6ZNXf.js";import{t as i}from"./boxes-D5kVpHYR.js";import{aa as a,fr as o,ga as s,la as c}from"./src-X6CKvVYm.js";import{t as l}from"./useTranslation-D3Is_4B6.js";import{Q as u,_ as d,et as f,f as p,tt as m}from"./index-DbU7nBkH.js";import{E as h,O as g,T as _,t as v,w as y}from"./CompositionEditor-ClnrKef1.js";import{t as b}from"./AdminPage-DRcphXBk.js";var x=`new`;function S(e){return e instanceof Error?e.message:String(e)}function C(e){let t=e.trim();return t===``?{}:{name:t}}function w(){let{blockId:w}=m(),{t:T}=l(),E=f(),D=a(),O=s(),k=w===void 0||w===x,A=c({blockId:w??``},{enabled:!k}),j=()=>{E(p)},M=e=>t(b,{icon:i,title:T(`compositionEditor.pageTitle`),children:e}),N=e=>t(`section`,{className:`${y} flex flex-col gap-2`,children:e});if(k)return M(t(v,{initial:g(r.Sensor),blockId:null,deviceType:r.Sensor,nativeCaps:null,targetFields:null,showTemplates:!0,onCancel:j,save:async(e,t)=>{try{let{block:n}=await D.mutateAsync({block:{...C(t),enabled:!0,composition:e}});return E(_(n.id,null).path,{replace:!0}),{kind:`saved`}}catch(e){return{kind:`refused`,reason:S(e)}}}}));if(A.status===`pending`)return M(N(t(`p`,{role:`status`,children:T(`compositionEditor.loading`)})));if(A.status===`error`)return M(N(t(o,{title:T(`compositionEditor.loadFailed`),message:A.error.message})));if(A.data.state===`not-loaded`)return M(N(t(`p`,{role:`status`,children:T(`customize.status.notLoaded`,{reason:A.data.reason})})));let P=A.data.view;if(P===null)return M(N(t(`p`,{children:T(`compositionEditor.notFound`,{blockId:w})})));let F=n(P.block);if(F===null)return M(N(t(`p`,{children:T(`compositionEditor.notComposition`)})));if(F.target.kind===`existing`){let e=P.state.kind===`answered`?P.state.state?.deviceId??null:null;return M(N(e===null?t(`p`,{children:T(`compositionEditor.customizationUnknownDevice`)}):t(u,{className:`text-primary`,to:d(e),children:T(`compositionEditor.openOnDevice`)})))}let I=P.state.kind===`answered`?P.state.state?.deviceId??null:null,L=I===null?null:_(P.block.id,I);return M(e(`div`,{className:`flex flex-col gap-3`,children:[L!==null&&L.kind===`device`&&t(u,{className:`text-sm text-primary`,to:L.path,"data-testid":`open-composed-device`,children:T(`compositionEditor.openComposedDevice`,{id:I})}),t(v,{initial:h(F,P.block.name),blockId:P.block.id,deviceType:F.target.type,nativeCaps:null,targetFields:null,onCancel:j,save:async(e,t)=>{try{return await O.mutateAsync({blockId:P.block.id,expectedUpdatedAt:P.block.updatedAt,block:{...C(t),composition:e}}),await A.refetch(),{kind:`saved`}}catch(e){return{kind:`refused`,reason:S(e)}}}},`${P.block.id}@${P.block.updatedAt}`)]}))}export{w as CompositionEditorPage};
1
+ import{S as e,x as t}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEHpkaJP.js";import{Lr as n,fi as r}from"./client-Tf7DwHzR.js";import{t as i}from"./boxes-OM3WXXCF.js";import{aa as a,fr as o,ga as s,la as c}from"./src-CxF5mieK.js";import{t as l}from"./useTranslation-D3Is_4B6.js";import{Q as u,_ as d,et as f,f as p,tt as m}from"./index-k7RW-84l.js";import{E as h,O as g,T as _,t as v,w as y}from"./CompositionEditor-Du0918m6.js";import{t as b}from"./AdminPage-0E8EpSO9.js";var x=`new`;function S(e){return e instanceof Error?e.message:String(e)}function C(e){let t=e.trim();return t===``?{}:{name:t}}function w(){let{blockId:w}=m(),{t:T}=l(),E=f(),D=a(),O=s(),k=w===void 0||w===x,A=c({blockId:w??``},{enabled:!k}),j=()=>{E(p)},M=e=>t(b,{icon:i,title:T(`compositionEditor.pageTitle`),children:e}),N=e=>t(`section`,{className:`${y} flex flex-col gap-2`,children:e});if(k)return M(t(v,{initial:g(r.Sensor),blockId:null,deviceType:r.Sensor,nativeCaps:null,targetFields:null,showTemplates:!0,onCancel:j,save:async(e,t)=>{try{let{block:n}=await D.mutateAsync({block:{...C(t),enabled:!0,composition:e}});return E(_(n.id,null).path,{replace:!0}),{kind:`saved`}}catch(e){return{kind:`refused`,reason:S(e)}}}}));if(A.status===`pending`)return M(N(t(`p`,{role:`status`,children:T(`compositionEditor.loading`)})));if(A.status===`error`)return M(N(t(o,{title:T(`compositionEditor.loadFailed`),message:A.error.message})));if(A.data.state===`not-loaded`)return M(N(t(`p`,{role:`status`,children:T(`customize.status.notLoaded`,{reason:A.data.reason})})));let P=A.data.view;if(P===null)return M(N(t(`p`,{children:T(`compositionEditor.notFound`,{blockId:w})})));let F=n(P.block);if(F===null)return M(N(t(`p`,{children:T(`compositionEditor.notComposition`)})));if(F.target.kind===`existing`){let e=P.state.kind===`answered`?P.state.state?.deviceId??null:null;return M(N(e===null?t(`p`,{children:T(`compositionEditor.customizationUnknownDevice`)}):t(u,{className:`text-primary`,to:d(e),children:T(`compositionEditor.openOnDevice`)})))}let I=P.state.kind===`answered`?P.state.state?.deviceId??null:null,L=I===null?null:_(P.block.id,I);return M(e(`div`,{className:`flex flex-col gap-3`,children:[L!==null&&L.kind===`device`&&t(u,{className:`text-sm text-primary`,to:L.path,"data-testid":`open-composed-device`,children:T(`compositionEditor.openComposedDevice`,{id:I})}),t(v,{initial:h(F,P.block.name),blockId:P.block.id,deviceType:F.target.type,nativeCaps:null,targetFields:null,onCancel:j,save:async(e,t)=>{try{return await O.mutateAsync({blockId:P.block.id,expectedUpdatedAt:P.block.updatedAt,block:{...C(t),composition:e}}),await A.refetch(),{kind:`saved`}}catch(e){return{kind:`refused`,reason:S(e)}}}},`${P.block.id}@${P.block.updatedAt}`)]}))}export{w as CompositionEditorPage};