@camstack/addon-admin-ui 1.2.32 → 1.2.33

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 (89) hide show
  1. package/dist/assets/{AddLocationWizard-Bqn51iVc.js → AddLocationWizard-BNLzjRkS.js} +1 -1
  2. package/dist/assets/{AddonCollectionPage-D9EE6p80.js → AddonCollectionPage-CvyviITl.js} +1 -1
  3. package/dist/assets/{Addons-Bp55KXZR.js → Addons-B0nG62pB.js} +1 -1
  4. package/dist/assets/{AdminTabs-DB9TozBh.js → AdminTabs-V94RuaJP.js} +1 -1
  5. package/dist/assets/{AiProfiles-C4ji0awJ.js → AiProfiles-CNda-xrz.js} +1 -1
  6. package/dist/assets/{Automation-BmDGNoTh.js → Automation-DYV0gbiV.js} +1 -1
  7. package/dist/assets/{BrokerForm-CtjETVv8.js → BrokerForm-DX_RUCNg.js} +1 -1
  8. package/dist/assets/{Capabilities-BlEUfcGN.js → Capabilities-Cud2I1p1.js} +1 -1
  9. package/dist/assets/{CapabilityBadges-CTZ7zqWM.js → CapabilityBadges-CaKz6Row.js} +1 -1
  10. package/dist/assets/{Cluster-CkGq5KVh.js → Cluster-Cx5dtvDp.js} +1 -1
  11. package/dist/assets/{ClusterRecordingTab-nszIK7qG.js → ClusterRecordingTab-BShu9AFE.js} +1 -1
  12. package/dist/assets/{Dashboard-CO5PTZ9n.js → Dashboard-CN0qzHHd.js} +1 -1
  13. package/dist/assets/{Data-CYwE4-K2.js → Data-Cddnp6Uz.js} +1 -1
  14. package/dist/assets/{DetectionIntelligence-MaxZ_sn8.js → DetectionIntelligence-C4g5DaCG.js} +1 -1
  15. package/dist/assets/{DeviceAggregateSection-C6sscd95.js → DeviceAggregateSection-H5AVeNJ0.js} +1 -1
  16. package/dist/assets/DeviceDetail-CLQTZBsf.js +2 -0
  17. package/dist/assets/{Devices-xlmwhKxI.js → Devices-Bp2S4_jq.js} +1 -1
  18. package/dist/assets/{EmbedPlayerPage-CLGFNg5C.js → EmbedPlayerPage-DVIbQ9_P.js} +1 -1
  19. package/dist/assets/{Events-EfdVWQGS.js → Events-C_TE39Tm.js} +1 -1
  20. package/dist/assets/{FormBuilder-ZuE9B0w9.js → FormBuilder-B3G6L5El.js} +1 -1
  21. package/dist/assets/{Identity-CKR7bmrK.js → Identity-D5YIw7nG.js} +1 -1
  22. package/dist/assets/{IntegrationDetail-DUkC3dFN.js → IntegrationDetail-Dj2OdD1K.js} +1 -1
  23. package/dist/assets/{Integrations-t8-3dqN4.js → Integrations-DZKddVhD.js} +1 -1
  24. package/dist/assets/{Integrations-BuhF2y9p.js → Integrations-fadRG4Km.js} +1 -1
  25. package/dist/assets/{Logs-D1sMKNHu.js → Logs-zJNzZ183.js} +1 -1
  26. package/dist/assets/{MotionZonesSettings-JUP-5dky.js → MotionZonesSettings-4IW50CRy.js} +1 -1
  27. package/dist/assets/{MyAccess-BSkJTbz8.js → MyAccess-CBfHhwSU.js} +1 -1
  28. package/dist/assets/{Network-CXKyrgFS.js → Network-Dx9MFUR0.js} +1 -1
  29. package/dist/assets/{NodeAddonsSettingsPanel-1C9rZfoa.js → NodeAddonsSettingsPanel-C2NjwPws.js} +1 -1
  30. package/dist/assets/{NodeInferenceDevices-D1yIrxri.js → NodeInferenceDevices-uPCEdvuj.js} +1 -1
  31. package/dist/assets/{Notifications-gurR5fDh.js → Notifications-C3Ng_pEz.js} +1 -1
  32. package/dist/assets/{Pipeline-DTKomVZV.js → Pipeline-Daj8GJqM.js} +1 -1
  33. package/dist/assets/{Plates-CQ4aoncO.js → Plates-CdBLHSjv.js} +1 -1
  34. package/dist/assets/{PrivacyMaskSettings-CfvJZ3tP.js → PrivacyMaskSettings-DOgtt7Eb.js} +1 -1
  35. package/dist/assets/{ProviderIcon-ClXY1rL4.js → ProviderIcon-DpSmN8_h.js} +1 -1
  36. package/dist/assets/{Recordings-DglOV8NW.js → Recordings-5kVeLC44.js} +1 -1
  37. package/dist/assets/{ScanNetworkModal-DmZyDQIW.js → ScanNetworkModal-CVNem53G.js} +1 -1
  38. package/dist/assets/{Settings-BVw2pnr7.js → Settings-Dot1aUpP.js} +1 -1
  39. package/dist/assets/{Showroom-9BtpR6nD.js → Showroom-CE0pD_JA.js} +1 -1
  40. package/dist/assets/{Terminal-C-v8B3we.js → Terminal-Jn61QHqq.js} +1 -1
  41. package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-BtA4eogJ.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-DfmS2X5b.js} +1 -1
  42. package/dist/assets/{build-cluster-graph-6UMcPt27.js → build-cluster-graph-oxCzI_GT.js} +1 -1
  43. package/dist/assets/circle-check-big-bqZqQn_F.js +1 -0
  44. package/dist/assets/clock-BxBK96nq.js +1 -0
  45. package/dist/assets/{copy-BObtPXKC.js → copy-BrMo-O0l.js} +1 -1
  46. package/dist/assets/{debounced-invalidate-Sygznr_T.js → debounced-invalidate-DCfaNC1r.js} +1 -1
  47. package/dist/assets/dist-DPJBx5gf.js +7 -0
  48. package/dist/assets/{dist-W1UImz79.js → dist-w7XvHdqJ.js} +1 -1
  49. package/dist/assets/{download-DsIysR_y.js → download-Bd71YsuA.js} +1 -1
  50. package/dist/assets/{face-bbox-DjqvdhYZ.js → face-bbox-ByAacIlM.js} +1 -1
  51. package/dist/assets/{hostInit-BUHMjqwF.js → hostInit-DhSUBWsx.js} +1 -1
  52. package/dist/assets/index-BIqRUg3I.css +2 -0
  53. package/dist/assets/{index-BqCgqp9V.js → index-BZA0u2Kc.js} +3 -3
  54. package/dist/assets/{key-round-DF1dcL0w.js → key-round-DZL9RdNY.js} +1 -1
  55. package/dist/assets/{mf-entry-bootstrap-0-62a13374.js → mf-entry-bootstrap-0-28bb7ad2.js} +2 -2
  56. package/dist/assets/{pencil-CQwfEybQ.js → pencil-TjwM9NpS.js} +1 -1
  57. package/dist/assets/{player-overlays-CJ2EDXmI.js → player-overlays-CkAkhPbQ.js} +1 -1
  58. package/dist/assets/plus-BgUAuoLj.js +1 -0
  59. package/dist/assets/{radio-C754NrLM.js → radio-DOrncLmg.js} +1 -1
  60. package/dist/assets/{refresh-cw-DAm7QoFj.js → refresh-cw-BYCB135v.js} +1 -1
  61. package/dist/assets/remoteEntry-2xQrocPD.js +1 -0
  62. package/dist/assets/{rotate-ccw-ildFCltM.js → rotate-ccw-Db_qQ-Qx.js} +1 -1
  63. package/dist/assets/rotate-cw-vsmRF4Nv.js +1 -0
  64. package/dist/assets/search-BopXcdUz.js +1 -0
  65. package/dist/assets/{send-BMpnpOJi.js → send-CosR7D5R.js} +1 -1
  66. package/dist/assets/{server-2ReeYjUz.js → server-CUNj6w6P.js} +1 -1
  67. package/dist/assets/square-C0Uc1Hub.js +1 -0
  68. package/dist/assets/{square-check-big-DUv4JqM3.js → square-check-big-yxLWkS9v.js} +1 -1
  69. package/dist/assets/src-Bh5CQXm7.js +7 -0
  70. package/dist/assets/{src-DCsdXZpS.js → src-DOXkuCPk.js} +10 -10
  71. package/dist/assets/{upload-Dvv16Zg3.js → upload-D0orNbud.js} +1 -1
  72. package/dist/assets/{useEventInvalidation-BI2Lc7mp.js → useEventInvalidation-DJ5h5Wvp.js} +1 -1
  73. package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-D3wOFHTg.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-Cg_QybrP.js} +2 -2
  74. package/dist/assets/{wifi-cBAahSiZ.js → wifi-D0ItCC1K.js} +1 -1
  75. package/dist/assets/{zap-C86yuB6j.js → zap-CIK4k9g5.js} +1 -1
  76. package/dist/index.html +6 -6
  77. package/dist/server/addon.js +283 -22
  78. package/package.json +1 -1
  79. package/dist/assets/DeviceDetail-KHB2dWaR.js +0 -2
  80. package/dist/assets/circle-check-big-5J4vhHcH.js +0 -1
  81. package/dist/assets/clock-D19QkJv2.js +0 -1
  82. package/dist/assets/dist-Bso6V1TI.js +0 -7
  83. package/dist/assets/index-BH_HqZVJ.css +0 -2
  84. package/dist/assets/plus-BIR1e9Y7.js +0 -1
  85. package/dist/assets/remoteEntry-EVtyXnE6.js +0 -1
  86. package/dist/assets/rotate-cw-DyrhB96Y.js +0 -1
  87. package/dist/assets/search-BFU3RCdH.js +0 -1
  88. package/dist/assets/square-CjeJk_qb.js +0 -1
  89. package/dist/assets/src-YgttllUb.js +0 -7
@@ -1,2 +0,0 @@
1
- import{$ as e,An as t,Bn as n,Bt as r,Ci as i,Cn as a,D as o,Dn as s,E as c,F as l,Fi as u,Ga as d,Gn as f,H as p,Hn as m,J as h,Ja as g,Ka as _,Ln as v,Lr as y,Mn as b,N as x,Ni as S,Nn as C,O as ee,On as w,P as T,Pi as te,Pn as ne,Q as E,Ro as re,T as D,Tt as ie,U as O,Un as k,Vi as ae,Vn as A,W as oe,Wn as j,Wr as M,X as N,Y as P,Z as se,_i as ce,_o as le,_r as F,a as I,ai as ue,ao as L,at as de,bi as fe,cn as pe,co as me,dr as he,et as ge,f as _e,fo as R,g as ve,gi as ye,gn as be,ho as xe,i as Se,io as Ce,jn as we,l as Te,ln as Ee,lo as De,m as Oe,mi as z,mo as ke,n as Ae,na as je,o as Me,ot as Ne,p as Pe,po as Fe,r as Ie,ro as Le,rt as Re,so as ze,st as Be,tt as Ve,u as He,uo as Ue,vn as We,vr as Ge,wn as Ke,y as qe,yr as Je,zn as Ye}from"./src-DCsdXZpS.js";import{I as Xe,K as B,Q as V,S as H,W as U,a as Ze,b as W,o as G,q as K,t as Qe,x as q,z as J}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DTufy7Ue.js";import{A as $e,D as et,L as tt,M as nt,O as rt,X as it,a as at,h as ot,i as st,j as ct,k as lt,z as Y}from"./src-YgttllUb.js";import{c as ut,k as dt,p as X,r as ft,t as pt,u as mt}from"./player-overlays-CJ2EDXmI.js";import{t as ht}from"./CapabilityBadges-CTZ7zqWM.js";import{n as gt,t as _t}from"./rotate-ccw-ildFCltM.js";import{t as vt}from"./ProviderIcon-ClXY1rL4.js";import{a as yt,c as bt,l as xt,n as St,o as Ct}from"./NodeInferenceDevices-D1yIrxri.js";import{n as wt}from"./FormBuilder-ZuE9B0w9.js";import{t as Tt}from"./pencil-CQwfEybQ.js";import{t as Et}from"./plus-BIR1e9Y7.js";import{t as Dt}from"./refresh-cw-DAm7QoFj.js";import{t as Ot}from"./rotate-cw-DyrhB96Y.js";import{t as kt}from"./server-2ReeYjUz.js";import{t as At}from"./wifi-cBAahSiZ.js";import{B as jt,C as Mt,G as Nt,H as Pt,J as Ft,M as It,R as Lt,W as Rt,Y as zt,b as Bt,c as Vt,h as Ht,i as Ut,j as Wt,l as Gt,o as Kt,q as qt,s as Jt,t as Yt,y as Xt}from"./index-BqCgqp9V.js";import{t as Zt}from"./StatusBadge-Dcr2bw58.js";import{t as Qt}from"./useEventInvalidation-BI2Lc7mp.js";import{i as $t,n as en,r as tn,t as nn}from"./DeviceAggregateSection-C6sscd95.js";var rn=Nt(`circle-help`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),an=Nt(`link-2-off`,[[`path`,{d:`M9 17H7A5 5 0 0 1 7 7`,key:`10o201`}],[`path`,{d:`M15 7h2a5 5 0 0 1 4 8`,key:`1d3206`}],[`line`,{x1:`8`,x2:`12`,y1:`12`,y2:`12`,key:`rvw6j4`}],[`line`,{x1:`2`,x2:`22`,y1:`2`,y2:`22`,key:`a6p6uj`}]]),on=Nt(`link-2`,[[`path`,{d:`M9 17H7A5 5 0 0 1 7 7h2`,key:`8i5ue5`}],[`path`,{d:`M15 7h2a5 5 0 1 1 0 10h-2`,key:`1b9ql8`}],[`line`,{x1:`8`,x2:`16`,y1:`12`,y2:`12`,key:`1jonct`}]]),sn=Nt(`power`,[[`path`,{d:`M12 2v10`,key:`mnfbl`}],[`path`,{d:`M18.4 6.6a9 9 0 1 1-12.77.04`,key:`obofu9`}]]),cn=Nt(`volume-2`,[[`path`,{d:`M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z`,key:`uqj9uw`}],[`path`,{d:`M16 9a5 5 0 0 1 0 6`,key:`1q6k2b`}],[`path`,{d:`M19.364 18.364a9 9 0 0 0 0-12.728`,key:`ijwkga`}]]);V();function ln({parentDeviceId:e}){let{t}=Yt(),n=qt(),r=X(),{data:i,isLoading:a,isError:o}=Ct(e),{data:c}=s({deviceId:e},{enabled:Number.isFinite(e)});if(a)return q(`div`,{className:`rounded-lg border border-border bg-surface p-3`,children:q(`p`,{className:`text-[10px] text-foreground-subtle`,children:t(`common.loading`,{defaultValue:`Loading…`})})});if(o)return q(`div`,{className:`rounded-lg border border-border bg-surface p-3`,children:q(`p`,{className:`text-[10px] text-warning`,children:t(`integrations.childrenLoadError`,{defaultValue:`Failed to load children`})})});let l=(i??[]).filter(e=>e.display?.hidden!==!0);if(l.length===0)return null;let u=N(c?.stableId??``,l,c?.childLayout),d=u.ungrouped,f=e=>n(`/devices/${String(e)}`),p=c?.name??``,m=(e,t)=>q(h,{trpc:r.trpcClient,device:{...t,name:ge(t,p)},variant:`minimal`,onNavigate:f},e),g=d.some(e=>!!e.role),_=d.some(e=>!e.role),v=g&&!_?t(`device.accessories`,{defaultValue:`Accessories`}):!g&&_?t(`device.adoptedDevices`,{defaultValue:`Adopted devices`}):t(`device.children`,{defaultValue:`Children`}),y=d.length>0?H(`div`,{className:`rounded-lg border border-border bg-surface p-3`,children:[q(`div`,{className:`text-[10px] font-semibold uppercase tracking-wide text-foreground-subtle mb-1.5`,children:v}),q(`div`,{className:`space-y-1`,children:d.map(e=>m(e.id,e))})]}):null,b=u.disabledSection===void 0?null:q(P,{title:t(`device.disabledSection`,{defaultValue:`Disabled`}),count:u.disabledSection.children.length,defaultOpen:!1,children:q(`div`,{className:`opacity-60 space-y-1`,children:u.disabledSection.children.map(e=>m(e.id,e))})},u.disabledSection.title);return u.sections.length===0?b===null?y:H(`div`,{className:`space-y-2`,children:[y,b]}):H(`div`,{className:`space-y-2`,children:[u.sections.map(e=>q(P,{title:e.title,count:e.children.length,defaultOpen:e.defaultOpen,children:e.children.map(e=>m(e.id,e))},e.title)),y,b]})}function un({deviceName:e,deviceType:t,provider:n,isOnline:r,features:i}){return H(`div`,{className:`flex h-full w-full flex-col items-center justify-center gap-3 rounded-lg border border-dashed border-border bg-surface p-6 text-center`,children:[q(vt,{type:n,size:`lg`}),H(`div`,{children:[q(`div`,{className:`text-sm font-semibold text-foreground`,children:e}),q(`div`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wider mt-0.5`,children:t})]}),H(`div`,{className:`flex items-center gap-2 flex-wrap justify-center`,children:[q(Zt,{status:r?`online`:`offline`}),i.length>0&&q(ht,{capabilities:i})]}),q(`div`,{className:`text-[10px] text-foreground-subtle italic max-w-xs mt-1`,children:`No live view for this device type. Use the Config tab or the shortcut row to interact.`})]})}function dn({deviceId:e}){let t=G(),n=pe({deviceId:e},{refetchInterval:1e4,retry:!1}),r=Ee({onSuccess:()=>{t.invalidateQueries({queryKey:[[`deviceDiscovery`,`listDiscovered`]]}),t.invalidateQueries({queryKey:[[`deviceDiscovery`,`getStatus`]]})}}),i=U(()=>fn(n.data??[]),[n.data]);return H(`div`,{className:`flex h-full w-full flex-col gap-3 p-3 sm:p-4`,children:[H(`div`,{className:`flex flex-wrap items-stretch gap-2 sm:gap-3`,children:[q(pn,{label:`Discovered`,value:i.total,icon:q(Xt,{className:`h-3.5 w-3.5`})}),q(pn,{label:`Adopted`,value:i.adopted,accent:`success`}),q(pn,{label:`Available`,value:i.available,accent:i.available>0?`primary`:void 0}),H(`button`,{type:`button`,onClick:()=>{r.mutateAsync({deviceId:e}).catch(()=>{})},disabled:r.isPending,className:`inline-flex items-center justify-center gap-1.5 rounded-lg border border-border px-3 py-2 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50 self-stretch shrink-0`,children:[r.isPending?q(Mt,{className:`h-3.5 w-3.5 animate-spin`}):q(Dt,{className:`h-3.5 w-3.5`}),q(`span`,{className:`hidden sm:inline`,children:`Discover`})]})]}),H(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-foreground-subtle border-t border-border-subtle pt-2`,children:[q(mn,{icon:q(At,{className:`h-3 w-3 text-emerald-500`}),label:`${i.online} online`}),q(mn,{icon:q(Bt,{className:`h-3 w-3 text-amber-500`}),label:`${i.sleeping} sleeping`}),q(mn,{icon:q(Kt,{className:`h-3 w-3 text-destructive`}),label:`${i.offline} offline`}),i.unknown>0?q(mn,{icon:q(rn,{className:`h-3 w-3 text-foreground-subtle`}),label:`${i.unknown} unknown`}):null]})]})}function fn(e){let t={total:e.length,adopted:0,available:0,online:0,sleeping:0,offline:0,unknown:0};for(let n of e)n.alreadyAdopted?t.adopted+=1:t.available+=1,t[n.status]+=1;return t}function pn({label:e,value:t,icon:n,accent:r}){return H(`div`,{className:`flex flex-1 basis-[140px] min-w-0 flex-col gap-1 rounded-lg border px-2 py-1.5 sm:px-3 sm:py-2 ${r===`success`?`bg-emerald-500/10 border-emerald-500/30 text-emerald-500`:r===`primary`?`bg-primary/10 border-primary/30 text-primary`:`bg-surface-hover border-border text-foreground`}`,children:[H(`div`,{className:`flex items-center gap-1.5 text-[10px] uppercase tracking-wider opacity-70 truncate`,children:[n,q(`span`,{className:`truncate`,children:e})]}),q(`div`,{className:`text-xl sm:text-2xl font-semibold tabular-nums leading-none`,children:t})]})}function mn({icon:e,label:t}){return H(`span`,{className:`inline-flex items-center gap-1`,children:[e,q(`span`,{children:t})]})}function hn({deviceId:e,features:t}){return q(`div`,{className:`flex h-full w-full flex-col items-stretch gap-3 p-3 sm:p-4`,children:q(_,{trpc:X().trpcClient,deviceId:e,features:t})})}function gn({deviceId:e,features:t}){return q(`div`,{className:`flex h-full w-full flex-col items-stretch p-3 sm:p-4`,children:q(d,{trpc:X().trpcClient,deviceId:e,features:t})})}V();function _n({dev:e,busy:t,setBusy:n}){let r=e?.motionTrigger,i=mt(e?.state.motionTrigger),[a,o]=K(!1);if(!r)return null;let s=i?.enabled===!0,c=i!==void 0,l=async()=>{if(t||!c)return;let e=!s;n(!0),o(!0);try{await r.setMotionTrigger({enabled:e})}finally{n(!1),o(!1)}};return H(`button`,{type:`button`,onClick:()=>{l()},disabled:t||!c,title:c?s?`Disable trigger on motion`:`Enable trigger on motion`:`Awaiting state…`,"aria-pressed":s,className:`inline-flex items-center gap-1.5 rounded-full border px-2.5 py-1 text-[11px] font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50 ${s?`border-primary/50 bg-primary/15 text-primary`:`border-border bg-surface text-foreground-subtle hover:text-foreground`}`,children:[q(Rt,{className:`h-3 w-3`}),q(`span`,{children:a?s?`Disabling…`:`Enabling…`:c?s?`On motion: on`:`On motion: off`:`On motion: …`})]})}V();function Z({deviceId:e,deviceType:t,features:n}){let r=X(),i=Ne(t)?.HeroCard??d,a=ut(r.trpcClient,e),o=mt(a?.state.deviceStatus),[s,c]=K(!1),l=o!==void 0&&o.online===!1,u=l?o.lastChangedAt:null;return H(`div`,{className:`flex h-full w-full flex-col items-stretch gap-3 p-3 sm:p-4`,children:[l?q(`div`,{className:`flex justify-center`,children:q(oe,{lastChangedAt:u})}):null,q(i,{trpc:r.trpcClient,deviceId:e,features:n}),q(`div`,{className:`flex justify-center`,children:q(_n,{dev:a,busy:s,setBusy:c})})]})}function vn({deviceId:e}){let t=X(),{data:n,isLoading:r}=yt(e),{data:i,isLoading:a}=Ct(e),o=r||a,s=(i??[]).map(e=>({id:e.id,stableId:e.stableId,type:e.type,name:e.name,features:e.features,...e.sourceInfo?{sourceInfo:{id:e.sourceInfo.id}}:{}})),c=typeof n?.linkDeviceId==`number`?n.linkDeviceId:null,l=typeof n?.primaryChildEntityId==`string`?n.primaryChildEntityId:null;return o?q(`div`,{className:`h-full min-h-32 w-full animate-pulse rounded-lg bg-surface`,"aria-hidden":`true`}):q(`div`,{className:`flex h-full w-full flex-col`,children:q(O,{trpc:t.trpcClient,children:s,linkDeviceId:c,primaryChildEntityId:l})})}var yn={[Y.Switch]:Z,[Y.Siren]:Z,[Y.Light]:Z,[Y.Sensor]:Z,[Y.Button]:Z,[Y.Hub]:dn,[Y.Cover]:hn,[Y.Valve]:Z,[Y.Humidifier]:Z,[Y.WaterHeater]:Z,[Y.Container]:vn,[Y.Lock]:Z,[Y.Fan]:Z,[Y.Thermostat]:Z,[Y.Climate]:Z,[Y.MediaPlayer]:Z,[Y.Control]:Z,[Y.AlarmPanel]:Z,[Y.EventEmitter]:gn,[Y.Notifier]:gn,[Y.Script]:Z,[Y.Automation]:Z,[Y.Presence]:Z,[Y.Update]:Z,[Y.Vacuum]:Z,[Y.LawnMower]:Z,[Y.Weather]:Z,[Y.Image]:Z,[Y.PetFeeder]:Z};function bn(e){return yn[e]??un}function xn(e){return q(bn(e.deviceType),{...e})}function Sn(e){return I(X().trpcClient,e)}V();function Cn(e){let[t,n]=K(`idle`),[r,i]=K(null),a=B(null),o=B(null),s=B(null),c=B(!0),l=Ge(),u=F(),d=Je(),f=Xe(()=>{if(a.current){try{a.current.close()}catch{}a.current=null}if(o.current){for(let e of o.current.getTracks())try{e.stop()}catch{}o.current=null}s.current=null},[]),p=Xe(async()=>{if(t===`idle`)return;n(`stopping`);let r=s.current;if(r&&e!==null)try{await Promise.race([d.mutateAsync({deviceId:e,sessionId:r}),new Promise((e,t)=>setTimeout(()=>t(Error(`server stopSession timeout`)),2e3))])}catch(e){console.warn(`[intercom] server stopSession failed (continuing teardown)`,e)}f(),c.current&&(n(`idle`),i(null))},[t,e,d,f]),m=Xe(async()=>{if(e===null||t!==`idle`&&t!==`error`)return;i(null);let r=null,f=null,m=null;try{n(`requesting-mic`),r=await navigator.mediaDevices.getUserMedia({audio:!0,video:!1}),o.current=r,n(`starting`);let t=await l.mutateAsync({deviceId:e});m=t.sessionId,s.current=m,n(`connecting`),f=new RTCPeerConnection,a.current=f,f.oniceconnectionstatechange=()=>{if(!c.current)return;let e=f.iceConnectionState;e===`connected`||e===`completed`?n(`talking`):(e===`failed`||e===`closed`||e===`disconnected`)&&c.current&&(i(e===`failed`?`WebRTC connection failed`:null),p())};for(let e of r.getAudioTracks())f.addTrack(e,r);await f.setRemoteDescription({type:`offer`,sdp:t.sdpOffer});let d=await f.createAnswer();await f.setLocalDescription(d);let h=f.localDescription?.sdp??d.sdp??``;await u.mutateAsync({deviceId:e,sessionId:m,sdpAnswer:h})}catch(t){let l=t instanceof Error?t.message:String(t);if(console.warn(`[intercom] start failed`,t),f)try{f.close()}catch{}if(r)for(let e of r.getTracks())try{e.stop()}catch{}if(a.current=null,o.current=null,m!==null)try{await d.mutateAsync({deviceId:e,sessionId:m})}catch{}s.current=null,c.current&&(i(l),n(`error`))}},[e,t,l,u,d,p]);return J(()=>(c.current=!0,()=>{c.current=!1;let t=s.current;if(t!==null&&e!==null&&d.mutate({deviceId:e,sessionId:t}),a.current){try{a.current.close()}catch{}a.current=null}if(o.current){for(let e of o.current.getTracks())try{e.stop()}catch{}o.current=null}s.current=null}),[e]),{state:t,error:r,start:m,stop:p,isTalking:t===`talking`}}V();var wn=0;function Q(){return++wn}function Tn(e){switch(e.type){case`system`:return`system`;case`device`:return`#${e.deviceId}`;case`provider`:return e.providerId;case`addon`:return e.addonId}}function En(e){return[``,`Commands`,` help Show this help`,` examples Show usage examples for the current scope`,` context Show every available variable + full API surface`,` clear Clear terminal (also Ctrl+L)`,``,`Shortcuts`,` Enter Execute expression`,` Arrow Up/Down Navigate command history`,` Ctrl+L Clear terminal`,``,`Try: ${{system:` sm.summary() // fleet overview`,device:` device.state.battery.value?.sleeping // sync read`,provider:` devices.map(d => d.name)`,addon:` manifest.version`}[e.type]}`,``,`Top-level objects: sm (SystemMirror), DeviceType, Math, JSON, Date, …`]}function Dn(e){switch(e.type){case`device`:return[``,`── State (sync, zero round-trip) ─────────────────────────`,` device.state.battery.value`,` device.state.battery.value?.percentage`,` device.state.motion.value?.detected`,``,`── Actions (async, through wrapper chain) ────────────────`,` await device.snapshot.getSnapshot({})`,` await device.ptz.move({ direction: 'left', steps: 1 })`,` await device.switch.setState({ on: true })`,``,`── Wait for condition ───────────────────────────────────`,` await sm.waitForState(deviceId, 'battery', s => !s.sleeping, 30_000)`,``,`── Subscribe to changes ─────────────────────────────────`,` const off = device.state.battery.subscribe(s => console.log(s))`,``,`── Quick info ───────────────────────────────────────────`,` info.name device name`,` info.addonId owning addon`,` sm.dump(deviceId) full debug dump`];case`system`:return[``,`── Lookups ──────────────────────────────────────────────`,` sm.getDeviceById(8)`,` sm.getDeviceByName('Sala da pranzo')`,` sm.getDevicesByAddon('reolink')`,` sm.getDevicesByType(DeviceType.Camera)`,``,`── Filters (typed query) ────────────────────────────────`,` sm.query({ addonId: 'reolink', online: true })`,` sm.query({ caps: ['battery', 'snapshot'] })`,` sm.query({ name: /^Cam-/ })`,``,`── Cross-device ─────────────────────────────────────────`,` sm.whereState('battery', s => s.percentage < 20).length`,` sm.mapState('battery', s => s.percentage)`,` sm.countByCap('snapshot')`,``,`── Batch action ─────────────────────────────────────────`,` await sm.invokeCap('snapshot', 'getSnapshot', {}, { parallelism: 4 })`,``,`── Listen ───────────────────────────────────────────────`,` sm.listenCap('motion', (id, s) => console.log(id, s))`,` sm.onDeviceAdded((id, info) => console.log('+', info.name))`,``,`── Diagnostics ──────────────────────────────────────────`,` sm.summary()`,` sm.dump(8)`];case`provider`:return[``,` devices.map(d => d.name)`,` await getIntegration()`,` sm.getDevicesByAddon('<this-addon-id>').length`];case`addon`:return[``,` manifest.name`,` manifest.version`,` declaration`]}}function On(e){let t=[``,`Scope: ${e.type}`,``];switch(e.type){case`system`:return[...t,`Primary API — sm (SystemMirror):`,` sm.getDeviceById(id) DeviceProxy | null (sync)`,` sm.getDeviceByName(name) DeviceProxy | null`,` sm.getDeviceByStableId(sid) DeviceProxy | null`,` sm.getAllDevices() readonly DeviceProxy[]`,` sm.getDeviceInfo(id) DeviceInfo | null`,` sm.summary() fleet stats`,``,`Filters — sm.query({...}):`,` sm.query({ addonId: 'reolink', online: true })`,` sm.query({ caps: ['battery', 'snapshot'] }) // ALL caps required`,` sm.query({ anyCap: ['ptz', 'motion'] }) // ANY cap`,` sm.query({ name: { contains: 'sala' } }) // case-insensitive`,` sm.query({ name: /^Cam-\\d+$/ })`,` sm.query({ type: DeviceType.Camera })`,` sm.query({ parentDeviceId: 8 }) // accessories of cam 8`,` sm.query({ where: (info, dev) => dev.state.battery.value?.sleeping })`,``,`State queries:`,` sm.whereState('battery', s => s.percentage < 20)`,` sm.mapState('battery', s => s.percentage)`,` sm.findState('motion', s => s.detected)`,` sm.countByCap('snapshot')`,``,`Listeners (return unsubscribe fn):`,` sm.listen((id, cap, slice) => …) // every state change`,` sm.listenCap('motion', (id, slice) => …)`,` sm.listenDevice(8, (id, cap, slice) => …)`,` sm.onDeviceAdded((id, info) => …)`,` sm.onDeviceRemoved((id, info) => …)`,``,`Wait primitives:`,` await sm.waitForState(8, 'battery', s => !s.sleeping, 30_000)`,` await sm.waitForDevice(99, 30_000)`,``,`Batch:`,` await sm.invokeCap('snapshot', 'getSnapshot', {}, { parallelism: 4 })`,` await sm.forEachCap('reboot', d => d.reboot.reboot({}))`,``,`Diagnostics:`,` sm.dump(8) debug dump (one device)`,` sm.dump() full fleet dump`,` sm.summary() breakdown by cap/addon/type`,``,`Legacy: deviceRegistry, addonRegistry, eventBus, devices(), addons()`];case`device`:return[...t,`Pre-bound variables:`,` device DeviceProxy for this device (sync state + async methods)`,` deviceId number`,` info DeviceInfo metadata (name, addonId, type, online, …)`,` sm SystemMirror (full cluster view)`,` rawDevice legacy IDevice instance (escape hatch)`,``,`Reactive state (sync, zero round-trip):`,` device.state.battery.value BatteryStatus | undefined`,` device.state.battery.value?.sleeping`,` device.state.battery.value?.percentage`,` device.state.motion.value?.detected`,` device.state.switch.value?.on`,` device.state.brightness.value?.percentage`,` device.state.doorbell.value?.lastPressedAt`,``,`Cap actions (async, through wrapper chain):`,` await device.snapshot.getSnapshot({})`,` await device.snapshot.getSnapshot({ streamId: 'high' })`,` await device.ptz.move({ direction: 'left', steps: 1 })`,` await device.ptz.goToPreset({ presetId: 'home' })`,` await device.switch.setState({ on: true })`,` await device.brightness.setBrightness({ percentage: 60 })`,` await device.reboot.reboot({})`,``,`Subscribe to slice changes:`,` const off = device.state.battery.subscribe(s => console.log(s))`,` // off() to unsubscribe`,``,`Wait for a state condition:`,` await sm.waitForState(deviceId, 'battery', s => !s.sleeping, 30_000)`,``,`Diagnostics:`,` info.name device name`,` info.addonId which addon owns it`,` info.online transport health`,` sm.dump(deviceId) full debug dump (binding + state + info)`];case`provider`:return[...t,`Pre-bound variables:`,` devices Devices belonging to this provider (raw IDevice[])`,` getIntegration() Integration metadata`,``,`For typed device access use the SystemMirror:`,` await getSystemMirror()`,` sm.getDevicesByAddon('this-addon-id')`];case`addon`:return[...t,`Pre-bound variables:`,` manifest { name, version, ... }`,` declaration addon declaration`,` source addon source location`,``,`Examples:`,` manifest.name`,` manifest.version`]}}function kn({scope:e,greeting:t,className:n}){let r=X(),[i,a]=K(()=>{let n=[];return t&&n.push({id:Q(),kind:`info`,text:t}),n.push({id:Q(),kind:`info`,text:`scope: ${Tn(e)} — type help or context for available commands`}),n}),[o,s]=K(``),[c,l]=K([]),[u,d]=K(-1),f=B(null),p=B(null);J(()=>{let e=p.current;e&&(e.scrollTop=e.scrollHeight)},[i]);let m=Xe(()=>{f.current?.focus()},[]),h=Qe({mutationFn:t=>r.trpcClient.repl.execute.mutate({code:t,scope:e}),onSuccess:e=>{let t=e??{},n=typeof t.output==`string`?t.output:e==null?`undefined`:typeof e==`string`?e:JSON.stringify(e,null,2),r=t.type===`error`;a(e=>[...e,{id:Q(),kind:r?`error`:`result`,text:n}])},onError:e=>{let t=e instanceof Error?e.message:String(e);a(e=>[...e,{id:Q(),kind:`error`,text:t}])}});function g(t){let n=t.trim();if(n){if(n===`clear`){a([{id:Q(),kind:`info`,text:`scope: ${Tn(e)}`}]),s(``);return}if(n===`help`){a(t=>[...t,{id:Q(),kind:`input`,text:`> ${n}`},...En(e).map(e=>({id:Q(),kind:`info`,text:e}))]),s(``);return}if(n===`context`){a(t=>[...t,{id:Q(),kind:`input`,text:`> ${n}`},...On(e).map(e=>({id:Q(),kind:`info`,text:e}))]),s(``);return}if(n===`examples`){a(t=>[...t,{id:Q(),kind:`input`,text:`> ${n}`},...Dn(e).map(e=>({id:Q(),kind:`info`,text:e}))]),s(``);return}l(e=>[...e,n]),d(-1),a(e=>[...e,{id:Q(),kind:`input`,text:`> ${n}`}]),s(``),h.mutate(n)}}function _(t){if(t.key===`Enter`){t.preventDefault(),g(o);return}if(t.key===`ArrowUp`){if(t.preventDefault(),c.length===0)return;let e=u===-1?c.length-1:Math.max(0,u-1);d(e),s(c[e]??``);return}if(t.key===`ArrowDown`){if(t.preventDefault(),u===-1)return;let e=u+1;e>=c.length?(d(-1),s(``)):(d(e),s(c[e]??``));return}t.ctrlKey&&t.key===`l`&&(t.preventDefault(),a([{id:Q(),kind:`info`,text:`scope: ${Tn(e)}`}]))}let v={input:`text-zinc-300`,result:`text-emerald-300`,error:`text-red-300`,info:`text-zinc-400`};return H(`div`,{className:`flex flex-col bg-[#0c0a09] rounded-lg border border-border overflow-hidden font-mono text-xs ${n??``}`,onClick:m,children:[H(`div`,{ref:p,className:`flex-1 overflow-y-auto p-3 space-y-1 min-h-[120px]`,children:[i.map(e=>q(`pre`,{className:`whitespace-pre-wrap break-words leading-relaxed ${v[e.kind]}`,children:e.text},e.id)),h.isPending&&q(`span`,{className:`text-zinc-500 animate-pulse`,children:`…thinking`})]}),H(`div`,{className:`flex items-center gap-2 border-t border-zinc-800 px-3 py-2 bg-[#0c0a09]`,children:[q(`span`,{className:`text-emerald-400 flex-shrink-0 select-none font-bold`,children:`>`}),q(`input`,{ref:f,value:o,onChange:e=>s(e.target.value),onKeyDown:_,disabled:h.isPending,placeholder:`device.state.battery.value`,autoFocus:!0,className:`flex-1 bg-transparent text-zinc-100 placeholder:text-zinc-600 focus:outline-none caret-emerald-400 disabled:opacity-50`,spellCheck:!1,autoComplete:`off`,autoCorrect:`off`,autoCapitalize:`off`})]})]})}function An({deviceId:e,intercomAvailable:t=!1}){let n=X(),r=typeof window<`u`?window.location.origin:``,i=Number.isFinite(e),a=Sn(i?e:null),{streams:o,pipelineMetrics:s,createSession:c,sendAnswer:l,handleOffer:u,getIceServers:d,addIceCandidate:f,getIceCandidates:p,closeSession:m,getSessionState:h}=Se(n.trpcClient,i?e:null),g=E(n.trpcClient,i?e:null),_=Cn(i&&t?e:null),v=_.state===`requesting-mic`||_.state===`starting`||_.state===`connecting`||_.state===`stopping`,y=_.isTalking||v,b=()=>{_.state===`idle`||_.state===`error`?_.start():_.state!==`stopping`&&_.stop()},x=ft(),S=ee(),C=typeof window<`u`?window.localStorage.getItem(`camstack_admin_token`):null,w=x.length>0?q(W,{children:x.map(e=>q(`div`,{className:`absolute inset-0`,children:e.node},e.id))}):null;return q(qe,{serverUrl:r,createSession:c,sendAnswer:l,handleOffer:u,getIceServers:d,addIceCandidate:f,getIceCandidates:p,closeSession:m,getSessionState:h,...S.request?{playbackUrl:S.request.url,playbackAuthToken:C,...S.request.label?{playbackLabel:S.request.label}:{},onExitPlayback:()=>S.clear()}:{},streams:o,pipelineMetrics:s,phase:a.phase,detections:a,defaultShowDetections:!0,defaultShowMotion:!0,showPlayStop:!0,snapshotSrc:g.src,...g.src?{posterUrl:g.src}:{},snapshotLoading:g.loading,onRefreshSnapshot:g.refresh,intercomAvailable:t,intercomShown:y,onIntercomToggle:b,extraOverlay:w,chromeless:!0,className:`h-full`})}function jn({deviceId:e,containerDeviceId:t}){return Number.isFinite(e)?q(`div`,{className:`flex flex-col h-full`,children:q(ve,{...t===void 0?{deviceId:e}:{containerDeviceId:t},limit:50,maxHeight:`max-h-full`,showScope:!1,showFilters:!1})}):H(`div`,{className:`flex items-center justify-center h-full text-[11px] text-foreground-subtle italic`,children:[`Device #`,e,` not loaded.`]})}function Mn({deviceId:e}){if(!Number.isFinite(e))return H(`div`,{className:`flex items-center justify-center h-full text-[11px] text-foreground-subtle italic`,children:[`Device #`,e,` not loaded.`]});let t=[`CamStack REPL — device #${e}`,``,` device.state.battery.value sync state read`,` await device.snapshot.getSnapshot({}) cap action`,``,` type 'examples' for more, 'context' for the full API`].join(`
2
- `);return q(kn,{scope:{type:`device`,deviceId:e},greeting:t,className:`h-full border-0 rounded-none`})}function Nn({deviceId:e}){return Number.isFinite(e)?q(`div`,{className:`flex flex-col h-full overflow-y-auto`,children:q(Oe,{deviceId:e,limit:50,maxHeight:`max-h-full`})}):H(`div`,{className:`flex items-center justify-center h-full text-[11px] text-foreground-subtle italic`,children:[`Device #`,e,` not loaded.`]})}function Pn({deviceId:e}){return Number.isFinite(e)?q(`div`,{className:`flex flex-col h-full overflow-y-auto`,children:q(_e,{deviceId:e,limit:50,maxHeight:`max-h-full`})}):H(`div`,{className:`flex items-center justify-center h-full text-[11px] text-foreground-subtle italic`,children:[`Device #`,e,` not loaded.`]})}var Fn={"no-provider":`Not available — nothing in this installation provides it.`,"source-unreachable":`Unknown — the service that owns this did not answer.`};function In({deviceId:e}){let t=G(),{data:n,isLoading:r,error:i}=ce({deviceId:e},{enabled:Number.isFinite(e)});Qt([`pipelineOrchestrator`,`getCameraSwitches`],[`capability.binding-changed`]);let a=u({onSuccess:()=>{t.invalidateQueries({queryKey:[[`pipelineOrchestrator`]]}),t.invalidateQueries({queryKey:[[`deviceManager`]]}),t.invalidateQueries({queryKey:[[`recording`]]})}});return r?H(`div`,{className:`flex items-center gap-2 text-xs text-muted`,children:[q(Mt,{className:`h-3 w-3 animate-spin`}),` Loading camera functions…`]}):i||!n?H(`div`,{className:`flex items-start gap-2 rounded-lg border border-border p-3 text-xs text-muted`,children:[q(Jt,{className:`mt-0.5 h-3 w-3 shrink-0`}),q(`span`,{children:`Camera functions could not be read. Nothing has changed — the switches are not shown rather than shown with a guessed state.`})]}):q(`div`,{className:`flex flex-col gap-2`,children:n.switches.map(t=>q(Ln,{row:t,busy:a.isPending,onToggle:n=>a.mutate({deviceId:e,switchId:t.id,enabled:n})},t.id))})}function Ln({row:e,busy:t,onToggle:n}){let r=e.available&&!e.enabled;return H(`div`,{className:`rounded-lg border p-3 ${r?`border-warning/50 bg-warning/5`:`border-border`}`,children:[H(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[H(`div`,{className:`flex items-center gap-2`,children:[q(`span`,{className:`text-sm font-medium`,children:e.label}),r?q(`span`,{className:`rounded bg-warning/20 px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-warning`,children:`Off`}):null]}),e.available?q(`button`,{type:`button`,disabled:t,onClick:()=>n(!e.enabled),className:`shrink-0 rounded border border-border px-2 py-1 text-xs disabled:opacity-50`,children:e.enabled?`Turn off`:`Turn on`}):q(`span`,{className:`shrink-0 text-[11px] text-muted`,children:e.unavailableReason?Fn[e.unavailableReason]:`Not available.`})]}),q(`p`,{className:`mt-1.5 text-xs leading-snug text-muted`,children:e.costWhenOff})]})}function Rn({deviceId:e}){let t=G(),n=Number.isFinite(e),{data:r}=s({deviceId:e},{enabled:n}),i=typeof r?.type==`string`?r.type:`camera`;Qt([`deviceManager`,`getBindings`],[`capability.binding-changed`]);let{data:a,isLoading:o,isError:c,error:l}=Ke({deviceId:e},{enabled:n}),{data:u}=C({deviceType:i},{enabled:!!i}),d=f({onSuccess:()=>{t.invalidateQueries({queryKey:[[`deviceManager`,`getBindings`]]})}});if(o)return q(`div`,{className:`p-4`,children:q(`div`,{className:`h-20 rounded-lg border border-border bg-surface animate-pulse`})});if(c)return H(`div`,{className:`p-4 text-xs text-red-400`,children:[`Failed to load bindings: `,l instanceof Error?l.message:String(l)]});let p=new Map,m={};for(let e of u??[])m[e.capName]=e.wrappers;for(let e of a?.entries??[])p.set(e.capName,{...e,wrappers:m[e.capName]??[]});for(let e of u??[])p.has(e.capName)||p.set(e.capName,{capName:e.capName,kind:`unbound`,providerAddonId:``,providerNodeId:``,nativeAddonId:``,wrappers:e.wrappers});let h=[...p.values()].toSorted((e,t)=>e.capName.localeCompare(t.capName));if(h.length===0)return H(`div`,{className:`flex flex-col items-center justify-center gap-2 p-8 text-foreground-subtle`,children:[q(gt,{className:`h-8 w-8 opacity-40`}),q(`p`,{className:`text-xs`,children:`No capability providers applicable to this device yet.`}),q(`p`,{className:`text-[10px] opacity-60`,children:`Native providers show up here as soon as the owning addon registers them.`})]});let g=h.filter(e=>e.kind!==`unbound`).length;return H(`div`,{className:`flex flex-col gap-3 p-1`,children:[i===`camera`?H(`section`,{className:`flex flex-col gap-2`,children:[q(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-foreground-subtle`,children:`Camera functions`}),q(In,{deviceId:e})]}):null,H(`div`,{className:`text-[11px] text-foreground-subtle`,children:[q(`span`,{className:`font-medium text-foreground`,children:g}),` of `,h.length,` capabilit`,h.length===1?`y`:`ies`,` bound — rows marked `,q(`em`,{children:`unbound`}),` have a wrapper available you can activate.`]}),q(De,{columns:[{key:`capability`,header:`Capability`,render:e=>q(`span`,{className:`font-mono text-foreground`,children:e.capName})},{key:`kind`,header:`Kind`,render:e=>q(zn,{kind:e.kind})},{key:`provider`,header:`Active Provider`,render:e=>q(`span`,{className:`font-mono text-foreground-subtle`,children:e.providerAddonId||q(`span`,{className:`opacity-40`,children:`—`})})},{key:`node`,header:`Node`,render:e=>e.providerNodeId?q(Bn,{nodeId:e.providerNodeId}):q(`span`,{className:`text-[10px] opacity-40`,children:`—`})},{key:`native`,header:`Native`,render:e=>q(`span`,{className:`font-mono text-foreground-subtle`,children:e.nativeAddonId||q(`span`,{className:`opacity-40`,children:`—`})})},{key:`wrapper`,header:`Wrapper`,render:t=>{let n=t.kind===`wrapped`?t.providerAddonId:null;return q(Vn,{wrappers:t.wrappers,activeWrapperId:n,disabled:d.isPending,onPick:r=>{let i=n===r;d.mutate({deviceId:e,capName:t.capName,wrapperAddonId:r,active:!i})}})}}],rows:h,rowKey:e=>e.capName,minWidthPx:720})]})}function zn({kind:e}){return e===`native`?H(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-success/30 text-success bg-success/5 px-1.5 py-0.5 text-[10px] font-medium`,children:[q(kt,{className:`h-3 w-3`}),`native`]}):e===`wrapped`?H(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-primary/30 text-primary bg-primary/5 px-1.5 py-0.5 text-[10px] font-medium`,children:[q(xt,{className:`h-3 w-3`}),`wrapped`]}):e===`linked`?H(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-warning/30 text-warning bg-warning/5 px-1.5 py-0.5 text-[10px] font-medium`,children:[q(on,{className:`h-3 w-3`}),`linked`]}):H(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-border text-foreground-subtle/70 px-1.5 py-0.5 text-[10px] font-medium`,children:[q(bt,{className:`h-3 w-3`}),`unbound`]})}function Bn({nodeId:e}){return q(`span`,{className:`inline-flex items-center rounded-md border border-border px-1.5 py-0.5 font-mono text-[10px] ${e===`hub`?`text-foreground-subtle`:`text-foreground`}`,children:e})}function Vn({wrappers:e,activeWrapperId:t,disabled:n,onPick:r}){return e.length===0?q(`span`,{className:`text-[10px] opacity-40`,children:`none available`}):q(`div`,{className:`flex flex-wrap gap-1`,children:e.map(e=>{let i=e===t;return H(`button`,{disabled:n,onClick:()=>r(e),title:i?`Click to deactivate (revert to native)`:`Activate wrapper ${e}`,className:`inline-flex items-center gap-1 rounded-md border px-1.5 py-0.5 font-mono text-[10px] transition-colors disabled:opacity-50 ${i?`border-primary/40 bg-primary/10 text-primary`:`border-border text-foreground-subtle hover:text-foreground hover:bg-surface-hover`}`,children:[q(i?Lt:_t,{className:`h-3 w-3`}),e]},e)})})}function Hn({deviceId:e,activeSubTab:t,onSubTabChange:n}){return q(`div`,{className:`flex flex-col gap-3`,children:q(nn,{deviceId:e,activeSubTab:t,onSubTabChange:n})})}V();var Un=new Set([`package-detection`]);function Wn(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 Gn(e){return e?e.modelId!==void 0||e.settings!==void 0:!1}function Kn({deviceId:e,refreshToken:t}){let n=G(),r=X().trpcClient,[a,o]=K(null),[s,c]=K(null),[l,u]=K(null),d=z({deviceId:e},{refetchOnMount:`always`}),f=ye({deviceId:e},{refetchOnMount:`always`}),p=i(void 0,{refetchOnMount:`always`});Qt([`nodes`,`topology`],[`agent.online`,`agent.offline`,`agent.unregistered`,`addon.installed`,`addon.uninstalled`]);let m=M(void 0,{refetchOnMount:`always`}),h=U(()=>{let e=new Set;for(let t of m.data??[])t.isOnline&&e.add(t.id);return e},[m.data]),g=U(()=>(p.data??[]).filter(e=>h.has(e.nodeId)).map(e=>e.nodeId),[p.data,h]),_=g[0]??``,v=ue({nodeId:_},{enabled:_!==``,refetchOnMount:`always`}),y=Ze({enabled:g.length>0,queryKey:[[`pipelineOrchestrator`,`getNodeInferenceDevices`],`device-step`,g.join(`,`),t],queryFn:async()=>{let e={};for(let t of g)try{e[t]=(await r.pipelineOrchestrator.getNodeInferenceDevices.query({nodeId:t})).devices}catch{e[t]=[]}return e}}),b=()=>{n.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCameraSettings`]]}),n.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCameraStepOverrides`]]})},x=S({onSuccess:b}),C=te({onSuccess:b}),ee=U(()=>v.data?ze(v.data):[],[v.data]),w=U(()=>{let e=p.data??[],t=h.size===0?[]:e.filter(e=>h.has(e.nodeId)),n=[];for(let e of t){let t=(y.data?.[e.nodeId]??[]).filter(e=>e.enabled&&e.available);if(t.length>=2)for(let r of t)n.push({agentNodeId:e.nodeId,engineLabel:r.format,deviceKey:r.key,deviceLabel:St(r).label});else n.push({agentNodeId:e.nodeId,engineLabel:t[0]?.format??`(engine unknown)`})}return n},[p.data,y.data,h]),T=(e,t)=>y.data?.[e]?.find(e=>e.key===t)??null,ne=e=>{if(e.deviceKey!==void 0)return e.deviceKey;let t=y.data?.[e.agentNodeId]??[],n=t.filter(e=>e.enabled&&e.available);return n.length>=1?n[0].key:t.find(e=>e.available)?.key??t[0]?.key??null},E=(e,t,n)=>f.data?.[e]?.[t]?.[n]??null,re=e=>{if(Un.has(e))return{kind:`zone-driven`};let t=Wn(v.data??null,e)?.enabledByDefault??!0,n=d.data?.stepToggles?.[e];return{kind:`gate`,effectiveOn:n??t,defaultOn:t,explicit:n!==void 0}},D=(e,t)=>{let n=Wn(v.data??null,e),r=t?.format;if(!(!n||r===void 0))return(n.slot===`detector`?t?.defaultModelId:void 0)??Le(n,r)},ie=(e,t)=>{let n=re(e),r=n.kind===`gate`?n.effectiveOn:!1,i=Wn(v.data??null,e),a=ne(t),o=a===null?null:T(t.agentNodeId,a),s=o?.format;if(!(i?.models.some(e=>s!==void 0&&!!e.formats[s])??!1))return r?{kind:`skip`}:{kind:`na`};let c=a===null?null:E(t.agentNodeId,a,e),l=o?.steps?.[e];return{kind:`enabled`,modelId:c?.modelId??l?.modelId??D(e,o)??`Auto`,overridden:Gn(c)}},O=a&&v.data?Wn(v.data,a.addonId):null,k=a?T(a.agentNodeId,a.deviceKey):null,ae=k?.format??`coreml`,A=a?Gn(E(a.agentNodeId,a.deviceKey,a.addonId)):!1,oe=a?D(a.addonId,k):void 0,j=U(()=>{if(!a||!k)return null;let e=k.steps?.[a.addonId];return{enabled:!0,...e?.modelId===void 0?{}:{modelId:e.modelId},settings:e?.settings??{}}},[a,k]),N=()=>{o(null),c(null)},P=(e,t)=>{let n=ne(t);n!==null&&(o({addonId:e,agentNodeId:t.agentNodeId,deviceKey:n}),c(E(t.agentNodeId,n,e)))},se=(t,n)=>{C.mutate({deviceId:e,addonId:t,enabled:n})},ce=()=>{a&&x.mutate({deviceId:e,agentNodeId:a.agentNodeId,deviceKey:a.deviceKey,addonId:a.addonId,patch:s},{onSuccess:N})},le=()=>{a&&x.mutate({deviceId:e,agentNodeId:a.agentNodeId,deviceKey:a.deviceKey,addonId:a.addonId,patch:null},{onSuccess:N})};if(p.isLoading||_!==``&&v.isLoading)return q(`div`,{className:`text-xs text-foreground-subtle animate-pulse p-4`,children:`Loading pipeline…`});if(w.length===0)return q(`div`,{className:`text-xs text-foreground-subtle p-4`,children:`No online agents.`});if(!v.data)return q(`div`,{className:`text-xs text-foreground-subtle p-4`,children:`Catalog unavailable.`});let F=a!==null&&O!==null&&k!==null;return H(`div`,{className:`relative h-full w-full space-y-3`,children:[H(`div`,{className:`rounded-md border border-border bg-muted/20 px-3 py-2 text-[11px] leading-relaxed text-foreground-subtle`,children:[q(`span`,{className:`font-medium text-foreground`,children:`Gate`}),` (col 1) decides whether this camera runs a step — independent of nodes. Each`,` `,q(`span`,{className:`font-medium text-foreground`,children:`node column`}),` shows the model that node runs; click a cell to pin a per-camera model override for that accelerator. A gated-on step with no model on a device shows a clickable `,q(`span`,{className:`text-amber-500`,children:`⚠ skip`}),` `,`and won't run there.`]}),H(`div`,{className:`rounded-md border border-sky-500/25 bg-sky-500/[0.06] px-3 py-2 text-[11px] leading-relaxed text-foreground-subtle`,children:[q(`span`,{className:`font-medium text-sky-400`,children:`Placement is dynamic.`}),` When a node has multiple inference accelerators, each session is balanced across them per-session at dispatch time — these device columns show each accelerator's effective model (override ?? device default), not a fixed assignment.`]}),q(`div`,{className:F?`md:pr-[360px]`:``,children:ee.length>0?q(Ce,{tree:ee,agents:w,gateFor:re,getCellState:ie,onCellClick:P,selectedCell:a,onSetGate:se,gateBusy:C.isPending,fallbackNodeId:l,onFallbackNodeChange:u}):q(`div`,{className:`text-xs text-foreground-subtle`,children:`Catalog empty.`})}),q(me,{open:F,onClose:N,title:O?.name??``,subtitle:a&&k?`${a.agentNodeId} · ${St(k).label} · ${k.format}`:``,footer:H(W,{children:[q(`button`,{type:`button`,className:`px-3 py-1 text-xs border border-border rounded bg-surface hover:bg-muted text-foreground-subtle disabled:opacity-50`,disabled:!A||x.isPending,onClick:le,children:`Clear override`}),q(`div`,{className:`flex-1`}),q(`button`,{type:`button`,className:`px-3 py-1 text-xs border border-border rounded bg-surface hover:bg-muted`,onClick:N,children:`Cancel`}),q(`button`,{type:`button`,disabled:!a||!j||x.isPending,className:`px-3 py-1 text-xs bg-primary text-primary-foreground rounded disabled:opacity-50`,onClick:ce,children:x.isPending?`Saving…`:`Save`})]}),children:O&&a&&j?q(L,{mode:`device`,addon:O,agentDefault:j,agentNodeId:a.agentNodeId,currentPatch:s,engineFormat:ae,effectiveModelId:oe,onChangePatch:c}):q(`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.`})})]})}var qn=[{id:`object-detection`,label:`Object detection`,icon:`scan-search`},{id:`tracking`,label:`Tracking`,icon:`route`},{id:`motion`,label:`Motion`,icon:`activity`},{id:`stationary`,label:`Stationary`,icon:`square-parking`},{id:`zones`,label:`Zones`,icon:`shapes`},{id:`audio`,label:`Audio`,icon:`volume-2`},{id:`cluster`,label:`Cluster`,icon:`server`}],Jn={"pipeline-object-detection":`object-detection`,"detection-sensitivity":`object-detection`,"onboard-object-detection":`object-detection`,tracking:`tracking`,"tracking-core":`tracking`,"motion-tuning":`motion`,"stationary-objects":`stationary`,occupancy:`stationary`,zones:`zones`,"pipeline-audio":`audio`,"cluster-assignment":`cluster`,"orchestrator-live":`cluster`};function Yn(e){return Jn[e]??`object-detection`}V();var Xn=`steps`,Zn=`settings`,Qn=new Set([Xn,Zn]);function $n(e){return e.location===`top-tab`&&(e.tab===`detection-pipeline`||e.tab===`zones`)}function er({deviceId:e,activeSubTab:t,onSubTabChange:n}){return H(R,{value:t&&Qn.has(t)?t:Xn,onValueChange:Xe(e=>{n?.(e)},[n]),className:`flex flex-col`,children:[H(ke,{className:`flex-shrink-0`,children:[q(xe,{value:Xn,children:`Steps`}),q(xe,{value:Zn,children:`Settings`})]}),q(Fe,{value:Xn,children:q(Kn,{deviceId:e,refreshToken:0})}),q(Fe,{value:Zn,children:q(nn,{deviceId:e,sectionFilter:$n,subTabGrouping:{groupOf:e=>Yn(e.id),tabs:qn}})})]})}function $({label:e,value:t}){return H(`div`,{className:`${dt} flex items-start gap-2 sm:gap-3`,children:[q(`span`,{className:`w-20 sm:w-28 flex-shrink-0 text-[11px] text-foreground-subtle`,children:e}),q(`div`,{className:`flex-1 min-w-0 text-[11px] text-foreground`,children:t})]})}V();function tr({deviceId:e,initialName:t}){let n=G(),[r,i]=K(!1),[a,o]=K(t),[s,c]=K(!1),l=B(null);J(()=>{r||o(t)},[t,r]),J(()=>{r&&l.current?.focus()},[r]);let u=m({onSuccess:()=>{n.invalidateQueries({queryKey:[[`deviceManager`,`getDevice`]]}),n.invalidateQueries({queryKey:[[`deviceManager`,`listAll`]]}),n.invalidateQueries({queryKey:[[`deviceManager`,`getDeviceAggregate`]]})}}),d=async()=>{let n=a.trim();if(n.length===0||n===t){i(!1),o(t);return}c(!0);try{await u.mutateAsync({deviceId:e,name:n}),i(!1)}catch{}finally{c(!1)}},f=()=>{o(t),i(!1)};return r?q($,{label:`Name`,value:H(`div`,{className:`flex items-center gap-1`,children:[q(`input`,{ref:l,type:`text`,value:a,onChange:e=>o(e.target.value),onKeyDown:e=>{e.key===`Enter`?d():e.key===`Escape`&&f()},disabled:s,className:`flex-1 min-w-0 px-1.5 py-0.5 text-[11px] bg-background border border-border rounded focus:outline-none focus:border-primary`}),q(`button`,{type:`button`,onClick:()=>void d(),disabled:s,className:`p-0.5 rounded hover:bg-success/10 text-success disabled:opacity-50`,"aria-label":`Save`,children:q(Lt,{className:`h-3 w-3`})}),q(`button`,{type:`button`,onClick:f,disabled:s,className:`p-0.5 rounded hover:bg-danger/10 text-danger disabled:opacity-50`,"aria-label":`Cancel`,children:q(Ut,{className:`h-3 w-3`})})]})}):q($,{label:`Name`,value:H(`div`,{className:`flex items-center gap-2 group`,children:[q(`span`,{className:`truncate`,children:t}),q(`button`,{type:`button`,onClick:()=>i(!0),className:`p-0.5 rounded text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,"aria-label":`Edit name`,children:q(Tt,{className:`h-3.5 w-3.5`})})]})})}V();function nr({deviceId:e,initialLocation:t}){let n=G(),[r,i]=K(!1),[a,o]=K(t??``),[s,c]=K(!1),l=B(null),{data:u}=ne(void 0,{enabled:r}),d=u??[];J(()=>{r||o(t??``)},[t,r]),J(()=>{r&&l.current?.focus()},[r]);let f=A({onSuccess:()=>{n.invalidateQueries({queryKey:[[`deviceManager`,`getDevice`]]}),n.invalidateQueries({queryKey:[[`deviceManager`,`listAll`]]}),n.invalidateQueries({queryKey:[[`deviceManager`,`getDeviceAggregate`]]}),n.invalidateQueries({queryKey:[[`deviceManager`,`listLocations`]]})}}),p=U(()=>{let e=a.trim().toLowerCase();return e.length===0?d:d.filter(t=>t.toLowerCase()!==e&&t.toLowerCase().includes(e))},[d,a]),m=a.trim().length>0&&!d.some(e=>e.toLowerCase()===a.trim().toLowerCase()),h=async n=>{let r=(n??a).trim(),o=r.length===0?null:r;if(o===(t??null)){i(!1);return}c(!0);try{await f.mutateAsync({deviceId:e,location:o}),i(!1)}catch{}finally{c(!1)}},g=()=>{o(t??``),i(!1)};return r?q($,{label:`Location`,value:H(`div`,{className:`relative`,children:[H(`div`,{className:`flex items-center gap-1`,children:[q(`input`,{ref:l,type:`text`,value:a,onChange:e=>o(e.target.value),onKeyDown:e=>{e.key===`Enter`?h():e.key===`Escape`&&g()},disabled:s,placeholder:`Room / area (or leave empty to clear)`,className:`flex-1 min-w-0 px-1.5 py-0.5 text-[11px] bg-background border border-border rounded focus:outline-none focus:border-primary`}),q(`button`,{type:`button`,onClick:()=>void h(),disabled:s,className:`p-0.5 rounded hover:bg-success/10 text-success disabled:opacity-50`,"aria-label":`Save`,children:q(Lt,{className:`h-3 w-3`})}),q(`button`,{type:`button`,onClick:g,disabled:s,className:`p-0.5 rounded hover:bg-danger/10 text-danger disabled:opacity-50`,"aria-label":`Cancel`,children:q(Ut,{className:`h-3 w-3`})})]}),(p.length>0||m)&&H(`div`,{className:`absolute z-10 left-0 right-0 mt-0.5 max-h-40 overflow-y-auto rounded-md border border-border bg-surface shadow-md`,children:[p.map(e=>H(`button`,{type:`button`,onClick:()=>{o(e),h(e)},className:`w-full flex items-center gap-2 px-2 py-1 text-left text-[11px] hover:bg-surface-hover`,children:[q(wt,{className:`h-3 w-3 text-foreground-subtle flex-shrink-0`}),q(`span`,{className:`truncate`,children:e})]},e)),m&&H(`button`,{type:`button`,onClick:()=>void h(),className:`w-full flex items-center gap-2 px-2 py-1 text-left text-[11px] hover:bg-surface-hover border-t border-border`,children:[q(`span`,{className:`text-foreground-subtle`,children:`Create`}),H(`span`,{className:`font-medium truncate`,children:[`"`,a.trim(),`"`]})]})]})]})}):q($,{label:`Location`,value:H(`div`,{className:`flex items-center gap-2 group`,children:[t?q(`span`,{className:`truncate`,children:t}):q(`span`,{className:`italic text-foreground-subtle`,children:`unset`}),q(`button`,{type:`button`,onClick:()=>i(!0),className:`p-0.5 rounded text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,"aria-label":`Edit location`,children:q(Tt,{className:`h-3.5 w-3.5`})})]})})}V();function rr({deviceId:e}){let t=G(),{data:n}=yt(e),{data:r}=Ct(e),[i,a]=K(null),o=k({onSuccess:()=>{a(null),t.invalidateQueries({queryKey:[[`deviceManager`]]})},onError:e=>{a(`Could not change primary child: ${e.message}`)}});if(n==null||String(n.type??``)!==Y.Container)return null;let s=(r??[]).map(e=>({id:e.id,stableId:e.stableId,type:e.type,name:e.name,...e.sourceInfo?{sourceInfo:{id:e.sourceInfo.id}}:{}}));if(s.length<=1)return null;let c=de(s,typeof n.linkDeviceId==`number`?n.linkDeviceId:null,typeof n.primaryChildEntityId==`string`?n.primaryChildEntityId:null);return H(W,{children:[q($,{label:`Primary child`,value:q(p,{childrenList:s,selectedId:c===null?s[0].id:c.id,onSetPrimary:t=>o.mutate({deviceId:e,primaryChildEntityId:t}),disabled:o.isPending})}),i!==null&&q(`p`,{role:`alert`,className:`px-3 sm:px-4 py-1.5 text-[11px] text-danger`,children:i})]})}V();var ir=[`manufacturer`,`model`,`hardware`,`firmware`,`serialNumber`,`uid`,`mac`,`itemNo`];function ar(e){return e.replace(/([a-z])([A-Z])/g,`$1 $2`).replace(/^./,e=>e.toUpperCase())}function or(e){return e==null?`—`:typeof e==`string`||typeof e==`number`||typeof e==`boolean`?String(e):JSON.stringify(e)}function sr(){let e=T(),t=l(),{data:n}=s({deviceId:e??0},{enabled:e!==null}),{data:r}=Ke({deviceId:e??0},{enabled:e!==null}),i=n??t??null,[a,o]=K(`identity`);if(e===null||!i)return null;let c=String(i.stableId??``),u=String(i.name??``),d=String(i.type??``),f=String(i.addonId??``),p=i.features??[],m=new Set([`device-status`,`feature-probe`,`device-ops`]),h=(r?.entries??[]).filter(e=>e.kind===`native`&&!m.has(e.capName)).map(e=>e.capName),g=p.length>0?p:h,_=i.location??null,v=i.metadata??null,y=v!==null&&Object.keys(v).length>0;return H(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[H(`div`,{className:`border-b border-border px-3 sm:px-4 py-2 flex items-center justify-between gap-3`,children:[q(`h2`,{className:`text-[11px] font-semibold text-foreground uppercase tracking-wider`,children:`Device Info`}),y&&H(`div`,{className:`flex items-center gap-1 rounded-md bg-surface-hover p-0.5`,children:[q(cr,{active:a===`identity`,onClick:()=>o(`identity`),label:`Identity`}),q(cr,{active:a===`hardware`,onClick:()=>o(`hardware`),label:`Hardware`})]})]}),(!y||a===`identity`)&&H(`div`,{className:`divide-y divide-border`,children:[q($,{label:`ID`,value:H(`span`,{className:`font-mono text-[11px] text-foreground`,children:[`#${e}`,H(`span`,{className:`ml-1.5 text-foreground-subtle`,children:[`(`,c,`)`]})]})}),q(tr,{deviceId:e,initialName:u}),q(nr,{deviceId:e,initialLocation:_}),q(rr,{deviceId:e}),q($,{label:`Type`,value:d}),q($,{label:`Provider`,value:q(vt,{type:f,size:`sm`,showLabel:!0})}),q($,{label:`Capabilities`,value:g.length>0?q(ht,{capabilities:g,showLabels:!0}):q(`span`,{className:`text-[11px] text-foreground-subtle`,children:`None`})})]}),y&&a===`hardware`&&q(lr,{metadata:v})]})}function cr({active:e,onClick:t,label:n}){return q(`button`,{type:`button`,onClick:t,className:`px-2 py-0.5 rounded text-[10px] font-medium transition-colors ${e?`bg-surface text-foreground shadow-sm`:`text-foreground-subtle hover:text-foreground`}`,children:n})}function lr({metadata:e}){let t=ir.filter(t=>t in e),n=Object.keys(e).filter(e=>!ir.includes(e)).toSorted(),r=[...t,...n];return H(`div`,{children:[q(`div`,{className:`px-3 sm:px-4 py-1.5 text-[10px] text-foreground-subtle border-b border-border bg-surface-subtle/40`,children:`Auto-populated by the driver on every connect. Read-only.`}),q(`div`,{className:`divide-y divide-border`,children:r.map(t=>q($,{label:ar(t),value:q(`span`,{className:`font-mono text-[11px] text-foreground break-all`,children:or(e[t])})},t))})]})}V();function ur({deviceId:e}){let[t,n]=K(null),r=be({onSuccess:e=>{n(e.changed?`Re-aligned with source — ${e.rebuiltChildren} child${e.rebuiltChildren===1?``:`ren`} rebuilt.`:`Already up to date.`)},onError:e=>n(`Re-sync failed: ${e.message}`)});return H(`div`,{className:`rounded-lg border border-border bg-surface px-4 py-3`,children:[H(`div`,{className:`flex items-center justify-between gap-3`,children:[H(`div`,{children:[q(`h2`,{className:`text-xs font-semibold uppercase tracking-wider text-foreground`,children:`Re-sync`}),q(`p`,{className:`mt-0.5 text-[11px] text-foreground-subtle`,children:`Re-align this device's type, role, capabilities and units with its source.`})]}),H(`button`,{type:`button`,disabled:r.isPending,onClick:()=>{n(null),r.mutate({camDeviceId:e})},className:`inline-flex shrink-0 items-center gap-1.5 rounded-md border border-border bg-background px-3 py-1.5 text-xs font-medium text-foreground hover:bg-surface disabled:opacity-50`,children:[q(Dt,{className:`h-3 w-3 ${r.isPending?`animate-spin`:``}`}),r.isPending?`Re-syncing…`:`Re-sync`]})]}),t!==null&&q(`p`,{className:`mt-2 text-[11px] text-foreground-subtle`,children:t})]})}V();var dr={icon:``,label:``,unit:``,precision:``,hidden:!1};function fr(e){return{icon:e?.icon??``,label:e?.label??``,unit:e?.unit??``,precision:e?.precision===void 0?``:String(e.precision),hidden:e?.hidden===!0}}function pr(e){if(typeof e!=`object`||!e)return;let t=e.unit;return typeof t==`string`?t:void 0}function mr(e){let t=e.precision.trim()===``?void 0:Number.parseInt(e.precision,10),n={...e.icon===``?{}:{icon:e.icon},...e.label.trim()===``?{}:{label:e.label.trim()},...e.unit===``?{}:{unit:e.unit},...t!==void 0&&Number.isFinite(t)?{precision:t}:{},...e.hidden?{hidden:!0}:{}};return Object.keys(n).length===0?null:n}function hr({deviceId:e}){let r=X(),i=G(),{data:a}=s({deviceId:e},{enabled:e>0}),o=typeof a?.role==`string`?a.role:null,c=o===null?void 0:Be[o],l=c?.kind===`numeric`,u=Ae(r.trpcClient,e,o??``),d=c?.kind===`numeric`?c.canonicalUnit:void 0,f=pr(u)??d,p=f===void 0?void 0:st(f),m=U(()=>p===void 0?[]:at(p),[p]),[h,g]=K(null),_=h??fr(a?.display),v=n({onSuccess:()=>{i.invalidateQueries({queryKey:[[`deviceManager`]]})}}),{data:y}=t({},{staleTime:6e4}),b=j({onSuccess:()=>{i.invalidateQueries({queryKey:[[`deviceManager`]]})}});if(a===void 0||o===null)return null;let x=e=>{g({..._,...e})},S=()=>{v.mutate({deviceId:e,display:mr(_)})},C=()=>{g(dr),v.mutate({deviceId:e,display:null})},ee=()=>{let e={..._.icon===``?{}:{icon:_.icon},..._.unit===``?{}:{unit:_.unit},..._.precision.trim()!==``&&Number.isFinite(Number.parseInt(_.precision,10))?{precision:Number.parseInt(_.precision,10)}:{}},t={...y?.defaults??{},[o]:e};b.mutate({defaults:t})},w=Re(o).label,T=Object.keys(Ve);return H(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[q(`div`,{className:`border-b border-border px-4 py-2`,children:q(`h2`,{className:`text-xs font-semibold text-foreground uppercase tracking-wider`,children:`Display`})}),H(`div`,{className:`p-4 space-y-3`,children:[H(`label`,{className:`block`,children:[q(`span`,{className:`text-[11px] text-foreground-subtle`,children:`Icon`}),H(`select`,{className:`mt-1 w-full rounded border border-border bg-surface px-2 py-1 text-sm text-foreground`,value:_.icon,onChange:e=>x({icon:e.target.value}),children:[H(`option`,{value:``,children:[`Default (`,w,`)`]}),T.map(e=>q(`option`,{value:e,children:e},e))]})]}),H(`label`,{className:`block`,children:[q(`span`,{className:`text-[11px] text-foreground-subtle`,children:`Label`}),q(`input`,{type:`text`,className:`mt-1 w-full rounded border border-border bg-surface px-2 py-1 text-sm text-foreground`,placeholder:w,value:_.label,onChange:e=>x({label:e.target.value})})]}),l&&H(`div`,{className:`grid grid-cols-2 gap-3`,children:[H(`label`,{className:`block`,children:[q(`span`,{className:`text-[11px] text-foreground-subtle`,children:`Unit`}),H(`select`,{className:`mt-1 w-full rounded border border-border bg-surface px-2 py-1 text-sm text-foreground`,value:_.unit,onChange:e=>x({unit:e.target.value}),disabled:m.length===0,children:[H(`option`,{value:``,children:[`Source`,f?` (${f})`:``]}),m.map(e=>q(`option`,{value:e,children:e},e))]})]}),H(`label`,{className:`block`,children:[q(`span`,{className:`text-[11px] text-foreground-subtle`,children:`Precision`}),q(`input`,{type:`number`,min:0,max:10,step:1,className:`mt-1 w-full rounded border border-border bg-surface px-2 py-1 text-sm text-foreground`,placeholder:`inherit`,value:_.precision,onChange:e=>x({precision:e.target.value})})]})]}),H(`label`,{className:`flex items-center gap-2`,children:[q(`input`,{type:`checkbox`,checked:_.hidden,onChange:e=>x({hidden:e.target.checked})}),q(`span`,{className:`text-sm text-foreground`,children:`Hide from device lists`})]}),H(`div`,{className:`flex flex-wrap items-center gap-2 pt-1`,children:[q(`button`,{type:`button`,className:`rounded bg-primary px-3 py-1 text-sm font-medium text-primary-foreground disabled:opacity-50`,onClick:S,disabled:v.isPending,children:`Save`}),q(`button`,{type:`button`,className:`rounded border border-border px-3 py-1 text-sm text-foreground-subtle`,onClick:C,disabled:v.isPending,children:`Reset`}),H(`button`,{type:`button`,className:`rounded border border-border px-3 py-1 text-sm text-foreground-subtle`,onClick:ee,disabled:b.isPending,title:`Apply this unit / precision / icon as the default for every ${w} sensor`,children:[`Set as default for all `,w,` sensors`]})]})]})]})}function gr(e){return e<1e3?`${e.toFixed(0)} kbps`:`${(e/1e3).toFixed(1)} Mbps`}function _r({device:e}){let t=qt(),n=typeof e.id==`number`?e.id:null,r=String(e.type??``),i=r===Y.Camera,a=r===Y.Hub,o=typeof e.role==`string`&&e.role.length>0,s=e.features??[],c=s.includes(tt.Resyncable),{data:l}=y({deviceId:n??0},{enabled:n!==null&&i,refetchInterval:5e3}),u=l?.streams??{},d=Object.entries(u),f=s.includes(tt.DoorbellButton),p=Ie(f?{deviceId:n??void 0,historyLimit:10}:void 0),m=p.latest?Date.now()-p.latest.timestamp<3e4:!1;return H(`div`,{className:`space-y-5`,children:[a&&n!==null&&q(Pe,{deviceId:n,onOpenChild:e=>t(`/devices/${e}`)}),c&&n!==null&&q(ur,{deviceId:n}),i&&n!==null&&q(D,{widgetId:`pipeline-orchestrator/pipeline-quick-stats`,host:`device-tab`,deviceId:n}),f&&q(He,{history:p.history,latestIsFresh:m}),i&&n!==null&&q(D,{widgetId:`stream-broker/stream-broker-panel`,host:`device-tab`,deviceId:n}),i&&d.length>0&&H(`div`,{className:`@container rounded-lg border border-border bg-surface overflow-hidden`,style:{containerType:`inline-size`},children:[q(`div`,{className:`border-b border-border px-4 py-2`,children:q(`h2`,{className:`text-xs font-semibold text-foreground uppercase tracking-wider`,children:`Stream Network`})}),q(`div`,{className:`divide-y divide-border`,children:d.map(([e,t])=>H(`div`,{className:`px-4 py-2.5`,children:[H(`div`,{className:`flex items-center gap-2 mb-2`,children:[q(At,{className:`h-3 w-3 text-foreground-subtle`}),q(`span`,{className:`text-[11px] font-medium text-foreground`,children:e})]}),H(`div`,{className:`grid grid-cols-2 @[640px]:grid-cols-4 gap-2`,children:[q(vr,{label:`Nominal`,value:gr(t.nominalBitrateKbps??0)}),q(vr,{label:`Observed`,value:gr(t.observedBitrateKbps??0)}),q(vr,{label:`Peak`,value:gr(t.peakBitrateKbps??0)}),q(vr,{label:`Packet Loss`,value:`${(t.packetLossPercent??0).toFixed(2)}%`,warning:(t.packetLossPercent??0)>1})]})]},e))})]}),q(sr,{}),o&&n!==null&&q(hr,{deviceId:n})]})}function vr({label:e,value:t,warning:n}){return H(`div`,{children:[q(`p`,{className:`text-[10px] text-foreground-subtle`,children:e}),q(`p`,{className:`text-xs font-medium ${n?`text-warning`:`text-foreground`}`,children:t})]})}V();function yr(e,t){if(t===`number`){let t=Number(e);return Number.isNaN(t)?e:t}return t===`boolean`?e===`true`:e}function br(e,t){let n={};for(let r of e)r.key!==``&&r.value!==``&&(n[r.key]=yr(r.value,t));return n}function xr(e,t){return e?.kind===`enum-map`?Object.entries(e.mapping).map(([e,t])=>({key:e,value:String(t)})):t?.kind===`enum`&&t.enumValues?t.enumValues.map(e=>({key:e,value:``})):[{key:``,value:``}]}function Sr(e){return e?.kind===`linear`?{scale:String(e.scale),offset:String(e.offset),clampMin:e.clamp?String(e.clamp[0]):``,clampMax:e.clamp?String(e.clamp[1]):``,useClamp:e.clamp!=null}:{scale:`1`,offset:`0`,clampMin:``,clampMax:``,useClamp:!1}}function Cr(e){return e==null?`identity`:e.kind}function wr({value:e,onChange:t,sourceField:n,targetKind:r}){let[i,a]=K(()=>Cr(e)),[o,s]=K(()=>xr(e,n)),[c,l]=K(()=>e?.kind===`enum-map`&&e.fallback!=null?String(e.fallback):``),[u,d]=K(()=>Sr(e));J(()=>{if(i===`enum-map`&&n?.kind===`enum`&&n.enumValues){let e=n.enumValues;s(t=>e.map(e=>({key:e,value:t.find(t=>t.key===e)?.value??``})))}},[n,i]),J(()=>{if(i===`identity`){t(void 0);return}if(i===`enum-map`){let e=br(o,r),n=c===``?void 0:yr(c,r);t({kind:`enum-map`,mapping:e,...n===void 0?{}:{fallback:n}});return}if(i===`linear`){let e=Number(u.scale),n=Number(u.offset);if(Number.isNaN(e)||Number.isNaN(n))return;let r=Number(u.clampMin),i=Number(u.clampMax),a=u.useClamp&&!Number.isNaN(r)&&!Number.isNaN(i)?[r,i]:void 0;t({kind:`linear`,scale:e,offset:n,...a?{clamp:a}:{}})}},[i,o,c,u,r,t]);let f=e=>{a(e),e===`enum-map`&&s(xr(void 0,n)),e===`linear`&&d(Sr(void 0))},p=(e,t,n)=>{s(r=>r.map((r,i)=>i===e?{...r,[t]:n}:r))},m=()=>s(e=>[...e,{key:``,value:``}]),h=e=>s(t=>t.filter((t,n)=>n!==e));return H(`div`,{className:`flex flex-col gap-3`,children:[H(`div`,{children:[q(`p`,{className:`text-[11px] font-medium text-foreground-subtle mb-1.5`,children:`Transform`}),q(`div`,{className:`flex items-center gap-4`,children:[`identity`,`enum-map`,`linear`].map(e=>H(`label`,{className:`flex items-center gap-1.5 text-xs cursor-pointer`,children:[q(`input`,{type:`radio`,name:`transform-kind`,value:e,checked:i===e,onChange:()=>f(e),className:`accent-primary`}),e===`identity`?`None`:e]},e))})]}),i===`enum-map`&&H(`div`,{className:`flex flex-col gap-2 rounded-md border border-border bg-surface p-3`,children:[q(`p`,{className:`text-[10px] font-medium text-foreground-subtle/70 uppercase tracking-wide`,children:`Key → Value mapping`}),o.map((e,t)=>H(`div`,{className:`flex items-center gap-1.5`,children:[q(`input`,{"aria-label":`enum key ${t}`,type:`text`,value:e.key,readOnly:n?.kind===`enum`,onChange:e=>p(t,`key`,e.target.value),placeholder:`source value`,className:`flex-1 rounded border border-border bg-background px-2 py-1 text-xs font-mono text-foreground focus:border-primary outline-none read-only:opacity-70`}),q(`span`,{className:`text-foreground-subtle/50 text-xs`,children:`→`}),r===`boolean`?H(`select`,{"aria-label":`enum value ${t}`,value:e.value,onChange:e=>p(t,`value`,e.target.value),className:`flex-1 rounded border border-border bg-background px-2 py-1 text-xs text-foreground focus:border-primary outline-none`,children:[q(`option`,{value:``,children:`—`}),q(`option`,{value:`true`,children:`true`}),q(`option`,{value:`false`,children:`false`})]}):q(`input`,{"aria-label":`enum value ${t}`,type:r===`number`?`number`:`text`,value:e.value,onChange:e=>p(t,`value`,e.target.value),placeholder:`target value`,className:`flex-1 rounded border border-border bg-background px-2 py-1 text-xs font-mono text-foreground focus:border-primary outline-none`}),n?.kind!==`enum`&&q(`button`,{type:`button`,onClick:()=>h(t),className:`shrink-0 rounded px-1.5 py-0.5 text-[10px] border border-border/80 text-foreground-subtle hover:text-danger hover:border-danger/50 transition-colors`,children:`✕`})]},t)),n?.kind!==`enum`&&q(`button`,{type:`button`,onClick:m,className:`self-start text-[10px] text-primary/70 hover:text-primary transition-colors`,children:`+ Add row`}),H(`div`,{className:`flex items-center gap-2 pt-1 border-t border-border/50`,children:[q(`label`,{className:`text-[10px] text-foreground-subtle/70 whitespace-nowrap`,children:`Fallback:`}),q(`input`,{type:`text`,value:c,onChange:e=>l(e.target.value),placeholder:`(leave empty for none)`,className:`flex-1 rounded border border-border bg-background px-2 py-0.5 text-xs font-mono text-foreground focus:border-primary outline-none`})]})]}),i===`linear`&&H(`div`,{className:`flex flex-col gap-2 rounded-md border border-border bg-surface p-3`,children:[q(`p`,{className:`text-[10px] font-medium text-foreground-subtle/70 uppercase tracking-wide`,children:`Linear: value × scale + offset`}),H(`div`,{className:`grid grid-cols-2 gap-2`,children:[H(`label`,{className:`flex flex-col gap-0.5`,children:[q(`span`,{className:`text-[10px] text-foreground-subtle`,children:`Scale`}),q(`input`,{type:`number`,value:u.scale,onChange:e=>d(t=>({...t,scale:e.target.value})),className:`rounded border border-border bg-background px-2 py-1 text-xs text-foreground focus:border-primary outline-none`})]}),H(`label`,{className:`flex flex-col gap-0.5`,children:[q(`span`,{className:`text-[10px] text-foreground-subtle`,children:`Offset`}),q(`input`,{type:`number`,value:u.offset,onChange:e=>d(t=>({...t,offset:e.target.value})),className:`rounded border border-border bg-background px-2 py-1 text-xs text-foreground focus:border-primary outline-none`})]})]}),H(`label`,{className:`flex items-center gap-1.5 text-xs cursor-pointer`,children:[q(`input`,{type:`checkbox`,checked:u.useClamp,onChange:e=>d(t=>({...t,useClamp:e.target.checked})),className:`accent-primary`}),q(`span`,{className:`text-foreground-subtle`,children:`Clamp output`})]}),u.useClamp&&H(`div`,{className:`grid grid-cols-2 gap-2`,children:[H(`label`,{className:`flex flex-col gap-0.5`,children:[q(`span`,{className:`text-[10px] text-foreground-subtle`,children:`Min`}),q(`input`,{type:`number`,value:u.clampMin,onChange:e=>d(t=>({...t,clampMin:e.target.value})),className:`rounded border border-border bg-background px-2 py-1 text-xs text-foreground focus:border-primary outline-none`})]}),H(`label`,{className:`flex flex-col gap-0.5`,children:[q(`span`,{className:`text-[10px] text-foreground-subtle`,children:`Max`}),q(`input`,{type:`number`,value:u.clampMax,onChange:e=>d(t=>({...t,clampMax:e.target.value})),className:`rounded border border-border bg-background px-2 py-1 text-xs text-foreground focus:border-primary outline-none`})]})]})]})]})}var Tr=`w-full rounded-md border border-border bg-surface px-2 py-1.5 text-foreground text-xs focus:border-primary outline-none disabled:opacity-50`;function Er({mode:e,idPrefix:t,labelPrefix:n,pickerDevices:r,value:i,onChange:a,search:o,onSearchChange:s}){let{data:c}=we({deviceId:i.sourceId??0},{enabled:i.sourceId!=null}),l=c?.caps??[],u=l.find(e=>e.cap===i.cap)?.fields??[],d=e=>{a(e,(l.find(t=>t.cap===e.cap)?.fields??[]).find(t=>t.path===e.fieldPath))},f=e=>{d({sourceId:e===``?null:Number(e),cap:``,fieldPath:``})},p=e=>{d({sourceId:i.sourceId,cap:e,fieldPath:``})},m=e=>{d({sourceId:i.sourceId,cap:i.cap,fieldPath:e})};return H(W,{children:[e===`global`&&s&&H(`div`,{children:[q(`label`,{htmlFor:`${t}-search`,className:`block text-[11px] font-medium text-foreground-subtle mb-1`,children:`Search devices`}),q(`input`,{id:`${t}-search`,type:`text`,value:o??``,placeholder:`Filter by name, stable id or #id`,onChange:e=>s(e.target.value),className:Tr})]}),H(`div`,{children:[H(`label`,{htmlFor:`${t}-device`,className:`block text-[11px] font-medium text-foreground-subtle mb-1`,children:[n,` device`]}),H(`select`,{id:`${t}-device`,value:i.sourceId??``,onChange:e=>f(e.target.value),className:Tr,children:[q(`option`,{value:``,children:`— select a device —`}),r.map(e=>H(`option`,{value:e.id,children:[e.name??e.stableId,` (#`,e.id,`)`]},e.id))]})]}),H(`div`,{children:[H(`label`,{htmlFor:`${t}-cap`,className:`block text-[11px] font-medium text-foreground-subtle mb-1`,children:[n,` cap`]}),H(`select`,{id:`${t}-cap`,value:i.cap,disabled:i.sourceId==null,onChange:e=>p(e.target.value),className:Tr,children:[q(`option`,{value:``,children:`— select a cap —`}),l.map(e=>q(`option`,{value:e.cap,children:e.cap},e.cap))]})]}),H(`div`,{children:[H(`label`,{htmlFor:`${t}-field`,className:`block text-[11px] font-medium text-foreground-subtle mb-1`,children:[n,` field`]}),H(`select`,{id:`${t}-field`,value:i.fieldPath,disabled:i.cap===``,onChange:e=>m(e.target.value),className:Tr,children:[q(`option`,{value:``,children:`— select a field —`}),u.map(e=>H(`option`,{value:e.path,children:[e.path,` (`,e.kind,`)`]},e.path))]})]})]})}function Dr(e,t){switch(e){case`null`:return{value:null};case`string`:return t===``?null:{value:t};case`number`:{if(t.trim()===``)return null;let e=Number(t);return Number.isFinite(e)?{value:e}:null}case`boolean`:return t===`true`?{value:!0}:t===`false`?{value:!1}:null}}function Or(e){return e===null?`null`:typeof e==`number`?`number`:typeof e==`boolean`?`boolean`:`string`}function kr(e){return e===null?``:String(e)}V();var Ar=`w-full rounded-md border border-border bg-surface px-2 py-1.5 text-foreground text-xs focus:border-primary outline-none disabled:opacity-50`,jr=`min, max, abs, round, floor, ceil, sqrt, pow, clamp, avg, sum, coalesce, age, convert`,Mr=0;function Nr(){return Mr+=1,`b${Mr}`}function Pr(e){return{key:Nr(),name:e,mode:`sibling`,sourceId:null,cap:``,fieldPath:``,search:``,literalType:`number`,literalText:``,sampleText:``}}function Fr(e,t,n){if(e===null)return[Pr(`a`)];let r=[];for(let[i,a]of Object.entries(e.bindings)){if(a.kind===`literal`){r.push({...Pr(i),mode:`literal`,literalType:Or(a.value),literalText:kr(a.value)});continue}if(a.kind===`global`){r.push({...Pr(i),mode:`global`,sourceId:t.find(e=>e.stableId===a.sourceStableId)?.id??null,cap:a.cap,fieldPath:a.fieldPath});continue}r.push({...Pr(i),mode:`sibling`,sourceId:t.find(e=>e.stableId===`${n}-${a.sourceKey}`)?.id??null,cap:a.cap,fieldPath:a.fieldPath})}return r.length>0?r:[Pr(`a`)]}function Ir(e,t,n){if(e.mode===`literal`){let t=Dr(e.literalType,e.literalText);return t===null?null:{kind:`literal`,value:t.value}}let r=t.find(t=>t.id===e.sourceId);if(!r||e.cap===``||e.fieldPath===``)return null;if(e.mode===`global`)return{kind:`global`,sourceStableId:r.stableId,cap:e.cap,fieldPath:e.fieldPath};let i=`${n}-`,a=r.stableId.startsWith(i)?r.stableId.slice(i.length):``;return a===``?null:{kind:`field`,sourceKey:a,cap:e.cap,fieldPath:e.fieldPath}}function Lr(e){if(e.mode===`literal`)return Dr(e.literalType,e.literalText)?.value??null;let t=e.sampleText.trim();if(t===``)return null;let n=Number(t);return Number.isFinite(n)?n:e.sampleText}function Rr({devices:e,siblings:t,targetDeviceId:n,containerStableId:r,initial:i,onChange:a}){let[o,s]=K(i?.expr??``),[c,l]=K(()=>Fr(i,e,r)),u=U(()=>{let t={},n=c.length>0,i=new Set;for(let a of c){let o=a.name.trim();if(o===``||i.has(o)){n=!1;continue}i.add(o);let s=Ir(a,e,r);if(s===null){n=!1;continue}t[o]=s}return{source:{kind:`expression`,expr:o,bindings:t},complete:n}},[c,o,e,r]),d=U(()=>rt({expr:u.source.expr,bindings:u.source.bindings}),[u.source]),f=U(()=>{if(o.trim()===``)return null;let e=lt(o);return e.ok?null:e.error},[o]),p=U(()=>{if(u.source.expr.trim()===``)return null;let e={};for(let t of c){let n=t.name.trim();n!==``&&(e[n]=Lr(t))}return et(u.source.expr,e,Date.now())},[u.source.expr,c]),m=u.complete&&d===null&&o.trim()!==``;J(()=>{a(m?u.source:null)},[m?JSON.stringify(u.source):`null`]);let h=e=>{let t=e.name.trim();return t===``?`required`:ct.test(t)?nt.has(t)?`reserved`:$e.has(t)?`shadows builtin`:c.filter(e=>e.name.trim()===t).length>1?`duplicate`:null:`invalid name`},g=(e,t)=>{l(n=>n.map(n=>n.key===e?{...n,...t}:n))},_=()=>{c.length>=32||l(e=>[...e,Pr(zr(e))])},v=e=>{l(t=>t.length<=1?t:t.filter(t=>t.key!==e))};return H(`div`,{className:`flex flex-col gap-3`,children:[H(`div`,{className:`flex flex-col gap-2`,children:[q(`span`,{className:`text-[10px] font-semibold uppercase tracking-widest text-foreground-subtle/70`,children:`Bindings`}),c.map((r,i)=>q(Br,{row:r,ordinal:i+1,devices:e,siblings:t,targetDeviceId:n,nameError:h(r),onPatch:e=>g(r.key,e),onRemove:()=>v(r.key),canRemove:c.length>1},r.key)),q(`button`,{type:`button`,onClick:_,disabled:c.length>=32,className:`self-start px-2 py-1 rounded-md text-[11px] font-medium border border-border text-foreground-subtle hover:bg-surface-hover disabled:opacity-50`,children:`+ Add binding`})]}),H(`div`,{children:[q(`label`,{htmlFor:`link-expr-input`,className:`block text-[11px] font-medium text-foreground-subtle mb-1`,children:`Expression`}),q(`textarea`,{id:`link-expr-input`,value:o,rows:2,spellCheck:!1,placeholder:`e.g. clamp(avg(a, b) + 5, 0, 100)`,onChange:e=>s(e.target.value),className:`${Ar} font-mono resize-y`}),H(`p`,{className:`mt-1 text-[10px] text-foreground-subtle/60`,children:[`Functions: `,jr]}),f&&q(`p`,{className:`mt-1 text-[10px] text-danger`,children:f}),f===null&&d&&q(`p`,{className:`mt-1 text-[10px] text-danger`,children:d})]}),H(`div`,{className:`rounded-md border border-border bg-surface/50 px-2 py-1.5`,children:[q(`span`,{className:`text-[10px] uppercase tracking-widest text-foreground-subtle/60`,children:`Preview`}),` `,p===null?q(`span`,{className:`text-[11px] text-foreground-subtle/60`,children:`enter an expression`}):p.ok?q(`span`,{className:`font-mono text-[11px] text-foreground`,children:JSON.stringify(p.value)}):q(`span`,{className:`font-mono text-[11px] text-danger`,children:p.error})]})]})}function zr(e){let t=new Set(e.map(e=>e.name.trim()));for(let e=0;e<26;e++){let n=String.fromCharCode(97+e);if(!t.has(n))return n}return`b${e.length+1}`}function Br({row:e,ordinal:t,devices:n,siblings:r,targetDeviceId:i,nameError:a,onPatch:o,onRemove:s,canRemove:c}){let l=e.search.trim().toLowerCase(),u=n.filter(e=>e.id===i?!1:l===``?!0:e.name.toLowerCase().includes(l)||e.stableId.toLowerCase().includes(l)||String(e.id).includes(l)),d=e.mode===`global`?u:r;return H(`div`,{className:`flex flex-col gap-2 rounded-md border border-border/60 p-2`,children:[H(`div`,{className:`flex items-center gap-2`,children:[q(`input`,{type:`text`,"aria-label":`binding ${t} name`,value:e.name,placeholder:`name`,onChange:e=>o({name:e.target.value}),className:`${Ar} max-w-[8rem] font-mono`}),H(`select`,{"aria-label":`binding ${t} mode`,value:e.mode,onChange:e=>{let t=e.target.value;(t===`sibling`||t===`global`||t===`literal`)&&o({mode:t,sourceId:null,cap:``,fieldPath:``,search:``})},className:`${Ar} max-w-[9rem]`,children:[q(`option`,{value:`sibling`,children:`Sibling`}),q(`option`,{value:`global`,children:`Any device`}),q(`option`,{value:`literal`,children:`Literal`})]}),c&&q(`button`,{type:`button`,"aria-label":`remove binding ${t}`,onClick:s,className:`px-2 py-1 rounded-md text-[11px] text-danger hover:bg-surface-hover`,children:`✕`})]}),a&&H(`span`,{className:`text-[10px] text-danger`,children:[`name: `,a]}),e.mode===`literal`?H(`div`,{className:`flex items-center gap-2`,children:[H(`select`,{"aria-label":`binding ${t} literal type`,value:e.literalType,onChange:e=>{let t=e.target.value;(t===`string`||t===`number`||t===`boolean`||t===`null`)&&o({literalType:t,literalText:t===`boolean`?`true`:``})},className:`${Ar} max-w-[7rem]`,children:[q(`option`,{value:`string`,children:`string`}),q(`option`,{value:`number`,children:`number`}),q(`option`,{value:`boolean`,children:`boolean`}),q(`option`,{value:`null`,children:`null`})]}),e.literalType!==`null`&&q(`input`,{type:`text`,"aria-label":`binding ${t} literal value`,value:e.literalText,placeholder:e.literalType===`number`?`e.g. 42`:`value`,onChange:e=>o({literalText:e.target.value}),className:Ar})]}):H(W,{children:[q(Er,{mode:e.mode,idPrefix:`binding-${t}`,labelPrefix:`Binding`,pickerDevices:d,value:{sourceId:e.sourceId,cap:e.cap,fieldPath:e.fieldPath},onChange:e=>o({sourceId:e.sourceId,cap:e.cap,fieldPath:e.fieldPath}),search:e.search,onSearchChange:e=>o({search:e})}),q(`input`,{type:`text`,"aria-label":`binding ${t} sample`,value:e.sampleText,placeholder:`sample value (preview only)`,onChange:e=>o({sampleText:e.target.value}),className:`${Ar} text-[10px]`})]})]})}V();function Vr(e,t,n){return(n===void 0?[e,t]:[e,n,t]).map(e=>e.replace(/[^a-z0-9]/gi,`-`)).join(`-`)}function Hr(e,t,n){let r=`${t}-${e}`;return n.find(e=>e.stableId===r)?.id??null}function Ur(e,t){return t.find(t=>t.stableId===e)?.id??null}function Wr(e){return e==null?`sibling`:e.source.kind===`literal`?`literal`:e.source.kind===`global`?`global`:e.source.kind===`expression`?`expression`:`sibling`}function Gr(e){return e==null||e.source.kind!==`literal`?`string`:Or(e.source.value)}function Kr(e){return e==null||e.source.kind!==`literal`?``:kr(e.source.value)}function qr({deviceId:e,parentDeviceId:t,deviceStableId:n,initial:r,onSave:i,onCancel:a}){let{data:o}=b({}),s=o??[],c=t==null?n:s.find(e=>e.id===t)?.stableId??n,l=s.filter(n=>n.parentDeviceId===t&&n.id!==e),{data:u}=we({deviceId:e,includeSynthesizable:!0}),d=u?.caps??[],f=r!=null&&(r.source.kind===void 0||r.source.kind===`field`)?r.source:null,p=r!=null&&r.source.kind===`global`?r.source:null,m=r!=null&&r.source.kind===`expression`?r.source:null,h=f==null?p==null?null:Ur(p.sourceStableId,s):Hr(f.sourceKey,c,s),[g,_]=K(Wr(r)),[v,y]=K(r?.target.cap??``),[x,S]=K(r?.target.fieldPath??``),[C,ee]=K(r?.target.itemKey??``),[w,T]=K(h),[te,ne]=K((f??p)?.cap??``),[E,re]=K((f??p)?.fieldPath??``),[D,ie]=K(void 0),[O,k]=K(``),[ae,A]=K(Gr(r)),[oe,j]=K(Kr(r)),[M,N]=K(m),[P,se]=K(r?.transform);J(()=>{if((f??p)==null||w!==null||s.length===0)return;let e=f==null?p==null?null:Ur(p.sourceStableId,s):Hr(f.sourceKey,c,s);e!==null&&T(e)},[f,p,w,s,c]);let ce=d.find(e=>e.cap===v)?.fields??[],le=ce.find(e=>e.path===x),F=le?.item===!0,I=O.trim().toLowerCase(),ue=s.filter(t=>t.id===e?!1:I===``?!0:t.name.toLowerCase().includes(I)||t.stableId.toLowerCase().includes(I)||String(t.id).includes(I)),L=g===`global`?ue:l,de=e=>{y(e),S(``),ee(``)},fe=e=>{e!==`sibling`&&e!==`global`&&e!==`literal`&&e!==`expression`||(_(e),T(null),ne(``),re(``),ie(void 0),k(``))},pe=Dr(ae,oe),me=g===`literal`?pe!==null:g===`expression`?M!==null:w!=null&&te!==``&&E!==``,he=v!==``&&x!==``&&(!F||C.trim()!==``)&&me,ge=()=>{if(g===`literal`)return pe===null?null:{kind:`literal`,value:pe.value};if(g===`expression`)return M;let e=s.find(e=>e.id===w);if(!e||te===``||E===``)return null;if(g===`global`)return{kind:`global`,sourceStableId:e.stableId,cap:te,fieldPath:E};let t=`${c}-`;return{sourceKey:e.stableId.startsWith(t)?e.stableId.slice(t.length):``,cap:te,fieldPath:E}},_e=()=>{if(!he)return;let e=ge();if(e===null)return;let t=F?C.trim():void 0;i({id:r?.id??Vr(v,x,t),source:e,target:{cap:v,fieldPath:x,...t===void 0?{}:{itemKey:t}},...P==null?{}:{transform:P}})},R=`w-full rounded-md border border-border bg-surface px-2 py-1.5 text-foreground text-xs focus:border-primary outline-none disabled:opacity-50`;return H(`div`,{className:`flex flex-col gap-4 p-3`,children:[H(`fieldset`,{className:`flex flex-col gap-3`,children:[q(`legend`,{className:`text-[10px] font-semibold uppercase tracking-widest text-foreground-subtle/70 mb-1`,children:`Target (this device)`}),H(`div`,{children:[q(`label`,{htmlFor:`link-target-cap`,className:`block text-[11px] font-medium text-foreground-subtle mb-1`,children:`Target cap`}),H(`select`,{id:`link-target-cap`,value:v,onChange:e=>de(e.target.value),className:R,children:[q(`option`,{value:``,children:`— select a cap —`}),d.map(e=>q(`option`,{value:e.cap,children:e.cap},e.cap))]})]}),H(`div`,{children:[q(`label`,{htmlFor:`link-target-field`,className:`block text-[11px] font-medium text-foreground-subtle mb-1`,children:`Target field`}),H(`select`,{id:`link-target-field`,value:x,disabled:v===``,onChange:e=>S(e.target.value),className:R,children:[q(`option`,{value:``,children:`— select a field —`}),ce.map(e=>q(`option`,{value:e.path,children:e.item===!0?`${e.path} (per item, ${e.kind})`:`${e.path} (${e.kind})`},e.path))]})]}),F&&H(`div`,{children:[q(`label`,{htmlFor:`link-target-item-key`,className:`block text-[11px] font-medium text-foreground-subtle mb-1`,children:`Item key`}),q(`input`,{id:`link-target-item-key`,type:`text`,value:C,placeholder:`e.g. main-brush`,onChange:e=>ee(e.target.value),className:R}),q(`p`,{className:`mt-1 text-[10px] text-foreground-subtle/60`,children:`Links sharing the same item key build one item (e.g. one consumable).`})]})]}),H(`fieldset`,{className:`flex flex-col gap-3`,children:[q(`legend`,{className:`text-[10px] font-semibold uppercase tracking-widest text-foreground-subtle/70 mb-1`,children:`Source`}),H(`div`,{children:[q(`label`,{htmlFor:`link-source-mode`,className:`block text-[11px] font-medium text-foreground-subtle mb-1`,children:`Source mode`}),H(`select`,{id:`link-source-mode`,value:g,onChange:e=>fe(e.target.value),className:R,children:[q(`option`,{value:`sibling`,children:`Sibling device (same container)`}),q(`option`,{value:`global`,children:`Any device`}),q(`option`,{value:`literal`,children:`Literal constant`}),q(`option`,{value:`expression`,children:`Expression (computed)`})]})]}),g===`literal`&&H(W,{children:[H(`div`,{children:[q(`label`,{htmlFor:`link-literal-type`,className:`block text-[11px] font-medium text-foreground-subtle mb-1`,children:`Literal type`}),H(`select`,{id:`link-literal-type`,value:ae,onChange:e=>{let t=e.target.value;(t===`string`||t===`number`||t===`boolean`||t===`null`)&&(A(t),t===`boolean`&&j(`true`),t===`null`&&j(``))},className:R,children:[q(`option`,{value:`string`,children:`string`}),q(`option`,{value:`number`,children:`number`}),q(`option`,{value:`boolean`,children:`boolean`}),q(`option`,{value:`null`,children:`null`})]})]}),ae!==`null`&&(ae===`boolean`?H(`div`,{children:[q(`label`,{htmlFor:`link-literal-value`,className:`block text-[11px] font-medium text-foreground-subtle mb-1`,children:`Literal value`}),H(`select`,{id:`link-literal-value`,value:oe,onChange:e=>j(e.target.value),className:R,children:[q(`option`,{value:`true`,children:`true`}),q(`option`,{value:`false`,children:`false`})]})]}):H(`div`,{children:[q(`label`,{htmlFor:`link-literal-value`,className:`block text-[11px] font-medium text-foreground-subtle mb-1`,children:`Literal value`}),q(`input`,{id:`link-literal-value`,type:`text`,value:oe,placeholder:ae===`number`?`e.g. 42`:`e.g. main-brush`,onChange:e=>j(e.target.value),className:R})]}))]}),g===`expression`&&q(Rr,{devices:s,siblings:l,targetDeviceId:e,containerStableId:c,initial:m,onChange:N}),(g===`sibling`||g===`global`)&&q(Er,{mode:g,idPrefix:`link-source`,labelPrefix:`Source`,pickerDevices:L,value:{sourceId:w,cap:te,fieldPath:E},onChange:(e,t)=>{T(e.sourceId),ne(e.cap),re(e.fieldPath),ie(t)},search:O,onSearchChange:k})]}),q(wr,{value:P,onChange:se,sourceField:g===`literal`||g===`expression`?void 0:D,targetKind:le?.kind}),H(`div`,{className:`flex items-center justify-end gap-2 pt-2 border-t border-border`,children:[q(`button`,{type:`button`,onClick:a,className:`px-3 py-1.5 rounded-md text-xs font-medium border border-border text-foreground-subtle hover:bg-surface-hover hover:text-foreground transition-colors`,children:`Cancel`}),q(`button`,{type:`button`,disabled:!he,onClick:_e,className:`px-3 py-1.5 rounded-md text-xs font-medium bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors`,children:`Save`})]})]})}V();function Jr({deviceId:e}){let t=X(),n=G(),r=Number.isFinite(e),{data:i,isLoading:a}=s({deviceId:e},{enabled:r,refetchInterval:1e4}),{data:o}=we({deviceId:e,includeSynthesizable:!0},{enabled:r}),c=new Map;for(let e of o?.caps??[])e.itemArray&&c.set(e.cap,e.itemArray);let l=Ye({onSuccess:()=>{n.invalidateQueries({queryKey:[[`deviceManager`]]})}}),u=i?.deviceLinks??[],d=typeof i?.parentDeviceId==`number`?i.parentDeviceId:null,f=typeof i?.stableId==`string`?i.stableId:``,[p,m]=K(null),h=t=>{l.mutate({deviceId:e,deviceLinks:u.filter(e=>e.id!==t)})};return a?q(`div`,{className:`p-4`,children:q(`div`,{className:`h-20 rounded-lg border border-border bg-surface animate-pulse`})}):p===null?H(`div`,{className:`flex flex-col gap-3 p-1`,children:[H(`div`,{className:`flex items-center justify-between`,children:[q(`h3`,{className:`text-xs font-semibold uppercase tracking-widest text-foreground-subtle/70`,children:`Wiring`}),H(`button`,{type:`button`,onClick:()=>m(`new`),title:`Add a cross-device link`,className:`inline-flex items-center gap-1 rounded-md border border-border px-2 py-1 text-[10px] text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,children:[q(Et,{className:`h-3 w-3`}),`Add link`]})]}),u.length===0?H(`div`,{className:`flex flex-col items-center justify-center gap-2 py-8 text-foreground-subtle`,children:[q(an,{className:`h-8 w-8 opacity-30`}),q(`p`,{className:`text-xs`,children:`No links yet.`}),q(`p`,{className:`text-[10px] opacity-60`,children:`Cross-device field wirings will appear here once authored.`})]}):q(`div`,{className:`flex flex-col divide-y divide-border rounded-lg border border-border overflow-hidden`,children:u.map(n=>q(Xr,{deviceId:e,link:n,itemArray:c.get(n.target.cap),trpcClient:t.trpcClient,onDelete:()=>h(n.id),onEdit:()=>m(n),isPending:l.isPending},n.id))})]}):H(`div`,{className:`flex flex-col gap-3 p-1`,children:[q(`div`,{className:`flex items-center justify-between`,children:q(`h3`,{className:`text-xs font-semibold uppercase tracking-widest text-foreground-subtle/70`,children:p===`new`?`Add link`:`Edit link`})}),q(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:q(qr,{deviceId:e,parentDeviceId:d,deviceStableId:f,initial:p===`new`?null:p,onSave:t=>{let n=u.some(e=>e.id===t.id)?u.map(e=>e.id===t.id?t:e):[...u,t];l.mutate({deviceId:e,deviceLinks:n}),m(null)},onCancel:()=>{m(null)}})})]})}function Yr(e,t,n,r){let i=ot(e,t.path);if(!Array.isArray(i))return;let a=i.find(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&Reflect.get(e,t.keyField)===n);return a===void 0?void 0:ot(a,r)}function Xr({deviceId:e,link:t,itemArray:n,trpcClient:r,onDelete:i,onEdit:a,isPending:o}){let s=Ae(r,e,t.target.cap),c=t.target.itemKey,l=s===void 0?void 0:c!==void 0&&n!==void 0?Yr(s,n,c,t.target.fieldPath):c===void 0?ot(s,t.target.fieldPath):void 0,u=l==null?`—`:String(l);return H(`div`,{className:`flex items-center gap-3 px-3 py-2.5 bg-surface hover:bg-surface-hover transition-colors`,children:[q(on,{className:`h-3.5 w-3.5 shrink-0 text-foreground-subtle/40`}),H(`div`,{className:`min-w-0 flex-1 flex flex-col gap-0.5`,children:[H(`div`,{className:`flex items-baseline gap-1 flex-wrap`,children:[q(`span`,{className:`font-mono text-[11px] font-medium text-foreground`,children:t.target.cap}),q(`span`,{className:`text-[10px] text-foreground-subtle/60`,children:`.`}),q(`span`,{className:`font-mono text-[11px] text-foreground-subtle`,children:t.target.fieldPath}),c!==void 0&&q(`span`,{className:`rounded bg-surface-hover px-1 py-px font-mono text-[9px] text-foreground-subtle`,title:`Item key — links sharing it build one array item`,children:c})]}),H(`div`,{className:`flex items-baseline gap-1 flex-wrap text-[10px] text-foreground-subtle/70`,children:[q(`span`,{children:`←`}),t.source.kind===`literal`?H(`span`,{className:`font-mono`,children:[`literal: `,String(t.source.value)]}):t.source.kind===`expression`?H(W,{children:[H(`span`,{className:`font-mono`,title:t.source.expr,children:[`ƒ`,` `,t.source.expr.length>40?`${t.source.expr.slice(0,40)}…`:t.source.expr]}),H(`span`,{className:`rounded bg-surface-hover px-1 py-px font-mono text-[9px] text-foreground-subtle`,title:`Number of source bindings`,children:[Object.keys(t.source.bindings).length,` bindings`]})]}):H(W,{children:[q(`span`,{className:`font-mono`,children:t.source.kind===`global`?t.source.sourceStableId:t.source.sourceKey}),q(`span`,{className:`opacity-60`,children:`/`}),q(`span`,{className:`font-mono`,children:t.source.cap}),q(`span`,{className:`opacity-60`,children:`.`}),q(`span`,{className:`font-mono`,children:t.source.fieldPath})]})]})]}),t.transform&&q(Zr,{kind:t.transform.kind}),q(`span`,{className:`font-mono text-[11px] tabular-nums min-w-[2.5rem] text-right text-foreground-subtle`,title:`Live resolved value (from this device's runtime-state slice)`,children:u}),q(`button`,{type:`button`,"aria-label":`Edit link`,title:`Edit this link`,disabled:o,onClick:a,className:`shrink-0 inline-flex items-center gap-1 rounded-md border border-border/80 px-1.5 py-0.5 text-[10px] text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50`,children:`Edit`}),q(`button`,{type:`button`,"aria-label":`Delete link`,title:`Remove this link`,disabled:o,onClick:i,className:`shrink-0 inline-flex items-center gap-1 rounded-md border border-border/80 px-1.5 py-0.5 text-[10px] text-foreground-subtle hover:text-danger hover:border-danger/50 hover:bg-danger/5 transition-colors disabled:opacity-50`,children:`Delete`})]})}function Zr({kind:e}){return q(`span`,{className:`inline-flex items-center rounded-md border border-primary/20 bg-primary/5 px-1.5 py-0.5 font-mono text-[10px] text-primary/80 shrink-0`,children:e})}V();var Qr=[{id:`overview`,label:`Overview`,cameraOnly:!1},{id:`config`,label:`Config`,cameraOnly:!1},{id:`detection-pipeline`,label:`Detection pipeline`,cameraOnly:!0},{id:`bindings`,label:`Bindings`,cameraOnly:!0},{id:`wiring`,label:`Wiring`,cameraOnly:!1}];function $r(e){let t=e===Y.Camera;return Qr.filter(e=>t||!e.cameraOnly).map(({id:e,label:t})=>({id:e,label:t}))}var ei=[{id:`logs`,icon:Ht,label:`Logs`},{id:`repl`,icon:Gt,label:`REPL`},{id:`events`,icon:Pt,label:`Events`},{id:`state`,icon:Wt,label:`State`}];function ti(){let t=Ft(),n=Number(t.deviceId),i=Number.isFinite(n),l=qt(),u=G(),d=g(),f=X(),[p,m]=zt(),h=p.get(`tab`)??`overview`,_=p.get(`sub`),[y,b]=K(`logs`),S=`device-detail.left-col-width-px`,[C,ee]=K(()=>{if(typeof window>`u`)return null;let e=window.localStorage.getItem(S),t=e?Number(e):NaN;return Number.isFinite(t)&&t>0?t:null}),T=B(C);T.current=C;function te(e){e.preventDefault();let t=e.clientX,n=e.currentTarget.previousElementSibling?.getBoundingClientRect().width??C??0,r=Math.max(330,Math.floor(window.innerWidth*.7)),i=e=>{ee(Math.max(280,Math.min(r,n+(e.clientX-t))))},a=()=>{document.removeEventListener(`mousemove`,i),document.removeEventListener(`mouseup`,a);let e=T.current;if(e!==null)try{window.localStorage.setItem(S,String(Math.round(e)))}catch{}document.body.style.userSelect=``,document.body.style.cursor=``};document.body.style.userSelect=`none`,document.body.style.cursor=`col-resize`,document.addEventListener(`mousemove`,i),document.addEventListener(`mouseup`,a)}let{data:ne,isLoading:E,isError:re}=s({deviceId:n},{enabled:i,refetchInterval:5e3,retry:1}),{data:D}=w({deviceId:n},{enabled:i}),O=U(()=>{let e=D?.settings?.sections??[],t=D?.live?.sections??[],n=[...e,...t],r=new Set;for(let e of n)e.location===`top-tab`&&e.tab&&r.add(e.tab===`zones`?`detection-pipeline`:e.tab);return n.some($t)&&r.add(en),[...r].map(e=>e===`export`?{id:e,label:tn,isAddonContrib:!0}:{id:e,label:it[e]?.label??e,isAddonContrib:!0})},[D]),k=ne,A=String(k?.name??t.deviceId??`Device`),oe=k?.online===!0,j=oe?`online`:`offline`,M=String(k?.addonId??`rtsp`),N=k?.features??[],P=k?.type,ce=P===Y.Camera,{data:F}=Ct(i?n:0),I=P===Y.Container,ue=U(()=>(F??[]).map(e=>({id:e.id,stableId:e.stableId,type:e.type,...e.sourceInfo?{sourceInfo:{id:e.sourceInfo.id}}:{}})),[F]),L=U(()=>I?de(ue,typeof k?.linkDeviceId==`number`?k.linkDeviceId:null,typeof k?.primaryChildEntityId==`string`?k.primaryChildEntityId:null)?.id??null:null,[I,ue,k?.linkDeviceId,k?.primaryChildEntityId]),{data:pe}=w({deviceId:L??0},{enabled:L!==null}),me=U(()=>{if(L===null)return[];let e=pe?.settings?.sections??[],t=pe?.live?.sections??[],n=new Set;for(let r of[...e,...t])r.location===`top-tab`&&r.tab&&n.add(r.tab);return[...n].map(e=>({id:e,label:it[e]?.label??e,isAddonContrib:!0,childDeviceId:L}))},[L,pe]),ge=typeof k?.parentDeviceId==`number`?k.parentDeviceId:null,{data:_e}=s({deviceId:ge??0},{enabled:ge!==null}),R=le(),ve=k?.disabled!==!0,{data:ye}=we({deviceId:n},{enabled:i}),be=(ye?.caps.length??0)>0,xe=U(()=>{let e=new Set,t=[];for(let n of[...$r(P),...O,...me])e.has(n.id)||(e.add(n.id),!(n.id===`wiring`&&!be)&&t.push(n));return t},[P,O,me,be]),Se=U(()=>xe.some(e=>e.id===h)?h:`overview`,[xe,h]),Ce=Xe(e=>{m(t=>{let n=new URLSearchParams(t);return e===`overview`?n.delete(`tab`):n.set(`tab`,e),n.delete(`sub`),n},{replace:!0})},[m]),Ee=Xe(e=>{m(t=>{let n=new URLSearchParams(t);return n.set(`sub`,e),n},{replace:!0})},[m]),De=(F??[]).length>0,Oe=U(()=>ei.filter(({featureGate:e})=>!e||N.includes(e)),[N]),{data:z}=he({addonId:M},{enabled:!!M&&M!==`rtsp`}),ke=v({onSuccess:()=>{u.invalidateQueries({queryKey:[[`deviceManager`]]}),l(z?.id?`/integrations/${z.id}`:`/integrations`)}}),Ae=a({onSuccess:()=>{u.invalidateQueries({queryKey:[[`deviceManager`]]})}}),Ne=We({onSuccess:()=>{u.invalidateQueries({queryKey:[[`deviceManager`]]})}}),Pe=je(),Fe=ie({onSuccess:()=>{u.invalidateQueries({queryKey:[[`deviceManager`]]})}}),Ie=N.includes(tt.Rebootable),Le=N.includes(tt.BatteryOperated),Re=e(f.trpcClient,Le&&i?n:null),[ze,Be]=K(!1),Ve=ut(f.trpcClient,i?n:null),He=async()=>{if(!(ze||!Ve)){Be(!0);try{await Ve.snapshot?.invalidateCache({});let e=await Ve.snapshot?.getSnapshot({});if(!e)return;let t=`data:${e.contentType};base64,${e.base64}`,n=e.contentType.includes(`png`)?`png`:`jpg`,r=A.replace(/[^a-zA-Z0-9_.-]+/g,`_`),i=new Date().toISOString().replace(/[:.]/g,`-`),a=document.createElement(`a`);a.href=t,a.download=`${r}-${i}.${n}`,document.body.appendChild(a),a.click(),document.body.removeChild(a)}finally{Be(!1)}}},Ge=Ae.isPending||Ne.isPending,{data:Ke}=fe({deviceId:n},{enabled:i,refetchInterval:1e4}),qe=Ke?.agentNodeId??null,Je=typeof qe==`string`&&qe.length>0&&!qe.startsWith(`addon:`)?qe:void 0,{data:Ye}=ae({deviceId:n,...Je?{nodeId:Je}:{}},{enabled:i,refetchInterval:3e3,retry:!1}),{data:V}=r({deviceId:n},{enabled:i,refetchInterval:3e3,retry:!1}),Ze=V?.level?.dbfs??null;function W(){if(!i)return null;switch(Se){case`overview`:return q(_r,{device:k??{}});case`config`:return q(Hn,{deviceId:n,activeSubTab:_,onSubTabChange:Ee});case`detection-pipeline`:return q(er,{deviceId:n,activeSubTab:_,onSubTabChange:Ee});case`bindings`:return q(Rn,{deviceId:n});case`wiring`:return q(Jr,{deviceId:n});default:{let e=Se,t=O.some(t=>t.id===e),r=me.find(t=>t.id===e);if(!t&&r===void 0)return null;let i=r?.childDeviceId??n;if(e===`export`)return q(nn,{deviceId:n,sectionFilter:$t,activeSubTab:_,onSubTabChange:Ee});let a=q(nn,{deviceId:i,sectionFilter:t=>t.location===`top-tab`&&(t.tab===e||e===`detection-pipeline`&&t.tab===`zones`),flattenSubTabs:e===`detection-pipeline`,activeSubTab:_,onSubTabChange:Ee});return r!==void 0&&i!==n?q(x,{deviceId:i,children:a}):a}}}return i?E?H(`div`,{className:`flex flex-col h-full`,children:[H(`div`,{className:`border-b border-border bg-surface px-6 py-4`,children:[q(`div`,{className:`h-4 w-48 rounded bg-surface-hover animate-pulse mb-3`}),q(`div`,{className:`h-8 w-64 rounded bg-surface-hover animate-pulse`})]}),q(`div`,{className:`flex-1 p-6`,children:q(`div`,{className:`h-40 rounded-lg border border-border bg-surface animate-pulse`})})]}):re||!ne?H(`div`,{className:`flex flex-col items-center justify-center h-full gap-3 text-foreground-subtle`,children:[q(`p`,{className:`text-lg font-semibold text-foreground`,children:`Device not found`}),H(`p`,{className:`text-xs`,children:[`No device with ID`,` `,H(`code`,{className:`font-mono bg-surface px-1.5 py-0.5 rounded text-[11px]`,children:[`#`,n]})]}),q(`button`,{onClick:()=>l(`/integrations`),className:`mt-2 rounded-lg bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 transition-colors`,children:`Back to Integrations`})]}):H(`div`,{className:`absolute inset-0 flex flex-col overflow-hidden`,children:[H(`div`,{className:`border-b border-border bg-surface px-6 py-3 flex-shrink-0`,children:[q(`div`,{className:`mb-2`,children:q(Ue,{items:[{label:`Integrations`,onClick:()=>l(`/integrations`)},{label:z?.name??M,onClick:()=>z?.id&&l(`/integrations/${z.id}`)},{label:A}]})}),H(`div`,{className:`flex items-center gap-2 sm:gap-3`,children:[q(vt,{type:M,size:`lg`}),H(`div`,{className:`min-w-0 flex-1`,children:[H(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[q(`h1`,{className:`text-sm sm:text-base font-semibold text-foreground truncate`,children:A}),q(Zt,{status:j}),Le&&q(se,{status:Re,variant:`full`})]}),ge!==null&&_e&&H(`button`,{type:`button`,onClick:()=>l(`/devices/${ge}`),className:`text-[10px] text-foreground-subtle hover:text-primary transition-colors mt-0.5 inline-flex items-center gap-1`,title:`Open parent device ${_e.name}`,children:[q(`span`,{children:`↑`}),q(`span`,{className:`truncate`,children:String(_e.name??`Device #${ge}`)})]}),q(`div`,{className:`hidden md:flex items-center gap-3 mt-0.5 text-[10px] text-foreground-subtle`,children:N.length>0&&q(ht,{capabilities:N})})]}),Ye&&q(`div`,{className:`hidden lg:flex`,children:q(ni,{metrics:Ye,dbfs:Ze})}),H(`div`,{className:`flex items-center gap-1 shrink-0`,children:[H(`button`,{onClick:async()=>{ve?await d({title:`Disable "${A}"?`,message:`The device will stop processing streams and events. You can re-enable it later.`,confirmLabel:`Disable`,variant:`danger`})&&Ne.mutate({deviceId:n}):Ae.mutate({deviceId:n})},disabled:Ge,title:ve?`Disable device`:`Enable device`,className:`inline-flex items-center gap-1.5 rounded-lg px-2 sm:px-2.5 py-1.5 text-[11px] font-medium border transition-colors disabled:opacity-50 ${ve?`border-success/30 text-success hover:bg-success/10`:`border-border text-foreground-subtle/50 hover:text-foreground hover:bg-surface-hover`}`,children:[q(sn,{className:`h-3.5 w-3.5`}),q(`span`,{className:`hidden sm:inline`,children:Ge?`Updating…`:ve?`Enabled`:`Disabled`})]}),q(`div`,{className:`hidden sm:block h-5 w-px bg-border mx-1`}),q(Te,{triggerClassName:`ml-1`,items:[{id:`snapshot`,label:`Take snapshot`,description:`Fetch a fresh frame and download it.`,icon:jt,disabled:ze,onClick:()=>{He()}},{id:`reboot`,label:`Reboot device`,description:`Camera goes offline for ~30 seconds.`,icon:Ot,hidden:!Ie,disabled:Pe.isPending,danger:!0,onClick:async()=>{await d({title:`Reboot "${A}"?`,message:`The camera will go offline for around 30 seconds while the firmware reboots.`,confirmLabel:`Reboot`,variant:`danger`})&&Pe.mutate({deviceId:n})}},{id:`restart-addon`,label:`Restart addon`,description:`Bounces every device served by ${z?.name??M}.`,icon:Dt,disabled:Fe.isPending,danger:!0,onClick:async()=>{await d({title:`Restart "${z?.name??M}"?`,message:`Restarting the addon will briefly disconnect every device served by it (not just "${A}"). Streams will reconnect automatically.`,confirmLabel:`Restart`,variant:`danger`})&&Fe.mutate({addonId:M})}},{id:`delete`,label:`Delete device`,description:`Remove the device and all its settings.`,icon:Vt,separatorBefore:!0,disabled:ke.isPending,danger:!0,onClick:async()=>{await d({title:`Delete "${A}"?`,message:`This will remove the device and all its settings. This action cannot be undone.`,confirmLabel:`Delete`,variant:`danger`})&&ke.mutate({deviceId:n})}}]})]})]})]}),q(x,{deviceId:n,device:k??void 0,children:q(o,{children:q(c,{children:q(pt,{children:q(Me,{children:H(`main`,{className:R?`flex-1 overflow-y-auto flex flex-col`:`flex-1 min-h-0 overflow-hidden flex flex-row`,children:[H(`div`,{className:R?`flex flex-col bg-surface`:`${C===null?`w-1/2 lg:w-1/3`:``} flex-shrink-0 flex flex-col bg-surface min-h-0 overflow-hidden`,style:!R&&C!==null?{width:`${String(C)}px`}:void 0,children:[q(`div`,{className:ce?`flex-shrink-0 border-b border-border-subtle bg-black`:R?`flex-shrink-0 border-b border-border-subtle bg-surface`:`max-h-[55%] shrink-0 overflow-y-auto border-b border-border-subtle bg-surface`,children:ce?q(An,{deviceId:n,intercomAvailable:N.includes(tt.TwoWayAudio)}):q(xn,{deviceId:n,deviceName:A,deviceType:P??`unknown`,provider:M,isOnline:oe,features:N})}),H(`div`,{className:R?`flex flex-col border-b border-border`:`flex-1 min-h-0 flex flex-col overflow-hidden`,children:[q(`div`,{className:`flex-shrink-0 border-b border-border-subtle px-2 py-1.5`,children:q(`div`,{className:`flex gap-1 overflow-x-auto -mx-1 px-1 pb-0.5`,children:Oe.map(({id:e,label:t,icon:n})=>H(`button`,{onClick:()=>b(e),title:t,className:`flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium transition-colors flex-shrink-0 ${y===e?`bg-primary/15 text-primary`:`text-foreground-subtle hover:text-foreground hover:bg-surface-hover`}`,children:[q(n,{className:`h-3 w-3`}),t]},e))})}),H(`div`,{className:R?`h-72 overflow-hidden`:`flex-1 min-h-0 overflow-hidden`,children:[y===`logs`&&q(jn,{deviceId:n,containerDeviceId:P===`container`?n:void 0}),y===`repl`&&q(Mn,{deviceId:n}),y===`events`&&q(Nn,{deviceId:n}),y===`state`&&q(Pn,{deviceId:n})]})]})]}),!R&&q(`div`,{role:`separator`,"aria-orientation":`vertical`,title:`Drag to resize`,onMouseDown:te,className:`flex-shrink-0 w-1 cursor-col-resize bg-border hover:bg-primary/40 transition-colors group relative z-10`,children:q(`span`,{className:`absolute inset-y-0 -left-1 -right-1`})}),H(`div`,{className:R?`flex flex-col`:`flex-1 min-w-0 min-h-0 flex flex-col overflow-hidden`,children:[q(`div`,{className:`flex-shrink-0 border-b border-border bg-surface px-4`,children:q(`div`,{className:`flex flex-nowrap overflow-x-auto md:flex-wrap md:overflow-x-visible items-center gap-0`,children:xe.map(e=>{let t=Se===e.id;return H(`button`,{onClick:()=>Ce(e.id),className:`relative flex-shrink-0 px-3 py-2 text-xs font-medium transition-colors ${t?`text-primary`:`text-foreground-subtle hover:text-foreground`}`,children:[e.label,t&&q(`span`,{className:`absolute bottom-0 left-0 right-0 h-0.5 rounded-full bg-primary`})]},e.id)})})}),H(`div`,{className:R?`p-3 flex flex-col gap-3`:`flex-1 min-h-0 overflow-y-auto p-4 flex flex-col gap-3`,children:[Se===`overview`&&De&&q(ln,{parentDeviceId:n}),W()]})]})]})})})})})})]}):H(`div`,{className:`flex flex-col items-center justify-center h-full gap-3 text-foreground-subtle`,children:[q(`p`,{className:`text-lg font-semibold text-foreground`,children:`Invalid device id`}),H(`p`,{className:`text-xs`,children:[`The URL segment`,` `,q(`code`,{className:`font-mono bg-surface px-1.5 py-0.5 rounded text-[11px]`,children:t.deviceId}),` `,`is not a number.`]}),q(`button`,{onClick:()=>l(`/integrations`),className:`mt-2 rounded-lg bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 transition-colors`,children:`Back to Integrations`})]})}function ni({metrics:e,dbfs:t}){let n=re(e.phase??`idle`);return H(`div`,{className:`flex items-center gap-3 flex-shrink-0`,children:[H(`div`,{className:`flex items-center gap-1.5`,children:[q(`span`,{className:`h-1.5 w-1.5 rounded-full ${n.dotClass}`}),q(`span`,{className:`text-[10px] font-medium ${n.textColor}`,children:n.label})]}),q(`div`,{className:`h-3 w-px bg-border`}),H(`div`,{className:`flex items-center gap-1 text-[10px] text-foreground-subtle`,children:[q(Rt,{className:`h-3 w-3`}),q(`span`,{className:`text-foreground tabular-nums`,children:(e.actualFps??0).toFixed(1)}),q(`span`,{children:`fps`})]}),H(`div`,{className:`flex items-center gap-1 text-[10px] text-foreground-subtle`,children:[q(It,{className:`h-3 w-3`}),q(`span`,{className:`text-foreground tabular-nums`,children:(e.avgInferenceTimeMs??0).toFixed(0)}),q(`span`,{children:`ms`})]}),H(`div`,{className:`flex items-center gap-1 text-[10px] text-foreground-subtle`,title:`Current audio level (dBFS)`,children:[q(cn,{className:`h-3 w-3`}),q(`span`,{className:`text-foreground tabular-nums`,children:t==null?`—`:t.toFixed(0)}),q(`span`,{children:`dB`})]}),(e.queueDepth??0)>0&&H(`span`,{className:`text-[10px] text-warning tabular-nums`,children:[`q:`,e.queueDepth]})]})}export{ti as DeviceDetailPage};
@@ -1 +0,0 @@
1
- import{G as e}from"./index-BqCgqp9V.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{G as e}from"./index-BqCgqp9V.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};