@camstack/addon-admin-ui 1.2.87 → 1.2.89

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 (111) hide show
  1. package/dist/assets/{AddLocationWizard-ClWHdX1D.js → AddLocationWizard-CYxP8ICv.js} +1 -1
  2. package/dist/assets/{AddonCollectionPage-CCm-n_-k.js → AddonCollectionPage-Czx0Rf1Y.js} +1 -1
  3. package/dist/assets/Addons-X9onTcjm.js +1 -0
  4. package/dist/assets/{AdminTabs-Ya-WafVI.js → AdminTabs-BFe9RXxD.js} +1 -1
  5. package/dist/assets/{AiProfiles-G8ohU36w.js → AiProfiles-DS7dcd3T.js} +1 -1
  6. package/dist/assets/{BrokerForm-Cja9Cp03.js → BrokerForm-RC8ZQms1.js} +1 -1
  7. package/dist/assets/{Build-BUwpX-xq.js → Build-DYatQ35G.js} +3 -3
  8. package/dist/assets/{Capabilities-CzxtAA9j.js → Capabilities-CdAjZZ5u.js} +1 -1
  9. package/dist/assets/CapabilityBadges-mGyqruK0.js +1 -0
  10. package/dist/assets/{Cluster-C3WY-Tom.js → Cluster-CIp91ynz.js} +1 -1
  11. package/dist/assets/{Data-DP4AzN8W.js → Data-CmrUXYoi.js} +1 -1
  12. package/dist/assets/{DetectionIntelligence-Dm0ZECMd.js → DetectionIntelligence-D80ddmLz.js} +1 -1
  13. package/dist/assets/{DeviceAggregateSection-aUgWgamW.js → DeviceAggregateSection-CmXH0Z_0.js} +1 -1
  14. package/dist/assets/DeviceDetail-CY4j2jrm.js +2 -0
  15. package/dist/assets/{Devices-BVC0zPbb.js → Devices-C8E4qBqs.js} +1 -1
  16. package/dist/assets/{EmbedPlayerPage-BwM49mOX.js → EmbedPlayerPage-nLTLNYPt.js} +1 -1
  17. package/dist/assets/Events-vfLnBqsv.js +1 -0
  18. package/dist/assets/{FormBuilder-CgtfU1VA.js → FormBuilder-CgXBJs1A.js} +1 -1
  19. package/dist/assets/{Identity-C2TOQEJq.js → Identity-C-6ig3ru.js} +1 -1
  20. package/dist/assets/{IntegrationDetail-3MgmsFlC.js → IntegrationDetail-CRrZPmmb.js} +1 -1
  21. package/dist/assets/{Integrations-AQCeGcvO.js → Integrations-CXvB3xLb.js} +1 -1
  22. package/dist/assets/{Integrations-CE6i7W5X.js → Integrations-CnscVQeA.js} +1 -1
  23. package/dist/assets/{Logs-C1e0vFcW.js → Logs-Ptalp9Ap.js} +1 -1
  24. package/dist/assets/{MotionZonesSettings-AZZ7Vac3.js → MotionZonesSettings-GG2onGsd.js} +1 -1
  25. package/dist/assets/{MyAccess-oAGUI1mc.js → MyAccess-C9X6mSCC.js} +1 -1
  26. package/dist/assets/Network-DdfJzcEJ.js +1 -0
  27. package/dist/assets/{NodeAddonsSettingsPanel-B1Cyvbcv.js → NodeAddonsSettingsPanel-BYXH3-BP.js} +1 -1
  28. package/dist/assets/{NodeInferenceDevices-CkoeBXMD.js → NodeInferenceDevices-CJBU3t4h.js} +1 -1
  29. package/dist/assets/Notifications-DVfJp0YC.js +1 -0
  30. package/dist/assets/Pipeline-YNTCsnOx.js +1 -0
  31. package/dist/assets/{Plates-TsHHlZDi.js → Plates-DzZx4BPp.js} +1 -1
  32. package/dist/assets/{PrivacyMaskSettings-BxIYztmC.js → PrivacyMaskSettings-DlD5nHl0.js} +1 -1
  33. package/dist/assets/{ProviderIcon-BBJFc8mr.js → ProviderIcon-DaauzRy3.js} +1 -1
  34. package/dist/assets/Recordings-i9RDqe2o.js +1 -0
  35. package/dist/assets/{ScanNetworkModal-BQIyP8Qh.js → ScanNetworkModal-DwKJwpIs.js} +1 -1
  36. package/dist/assets/{SceneMonitorEditor-ZOTjS5Og.js → SceneMonitorEditor-H2Z_9riR.js} +1 -1
  37. package/dist/assets/{Scenes-DDemjEwK.js → Scenes-DiJCcvjG.js} +1 -1
  38. package/dist/assets/{Settings-BJydhDaq.js → Settings-Clokst-N.js} +1 -1
  39. package/dist/assets/{Showroom-Di_0Md3V.js → Showroom-1ViARhyC.js} +1 -1
  40. package/dist/assets/{Terminal-CIo6IaUC.js → Terminal-mLwOsOgP.js} +5 -3
  41. package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-C91lgIiF.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-BTd_JgZ5.js} +1 -1
  42. package/dist/assets/{bell-ring-0co0yj8J.js → bell-ring-BPrVhIE4.js} +1 -1
  43. package/dist/assets/{boxes-CKu64rZy.js → boxes-89UouT8T.js} +1 -1
  44. package/dist/assets/{build-cluster-graph-BWmowgwv.js → build-cluster-graph-Cbb1I-jq.js} +1 -1
  45. package/dist/assets/circle-check-big-D9ynSOrO.js +1 -0
  46. package/dist/assets/{circle-x-_qOKhKMV.js → circle-x-Bsgek5uU.js} +1 -1
  47. package/dist/assets/clock-BvQlDL5a.js +1 -0
  48. package/dist/assets/{copy-CE9Wp04n.js → copy-BtDJ2xWI.js} +1 -1
  49. package/dist/assets/{debounced-invalidate-CfnWx62K.js → debounced-invalidate-CfMppTLk.js} +1 -1
  50. package/dist/assets/{dist-CcR-lswN.js → dist-BJIJtrLw.js} +1 -1
  51. package/dist/assets/dist-BVCWYzWk.js +349 -0
  52. package/dist/assets/{download-mZ1OYsqe.js → download-DrTCm0Zn.js} +1 -1
  53. package/dist/assets/{face-bbox-Y-X13UcQ.js → face-bbox-bnTYLJ2C.js} +1 -1
  54. package/dist/assets/{hard-drive-D6z2TCCh.js → hard-drive-D6wUZdNf.js} +1 -1
  55. package/dist/assets/{hostInit-Dr0x9nND.js → hostInit-ZAX9mo8c.js} +1 -1
  56. package/dist/assets/index-D7fwM52p.js +4 -0
  57. package/dist/assets/{key-round-CegkgxO2.js → key-round-PssF2mH1.js} +1 -1
  58. package/dist/assets/{mf-entry-bootstrap-0-e3818a6f.js → mf-entry-bootstrap-0-12df8905.js} +2 -2
  59. package/dist/assets/{pencil-CCyVFYXA.js → pencil-DDE9Ut_f.js} +1 -1
  60. package/dist/assets/play-VJTjxs_g.js +1 -0
  61. package/dist/assets/{player-overlays-BCuyatPp.js → player-overlays-DsK1iDkv.js} +1 -1
  62. package/dist/assets/plus-CKJhtG9S.js +1 -0
  63. package/dist/assets/power-DIX0P9O_.js +1 -0
  64. package/dist/assets/{radio-DvHOeyw2.js → radio-Cgg_wmnh.js} +1 -1
  65. package/dist/assets/{refresh-cw-CvqUZLg2.js → refresh-cw-B06QF6BP.js} +1 -1
  66. package/dist/assets/remoteEntry-GRBshePF.js +1 -0
  67. package/dist/assets/rotate-ccw-CHuGPAms.js +1 -0
  68. package/dist/assets/rotate-cw-B7IVurj2.js +1 -0
  69. package/dist/assets/search-B9qXKjRG.js +1 -0
  70. package/dist/assets/{send-DRex-kWD.js → send-CCB7-Bua.js} +1 -1
  71. package/dist/assets/{server-DSkdRu09.js → server-qRR4BT4Q.js} +1 -1
  72. package/dist/assets/shield-Dhep2Fkd.js +1 -0
  73. package/dist/assets/square-CfRn6ZFd.js +1 -0
  74. package/dist/assets/{square-check-big-BbcMGYFH.js → square-check-big-CKJTPtsS.js} +1 -1
  75. package/dist/assets/src-DY4vbC0g.js +349 -0
  76. package/dist/assets/src-DnZ6ZcH0.js +67 -0
  77. package/dist/assets/{star-BT_oUHvU.js → star-Cfry0hZj.js} +1 -1
  78. package/dist/assets/{undo-2-D7QQycip.js → undo-2-CP7k5Csp.js} +1 -1
  79. package/dist/assets/{upload-D5h4xcC3.js → upload-DKCLx4MR.js} +1 -1
  80. package/dist/assets/{use-scenes-feed-DcfGN5ks.js → use-scenes-feed-Cf4dSlYi.js} +1 -1
  81. package/dist/assets/useEventInvalidation-CINdEbPJ.js +1 -0
  82. package/dist/assets/{video--sYC3ys-.js → video-LCt0QHTC.js} +1 -1
  83. package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-DBBIBnMR.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-D-HrWJSs.js} +2 -2
  84. package/dist/assets/{wifi-Wacew_4h.js → wifi-BHTVIRt4.js} +1 -1
  85. package/dist/assets/{zap-CrjJ004P.js → zap-BXQ1pVxK.js} +1 -1
  86. package/dist/index.html +5 -5
  87. package/dist/server/addon.js +137 -10
  88. package/package.json +1 -1
  89. package/dist/assets/Addons-CNQu3idA.js +0 -1
  90. package/dist/assets/CapabilityBadges-BVAXgYuj.js +0 -1
  91. package/dist/assets/DeviceDetail-BoKKas-k.js +0 -2
  92. package/dist/assets/Events-X4Lovw2K.js +0 -1
  93. package/dist/assets/Network-BLaNQAjB.js +0 -1
  94. package/dist/assets/Notifications-D2ro0AxS.js +0 -1
  95. package/dist/assets/Pipeline-BvxT4V4g.js +0 -1
  96. package/dist/assets/Recordings-CYIFqOWF.js +0 -1
  97. package/dist/assets/circle-check-big-BPF9MiQz.js +0 -1
  98. package/dist/assets/clock-DoS4fxPG.js +0 -1
  99. package/dist/assets/dist-D6EYui_h.js +0 -349
  100. package/dist/assets/index-CoX6Kh_l.js +0 -4
  101. package/dist/assets/play-DCoy3WUZ.js +0 -1
  102. package/dist/assets/plus-D-xjJ9wd.js +0 -1
  103. package/dist/assets/power-ChfUL_0y.js +0 -1
  104. package/dist/assets/remoteEntry-C4Nbi34r.js +0 -1
  105. package/dist/assets/rotate-ccw-CwngHzIQ.js +0 -1
  106. package/dist/assets/rotate-cw-pPP0LEo9.js +0 -1
  107. package/dist/assets/search-Cvti5PjG.js +0 -1
  108. package/dist/assets/square-B3jj9vzX.js +0 -1
  109. package/dist/assets/src-BmCjCFGO.js +0 -67
  110. package/dist/assets/src-D8hsVOc6.js +0 -349
  111. package/dist/assets/useEventInvalidation-DCo7fWEj.js +0 -1
@@ -1 +0,0 @@
1
- import{I as e,K as t,Q as n,S as r,T as i,W as a,b as o,i as s,o as c,p as l,q as u,x as d,z as f}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{Z as p}from"./player-overlays-BCuyatPp.js";import{$ as m,$a as h,Aa as g,As as _,B as v,Bt as y,Ca as b,Da as x,Ea as S,Ga as C,Ha as w,Ht as T,Ia as E,It as D,J as O,Ja as k,Jt as A,Ka as j,Ma as M,Ms as N,Na as P,Ns as F,Oa as I,Pa as L,Qa as R,Rt as ee,Sa as te,Ta as ne,Va as z,Vt as re,Wa as B,Xa as ie,Ya as ae,Za as oe,Zi as se,ao as ce,b as le,d as ue,gn as de,h as fe,hn as pe,i as me,io as he,ja as ge,js as _e,ka as ve,ks as V,ln as ye,lo as be,oo as xe,so as Se,u as Ce,vn as we,wa as Te,za as Ee,zt as De}from"./src-BmCjCFGO.js";import{n as Oe}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_trpc_mf_1_react_mf_2_query__loadShare__.js-DX7sYWrs.js";import{It as ke,Lt as Ae,f as je,m as Me,p as Ne,yt as Pe}from"./src-D8hsVOc6.js";import{a as Fe,d as Ie,i as Le,l as Re,n as H,o as ze,r as Be,t as Ve,u as He}from"./NodeInferenceDevices-CkoeBXMD.js";import{t as Ue}from"./download-mZ1OYsqe.js";import{t as We}from"./hard-drive-D6z2TCCh.js";import{n as Ge,t as Ke}from"./video--sYC3ys-.js";import{t as qe}from"./pencil-CCyVFYXA.js";import{t as Je}from"./plus-D-xjJ9wd.js";import{t as Ye}from"./radio-DvHOeyw2.js";import{t as Xe}from"./refresh-cw-CvqUZLg2.js";import{t as Ze}from"./search-Cvti5PjG.js";import{t as Qe}from"./server-DSkdRu09.js";import{t as $e}from"./square-check-big-BbcMGYFH.js";import{t as et}from"./square-B3jj9vzX.js";import{t as tt}from"./zap-CrjJ004P.js";import{C as U,D as nt,E as rt,F as it,I as at,K as ot,N as W,O as st,P as ct,R as lt,X as ut,a as dt,i as ft,o as pt,s as mt,z as ht}from"./index-CoX6Kh_l.js";import{t as gt}from"./AdminPage-CCD07UMs.js";import"./useEventInvalidation-DCo7fWEj.js";import{r as _t,t as vt}from"./build-cluster-graph-BWmowgwv.js";import{n as yt}from"./format-size-CO9d3C3-.js";import{t as bt}from"./NodeAddonsSettingsPanel-B1Cyvbcv.js";var xt=ot(`ellipsis-vertical`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`12`,cy:`5`,r:`1`,key:`gxeob9`}],[`circle`,{cx:`12`,cy:`19`,r:`1`,key:`lyex9k`}]]),St=ot(`flame`,[[`path`,{d:`M8.5 14.5A2.5 2.5 0 0 0 11 12c0-1.38-.5-2-1-3-1.072-2.143-.224-4.054 2-6 .5 2.5 2 4.9 4 6.5 2 1.6 3 3.5 3 5.5a7 7 0 1 1-14 0c0-1.153.433-2.294 1-3a2.5 2.5 0 0 0 2.5 2.5z`,key:`96xj49`}]]),Ct=ot(`pin`,[[`path`,{d:`M12 17v5`,key:`bb1du9`}],[`path`,{d:`M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z`,key:`1nkz8b`}]]);n();function wt(e){return e}function Tt(e,t){for(let[n,r]of Object.entries(e??{}))if(n===t)return r}function Et(e,t){return typeof e==`boolean`?e:wt(t)}function Dt(e,t){return{pipeline:Et(Tt(e,`detect`),t),audio:Et(Tt(e,`audio`),t),ingest:Et(Tt(e,`ingest`),t)}}function Ot(e,t,n){let r=e?.find(e=>e.nodeId===t);return Dt(r?.settings,n)}function kt({selectedNodeId:e,onSelect:t,refreshToken:n}){let{data:i}=se(void 0),{data:a}=z(void 0),{data:s}=B(void 0),c=new Map;for(let e of a??[])c.set(e.agentNodeId,(c.get(e.agentNodeId)??0)+1);let l=i??[],u=l.filter(e=>e.isOnline).length,f=l.filter(e=>!e.isOnline).length;return r(`div`,{className:`flex flex-col h-full`,children:[r(`button`,{type:`button`,onClick:()=>t(ei),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:[d(rt,{className:`h-4 w-4 flex-shrink-0`}),r(`div`,{className:`min-w-0 flex-1`,children:[d(`div`,{className:`text-xs font-semibold truncate`,children:`Cluster`}),d(`div`,{className:`text-[10px] text-foreground-subtle`,children:`Balancer + failover + assignments`})]})]}),d(`div`,{className:`flex-1 overflow-y-auto`,children:l.map(n=>{let i=e===n.id,a=c.get(n.id)??0,l=n.isHub?Qe:W,u=Ot(s,n.id,n.isHub),f=n.isOnline?null:v(_t(n.lastSeen));return r(`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 ${i?`bg-primary/10 text-primary`:`text-foreground hover:bg-surface-hover`}${n.isOnline?``:` opacity-60`}`,children:[d(l,{className:`h-4 w-4 flex-shrink-0`}),r(`div`,{className:`min-w-0 flex-1`,children:[r(`div`,{className:`flex items-center gap-2`,children:[d(`span`,{className:`text-xs font-semibold truncate`,children:n.name}),n.isHub&&d(`span`,{className:`text-[9px] uppercase tracking-wider text-foreground-subtle border border-border rounded px-1 py-0.5`,children:`hub`}),!n.isOnline&&d(`span`,{className:`h-1.5 w-1.5 rounded-full bg-destructive flex-shrink-0`}),n.isOnline&&d(`span`,{className:`h-1.5 w-1.5 rounded-full bg-success flex-shrink-0`})]}),r(`div`,{className:`text-[10px] text-foreground-subtle flex items-center gap-2 mt-0.5`,children:[r(`span`,{children:[n.cpuCores,` cores`]}),d(`span`,{children:`•`}),r(`span`,{children:[Math.round(n.memoryMB/1024),` GB`]}),a>0&&r(o,{children:[d(`span`,{children:`•`}),r(`span`,{className:`inline-flex items-center gap-0.5 text-foreground`,children:[d(Ke,{className:`h-2.5 w-2.5`}),a]})]}),!n.isOnline&&r(o,{children:[d(`span`,{children:`•`}),r(`span`,{className:`text-destructive`,children:[`offline`,f===null?``:` · ${f}`]})]})]}),r(`div`,{className:`mt-0.5 flex items-center gap-1`,children:[d(D,{variant:u.pipeline?`success`:`danger`,className:`px-1 py-0 text-[9px] leading-3`,title:u.pipeline?`Pipeline: enabled`:`Pipeline: not enabled (agent capability)`,children:`Pipe`}),d(D,{variant:u.audio?`success`:`danger`,className:`px-1 py-0 text-[9px] leading-3`,title:u.audio?`Audio: enabled`:`Audio: not enabled (agent capability)`,children:`Aud`})]})]})]},n.id)})}),r(`div`,{className:`px-4 py-2 border-t border-border text-[10px] text-foreground-subtle flex items-center justify-between`,children:[r(`span`,{children:[u,` online`]}),f>0&&r(`span`,{className:`text-destructive`,children:[f,` offline`]})]})]})}function At({nodeId:e,refreshToken:t}){let{data:n}=se(void 0),i=n?.find(t=>t.id===e),a=_(`pipeline.runner-load-snapshot`,t=>t.nodeId===e)?.load??null;return i?r(`div`,{className:`px-6 py-4 border-b border-border`,children:[r(`div`,{className:`flex items-center gap-2 mb-1`,children:[d(`h2`,{className:`text-base font-semibold text-foreground`,children:i.name}),i.isOnline?d(`span`,{className:`text-[10px] px-2 py-0.5 rounded-full bg-success/10 text-success`,children:`online`}):d(`span`,{className:`text-[10px] px-2 py-0.5 rounded-full bg-destructive/10 text-destructive`,children:`offline`}),i.isHub&&d(`span`,{className:`text-[9px] uppercase tracking-wider text-foreground-subtle border border-border rounded px-1 py-0.5`,children:`hub`})]}),r(`div`,{className:`text-[11px] text-foreground-subtle flex items-center gap-2 flex-wrap`,children:[d(`span`,{children:i.cpuModel??`CPU`}),d(`span`,{children:`•`}),r(`span`,{children:[i.cpuCores,` cores`]}),d(`span`,{children:`•`}),r(`span`,{children:[Math.round(i.memoryMB/1024),` GB`]}),a&&r(o,{children:[d(`span`,{children:`•`}),r(`span`,{children:[a.attachedCameras,` cameras (`,a.activeCameras,` active)`]}),d(`span`,{children:`•`}),r(`span`,{children:[a.avgInferenceTimeMs.toFixed(0),`ms avg inference`]}),d(`span`,{children:`•`}),r(`span`,{children:[`queue `,a.queueDepthTotal]}),a.hardware.hasGpu&&r(o,{children:[d(`span`,{children:`•`}),d(`span`,{className:`text-success`,children:`GPU`})]})]})]})]}):d(`div`,{className:`px-6 py-4 border-b border-border`,children:r(`div`,{className:`text-xs text-foreground-subtle`,children:[`Node not found: `,e]})})}function jt({refreshToken:e,nodeId:t}){let[n,i]=u(new Map),{nodes:o}=V();N(`pipeline.camera-metrics-snapshot`,e=>{let t=e.data;typeof t?.deviceId==`number`&&i(e=>{let n=new Map(e);return n.set(t.deviceId,t),n})});let{data:s}=L(void 0),c=a(()=>{let e=new Map;for(let t of s??[])e.set(t.nodeId,t.deviceCount);return e},[s]),l=a(()=>{let e=new Map,t=Date.now()-3e4;for(let r of n.values()){if(r.timestamp<t)continue;let n=r.nodeId??`hub`,i=e.get(n)??{attachedCameras:0,activeCameras:0,totalFps:0,totalInferenceWeighted:0,queueDepth:0};i.attachedCameras++,r.metrics.phase===`active`&&i.activeCameras++,i.totalFps+=r.metrics.actualFps,i.totalInferenceWeighted+=r.metrics.avgInferenceTimeMs,i.queueDepth+=r.metrics.queueDepth,e.set(n,i)}return e},[n]),f=a(()=>{let e=new Map;for(let t of o)e.set(t.id,t.shortName);return e},[o]),p=a(()=>{let e=0,t=0,n=0,r=0,i=0;for(let a of l.values())e+=a.attachedCameras,t+=a.activeCameras,n+=a.totalFps,r+=a.totalInferenceWeighted,i+=a.queueDepth;let a=e>0?r/e:0;return{totalAgents:o.length,onlineAgents:o.filter(e=>e.isOnline).length,attachedCameras:e,activeCameras:t,avgInferenceTimeMs:a,queueDepth:i,totalFps:n}},[l,o]);if(t){let e=l.get(t);return r(`div`,{className:`@container/liveload`,children:[d(`h3`,{className:`text-sm font-semibold text-foreground mb-2`,children:`Live load`}),r(`div`,{className:`grid grid-cols-2 @md/liveload:grid-cols-3 @3xl/liveload:grid-cols-5 gap-2 mb-3`,children:[d(G,{label:`FPS`,value:e?e.totalFps.toFixed(1):`—`}),d(G,{label:`Active / Attached`,value:e?`${e.activeCameras}/${e.attachedCameras}`:`—`}),d(G,{label:`Avg infer ms`,value:e&&e.attachedCameras>0?(e.totalInferenceWeighted/e.attachedCameras).toFixed(0):`—`}),d(G,{label:`Queue`,value:e?String(e.queueDepth):`—`}),d(G,{label:`Audio`,value:String(c.get(t)??`—`)})]})]})}let m=[...l.entries()].toSorted(([e],[t])=>e===`hub`?-1:t===`hub`?1:e.localeCompare(t));return r(`div`,{className:`@container/liveload`,children:[d(`h3`,{className:`text-sm font-semibold text-foreground mb-2`,children:`Live load`}),r(`div`,{className:`grid grid-cols-2 @md/liveload:grid-cols-3 @3xl/liveload:grid-cols-5 gap-2 sm:gap-3 mb-3`,children:[d(G,{label:`Total agents`,value:`${p.onlineAgents}/${p.totalAgents}`}),d(G,{label:`Active / Attached`,value:`${p.activeCameras}/${p.attachedCameras}`}),d(G,{label:`Total FPS`,value:p.totalFps.toFixed(1)}),d(G,{label:`Avg inference ms`,value:p.avgInferenceTimeMs.toFixed(0)}),d(G,{label:`Queue depth`,value:String(p.queueDepth)})]}),d(`div`,{className:`rounded-lg border border-border overflow-x-auto`,children:r(`table`,{className:`w-full text-xs min-w-[480px]`,children:[d(`thead`,{className:`bg-surface`,children:r(`tr`,{className:`text-foreground-subtle text-[10px] uppercase tracking-wider`,children:[d(`th`,{className:`text-left px-3 py-2`,children:`Agent`}),d(`th`,{className:`text-right px-3 py-2`,children:`FPS`}),d(`th`,{className:`text-right px-3 py-2`,children:`Cameras`}),d(`th`,{className:`text-right px-3 py-2`,children:`Inference ms`}),d(`th`,{className:`text-right px-3 py-2`,children:`Queue`}),d(`th`,{className:`text-right px-3 py-2`,children:`Audio`})]})}),r(`tbody`,{children:[m.map(([e,t])=>r(`tr`,{className:`border-t border-border`,children:[d(`td`,{className:`px-3 py-2 text-foreground font-medium`,children:f.get(e)??e}),d(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t.totalFps.toFixed(1)}),d(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t.attachedCameras}),d(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t.attachedCameras>0?(t.totalInferenceWeighted/t.attachedCameras).toFixed(0):`—`}),d(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t.queueDepth}),d(`td`,{className:`px-3 py-2 text-right text-foreground`,children:c.get(e)??`—`})]},e)),m.length===0&&d(`tr`,{children:d(`td`,{colSpan:6,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:`No camera metrics received yet`})})]})]})})]})}function G({label:e,value:t}){return r(`div`,{className:`rounded-lg border border-border bg-surface/60 p-3`,children:[d(`div`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle mb-1`,children:e}),d(`div`,{className:`text-lg font-semibold text-foreground`,children:t})]})}n();var Mt={active:!1,pinned:!1,nodeId:null,reason:``},Nt=[`pipeline.camera-assigned`,`pipeline.camera-unassigned`,`pipeline.camera-updated`,`agent.online`,`agent.offline`],Pt=3e5,Ft={pipeline:W,decoder:st,audio:Ge},It={pipeline:`Pipeline`,decoder:`Decoder`,audio:`Audio`};function Lt({mode:e,nodeId:t,compact:n=!1}){if(e===`agent`&&!t)throw Error(`CameraAssignmentsTable: nodeId is required when mode === "agent"`);let s=c(),[l,p]=u(null),[m,h]=u(null),[_,v]=u(new Map);me([`pipelineOrchestrator`,`getPipelineAssignments`],Nt),me([`pipelineOrchestrator`,`getAudioAssignments`],Nt),me([`pipelineOrchestrator`,`getCameraStatuses`],Nt);let{data:y}=z(void 0),{data:b}=P(void 0),{data:x}=E({},{enabled:e===`agent`}),{nodes:S}=V(),{data:C}=Re();N(`pipeline.camera-metrics-snapshot`,e=>{let t=e.data;typeof t.deviceId==`number`&&v(e=>{let n=new Map(e);return n.set(t.deviceId,t),n})}),f(()=>{if(_.size===0)return;let e=setInterval(()=>{v(e=>{let t=Date.now()-1e4,n=!1,r=new Map(e);for(let[i,a]of e)a.timestamp<t&&(r.delete(i),n=!0);return n?r:e})},5e3);return()=>clearInterval(e)},[_.size]);let w=a(()=>{let e=new Map;for(let t of C??[])e.set(t.id,t.name);return e},[C]),T=a(()=>{if(e===`agent`){let e=[];for(let n of x??[]){let r=n.assignment,i=(e,n,r)=>({active:e!==null&&e===t,pinned:n,nodeId:e,reason:r??``}),a=i(r.detectionNodeId,r.pinned.detection,r.reasons.detection),o=i(r.decoderNodeId,r.pinned.decoder,r.reasons.decoder),s=i(r.audioNodeId,r.pinned.audio,r.reasons.audio);!a.active&&!o.active&&!s.active||e.push({deviceId:n.deviceId,deviceName:w.get(n.deviceId)??`Device ${n.deviceId}`,pipeline:a,decoder:o,audio:s})}return e.sort((e,t)=>e.deviceId-t.deviceId),e}let n=new Map,r=e=>{let t=n.get(e);if(t)return t;let r={deviceId:e,deviceName:w.get(e)??`Device ${e}`,pipeline:Mt,decoder:Mt,audio:Mt};return n.set(e,r),r};for(let i of y??[]){let a=r(i.deviceId);n.set(i.deviceId,{...a,pipeline:{active:!0,pinned:i.pinned,nodeId:i.agentNodeId,reason:i.reason??``},decoder:{active:e===`cluster`?!0:i.agentNodeId===t,pinned:!1,nodeId:i.agentNodeId,reason:`co-located`}})}for(let e of b??[]){let t=r(e.deviceId);n.set(e.deviceId,{...t,audio:{active:!0,pinned:e.pinned,nodeId:e.nodeId,reason:`capacity`}})}let i=[...n.values()];return i.sort((e,t)=>e.deviceId-t.deviceId),i},[y,b,x,w,e,t]),D=a(()=>(S??[]).filter(e=>e.isOnline).map(e=>({id:e.id,name:e.name})),[S]),O=()=>{s.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineAssignments`]]}),s.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getAudioAssignments`]]}),s.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCameraStatuses`]]})},k=g({onSuccess:O}),j=xe({onSuccess:O}),M=ve({onSuccess:O}),F=ce({onSuccess:O}),I=(e,t,n)=>{t===`pipeline`?k.mutate({deviceId:e,agentNodeId:n}):M.mutate({deviceId:e,nodeId:n}),p(null)},L=(e,t)=>{t===`pipeline`?j.mutate({deviceId:e}):F.mutate({deviceId:e}),p(null)};return d(`div`,{className:`rounded-lg border border-border overflow-x-auto`,children:r(`table`,{className:`w-full text-xs min-w-[760px] table-fixed`,children:[d(`thead`,{className:`bg-surface`,children:r(`tr`,{className:`text-foreground-subtle text-[10px] uppercase tracking-wider`,children:[!n&&d(`th`,{className:`w-10`}),d(`th`,{className:`min-w-[200px] text-left px-3 py-2 align-middle`,children:`Camera`}),e===`cluster`?r(o,{children:[d(`th`,{className:`w-[168px] text-left px-3 py-2 align-middle`,children:`Auto | Pin`}),d(`th`,{className:`w-[188px] text-left px-3 py-2 align-middle`,children:`Resolved placement`})]}):r(o,{children:[d(`th`,{className:`w-[120px] text-left px-3 py-2 align-middle`,children:`Pipeline`}),d(`th`,{className:`w-[120px] text-left px-3 py-2 align-middle`,children:`Decoder`}),d(`th`,{className:`w-[120px] text-left px-3 py-2 align-middle`,children:`Audio`})]}),d(`th`,{className:`w-[132px] text-left px-3 py-2 align-middle`,children:`Status`})]})}),r(`tbody`,{children:[T.map(t=>{let a=_.get(t.deviceId),s=m===t.deviceId;return r(i.Fragment,{children:[r(`tr`,{className:`border-t border-border align-middle relative`,children:[!n&&d(`td`,{className:`px-2 py-2 align-middle`,children:d(`button`,{type:`button`,onClick:()=>h(s?null:t.deviceId),className:`p-1 rounded hover:bg-surface-hover text-foreground-subtle`,"aria-label":s?`Collapse broker details`:`Expand broker details`,children:d(s?lt:at,{className:`h-3.5 w-3.5`})})}),r(`td`,{className:`px-3 py-2 align-middle min-w-0`,children:[d(`div`,{className:`text-foreground font-medium leading-tight line-clamp-2 break-words`,title:t.deviceName,children:t.deviceName}),r(`div`,{className:`text-[10px] text-foreground-subtle leading-tight`,children:[`#`,t.deviceId]})]}),e===`cluster`?r(o,{children:[d(`td`,{className:`px-3 py-2 align-middle`,children:d(zt,{state:t.pipeline,onlineNodes:D,pending:k.isPending||j.isPending,onChange:e=>{e===`auto`?L(t.deviceId,`pipeline`):I(t.deviceId,`pipeline`,e)}})}),d(`td`,{className:`px-3 py-2 align-middle`,children:d(Vt,{state:t.pipeline,deviceId:t.deviceId})})]}):r(o,{children:[d(Ut,{role:`pipeline`,state:t.pipeline,mode:e,deviceId:t.deviceId,onlineNodes:D,isMenuOpen:l?.deviceId===t.deviceId&&l.role===`pipeline`,onToggleMenu:()=>p(l?.deviceId===t.deviceId&&l.role===`pipeline`?null:{deviceId:t.deviceId,role:`pipeline`}),onCloseMenu:()=>p(null),onMove:e=>I(t.deviceId,`pipeline`,e),onUnpin:()=>L(t.deviceId,`pipeline`)}),d(Ut,{role:`decoder`,state:t.decoder,mode:e,deviceId:t.deviceId,onlineNodes:D,readOnly:!0,isMenuOpen:!1,onToggleMenu:()=>void 0,onCloseMenu:()=>void 0,onMove:()=>void 0,onUnpin:()=>void 0}),d(Ut,{role:`audio`,state:t.audio,mode:e,deviceId:t.deviceId,onlineNodes:D,isMenuOpen:l?.deviceId===t.deviceId&&l.role===`audio`,onToggleMenu:()=>p(l?.deviceId===t.deviceId&&l.role===`audio`?null:{deviceId:t.deviceId,role:`audio`}),onCloseMenu:()=>p(null),onMove:e=>I(t.deviceId,`audio`,e),onUnpin:()=>L(t.deviceId,`audio`)})]}),d(`td`,{className:`px-3 py-2 align-middle`,children:d(qt,{snap:a})})]}),s&&!n&&r(`tr`,{className:`bg-surface/50`,children:[d(`td`,{}),r(`td`,{colSpan:e===`cluster`?4:5,className:`px-3 py-2 space-y-3`,children:[t.pipeline.nodeId&&d(Rt,{deviceId:t.deviceId,nodeId:t.pipeline.nodeId}),d(A,{widgetId:`stream-broker/stream-broker-panel`,host:`device-tab`,deviceId:t.deviceId,instanceId:`pipeline-row/${t.deviceId}`,config:{variant:`compact`,title:`Stream brokers & clients`}})]})]})]},t.deviceId)}),T.length===0&&d(`tr`,{children:d(`td`,{colSpan:n?e===`cluster`?4:5:e===`cluster`?5:6,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:e===`agent`?`No cameras assigned to this node`:`No cameras currently assigned`})})]})]})})}function Rt({deviceId:e,nodeId:t}){let n=c(),{data:i}=Ee({nodeId:t}),{data:a}=w({deviceId:e}),o=he({onSuccess:()=>{n.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineDevicePin`]]})}}),s=i?.devices??[],l=a?.deviceKey??`auto`,u=l!==`auto`&&!s.some(e=>e.key===l);return r(`label`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[d(`span`,{className:`shrink-0 font-medium text-foreground`,children:`Inference device`}),r(`select`,{value:l,disabled:o.isPending,"aria-label":`Inference device pin`,onChange:t=>o.mutate({deviceId:e,deviceKey:t.target.value}),className:`rounded-md border border-border bg-background px-2 py-1 text-xs text-foreground`,children:[d(`option`,{value:`auto`,children:`Auto (balanced)`}),u&&r(`option`,{value:l,children:[`Pin → `,l,` (not on this node)`]}),s.map(e=>r(`option`,{value:e.key,children:[`Pin → `,e.key,e.available?``:` (unavailable)`]},e.key))]}),o.isPending&&d(`span`,{className:`text-[10px] opacity-70`,children:`saving…`})]})}function zt({state:e,onlineNodes:t,pending:n,onChange:i}){let a=e.pinned&&e.nodeId?e.nodeId:`auto`,o=[...new Set([...e.nodeId?[e.nodeId]:[],...t.map(e=>e.id)])];return r(`select`,{value:a,disabled:n,"aria-label":`Pipeline 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-xs text-foreground`,children:[d(`option`,{value:`auto`,children:`Auto`}),o.map(e=>r(`option`,{value:e,children:[`Pin → `,t.find(t=>t.id===e)?.name??e]},e))]})}function Bt(e){let n=t(null);return e.nodeId!==null&&(n.current=e),n.current}function Vt({state:e,deviceId:t}){let n=Bt(e),i=e.active&&e.nodeId!==null;if(n===null||n.nodeId===null)return d(`span`,{className:`text-[10px] text-foreground-subtle italic`,children:`— · no session yet`});let a=n.pinned?`pinned · manual`:`auto · ${n.reason||`capacity`}`;return r(`div`,{className:`flex flex-col leading-tight min-w-0`,children:[d(`span`,{className:`font-mono text-[11px] truncate ${i?`text-foreground`:`text-foreground-subtle`}`,title:n.pinned?n.nodeId:`${n.nodeId} — an unpinned camera is re-elected per on-motion session, so this can change between sessions`,children:n.nodeId}),d(`span`,{className:`truncate ${n.pinned?`text-amber-400 text-[10px]`:`text-foreground-subtle text-[10px]`}`,title:a,children:a}),d(`span`,{className:`truncate text-[10px] ${i?`text-emerald-400`:`text-foreground-subtle/70`}`,children:i?`● running here`:`○ idle · last session here`}),d(Ht,{deviceId:t,nodeId:n.nodeId})]})}function Ht({deviceId:e,nodeId:t}){let n=c(),{data:i}=w({deviceId:e},{refetchOnMount:`always`}),{data:a}=Ee({nodeId:t},{staleTime:Pt}),o=he({onSuccess:()=>{n.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineDevicePin`]]})}});if(i===void 0||a===void 0)return d(`span`,{className:`mt-0.5 text-[10px] text-foreground-subtle italic`,children:`device: …`});let s=a.devices??[],l=s.filter(e=>e.enabled),u=i.deviceKey??`auto`,f=u!==`auto`&&!l.some(e=>e.key===u),p=s.find(e=>e.key===u);return r(`select`,{value:u,disabled:o.isPending,"aria-label":`Inference device pin`,onChange:t=>o.mutate({deviceId:e,deviceKey:t.target.value}),className:`mt-0.5 w-full min-w-0 rounded border border-border bg-background px-1 py-0.5 text-[10px] text-foreground disabled:opacity-50`,children:[d(`option`,{value:`auto`,children:`Auto (balanced)`}),f&&r(`option`,{value:u,children:[p?`${H(p).label} (${u})`:u,` (not enabled)`]}),l.map(e=>r(`option`,{value:e.key,children:[H(e).label,` · `,e.format]},e.key))]})}function Ut({role:e,state:t,mode:n,onlineNodes:i,readOnly:a=!1,isMenuOpen:o,onToggleMenu:s,onCloseMenu:c,onMove:l,onUnpin:u}){let f=Ft[e],p=i.filter(e=>e.id!==(t.nodeId??``)),m=!a&&(t.active||n===`cluster`)&&(p.length>0||t.pinned);return r(`td`,{className:`px-3 py-2 align-middle relative min-w-0`,children:[r(`div`,{className:`flex items-center gap-2 min-w-0`,children:[d(n===`agent`?Wt:Gt,{state:t,Icon:f}),d(`div`,{className:`ml-auto shrink-0`,children:m&&d(`button`,{type:`button`,onClick:s,className:`p-1 rounded hover:bg-surface-hover`,"aria-label":`${It[e]} actions`,children:d(xt,{className:`h-3 w-3 text-foreground-subtle`})})})]}),o&&m&&d(Jt,{title:It[e],targets:p,pinned:t.pinned,onMove:l,onUnpin:u,onClose:c})]})}function Wt({state:e,Icon:t}){return r(`div`,{className:`flex items-center gap-1.5`,children:[d(e.active?$e:et,{className:`h-3.5 w-3.5 ${e.active?`text-success`:`text-foreground-subtle/50`}`}),d(t,{className:`h-3 w-3 ${e.active?`text-foreground-subtle`:`text-foreground-subtle/40`}`}),e.pinned&&d(Ct,{className:`h-2.5 w-2.5 text-amber-400`})]})}function Gt({state:e,Icon:t}){return!e.active||!e.nodeId?r(`div`,{className:`flex items-center gap-1.5 text-foreground-subtle/60`,children:[d(t,{className:`h-3 w-3`}),d(`span`,{className:`text-[10px] italic`,children:`—`})]}):r(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[d(t,{className:`h-3 w-3 text-foreground-subtle shrink-0`}),r(`div`,{className:`flex flex-col leading-tight min-w-0`,children:[d(`span`,{className:`font-mono text-[11px] text-foreground truncate`,children:e.nodeId}),d(`span`,{className:`flex items-center gap-1 text-[10px]`,children:e.pinned?r(`span`,{className:`inline-flex items-center gap-0.5 text-amber-400`,children:[d(Ct,{className:`h-2.5 w-2.5`}),` manual`]}):r(`span`,{className:`text-foreground-subtle truncate`,children:[`auto · `,e.reason||`capacity`]})})]})]})}var Kt=`min-h-[3.25rem]`;function qt({snap:e}){if(!e)return d(`div`,{className:`flex items-center ${Kt}`,children:d(`span`,{className:`text-[10px] text-foreground-subtle italic`,children:`—`})});let{phase:t,actualFps:n,avgInferenceTimeMs:i,queueDepth:a,configuredFps:o,droppedFrames:s}=e.metrics,c=m(t);return r(`div`,{className:`flex flex-col justify-center gap-0.5 font-mono text-[10px] tabular-nums leading-tight min-w-0 ${Kt}`,children:[r(`span`,{className:`inline-flex items-center gap-1 min-w-0 ${c.textColor}`,children:[d(fe,{phase:t,className:`h-2.5 w-2.5 shrink-0`}),d(`span`,{className:`font-semibold uppercase tracking-wider truncate`,children:c.label})]}),r(`span`,{className:`text-foreground-subtle whitespace-nowrap truncate`,children:[d(`span`,{className:`text-foreground`,children:n.toFixed(1)}),r(`span`,{children:[`/`,o.toFixed(0),` fps`]})]}),r(`span`,{className:`text-foreground-subtle whitespace-nowrap truncate`,children:[d(`span`,{className:`text-foreground`,children:i.toFixed(0)}),d(`span`,{children:` ms`}),a>0&&r(`span`,{className:`text-warning ml-1`,children:[`q`,a]})]}),r(`span`,{className:`whitespace-nowrap truncate ${s>0?`text-warning`:`text-foreground-subtle`}`,children:[`drops `,d(`span`,{className:`text-foreground`,children:s})]})]})}function Jt({title:e,targets:n,pinned:i,onMove:a,onUnpin:o,onClose:s}){let c=t(null);return f(()=>{let e=e=>{c.current?.contains(e.target)||s()};return window.addEventListener(`mousedown`,e),()=>window.removeEventListener(`mousedown`,e)},[s]),r(`div`,{ref:c,className:`absolute right-2 top-full mt-1 w-48 rounded-lg border border-border bg-surface shadow-lg z-20 text-left`,children:[d(`div`,{className:`px-3 py-1 text-[9px] uppercase tracking-wider text-foreground-subtle border-b border-border`,children:e}),n.length>0&&d(`div`,{className:`py-1`,children:n.map(e=>r(`button`,{type:`button`,onClick:()=>a(e.id),className:`block w-full text-left px-3 py-1 text-[11px] text-foreground hover:bg-surface-hover`,children:[`Move to `,e.name]},e.id))}),i&&r(`button`,{type:`button`,onClick:o,className:`block w-full text-left px-3 py-1.5 text-[11px] text-destructive hover:bg-destructive/10 border-t border-border`,children:[`Unpin `,e.toLowerCase()]}),n.length===0&&!i&&d(`div`,{className:`px-3 py-1.5 text-[10px] text-foreground-subtle italic`,children:`Already auto · no other nodes online`})]})}function Yt({nodeId:e,refreshToken:t}){return r(`div`,{className:`space-y-6`,children:[d(jt,{refreshToken:t,nodeId:e}),r(`div`,{children:[d(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Cameras on this node`}),r(`p`,{className:`text-[11px] text-foreground-subtle`,children:[`Checkboxes mark the roles currently running on `,e,`. Use the kebab to move a role to another node or unpin it; live KPIs come from the runner snapshot stream.`]})]}),d(Lt,{mode:`agent`,nodeId:e,compact:!0})]})}n();function Xt(e,t){let n=Math.max(0,t-e);return`${Math.floor(e/1e3)}s idle · ${Math.floor(n/1e3)}s left`}function Zt({nodeId:e,refreshToken:t}){let n=c(),i=x({onSettled:()=>{n.invalidateQueries({queryKey:[`pipelineExecutor`,`listLoadedEngines`]})}}),{data:o}=I({nodeId:e}),s=_(`pipeline.engine-metrics-snapshot`,t=>t.nodeId===e)?.engines??o??null,l=s===null;me([`pipelineRunner`,`getLocalCameras`],[`pipeline.camera-assigned`,`pipeline.camera-unassigned`]);let{data:u}=be({nodeId:e}),{values:f}=_e(`pipeline.camera-metrics-snapshot`,e=>e.deviceId,t=>t.nodeId===e),p=a(()=>f.filter(e=>e.metrics.phase===`active`).length,[f]),m=t=>{let n=u??[];n.length>0&&!window.confirm(`${n.length} camera(s) are dispatching through this engine. Killing it forces a respawn on the next frame. Continue?`)||i.mutate({nodeId:e,engine:t,force:n.length>0})};return r(`div`,{className:`space-y-6`,children:[r(`div`,{children:[d(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Inference engines on this node`}),r(`p`,{className:`text-[11px] text-foreground-subtle`,children:[(s??[]).length,` engine(s) resident in RAM. `,(u??[]).length,` `,`camera(s) attached, `,p,` actively dispatching frames. Refreshes every 5s.`]})]}),d(`div`,{className:`rounded-lg border border-border overflow-x-auto`,children:r(`table`,{className:`w-full text-xs min-w-[640px]`,children:[d(`thead`,{className:`bg-surface`,children:r(`tr`,{className:`text-foreground-subtle text-[10px] uppercase tracking-wider`,children:[d(`th`,{className:`text-left px-3 py-2 whitespace-nowrap`,children:`Kind`}),d(`th`,{className:`text-left px-3 py-2 whitespace-nowrap`,children:`Runtime / Backend / Device`}),d(`th`,{className:`text-left px-3 py-2`,children:`Models`}),d(`th`,{className:`text-right px-3 py-2 whitespace-nowrap`,children:`Pool PID`}),d(`th`,{className:`text-right px-3 py-2 whitespace-nowrap`,children:`Auto-kill`}),d(`th`,{className:`text-right px-3 py-2 whitespace-nowrap`,children:`In use`}),d(`th`,{className:`w-20`})]})}),r(`tbody`,{children:[l&&d(`tr`,{children:d(`td`,{colSpan:7,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:`Loading…`})}),!l&&(s??[]).map(e=>{let t=e.kind===`warm-override`,n=e.kind===`device-pool`;return r(`tr`,{className:`border-t border-border ${t?`bg-amber-500/5`:n?`bg-primary/[0.05]`:``}`,children:[d(`td`,{className:`px-3 py-2`,children:r(`span`,{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded-full text-[10px] font-medium ${t?`bg-amber-500/15 text-amber-400`:n?`bg-primary/15 text-primary`:`bg-success/15 text-success`}`,children:[d(t?St:n?Ie:W,{className:`h-3 w-3`}),t?`warm`:n?`pool`:`runtime`]})}),d(`td`,{className:`px-3 py-2`,children:r(`span`,{className:`inline-flex items-center gap-1 text-[11px] text-sky-400`,children:[d(tt,{className:`h-3 w-3`}),e.engine.runtime,`/`,e.engine.backend,e.engine.device?`/${e.engine.device}`:``,e.engine.format?` · ${e.engine.format}`:``]})}),d(`td`,{className:`px-3 py-2`,children:e.modelsLoaded.length===0?d(`span`,{className:`text-foreground-subtle text-[11px]`,children:`—`}):d(`div`,{className:`flex flex-wrap gap-1`,children:e.modelsLoaded.map(e=>d(`span`,{className:`inline-block rounded bg-surface px-1.5 py-0.5 text-[10px] font-mono text-foreground-subtle`,children:e},e))})}),d(`td`,{className:`px-3 py-2 text-right font-mono text-foreground`,children:e.poolPid??`—`}),d(`td`,{className:`px-3 py-2 text-right text-[11px]`,children:e.idleMs!==null&&e.idleTtlMs!==null?d(`span`,{className:`text-foreground-subtle`,children:Xt(e.idleMs,e.idleTtlMs)}):d(`span`,{className:`text-foreground-subtle/50`,children:`never`})}),d(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t?`—`:(u??[]).length}),d(`td`,{className:`px-3 py-2 text-right`,children:n?d(`span`,{className:`text-[11px] text-foreground-subtle`,children:`auto`}):r(`button`,{type:`button`,disabled:i.isPending,onClick:()=>m(e.engine),className:`inline-flex items-center gap-1 px-2 py-1 rounded border border-destructive/30 text-destructive text-[11px] hover:bg-destructive/10 disabled:opacity-50`,children:[d(mt,{className:`h-3 w-3`}),`Kill`]})})]},e.engineKey)}),!l&&(s??[]).length===0&&d(`tr`,{children:d(`td`,{colSpan:7,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:`No engines resident — the factory spins up on the first pipeline run.`})})]})]})}),r(`div`,{className:`text-[10px] text-foreground-subtle leading-relaxed`,children:[d(`strong`,{className:`text-foreground`,children:`runtime`}),`: main camera-serving engine; never auto-killed while cameras attached. `,d(`strong`,{className:`text-foreground`,children:`warm`}),`: benchmark/test override held in cache for fast re-use; auto-disposed after the idle TTL.`,` `,d(`strong`,{className:`text-foreground`,children:`pool`}),`: a per-device balanced inference pool (one per enabled accelerator, running concurrently); reaper-managed on its own idle TTL.`]}),i.isError&&r(`div`,{className:`rounded-md border border-destructive/30 bg-destructive/5 px-3 py-2 text-[11px] text-destructive`,children:[`Kill failed:`,` `,i.error instanceof Error?i.error.message:`unknown`]})]})}n();var Qt=new Set(Pe);function $t(e){return Qt.has(e)}function en(e,t,n){return`${e}/${t}/${n}`}function tn(e){return{coreml:`CoreML`,openvino:`OpenVINO`,onnx:`ONNX`}[e.format]??e.format.toUpperCase()}function nn(e){return{coreml:`Apple Neural Engine / GPU — .mlpackage`,openvino:`Intel CPU / GPU / NPU — .xml`,onnx:`CPU, CUDA, Node.js — .onnx`}[e.format]??`.${e.format}`}function K(e){return e.format}function rn(e,t){let n=0,r=0,i=0;for(let a of e)for(let e of a.addons)for(let a of e.models){let e=a.formats[t];e&&(n++,e.downloaded&&(r++,i+=e.sizeMB))}return{total:n,downloaded:r,downloadedSizeMB:i}}function an({addonId:e,model:t,format:n,isActive:i,progress:a,errorMsg:o,onDownload:s,onDelete:c}){let l=t.formats[n];return l?r(`div`,{className:`flex items-center gap-3 px-4 py-3 border-b border-border/50 last:border-b-0 hover:bg-surface-hover/30 transition-colors`,children:[d(`div`,{className:`h-2 w-2 rounded-full shrink-0 ${l.downloaded?`bg-success`:`bg-foreground-subtle/30`}`}),r(`div`,{className:`flex-1 min-w-0`,children:[r(`div`,{className:`flex items-center gap-2`,children:[d(`span`,{className:`text-sm font-medium text-foreground`,children:t.name}),r(`span`,{className:`text-[10px] text-foreground-subtle font-mono`,children:[`(`,t.id,`)`]})]}),a&&a.progress>=0&&a.progress<100&&r(`div`,{className:`mt-1.5 flex items-center gap-2 max-w-xs`,children:[d(`div`,{className:`flex-1 h-1 bg-surface-hover rounded-full overflow-hidden`,children:d(`div`,{className:`bg-primary h-full rounded-full transition-all duration-300`,style:{width:`${a.progress}%`}})}),r(`span`,{className:`text-[9px] text-primary font-mono tabular-nums shrink-0`,children:[Math.round(a.progress),`%`]})]})]}),d(`span`,{className:`text-xs text-foreground-subtle tabular-nums shrink-0`,children:yt(l.sizeMB)}),o&&r(`span`,{className:`flex items-center gap-1 text-[10px] text-danger max-w-[160px] truncate shrink-0`,title:o,children:[d(it,{className:`h-3 w-3 shrink-0`}),o]}),l.downloaded?r(`button`,{onClick:c,disabled:i,className:`inline-flex items-center gap-1.5 px-3 py-1.5 text-[11px] font-medium rounded-md border border-danger/30 text-danger hover:bg-danger/10 disabled:opacity-50 transition-colors shrink-0`,children:[i?d(U,{className:`h-3 w-3 animate-spin`}):d(mt,{className:`h-3 w-3`}),i?`Deleting...`:`Delete`]}):r(`button`,{onClick:s,disabled:i,className:`inline-flex items-center gap-1.5 px-3 py-1.5 text-[11px] font-medium rounded-md bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 transition-colors shrink-0`,children:[i?d(U,{className:`h-3 w-3 animate-spin`}):d(Ue,{className:`h-3 w-3`}),i?`Downloading...`:`Download`]})]}):null}function on({engines:e,activeEngine:t,viewEngine:n,onSelect:i}){let[a,o]=u(!1);return r(`div`,{className:`relative`,children:[r(`button`,{type:`button`,onClick:()=>o(!a),className:`flex items-center gap-2 rounded-lg border border-border bg-surface px-4 py-2.5 w-full text-left hover:bg-surface-hover transition-colors`,children:[d(W,{className:`h-4 w-4 text-primary shrink-0`}),r(`div`,{className:`flex-1 min-w-0`,children:[r(`div`,{className:`flex items-center gap-2`,children:[d(`span`,{className:`text-sm font-medium text-foreground`,children:tn(n)}),K(n)===K(t)&&d(`span`,{className:`text-[9px] px-1.5 py-0.5 rounded-full bg-success/10 text-success font-medium`,children:`Active`})]}),d(`div`,{className:`text-[10px] text-foreground-subtle`,children:nn(n)})]}),d(lt,{className:`h-4 w-4 text-foreground-subtle transition-transform ${a?`rotate-180`:``}`})]}),a&&d(`div`,{className:`absolute top-full left-0 right-0 mt-1 rounded-lg border border-border bg-surface shadow-lg z-50 overflow-hidden`,children:e.map(e=>{let a=K(e)===K(n),s=K(e)===K(t);return r(`button`,{type:`button`,onClick:()=>{i(e),o(!1)},className:`flex items-center gap-3 px-4 py-2.5 w-full text-left transition-colors ${a?`bg-primary/5`:`hover:bg-surface-hover`}`,children:[d(W,{className:`h-4 w-4 shrink-0 ${a?`text-primary`:`text-foreground-subtle`}`}),r(`div`,{className:`flex-1`,children:[r(`div`,{className:`flex items-center gap-2`,children:[d(`span`,{className:`text-sm font-medium ${a?`text-primary`:`text-foreground`}`,children:tn(e)}),s&&d(`span`,{className:`text-[9px] px-1.5 py-0.5 rounded-full bg-success/10 text-success font-medium`,children:`Active`})]}),d(`div`,{className:`text-[10px] text-foreground-subtle`,children:nn(e)})]}),a&&d(ct,{className:`h-4 w-4 text-primary shrink-0`})]},K(e))})})]})}function sn({embedded:t=!1,nodeId:n}={}){let i=c(),a=n??`hub`,[s,l]=u(null),[f,p]=u(new Set),[m,h]=u(new Map),[g,_]=u(new Map),[v,y]=u(``),{data:x=[]}=Te({nodeId:a}),C=x.filter((e,t,n)=>n.findIndex(t=>t.format===e.format)===t),{data:w}=S({nodeId:a}),E=w,{data:D,isLoading:O}=ne({nodeId:a}),k=b(),A=te();N(`model.download.progress`,e=>{let t=e.data,n=typeof t.modelId==`string`?t.modelId:void 0,r=typeof t.progress==`number`?t.progress:void 0,a=typeof t.totalMB==`number`?t.totalMB:0;n===void 0||r===void 0||(h(e=>{let t=new Map(e);return r===100||r===-1?t.delete(n):t.set(n,{modelId:n,progress:r,totalMB:a}),t}),r===100&&i.invalidateQueries({queryKey:[[`pipelineExecutor`,`getSchema`]]}))});let j=E??{runtime:`node`,backend:`cpu`,format:`onnx`},M=C.find(e=>e.format===s)??j,P=M.format,F=e=>e.formats[P]?.downloaded===!0,I=D?.slots??[],L=I.map(e=>({...e,addons:e.addons.map(e=>({...e,models:T(e.models,P)})).filter(e=>e.models.length>0)})).filter(e=>e.addons.length>0),R=rn(L,P),ee=e(async(e,t,n)=>{if(!$t(n))return;let r=en(e,t,n);p(e=>new Set([...e,r])),_(e=>{let t=new Map(e);return t.delete(r),t});try{await k.mutateAsync({addonId:e,modelId:t,format:n,nodeId:a}),i.invalidateQueries({queryKey:[[`pipelineExecutor`,`getSchema`]]})}catch(e){_(t=>new Map([...t,[r,e instanceof Error?e.message:`Download failed`]]))}finally{p(e=>{let t=new Set(e);return t.delete(r),t})}},[k,i,a]),z=e(async(e,t,n)=>{if(!$t(n))return;let r=en(e,t,n);p(e=>new Set([...e,r])),_(e=>{let t=new Map(e);return t.delete(r),t});try{await A.mutateAsync({addonId:e,modelId:t,format:n,nodeId:a}),i.invalidateQueries({queryKey:[[`pipelineExecutor`,`getSchema`]]})}catch(e){_(t=>new Map([...t,[r,e instanceof Error?e.message:`Delete failed`]]))}finally{p(e=>{let t=new Set(e);return t.delete(r),t})}},[A,i,a]),re=e(e=>{l(e.format)},[]),B=v.trim()?L.map(e=>({...e,addons:e.addons.map(e=>({...e,models:e.models.filter(t=>t.name.toLowerCase().includes(v.toLowerCase())||t.id.toLowerCase().includes(v.toLowerCase())||e.name.toLowerCase().includes(v.toLowerCase()))})).filter(e=>e.models.length>0)})).filter(e=>e.addons.length>0):L,ie=r(o,{children:[O&&d(`div`,{className:`flex items-center justify-center py-16`,children:d(U,{className:`h-5 w-5 animate-spin text-foreground-subtle`})}),!O&&I.length===0&&r(`div`,{className:`flex flex-col items-center justify-center py-16 text-foreground-subtle`,children:[d(We,{className:`h-8 w-8 mb-3 opacity-30`}),d(`span`,{className:`text-sm`,children:`No pipeline steps available`}),d(`span`,{className:`text-xs mt-1`,children:`Configure the detection pipeline to see available models.`})]}),!O&&I.length>0&&r(o,{children:[d(on,{engines:C,activeEngine:j,viewEngine:M,onSelect:re}),r(`div`,{className:`flex items-center gap-4 text-xs text-foreground-subtle`,children:[r(`span`,{children:[d(`span`,{className:`font-semibold text-foreground tabular-nums`,children:R.total}),d(`span`,{className:`ml-1`,children:`compatible models`})]}),d(`span`,{className:`text-border`,children:`|`}),r(`span`,{children:[d(`span`,{className:`font-semibold text-success tabular-nums`,children:R.downloaded}),d(`span`,{className:`ml-1`,children:`downloaded`})]}),d(`span`,{className:`text-border`,children:`|`}),r(`span`,{className:`tabular-nums`,children:[yt(R.downloadedSizeMB),d(`span`,{className:`ml-1`,children:`on disk`})]})]}),R.total>5&&r(`div`,{className:`relative`,children:[d(Ze,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-foreground-subtle`}),d(`input`,{type:`text`,value:v,onChange:e=>y(e.target.value),placeholder:`Search models...`,className:`w-full pl-9 pr-3 py-2 text-sm rounded-lg border border-border bg-surface text-foreground placeholder:text-foreground-subtle/50 focus:outline-none focus:ring-1 focus:ring-primary`})]}),B.map(e=>{let t=e.addons.reduce((e,t)=>e+t.models.length,0),n=e.addons.reduce((e,t)=>e+T(t.models,P).filter(F).length,0);return r(`div`,{children:[r(`div`,{className:`flex items-center gap-2 mb-2`,children:[d(`h2`,{className:`text-sm font-semibold text-foreground`,children:e.label}),d(`div`,{className:`flex-1 h-px bg-border`}),r(`span`,{className:`text-[10px] text-foreground-subtle tabular-nums`,children:[n,`/`,t]})]}),d(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:e.addons.map(e=>e.models.map(t=>{let n=en(e.id,t.id,P);return d(an,{addonId:e.id,model:t,format:P,isActive:f.has(n),progress:m.get(t.id),errorMsg:g.get(n),onDownload:()=>ee(e.id,t.id,P),onDelete:()=>z(e.id,t.id,P)},`${e.id}/${t.id}`)}))})]},e.id)}),B.length===0&&d(`div`,{className:`text-center py-8 text-sm text-foreground-subtle`,children:v.trim()?r(o,{children:[`No models matching “`,v,`”`]}):r(o,{children:[`No models available for `,tn(M),` format`]})})]})]});return t?d(`div`,{className:`space-y-4`,children:ie}):d(gt,{children:ie})}function cn({nodeId:e,refreshToken:t}){return d(sn,{embedded:!0,nodeId:e})}var ln=`pipeline-runner`,un=200;function dn({nodeId:e}){return r(`div`,{className:`flex flex-col gap-3`,children:[r(`div`,{children:[d(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Runner logs`}),r(`p`,{className:`text-[11px] text-foreground-subtle`,children:[`pipeline-runner activity on `,e,` — camera attach/detach, engine phases and pipeline errors. Streaming live; the device chip on a line tells which camera it refers to.`]})]}),d(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:d(O,{agentId:e,addonId:ln,limit:un,maxHeight:`max-h-[calc(100vh-360px)]`,showScope:!0,showDeviceChip:!0,showFilters:!1})})]})}n(),n();function fn({nodeId:e,title:t}){let{data:n}=Re(),{data:i}=z(void 0),o=a(()=>{let e=new Map;for(let t of n??[])e.set(t.id,t.name);return e},[n]),s=a(()=>{if(!e)return null;let t=new Set;for(let n of i??[])n.agentNodeId===e&&t.add(n.deviceId);return t},[e,i]),[c,l]=u(new Map);N(`pipeline.camera-metrics-snapshot`,t=>{let n=t.data;typeof n.deviceId==`number`&&(e&&n.nodeId!==e||l(e=>{let t=new Map(e);return t.set(n.deviceId,n),t}))}),f(()=>{if(c.size===0)return;let e=setInterval(()=>{l(e=>{let t=Date.now()-1e4,n=!1,r=new Map(e);for(let[i,a]of e)a.timestamp<t&&(r.delete(i),n=!0);return n?r:e})},5e3);return()=>clearInterval(e)},[c.size]);let p=a(()=>{let e=[];for(let t of c.values())s&&!s.has(t.deviceId)||e.push(t);return e.sort((e,t)=>e.deviceId-t.deviceId),e},[c,s]);return p.length===0?r(`div`,{className:`rounded-md border border-border bg-surface px-3 py-2 text-[11px] text-foreground-subtle italic`,children:[t??`Cameras`,`: no live snapshots yet`]}):r(`div`,{className:`rounded-md border border-border bg-surface px-3 py-2`,children:[r(`div`,{className:`flex items-center gap-2 mb-1.5`,children:[d(`span`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle`,children:t??`Cameras`}),d(`span`,{className:`text-[10px] text-foreground-subtle`,children:p.length})]}),d(`div`,{className:`flex flex-wrap gap-1.5`,children:p.map(e=>{let t=o.get(e.deviceId)??`#${e.deviceId}`,n=m(e.metrics.phase);return r(`div`,{title:`${t} · ${n.label} · ${e.metrics.actualFps.toFixed(1)} fps · ${e.metrics.avgInferenceTimeMs.toFixed(0)}ms infer · q=${e.metrics.queueDepth}`,className:`inline-flex items-center gap-1 rounded border px-1.5 py-0.5 text-[10px] ${n.badgeClass}`,children:[d(fe,{phase:e.metrics.phase,className:`h-2.5 w-2.5`}),d(`span`,{className:`font-medium text-foreground/90 max-w-[220px] truncate`,children:t}),d(`span`,{className:`font-mono tabular-nums`,children:e.metrics.actualFps.toFixed(1)}),d(`span`,{className:`opacity-60`,children:`fps`})]},e.deviceId)})})]})}var pn=`pipeline-orchestrator`;function mn(e){return je.find(t=>t.stepId===e)??null}function hn({title:e}){return d(`span`,{title:e??`One value for the whole cluster — this step writes into a shared vector index, where two encoders make similarity scores meaningless.`,className:`ml-1 rounded border border-primary/40 bg-primary/10 px-1 py-px text-[9px] font-medium uppercase tracking-wide text-primary`,children:`cluster-wide`})}function gn({step:e,engineFormat:t,runnableModelIds:n}){let i=c(),{data:a,isLoading:o}=de({addonId:pn}),s=we({onSuccess:()=>{i.invalidateQueries({queryKey:[[`addonSettings`,`getGlobalSettings`]]})}}),l=Me(a??null)[e.stepId]??e.defaultModelId,u=n.length>0&&!n.includes(l);return r(`div`,{className:`space-y-3`,children:[r(`div`,{className:`rounded-md border border-primary/30 bg-primary/5 px-3 py-2`,children:[r(`div`,{className:`flex items-center text-[11px] font-medium text-foreground`,children:[e.label,d(hn,{})]}),r(`p`,{className:`mt-1 text-[10px] leading-snug text-foreground-subtle`,children:[`Applies to every node. Changing it does not corrupt `,e.indexName,` — every vector carries the model that produced it and only matches its own — but it STRANDS it: the existing vectors stay readable and match nothing until a re-embed pass has run.`]})]}),o?d(U,{className:`h-4 w-4 animate-spin text-foreground-subtle`}):d(`select`,{className:`w-full rounded border border-border bg-surface px-2 py-1 text-xs`,value:l,disabled:s.isPending,onChange:t=>{t.target.value!==l&&s.mutate({addonId:pn,patch:{[Ne(e.stepId)]:t.target.value}})},children:e.options.map(t=>r(`option`,{value:t.id,children:[t.label,t.id===e.defaultModelId?` (default)`:``]},t.id))}),u&&r(`div`,{className:`rounded-md border border-amber-500/40 bg-amber-500/10 px-3 py-2 text-[10px] leading-snug text-amber-300`,children:[`This node's engine (`,t,`) ships no build of `,d(`b`,{children:l}),`. It will REFUSE this step rather than run a different encoder — a substitute would put a second feature space into `,e.indexName,`. Either pick a model with a `,t,` build, or accept that this node contributes nothing to that index.`]}),d(`p`,{className:`text-[10px] leading-snug text-foreground-subtle`,children:`Stored once, in Pipeline → Enrichment models. This editor writes that same row — there is no per-node copy of this value.`})]})}n();function q(e,t){if(!e)return null;for(let n of e.slots)for(let e of n.addons)if(e.id===t)return e;return null}function _n(e){if(!e)return null;let t=e.modelId!==void 0&&e.modelId!==``?e.modelId:void 0,n=e.settings&&Object.keys(e.settings).length>0?e.settings:void 0;return t===void 0&&n===void 0?null:{...t===void 0?{}:{modelId:t},...n===void 0?{}:{settings:n}}}function vn({nodeId:e,refreshToken:t}){let n=c(),[i,s]=u(null),[l,f]=u(null),[p,m]=u(``),[h,g]=u(null),_=Ee({nodeId:e},{refetchOnMount:`always`}),v=ne({nodeId:e},{refetchOnMount:`always`}),b=Me(de({addonId:`pipeline-orchestrator`}).data??null),x=_.data?.devices??[],S=R({onSuccess:()=>{n.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getNodeInferenceDevices`]]})}}),C=a(()=>v.data?Ce(v.data):[],[v.data]),w=a(()=>x.map(t=>({agentNodeId:e,engineLabel:t.format,deviceKey:t.key,deviceLabel:H(t).label})),[x,e]),E=e=>x.find(t=>t.key===e)??null,D=a(()=>x.filter(e=>e.enabled),[x]),O=D.length>=2,k=(e,t)=>re(q(v.data??null,e)?.models??[],t?.format),A=e=>{let t=E(e);return t?H(t).label:e},j=(e,t)=>D.filter(n=>n.key!==t&&k(e,n)).toSorted((e,t)=>e.key<t.key?-1:+(e.key>t.key))[0]??null,M=e=>{let t=q(v.data??null,e)?.enabledByDefault??!0;return{kind:`gate`,effectiveOn:t,defaultOn:t,explicit:!1}},N=(e,t)=>{let n=q(v.data??null,e);if(n)return De(n,t)},P=(e,t)=>{let n=M(e),r=n.kind===`gate`?n.effectiveOn:!1,i=q(v.data??null,e),a=t.deviceKey===void 0?null:E(t.deviceKey),o=re(i?.models??[],a?.format),s=a?.steps?.[e];if(!o){if(!r)return{kind:`na`};let n=s?.jumpDeviceKey,i=n!==void 0&&D.some(e=>e.key===n)?n:t.deviceKey===void 0?void 0:j(e,t.deviceKey)?.key;return i===void 0?{kind:`skip`}:{kind:`skip`,jumpTo:A(i)}}let c=mn(e);return c?{kind:`enabled`,modelId:b[e]??c.defaultModelId,clusterWide:!0}:{kind:`enabled`,modelId:(i?y({catalog:i,device:a,base:s?.modelId}):void 0)??`Auto`,...s?.jumpDeviceKey!==void 0&&D.some(e=>e.key===s.jumpDeviceKey)?{jumpTo:A(s.jumpDeviceKey)}:{}}},F=i&&v.data?q(v.data,i.addonId):null,I=i?E(i.deviceKey):null,L=I?.format??`coreml`,te=i?N(i.addonId,I):void 0,z=()=>{s(null),f(null),m(``)},B=(e,t)=>{if(t.deviceKey===void 0)return;let n=E(t.deviceKey)?.steps?.[e];s({addonId:e,deviceKey:t.deviceKey});let r=n?.settings??Fe(x.map(e=>({key:e.key,enabled:e.enabled,weight:e.weight,maxSessions:e.maxSessions,steps:e.steps??{}})),t.deviceKey,e)??{};f({enabled:!0,...n?.modelId===void 0?{}:{modelId:n.modelId},settings:r}),m(n?.jumpDeviceKey??``)},ie=()=>{if(!i)return;let t=_n(l),n=p!==``&&p!==i.deviceKey?p:void 0,r=t||n!==void 0?{...t,...n===void 0?{}:{jumpDeviceKey:n}}:null,a=x.map(e=>{let t={...e.steps};return e.key===i.deviceKey&&(r?t[i.addonId]=r:delete t[i.addonId]),{key:e.key,enabled:e.key===i.deviceKey?!0:e.enabled,weight:e.weight,maxSessions:e.maxSessions,steps:t}}),o=r?.settings!==void 0&&Object.keys(r.settings).length>0?ze(a,i.deviceKey,i.addonId):a;S.mutate({agentNodeId:e,inferenceDevices:Le(o)},{onSuccess:z})};if(_.isLoading||v.isLoading)return d(`div`,{className:`text-xs text-foreground-subtle animate-pulse p-4`,children:`Loading pipeline…`});if(x.length===0)return d(`div`,{className:`rounded-md border border-dashed border-border bg-background px-4 py-6 text-center text-xs text-foreground-subtle`,children:`No inference devices reported by this node's platform probe.`});if(!v.data)return d(`div`,{className:`text-xs text-foreground-subtle p-4`,children:`Catalog unavailable.`});let ae=i!==null&&F!==null&&I!==null;return r(`div`,{className:`relative h-full w-full space-y-3`,children:[r(`div`,{className:`rounded-md border border-border bg-muted/20 px-3 py-2 text-[11px] leading-relaxed text-foreground-subtle`,children:[`Each column is one of this node's inference accelerators. A cell shows the`,` `,d(`span`,{className:`font-medium text-foreground`,children:`base model`}),` every camera landing on that accelerator runs; click to change it. Whether a camera runs a step is set per-camera on that camera's Detection pipeline tab — there is no gate here.`]}),d(`div`,{className:ae?`md:pr-[360px]`:``,children:C.length>0?d(le,{tree:C,agents:w,gateFor:M,getCellState:P,onCellClick:B,selectedCell:i?{addonId:i.addonId,agentNodeId:e,deviceKey:i.deviceKey}:null,onSetGate:()=>{},fallbackNodeId:h,onFallbackNodeChange:g,hideGate:!0}):d(`div`,{className:`text-xs text-foreground-subtle`,children:`Catalog empty.`})}),d(ue,{open:ae,onClose:z,title:F?.name??``,subtitle:i&&I?`${e} · ${H(I).label} · ${I.format}`:``,footer:r(o,{children:[d(`div`,{className:`flex-1`}),d(`button`,{type:`button`,className:`px-3 py-1 text-xs border border-border rounded bg-surface hover:bg-muted`,onClick:z,children:`Cancel`}),d(`button`,{type:`button`,disabled:!i||!l||S.isPending,className:`px-3 py-1 text-xs bg-primary text-primary-foreground rounded disabled:opacity-50`,onClick:ie,children:S.isPending?`Saving…`:`Save`})]}),children:F&&i&&mn(i.addonId)?d(gn,{step:mn(i.addonId),engineFormat:L,runnableModelIds:T(F.models??[],L).map(e=>e.id)}):F&&i&&l?r(`div`,{className:`space-y-3`,children:[O&&r(`div`,{className:`rounded-md border border-border bg-muted/10 px-3 py-2 space-y-1`,children:[d(`label`,{className:`block text-[11px] font-medium text-foreground`,children:`Run on`}),r(`select`,{className:`w-full rounded border border-border bg-surface px-2 py-1 text-xs`,value:p,onChange:e=>m(e.target.value),children:[d(`option`,{value:``,children:`Auto (this device, or auto-jump if unsupported)`}),D.filter(e=>e.key!==i.deviceKey).map(e=>r(`option`,{value:e.key,children:[H(e).label,` · `,e.format]},e.key))]}),d(`p`,{className:`text-[10px] leading-snug text-foreground-subtle`,children:`Route this step (and its child steps) to another accelerator on this node.`})]}),d(ee,{mode:`agent`,addon:F,agentDefault:l,agentNodeId:e,engineFormat:L,effectiveModelId:te,onChangeAgentConfig:f})]}):d(`div`,{className:`rounded-md border border-amber-500/40 bg-amber-500/10 px-3 py-2 text-[11px] text-amber-300`,children:`This accelerator is no longer reported by the node, so there is nothing to provision here.`})})]})}n();var yn=[`pipeline-orchestrator`],bn=[`decoder`],xn=!1;function Sn({nodeId:e,refreshToken:t}){let n=ye(),[i,a]=u(null),[o,s]=u(null),c=(se(void 0).data??[]).find(t=>t.id===e),l=c?.name??e,f=c?.isOnline??!1,p=k({onSuccess:e=>{s(e.effectiveModelId===null?`Reset done — model config cleared (node offline: effective model resolves on reconnect)`:`Reset done — effective detection model: ${e.effectiveModelId} (Auto)`)}}),m=async()=>{await n({title:`Reset ${l} to hardware-aware defaults?`,message:`This clears every per-device model default on this node (back to the format default) and every per-camera step override scoped to it. Existing per-camera customisations on this node are lost.`,confirmLabel:`Reset`,variant:`danger`})&&(s(null),p.mutate({agentNodeId:e}))};return r(`div`,{className:`relative h-full w-full space-y-3`,children:[r(`div`,{className:`flex items-center justify-end gap-2 text-xs`,children:[o&&d(`span`,{className:`text-emerald-400`,children:o}),p.isError&&d(`span`,{className:`text-red-400`,children:p.error instanceof Error?p.error.message:`Reset failed`}),d(`button`,{type:`button`,onClick:()=>{m()},disabled:p.isPending,className:`rounded border border-amber-500/40 bg-surface px-2 py-0.5 text-amber-300 hover:bg-surface-hover disabled:opacity-50`,title:`Clear this node's per-device model defaults + per-camera overrides scoped to this node`,children:p.isPending?`Resetting…`:`Reset to default`})]}),d(fn,{nodeId:e}),d(bt,{nodeId:e,addonIds:yn,level:`global`,sectionIds:bn}),xn,xn,r(`div`,{children:[d(`h3`,{className:`mb-1.5 text-xs font-semibold uppercase tracking-wide text-foreground-subtle`,children:`Inference devices — default model per accelerator`}),d(Ve,{nodeId:e,nodeName:l,isOnline:f})]}),r(`div`,{children:[d(`h3`,{className:`mb-1.5 text-xs font-semibold uppercase tracking-wide text-foreground-subtle`,children:`Detection steps — model per accelerator`}),d(vn,{nodeId:e,refreshToken:t})]})]})}var Cn=[`detection-pipeline`,`audio-analyzer`,`pipeline-runner`],wn=`decoder-nodeav`;function Tn({nodeId:e,refreshToken:t}){let{data:n}=se(void 0),i=n?.find(t=>t.id===e)?.addons.find(e=>e.capabilities.includes(`decoder`))?.id??wn,a=[...Cn,i];return r(`div`,{className:`flex flex-col h-full`,children:[d(At,{nodeId:e,refreshToken:t}),d(`div`,{className:`flex-1 min-h-0 overflow-y-auto p-6`,children:d(bt,{nodeId:e,addonIds:a,level:`global`,extraTabs:[{id:`assignments`,label:`Assignments`,order:-10,content:d(Yt,{nodeId:e,refreshToken:t})},{id:`tree`,label:`Pipeline`,order:39,content:d(Sn,{nodeId:e,refreshToken:t})},{id:`engines`,label:`Warm instances`,order:180,content:d(Zt,{nodeId:e,refreshToken:t})},{id:`models`,label:`Models`,order:200,content:d(cn,{nodeId:e,refreshToken:t})},{id:`logs`,label:`Logs`,order:300,content:d(dn,{nodeId:e})}]})})]})}function En(e){let t=e.backend.toLowerCase(),n=e.device.toLowerCase();return e.key===`cpu`||n===`cpu`?`CPU`:t===`openvino`&&n===`npu`?`Intel NPU`:t===`openvino`&&(n===`gpu`||n===`igpu`)?`Intel iGPU`:t===`edgetpu`?`Coral Edge TPU`:t===`coreml`?`Apple ANE`:`${e.backend} ${e.device}`.trim()}var Dn={disabled:`switched off — not a dispatch target`,unavailable:`the node probe does not see it (unplugged or still provisioning)`,"cannot-host-camera-root":`its engine format has no object-detection root model`,"accelerator-preferred":`CPU fallback — it never competes while an accelerator is serving`};function On(e,t){return t<=0?0:Math.round(e/t*1e3)/10}function kn(e,t){let n=e.filter(e=>e.exclusion===null).reduce((e,t)=>e+(t.weight>0?t.weight:1),0);return e.map(e=>{let r=t.get(e.key),i=r?.sessions??0,a=e.weight>0?e.weight:1;return{key:e.key,label:En(e),format:e.format,sessions:i,queueDepth:r?.queueDepth??0,weight:a,weightSharePct:e.exclusion===null?On(a,n):null,maxSessions:e.maxSessions,atCap:e.maxSessions!==null&&i>=e.maxSessions,available:e.available,enabled:e.enabled,exclusion:e.exclusion}}).toSorted((e,t)=>e.exclusion===null==(t.exclusion===null)?e.key.localeCompare(t.key):e.exclusion===null?-1:1)}function An(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),r=e.loads.reduce((e,t)=>e+t.load.attachedCameras,0);return e.nodes.map(i=>{let a=t.get(i.id),o=kn(e.devicesByNode[i.id]??[],new Map((a?.load.devices??[]).map(e=>[e.deviceKey,{sessions:e.attachedCameras,queueDepth:e.queueDepthTotal}]))),s=i.isOnline&&i.detectEnabled,c=i.weight>0?i.weight:1,l=a?.load.attachedCameras??null;return{nodeId:i.id,name:i.name,isOnline:i.isOnline,detectEnabled:i.detectEnabled,reported:a!==void 0,attachedCameras:l,activeCameras:a?.load.activeCameras??null,maxCameras:i.maxCameras,capacityPct:l!==null&&i.maxCameras!==null&&i.maxCameras>0?On(l,i.maxCameras):null,queueDepthTotal:a?.load.queueDepthTotal??null,avgInferenceTimeMs:a?.load.avgInferenceTimeMs??null,score:a?.score??null,weight:c,weightSharePct:s?On(c,n):null,cameraSharePct:l===null?null:On(l,r),decodeHwaccel:a?.decodeHwaccel??null,devices:o,eligibleDeviceCount:o.filter(e=>e.exclusion===null).length}})}var jn=`pipeline-orchestrator`,Mn=`recorder`,Nn=`recordingNodeId`,Pn=[`ingestNode`,`recordingNode`,`audioNode`,`motionNode`],Fn=[{key:`detect`,label:`Detect`,hint:`Runs the detection pipeline (decode + inference) for assigned cameras`}];function In(e,t){for(let n of e?.sections??[])for(let e of n.fields??[])if(e.key===t)return e.value}function Ln(e,t){for(let[n,r]of Object.entries(e??{}))if(n===t)return r}function Rn(e,t,n){let r=In(e,t);return typeof r==`string`&&r.length>0?r:n}function zn(e,t,n){let r=In(e,t);return typeof r==`number`&&Number.isFinite(r)?r:n}function Bn(e,t){let n=Ln(e,t);return typeof n==`number`&&Number.isFinite(n)?n:null}function Vn(e,t){let n=Ln(e,t);return typeof n==`string`&&n.length>0?n:null}function Hn(e){return e===`ingestNode`?`Ingest`:e===`recordingNode`?`Recording`:e===`audioNode`?`Audio`:`Motion Node`}function Un(e){return e===`ingestNode`?`Node that terminates default camera ingest`:e===`recordingNode`?`Node that owns the recorder (recording-node)`:e===`audioNode`?`Node that runs singleton audio work`:`Runs software (analyzer) motion-watch. Onboard cameras are unaffected.`}function Wn(e,t){switch(t){case`detect`:return e.pipeline}}function Gn(e){return e instanceof Error?e.message:`Failed to save`}function Kn(e){e.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`listAgentSettings`]]}),e.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getAgentSettings`]]}),e.invalidateQueries({queryKey:[[`addonSettings`,`getGlobalSettings`]]})}n();var qn=2e4,Jn=3e5;function Yn(){let{nodes:e}=V(),t=p().trpcClient,n=M(void 0,{placeholderData:l,staleTime:qn,refetchInterval:qn,refetchOnWindowFocus:!0}),i=B(void 0,{staleTime:Jn}),o=a(()=>e.map(e=>e.id),[e]),c=s({queries:o.map(e=>({queryKey:Oe(F.pipelineOrchestrator.getNodeInferenceDevices,{nodeId:e},`query`),queryFn:()=>t.pipelineOrchestrator.getNodeInferenceDevices.query({nodeId:e}),staleTime:Jn,refetchOnWindowFocus:!1,placeholderData:l}))}),u=a(()=>{let e={};return o.forEach((t,n)=>{let r=c[n]?.data;r&&(e[t]=r.devices)}),e},[o,c.map(e=>e.dataUpdatedAt).join(`|`)]),f=a(()=>{let e=new Map;for(let t of i.data??[])e.set(t.nodeId,t.settings);return e},[i.data]),m=a(()=>e.map(e=>{let t=f.get(e.id);return{id:e.id,name:e.name,isOnline:e.isOnline,detectEnabled:Dt(t,e.isHub).pipeline,weight:Bn(t,`detectWeight`)??1,maxCameras:Bn(t,`maxCameras`)}}),[e,f]),h=n.data??[],g=a(()=>An({nodes:m,loads:h,devicesByNode:u}),[m,h,u]),_=g.reduce((e,t)=>e+(t.attachedCameras??0),0),v=g.reduce((e,t)=>e+(t.activeCameras??0),0),y=n.dataUpdatedAt>0?Date.now()-n.dataUpdatedAt:null;return r(`section`,{className:`rounded-md border border-border bg-surface px-3 py-2.5`,children:[r(`div`,{className:`flex flex-wrap items-baseline gap-x-2 gap-y-1 mb-2`,children:[d(`span`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle`,children:`Node load`}),r(`span`,{className:`text-[10px] text-foreground-subtle`,children:[v,` running · `,_,` attached across `,g.length,` `,g.length===1?`node`:`nodes`]}),d(`span`,{className:`ml-auto text-[10px] text-foreground-subtle/70 tabular-nums`,children:n.data===void 0?`reading…`:`reading ${y===null?`—`:`${Math.round(y/1e3)}s`} old · every ${qn/1e3}s`})]}),g.length===0?d(`p`,{className:`text-[11px] italic text-foreground-subtle`,children:`No cluster nodes reported yet.`}):d(`div`,{className:`grid gap-2 @2xl/clustertab:grid-cols-2 @5xl/clustertab:grid-cols-3`,children:g.map(e=>d(Xn,{row:e},e.nodeId))})]})}function Xn({row:e}){let t=e.attachedCameras===null?`—`:`${e.activeCameras??0} / ${e.attachedCameras}${e.maxCameras===null?``:` of ${e.maxCameras}`}`;return r(`div`,{className:`rounded-lg border border-border bg-surface/60 p-2.5 min-w-0`,children:[r(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[d(`span`,{className:`h-1.5 w-1.5 shrink-0 rounded-full ${e.isOnline?`bg-emerald-400`:`bg-foreground-subtle/40`}`}),d(`span`,{className:`truncate text-xs font-medium text-foreground`,title:e.nodeId,children:e.name}),!e.detectEnabled&&d(`span`,{className:`shrink-0 rounded bg-surface-hover px-1 text-[9px] uppercase tracking-wide text-foreground-subtle`,children:`no detect`}),!e.reported&&e.isOnline&&r(`span`,{className:`ml-auto inline-flex shrink-0 items-center gap-1 text-[9px] text-amber-400`,title:`Online, but it did not answer the last load read — its numbers below are unknown, not zero.`,children:[d(pt,{className:`h-2.5 w-2.5`}),` no reading`]}),!e.isOnline&&r(`span`,{className:`ml-auto inline-flex shrink-0 items-center gap-1 text-[9px] text-foreground-subtle`,children:[d(dt,{className:`h-2.5 w-2.5`}),` offline`]})]}),r(`dl`,{className:`mt-1.5 grid grid-cols-2 gap-x-2 gap-y-0.5 text-[10px]`,children:[d(J,{label:`Running / attached`,value:t,title:`Sessions in inference now / cameras attached to this runner (the balancer's committed load) / operator cap.`}),d(J,{label:`Target share`,value:e.weightSharePct===null?`out of play`:`${e.weightSharePct}%`,title:`detectWeight normalised over the nodes the balancer actually ranks (online AND detect-enabled).`}),d(J,{label:`Actual share`,value:e.cameraSharePct===null?`—`:`${e.cameraSharePct}%`,title:`Share of the cluster's attached cameras this node carries right now.`}),d(J,{label:`Score · queue`,value:e.score===null?`—`:`${e.score} · ${e.queueDepthTotal??0}`,title:`The capacity score balance() minimises (attached + queue depth), and the raw queue depth.`}),e.capacityPct!==null&&d(J,{label:`Cap fill`,value:`${e.capacityPct}%`,title:`attached / maxCameras.`}),e.avgInferenceTimeMs!==null&&d(J,{label:`Avg infer`,value:`${Math.round(e.avgInferenceTimeMs)} ms`,title:`Mean inference time across this node's attached cameras.`}),e.decodeHwaccel!==null&&d(J,{label:`Decode`,value:e.decodeHwaccel,title:`This node's probed decode hwaccel.`})]}),d(Zn,{row:e})]})}function Zn({row:e}){return e.devices.length===0?d(`p`,{className:`mt-2 text-[10px] italic text-foreground-subtle`,children:`Accelerators not read yet.`}):r(`div`,{className:`mt-2 border-t border-border pt-1.5`,children:[r(`div`,{className:`flex items-center gap-1 text-[9px] uppercase tracking-wider text-foreground-subtle`,children:[d(nt,{className:`h-2.5 w-2.5`}),`Accelerators`,e.eligibleDeviceCount===0&&d(`span`,{className:`ml-1 normal-case tracking-normal text-amber-400`,title:`No device is a camera-root candidate on this node — sessions run on the runner's default (CPU) pool.`,children:`none in play · runner default pool`})]}),d(`ul`,{className:`mt-1 space-y-0.5`,children:e.devices.map(e=>d(Qn,{device:e},e.key))})]})}function Qn({device:e}){let t=e.exclusion;return r(`li`,{className:`flex items-baseline gap-1.5 text-[10px] min-w-0`,children:[d(W,{className:`h-2.5 w-2.5 shrink-0 ${t===null?`text-foreground-subtle`:`text-foreground-subtle/50`}`}),d(`span`,{className:`shrink-0 font-medium ${t===null?`text-foreground`:`text-foreground-subtle`}`,title:`${e.key} · ${e.format}`,children:e.label}),t===null?r(o,{children:[r(`span`,{className:`shrink-0 tabular-nums text-foreground-subtle`,children:[e.weightSharePct,`% share`]}),r(`span`,{className:`shrink-0 tabular-nums text-foreground-subtle`,children:[`· `,e.sessions,` session`,e.sessions===1?``:`s`,e.maxSessions===null?``:`/${e.maxSessions}`]}),e.queueDepth>0&&r(`span`,{className:`shrink-0 tabular-nums text-amber-400`,children:[`· q`,e.queueDepth]}),e.atCap&&d(`span`,{className:`shrink-0 text-amber-400`,title:`At its maxSessions cap — the balancer skips it until a session ends.`,children:`· at cap`})]}):r(`span`,{className:`truncate text-foreground-subtle/80`,title:Dn[t],children:[`excluded — `,Dn[t]]})]})}function J({label:e,value:t,title:n}){return r(`div`,{className:`min-w-0`,title:n,children:[d(`dt`,{className:`text-[9px] uppercase tracking-wide text-foreground-subtle`,children:e}),d(`dd`,{className:`truncate font-medium tabular-nums text-foreground`,children:t})]})}function $n(){return r(`div`,{className:`space-y-6`,children:[d(fn,{title:`Cluster cameras`}),d(Yn,{}),r(`div`,{className:`min-w-0`,children:[d(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Placement matrix`}),d(`p`,{className:`text-[11px] text-foreground-subtle`,children:`Pipeline · audio assignments per camera (decode always runs co-located with the pipeline). Use the Auto | Pin control to pin a camera to a node, the inference-device select to pin it to an accelerator, or the kebab to move a role; expand the chevron for the per-camera broker drill-down. Cluster load, inference-device weights, and Rebalance live on the Balancer tab.`})]}),d(Lt,{mode:`cluster`})]})}function er({capability:e,label:t,hint:n,nodeId:i,active:a,pending:o,layout:s,onToggle:c}){let l=a?`border-success/30 bg-success/15 text-success hover:bg-success/25`:`border-border bg-surface-hover text-foreground-subtle hover:bg-surface hover:text-foreground`,u=s===`card`?`w-full justify-center px-3 py-2 text-xs`:`px-2.5 py-1 text-[11px]`,f=a?ht:He;return r(`button`,{type:`button`,role:`switch`,"aria-checked":a,"aria-label":`${t} capability for ${i}`,title:`${t} — ${n}`,disabled:o,onClick:()=>c(e,!a),className:`inline-flex items-center gap-1.5 rounded-full border font-medium transition-colors disabled:opacity-50 focus:outline-none focus-visible:ring-2 focus-visible:ring-primary/40 ${l} ${u}`,children:[d(f,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":`true`}),d(`span`,{children:t})]})}function tr({node:e,emphasis:t=!1}){let n=e.isHub?Qe:W;return r(`div`,{className:`flex items-center gap-2.5 min-w-0`,children:[d(`span`,{className:`h-2 w-2 shrink-0 rounded-full ${e.isOnline?`bg-success`:`bg-danger`}`,"aria-hidden":`true`}),d(n,{className:`h-4 w-4 shrink-0 text-foreground-subtle`,"aria-hidden":`true`}),r(`div`,{className:`min-w-0`,children:[r(`div`,{className:`flex items-center gap-1.5 ${t?`text-sm`:`text-xs`} font-semibold text-foreground`,children:[d(`span`,{className:`truncate`,children:e.name}),e.isHub&&d(D,{variant:`info`,className:`px-1.5 py-0 text-[9px] uppercase tracking-wider`,children:`hub`}),!e.isOnline&&d(D,{variant:`danger`,className:`px-1.5 py-0 text-[9px] uppercase tracking-wider`,children:`offline`})]}),d(`div`,{className:`font-mono text-[10px] text-foreground-subtle truncate`,children:e.id})]})]})}n();function nr({nodeId:e,value:t,detectedHosts:n,status:i,errorMessage:a,onCommit:o}){let[s,c]=u(t??``);f(()=>{c(t??``)},[t]);let l=n[0],p=l===void 0?`auto-detect`:`auto: ${l}`,m=i===`pending`,h=s.trim(),g=h!==(t??``),_=g&&!m,v=()=>{_&&o(e,h.length>0?h:null)};return r(`div`,{className:`flex items-center gap-1.5`,children:[d(`input`,{"aria-label":`Reachable host for ${e}`,type:`text`,inputMode:`url`,autoComplete:`off`,spellCheck:!1,placeholder:p,value:s,disabled:m,onChange:e=>c(e.target.value),onBlur:v,onKeyDown:e=>{e.key===`Enter`&&v(),e.key===`Escape`&&c(t??``)},className:`w-40 rounded-md border border-border bg-background px-2.5 py-1.5 text-sm text-foreground placeholder:text-foreground-subtle focus:border-primary focus:outline-none disabled:opacity-50`}),r(`button`,{type:`button`,onClick:v,disabled:!_,"aria-label":`Save reachable host for ${e}`,title:`Save reachable host`,className:`inline-flex shrink-0 items-center gap-1 rounded-md px-2 py-1.5 text-[11px] font-medium bg-primary text-white hover:bg-primary/90 disabled:opacity-40 disabled:cursor-not-allowed`,children:[m?d(U,{className:`h-3 w-3 animate-spin`,"aria-hidden":`true`}):d(ht,{className:`h-3 w-3`,"aria-hidden":`true`}),`Save`]}),!g&&!m&&i===`success`&&d(ht,{className:`h-3.5 w-3.5 shrink-0 text-emerald-400`,"aria-label":`Saved`,role:`img`}),i===`error`&&d(`span`,{title:a??`Failed to save reachable host`,children:d(it,{className:`h-3.5 w-3.5 shrink-0 text-red-400`,"aria-label":a??`Failed to save reachable host`,role:`img`})})]})}function rr({label:e,children:t}){return r(`div`,{className:`flex items-center justify-between gap-3`,children:[d(`span`,{className:`text-[11px] font-medium uppercase tracking-wide text-foreground-subtle`,children:e}),t]})}function ir({node:e,actions:t}){return r(`div`,{className:`rounded-xl border border-border bg-background p-4 space-y-4 ${e.isOnline?``:`opacity-60`}`,children:[d(tr,{node:e,emphasis:!0}),d(`div`,{className:`grid grid-cols-2 gap-2`,children:Fn.map(n=>d(er,{capability:n.key,label:n.label,hint:n.hint,nodeId:e.id,active:Wn(e.effective,n.key),pending:t.capabilityPending,layout:`card`,onToggle:(n,r)=>t.onToggleCapability(e.id,n,r)},n.key))}),d(`div`,{className:`space-y-3 border-t border-border pt-3`,children:d(rr,{label:`Reachable host`,children:d(nr,{nodeId:e.id,value:e.reachableHost,detectedHosts:e.detectedHosts,status:t.reachableHostStatus(e.id),errorMessage:t.reachableHostErrorMessage(e.id),onCommit:t.onCommitReachableHost})})})]})}function ar(){return r(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1.5 text-[10px] text-foreground-subtle`,children:[r(`span`,{className:`inline-flex items-center gap-1.5`,children:[d(`span`,{className:`h-2.5 w-2.5 rounded-full border border-success/30 bg-success/15`}),`Active capability`]}),r(`span`,{className:`inline-flex items-center gap-1.5`,children:[d(`span`,{className:`h-2.5 w-2.5 rounded-full border border-border bg-surface-hover`}),`Idle`]}),r(`span`,{className:`inline-flex items-center gap-1.5`,children:[d(`span`,{className:`h-2 w-2 rounded-full bg-success`}),`Node online`]}),r(`span`,{className:`inline-flex items-center gap-1.5`,children:[d(`span`,{className:`h-2 w-2 rounded-full bg-danger`}),`Node offline`]})]})}function or({nodes:e,actions:t}){return d(`div`,{className:`overflow-x-auto rounded-lg border border-border`,children:r(`table`,{className:`w-full min-w-[720px] border-collapse text-sm`,children:[d(`thead`,{children:r(`tr`,{className:`border-b border-border bg-background text-[10px] uppercase tracking-wider text-foreground-subtle`,children:[d(`th`,{className:`px-4 py-3 text-left font-semibold`,children:`Node`}),Fn.map(e=>d(`th`,{className:`px-3 py-3 text-center font-semibold`,children:e.label},e.key)),d(`th`,{className:`px-4 py-3 text-left font-semibold`,children:`Reachable host`})]})}),d(`tbody`,{children:e.map(e=>r(`tr`,{className:`border-b border-border last:border-b-0 transition-colors hover:bg-surface-hover/40 ${e.isOnline?``:`opacity-60`}`,children:[d(`td`,{className:`px-4 py-3 align-middle`,children:d(tr,{node:e})}),Fn.map(n=>d(`td`,{className:`px-3 py-3 text-center align-middle`,children:d(er,{capability:n.key,label:n.label,hint:n.hint,nodeId:e.id,active:Wn(e.effective,n.key),pending:t.capabilityPending,layout:`cell`,onToggle:(n,r)=>t.onToggleCapability(e.id,n,r)})},n.key)),d(`td`,{className:`px-4 py-3 align-middle`,children:d(nr,{nodeId:e.id,value:e.reachableHost,detectedHosts:e.detectedHosts,status:t.reachableHostStatus(e.id),errorMessage:t.reachableHostErrorMessage(e.id),onCommit:t.onCommitReachableHost})})]},e.id))})]})})}function sr({role:e,value:t,options:n,pending:i,onChange:a}){return r(`label`,{className:`flex flex-col gap-1.5 rounded-lg border border-border bg-background p-3`,children:[d(`span`,{className:`text-xs font-semibold text-foreground`,children:Hn(e)}),d(`select`,{value:t,disabled:i,onChange:t=>a(e,t.target.value),className:`rounded-md border border-border bg-surface px-2.5 py-1.5 text-sm text-foreground focus:border-primary focus:outline-none disabled:opacity-50`,children:n.map(e=>d(`option`,{value:e,children:e===`hub`?`hub (default)`:e},e))}),d(`span`,{className:`text-[10px] leading-tight text-foreground-subtle`,children:Un(e)})]})}function cr({roleValues:e,options:t,pending:n,lowFpsEnabled:i,fpsMinThreshold:a,onRoleChange:o,onLowFpsToggle:s}){return r(`div`,{className:`grid gap-3 @lg/clustertab:grid-cols-2 @3xl/clustertab:grid-cols-4`,children:[Pn.map(r=>d(sr,{role:r,value:e[r],options:t,pending:n,onChange:o},r)),r(`label`,{className:`flex items-start gap-2.5 rounded-lg border border-border bg-background p-3 text-sm text-foreground`,children:[d(`input`,{type:`checkbox`,checked:i,disabled:n,onChange:e=>s(e.target.checked),className:`mt-0.5 h-4 w-4 shrink-0 accent-primary`}),r(`span`,{className:`flex flex-col gap-0.5`,children:[d(`span`,{className:`text-xs font-semibold`,children:`Low-fps relocate/shed`}),r(`span`,{className:`text-[10px] leading-tight text-foreground-subtle`,children:[`fpsMinThreshold `,i?`${a} fps`:`disabled`]})]})]})]})}n();function lr(){let e=c(),{nodes:t}=V(),n=B(void 0),i=de({addonId:jn}),s=de({addonId:Mn}),l=()=>Kn(e),f=ie({onSuccess:l}),p=oe(),m=h({onSuccess:l}),g=we({onSuccess:l}),[_,v]=u(!1),y=a(()=>{let e=new Map;for(let t of n.data??[])e.set(t.nodeId,t.settings);return e},[n.data]),b=a(()=>t.map(e=>{let t=y.get(e.id),n=Dt(t,e.isHub),r=Bn(t,`detectWeight`);return{id:e.id,name:e.name,isHub:e.isHub,isOnline:e.isOnline,settings:t,effective:n,weight:r??1,maxCameras:Bn(t,`maxCameras`),reachableHost:Vn(t,`reachableHost`),detectedHosts:e.localIps}}),[t,y]),x=b.filter(e=>e.effective.pipeline),S={ingestNode:Rn(i.data,`ingestNode`,`hub`),recordingNode:Rn(s.data,Nn,`hub`),audioNode:Rn(i.data,`audioNode`,`hub`),motionNode:Rn(i.data,`motionNode`,`hub`)},C=a(()=>{let e=t.filter(e=>e.isOnline).map(e=>e.id);return[...new Set([`hub`,...Pn.map(e=>S[e]),...e])].filter(e=>e.length>0)},[t,S]),w=zn(i.data,`fpsMinThreshold`,0),T=w>0,E=n.isLoading||i.isLoading||s.isLoading,D=(e,t,n)=>{f.mutate({agentNodeId:e,[t]:n})},O=(e,t)=>{if(e===`recordingNode`){g.mutate({addonId:Mn,patch:{[Nn]:t}});return}g.mutate({addonId:jn,patch:{[e]:t}})},k=e=>{g.mutate({addonId:jn,patch:{fpsMinThreshold:e?Math.max(1,w):0}})},A=e=>m.variables?.agentNodeId===e?m.isPending?`pending`:m.isError?`error`:m.isSuccess?`success`:`idle`:`idle`,j=e=>A(e)===`error`?Gn(m.error):null,M=async e=>{v(!0);try{for(let t of e)await p.mutateAsync({agentNodeId:t.nodeId,detectWeight:t.weight})}finally{v(!1),l()}},N={capabilityPending:f.isPending,onToggleCapability:D,onCommitReachableHost:(e,t)=>m.mutate({agentNodeId:e,reachableHost:t}),reachableHostStatus:A,reachableHostErrorMessage:j};return r(`section`,{className:`rounded-xl border border-border bg-surface p-5 @3xl/clustertab:p-6 space-y-6`,children:[r(`header`,{className:`flex items-start justify-between gap-4`,children:[r(`div`,{className:`space-y-1`,children:[d(`h3`,{className:`text-base font-semibold text-foreground`,children:`Pipeline placement`}),d(`p`,{className:`max-w-prose text-xs leading-relaxed text-foreground-subtle`,children:`Toggle which node runs each pipeline capability, distribute detection weight across detect-capable nodes, and choose the singleton cluster roles.`})]}),E&&d(U,{className:`h-5 w-5 shrink-0 animate-spin text-foreground-subtle`,"aria-label":`Loading`})]}),r(`div`,{className:`space-y-3`,children:[d(`h4`,{className:`text-xs font-semibold uppercase tracking-wide text-foreground-subtle`,children:`Singleton cluster roles`}),d(cr,{roleValues:S,options:C,pending:g.isPending,lowFpsEnabled:T,fpsMinThreshold:w,onRoleChange:O,onLowFpsToggle:k})]}),r(`div`,{className:`space-y-3`,children:[r(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[d(`h4`,{className:`text-xs font-semibold uppercase tracking-wide text-foreground-subtle`,children:`Per-node capabilities`}),d(ar,{})]}),b.length===0?d(`p`,{className:`rounded-lg border border-dashed border-border bg-background px-4 py-6 text-center text-xs text-foreground-subtle`,children:`No cluster nodes reporting yet.`}):r(o,{children:[d(`div`,{className:`grid gap-4 @xl/clustertab:grid-cols-2 @3xl/clustertab:hidden`,children:b.map(e=>d(ir,{node:e,actions:N},e.id))}),d(`div`,{className:`hidden @3xl/clustertab:block`,children:d(or,{nodes:b,actions:N})})]})]}),r(`div`,{className:`space-y-3`,children:[d(`h4`,{className:`text-xs font-semibold uppercase tracking-wide text-foreground-subtle`,children:`Detection weight`}),d(Be,{nodes:x,pending:_,onCommitWeights:e=>void M(e)})]}),r(`div`,{className:`space-y-3`,children:[d(`h4`,{className:`text-xs font-semibold uppercase tracking-wide text-foreground-subtle`,children:`Inference devices`}),x.length===0?d(`p`,{className:`rounded-lg border border-dashed border-border bg-background px-4 py-6 text-center text-xs text-foreground-subtle`,children:`No detect-capable nodes — enable detection on a node above to configure its accelerators.`}):d(`div`,{className:`space-y-2`,children:x.map(e=>d(Ve,{nodeId:e.id,nodeName:e.name,isOnline:e.isOnline},e.id))})]})]})}n();var ur=!1;function dr({refreshToken:e}){let t=c(),{data:n}=se(void 0);a(()=>vt(n??[]),[n]);let i=j({onSuccess:()=>{t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineAssignments`]]}),t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getAudioAssignments`]]})}});return r(`div`,{className:`space-y-6`,children:[d(jt,{refreshToken:e}),d(lr,{}),ur,r(`div`,{className:`flex flex-col gap-3 @md/clustertab:flex-row @md/clustertab:items-center @md/clustertab:justify-between`,children:[r(`div`,{className:`min-w-0`,children:[d(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Rebalance`}),d(`p`,{className:`text-[11px] text-foreground-subtle`,children:`Recompute the optimal node for every assigned camera from current load + hardware affinity, and migrate the ones no longer on their best node. Pinned cameras never move.`})]}),r(`button`,{type:`button`,onClick:()=>i.mutate(void 0),disabled:i.isPending,className:`inline-flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-white hover:bg-primary/90 disabled:opacity-50 shrink-0 self-start @md/clustertab:self-auto whitespace-nowrap`,children:[d(tt,{className:`h-3.5 w-3.5`}),i.isPending?`Rebalancing…`:`Rebalance pipelines`]})]})]})}var fr=[`pipeline-orchestrator`];function pr({refreshToken:e}){return d(`div`,{className:`space-y-4 max-w-3xl`,children:d(bt,{nodeId:`hub`,addonIds:fr,level:`global`,title:`Cluster settings`,description:`Cluster-wide orchestration knobs: enabled nodes, load balancer thresholds, and failover policy. Per-camera pipelines live in Device Overrides; live cluster load is on the Assignments tab.`})})}n();function mr({refreshToken:e}){let t=c(),{data:n,isLoading:i}=C(),[a,s]=u(null),[l,f]=u(``),[p,m]=u(``),h=()=>{t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`listTemplates`]]})},g=Se({onSuccess:()=>{s(null),h()}}),_=ge({onSuccess:h}),v=e=>{s(e.id),f(e.name),m(e.description??``)},y=()=>{s(null),f(``),m(``)},b=()=>{if(!a)return;let e=p.trim();g.mutate({id:a,name:l.trim()||`Untitled`,...e?{description:e}:{}})};if(i)return d(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:`Loading templates…`});let x=[...n??[]].toSorted((e,t)=>e.name.localeCompare(t.name));return d(`div`,{className:`space-y-6 max-w-4xl`,children:r(`section`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[r(`div`,{className:`border-b border-border px-4 py-3 flex items-center justify-between`,children:[r(`div`,{children:[d(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Templates`}),d(`p`,{className:`text-[11px] text-foreground-subtle mt-0.5`,children:`Curated pipeline presets operators can apply to any camera. Apply-time is a copy — future edits to a template don't retroactively change cameras that were seeded from it. Save a template from the device Pipeline tab.`})]}),r(`div`,{className:`text-[11px] text-foreground-subtle`,children:[x.length,` template`,x.length===1?``:`s`]})]}),x.length===0?r(`div`,{className:`px-4 py-8 text-xs text-foreground-subtle flex flex-col items-center gap-2`,children:[d(Je,{className:`h-6 w-6 opacity-40`}),d(`div`,{children:`No templates yet. Create one from a device Pipeline tab ("Save as template").`})]}):d(`ul`,{className:`divide-y divide-border`,children:x.map(e=>{let t=a===e.id;return d(`li`,{className:`px-4 py-3 text-xs`,children:r(`div`,{className:`flex items-start gap-3`,children:[d(`div`,{className:`flex-1 min-w-0`,children:t?r(`div`,{className:`space-y-2`,children:[d(`input`,{className:`w-full rounded border border-border bg-surface-hover px-2 py-1 text-xs text-foreground focus:outline-none focus:border-primary`,value:l,onChange:e=>f(e.target.value),placeholder:`Template name`,autoFocus:!0}),d(`input`,{className:`w-full rounded border border-border bg-surface-hover px-2 py-1 text-[11px] text-foreground focus:outline-none focus:border-primary`,value:p,onChange:e=>m(e.target.value),placeholder:`Description (optional)`})]}):r(o,{children:[d(`div`,{className:`font-medium text-foreground`,children:e.name}),e.description&&d(`div`,{className:`text-foreground-subtle mt-0.5`,children:e.description}),r(`div`,{className:`mt-1 font-mono text-[10px] text-foreground-subtle`,children:[e.config.steps.length,` step(s)`,e.config.audio?.enabled?` · audio`:``,r(`span`,{className:`ml-2`,children:[`updated `,new Date(e.updatedAt).toLocaleString()]})]})]})}),d(`div`,{className:`flex items-center gap-1 shrink-0`,children:t?r(o,{children:[r(`button`,{type:`button`,onClick:b,disabled:g.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[11px] font-medium bg-primary text-white hover:bg-primary/90 disabled:opacity-50`,children:[d(ht,{className:`h-3 w-3`}),`Save`]}),r(`button`,{type:`button`,onClick:y,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[11px] text-foreground-subtle hover:bg-surface-hover`,children:[d(ft,{className:`h-3 w-3`}),`Cancel`]})]}):r(o,{children:[d(`button`,{type:`button`,onClick:()=>v(e),title:`Rename`,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[11px] text-foreground-subtle hover:text-foreground hover:bg-surface-hover`,children:d(qe,{className:`h-3 w-3`})}),d(`button`,{type:`button`,onClick:()=>{confirm(`Delete template "${e.name}"?`)&&_.mutate({id:e.id})},disabled:_.isPending,title:`Delete`,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[11px] text-foreground-subtle hover:text-red-400 hover:bg-surface-hover disabled:opacity-50`,children:d(mt,{className:`h-3 w-3`})})]})})]})},e.id)})})]})})}var hr=`pipeline-orchestrator`,gr=200;function _r(){return r(`div`,{className:`flex flex-col gap-3`,children:[r(`div`,{children:[d(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Orchestrator logs`}),d(`p`,{className:`text-[11px] text-foreground-subtle`,children:`Dispatch decisions, balancer moves and failover events from the pipeline orchestrator. Streaming live; the device chip on a line tells which camera it refers to.`})]}),d(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:d(O,{addonId:hr,limit:gr,maxHeight:`max-h-[calc(100vh-360px)]`,showScope:!0,showDeviceChip:!0,showFilters:!1})})]})}n();var vr=[{id:`assignments`,label:`Assignments`},{id:`balancer`,label:`Balancer`},{id:`settings`,label:`Settings`},{id:`templates`,label:`Templates`},{id:`logs`,label:`Logs`}];function yr({refreshToken:e}){let[t,n]=u(`assignments`);return r(`div`,{className:`flex flex-col h-full`,children:[r(`div`,{className:`px-4 sm:px-6 py-4 border-b border-border`,children:[d(`h2`,{className:`text-base font-semibold text-foreground`,children:`Cluster Orchestration`}),d(`div`,{className:`text-[11px] text-foreground-subtle mt-1`,children:`Per-camera assignments, the load balancer (live load + inference-device weights), cluster-wide settings, and the pipeline template library.`})]}),d(`div`,{className:`flex items-center gap-1 px-4 sm:px-6 border-b border-border overflow-x-auto`,children:vr.map(e=>d(`button`,{type:`button`,onClick:()=>n(e.id),className:`shrink-0 whitespace-nowrap px-3 py-2 text-xs font-medium border-b-2 transition-colors ${t===e.id?`border-primary text-primary`:`border-transparent text-foreground-subtle hover:text-foreground`}`,children:e.label},e.id))}),r(`div`,{className:`flex-1 min-h-0 overflow-y-auto p-4 sm:p-6 @container/clustertab`,children:[t===`assignments`&&d($n,{}),t===`balancer`&&d(dr,{refreshToken:e}),t===`settings`&&d(pr,{refreshToken:e}),t===`templates`&&d(mr,{refreshToken:e}),t===`logs`&&d(_r,{})]})]})}var br=`armed:`;function xr(e){return e.assignment.reasons.detection?.startsWith(br)===!0}function Sr(e){let{assignment:t,detection:n}=e;return n!==null&&n.provisioning.state===`failed`||t.detectionNodeId===null&&n===null&&!xr(e)?`error`:n!==null&&n.phase===`active`?`healthy`:`idle`}function Cr(e){let t=[],n=[],{assignment:r,detection:i,decoder:a,broker:o}=e;i!==null&&i.provisioning.state===`failed`&&t.push({code:`provisioning-failed`,severity:`error`,message:i.provisioning.error!==void 0&&i.provisioning.error.length>0?`Engine provisioning failed: ${i.provisioning.error}`:`Engine provisioning failed on the detection node`}),i!==null&&i.phase===`active`&&i.actualFps===0&&t.push({code:`detection-black-hole`,severity:`error`,message:`Detection phase is ACTIVE but 0 fps are being processed — frames are not reaching the detector (cross-node black-hole signature)`}),i!==null&&i.phase===`active`&&a!==null&&a.shm.framesWritten===0&&t.push({code:`decoder-black-hole`,severity:`error`,message:`Decoder on ${a.nodeId} has written 0 frames to the shared-memory plane while detection is active — the decode path is stalled`}),r.detectionNodeId===null&&i===null&&!xr(e)&&n.push({code:`unassigned`,severity:`warning`,message:`Not placed on any detection node — no pipeline is running for this camera`});let s=e.degraded??[];if(s.length>0){let e=[...new Set(s.map(e=>e.stage))].join(`, `);n.push({code:`status-unreadable`,severity:`warning`,message:`Could not read ${e} for this camera — those blocks are unknown, not empty (a switch read that failed does NOT mean nothing is switched off)`})}for(let e of o?.profiles??[])e.status===`streaming`&&e.inFps===0&&n.push({code:`broker-stalled`,severity:`warning`,message:`Broker profile "${e.profile}" reports streaming but 0 in-fps — the source pull may be stalled`});return[...t,...n]}function wr(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Y(e){return typeof e==`string`&&e.length>0?e:null}function Tr(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function Er(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function Dr(e,t){return e==null?!1:JSON.stringify(e)!==JSON.stringify(t??null)}var Or={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 kr(e){if(!wr(e)||!Array.isArray(e.sections))return Or;let t=ke(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)Dr(n.value,n.default)&&r.add(e);return{detectionMode:Y(n(`detectionMode`)),detectionStreamProfile:Y(n(`detectionStreamProfile`)),detectionFps:Tr(n(`detectionFps`)),motionSources:Er(n(`motionSources`)),motionFps:Tr(n(`motionFps`)),motionCooldownMs:Tr(n(`motionCooldownMs`)),motionStreamProfile:Y(n(`motionStreamProfile`)),audioMode:Y(n(`audioMode`)),pipelineNodeId:Y(n(`pipelineNodeId`)),decoderNodeId:Y(n(`decoderNodeId`)),audioNodeId:Y(n(`audioNodeId`)),overriddenKeys:r}}function Ar(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(...Ar(r.children,t+1));return n}function X({title:e,children:t}){return r(`div`,{className:`bg-background px-3.5 py-3 min-w-0`,children:[d(`div`,{className:`text-[9px] font-semibold uppercase tracking-[0.14em] text-foreground-subtle mb-2`,children:e}),d(`div`,{className:`flex flex-col gap-1 min-w-0`,children:t})]})}function Z({label:e,children:t,overridden:n=!1}){return r(`div`,{className:`flex items-baseline gap-2 text-[11px] leading-snug min-w-0`,children:[d(`span`,{className:`text-foreground-subtle shrink-0 w-24 truncate`,title:e,children:e}),d(`span`,{className:`font-mono tabular-nums text-foreground min-w-0 truncate flex-1`,children:t}),n&&d(jr,{})]})}function jr(){return d(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full bg-warning shrink-0 self-center`,title:`Device-level override active`,"aria-label":`Device-level override active`,role:`img`})}var Mr={neutral:`border-border text-foreground-muted`,success:`border-success/40 text-success`,warning:`border-warning/40 text-warning`,danger:`border-danger/40 text-danger`,info:`border-info/40 text-info`};function Q({tone:e=`neutral`,children:t,title:n}){return d(`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 ${Mr[e]}`,children:t})}function $({children:e}){return d(`div`,{className:`text-[11px] text-foreground-subtle italic`,children:e})}function Nr({icon:e,label:t,nodeId:n,pinned:i,reason:a,overridden:s}){return r(`div`,{className:`flex items-center gap-2 text-[11px] leading-snug min-w-0`,children:[d(e,{className:`h-3 w-3 text-foreground-subtle shrink-0`}),d(`span`,{className:`text-foreground-subtle w-[4.5rem] shrink-0`,children:t}),n===null?d(`span`,{className:`text-foreground-subtle italic`,children:`unassigned`}):r(o,{children:[d(`span`,{className:`font-mono text-foreground truncate`,title:n,children:n}),i?r(`span`,{className:`inline-flex items-center gap-0.5 text-[10px] text-warning shrink-0`,title:`Manually pinned`,children:[d(Ct,{className:`h-2.5 w-2.5`}),` manual`]}):r(`span`,{className:`text-[10px] text-foreground-subtle shrink-0 truncate`,children:[`auto · `,a!==void 0&&a.length>0?a:`capacity`]}),s&&d(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full bg-warning shrink-0`,title:`Persisted settings pin for this role`})]})]})}function Pr({assignment:e,settings:t,onlineNodes:n,pinPending:i,onDetectionPinChange:a}){let o=e.pinned.detection&&e.detectionNodeId!==null?e.detectionNodeId:`auto`,s=[...new Set([...e.detectionNodeId===null?[]:[e.detectionNodeId],...n.map(e=>e.id)])];return r(X,{title:`Where it runs`,children:[d(Nr,{icon:W,label:`Detection`,nodeId:e.detectionNodeId,pinned:e.pinned.detection,reason:e.reasons.detection,overridden:t.overriddenKeys.has(`pipelineNodeId`)}),d(Nr,{icon:st,label:`Decoder`,nodeId:e.decoderNodeId,pinned:e.pinned.decoder,reason:e.reasons.decoder,overridden:t.overriddenKeys.has(`decoderNodeId`)}),d(Nr,{icon:Ge,label:`Audio`,nodeId:e.audioNodeId,pinned:e.pinned.audio,reason:e.reasons.audio,overridden:t.overriddenKeys.has(`audioNodeId`)}),d(Nr,{icon:Ye,label:`Source`,nodeId:e.sourceNodeId,pinned:!1,reason:`ingest owner`,overridden:!1}),d(`div`,{className:`mt-1.5`,children:r(`select`,{value:o,disabled:i,"aria-label":`Detection placement pin`,onChange:e=>a(e.target.value),className:`w-full min-w-0 rounded-md border border-border bg-background px-2 py-1 text-[11px] text-foreground disabled:opacity-50`,children:[d(`option`,{value:`auto`,children:`Auto (load balanced)`}),s.map(e=>r(`option`,{value:e,children:[`Pin detection → `,n.find(t=>t.id===e)?.name??e]},e))]})})]})}function Fr(e){return`${e.width}×${e.height} ${e.codec} @${e.fps}fps`}function Ir(e,t){if(!(t===null||e===void 0))return e.find(e=>e.profile===t)}function Lr(e){return e===null?`default`:e===0?`native (no throttle)`:`${e} fps`}function Rr({streams:e,brokerProfiles:t,settings:n,motionEnabled:i,motionFpsLive:a}){let s=Ir(t,n.detectionStreamProfile),c=Ir(t,n.motionStreamProfile),l=n.motionSources.includes(`analyzer`);return r(X,{title:`Streams & motion`,children:[r(Z,{label:`Detect stream`,overridden:n.overriddenKeys.has(`detectionStreamProfile`),children:[n.detectionStreamProfile??`—`,s!==void 0&&` · ${s.width}×${s.height} ${s.codec}`]}),d(Z,{label:`Detect FPS`,overridden:n.overriddenKeys.has(`detectionFps`),children:Lr(n.detectionFps)}),r(Z,{label:`Motion src`,overridden:n.overriddenKeys.has(`motionSources`),children:[n.motionSources.length>0?n.motionSources.join(` + `):`none`,i===!1&&` · inactive`]}),l&&r(o,{children:[r(Z,{label:`Motion stream`,overridden:n.overriddenKeys.has(`motionStreamProfile`),children:[n.motionStreamProfile??`—`,c!==void 0&&` · ${c.width}×${c.height} ${c.codec}`]}),r(Z,{label:`Motion FPS`,overridden:n.overriddenKeys.has(`motionFps`),children:[Lr(n.motionFps),a!==null&&` · live ${a.toFixed(1)}`]})]}),d(Z,{label:`Cooldown`,overridden:n.overriddenKeys.has(`motionCooldownMs`),children:n.motionCooldownMs===null?`default`:`${n.motionCooldownMs/1e3}s`}),d(`div`,{className:`mt-1.5 flex flex-col gap-0.5`,children:e.length===0?d($,{children:`No streams registered`}):e.map(e=>r(`div`,{className:`text-[10px] font-mono text-foreground-subtle truncate`,title:e.camStreamId,children:[d(`span`,{className:`text-foreground-muted`,children:e.kind}),` `,Fr(e)]},e.camStreamId))})]})}function zr({steps:e,audioModelId:t,audioEnabled:n,audioMode:i}){return r(X,{title:`Pipeline steps`,children:[e===void 0?d($,{children:`Resolving…`}):e.length===0?d($,{children:`No steps configured`}):d(`div`,{className:`flex flex-wrap gap-1`,children:e.map((e,t)=>d(Q,{tone:e.enabled&&e.depth===0?`info`:`neutral`,title:e.modelId??e.addonId,children:r(`span`,{className:e.enabled?``:`line-through opacity-60`,children:[e.depth>0&&d(`span`,{className:`opacity-50`,children:`↳ `}),e.addonId,e.modelId!==null&&r(`span`,{className:`font-mono opacity-75`,children:[` · `,e.modelId]})]})},`${e.addonId}-${t}`))}),d(`div`,{className:`mt-1`,children:r(Z,{label:`Audio class.`,children:[i??`—`,n!==null&&(n?` · running`:` · off`),t!==null&&` · ${t}`]})})]})}var Br={ready:`success`,installing:`info`,verifying:`info`,idle:`neutral`,failed:`danger`};function Vr({detection:e,live:t,detectionMode:n,modeOverridden:i}){if(e===null)return r(X,{title:`Detection runtime`,children:[d(Z,{label:`Mode`,overridden:i,children:n??`—`}),d($,{children:`Detection stage inactive or unreachable`})]});let a=t?.phase??e.phase,o=t?.actualFps??e.actualFps,s=t?.configuredFps??e.configuredFps,c=t?.avgInferenceTimeMs??e.avgInferenceMs,l=t?.queueDepth??e.queueDepth,u=m(a),f=a===`active`&&o===0;return r(X,{title:`Detection runtime`,children:[r(`div`,{className:`flex items-center gap-1.5 mb-0.5`,children:[r(`span`,{className:`inline-flex items-center gap-1 rounded border px-1.5 py-px text-[10px] font-semibold uppercase tracking-wider ${u.badgeClass}`,children:[d(fe,{phase:a,className:`h-2.5 w-2.5`}),u.label]}),t!==void 0&&d(`span`,{className:`text-[9px] text-foreground-subtle uppercase tracking-wider`,children:`live`})]}),d(Z,{label:`Mode`,overridden:i,children:n??`—`}),r(Z,{label:`FPS`,children:[d(`span`,{className:f?`text-danger font-semibold`:``,children:o.toFixed(1)}),r(`span`,{className:`text-foreground-subtle`,children:[` / `,s.toFixed(0),` configured`]})]}),r(Z,{label:`Inference`,children:[c.toFixed(0),` ms`,l>0&&r(`span`,{className:`text-warning`,children:[` · queue `,l]}),t!==void 0&&t.droppedFrames>0&&r(`span`,{className:`text-warning`,children:[` · drops `,t.droppedFrames]})]}),r(Z,{label:`Engine`,children:[e.engine.backend,` · `,e.engine.device]}),r(Z,{label:`Provisioning`,children:[d(Q,{tone:Br[e.provisioning.state]??`neutral`,children:e.provisioning.state}),e.provisioning.error!==void 0&&r(`span`,{className:`text-danger text-[10px]`,children:[` `,e.provisioning.error]})]})]})}function Hr({broker:e}){return e===null?d(X,{title:`Stream broker`,children:d($,{children:`Broker stage inactive or unreachable`})}):r(X,{title:`Stream broker`,children:[e.profiles.length===0?d($,{children:`No broker profiles`}):d(`div`,{className:`flex flex-col gap-1`,children:e.profiles.map(e=>{let t=e.status===`streaming`,n=t&&e.inFps===0;return r(`div`,{className:`flex items-center gap-2 text-[11px] font-mono tabular-nums min-w-0`,children:[d(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full shrink-0 ${n?`bg-danger`:t?`bg-success animate-pulse`:`bg-border`}`,title:e.status}),d(`span`,{className:`text-foreground w-10 shrink-0 truncate`,title:e.profile,children:e.profile}),r(`span`,{className:`text-foreground-subtle truncate`,children:[e.width,`×`,e.height,` `,e.codec]}),r(`span`,{className:`ml-auto shrink-0 ${n?`text-danger`:`text-foreground`}`,children:[e.inFps.toFixed(0),`→`,e.outFps.toFixed(0),`fps`]}),r(`span`,{className:`text-foreground-subtle shrink-0`,title:`Subscribers`,children:[`×`,e.subscribers]})]},e.profile)})}),r(`div`,{className:`mt-1.5 flex flex-wrap gap-1`,children:[r(Q,{tone:e.webrtcSessions>0?`info`:`neutral`,children:[`WebRTC `,e.webrtcSessions]}),r(Q,{tone:e.rtspRestream?`success`:`neutral`,children:[`restream `,e.rtspRestream?`on`:`off`]})]})]})}function Ur({decoder:e,detectionActive:t}){if(e===null)return d(X,{title:`Decoder`,children:d($,{children:`Decoder stage inactive or unreachable`})});let n=t&&e.shm.framesWritten===0;return r(X,{title:`Decoder`,children:[d(Z,{label:`Node`,children:e.nodeId}),d(Z,{label:`Sessions`,children:e.sessionCount}),r(Z,{label:`SHM frames`,children:[d(`span`,{className:n?`text-danger font-semibold`:``,children:e.shm.framesWritten}),d(`span`,{className:`text-foreground-subtle`,children:` written`})]}),r(Z,{label:`SHM reads`,children:[e.shm.getFrameHits,` hits`,e.shm.getFrameMisses>0&&r(`span`,{className:`text-warning`,children:[` · `,e.shm.getFrameMisses,` misses`]})]}),r(Z,{label:`SHM budget`,children:[e.shm.budgetMb,` MB`]}),e.formats.length>0&&d(Z,{label:`Formats`,children:e.formats.join(`, `)})]})}n();var Wr=`pipeline-orchestrator`,Gr={healthy:`bg-success`,idle:`bg-warning`,error:`bg-danger`},Kr={healthy:`Healthy`,idle:`Idle`,error:`Error`};function qr({problems:e}){return d(`div`,{role:`alert`,className:`flex flex-col border-b border-border`,children:e.map(e=>r(`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:[d(pt,{className:`h-3.5 w-3.5 shrink-0 mt-px`}),d(`span`,{className:`min-w-0`,children:e.message})]},e.code))})}function Jr({deviceId:e,name:t,online:n,status:i,live:o,onlineNodes:s}){let l=c(),{data:u}=pe({addonId:Wr,deviceId:e,nodeId:`hub`},{staleTime:3e4}),{data:f}=ae({deviceId:e},{staleTime:3e4}),p=a(()=>kr(u),[u]),m=a(()=>f===void 0?void 0:Ar(f.steps),[f]),h=a(()=>i===void 0?[]:Cr(i),[i]),_=()=>{l.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCameraStatuses`]]}),l.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineAssignments`]]})},v=g({onSuccess:_}),y=xe({onSuccess:_}),b=t=>{t===`auto`?y.mutate({deviceId:e}):v.mutate({deviceId:e,agentNodeId:t})},x=i===void 0?`idle`:Sr(i),S=h.some(e=>e.severity===`error`),C=h.length>0,w=S?`border-danger/50`:C?`border-warning/40`:`border-border`;return r(`article`,{"aria-label":`${t} pipeline status`,className:`rounded-lg border ${w} bg-background overflow-hidden`,children:[r(`header`,{className:`flex items-center gap-2.5 px-4 py-2.5 border-b border-border bg-surface/50 min-w-0`,children:[d(`span`,{className:`inline-block h-2 w-2 rounded-full shrink-0 ${S?`bg-danger`:Gr[x]}`,title:S?`Error`:Kr[x],"aria-label":S?`Error`:Kr[x],role:`img`}),d(`h3`,{className:`text-[13px] font-semibold text-foreground truncate`,title:t,children:t}),r(`span`,{className:`text-[10px] text-foreground-subtle shrink-0`,children:[`#`,e]}),!n&&d(Q,{tone:`danger`,children:`offline`}),r(`span`,{className:`ml-auto flex items-center gap-1.5 shrink-0`,children:[p.detectionMode!==null&&d(Q,{tone:p.detectionMode===`disabled`?`warning`:p.detectionMode===`always-on`?`info`:`neutral`,title:`Object detection mode`,children:p.detectionMode===`disabled`?`detection off`:p.detectionMode}),i?.recording!=null&&(i.recording.active?r(Q,{tone:`danger`,title:`Recording (${i.recording.mode})`,children:[d(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full bg-danger animate-pulse`}),`REC`]}):i.recording.mode!==`off`&&r(Q,{tone:`neutral`,title:`Recording mode`,children:[`rec `,i.recording.mode]}))]})]}),h.length>0&&d(qr,{problems:h}),i===void 0?d(`div`,{className:`px-4 py-5 text-[11px] text-foreground-subtle italic`,children:`No pipeline status yet — the orchestrator has not composed a snapshot for this camera.`}):r(`div`,{className:`grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-px bg-border`,children:[d(Pr,{assignment:i.assignment,settings:p,onlineNodes:s,pinPending:v.isPending||y.isPending,onDetectionPinChange:b}),d(Vr,{detection:i.detection,live:o,detectionMode:p.detectionMode,modeOverridden:p.overriddenKeys.has(`detectionMode`)}),d(zr,{steps:m,audioModelId:f?.audio?.modelId??null,audioEnabled:i.audio?.enabled??f?.audio?.enabled??null,audioMode:p.audioMode}),d(Rr,{streams:i.source.streams,brokerProfiles:i.broker?.profiles,settings:p,motionEnabled:i.motion?.enabled??null,motionFpsLive:i.motion?.fps??null}),d(Hr,{broker:i.broker}),d(Ur,{decoder:i.decoder,detectionActive:i.detection?.phase===`active`})]})]})}n();var Yr=5e3,Xr=1e4,Zr=5e3;function Qr(e){let t=c(),{data:n,isLoading:r}=Re(),{data:i,isLoading:o}=E({},{refetchInterval:Yr}),{nodes:s}=V();f(()=>{e!==0&&t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCameraStatuses`]]})},[e,t]);let[l,d]=u(new Map);N(Ae.PipelineCameraMetricsSnapshot,e=>{let t=e.data;typeof t.deviceId==`number`&&d(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})}),f(()=>{if(l.size===0)return;let e=setInterval(()=>{d(e=>{let t=Date.now()-Xr,n=!1,r=new Map(e);for(let[i,a]of e)a.timestamp<t&&(r.delete(i),n=!0);return n?r:e})},Zr);return()=>clearInterval(e)},[l.size]);let p=a(()=>{let e=new Map;for(let t of i??[])e.set(t.deviceId,t);return e},[i]);return{rows:a(()=>(n??[]).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)),[n,p]),liveMetrics:l,onlineNodes:a(()=>(s??[]).filter(e=>e.isOnline).map(e=>({id:e.id,name:e.name})),[s]),isLoading:r||o}}n();function $r({refreshToken:e}){let{rows:t,liveMetrics:n,onlineNodes:i,isLoading:o}=Qr(e),s=a(()=>[...t.map(e=>{let t=e.status===void 0?[]:Cr(e.status);return{row:e,errorCount:t.filter(e=>e.severity===`error`).length,warningCount:t.filter(e=>e.severity===`warning`).length}})].sort((e,t)=>e.errorCount===t.errorCount?e.warningCount===t.warningCount?0:t.warningCount-e.warningCount:t.errorCount-e.errorCount),[t]),c=a(()=>{let e=0,t=0;for(let r of s)(r.errorCount>0||r.warningCount>0)&&(t+=1),(n.get(r.row.deviceId)?.phase??r.row.status?.detection?.phase)===`active`&&(e+=1);return{total:s.length,active:e,issues:t}},[s,n]);return o&&t.length===0?d(`div`,{className:`flex items-center justify-center h-full text-sm text-foreground-subtle`,children:`Loading camera pipelines…`}):t.length===0?d(`div`,{className:`flex items-center justify-center h-full text-sm text-foreground-subtle`,children:`No cameras found`}):d(`div`,{className:`h-full overflow-y-auto`,children:r(`div`,{className:`max-w-6xl mx-auto flex flex-col gap-3 px-4 py-4`,children:[r(`div`,{className:`flex items-center gap-4 text-[11px] text-foreground-subtle px-1`,children:[r(`span`,{children:[d(`span`,{className:`font-semibold text-foreground`,children:c.total}),` cameras`]}),r(`span`,{children:[d(`span`,{className:`font-semibold text-success`,children:c.active}),` actively inferring`]}),r(`span`,{children:[d(`span`,{className:`font-semibold ${c.issues>0?`text-danger`:`text-foreground`}`,children:c.issues}),` `,`with issues`]}),d(`span`,{className:`ml-auto hidden sm:inline text-[10px]`,children:`polled every 5 s · detection metrics live at 1 Hz`})]}),s.map(({row:e})=>d(Jr,{deviceId:e.deviceId,name:e.name,online:e.online,status:e.status,live:n.get(e.deviceId),onlineNodes:i},e.deviceId))]})})}n();var ei=`__cluster__`;function ti(e){return e===`cameras`?`cameras`:`nodes`}function ni(){let[e,t]=ut(),n=ti(e.get(`view`)),i=e.get(`node`)??`__cluster__`,[a,s]=u(0),[c,l]=u(!1);return f(()=>{n===`nodes`&&!e.get(`node`)&&t({view:`nodes`,node:ei},{replace:!0})},[n,e,t]),r(`div`,{className:`flex flex-col h-full overflow-hidden`,children:[r(`div`,{className:`flex items-center justify-between gap-4 px-4 py-3 border-b border-border shrink-0`,children:[r(`div`,{className:`flex items-center gap-1 rounded-lg border border-border p-0.5 bg-surface`,children:[d(`button`,{type:`button`,onClick:()=>{t({view:`nodes`,node:i},{replace:!0})},className:[`px-3 py-1 rounded-md text-[11px] font-medium transition-colors`,n===`nodes`?`bg-background text-foreground shadow-sm`:`text-foreground-subtle hover:text-foreground`].join(` `),children:`Nodes`}),d(`button`,{type:`button`,onClick:()=>{t({view:`cameras`},{replace:!0})},className:[`px-3 py-1 rounded-md text-[11px] font-medium transition-colors`,n===`cameras`?`bg-background text-foreground shadow-sm`:`text-foreground-subtle hover:text-foreground`].join(` `),children:`Cameras`})]}),d(`div`,{className:`flex items-center gap-2`,children:r(`button`,{type:`button`,onClick:()=>s(e=>e+1),title:`Refresh`,className:`inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-[11px] font-medium border border-border text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,children:[d(Xe,{className:`h-3.5 w-3.5`}),`Refresh`]})})]}),n===`nodes`&&r(`button`,{type:`button`,onClick:()=>l(e=>!e),"aria-expanded":c,className:`md:hidden flex items-center justify-between gap-2 px-4 py-2 border-b border-border shrink-0 text-[11px] font-medium text-foreground-subtle hover:text-foreground transition-colors`,children:[r(`span`,{children:[c?`Hide`:`Show`,` node list`]}),d(lt,{className:[`h-4 w-4 transition-transform`,c?`rotate-180`:``].join(` `)})]}),d(`div`,{className:`flex-1 flex flex-col md:flex-row overflow-hidden min-h-0`,children:n===`nodes`?r(o,{children:[d(`aside`,{className:[c?`block`:`hidden`,`md:block w-full md:w-72 shrink-0 border-b md:border-b-0 md:border-r border-border`,`max-h-[60vh] md:max-h-none overflow-y-auto`].join(` `),children:d(kt,{selectedNodeId:i,onSelect:e=>{t({view:`nodes`,node:e},{replace:!0}),l(!1)},refreshToken:a})}),d(`section`,{className:`flex-1 min-h-0 overflow-hidden`,children:i===`__cluster__`?d(yr,{refreshToken:a}):d(Tn,{nodeId:i,refreshToken:a})})]}):d(`section`,{className:`flex-1 min-h-0 overflow-hidden`,children:d($r,{refreshToken:a})})})]})}export{ni as PipelinePage};
@@ -1 +0,0 @@
1
- import{I as e,Q as t,S as n,W as r,o as i,q as a,x as o,z as s}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{Z as c,q as l}from"./player-overlays-BCuyatPp.js";import{Ao as u,Bo as d,Br as f,Do as p,Eo as m,Go as h,Ho as g,Ko as _,Mo as v,Oo as y,Ro as b,To as x,Ua as S,Uo as C,Wo as w,Xt as T,Zi as E,an as D,da as O,et as k,ga as A,gn as j,jo as ee,js as M,ln as N,na as te,oa as ne,qa as re,vn as ie,wo as ae,zo as oe}from"./src-BmCjCFGO.js";import{Lt as P,pt as F}from"./src-D8hsVOc6.js";import{t as se}from"./circle-x-_qOKhKMV.js";import{t as ce}from"./download-mZ1OYsqe.js";import{t as I}from"./hard-drive-D6z2TCCh.js";import{C as L,G as R,K as z,M as B,O as V,V as le,i as H,s as U}from"./index-CoX6Kh_l.js";import{t as ue}from"./AdminPage-CCD07UMs.js";import{r as de}from"./authed-media-BPd_L9jr.js";import{t as fe}from"./DeviceAggregateSection-aUgWgamW.js";import{t as pe}from"./AdminTabs-Ya-WafVI.js";import{t as W}from"./format-size-CO9d3C3-.js";import{i as G,n as me,r as he,t as ge}from"./AddLocationWizard-ClWHdX1D.js";var K=z(`arrow-right-left`,[[`path`,{d:`m16 3 4 4-4 4`,key:`1x1c3m`}],[`path`,{d:`M20 7H4`,key:`zbl0bi`}],[`path`,{d:`m8 21-4-4 4-4`,key:`h9nckh`}],[`path`,{d:`M4 17h16`,key:`g4d7ey`}]]),q=z(`scissors`,[[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M8.12 8.12 12 12`,key:`1alkpv`}],[`path`,{d:`M20 4 8.12 15.88`,key:`xgtan2`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}],[`path`,{d:`M14.8 14.8 20 20`,key:`ptml3r`}]]),_e=z(`settings-2`,[[`path`,{d:`M20 7h-9`,key:`3s1dr2`}],[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]);t();function ve(){let e=f({}),t=r(()=>(e.data??[]).filter(e=>e.type===F.Camera).sort((e,t)=>e.name.localeCompare(t.name)),[e.data]),[i,s]=a(null),c=i??t[0]?.id??null;return!e.isLoading&&t.length===0?o(T,{icon:le,title:`No cameras`,description:`Add a camera first.`}):n(`div`,{className:`space-y-3`,children:[n(`div`,{className:`flex items-center gap-2`,children:[o(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Camera`}),o(`select`,{value:c??``,onChange:e=>s(Number(e.target.value)),className:`rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground`,children:t.map(e=>o(`option`,{value:e.id,children:e.name},e.id))})]}),c!==null&&o(D,{deviceId:c,children:o(fe,{deviceId:c,sectionFilter:e=>e.location===`top-tab`&&e.tab===`recording`})},c)]})}t();var ye=[`high`,`mid`,`low`],be=[{value:1,label:`Real time (1×)`},{value:2,label:`2×`},{value:4,label:`4×`},{value:8,label:`8×`},{value:16,label:`16×`}],xe=10080*60*1e3;function J(e){let t=new Date(Date.now()-e*6e4),n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}T${n(t.getHours())}:${n(t.getMinutes())}`}function Se({onClose:e,onCreated:t}){let i=f({}),s=r(()=>(i.data??[]).filter(e=>e.type===F.Camera).sort((e,t)=>e.name.localeCompare(t.name)),[i.data]),[c,l]=a(``),[u,d]=a(`high`),[p,h]=a(J(60)),[g,_]=a(J(0)),[v,y]=a(1),[b,x]=a(!0),[S,C]=a(``),[w,T]=a(null),E=c===``?s[0]?.id??null:c,D=new Date(p).getTime(),O=new Date(g).getTime(),k=Number.isFinite(D)&&Number.isFinite(O)&&D<O,A=m({onSuccess:()=>{t(),e()},onError:e=>T(e instanceof Error?e.message:String(e))});return o(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm`,onClick:e,children:n(`div`,{className:`w-full max-w-md rounded-xl border border-border bg-surface shadow-2xl`,onClick:e=>e.stopPropagation(),children:[n(`div`,{className:`flex items-start justify-between border-b border-border px-4 py-3`,children:[n(`h2`,{className:`flex items-center gap-1.5 text-sm font-semibold text-foreground`,children:[o(V,{className:`h-3.5 w-3.5`}),`New export`]}),o(`button`,{onClick:e,className:`text-foreground-subtle hover:text-foreground`,children:o(H,{className:`h-4 w-4`})})]}),n(`div`,{className:`p-4 space-y-3`,children:[n(`div`,{className:`grid grid-cols-2 gap-3`,children:[n(`div`,{className:`space-y-1`,children:[o(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Camera`}),o(`select`,{value:E??``,onChange:e=>l(Number(e.target.value)),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground`,children:s.map(e=>o(`option`,{value:e.id,children:e.name},e.id))})]}),n(`div`,{className:`space-y-1`,children:[o(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Profile`}),o(`select`,{value:u,onChange:e=>d(e.target.value),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground`,children:ye.map(e=>o(`option`,{value:e,children:e},e))})]})]}),n(`div`,{className:`grid grid-cols-2 gap-3`,children:[n(`div`,{className:`space-y-1`,children:[o(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`From`}),o(`input`,{type:`datetime-local`,value:p,onChange:e=>h(e.target.value),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground`})]}),n(`div`,{className:`space-y-1`,children:[o(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`To`}),o(`input`,{type:`datetime-local`,value:g,onChange:e=>_(e.target.value),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground`})]})]}),n(`div`,{className:`grid grid-cols-2 gap-3`,children:[n(`div`,{className:`space-y-1`,children:[o(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Speed`}),o(`select`,{value:v,onChange:e=>y(Number(e.target.value)),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground`,children:be.map(e=>o(`option`,{value:e.value,children:e.label},e.value))})]}),n(`div`,{className:`space-y-1`,children:[o(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Title (optional)`}),o(`input`,{type:`text`,value:S,onChange:e=>C(e.target.value),placeholder:`e.g. courier at the gate`,className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground placeholder:text-foreground-subtle`})]})]}),n(`label`,{className:`flex items-center gap-2 text-xs text-foreground cursor-pointer`,children:[o(`input`,{type:`checkbox`,checked:b,disabled:v!==1,onChange:e=>x(e.target.checked),className:`accent-primary`}),`Include audio`,v===1?``:` (real-time only)`]}),!k&&o(`p`,{className:`text-[11px] text-danger`,children:`"From" must be before "To".`}),w&&o(`p`,{className:`text-[11px] text-danger`,children:w})]}),n(`div`,{className:`flex justify-end gap-2 border-t border-border px-4 py-3`,children:[o(`button`,{onClick:e,className:`rounded border border-border px-3 py-1.5 text-xs text-foreground-subtle hover:text-foreground`,children:`Cancel`}),o(`button`,{onClick:()=>{if(E===null||!k)return;T(null);let e=S.trim();A.mutate({deviceId:E,profile:u,fromMs:D,toMs:O,options:{includeAudio:b,maxLifeMs:xe,deleteAfterDownload:!1,...v===1?{}:{speed:v},...e.length>0?{title:e}:{}}})},disabled:E===null||!k||A.isPending,className:`rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground disabled:opacity-50`,children:A.isPending?`Queuing…`:`Create export`})]})]})})}function Ce(e){let t=[];return e.timelapse?t.push(`timelapse ${String(e.timelapse.everyMs/1e3)}s`):(t.push(`${String(e.speed??1)}×`),e.includeAudio&&t.push(`+ audio`)),t.join(` `)}function we(e){return new Date(e).toLocaleString(void 0,{day:`2-digit`,month:`short`,hour:`2-digit`,minute:`2-digit`})}function Te(e,t){let n=Math.max(0,Math.round((t-e)/1e3)),r=Math.floor(n/3600),i=Math.floor(n%3600/60),a=n%60,o=r>0?`${String(r)}:${String(i).padStart(2,`0`)}:${String(a).padStart(2,`0`)}`:`${String(i)}:${String(a).padStart(2,`0`)}`;return`${we(e)} · ${o}`}function Ee(e,t){let n=e-t;if(n<=0)return`expired`;let r=Math.floor(n/6e4);if(r<60)return`in ${String(r)}m`;let i=Math.floor(r/60);return i<24?`in ${String(i)}h`:`in ${String(Math.floor(i/24))}d`}function De(e,t,n,r){return e.map(e=>{if(e.state===`expired`||e.state===`deleted`)return e;let i=r.get(e.id);if(i)return{...e,state:`failed`,error:i.error,progressPct:null};let a=n.get(e.id);if(a)return{...e,state:`ready`,fileBytes:a.fileBytes,progressPct:100};let o=t.get(e.id);return o&&(e.state===`queued`||e.state===`rendering`)?{...e,state:`rendering`,progressPct:o.progressPct}:e})}t();var Oe=[[`recordingExport`]],ke={queued:{cls:`bg-muted text-foreground-subtle`,label:`queued`},rendering:{cls:`bg-primary/10 text-primary`,label:`rendering`,spin:!0},ready:{cls:`bg-success/10 text-success`,label:`ready`},failed:{cls:`bg-danger/10 text-danger`,label:`failed`},expired:{cls:`bg-muted text-foreground-subtle`,label:`expired`},deleted:{cls:`bg-muted text-foreground-subtle`,label:`deleted`}};function Ae(){let{data:e,isLoading:t}=y({},{refetchOnWindowFocus:!1,refetchInterval:e=>(e.state.data??[]).some(e=>e.state===`queued`||e.state===`rendering`)?3e3:!1}),{map:n}=M(P.RecordingExportProgress,e=>e.exportId),{map:i}=M(P.RecordingExportCompleted,e=>e.exportId),{map:a}=M(P.RecordingExportFailed,e=>e.exportId);return{rows:r(()=>De(e??[],n,i,a),[e,n,i,a]),isLoading:t}}function je(e){let[t,n]=a(()=>Date.now());return s(()=>{let t=setInterval(()=>n(Date.now()),e);return()=>clearInterval(t)},[e]),t}function Me(){let t=i(),[s,l]=a(!1),u=()=>{t.invalidateQueries({queryKey:[[`recordingExport`,`listExports`]]})},d=N(),m=c().trpcClient,h=je(6e4),{rows:g,isLoading:_}=Ae(),{data:v}=f({}),y=r(()=>{let e=new Map;for(let t of v??[])e.set(t.id,t.name);return e},[v]),b=e(()=>{t.invalidateQueries({queryKey:Oe})},[t]),S=x({onSuccess:b}),C=p({onSuccess:b}),[w,E]=a(null),D=e(async e=>{E(e.id);try{let{url:t}=await m.recordingExport.getDownloadUrl.query({exportId:e.id}),n=await de(t),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`${e.options.title??e.id}.mp4`,document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(r),b()}finally{E(null)}},[m,b]),O=e(async e=>{await d({title:`Cancel this export?`,message:`Stops the render. The partial file is discarded.`,confirmLabel:`Cancel export`,variant:`danger`})&&S.mutate({exportId:e.id})},[d,S]),A=e(async e=>{await d({title:`Delete this export?`,message:`Permanently removes the rendered file and its history row.`,confirmLabel:`Delete`,variant:`danger`})&&C.mutate({exportId:e.id})},[d,C]),j=r(()=>[{key:`camera`,header:`Camera`,render:e=>o(`span`,{className:`text-foreground`,children:y.get(e.deviceId)??`#${String(e.deviceId)}`})},{key:`range`,header:`Range`,nowrap:!0,render:e=>o(`span`,{className:`tabular-nums`,children:Te(e.fromMs,e.toMs)})},{key:`variant`,header:`Variant`,render:e=>o(`span`,{className:`text-foreground-subtle`,children:Ce(e.options)})},{key:`state`,header:`State`,render:e=>{let t=ke[e.state];return n(`span`,{className:`inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] font-medium ${t.cls}`,children:[t.spin&&o(L,{className:`h-2.5 w-2.5 animate-spin`}),t.label,e.state===`rendering`&&e.progressPct!==null&&n(`span`,{className:`tabular-nums`,children:[e.progressPct,`%`]})]})}},{key:`expiry`,header:`Expires`,nowrap:!0,render:e=>e.state===`deleted`?o(`span`,{className:`text-foreground-subtle`,children:`—`}):o(`span`,{className:`text-foreground-subtle tabular-nums`,children:Ee(e.expiresAt,h)})},{key:`size`,header:`Size`,align:`right`,nowrap:!0,render:e=>o(`span`,{className:`tabular-nums`,children:e.fileBytes===null?`—`:W(e.fileBytes)})},{key:`actions`,header:``,align:`right`,render:e=>{let t=e.state===`ready`,r=e.state===`queued`||e.state===`rendering`,i=e.state!==`deleted`;return n(`div`,{className:`flex items-center justify-end gap-1`,children:[t&&n(`button`,{onClick:()=>{D(e)},disabled:w===e.id,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-foreground-subtle hover:bg-primary/10 hover:text-foreground disabled:opacity-50`,title:`Download MP4`,children:[w===e.id?o(L,{className:`h-3 w-3 animate-spin`}):o(ce,{className:`h-3 w-3`}),`Download`]}),r&&n(`button`,{onClick:()=>{O(e)},disabled:S.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-foreground-subtle hover:bg-amber-500/10 hover:text-amber-500 disabled:opacity-50`,title:`Cancel render`,children:[o(se,{className:`h-3 w-3`}),`Cancel`]}),i&&o(`button`,{onClick:()=>{A(e)},disabled:C.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10 disabled:opacity-50`,title:`Delete export`,children:o(U,{className:`h-3 w-3`})})]})}}],[y,h,w,S.isPending,C.isPending,D,O,A]);return _&&g.length===0?n(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[o(L,{className:`h-4 w-4 animate-spin`}),`Loading exports…`]}):n(`div`,{className:`space-y-3`,children:[o(`div`,{className:`flex justify-end`,children:n(`button`,{onClick:()=>l(!0),className:`inline-flex items-center gap-1.5 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground`,children:[o(V,{className:`h-3.5 w-3.5`}),`New export`]})}),g.length===0?o(T,{icon:V,title:`No exports yet`,description:`Create one here (New export) or from a camera's timeline in the viewer. Rendered clips show up here to download or manage.`}):o(k,{columns:j,rows:g,rowKey:e=>e.id,minWidthPx:720}),s&&o(Se,{onClose:()=>l(!1),onCreated:u})]})}function Y(e){return e.locationIds!==void 0&&e.locationIds.length>0?e.locationIds:e.locationId===null?[]:[e.locationId]}function X(e,t){let n=Y(e);return n.length===0?`default root`:n.map(e=>t.get(e)??e).join(` + `)}function Ne(e,t,n){if(e.length===0)return null;let r=e[0];if(e.length===1&&r!==void 0)return{label:X(r,t),exact:!0};if(n===null)return null;let i=e.find(e=>Y(e).includes(n));return i===void 0?null:{label:X(i,t),exact:!1}}var Z=[`ok`,`warn`,`critical`];function Pe(e){return e>=.95?`critical`:e>=.85?`warn`:`ok`}function Fe(e){return Math.min(1,Math.max(0,e))}function Ie(e){let{availableBytes:t,totalBytes:n}=e;if(n===null||n<=0||t===null)return null;let r=Fe((n-t)/n);return{fraction:r,severity:Pe(r),recordingsFraction:Fe(e.usedBytes/n),freeBytes:t,totalBytes:n}}function Le(e){if(e.length===0)return null;let t=0,n=0,r=0,i=0,a=null;for(let o of e){let e=Ie(o);if(e===null){n+=1;continue}t+=1,r+=e.totalBytes,i+=e.freeBytes,(a===null||Z.indexOf(e.severity)>Z.indexOf(a))&&(a=e.severity)}return{knownVolumes:t,unknownVolumes:n,totalBytes:r,freeBytes:i,severity:a}}t();var Re=[[`recording`]],ze=[{value:`retention`,label:`Retention policy`},{value:`quota`,label:`Quota / disk pressure`},{value:`operator`,label:`Operator`}],Be={ok:`bg-primary`,warn:`bg-amber-500`,critical:`bg-danger`},Ve={ok:`text-foreground-subtle`,warn:`text-amber-500`,critical:`text-danger`};function Q(e){return`${String(Math.round(e*100))}%`}function He(e,t){let n=e.locationIds??(e.locationId===null?[]:[e.locationId]),r=n.map(e=>t.get(e)).filter(e=>e!==void 0);return r.length>0?r.join(` + `):e.root===void 0?n.length>0?n.join(` + `):`default root`:e.root}function Ue(){let t=i(),s=N(),[c,p]=a(`retention`),{data:m,isLoading:h}=u({},{refetchOnWindowFocus:!1}),{data:g}=f({}),{data:_}=d({}),y=r(()=>{let e=new Map;for(let t of g??[])e.set(t.id,t.name);return e},[g]),b=r(()=>{let e=new Map;for(let t of _??[])e.set(t.id,t.displayName);return e},[_]),x=r(()=>(_??[]).find(e=>e.type===`recordings`&&e.isDefault)?.id??null,[_]),S=r(()=>m?.locations??[],[m?.locations]),C=r(()=>Ne(S,b,x),[S,b,x]),w=r(()=>Le(S),[S]),E=e(()=>{t.invalidateQueries({queryKey:Re})},[t]),D=v({onSuccess:E}),O=ae({onSuccess:E}),A=e(async e=>{await s({title:`Prune ${y.get(e.deviceId)??`#${String(e.deviceId)}`}?`,message:`Applies the retention policy now (reason: ${c}). Footage beyond the policy is permanently deleted.`,confirmLabel:`Prune now`,variant:`danger`})&&D.mutate({deviceId:e.deviceId,reason:c})},[s,D,c,y]),j=e(async e=>{await s({title:`Delete all footage for ${y.get(e.deviceId)??`#${String(e.deviceId)}`}?`,message:`Permanently deletes ${W(e.usedBytes)} of recorded footage for this camera. This cannot be undone.`,confirmLabel:`Delete ${W(e.usedBytes)}`,variant:`danger`})&&O.mutate({deviceId:e.deviceId})},[s,O,y]),ee=r(()=>[{key:`camera`,header:`Camera`,render:e=>o(`span`,{className:`text-foreground`,children:y.get(e.deviceId)??`#${String(e.deviceId)}`})},{key:`disk`,header:`Disk`,nowrap:!0,render:()=>C===null?o(`span`,{className:`text-foreground-subtle`,children:`—`}):n(`span`,{className:C.exact?`text-foreground`:`text-foreground-subtle`,title:C.exact?`The only recordings volume on this node — this camera can only be here.`:`The recordings DEFAULT. This node has several recordings volumes and the per-camera placement is not reported by recording.getStorageUsage, so this is where footage lands by default rather than a per-camera fact.`,children:[C.label,!C.exact&&o(`span`,{className:`ml-1 text-foreground-subtle`,children:`(default)`})]})},{key:`used`,header:`Used`,align:`right`,nowrap:!0,render:e=>o(`span`,{className:`tabular-nums`,children:W(e.usedBytes)})},{key:`actions`,header:``,align:`right`,render:e=>n(`div`,{className:`flex items-center justify-end gap-1`,children:[n(`button`,{onClick:()=>{A(e)},disabled:D.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-foreground-subtle hover:bg-amber-500/10 hover:text-amber-500 disabled:opacity-50`,title:`Apply retention policy now`,children:[o(q,{className:`h-3 w-3`}),`Prune`]}),n(`button`,{onClick:()=>{j(e)},disabled:O.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10 disabled:opacity-50`,title:`Delete all footage`,children:[o(U,{className:`h-3 w-3`}),`Delete`]})]})}],[y,C,A,j,D.isPending,O.isPending]);if(h&&!m)return n(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[o(L,{className:`h-4 w-4 animate-spin`}),`Loading storage usage…`]});if(!m)return o(T,{icon:I,title:`No storage data`,description:`The recording node has not reported any storage usage yet.`});let M=m.devices.length;return n(`div`,{className:`flex flex-col gap-6`,children:[n(`section`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:[o(l,{label:`Total used`,icon:o(I,{className:`h-3 w-3`}),footer:`${String(M)} camera${M===1?``:`s`} on ${m.nodeId}`,children:W(m.totalUsedBytes)}),w!==null&&w.severity!==null&&o(l,{label:`Free on recordings volumes`,icon:o(I,{className:`h-3 w-3`}),footer:`across ${String(w.knownVolumes)} volume${w.knownVolumes===1?``:`s`} of ${W(w.totalBytes)}`+(w.unknownVolumes>0?` · ${String(w.unknownVolumes)} did not report capacity`:``),children:o(`span`,{className:`tabular-nums ${Ve[w.severity]}`,children:W(w.freeBytes)})}),S.map(e=>{let t=Ie(e),r=e.locationId??e.root??`default`;return o(l,{label:`Disk: ${He(e,b)}`,footer:t===null?`${W(e.usedBytes)} of recordings · volume capacity unknown`:`${W(t.freeBytes)} free of ${W(t.totalBytes)} · ${W(e.usedBytes)} recordings (${Q(t.recordingsFraction)})`,children:t===null?o(`span`,{className:`tabular-nums`,children:W(e.usedBytes)}):n(`div`,{className:`flex items-center gap-2`,title:`Volume fill — everything on the disk, not only recordings. Warn at 85%, critical at 95%.`,children:[o(`div`,{className:`h-2 flex-1 overflow-hidden rounded bg-muted`,children:o(`div`,{className:`h-full rounded ${Be[t.severity]}`,style:{width:Q(t.fraction)}})}),o(`span`,{className:`tabular-nums text-xs ${Ve[t.severity]}`,children:Q(t.fraction)})]})},r)})]}),n(`section`,{className:`flex items-center gap-2 text-xs`,children:[o(`label`,{htmlFor:`prune-reason`,className:`text-foreground-subtle`,children:`Prune reason`}),o(`select`,{id:`prune-reason`,value:c,onChange:e=>{let t=ze.find(t=>t.value===e.target.value);t&&p(t.value)},className:`rounded-md border border-border bg-surface px-2 py-1 text-xs text-foreground`,children:ze.map(e=>o(`option`,{value:e.value,children:e.label},e.value))})]}),M===0?o(T,{icon:I,title:`No recorded footage`,description:`No camera has recorded footage on this node yet.`}):o(k,{columns:ee,rows:[...m.devices],rowKey:e=>e.deviceId,minWidthPx:480})]})}t();var We=[{value:`all`,label:`All`},{value:`recording`,label:`Recordings`},{value:`events`,label:`Events`}],Ge={recording:`bg-primary/10 text-primary`,events:`bg-violet-500/10 text-violet-400`};function Ke(e){return new Date(e).toLocaleString()}function qe(){let[e,t]=a(`all`),{data:i,isLoading:s}=ee({},{refetchOnWindowFocus:!1}),{data:c,isLoading:l}=O({},{refetchOnWindowFocus:!1}),{data:u}=f({}),d=r(()=>{let e=new Map;for(let t of u??[])e.set(t.id,t.name);return e},[u]),p=r(()=>{let t=[...i??[],...c??[]];return(e===`all`?t:t.filter(t=>t.domain===e)).toSorted((e,t)=>t.at-e.at)},[i,c,e]),m=r(()=>[{key:`at`,header:`When`,nowrap:!0,render:e=>o(`span`,{className:`text-foreground-subtle tabular-nums`,children:Ke(e.at)})},{key:`domain`,header:`Domain`,render:e=>o(`span`,{className:`inline-flex rounded px-1.5 py-0.5 text-[10px] font-medium ${Ge[e.domain]}`,children:e.domain})},{key:`op`,header:`Operation`,render:e=>o(`span`,{className:`text-foreground`,children:e.op})},{key:`reason`,header:`Reason`,render:e=>o(`span`,{className:`text-foreground-subtle`,children:e.reason})},{key:`device`,header:`Camera`,render:e=>e.deviceId===null?o(`span`,{className:`text-foreground-subtle`,children:`cluster`}):o(`span`,{className:`text-foreground`,children:d.get(e.deviceId)??`#${String(e.deviceId)}`})},{key:`items`,header:`Items`,align:`right`,nowrap:!0,render:e=>o(`span`,{className:`tabular-nums`,children:e.itemsAffected.toLocaleString()})},{key:`bytes`,header:`Reclaimed`,align:`right`,nowrap:!0,render:e=>o(`span`,{className:`tabular-nums`,children:e.bytesReclaimed>0?W(e.bytesReclaimed):`—`})}],[d]),h=s||l;return n(`div`,{className:`flex flex-col gap-4`,children:[o(`div`,{className:`flex items-center gap-1`,children:We.map(n=>o(`button`,{onClick:()=>t(n.value),className:`rounded px-2 py-1 text-xs font-medium ${e===n.value?`bg-primary/10 text-primary`:`text-foreground-subtle hover:bg-muted`}`,children:n.label},n.value))}),h&&p.length===0?n(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[o(L,{className:`h-4 w-4 animate-spin`}),`Loading activity…`]}):p.length===0?o(T,{icon:R,title:`No activity yet`,description:`Prune, delete and rescan operations across recordings and events show up here.`}):o(k,{columns:m,rows:p,rowKey:e=>e.id,minWidthPx:720})]})}t();function Je({types:e}){let t=i(),s=N(),{data:c}=d({}),l=oe(),u=r(()=>l.data??[],[l.data]),[f,p]=a(null),[m,h]=a(null),g=()=>{t.invalidateQueries({queryKey:[[`storage`,`listLocations`]]})},v=_({onSuccess:g}),y=b({onSuccess:g}),x=r(()=>{let e=new Map;for(let t of c??[]){let n=e.get(t.type);n?n.push(t):e.set(t.type,[t])}return e},[c]),S=e=>{e.isDefault||v.mutate(G(e,{isDefault:!0}))},C=(e,t)=>{v.mutate(G(e,{enabled:t}))},w=async e=>{if(e.isDefault){await s({title:`Cannot delete default location`,message:`"${e.displayName}" is the default for type "${e.type}". Mark another as default first.`,confirmLabel:`OK`,variant:`warning`});return}await s({title:`Delete location "${e.displayName}"?`,message:`Removes the record; files on disk are untouched.`,confirmLabel:`Delete`,variant:`danger`})&&y.mutate({id:e.id})},T=e.map(e=>u.find(t=>t.id===e)).filter(e=>e!==void 0);return n(`div`,{className:`space-y-3`,children:[T.length===0?o(`p`,{className:`text-[11px] text-foreground-subtle italic`,children:`No storage locations declared for this purpose.`}):T.map(e=>o(he,{type:e.id,displayName:e.displayName,description:e.description,cardinality:e.cardinality,locations:x.get(e.id)??[],onAdd:e=>p(e),onEdit:e=>h(e),onDelete:e=>{w(e)},onSetDefault:e=>S(e),onToggleEnabled:(e,t)=>C(e,t)},e.id)),f!==null&&o(ge,{initialType:f,onClose:()=>p(null),onCreated:()=>{g(),p(null)}}),m!==null&&o(me,{location:m,onClose:()=>h(null),onSaved:()=>{g(),h(null)}})]})}t();var $=`pipeline-analytics`;function Ye(e){for(let t of e?.sections??[])for(let e of t.fields??[])if(e.key===`postProcessingNodeId`&&typeof e.value==`string`)return e.value;return`hub`}function Xe(){let e=i(),{data:t}=E(void 0),{data:a,isLoading:s}=j({addonId:$}),c=Ye(a),l=ie({onSuccess:()=>{e.invalidateQueries({queryKey:[[`addonSettings`,`getGlobalSettings`]]})}}),u=r(()=>{let e=(t??[]).filter(e=>e.isOnline).map(e=>e.id);return[...new Set([`hub`,c,...e])].filter(Boolean)},[t,c]);return n(`div`,{className:`flex flex-col gap-6`,children:[n(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[o(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Post-processing node`}),o(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:`The single node that runs detection post-processing (events, media, audio & motion). Every other node stays inert — no multi-node balancing. Takes effect on addon restart.`}),n(`div`,{className:`mt-3 flex items-center gap-2`,children:[s?o(L,{className:`h-4 w-4 animate-spin text-foreground-subtle`}):o(`select`,{value:c,onChange:e=>{e.target.value!==c&&l.mutate({addonId:$,patch:{postProcessingNodeId:e.target.value}})},disabled:l.isPending,className:`rounded-md border border-border bg-surface px-2 py-1 text-xs text-foreground`,children:u.map(e=>o(`option`,{value:e,children:e===`hub`?`hub (default)`:e},e))}),l.isPending&&o(L,{className:`h-4 w-4 animate-spin text-primary`})]})]}),n(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[o(`h3`,{className:`mb-1 text-sm font-semibold text-foreground`,children:`Events folder`}),o(`p`,{className:`mb-3 text-[11px] text-foreground-subtle`,children:`Where event crops / full frames are stored. A single folder — no collection / equal-splitting.`}),o(Je,{types:[`eventMedia`]})]})]})}t();var Ze=`recorder`;function Qe(e,t,n){for(let n of e?.sections??[])for(let e of n.fields??[])if(e.key===t&&typeof e.value==`string`)return e.value;return n}function $e(){let e=i(),{data:t}=E(void 0),{data:a,isLoading:s}=j({addonId:Ze}),c=Qe(a,`recordingNodeId`,`hub`),l=ie({onSuccess:()=>{e.invalidateQueries({queryKey:[[`addonSettings`,`getGlobalSettings`]]})}}),u=r(()=>{let e=(t??[]).filter(e=>e.isOnline).map(e=>e.id);return[...new Set([`hub`,c,...e])].filter(Boolean)},[t,c]);return n(`div`,{className:`flex flex-col gap-6`,children:[n(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[o(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Recording node`}),o(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:`The single node that records (continuous & events) and serves playback. Every other node stays inert — no multi-node balancing. Takes effect on addon restart.`}),n(`div`,{className:`mt-3 flex items-center gap-2`,children:[s?o(L,{className:`h-4 w-4 animate-spin text-foreground-subtle`}):o(`select`,{value:c,onChange:e=>{e.target.value!==c&&l.mutate({addonId:Ze,patch:{recordingNodeId:e.target.value}})},disabled:l.isPending,className:`rounded-md border border-border bg-surface px-2 py-1 text-xs text-foreground`,children:u.map(e=>o(`option`,{value:e,children:e===`hub`?`hub (default)`:e},e))}),l.isPending&&o(L,{className:`h-4 w-4 animate-spin text-primary`})]}),c!==`hub`&&n(`p`,{className:`mt-2 text-[11px] text-amber-500`,children:[`The stream-broker is hub-only — an agent recorder pulls streams from the hub over the network. The hub's RTSP restream port must be reachable from`,` `,o(`span`,{className:`font-medium`,children:c}),`. If the auto-derived host doesn't work, set the recorder's`,o(`span`,{className:`font-medium`,children:` recordingHubHostname`}),` global setting.`]})]}),n(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[o(`h3`,{className:`mb-1 text-sm font-semibold text-foreground`,children:`Recordings folders`}),o(`p`,{className:`mb-3 text-[11px] text-foreground-subtle`,children:`Where recordings are stored. Multi-location collections — segments are split across the locations of a type. Add a location to grow capacity; mark one default per type.`}),o(Je,{types:[`recordings`,`recordingsLow`]})]})]})}t();var et=2e3;function tt(){let e=N(),t=i(),r=re(),a=S(void 0,{refetchInterval:e=>e.state.data?.state===`running`?et:!1}),c=a.data,l=c?.state===`running`,u=l||r.isPending;s(()=>{c?.state!==`done`||c.finishedAtMs===null||(t.invalidateQueries({queryKey:[[`recording`]]}),t.invalidateQueries({queryKey:[[`pipelineAnalytics`]]}))},[c?.state,c?.finishedAtMs,t]);let d=async()=>{await e({title:`Reconcile storage from disk?`,message:`Makes the database match the filesystem: recordings index, tracks, events and media whose files are gone. Favourited tracks without files are deleted. Snapshot-less motion/audio events are deleted. Enrolled identities stay. This cannot be undone.`,confirmLabel:`Reconcile`,variant:`warning`})&&(await r.mutateAsync(),await a.refetch())},f=l?c.total>0?`Reconciling ${String(c.completed)}/${String(c.total)}…`:`Reconciling…`:r.isPending?`Reconciling…`:`Reconcile from disk`;return n(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[o(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Disk reconcile`}),o(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:`Makes the database match the filesystem for recordings, tracks, events and media. Rows whose files are gone are deleted, including snapshot-less motion events. Enrolled identities stay. The walk runs on the hub; you can leave this page.`}),n(`div`,{className:`mt-3 flex flex-col gap-2`,children:[n(`button`,{type:`button`,onClick:()=>void d(),disabled:u,className:`inline-flex w-fit items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-[11px] font-medium border border-border text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50`,children:[u?o(L,{className:`h-3.5 w-3.5 animate-spin`}):o(I,{className:`h-3.5 w-3.5`}),f]}),c?.state===`done`?n(`p`,{className:`text-[11px] text-foreground-subtle`,children:[`Last run: `,String(c.completed),` camera(s) — dropped `,String(c.tracks),` tracks,`,` `,String(c.events),` events, `,String(c.mediaDropped),` media`,c.failed.length>0?`, ${String(c.failed.length)} failed (${c.failed.join(`, `)})`:``,`.`]}):null,c?.state===`error`&&c.error!==null?n(`p`,{className:`text-[11px] text-destructive`,children:[`Reconcile failed: `,c.error]}):null]})]})}t();var nt=[[`pipelineAnalytics`]],rt=1440*60*1e3,it=[{days:1,label:`1 day`},{days:7,label:`7 days`},{days:30,label:`30 days`},{days:90,label:`90 days`}];function at(){let t=i(),s=N(),[c,u]=a(30),{data:d,isLoading:p}=ne({},{refetchOnWindowFocus:!1}),{data:m}=f({}),h=r(()=>{let e=new Map;for(let t of m??[])e.set(t.id,t.name);return e},[m]),g=e(()=>{t.invalidateQueries({queryKey:nt})},[t]),_=A({onSuccess:g}),v=te({onSuccess:g}),y=e(async()=>{await s({title:`Prune events older than ${String(c)} day${c===1?``:`s`}?`,message:`Permanently deletes every event (motion / object / audio) older than the cutoff across all cameras, and their media. This cannot be undone.`,confirmLabel:`Prune events`,variant:`danger`})&&_.mutate({olderThanMs:Date.now()-c*rt,reason:`retention`})},[s,_,c]),b=e(async e=>{await s({title:`Delete all events for ${h.get(e.deviceId)??`#${String(e.deviceId)}`}?`,message:`Permanently deletes ${String(e.rows)} event${e.rows===1?``:`s`} (${W(e.bytes)} of media) for this camera. This cannot be undone.`,confirmLabel:`Delete events`,variant:`danger`})&&v.mutate({deviceId:e.deviceId})},[s,v,h]),x=r(()=>[{key:`camera`,header:`Camera`,render:e=>o(`span`,{className:`text-foreground`,children:h.get(e.deviceId)??`#${String(e.deviceId)}`})},{key:`rows`,header:`Events`,align:`right`,nowrap:!0,render:e=>o(`span`,{className:`tabular-nums`,children:e.rows.toLocaleString()})},{key:`bytes`,header:`Media`,align:`right`,nowrap:!0,render:e=>o(`span`,{className:`tabular-nums`,children:W(e.bytes)})},{key:`actions`,header:``,align:`right`,render:e=>n(`button`,{onClick:()=>{b(e)},disabled:v.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10 disabled:opacity-50`,title:`Delete all events for this camera`,children:[o(U,{className:`h-3 w-3`}),`Delete`]})}],[h,b,v.isPending]);return p&&!d?n(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[o(L,{className:`h-4 w-4 animate-spin`}),`Loading event-store footprint…`]}):d?n(`div`,{className:`flex flex-col gap-6`,children:[n(`section`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2`,children:[o(l,{label:`Total events`,icon:o(B,{className:`h-3 w-3`}),footer:`across ${String(d.devices.length)} camera${d.devices.length===1?``:`s`}`,children:d.totalRows.toLocaleString()}),o(l,{label:`Event media on disk`,children:W(d.totalBytes)})]}),n(`section`,{className:`flex flex-wrap items-center gap-2 text-xs`,children:[o(`span`,{className:`text-foreground-subtle`,children:`Prune events older than`}),o(`select`,{value:c,onChange:e=>u(Number(e.target.value)),className:`rounded-md border border-border bg-surface px-2 py-1 text-xs text-foreground`,children:it.map(e=>o(`option`,{value:e.days,children:e.label},e.days))}),n(`button`,{onClick:()=>{y()},disabled:_.isPending,className:`inline-flex items-center gap-1 rounded border border-border px-2 py-1 text-xs font-medium text-foreground-subtle hover:bg-amber-500/10 hover:text-amber-500 disabled:opacity-50`,children:[_.isPending?o(L,{className:`h-3 w-3 animate-spin`}):o(q,{className:`h-3 w-3`}),`Prune now`]})]}),d.devices.length===0?o(T,{icon:B,title:`No stored events`,description:`No camera has persisted events yet.`}):o(k,{columns:x,rows:[...d.devices],rowKey:e=>e.deviceId,minWidthPx:480})]}):o(T,{icon:B,title:`No event data`,description:`Pipeline analytics has not reported any event-store footprint yet.`})}t();var ot=`storage-migration`;function st(){let{data:e}=E(void 0);return(e??[]).some(e=>e.addons.some(e=>e.capabilities.includes(ot)))}var ct=[{id:`recordings`,label:`Recordings`,locationType:`recordings`},{id:`recordingsLow`,label:`Low-res recordings`,locationType:`recordingsLow`},{id:`eventMedia`,label:`Event media`,locationType:`eventMedia`}],lt=new Set([`planning`,`pausing`,`moving`,`verifying`,`repointing`,`refreshing`,`resuming`]);function ut(){return st()?o(dt,{}):o(T,{icon:K,title:`Storage migration not installed`,description:`This system doesn't advertise the storage-migration capability yet. Once it's deployed, this panel moves recordings, low-res recordings and event media to new storage locations in one coordinated, verified operation.`})}function dt(){let e=N(),{data:t}=d({}),[i,s]=a({}),[c,l]=a(null),[u,f]=a(null),p=r(()=>{let e=new Map;for(let n of t??[]){let t=e.get(n.type);t?t.push(n):e.set(n.type,[n])}return e},[t]),m=h({},{refetchInterval:2e3}),_=m.data??null,v=_!==null&&lt.has(_.phase),y=r(()=>{let e={};for(let t of ct){let n=i[t.id];n&&(e[t.id]=n)}return Object.keys(e).length>0?e:void 0},[i]),b=C({destinations:y??{}},{enabled:!1,retry:!1}),x=w(),S=g(),T=async()=>{if(!y)return;f(null);let e=await b.refetch();if(e.error){f(e.error instanceof Error?e.error.message:String(e.error));return}l(e.data??null)},E=async()=>{if(y&&await e({title:`Start storage migration?`,message:`Pauses the affected writers, copies the data to the new locations, verifies it, then repoints the defaults. Safe to re-run if interrupted.`,confirmLabel:`Start migration`,variant:`danger`})){f(null);try{await x.mutateAsync({destinations:y}),l(null),await m.refetch()}catch(e){f(e instanceof Error?e.message:String(e))}}},D=async()=>{if(_&&await e({title:`Cancel migration?`,message:`Stops the in-progress migration. Data already moved and verified stays at the destination; anything already repointed is not reverted.`,confirmLabel:`Cancel migration`,variant:`danger`}))try{await S.mutateAsync({jobId:_.jobId}),await m.refetch()}catch{}};return n(`div`,{className:`flex flex-col gap-6`,children:[n(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[n(`h3`,{className:`flex items-center gap-1.5 text-sm font-semibold text-foreground`,children:[o(K,{className:`h-3.5 w-3.5`}),`Storage migration`]}),o(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:`Move recordings, low-res recordings and/or event media to new storage locations in one coordinated operation: pauses the writers, copies via the recorder / pipeline-analytics movers, verifies, then repoints the defaults. Always applies to every camera — destinations are global defaults per storage class, so migration can't be scoped to a subset of cameras. This is the only supported way to move a storage location's data — the Storage tab no longer offers a per-location "Relocate" action.`}),o(`div`,{className:`mt-3 grid grid-cols-1 gap-3 sm:grid-cols-3`,children:ct.map(e=>{let t=p.get(e.locationType)??[];return n(`div`,{className:`space-y-1`,children:[o(`label`,{htmlFor:`migration-dest-${e.id}`,className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:e.label}),n(`select`,{id:`migration-dest-${e.id}`,value:i[e.id]??``,onChange:t=>{let n=t.target.value;s(t=>({...t,[e.id]:n}))},disabled:v,className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground disabled:opacity-50`,children:[o(`option`,{value:``,children:`— unchanged —`}),t.map(e=>o(`option`,{value:e.id,children:e.displayName},e.id))]})]},e.id)})}),u&&o(`p`,{className:`mt-2 text-[11px] text-danger`,children:u}),n(`div`,{className:`mt-3 flex items-center gap-2`,children:[n(`button`,{type:`button`,onClick:()=>{T()},disabled:!y||b.isFetching||v,className:`inline-flex items-center gap-1.5 rounded border border-border px-2.5 py-1.5 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover disabled:opacity-50`,children:[b.isFetching&&o(L,{className:`h-3 w-3 animate-spin`}),`Plan`]}),n(`button`,{type:`button`,onClick:()=>{E()},disabled:!y||x.isPending||v,className:`inline-flex items-center gap-1.5 rounded bg-primary px-2.5 py-1.5 text-xs font-medium text-primary-foreground disabled:opacity-50`,children:[x.isPending&&o(L,{className:`h-3 w-3 animate-spin`}),`Start migration`]})]}),c&&o(`div`,{className:`mt-3 divide-y divide-border rounded-md border border-border`,children:c.moves.length===0?o(`p`,{className:`px-2.5 py-1.5 text-[11px] text-foreground-subtle`,children:`Nothing to move — selected destinations match the current defaults.`}):c.moves.map(e=>n(`div`,{className:`px-2.5 py-1.5 text-[11px] text-foreground`,children:[e.storageClass,`: `,e.fromLocationId,` → `,e.toLocationId]},`${e.storageClass}-${e.toLocationId}`))})]}),_&&n(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[n(`div`,{className:`flex items-center justify-between`,children:[o(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Migration status`}),v&&n(`button`,{type:`button`,onClick:()=>{D()},className:`inline-flex items-center gap-1 rounded border border-border px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10`,children:[o(H,{className:`h-3 w-3`}),`Cancel`]})]}),n(`p`,{className:`mt-1 text-xs text-foreground`,children:[`Phase: `,o(`span`,{className:`font-medium`,children:_.phase}),v&&o(L,{className:`ml-2 inline h-3 w-3 animate-spin text-primary`})]}),_.error&&o(`p`,{className:`mt-1 text-[11px] text-danger`,children:_.error}),_.pausedParticipants.length>0&&n(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:[`Paused: `,_.pausedParticipants.join(`, `)]}),o(`div`,{className:`mt-2 divide-y divide-border rounded-md border border-border`,children:_.moves.map(e=>n(`div`,{className:`flex items-center justify-between px-2.5 py-1.5 text-[11px]`,children:[n(`span`,{className:`text-foreground`,children:[e.storageClass,`: `,e.fromLocationId,` → `,e.toLocationId]}),n(`span`,{className:`text-foreground-subtle`,children:[e.state??`pending`,e.error?` (${e.error})`:``]})]},e.storageClass))})]})]})}function ft(){return n(`div`,{className:`flex flex-col gap-8`,children:[n(`div`,{children:[o(`h2`,{className:`text-sm font-semibold text-foreground`,children:`Recording`}),o(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:`The cluster recording node and recordings folders.`}),n(`div`,{className:`mt-3 flex flex-col gap-6`,children:[o($e,{}),o(tt,{})]})]}),n(`div`,{children:[o(`h2`,{className:`text-sm font-semibold text-foreground`,children:`Events`}),o(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:`The cluster post-processing node, the events folder, and the durable event-store footprint with retention and per-camera deletion.`}),n(`div`,{className:`mt-3 flex flex-col gap-6`,children:[o(Xe,{}),o(at,{})]})]}),n(`div`,{children:[o(`h2`,{className:`text-sm font-semibold text-foreground`,children:`Migration`}),o(`div`,{className:`mt-3`,children:o(ut,{})})]})]})}function pt(){return o(ue,{icon:V,title:`Recordings`,subtitle:`Recording node & storage, event-store management, exported clips, and an activity log.`,children:o(pe,{tabs:[{id:`storage`,label:`Storage`,icon:I,content:o(Ue,{})},{id:`cameras`,label:`Cameras`,icon:le,content:o(ve,{})},{id:`exports`,label:`Export`,icon:V,content:o(Me,{})},{id:`activity`,label:`Activity`,icon:R,content:o(qe,{})},{id:`management`,label:`Management`,icon:_e,content:o(ft,{})}]})})}export{pt as RecordingsPage};
@@ -1 +0,0 @@
1
- import{K as e}from"./index-CoX6Kh_l.js";var t=e(`circle-check-big`,[[`path`,{d:`M21.801 10A10 10 0 1 1 17 3.335`,key:`yps3ct`}],[`path`,{d:`m9 11 3 3L22 4`,key:`1pflzl`}]]);export{t};
@@ -1 +0,0 @@
1
- import{K as e}from"./index-CoX6Kh_l.js";var t=e(`clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`polyline`,{points:`12 6 12 12 16 14`,key:`68esgv`}]]);export{t};