@camstack/addon-admin-ui 1.2.39 → 1.2.41

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 (110) hide show
  1. package/dist/assets/{AddLocationWizard-OriRyfGb.js → AddLocationWizard-BMebDBIA.js} +1 -1
  2. package/dist/assets/AddonCollectionPage-r3MDTb2U.js +1 -0
  3. package/dist/assets/Addons-IfPdw6C0.js +1 -0
  4. package/dist/assets/{AdminTabs-DM6mL-tM.js → AdminTabs-BN9bq2Fe.js} +1 -1
  5. package/dist/assets/{AiProfiles-Brqvkhl4.js → AiProfiles-CaU_0vCA.js} +1 -1
  6. package/dist/assets/{BrokerForm-B-QT1L9v.js → BrokerForm-pR2D2FEG.js} +1 -1
  7. package/dist/assets/Build-BDfaId30.js +32 -0
  8. package/dist/assets/{Capabilities-BYnCJ_wF.js → Capabilities-DCYvjUOV.js} +1 -1
  9. package/dist/assets/{CapabilityBadges-C5TaGUC8.js → CapabilityBadges-BrUlJxX7.js} +1 -1
  10. package/dist/assets/Cluster-sFTMFphL.js +1 -0
  11. package/dist/assets/{ClusterRecordingTab-BCsf2fwB.js → ClusterRecordingTab-CKyWHM6i.js} +1 -1
  12. package/dist/assets/{Dashboard-r3XlD3RZ.js → Dashboard-jy4FWmQo.js} +1 -1
  13. package/dist/assets/Data-BE3nk7HN.js +1 -0
  14. package/dist/assets/DetectionIntelligence-CVACMVUz.js +1 -0
  15. package/dist/assets/{DeviceAggregateSection-DF9Z2L7S.js → DeviceAggregateSection-BGpxGM1L.js} +1 -1
  16. package/dist/assets/DeviceDetail-BN3ud2_r.js +2 -0
  17. package/dist/assets/{Devices-CaA0QYmI.js → Devices-Xl3xsFW3.js} +1 -1
  18. package/dist/assets/{EmbedPlayerPage-BrIhUfY9.js → EmbedPlayerPage-NqPvTLKU.js} +1 -1
  19. package/dist/assets/Events-Bq860K-k.js +1 -0
  20. package/dist/assets/{FormBuilder-BJU_ZIZk.js → FormBuilder-BrkB_Vuo.js} +1 -1
  21. package/dist/assets/{Identity-BCOzZv52.js → Identity-5C3sPUQm.js} +1 -1
  22. package/dist/assets/IntegrationDetail-TpeJiSq_.js +1 -0
  23. package/dist/assets/Integrations-D7OMgnaW.js +1 -0
  24. package/dist/assets/Integrations-DrSyeMHp.js +1 -0
  25. package/dist/assets/{Logs-CHQXs8Vu.js → Logs-q6ZBX4ns.js} +1 -1
  26. package/dist/assets/{MotionZonesSettings-BjvHQ1e5.js → MotionZonesSettings-blj7QMMa.js} +1 -1
  27. package/dist/assets/{MyAccess-DNymG7pu.js → MyAccess-DtT6FFYG.js} +1 -1
  28. package/dist/assets/Network-Z4oREGTh.js +1 -0
  29. package/dist/assets/{NodeAddonsSettingsPanel-Ba1gsH1f.js → NodeAddonsSettingsPanel-DiBk6Fev.js} +1 -1
  30. package/dist/assets/{NodeInferenceDevices-UGBHLkhA.js → NodeInferenceDevices-LHaBTVxw.js} +1 -1
  31. package/dist/assets/Notifications-BZLN5NsG.js +1 -0
  32. package/dist/assets/Pipeline-Dt2CTPL5.js +1 -0
  33. package/dist/assets/{Plates-CO4B3ixk.js → Plates-z1VqssCX.js} +1 -1
  34. package/dist/assets/{PrivacyMaskSettings-BXIBSDkD.js → PrivacyMaskSettings-BgOgmwS6.js} +1 -1
  35. package/dist/assets/{ProviderIcon-B5LCn3Mf.js → ProviderIcon-D3veqTWe.js} +1 -1
  36. package/dist/assets/Recordings-T7rllaEV.js +1 -0
  37. package/dist/assets/{ScanNetworkModal-B2JsrwAN.js → ScanNetworkModal-o5xFugCK.js} +1 -1
  38. package/dist/assets/{Settings-CpbZOr_5.js → Settings-cx5X8HsR.js} +1 -1
  39. package/dist/assets/{Showroom-DEmabhu2.js → Showroom-CDrrv1TO.js} +1 -1
  40. package/dist/assets/{Terminal-CDDcYkp0.js → Terminal-D5vXOWT2.js} +2 -2
  41. package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-DTslggLS.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-BlAsWS9v.js} +1 -1
  42. package/dist/assets/{boxes-CPXAmMjb.js → boxes-rTzctUbU.js} +1 -1
  43. package/dist/assets/{build-cluster-graph-DVv0t_wf.js → build-cluster-graph-Coy_GdHx.js} +2 -2
  44. package/dist/assets/circle-check-big-CRchJGb3.js +1 -0
  45. package/dist/assets/circle-x-D0bWsIts.js +1 -0
  46. package/dist/assets/clock-C25GXwpo.js +1 -0
  47. package/dist/assets/{copy-C5lJfJcA.js → copy-DySg8B81.js} +1 -1
  48. package/dist/assets/{debounced-invalidate-CEaa4b9p.js → debounced-invalidate-D5kf3uDk.js} +1 -1
  49. package/dist/assets/{dist-oY93oUD8.js → dist-CKpGYpil.js} +1 -1
  50. package/dist/assets/dist-DBLYemqE.js +345 -0
  51. package/dist/assets/{download-Bzkw7O4Z.js → download-CF59Q1Zv.js} +1 -1
  52. package/dist/assets/{face-bbox-BIMrI8Pc.js → face-bbox-DOKrhacR.js} +1 -1
  53. package/dist/assets/{hostInit-Cwmrkw0G.js → hostInit-D_uPN66O.js} +1 -1
  54. package/dist/assets/index-D1Lv9nnm.js +4 -0
  55. package/dist/assets/index-DW7B7QJD.css +2 -0
  56. package/dist/assets/{key-round-BzoMmtbk.js → key-round-DFR8IuYK.js} +1 -1
  57. package/dist/assets/{mf-entry-bootstrap-0-d82c7966.js → mf-entry-bootstrap-0-803942ee.js} +2 -2
  58. package/dist/assets/{pencil-Y8UysE-S.js → pencil-Chd1XFvs.js} +1 -1
  59. package/dist/assets/play-BS6NorXW.js +1 -0
  60. package/dist/assets/{player-overlays-DELm4F-u.js → player-overlays-RSBJ34HJ.js} +1 -1
  61. package/dist/assets/plus-CLA9DCBk.js +1 -0
  62. package/dist/assets/{radio-BHeC3wQq.js → radio-CN2vqo__.js} +1 -1
  63. package/dist/assets/{refresh-cw-Dj7zL6_z.js → refresh-cw-Blid1l_b.js} +1 -1
  64. package/dist/assets/remoteEntry-C9ffs8f0.js +1 -0
  65. package/dist/assets/rotate-ccw-twRh3mwW.js +1 -0
  66. package/dist/assets/rotate-cw-CMVPPwHk.js +1 -0
  67. package/dist/assets/search-BmreiQPf.js +1 -0
  68. package/dist/assets/{send-BBUpM83x.js → send-CInmQKy1.js} +1 -1
  69. package/dist/assets/{server-BI_u9sYY.js → server-CsrhvWyN.js} +1 -1
  70. package/dist/assets/square-BAUrJi-y.js +1 -0
  71. package/dist/assets/{square-check-big-mv0hqUya.js → square-check-big-rQeR1daL.js} +1 -1
  72. package/dist/assets/src-CrugYgqk.js +345 -0
  73. package/dist/assets/src-RAEsAO7u.js +67 -0
  74. package/dist/assets/{undo-2-D0BRjC1S.js → undo-2-DWkYdwKX.js} +1 -1
  75. package/dist/assets/{upload-CI8AxjkJ.js → upload-COgXhe8s.js} +1 -1
  76. package/dist/assets/{useEventInvalidation-D-wl8gip.js → useEventInvalidation-CINRwQED.js} +1 -1
  77. package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-C9fYNixB.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-DZ3nAi20.js} +2 -2
  78. package/dist/assets/{wifi-D-4Fli1P.js → wifi-CRvgXCEx.js} +1 -1
  79. package/dist/assets/{zap-CnvxsMR1.js → zap-Bz2U4Gui.js} +1 -1
  80. package/dist/index.html +6 -6
  81. package/dist/server/addon.js +15057 -14647
  82. package/package.json +1 -1
  83. package/dist/assets/AddonCollectionPage-7y8If9fE.js +0 -1
  84. package/dist/assets/Addons-hU4-qfh2.js +0 -1
  85. package/dist/assets/Build-Dt5OBjW5.js +0 -29
  86. package/dist/assets/Cluster-XbnMe9Pm.js +0 -1
  87. package/dist/assets/Data-BKTmde3A.js +0 -1
  88. package/dist/assets/DetectionIntelligence-BUJk53Nr.js +0 -1
  89. package/dist/assets/DeviceDetail-CsHJjW3e.js +0 -2
  90. package/dist/assets/Events-aoQrd7-L.js +0 -1
  91. package/dist/assets/IntegrationDetail-2L8sysid.js +0 -1
  92. package/dist/assets/Integrations-Dh3w0aKJ.js +0 -1
  93. package/dist/assets/Integrations-vZKrLwHE.js +0 -1
  94. package/dist/assets/Network-D_CsKU8a.js +0 -1
  95. package/dist/assets/Notifications-DILhVkzg.js +0 -1
  96. package/dist/assets/Pipeline-_RMzi7q3.js +0 -1
  97. package/dist/assets/Recordings-BL_kacL0.js +0 -1
  98. package/dist/assets/circle-check-big-CJjIBE-Y.js +0 -1
  99. package/dist/assets/clock-BCe1hJij.js +0 -1
  100. package/dist/assets/dist-Bie7I4Dp.js +0 -7
  101. package/dist/assets/index-C8SRsMDj.js +0 -4
  102. package/dist/assets/index-mdJi1UIz.css +0 -2
  103. package/dist/assets/plus-wHPjAjjI.js +0 -1
  104. package/dist/assets/remoteEntry-RbjAYG4k.js +0 -1
  105. package/dist/assets/rotate-ccw-D5cMUAdd.js +0 -1
  106. package/dist/assets/rotate-cw-D9vE4NZ4.js +0 -1
  107. package/dist/assets/search-BrQOPJ2n.js +0 -1
  108. package/dist/assets/square-E_LF6StT.js +0 -1
  109. package/dist/assets/src-DB2IsJfq.js +0 -67
  110. package/dist/assets/src-wWV0FeEw.js +0 -7
@@ -0,0 +1 @@
1
+ import{Br as e,Ca as t,Fo as n,Gr as r,Hr as i,Mo as a,Mr as o,No as s,Nr as c,Po as l,Sa as u,Ta as d,Ur as f,Vr as p,Wr as m,do as h,g,ki as _,m as v,oo as y,po as b,qi as x,wa as S,zr as C}from"./src-RAEsAO7u.js";import{I as w,K as T,Q as E,S as D,W as O,o as k,q as A,x as j,z as M}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DTufy7Ue.js";import{p as N}from"./player-overlays-RSBJ34HJ.js";import{t as P}from"./pencil-Chd1XFvs.js";import{t as F}from"./radio-CN2vqo__.js";import{t as I}from"./refresh-cw-Blid1l_b.js";import{t as L}from"./rotate-cw-CMVPPwHk.js";import{t as ee}from"./server-CsrhvWyN.js";import{t as R}from"./upload-COgXhe8s.js";import{F as z,G as B,L as te,M as ne,R as re,S as V,V as ie,i as ae,m as H,o as U,s as W,t as G}from"./index-D1Lv9nnm.js";import{n as K,t as q}from"./build-cluster-graph-Coy_GdHx.js";import{t as J}from"./format-size-CO9d3C3-.js";import{t as oe}from"./NodeAddonsSettingsPanel-DiBk6Fev.js";var Y=B(`arrow-down-to-line`,[[`path`,{d:`M12 17V3`,key:`1cwfxf`}],[`path`,{d:`m6 11 6 6 6-6`,key:`12ii2o`}],[`path`,{d:`M19 21H5`,key:`150jfl`}]]),se=B(`git-fork`,[[`circle`,{cx:`12`,cy:`18`,r:`3`,key:`1mpf1b`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`path`,{d:`M18 9v2c0 .6-.4 1-1 1H7c-.6 0-1-.4-1-1V9`,key:`1uq4wg`}],[`path`,{d:`M12 12v3`,key:`158kv8`}]]),ce=B(`hard-drive-download`,[[`path`,{d:`M12 2v8`,key:`1q4o3n`}],[`path`,{d:`m16 6-4 4-4-4`,key:`6wukr`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,key:`w68u3i`}],[`path`,{d:`M6 18h.01`,key:`uhywen`}],[`path`,{d:`M10 18h.01`,key:`h775k`}]]),le=B(`memory-stick`,[[`path`,{d:`M6 19v-3`,key:`1nvgqn`}],[`path`,{d:`M10 19v-3`,key:`iu8nkm`}],[`path`,{d:`M14 19v-3`,key:`kcehxu`}],[`path`,{d:`M18 19v-3`,key:`1vh91z`}],[`path`,{d:`M8 11V9`,key:`63erz4`}],[`path`,{d:`M16 11V9`,key:`fru6f3`}],[`path`,{d:`M12 11V9`,key:`ha00sb`}],[`path`,{d:`M2 15h20`,key:`16ne18`}],[`path`,{d:`M2 7a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v1.1a2 2 0 0 0 0 3.837V17a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-5.1a2 2 0 0 0 0-3.837Z`,key:`lhddv3`}]]),X=B(`skull`,[[`path`,{d:`m12.5 17-.5-1-.5 1h1z`,key:`3me087`}],[`path`,{d:`M15 22a1 1 0 0 0 1-1v-1a2 2 0 0 0 1.56-3.25 8 8 0 1 0-11.12 0A2 2 0 0 0 8 20v1a1 1 0 0 0 1 1z`,key:`1o5pge`}],[`circle`,{cx:`15`,cy:`12`,r:`1`,key:`1tmaij`}],[`circle`,{cx:`9`,cy:`12`,r:`1`,key:`1vctgf`}]]),ue=B(`table-2`,[[`path`,{d:`M9 3H5a2 2 0 0 0-2 2v4m6-6h10a2 2 0 0 1 2 2v4M9 3v18m0 0h10a2 2 0 0 0 2-2V9M9 21H5a2 2 0 0 1-2-2V9m0 0h18`,key:`gugj83`}]]);E();function de(e){let t=new FormData;return t.append(`file`,e.file,e.file.name),t.append(`nodeId`,e.nodeId),e.addonId&&t.append(`addonId`,e.addonId),new Promise((n,r)=>{let i=new XMLHttpRequest;i.open(`POST`,`/api/addons/upload`),e.token&&i.setRequestHeader(`Authorization`,`Bearer ${e.token}`),i.upload.addEventListener(`progress`,t=>{t.lengthComputable&&e.onProgress(Math.round(t.loaded/t.total*100))}),i.addEventListener(`load`,()=>{let e;try{e=JSON.parse(i.responseText)}catch{r(Error(`HTTP ${i.status}`));return}i.status>=200&&i.status<300?n(e):r(Error(e.error??`HTTP ${i.status}`))}),i.addEventListener(`error`,()=>r(Error(`Network error during upload`))),i.addEventListener(`abort`,()=>r(Error(`Upload aborted`))),i.send(t)})}function fe({nodeId:e,addons:t,isHub:n}){let i=k(),a=y(),[o,s]=A(null),[c,l]=A(null),[u,d]=A(!1),[f,m]=A(null),[h,g]=A(0),_=T(null),v=p(),b=r(),x=C({nodeId:e}),S=x.data??[],w=new Map(t.map(e=>[e.id,e.capabilities])),E=S.length>0?S.map(e=>({id:e.id,status:e.status,capabilities:w.get(e.id)??[],version:e.version,packageName:e.packageName})):t.map(e=>({id:e.id,status:e.status,capabilities:e.capabilities,version:void 0,packageName:void 0})),O=()=>{i.invalidateQueries({queryKey:[[`nodes`,`topology`]]}),x.refetch()},M=async t=>{s(t);try{await v.mutateAsync({nodeId:e,addonId:t}),O()}catch(e){console.error(`Failed to restart addon:`,e)}finally{s(null)}},N=async t=>{if(await a({title:`Uninstall addon`,message:`Remove "${t}" from ${e}? The addon directory will be deleted on disk.`,confirmLabel:`Uninstall`,variant:`danger`})){l(t);try{await b.mutateAsync({nodeId:e,addonId:t}),O()}catch(e){console.error(`Failed to uninstall addon:`,e)}finally{l(null)}}},P=D(`div`,{className:`flex items-center gap-2 mb-2`,children:[j(`input`,{ref:_,type:`file`,accept:`.tgz,.tar.gz`,className:`hidden`,onChange:async t=>{let n=t.target.files?.[0];if(n){t.target.value=``,m(null),d(!0),g(0);try{await de({file:n,nodeId:e,token:localStorage.getItem(`camstack_admin_token`),onProgress:g}),O()}catch(e){m(e instanceof Error?e.message:String(e))}finally{d(!1),g(0)}}}}),D(`button`,{onClick:()=>_.current?.click(),disabled:u,className:`inline-flex items-center gap-1.5 rounded-md border border-border px-2.5 py-1 text-[11px] font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50`,children:[u?j(V,{className:`h-3 w-3 animate-spin`}):j(R,{className:`h-3 w-3`}),u?`Uploading… ${h}%`:`Upload addon (.tgz)`]}),u&&j(`div`,{className:`flex-1 h-1 rounded-full bg-muted overflow-hidden max-w-[140px]`,children:j(`div`,{className:`h-full bg-primary transition-all`,style:{width:`${h}%`}})}),f&&j(`span`,{className:`text-[10px] text-destructive`,children:f})]});return E.length===0?D(`div`,{children:[P,j(`div`,{className:`py-4 text-xs text-muted-foreground text-center`,children:x.isLoading?`Loading addons…`:`No addons on this node`})]}):D(`div`,{children:[P,j(`div`,{className:`rounded-lg border border-border max-h-[60vh] overflow-auto`,children:D(`table`,{className:`w-full text-xs`,children:[j(`thead`,{className:`sticky top-0 z-10 bg-surface`,children:D(`tr`,{className:`text-muted-foreground text-left`,children:[j(`th`,{className:`px-3 py-2 font-medium`,children:`Addon`}),j(`th`,{className:`px-3 py-2 font-medium`,children:`Version`}),j(`th`,{className:`px-3 py-2 font-medium`,children:`Capabilities`}),j(`th`,{className:`px-3 py-2 font-medium`,children:`Status`}),j(`th`,{className:`px-3 py-2 font-medium w-16`})]})}),j(`tbody`,{children:E.map(e=>D(`tr`,{className:`border-t border-border/50`,children:[D(`td`,{className:`px-3 py-2 font-medium`,children:[j(`div`,{children:e.id}),e.packageName&&j(`div`,{className:`text-[9px] text-muted-foreground`,children:e.packageName})]}),j(`td`,{className:`px-3 py-2 text-muted-foreground`,children:e.version??`—`}),j(`td`,{className:`px-3 py-2`,children:j(`div`,{className:`flex flex-wrap gap-1`,children:e.capabilities.length>0?e.capabilities.map(e=>j(`span`,{className:`text-[9px] px-1 py-0.5 rounded bg-blue-500/10 text-blue-400`,children:e},e)):j(`span`,{className:`text-muted-foreground`,children:`—`})})}),j(`td`,{className:`px-3 py-2`,children:j(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded-full ${e.status===`running`?`bg-success/10 text-success`:e.status===`error`?`bg-destructive/10 text-destructive`:`bg-muted text-muted-foreground`}`,children:e.status})}),j(`td`,{className:`px-3 py-2`,children:D(`div`,{className:`flex items-center gap-1 justify-end`,children:[j(`button`,{onClick:()=>M(e.id),disabled:o===e.id||c===e.id,className:`p-1 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50`,title:`Restart ${e.id}`,children:j(L,{className:`h-3 w-3 ${o===e.id?`animate-spin`:``}`})}),j(`button`,{onClick:()=>N(e.id),disabled:o===e.id||c===e.id,className:`p-1 rounded hover:bg-destructive/10 text-muted-foreground hover:text-destructive transition-colors disabled:opacity-50`,title:`Uninstall ${e.id}`,children:c===e.id?j(V,{className:`h-3 w-3 animate-spin`}):j(W,{className:`h-3 w-3`})})]})})]},e.id))})]})})]})}E();function pe(e){if(e<60)return`${e}s`;let t=Math.floor(e/60);if(t<60)return`${t}m`;let n=Math.floor(t/60);return n<24?`${n}h ${t%60}m`:`${Math.floor(n/24)}d ${n%24}h`}function me({state:e}){return j(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded-full ${e===`running`?`bg-success/10 text-success`:e===`crashed`||e===`failed`?`bg-destructive/10 text-destructive`:`bg-muted text-muted-foreground`}`,children:e})}var he=[`trace`,`debug`,`info`,`warn`,`error`];function ge({proc:e,nodeId:t,defaultExpanded:r,activePanel:o,onTogglePanel:c}){let u=e.services??[],d=u.length===1,[m,h]=A(d||r),[_,y]=A(null),[b,x]=A(`info`),S=e.name.includes(`(core)`),C=p(),w=i(),T=f(),E=async e=>{y(e);try{await C.mutateAsync({nodeId:t,addonId:e})}catch(e){console.error(`Failed to restart addon:`,e)}finally{y(null)}},O=async()=>{y(e.name);try{await w.mutateAsync({nodeId:t,processName:e.name})}catch(e){console.error(`Failed to restart process:`,e)}finally{y(null)}},k=async n=>{let r=`${t}/${e.name}`;try{await T.mutateAsync({nodeId:r,level:n}),x(n)}catch(e){console.error(`Failed to set log level:`,e)}};return D(`div`,{className:`border border-border/50 rounded-lg overflow-hidden`,children:[D(`div`,{role:d?void 0:`button`,tabIndex:d?void 0:0,onClick:d?void 0:()=>h(!m),onKeyDown:d?void 0:e=>{(e.key===`Enter`||e.key===` `)&&h(!m)},className:`flex items-center gap-2 w-full px-3 py-2 bg-muted/20 transition-colors text-left select-none ${d?``:`hover:bg-muted/40 cursor-pointer`}`,children:[d?j(`span`,{className:`h-3 w-3 shrink-0`}):j(m?te:z,{className:`h-3 w-3 text-muted-foreground shrink-0`}),S?j(ee,{className:`h-3.5 w-3.5 text-primary shrink-0`}):j(ie,{className:`h-3.5 w-3.5 text-amber-500 shrink-0`}),j(`span`,{className:`text-xs font-semibold flex-1`,children:e.name}),D(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:[`PID `,e.pid]}),j(me,{state:e.state}),D(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:[e.cpuPercent,`% CPU`]}),j(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:J(e.memoryRss)}),j(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:pe(e.uptimeSeconds)}),!S&&D(`div`,{className:`flex items-center gap-1`,onClick:e=>e.stopPropagation(),children:[D(a,{children:[j(n,{className:`text-[9px] px-1.5 py-0.5 rounded border border-border text-muted-foreground hover:text-foreground hover:bg-muted transition-colors font-mono`,title:`Set log level`,children:b}),j(s,{align:`end`,className:`min-w-[70px] py-0.5`,children:he.map(e=>j(l,{onClick:()=>k(e),className:`h-auto px-2 py-1 text-[10px] font-mono ${e===b?`text-primary font-semibold`:``}`,children:e},e))})]}),j(`button`,{onClick:O,disabled:_===e.name,className:`p-1 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50`,title:`Restart process`,children:j(L,{className:`h-3 w-3 ${_===e.name?`animate-spin`:``}`})})]})]}),m&&u.length>0&&j(`div`,{className:`divide-y divide-border/30`,children:u.map(e=>D(`div`,{children:[D(`div`,{className:`flex items-center gap-2 px-3 py-1.5 pl-9 hover:bg-muted/10 transition-colors`,children:[j(`div`,{className:`h-1.5 w-1.5 rounded-full shrink-0 ${e.status===`running`?`bg-success`:`bg-muted-foreground/30`}`}),j(`span`,{className:`text-xs font-medium flex-1 min-w-0 truncate`,children:e.addonId}),e.capabilities.length>0&&D(`div`,{className:`flex gap-1 flex-shrink-0`,children:[e.capabilities.slice(0,3).map(e=>j(`span`,{className:`text-[9px] px-1 py-0.5 rounded bg-blue-500/10 text-blue-400 truncate max-w-[80px]`,children:e},e)),e.capabilities.length>3&&D(`span`,{className:`text-[9px] text-muted-foreground`,children:[`+`,e.capabilities.length-3]})]}),D(`div`,{className:`flex items-center gap-1 shrink-0`,children:[j(`button`,{onClick:()=>c(e.addonId,`logs`),className:`p-0.5 rounded transition-colors ${o?.addonId===e.addonId&&o.type===`logs`?`bg-primary/10 text-primary`:`hover:bg-muted text-muted-foreground hover:text-foreground`}`,title:`Show logs for ${e.addonId}`,children:j(H,{className:`h-3 w-3`})}),j(`button`,{onClick:()=>c(e.addonId,`events`),className:`p-0.5 rounded transition-colors ${o?.addonId===e.addonId&&o.type===`events`?`bg-primary/10 text-primary`:`hover:bg-muted text-muted-foreground hover:text-foreground`}`,title:`Show events for ${e.addonId}`,children:j(F,{className:`h-3 w-3`})}),j(`button`,{onClick:()=>E(e.addonId),disabled:_===e.addonId,className:`p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50`,title:`Restart ${e.addonId}`,children:j(L,{className:`h-3 w-3 ${_===e.addonId?`animate-spin`:``}`})})]})]}),o?.addonId===e.addonId&&o.type===`logs`&&j(`div`,{className:`border-t border-border/40 bg-muted/5`,children:j(g,{addonId:e.addonId,agentId:t,maxHeight:`max-h-48`,showFilters:!1,onClose:()=>c(e.addonId,`logs`)})}),o?.addonId===e.addonId&&o.type===`events`&&j(`div`,{className:`border-t border-border/40 bg-muted/5`,children:j(v,{addonId:e.addonId,category:`addon.*`,maxHeight:`max-h-48`,onClose:()=>c(e.addonId,`events`)})})]},e.addonId))}),m&&u.length===0&&j(`div`,{className:`px-3 py-2 pl-9 text-[10px] text-muted-foreground`,children:`No services`})]})}function _e({nodeId:e,processes:t}){let[n,r]=A(null),i=(e,t)=>{r(n=>n?.addonId===e&&n.type===t?null:{addonId:e,type:t})};return t.length===0?j(`div`,{className:`py-4 text-xs text-muted-foreground text-center`,children:`No processes on this node`}):j(`div`,{className:`space-y-2 py-1`,children:t.map((t,r)=>j(ge,{proc:t,nodeId:e,defaultExpanded:r===0,activePanel:n,onTogglePanel:i},t.name))})}E();function ve(e){return e<60?`${e}s`:e<3600?`${Math.floor(e/60)}m ${e%60}s`:e<86400?`${Math.floor(e/3600)}h ${Math.floor(e%3600/60)}m`:`${Math.floor(e/86400)}d ${Math.floor(e%86400/3600)}h`}function ye(e,t=80){return e.length<=t?e:`…${e.slice(e.length-t+1)}`}function be({nodeId:e}){let t=k(),n=y(),[r,i]=A(`all`),a=h(`metrics.node-processes-snapshot`,t=>t.nodeId===e),{data:s}=c({nodeId:e}),l=a?.processes??s,u=O(()=>l?[...l]:[],[l]),d=O(()=>r===`ghost`?u.filter(e=>e.classification===`ghost`):u,[u,r]),f=O(()=>{let e=u.filter(e=>e.classification===`ghost`),t=new Map;for(let n of e)t.has(n.ppid)||t.set(n.ppid,[]),t.get(n.ppid).push(n);return[...t.entries()].filter(([,e])=>e.length>1).map(([e,t])=>({ppid:e,children:t})).toSorted((e,t)=>t.children.length-e.children.length)},[u]),p=o({onSettled:()=>{t.invalidateQueries({queryKey:[[`metricsProvider`,`listNodeProcesses`]]})}}),m=O(()=>{let e=new Map;for(let t of u)e.set(t.pid,t.classification);return e},[u]),g=async(t,r)=>{if(t.classification===`root`||t.classification===`system`)return;let i=t.classification===`ghost`?`ghost`:t.addonId??`process`,a=r?`SIGKILL`:`SIGTERM`;await n({title:`Send ${a}?`,message:`Target pid ${t.pid} (${i}) on node ${e}.`,confirmLabel:`Send ${a}`,variant:`danger`})&&p.mutate({nodeId:e,pid:t.pid,force:r})},_=async(t,n)=>{try{await p.mutateAsync({nodeId:e,pid:t,force:n})}catch{}},v=async r=>{let i=m.get(r.ppid);if(i===`root`||i===`system`){await n({title:`Cannot kill protected ancestor`,message:i===`root`?`pid ${r.ppid} is the current node supervisor. Restart the node via the cluster page instead.`:`pid ${r.ppid} is a system ancestor (concurrently / vite / npm wrapper). Killing it would tear down the dev tree.`,confirmLabel:`OK`,cancelLabel:`Close`,variant:`warning`});return}await n({title:`Kill ghost parent + ${r.children.length} child(ren)?`,message:`SIGKILL parent pid ${r.ppid} and SIGTERM ${r.children.length} ghost child(ren) on node ${e}.`,confirmLabel:`Kill all`,variant:`danger`})&&(await Promise.all([_(r.ppid,!0),...r.children.map(e=>_(e.pid,!1))]),t.invalidateQueries({queryKey:[[`metricsProvider`,`listNodeProcesses`]]}))},b=async()=>{let r=u.filter(e=>e.classification===`ghost`);r.length!==0&&await n({title:`Kill all ${r.length} ghost process(es)?`,message:`SIGKILL ${r.length} ghost process(es) on node ${e}. This is irreversible.`,confirmLabel:`Kill all`,variant:`danger`})&&(await Promise.all(r.map(e=>_(e.pid,!0))),t.invalidateQueries({queryKey:[[`metricsProvider`,`listNodeProcesses`]]}))},x=u.filter(e=>e.classification===`ghost`).length,S=u.filter(e=>e.classification===`managed`).length,C=u.filter(e=>e.classification===`root`).length,w=u.filter(e=>e.classification===`system`).length;return D(`div`,{className:`space-y-4`,children:[D(`div`,{className:`flex items-start justify-between gap-4`,children:[D(`p`,{className:`text-[11px] text-foreground-subtle`,children:[`ps`," scan + kernel `$process.list` cross-reference. Ghosts = camstack-shaped commands with no managed binding (usually orphaned to ppid=1). Refreshes every 10s."]}),D(`button`,{type:`button`,onClick:()=>t.invalidateQueries({queryKey:[[`metricsProvider`,`listNodeProcesses`]]}),className:`inline-flex items-center gap-1 rounded border border-border px-2 py-1 text-[11px] text-foreground hover:bg-surface-hover`,children:[j(I,{className:`h-3 w-3`}),` Refresh`]})]}),D(`div`,{className:`grid grid-cols-4 gap-3`,children:[D(`div`,{className:`rounded-lg border border-border p-3`,children:[j(`div`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle`,children:`Root`}),j(`div`,{className:`text-xl font-semibold text-foreground`,children:C})]}),D(`div`,{className:`rounded-lg border border-border p-3`,children:[j(`div`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle`,children:`Managed`}),j(`div`,{className:`text-xl font-semibold text-foreground`,children:S})]}),D(`div`,{className:`rounded-lg border border-border p-3`,children:[j(`div`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle`,children:`System`}),j(`div`,{className:`text-xl font-semibold text-foreground`,children:w})]}),D(`div`,{className:`rounded-lg border p-3 ${x>0?`border-destructive/40 bg-destructive/5`:`border-border`}`,children:[D(`div`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle flex items-center gap-1`,children:[x>0&&j(X,{className:`h-3 w-3 text-destructive`}),` Ghosts`]}),j(`div`,{className:`text-xl font-semibold ${x>0?`text-destructive`:`text-foreground`}`,children:x})]})]}),f.length>0&&D(`div`,{className:`rounded-lg border border-amber-500/40 bg-amber-500/5 p-3`,children:[D(`div`,{className:`flex items-center gap-1 text-[11px] font-semibold text-amber-400 mb-2`,children:[j(U,{className:`h-3 w-3`}),` Recurring ghost parents (`,f.length,`)`]}),j(`div`,{className:`space-y-1.5`,children:f.map(e=>D(`div`,{className:`text-[11px] text-foreground flex items-center justify-between gap-2`,children:[D(`div`,{className:`flex items-center gap-2`,children:[D(`span`,{className:`font-mono text-foreground-subtle`,children:[`ppid `,e.ppid]}),D(`span`,{children:[`→ `,e.children.length,` ghost(s)`]})]}),D(`button`,{type:`button`,disabled:p.isPending,onClick:()=>{v(e)},className:`inline-flex items-center gap-1 rounded border border-amber-500/40 bg-amber-500/10 px-2 py-0.5 text-[10px] text-amber-400 hover:bg-amber-500/20 disabled:opacity-30`,children:[j(X,{className:`h-3 w-3`}),` Kill parent + `,e.children.length]})]},e.ppid))})]}),D(`div`,{className:`flex items-center justify-between gap-2 text-[11px]`,children:[D(`div`,{className:`flex items-center gap-2`,children:[j(`span`,{className:`text-foreground-subtle`,children:`Filter:`}),D(`button`,{type:`button`,className:`px-2 py-0.5 rounded ${r===`all`?`bg-primary text-primary-foreground`:`border border-border text-foreground hover:bg-surface-hover`}`,onClick:()=>i(`all`),children:[`All (`,u.length,`)`]}),D(`button`,{type:`button`,className:`px-2 py-0.5 rounded ${r===`ghost`?`bg-destructive text-destructive-foreground`:`border border-border text-foreground hover:bg-surface-hover`}`,onClick:()=>i(`ghost`),children:[`Ghost only (`,x,`)`]})]}),x>0&&D(`button`,{type:`button`,disabled:p.isPending,onClick:()=>{b()},className:`inline-flex items-center gap-1 rounded border border-destructive/40 bg-destructive/10 px-2 py-1 text-[11px] font-medium text-destructive hover:bg-destructive/20 disabled:opacity-30`,children:[j(X,{className:`h-3 w-3`}),` Kill all `,x,` ghost(s)`]})]}),j(`div`,{className:`rounded-lg border border-border max-h-[60vh] overflow-auto`,children:D(`table`,{className:`w-full text-xs`,children:[j(`thead`,{className:`sticky top-0 z-10 bg-surface`,children:D(`tr`,{className:`text-foreground-subtle text-[10px] uppercase tracking-wider`,children:[j(`th`,{className:`text-left px-3 py-2`,children:`Class`}),j(`th`,{className:`text-right px-3 py-2`,children:`PID`}),j(`th`,{className:`text-right px-3 py-2`,children:`PPID`}),j(`th`,{className:`text-left px-3 py-2`,children:`Addon`}),j(`th`,{className:`text-left px-3 py-2`,children:`Command`}),j(`th`,{className:`text-right px-3 py-2`,children:`CPU%`}),j(`th`,{className:`text-right px-3 py-2`,children:`RSS`}),j(`th`,{className:`text-right px-3 py-2`,children:`Uptime`}),j(`th`,{className:`w-44`})]})}),D(`tbody`,{children:[d.length===0&&j(`tr`,{children:j(`td`,{colSpan:9,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:r===`ghost`?`No ghost processes detected.`:`Scanning…`})}),d.map(e=>D(`tr`,{className:`border-t border-border ${e.classification===`ghost`?`bg-destructive/5`:``}`,children:[j(`td`,{className:`px-3 py-2`,children:j(`span`,{className:`inline-block rounded-full px-1.5 py-0.5 text-[10px] font-medium ${e.classification===`ghost`?`bg-destructive/20 text-destructive`:e.classification===`root`?`bg-sky-500/20 text-sky-400`:e.classification===`system`?`bg-foreground-subtle/20 text-foreground-subtle`:`bg-success/20 text-success`}`,children:e.classification})}),j(`td`,{className:`px-3 py-2 text-right font-mono text-foreground`,children:e.pid}),D(`td`,{className:`px-3 py-2 text-right font-mono text-foreground-subtle`,children:[e.ppid,e.orphaned?` ⚠`:``]}),j(`td`,{className:`px-3 py-2 text-foreground-subtle text-[11px]`,children:e.addonId??`—`}),j(`td`,{className:`px-3 py-2 font-mono text-[10px] text-foreground-subtle break-all`,children:ye(e.command)}),j(`td`,{className:`px-3 py-2 text-right text-foreground`,children:e.cpuPercent.toFixed(1)}),j(`td`,{className:`px-3 py-2 text-right text-foreground`,children:J(e.memoryRssBytes)}),j(`td`,{className:`px-3 py-2 text-right text-foreground-subtle`,children:ve(e.uptimeSec)}),j(`td`,{className:`px-3 py-2 text-right`,children:D(`div`,{className:`inline-flex gap-1`,children:[D(`button`,{type:`button`,disabled:p.isPending||e.classification===`root`||e.classification===`system`,onClick:()=>{g(e,!1)},title:`SIGTERM`,className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded border border-border text-[10px] text-foreground hover:bg-surface-hover disabled:opacity-30`,children:[j(W,{className:`h-3 w-3`}),` Term`]}),D(`button`,{type:`button`,disabled:p.isPending||e.classification===`root`||e.classification===`system`,onClick:()=>{g(e,!0)},title:`SIGKILL`,className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded border border-destructive/30 text-[10px] text-destructive hover:bg-destructive/10 disabled:opacity-30`,children:[j(X,{className:`h-3 w-3`}),` Kill`]})]})})]},e.pid))]})]})}),p.isError&&D(`div`,{className:`rounded-md border border-destructive/30 bg-destructive/5 px-3 py-2 text-[11px] text-destructive`,children:[`Kill failed:`,` `,p.error instanceof Error?p.error.message:`unknown`]})]})}function xe({nodeId:e,addonIds:t}){return t.length===0?j(`div`,{className:`py-4 text-xs text-muted-foreground text-center`,children:`No addons on this node`}):j(`div`,{className:`w-full py-2`,children:j(oe,{nodeId:e,addonIds:t,level:`global`,selfTabbed:!0})})}E();function Se({nodeId:e,addons:t}){let n=k(),{data:r,isLoading:i}=_({nodeId:e}),a=O(()=>{let e=new Map;for(let n of t)for(let t of n.capabilities){let r=e.get(t)??[];r.push(n.id),e.set(t,r)}return[...e.entries()].toSorted(([e],[t])=>e.localeCompare(t)).map(([e,t])=>({capName:e,providers:t}))},[t]),o=x({onSuccess:()=>{n.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCapabilityBindings`]]})}});return a.length===0?j(`div`,{className:`py-4 text-xs text-muted-foreground text-center`,children:`No capabilities on this node`}):j(`div`,{className:`rounded-lg border border-border max-h-[60vh] overflow-auto`,children:D(`table`,{className:`w-full text-xs`,children:[j(`thead`,{className:`sticky top-0 z-10 bg-surface`,children:D(`tr`,{className:`text-muted-foreground text-left`,children:[j(`th`,{className:`px-3 py-2 font-medium w-1/2`,children:`Capability`}),j(`th`,{className:`px-3 py-2 font-medium`,children:`Bound provider`})]})}),j(`tbody`,{children:a.map(({capName:t,providers:n})=>{let a=r?.[t]??n[0]??``,s=n.length===1;return D(`tr`,{className:`border-t border-border/50`,children:[j(`td`,{className:`px-3 py-2 font-medium`,children:t}),j(`td`,{className:`px-3 py-2`,children:j(`select`,{value:a,onChange:n=>o.mutate({nodeId:e,capName:t,addonId:n.target.value}),disabled:s||o.isPending||i,className:`w-full rounded-md border border-border bg-surface px-2 py-1 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary disabled:opacity-60`,title:s?`Only one provider installed — choice becomes available once a second addon registers this capability`:void 0,children:n.map(e=>j(`option`,{value:e,children:e},e))})})]},t)})})]})})}E();function Z(e){if(e==null)return`—`;let t=Math.floor(e/1e3),n=Math.floor(t/86400),r=Math.floor(t%86400/3600),i=Math.floor(t%3600/60);return n>0?`${n}d ${r}h ${i}m`:r>0?`${r}h ${i}m`:`${i}m`}function Ce(t){let[n,r]=A(!1),[i,a]=A(t.name),o=k(),s=e({onSuccess:()=>{o.invalidateQueries({queryKey:[[`nodes`,`topology`]]})}}),c=(t.localIps??[]).filter(e=>!e.includes(`:`)),l=(t.localIps??[]).filter(e=>e.includes(`:`)),u=async()=>{if(!i.trim()||i===t.name){r(!1);return}try{await s.mutateAsync({nodeId:t.nodeId,name:i.trim()}),r(!1)}catch(e){console.error(`Rename failed:`,e)}},d=[[`Node ID`,j(`span`,{className:`font-mono text-xs`,children:t.nodeId})],[`Display Name`,n?D(`div`,{className:`flex items-center gap-1.5`,children:[j(`input`,{type:`text`,className:`flex-1 px-2 py-0.5 text-xs border border-border rounded bg-background focus:outline-none focus:ring-1 focus:ring-primary`,value:i,onChange:e=>a(e.target.value),onKeyDown:e=>{e.key===`Enter`&&u(),e.key===`Escape`&&r(!1)},disabled:s.isPending,autoFocus:!0}),j(`button`,{onClick:()=>void u(),disabled:s.isPending,className:`p-0.5 text-success hover:bg-success/10 rounded`,title:`Save`,children:j(re,{className:`h-3.5 w-3.5`})}),j(`button`,{onClick:()=>r(!1),className:`p-0.5 text-muted-foreground hover:bg-muted rounded`,title:`Cancel`,children:j(ae,{className:`h-3.5 w-3.5`})})]}):D(`div`,{className:`flex items-center gap-1.5`,children:[j(`span`,{className:`text-xs`,children:t.name}),!t.isHub&&j(`button`,{onClick:()=>{a(t.name),r(!0)},className:`p-0.5 text-muted-foreground hover:text-primary rounded`,title:`Rename`,children:j(P,{className:`h-3 w-3`})})]})],[`Hostname`,j(`span`,{className:`text-xs`,children:t.hostname})],[`Role`,t.isHub?j(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-primary/10 text-primary font-medium`,children:`Hub`}):j(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-muted text-muted-foreground font-medium`,children:`Agent`})],[`Root Package`,t.rootPackage?D(`span`,{className:`font-mono text-xs`,children:[t.rootPackage.name,`@`,t.rootPackage.version]}):j(`span`,{className:`text-xs text-muted-foreground`,children:`—`})],[`Platform`,D(`span`,{className:`text-xs`,children:[t.platform,` / `,t.arch]})],[`CPU`,D(`span`,{className:`text-xs`,children:[t.cpuModel??`—`,` (`,t.cpuCores,` cores)`]})],[`Memory`,j(`span`,{className:`text-xs`,children:t.memoryMB>0?`${(t.memoryMB/1024).toFixed(1)} GB`:`—`})],[`Uptime`,j(`span`,{className:`text-xs`,children:Z(t.uptime)})],[`Engines`,t.engines.length>0?j(`div`,{className:`flex flex-wrap gap-1`,children:t.engines.map(e=>j(`span`,{className:`text-[9px] px-1.5 py-0.5 rounded-full bg-purple-500/10 text-purple-400 font-medium`,children:e},e))}):j(`span`,{className:`text-xs text-muted-foreground`,children:`—`})]];return c.length>0&&d.push([`IPv4`,j(`div`,{className:`flex flex-wrap gap-1.5`,children:c.map((e,t)=>j(`span`,{className:`font-mono text-xs px-1.5 py-0.5 rounded bg-muted`,children:e},`${e}-${t}`))})]),l.length>0&&d.push([`IPv6`,j(`div`,{className:`flex flex-wrap gap-1.5`,children:l.map((e,t)=>j(`span`,{className:`font-mono text-[10px] px-1.5 py-0.5 rounded bg-muted truncate max-w-[280px]`,title:e,children:e},`${e}-${t}`))})]),j(`div`,{className:`py-2`,children:j(`table`,{className:`w-full text-sm`,children:j(`tbody`,{children:d.map(([e,t],n)=>D(`tr`,{className:n%2==0?`bg-muted/20`:``,children:[j(`td`,{className:`py-1.5 px-2 text-xs font-medium text-muted-foreground w-28 align-top whitespace-nowrap`,children:e}),j(`td`,{className:`py-1.5 px-2`,children:t})]},e))})})})}E();var we=[[`serverManagement`,`getServerPackageStatus`]];function Q({label:e,tone:t}){return j(`span`,{className:`inline-flex items-center rounded px-2 py-0.5 text-[11px] font-medium ${{neutral:`bg-surface-muted text-foreground-subtle`,ok:`bg-emerald-500/15 text-emerald-500`,info:`bg-sky-500/15 text-sky-500`,warn:`bg-amber-500/15 text-amber-500`,error:`bg-red-500/15 text-red-500`}[t]}`,children:e})}function $({label:e,value:t}){return D(`div`,{className:`flex items-center justify-between gap-4 text-sm`,children:[j(`span`,{className:`text-foreground-subtle`,children:e}),j(`span`,{className:`font-mono text-foreground`,children:t??`—`})]})}function Te({node:e}){let{t:n}=G(),r=k(),i=y(),[a,o]=A(!1),s=e.isHub?void 0:{nodeId:e.id},c=S(s,{refetchInterval:1e4,enabled:e.isOnline,retry:1}),l=c.data??null,f=w(()=>{r.invalidateQueries({queryKey:we})},[r]),p=t({onSettled:f}),m=u({onSettled:f}),h=d({onSettled:f}),g=w(async()=>{l?.latestVersion!=null&&await i({title:n(`serverManagement.confirmUpdateTitle`,`Update node root package`),message:n(`serverManagement.confirmUpdateBody`,`Install {{pkg}}@{{version}} on "{{node}}" and restart to apply.`,{pkg:l.packageName,version:l.latestVersion,node:e.name}),confirmLabel:n(`serverManagement.confirmUpdateAction`,`Update & restart`)})&&(await m.mutateAsync({version:l.latestVersion,...s})).restarting&&o(!0)},[m,i,e.name,s,l,n]),_=w(async()=>{await i({title:n(`serverManagement.confirmRestartTitle`,`Restart node`),message:n(`serverManagement.confirmRestartBody`,`Restart "{{node}}"? In-flight requests to this node are dropped.`,{node:e.name}),confirmLabel:n(`serverManagement.confirmRestartAction`,`Restart`),variant:`warning`})&&(await h.mutateAsync(s)).restarting&&o(!0)},[i,e.name,h,s,n]),v=()=>{switch(l?.bootMode){case`data-root`:return{label:n(`serverManagement.bootDataRoot`,`runtime-updatable`),tone:`ok`};case`workspace`:return{label:n(`serverManagement.bootWorkspace`,`dev workspace`),tone:`info`};default:return{label:n(`serverManagement.bootBaked`,`baked image seed`),tone:`neutral`}}},b=()=>{if(l==null)return null;switch(l.updateState){case`checking`:return{label:n(`serverManagement.stateChecking`,`checking…`),tone:`info`};case`staging`:return{label:n(`serverManagement.stateStaging`,`updating…`),tone:`info`};case`pending-restart`:return{label:n(`serverManagement.statePending`,`restart pending`),tone:`warn`};default:return l.updateAvailable?{label:n(`serverManagement.stateUpdateAvailable`,`update available`),tone:`warn`}:{label:n(`serverManagement.stateUpToDate`,`up to date`),tone:`ok`}}},x=l?.bootMode===`workspace`,C=e.isOnline&&l!=null&&!x&&l.updateAvailable&&l.updateState===`idle`&&!m.isPending,T=e.isOnline&&l!=null&&l.updateState===`idle`&&!h.isPending,E=e.isOnline?b():null;return D(`div`,{className:`space-y-4 py-2`,children:[D(`div`,{className:`flex items-center justify-between gap-3`,children:[D(`div`,{className:`flex items-center gap-2 min-w-0`,children:[j(`span`,{className:`font-mono text-xs text-foreground-subtle truncate`,children:l?.packageName??e.rootPackage?.name??`@camstack/server`}),e.isOnline&&l!=null&&j(Q,{...v()})]}),E!=null&&j(Q,{...E})]}),!e.isOnline&&j($,{label:n(`serverManagement.lastReportedVersion`,`Last reported version`),value:e.rootPackage?.version??null}),e.isOnline&&c.isLoading&&D(`div`,{className:`flex items-center gap-2 text-sm text-foreground-subtle`,children:[j(V,{className:`h-4 w-4 animate-spin`}),n(`common.loading`,`Loading…`)]}),e.isOnline&&c.isError&&D(`div`,{className:`space-y-1.5`,children:[j(`p`,{className:`text-sm text-red-500`,children:n(`serverManagement.loadError`,`Could not load the node root-package status.`)}),e.rootPackage!=null&&j($,{label:n(`serverManagement.lastReportedVersion`,`Last reported version`),value:e.rootPackage.version})]}),e.isOnline&&l!=null&&D(`div`,{className:`space-y-1.5`,children:[j($,{label:n(`serverManagement.runningVersion`,`Running version`),value:l.runningVersion}),j($,{label:n(`serverManagement.latestVersion`,`Latest on registry`),value:l.latestVersion}),j($,{label:n(`serverManagement.imageSeedVersion`,`Image seed (baked)`),value:l.seedVersion}),j($,{label:n(`serverManagement.nodeRuntimeVersion`,`Node.js runtime`),value:l.nodeRuntimeVersion}),l.pendingVersion!=null&&j($,{label:n(`serverManagement.pendingVersion`,`Staged (applies on restart)`),value:l.pendingVersion})]}),e.isOnline&&(l?.imageContract?.state===`behind-series`||l?.imageContract?.state===`behind-patch`)&&D(`div`,{className:`rounded-md border px-3 py-2 text-xs leading-relaxed ${l.imageContract.state===`behind-series`?`border-red-500/40 bg-red-500/10 text-red-500`:`border-amber-500/40 bg-amber-500/10 text-amber-500`}`,children:[j(`p`,{className:`mb-0.5 font-semibold`,children:n(`serverManagement.imageContractDiverged`,`Container image diverges from the deployment contract`)}),j(`p`,{children:l.imageContract.message})]}),e.isOnline&&x&&j(`p`,{className:`text-xs text-foreground-subtle`,children:n(`serverManagement.workspaceNote`,`Development workspace detected — runtime updates are disabled (the dev loop resolves code from the workspace).`)}),a&&D(`div`,{className:`flex items-center gap-2 text-sm text-amber-500`,children:[j(V,{className:`h-4 w-4 animate-spin`}),n(`serverManagement.nodeRestarting`,`The node is restarting to apply the change…`)]}),e.isOnline&&D(`div`,{className:`flex flex-wrap items-center gap-2 pt-1`,children:[D(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded border border-border px-2.5 py-1.5 text-xs font-medium text-foreground hover:bg-surface-muted disabled:opacity-50`,disabled:p.isPending||l?.updateState===`staging`,onClick:()=>p.mutate(s),children:[p.isPending?j(V,{className:`h-3.5 w-3.5 animate-spin`}):j(I,{className:`h-3.5 w-3.5`}),n(`serverManagement.checkForUpdate`,`Check for update`)]}),C&&D(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded bg-primary px-2.5 py-1.5 text-xs font-medium text-primary-foreground hover:opacity-90 disabled:opacity-50`,onClick:()=>void g(),children:[m.isPending?j(V,{className:`h-3.5 w-3.5 animate-spin`}):j(Y,{className:`h-3.5 w-3.5`}),n(`serverManagement.updateTo`,`Update to {{version}}`,{version:l?.latestVersion??``})]}),D(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded border border-border px-2.5 py-1.5 text-xs font-medium text-foreground hover:bg-surface-muted disabled:opacity-50`,disabled:!T,onClick:()=>void _(),children:[h.isPending?j(V,{className:`h-3.5 w-3.5 animate-spin`}):j(L,{className:`h-3.5 w-3.5`}),n(`serverManagement.restart`,`Restart`)]})]}),e.isOnline&&l?.lastCheckedAtMs!=null&&D(`p`,{className:`flex items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[j(ce,{className:`h-3 w-3`}),n(`serverManagement.lastChecked`,`Last checked: {{when}}`,{when:new Date(l.lastCheckedAtMs).toLocaleString()})]})]})}E();function Ee({node:e}){let t=N(),[n,r]=A(`info`),[i,a]=A(!1),o=e.processes??[],s=e.addons.map(e=>e.id),c=async()=>{if(!i){a(!0);try{await Promise.allSettled([t.trpcClient.pipelineOrchestrator.removeAgentSettings.mutate({agentNodeId:e.id}),t.trpcClient.clusterNodes.forgetNode.mutate({nodeId:e.id})])}finally{a(!1)}}};return e.isOnline?D(`div`,{className:`border border-border rounded-xl`,children:[D(`div`,{className:`flex items-center gap-3 px-4 py-3 bg-muted/30 border-b border-border rounded-t-xl`,children:[j(`div`,{className:`w-2.5 h-2.5 rounded-full bg-success`}),j(`span`,{className:`text-sm font-semibold`,children:e.name}),D(`span`,{className:`text-xs text-muted-foreground`,children:[e.cpuModel??e.platform,` ·`,` `,e.memoryMB>0?`${Math.round(e.memoryMB/1024)}GB`:``,` · `,e.arch]}),e.engines.map(e=>j(`span`,{className:`text-[9px] px-1.5 py-0.5 rounded-full bg-purple-500/10 text-purple-400 font-medium`,children:e},e)),D(`div`,{className:`ml-auto flex gap-3 text-xs text-muted-foreground`,children:[D(`span`,{className:`flex items-center gap-1`,children:[j(ne,{className:`h-3 w-3`}),` `,e.cpuPercent,`%`]}),D(`span`,{className:`flex items-center gap-1`,children:[j(le,{className:`h-3 w-3`}),` `,e.memoryPercent,`%`]})]})]}),j(`div`,{className:`sticky top-0 z-20 flex border-b border-border px-4 bg-background overflow-x-auto`,children:[`info`,`addons`,`forks`,`processes`,`settings`,`capabilities`].map(t=>j(`button`,{onClick:()=>r(t),className:`shrink-0 whitespace-nowrap px-3 py-2 text-xs font-medium border-b-2 transition-colors ${n===t?`border-primary text-primary`:`border-transparent text-muted-foreground hover:text-foreground`}`,children:t===`info`?`General`:t===`addons`?`Addons (${e.addons.length})`:t===`forks`?`Forks (${o.length})`:t===`processes`?`Processes`:t===`settings`?`Settings`:`Capabilities`},t))}),D(`div`,{className:`px-4 py-2`,children:[n===`info`&&D(`div`,{className:`space-y-3`,children:[j(Ce,{nodeId:e.id,name:e.name,hostname:e.hostname,platform:e.platform,arch:e.arch,cpuModel:e.cpuModel,cpuCores:e.cpuCores,memoryMB:e.memoryMB,engines:e.engines,isHub:e.isHub,uptime:e.uptime,localIps:e.localIps,rootPackage:e.rootPackage}),j(`div`,{className:`border-t border-border pt-1`,children:j(Te,{node:{id:e.id,name:e.name,isHub:e.isHub,isOnline:e.isOnline,rootPackage:e.rootPackage??null}})})]}),n===`addons`&&j(fe,{nodeId:e.id,addons:e.addons,isHub:e.isHub}),n===`forks`&&j(_e,{nodeId:e.id,processes:o}),n===`processes`&&j(be,{nodeId:e.id}),n===`settings`&&j(xe,{nodeId:e.id,addonIds:s}),n===`capabilities`&&j(Se,{nodeId:e.id,addons:e.addons})]})]}):D(`div`,{className:`border border-border rounded-xl overflow-hidden opacity-60`,children:[D(`div`,{className:`flex items-center gap-3 px-4 py-3 bg-muted/30`,children:[j(`div`,{className:`w-2.5 h-2.5 rounded-full bg-destructive`}),j(`span`,{className:`text-sm font-semibold`,children:e.name}),D(`span`,{className:`text-xs text-muted-foreground`,children:[e.cpuModel??e.platform,` ·`,` `,e.memoryMB>0?`${Math.round(e.memoryMB/1024)}GB`:``,` · `,e.arch]}),e.engines.map(e=>j(`span`,{className:`text-[9px] px-1.5 py-0.5 rounded-full bg-purple-500/10 text-purple-400 font-medium`,children:e},e)),e.rootPackage&&D(`span`,{className:`text-[10px] font-mono px-1.5 py-0.5 rounded bg-muted text-muted-foreground`,children:[e.rootPackage.name,`@`,e.rootPackage.version]}),j(`span`,{className:`ml-auto text-xs px-2 py-0.5 rounded-full bg-destructive/10 text-destructive`,children:`offline`})]}),D(`div`,{className:`flex items-center justify-between gap-3 px-4 py-3`,children:[D(`span`,{className:`text-xs text-muted-foreground`,children:[e.lastSeen?`Last seen ${new Date(e.lastSeen).toLocaleString()} — `:``,e.addons.length,` addon`,e.addons.length===1?``:`s`,` assigned; will resume when node reconnects`]}),D(`button`,{type:`button`,onClick:()=>void c(),disabled:i,title:`Forget this node — removes its saved history and pipeline assignments`,className:`flex items-center gap-1 text-xs px-2 py-1 rounded-md border border-border text-muted-foreground hover:text-destructive hover:border-destructive/50 disabled:opacity-50 transition-colors`,children:[j(W,{className:`h-3 w-3`}),i?`Forgetting…`:`Forget node`]})]})]})}E();function De({nodes:e,focusNodeId:t,focusNonce:n}){let r=[...e].toSorted((e,t)=>e.isHub?-1:t.isHub?1:e.isOnline&&!t.isOnline?-1:!e.isOnline&&t.isOnline?1:e.name.localeCompare(t.name)),i=T(null);return M(()=>{if(!t)return;let e=i.current?.querySelector(`#node-card-${CSS.escape(t)}`);e&&e.scrollIntoView({behavior:`smooth`,block:`start`})},[t,n]),j(`div`,{ref:i,className:`flex flex-col gap-4`,children:r.map(e=>j(`div`,{id:`node-card-${e.id}`,children:j(Ee,{node:e})},e.id))})}E();function Oe(e){let[t,n]=A(()=>typeof window<`u`?window.matchMedia(e).matches:!1);return M(()=>{let t=window.matchMedia(e),r=e=>n(e.matches);return t.addEventListener(`change`,r),()=>t.removeEventListener(`change`,r)},[e]),t}function ke(){let{data:e,isLoading:t}=m(void 0,{staleTime:1/0}),[n,r]=A(null);return b(`cluster.topology-snapshot`,e=>{let t=e.data?.nodes;Array.isArray(t)&&r(t)}),{nodes:O(()=>n??e??[],[n,e]),isLoading:t&&!n}}function Ae(){let{t:e}=G(),t=y(),[n,r]=A(`table`),[i,a]=A(void 0),[o,s]=A(0),c=Oe(`(max-width: 767px)`),l=c&&n===`graph`?`table`:n,{nodes:d,isLoading:f}=ke(),p=O(()=>q(d),[d]),m=O(()=>d.filter(e=>e.isOnline),[d]),h=m.length,g=d.filter(e=>!e.isOnline).length,_=u(),[v,b]=A(!1),x=w(async()=>{let n=[...m].sort((e,t)=>e.isHub===t.isHub?0:e.isHub?1:-1);if(await t({title:e(`serverManagement.confirmUpdateAllTitle`,`Update all nodes`),message:e(`serverManagement.confirmUpdateAllBody`,`Update and restart every online node, agents first, hub last. Up-to-date nodes are skipped; this page reconnects when the hub comes back.`),confirmLabel:e(`serverManagement.confirmUpdateAllAction`,`Update all & restart`),variant:`warning`})){b(!0);try{for(let e of n)try{await _.mutateAsync(e.isHub?{}:{nodeId:e.id})}catch{}}finally{b(!1)}}},[_,t,m,e]),S=w(e=>{r(`table`),a(e),s(e=>e+1)},[]),C=(e,t,i)=>D(`button`,{onClick:()=>r(e),className:`flex items-center gap-1.5 px-3 py-1.5 rounded-md text-xs font-medium transition-colors ${n===e?`bg-primary text-primary-foreground`:`text-muted-foreground hover:text-foreground`}`,children:[j(i,{className:`h-3.5 w-3.5`}),t]});return D(`div`,{className:`flex flex-col h-full gap-4 p-4`,children:[D(`div`,{className:`flex items-center justify-between gap-2 flex-wrap`,children:[D(`div`,{className:`flex items-center gap-2`,children:[h>0&&D(`span`,{className:`text-xs px-2 py-0.5 rounded-full bg-success/10 text-success`,children:[h,` online`]}),g>0&&D(`span`,{className:`text-xs px-2 py-0.5 rounded-full bg-destructive/10 text-destructive`,children:[g,` offline`]})]}),D(`div`,{className:`flex items-center gap-2`,children:[h>1&&D(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:opacity-90 disabled:opacity-50`,disabled:v,title:e(`serverManagement.updateAllHint`,`Sequenced agents-first, hub-last — up-to-date nodes are skipped.`),onClick:()=>void x(),children:[v?j(V,{className:`h-3.5 w-3.5 animate-spin`}):j(Y,{className:`h-3.5 w-3.5`}),e(`serverManagement.updateAll`,`Update all nodes`)]}),D(`div`,{className:`flex gap-0.5 p-1 rounded-lg bg-muted`,children:[C(`table`,`Table`,ue),!c&&C(`graph`,`Graph`,se)]})]})]}),f?j(`div`,{className:`flex items-center justify-center flex-1 text-muted-foreground`,children:`Loading cluster topology...`}):l===`graph`?j(K,{graph:p,onOpenNodeDetail:S}):j(`div`,{className:`flex-1 overflow-auto`,children:j(De,{nodes:d,focusNodeId:i,focusNonce:o})})]})}export{Ae as ClusterPage};
@@ -1 +1 @@
1
- import{Ea as e,Hr as t,Oa as n,Ta as r,ft as i,ro as a,ut as o,wa as s}from"./src-DB2IsJfq.js";import{Q as c,S as l,W as u,o as d,q as f,x as p}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DTufy7Ue.js";import{n as m,r as h,t as g}from"./AddLocationWizard-OriRyfGb.js";import{S as _}from"./index-C8SRsMDj.js";c();function v({types:t}){let i=d(),o=a(),{data:c}=e({}),_=r(),v=u(()=>_.data??[],[_.data]),[y,b]=f(null),[x,S]=f(null),C=()=>{i.invalidateQueries({queryKey:[[`storage`,`listLocations`]]})},w=n({onSuccess:C}),T=s({onSuccess:C}),E=u(()=>{let e=new Map;for(let t of c??[]){let n=e.get(t.type);n?n.push(t):e.set(t.type,[t])}return e},[c]),D=e=>{e.isDefault||w.mutate({id:e.id,type:e.type,providerId:e.providerId,displayName:e.displayName,config:e.config,isDefault:!0})},O=async e=>{if(e.isDefault){await o({title:`Cannot delete default location`,message:`"${e.displayName}" is the default for type "${e.type}". Mark another as default first.`,confirmLabel:`OK`,variant:`warning`});return}await o({title:`Delete location "${e.displayName}"?`,message:`Removes the record; files on disk are untouched.`,confirmLabel:`Delete`,variant:`danger`})&&T.mutate({id:e.id})},k=t.map(e=>v.find(t=>t.id===e)).filter(e=>e!==void 0);return l(`div`,{className:`space-y-3`,children:[k.length===0?p(`p`,{className:`text-[11px] text-foreground-subtle italic`,children:`No storage locations declared for this purpose.`}):k.map(e=>p(h,{type:e.id,displayName:e.displayName,description:e.description,cardinality:e.cardinality,locations:E.get(e.id)??[],onAdd:e=>b(e),onEdit:e=>S(e),onDelete:e=>{O(e)},onSetDefault:e=>D(e)},e.id)),y!==null&&p(g,{initialType:y,onClose:()=>b(null),onCreated:()=>{C(),b(null)}}),x!==null&&p(m,{location:x,onClose:()=>S(null),onSaved:()=>{C(),S(null)}})]})}c();var y=`recorder`;function b(e,t,n){for(let n of e?.sections??[])for(let e of n.fields??[])if(e.key===t&&typeof e.value==`string`)return e.value;return n}function x(){let e=d(),{data:n}=t(void 0),{data:r,isLoading:a}=o({addonId:y}),s=b(r,`recordingNodeId`,`hub`),c=i({onSuccess:()=>{e.invalidateQueries({queryKey:[[`addonSettings`,`getGlobalSettings`]]})}}),f=u(()=>{let e=(n??[]).filter(e=>e.isOnline).map(e=>e.id);return[...new Set([`hub`,s,...e])].filter(Boolean)},[n,s]);return l(`div`,{className:`flex flex-col gap-6`,children:[l(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[p(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Recording node`}),p(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:`The single node that records (continuous & events) and serves playback. Every other node stays inert — no multi-node balancing. Takes effect on addon restart.`}),l(`div`,{className:`mt-3 flex items-center gap-2`,children:[a?p(_,{className:`h-4 w-4 animate-spin text-foreground-subtle`}):p(`select`,{value:s,onChange:e=>{e.target.value!==s&&c.mutate({addonId:y,patch:{recordingNodeId:e.target.value}})},disabled:c.isPending,className:`rounded-md border border-border bg-surface px-2 py-1 text-xs text-foreground`,children:f.map(e=>p(`option`,{value:e,children:e===`hub`?`hub (default)`:e},e))}),c.isPending&&p(_,{className:`h-4 w-4 animate-spin text-primary`})]}),s!==`hub`&&l(`p`,{className:`mt-2 text-[11px] text-amber-500`,children:[`The stream-broker is hub-only — an agent recorder pulls streams from the hub over the network. The hub's RTSP restream port must be reachable from`,` `,p(`span`,{className:`font-medium`,children:s}),`. If the auto-derived host doesn't work, set the recorder's`,p(`span`,{className:`font-medium`,children:` recordingHubHostname`}),` global setting.`]})]}),l(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[p(`h3`,{className:`mb-1 text-sm font-semibold text-foreground`,children:`Recordings folders`}),p(`p`,{className:`mb-3 text-[11px] text-foreground-subtle`,children:`Where recordings are stored. Multi-location collections — segments are split across the locations of a type. Add a location to grow capacity; mark one default per type.`}),p(v,{types:[`recordings`,`recordingsLow`]})]})]})}export{v as n,x as t};
1
+ import{Aa as e,Da as t,Ea as n,Oa as r,Wr as i,ft as a,oo as o,ut as s}from"./src-RAEsAO7u.js";import{Q as c,S as l,W as u,o as d,q as f,x as p}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DTufy7Ue.js";import{n as m,r as h,t as g}from"./AddLocationWizard-BMebDBIA.js";import{S as _}from"./index-D1Lv9nnm.js";c();function v({types:i}){let a=d(),s=o(),{data:c}=r({}),_=t(),v=u(()=>_.data??[],[_.data]),[y,b]=f(null),[x,S]=f(null),C=()=>{a.invalidateQueries({queryKey:[[`storage`,`listLocations`]]})},w=e({onSuccess:C}),T=n({onSuccess:C}),E=u(()=>{let e=new Map;for(let t of c??[]){let n=e.get(t.type);n?n.push(t):e.set(t.type,[t])}return e},[c]),D=e=>{e.isDefault||w.mutate({id:e.id,type:e.type,providerId:e.providerId,displayName:e.displayName,config:e.config,isDefault:!0})},O=async e=>{if(e.isDefault){await s({title:`Cannot delete default location`,message:`"${e.displayName}" is the default for type "${e.type}". Mark another as default first.`,confirmLabel:`OK`,variant:`warning`});return}await s({title:`Delete location "${e.displayName}"?`,message:`Removes the record; files on disk are untouched.`,confirmLabel:`Delete`,variant:`danger`})&&T.mutate({id:e.id})},k=i.map(e=>v.find(t=>t.id===e)).filter(e=>e!==void 0);return l(`div`,{className:`space-y-3`,children:[k.length===0?p(`p`,{className:`text-[11px] text-foreground-subtle italic`,children:`No storage locations declared for this purpose.`}):k.map(e=>p(h,{type:e.id,displayName:e.displayName,description:e.description,cardinality:e.cardinality,locations:E.get(e.id)??[],onAdd:e=>b(e),onEdit:e=>S(e),onDelete:e=>{O(e)},onSetDefault:e=>D(e)},e.id)),y!==null&&p(g,{initialType:y,onClose:()=>b(null),onCreated:()=>{C(),b(null)}}),x!==null&&p(m,{location:x,onClose:()=>S(null),onSaved:()=>{C(),S(null)}})]})}c();var y=`recorder`;function b(e,t,n){for(let n of e?.sections??[])for(let e of n.fields??[])if(e.key===t&&typeof e.value==`string`)return e.value;return n}function x(){let e=d(),{data:t}=i(void 0),{data:n,isLoading:r}=s({addonId:y}),o=b(n,`recordingNodeId`,`hub`),c=a({onSuccess:()=>{e.invalidateQueries({queryKey:[[`addonSettings`,`getGlobalSettings`]]})}}),f=u(()=>{let e=(t??[]).filter(e=>e.isOnline).map(e=>e.id);return[...new Set([`hub`,o,...e])].filter(Boolean)},[t,o]);return l(`div`,{className:`flex flex-col gap-6`,children:[l(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[p(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Recording node`}),p(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:`The single node that records (continuous & events) and serves playback. Every other node stays inert — no multi-node balancing. Takes effect on addon restart.`}),l(`div`,{className:`mt-3 flex items-center gap-2`,children:[r?p(_,{className:`h-4 w-4 animate-spin text-foreground-subtle`}):p(`select`,{value:o,onChange:e=>{e.target.value!==o&&c.mutate({addonId:y,patch:{recordingNodeId:e.target.value}})},disabled:c.isPending,className:`rounded-md border border-border bg-surface px-2 py-1 text-xs text-foreground`,children:f.map(e=>p(`option`,{value:e,children:e===`hub`?`hub (default)`:e},e))}),c.isPending&&p(_,{className:`h-4 w-4 animate-spin text-primary`})]}),o!==`hub`&&l(`p`,{className:`mt-2 text-[11px] text-amber-500`,children:[`The stream-broker is hub-only — an agent recorder pulls streams from the hub over the network. The hub's RTSP restream port must be reachable from`,` `,p(`span`,{className:`font-medium`,children:o}),`. If the auto-derived host doesn't work, set the recorder's`,p(`span`,{className:`font-medium`,children:` recordingHubHostname`}),` global setting.`]})]}),l(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[p(`h3`,{className:`mb-1 text-sm font-semibold text-foreground`,children:`Recordings folders`}),p(`p`,{className:`mb-3 text-[11px] text-foreground-subtle`,children:`Where recordings are stored. Multi-location collections — segments are split across the locations of a type. Add a location to grow capacity; mark one default per type.`}),p(v,{types:[`recordings`,`recordingsLow`]})]})]})}export{v as n,x as t};
@@ -1 +1 @@
1
- import{A as e,T as t,jn as n}from"./src-DB2IsJfq.js";import{I as r,Q as i,S as a,W as o,q as s,x as c}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DTufy7Ue.js";import{t as l}from"./plus-wHPjAjjI.js";import{C as u,i as d}from"./index-C8SRsMDj.js";i();var f=`camstack:dashboard-layout`,p={version:1,widgets:[]};function m(){try{let e=localStorage.getItem(f);if(!e)return p;let t=JSON.parse(e);return t&&t.version===1&&Array.isArray(t.widgets)?{version:1,widgets:t.widgets}:p}catch{return p}}function h(e){try{localStorage.setItem(f,JSON.stringify(e))}catch{}}function g(){let e=typeof crypto<`u`?crypto:void 0;return e?.randomUUID?e.randomUUID():`widget-${Date.now().toString(36)}-${Math.floor(Math.random()*1e6).toString(36)}`}function _(){let[t,n]=s(m),[i,u]=s(!1),d=e(),f=o(()=>d.filter(e=>e.hosts.includes(`dashboard`)),[d]),p=r(e=>{n(e),h(e)},[]),g=r(e=>{p({version:1,widgets:[...t.widgets,e]})},[t,p]),_=r(e=>{p({version:1,widgets:t.widgets.filter(t=>t.instanceId!==e)})},[t,p]);return a(`div`,{className:`p-4`,children:[a(`div`,{className:`flex items-center justify-between mb-4`,children:[c(`h1`,{className:`text-lg font-semibold text-foreground`,children:`Dashboard`}),a(`button`,{onClick:()=>u(!0),className:`flex items-center gap-1.5 rounded-md bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 transition-colors`,children:[c(l,{className:`h-3.5 w-3.5`}),`Add widget`]})]}),t.widgets.length===0?c(v,{onAdd:()=>u(!0)}):c(`div`,{className:`grid grid-cols-12 gap-3 auto-rows-[minmax(80px,_auto)]`,children:t.widgets.map(e=>c(y,{entry:e,onRemove:()=>_(e.instanceId)},e.instanceId))}),i&&c(x,{widgets:f,onClose:()=>u(!1),onAdd:e=>{g(e),u(!1)}})]})}function v({onAdd:e}){return a(`div`,{className:`flex flex-col items-center justify-center py-24 text-foreground-subtle`,children:[c(`div`,{className:`flex h-16 w-16 items-center justify-center rounded-2xl bg-surface border border-border mb-4`,children:c(u,{className:`h-8 w-8 text-foreground-subtle/40`})}),c(`p`,{className:`text-sm font-medium text-foreground/70`,children:`Your dashboard is empty`}),c(`p`,{className:`text-xs text-foreground-subtle mt-1 mb-4`,children:`Add widgets to monitor your cameras and system`}),a(`button`,{onClick:e,className:`flex items-center gap-1.5 rounded-lg bg-primary px-4 py-2 text-xs font-semibold text-primary-foreground shadow-md shadow-primary/20 hover:shadow-lg transition-all`,children:[c(l,{className:`h-3.5 w-3.5`}),`Add your first widget`]})]})}function y({entry:e,onRemove:n}){let r=b(e.columns),i=Math.max(1,Math.min(12,e.rows));return a(`div`,{className:`relative group rounded-lg border border-border bg-surface overflow-hidden flex flex-col`,style:{gridColumn:`span ${r} / span ${r}`,gridRow:`span ${i} / span ${i}`},children:[c(`button`,{type:`button`,onClick:n,title:`Remove widget`,className:`absolute right-1.5 top-1.5 z-10 inline-flex h-5 w-5 items-center justify-center rounded-md border border-border/60 bg-surface/80 text-foreground-subtle opacity-0 group-hover:opacity-100 hover:bg-danger/10 hover:text-danger hover:border-danger/40 transition-all`,children:c(d,{className:`h-3 w-3`})}),c(`div`,{className:`flex-1 min-h-0 overflow-auto p-2`,children:c(t,{widgetId:e.widgetId,host:`dashboard`,instanceId:e.instanceId,config:e.config,deviceId:e.deviceId,size:e.size,columns:e.columns,rows:e.rows})})]})}function b(e){return!Number.isFinite(e)||e<1?6:Math.min(12,Math.floor(e))}function x({widgets:e,onClose:t,onAdd:n}){let[r,i]=s(null);return c(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm`,onClick:t,children:a(`div`,{className:`w-full max-w-2xl rounded-xl border border-border bg-surface p-5 shadow-2xl shadow-black/20`,onClick:e=>e.stopPropagation(),children:[a(`div`,{className:`flex items-center justify-between mb-4`,children:[c(`h2`,{className:`text-sm font-semibold text-foreground`,children:r?`Configure: ${r.label}`:`Add widget`}),c(`button`,{onClick:t,className:`p-1 rounded-md hover:bg-surface-hover text-foreground-subtle hover:text-foreground transition-colors`,children:c(d,{className:`h-4 w-4`})})]}),r===null?c(S,{widgets:e,onSelect:i}):c(C,{widget:r,onCancel:()=>i(null),onAdd:n})]})})}function S({widgets:e,onSelect:t}){return e.length===0?c(`div`,{className:`text-center py-8 text-xs text-foreground-subtle italic`,children:`No dashboard-host widgets registered. Make sure the contributing addons are enabled and have rebuilt their widget bundles.`}):c(`div`,{className:`grid grid-cols-2 gap-2 max-h-96 overflow-auto`,children:e.map(e=>a(`button`,{onClick:()=>t(e),className:`flex flex-col rounded-lg border border-border p-3 text-left hover:bg-surface-hover hover:border-primary/30 transition-all group`,children:[c(`span`,{className:`text-xs font-medium text-foreground block`,children:e.label}),c(`span`,{className:`text-[10px] text-foreground-subtle truncate`,title:e.widgetId,children:e.widgetId}),e.description&&c(`span`,{className:`text-[10px] text-foreground-subtle mt-1 line-clamp-2`,children:e.description})]},e.widgetId))})}function C({widget:e,onCancel:t,onAdd:r}){let[i,o]=s(e.defaultSize),[l,u]=s(e.defaultColumns),[d,f]=s(e.defaultRows),[p,m]=s(null),{data:h}=n({},{enabled:e.requires.deviceContext}),_=!e.requires.deviceContext||p!==null&&p>0;return a(`div`,{className:`space-y-3`,children:[a(`div`,{children:[c(`label`,{className:`block text-[11px] font-medium text-foreground-subtle mb-1`,children:`Size`}),c(`div`,{className:`flex items-center gap-1`,children:e.allowedSizes.map(e=>c(`button`,{onClick:()=>o(e),className:`px-3 py-1 rounded-md text-[11px] font-medium border transition-colors ${i===e?`bg-primary/10 text-primary border-primary/30`:`border-border text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:e.toUpperCase()},e))})]}),a(`div`,{className:`grid grid-cols-2 gap-3`,children:[c(w,{label:`Columns (1-12)`,value:l,min:1,max:12,onChange:u}),c(w,{label:`Rows (1-12)`,value:d,min:1,max:12,onChange:f})]}),e.requires.deviceContext&&a(`div`,{children:[c(`label`,{className:`block text-[11px] font-medium text-foreground-subtle mb-1`,children:`Device`}),a(`select`,{value:p??``,onChange:e=>m(e.target.value===``?null:Number(e.target.value)),className:`w-full rounded-md border border-border bg-surface px-2 py-1.5 text-foreground text-xs focus:border-primary outline-none`,children:[c(`option`,{value:``,children:`— select a device —`}),(h??[]).map(e=>a(`option`,{value:e.id,children:[e.name??e.stableId,` (#`,e.id,`)`]},e.id))]})]}),a(`div`,{className:`flex items-center justify-end gap-2 pt-2 border-t border-border`,children:[c(`button`,{onClick:t,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:`Back`}),c(`button`,{disabled:!_,onClick:()=>{_&&r({instanceId:g(),widgetId:e.widgetId,size:i,columns:l,rows:d,...e.requires.deviceContext&&p!==null?{deviceId:p}:{}})},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:`Add to dashboard`})]})]})}function w({label:e,value:t,min:n,max:r,onChange:i}){return a(`div`,{children:[c(`label`,{className:`block text-[11px] font-medium text-foreground-subtle mb-1`,children:e}),c(`input`,{type:`number`,min:n,max:r,value:t,onChange:e=>{let t=Number(e.target.value);Number.isFinite(t)&&i(Math.max(n,Math.min(r,Math.floor(t))))},className:`w-full rounded-md border border-border bg-surface px-2 py-1.5 text-foreground text-xs focus:border-primary outline-none`})]})}function T(){return c(_,{})}export{T as DashboardPage};
1
+ import{A as e,Nn as t,T as n}from"./src-RAEsAO7u.js";import{I as r,Q as i,S as a,W as o,q as s,x as c}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DTufy7Ue.js";import{t as l}from"./plus-CLA9DCBk.js";import{C as u,i as d}from"./index-D1Lv9nnm.js";i();var f=`camstack:dashboard-layout`,p={version:1,widgets:[]};function m(){try{let e=localStorage.getItem(f);if(!e)return p;let t=JSON.parse(e);return t&&t.version===1&&Array.isArray(t.widgets)?{version:1,widgets:t.widgets}:p}catch{return p}}function h(e){try{localStorage.setItem(f,JSON.stringify(e))}catch{}}function g(){let e=typeof crypto<`u`?crypto:void 0;return e?.randomUUID?e.randomUUID():`widget-${Date.now().toString(36)}-${Math.floor(Math.random()*1e6).toString(36)}`}function _(){let[t,n]=s(m),[i,u]=s(!1),d=e(),f=o(()=>d.filter(e=>e.hosts.includes(`dashboard`)),[d]),p=r(e=>{n(e),h(e)},[]),g=r(e=>{p({version:1,widgets:[...t.widgets,e]})},[t,p]),_=r(e=>{p({version:1,widgets:t.widgets.filter(t=>t.instanceId!==e)})},[t,p]);return a(`div`,{className:`p-4`,children:[a(`div`,{className:`flex items-center justify-between mb-4`,children:[c(`h1`,{className:`text-lg font-semibold text-foreground`,children:`Dashboard`}),a(`button`,{onClick:()=>u(!0),className:`flex items-center gap-1.5 rounded-md bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 transition-colors`,children:[c(l,{className:`h-3.5 w-3.5`}),`Add widget`]})]}),t.widgets.length===0?c(v,{onAdd:()=>u(!0)}):c(`div`,{className:`grid grid-cols-12 gap-3 auto-rows-[minmax(80px,_auto)]`,children:t.widgets.map(e=>c(y,{entry:e,onRemove:()=>_(e.instanceId)},e.instanceId))}),i&&c(x,{widgets:f,onClose:()=>u(!1),onAdd:e=>{g(e),u(!1)}})]})}function v({onAdd:e}){return a(`div`,{className:`flex flex-col items-center justify-center py-24 text-foreground-subtle`,children:[c(`div`,{className:`flex h-16 w-16 items-center justify-center rounded-2xl bg-surface border border-border mb-4`,children:c(u,{className:`h-8 w-8 text-foreground-subtle/40`})}),c(`p`,{className:`text-sm font-medium text-foreground/70`,children:`Your dashboard is empty`}),c(`p`,{className:`text-xs text-foreground-subtle mt-1 mb-4`,children:`Add widgets to monitor your cameras and system`}),a(`button`,{onClick:e,className:`flex items-center gap-1.5 rounded-lg bg-primary px-4 py-2 text-xs font-semibold text-primary-foreground shadow-md shadow-primary/20 hover:shadow-lg transition-all`,children:[c(l,{className:`h-3.5 w-3.5`}),`Add your first widget`]})]})}function y({entry:e,onRemove:t}){let r=b(e.columns),i=Math.max(1,Math.min(12,e.rows));return a(`div`,{className:`relative group rounded-lg border border-border bg-surface overflow-hidden flex flex-col`,style:{gridColumn:`span ${r} / span ${r}`,gridRow:`span ${i} / span ${i}`},children:[c(`button`,{type:`button`,onClick:t,title:`Remove widget`,className:`absolute right-1.5 top-1.5 z-10 inline-flex h-5 w-5 items-center justify-center rounded-md border border-border/60 bg-surface/80 text-foreground-subtle opacity-0 group-hover:opacity-100 hover:bg-danger/10 hover:text-danger hover:border-danger/40 transition-all`,children:c(d,{className:`h-3 w-3`})}),c(`div`,{className:`flex-1 min-h-0 overflow-auto p-2`,children:c(n,{widgetId:e.widgetId,host:`dashboard`,instanceId:e.instanceId,config:e.config,deviceId:e.deviceId,size:e.size,columns:e.columns,rows:e.rows})})]})}function b(e){return!Number.isFinite(e)||e<1?6:Math.min(12,Math.floor(e))}function x({widgets:e,onClose:t,onAdd:n}){let[r,i]=s(null);return c(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm`,onClick:t,children:a(`div`,{className:`w-full max-w-2xl rounded-xl border border-border bg-surface p-5 shadow-2xl shadow-black/20`,onClick:e=>e.stopPropagation(),children:[a(`div`,{className:`flex items-center justify-between mb-4`,children:[c(`h2`,{className:`text-sm font-semibold text-foreground`,children:r?`Configure: ${r.label}`:`Add widget`}),c(`button`,{onClick:t,className:`p-1 rounded-md hover:bg-surface-hover text-foreground-subtle hover:text-foreground transition-colors`,children:c(d,{className:`h-4 w-4`})})]}),r===null?c(S,{widgets:e,onSelect:i}):c(C,{widget:r,onCancel:()=>i(null),onAdd:n})]})})}function S({widgets:e,onSelect:t}){return e.length===0?c(`div`,{className:`text-center py-8 text-xs text-foreground-subtle italic`,children:`No dashboard-host widgets registered. Make sure the contributing addons are enabled and have rebuilt their widget bundles.`}):c(`div`,{className:`grid grid-cols-2 gap-2 max-h-96 overflow-auto`,children:e.map(e=>a(`button`,{onClick:()=>t(e),className:`flex flex-col rounded-lg border border-border p-3 text-left hover:bg-surface-hover hover:border-primary/30 transition-all group`,children:[c(`span`,{className:`text-xs font-medium text-foreground block`,children:e.label}),c(`span`,{className:`text-[10px] text-foreground-subtle truncate`,title:e.widgetId,children:e.widgetId}),e.description&&c(`span`,{className:`text-[10px] text-foreground-subtle mt-1 line-clamp-2`,children:e.description})]},e.widgetId))})}function C({widget:e,onCancel:n,onAdd:r}){let[i,o]=s(e.defaultSize),[l,u]=s(e.defaultColumns),[d,f]=s(e.defaultRows),[p,m]=s(null),{data:h}=t({},{enabled:e.requires.deviceContext}),_=!e.requires.deviceContext||p!==null&&p>0;return a(`div`,{className:`space-y-3`,children:[a(`div`,{children:[c(`label`,{className:`block text-[11px] font-medium text-foreground-subtle mb-1`,children:`Size`}),c(`div`,{className:`flex items-center gap-1`,children:e.allowedSizes.map(e=>c(`button`,{onClick:()=>o(e),className:`px-3 py-1 rounded-md text-[11px] font-medium border transition-colors ${i===e?`bg-primary/10 text-primary border-primary/30`:`border-border text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:e.toUpperCase()},e))})]}),a(`div`,{className:`grid grid-cols-2 gap-3`,children:[c(w,{label:`Columns (1-12)`,value:l,min:1,max:12,onChange:u}),c(w,{label:`Rows (1-12)`,value:d,min:1,max:12,onChange:f})]}),e.requires.deviceContext&&a(`div`,{children:[c(`label`,{className:`block text-[11px] font-medium text-foreground-subtle mb-1`,children:`Device`}),a(`select`,{value:p??``,onChange:e=>m(e.target.value===``?null:Number(e.target.value)),className:`w-full rounded-md border border-border bg-surface px-2 py-1.5 text-foreground text-xs focus:border-primary outline-none`,children:[c(`option`,{value:``,children:`— select a device —`}),(h??[]).map(e=>a(`option`,{value:e.id,children:[e.name??e.stableId,` (#`,e.id,`)`]},e.id))]})]}),a(`div`,{className:`flex items-center justify-end gap-2 pt-2 border-t border-border`,children:[c(`button`,{onClick:n,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:`Back`}),c(`button`,{disabled:!_,onClick:()=>{_&&r({instanceId:g(),widgetId:e.widgetId,size:i,columns:l,rows:d,...e.requires.deviceContext&&p!==null?{deviceId:p}:{}})},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:`Add to dashboard`})]})]})}function w({label:e,value:t,min:n,max:r,onChange:i}){return a(`div`,{children:[c(`label`,{className:`block text-[11px] font-medium text-foreground-subtle mb-1`,children:e}),c(`input`,{type:`number`,min:n,max:r,value:t,onChange:e=>{let t=Number(e.target.value);Number.isFinite(t)&&i(Math.max(n,Math.min(r,Math.floor(t))))},className:`w-full rounded-md border border-border bg-surface px-2 py-1.5 text-foreground text-xs focus:border-primary outline-none`})]})}function T(){return c(_,{})}export{T as DashboardPage};
@@ -0,0 +1 @@
1
+ import{Aa as e,Da as t,Ea as n,Et as r,Gt as i,Ht as a,Jt as o,Kt as s,Oa as c,Ut as l,Vt as u,Wt as d,Xt as f,Yt as p,bt as m,oo as h,qt as g,xt as _}from"./src-RAEsAO7u.js";import{I as v,Q as y,S as b,W as x,a as S,b as C,o as w,q as T,x as E,z as D}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DTufy7Ue.js";import{p as O}from"./player-overlays-RSBJ34HJ.js";import{a as k,i as A,n as j,r as M,t as N}from"./AddLocationWizard-BMebDBIA.js";import{t as P}from"./download-CF59Q1Zv.js";import{t as F}from"./pencil-Chd1XFvs.js";import{t as ee}from"./play-BS6NorXW.js";import{t as te}from"./plus-CLA9DCBk.js";import{t as I}from"./rotate-cw-CMVPPwHk.js";import{F as ne,G as L,L as re,S as R,U as z,i as B,m as V,s as H}from"./index-D1Lv9nnm.js";import{t as U}from"./AdminPage-Dq33XE9j.js";import{r as ie}from"./authed-media-B8T1dsFh.js";import{t as ae}from"./AdminTabs-BN9bq2Fe.js";import{t as W}from"./format-size-CO9d3C3-.js";import{t as G}from"./AddonCollectionPage-r3MDTb2U.js";import{t as K}from"./addon-display-names-DvSEQty-.js";var q=L(`archive`,[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8`,key:`1s80jp`}],[`path`,{d:`M10 12h4`,key:`a56b0p`}]]),J=L(`arrow-right`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]),oe=L(`calendar-clock`,[[`path`,{d:`M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5`,key:`1osxxc`}],[`path`,{d:`M16 2v4`,key:`4m81vk`}],[`path`,{d:`M8 2v4`,key:`1cmpym`}],[`path`,{d:`M3 10h5`,key:`r794hk`}],[`path`,{d:`M17.5 17.5 16 16.3V14`,key:`akvzfd`}],[`circle`,{cx:`16`,cy:`16`,r:`6`,key:`qoo3c4`}]]),se=L(`file-text`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]);y();var ce=new Set([`recordings`,`recordingsLow`]);function le(e){let t=e.filesTotal===null?``:`/${e.filesTotal}`,n=Math.round(e.bytesMoved/(1024*1024)),r=`${e.entities.join(`+`)}: ${e.filesMoved}${t} files, ${n} MB — ${e.state}`;return e.error?`${r} (${e.error})`:r}function ue({location:e,onClose:t}){let n=O().trpcClient,[r,i]=T(``),[a,o]=T(!0),[s,c]=T(!0),[l,u]=T(null),[d,f]=T(!1),p=S({queryKey:[`storage`,`listLocations`,`relocate`],queryFn:()=>n.storage.listLocations.query({})}),m=x(()=>(p.data??[]).filter(t=>t.id!==e.id&&ce.has(t.type)&&t.config.readOnly!==!0&&t.config.basePath!==e.config.basePath),[p.data,e]),h=S({queryKey:[`relocate`,`jobs`],queryFn:async()=>{let[e,t]=await Promise.all([n.recording.getRelocateStatus.query({}).catch(()=>[]),n.pipelineAnalytics.getMediaRelocateStatus.query({}).catch(()=>[])]);return[...e,...t].sort((e,t)=>t.startedAt-e.startedAt)},refetchInterval:2e3}),g=h.data??[],_=g.some(e=>e.state===`running`);D(()=>{r===``&&m.length>0&&i(m[0].id)},[m,r]);let v=async()=>{if(r!==``){u(null),f(!0);try{a&&await n.recording.relocateFootage.mutate({fromLocationId:e.id,toLocationId:r}),s&&await n.pipelineAnalytics.relocateMedia.mutate({toLocationId:r}),await h.refetch()}catch(e){u(e instanceof Error?e.message:String(e))}finally{f(!1)}}},y=async e=>{try{e.entities.includes(`media`)?await n.pipelineAnalytics.cancelMediaRelocate.mutate({jobId:e.jobId}):await n.recording.cancelRelocate.mutate({jobId:e.jobId}),await h.refetch()}catch{}};return E(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm`,onClick:t,children:b(`div`,{className:`w-full max-w-md rounded-xl border border-border bg-surface shadow-2xl`,onClick:e=>e.stopPropagation(),children:[b(`div`,{className:`flex items-start justify-between border-b border-border px-4 py-3`,children:[b(`div`,{className:`space-y-0.5`,children:[b(`h2`,{className:`flex items-center gap-1.5 text-sm font-semibold text-foreground`,children:[E(k,{className:`h-3.5 w-3.5`}),`Relocate from `,e.displayName]}),E(`p`,{className:`text-xs text-foreground-subtle`,children:`Throttled background move; safe to re-run — it resumes where it stopped. Mark this location read-only first so nothing new lands here.`})]}),E(`button`,{onClick:t,className:`text-foreground-subtle hover:text-foreground`,children:E(B,{className:`h-4 w-4`})})]}),b(`div`,{className:`p-4 space-y-3`,children:[b(`div`,{className:`space-y-1`,children:[E(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Target location`}),m.length===0?E(`p`,{className:`text-[11px] text-foreground-subtle`,children:`No writable recordings location on a different root to move to.`}):E(`select`,{value:r,onChange:e=>i(e.target.value),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground`,children:m.map(e=>b(`option`,{value:e.id,children:[e.displayName,` (`,String(e.config.basePath??e.id),`)`]},e.id))})]}),b(`div`,{className:`space-y-1`,children:[b(`label`,{className:`flex items-center gap-2 text-xs text-foreground cursor-pointer`,children:[E(`input`,{type:`checkbox`,checked:a,onChange:e=>o(e.target.checked),className:`accent-primary`}),`Footage (segments + strips)`]}),b(`label`,{className:`flex items-center gap-2 text-xs text-foreground cursor-pointer`,children:[E(`input`,{type:`checkbox`,checked:s,onChange:e=>c(e.target.checked),className:`accent-primary`}),`Event media (crops, thumbnails, snapshots)`]})]}),l&&E(`p`,{className:`text-[11px] text-danger`,children:l}),g.length>0&&E(`div`,{className:`rounded-md border border-border divide-y divide-border`,children:g.slice(0,4).map(e=>b(`div`,{className:`flex items-center gap-2 px-2.5 py-1.5`,children:[E(`span`,{className:`flex-1 truncate text-[11px] text-foreground`,children:le(e)}),e.state===`running`&&E(`button`,{onClick:()=>void y(e),className:`rounded border border-border px-1.5 py-0.5 text-[10px] text-foreground-subtle hover:text-foreground`,children:`Cancel`})]},e.jobId))})]}),b(`div`,{className:`flex justify-end gap-2 border-t border-border px-4 py-3`,children:[E(`button`,{onClick:t,className:`rounded border border-border px-3 py-1.5 text-xs text-foreground-subtle hover:text-foreground`,children:`Close`}),E(`button`,{onClick:()=>void v(),disabled:r===``||d||_||!a&&!s,className:`rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground disabled:opacity-50`,children:_?`Running…`:`Start relocation`})]})]})})}y();function de(){let r=w(),i=h(),{data:a,isLoading:o,isError:s}=c({}),l=t(),u=x(()=>l.data??[],[l.data]),[d,f]=T(null),[p,m]=T(null),[g,_]=T(null),v=n({onSuccess:()=>{r.invalidateQueries({queryKey:[[`storage`,`listLocations`]]})}}),y=e({onSuccess:()=>{r.invalidateQueries({queryKey:[[`storage`,`listLocations`]]})}}),S=e=>{e.isDefault||y.mutate({id:e.id,type:e.type,providerId:e.providerId,displayName:e.displayName,config:e.config,isDefault:!0})},C=async e=>{if(e.isDefault){await i({title:`Cannot delete default location`,message:`"${e.displayName}" is the default for type "${e.type}". Mark another location as default first, then delete this one.`,confirmLabel:`OK`,variant:`warning`});return}await i({title:`Delete location "${e.displayName}"?`,message:`This removes the location record. Files on disk are not deleted; the underlying directory or remote path stays untouched.`,confirmLabel:`Delete`,variant:`danger`})&&v.mutate({id:e.id})},D=x(()=>{let e=new Map;for(let t of a??[]){let n=e.get(t.type);n?n.push(t):e.set(t.type,[t])}return e},[a]),O=o||l.isLoading,k=s||l.isError;return b(U,{children:[O&&E(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:`Loading locations…`}),k&&E(`div`,{className:`text-xs text-danger`,children:`Failed to load storage locations.`}),!O&&!k&&b(`div`,{className:`space-y-3`,children:[u.length===0&&E(`div`,{className:`rounded-lg border border-border bg-surface px-3 py-4 text-center text-[11px] text-foreground-subtle italic`,children:`No storage locations declared by any installed addon.`}),u.map(e=>E(M,{type:e.id,displayName:e.displayName,description:e.description,cardinality:e.cardinality,locations:D.get(e.id)??[],onAdd:e=>f(e),onEdit:e=>m(e),onDelete:e=>{C(e)},onSetDefault:e=>S(e),...e.id===`recordings`||e.id===`recordingsLow`?{onRelocate:e=>_(e)}:{}},e.id))]}),d!==null&&E(N,{initialType:d,onClose:()=>f(null),onCreated:()=>{r.invalidateQueries({queryKey:[[`storage`,`listLocations`]]}),f(null)}}),p!==null&&E(j,{location:p,onClose:()=>m(null),onSaved:()=>{r.invalidateQueries({queryKey:[[`storage`,`listLocations`]]}),m(null)}}),g&&E(ue,{location:g,onClose:()=>_(null)})]})}y();var fe=[[`backup`,`listDestinations`]],pe=[`backup`,`listArchives`];function me({destinationId:e,restoreSupported:t,onOpenRestoreWizard:n}){let r=w(),i=h(),{data:a,isLoading:o,isError:s}=d({destinationId:e}),c=a??[],l=u({onSuccess:()=>{r.invalidateQueries({queryKey:[[...pe]]}),r.invalidateQueries({queryKey:fe})}}),f=v(async t=>{await i({title:`Delete this archive?`,message:`Permanently deletes "${t.label??t.id}" and frees ${W(t.sizeBytes)}.`,confirmLabel:`Delete`,variant:`danger`})&&l.mutate({destinationId:e,backupId:t.id})},[i,e,l]),[p,m]=T(null),g=v(async t=>{m(t.id);try{let n=await ie(he(e,t.id)),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`${t.label??t.id}.tar.gz`,document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(r)}finally{m(null)}},[e]),_=x(()=>[...c].toSorted((e,t)=>t.createdAt-e.createdAt),[c]);return o?E(`div`,{className:`text-xs text-foreground-subtle animate-pulse py-2`,children:`Loading archives…`}):s?E(`div`,{className:`text-xs text-danger py-2`,children:`Failed to read manifest for this destination`}):_.length===0?E(`div`,{className:`text-xs text-foreground-subtle italic py-2`,children:`No archives at this destination yet.`}):E(`div`,{className:`rounded border border-border bg-surface overflow-x-auto`,children:b(`table`,{className:`w-full text-xs min-w-[640px]`,children:[E(`thead`,{children:b(`tr`,{className:`text-foreground-subtle bg-background/30`,children:[E(`th`,{className:`text-left px-3 py-1.5 font-medium`,children:`When`}),E(`th`,{className:`text-left px-3 py-1.5 font-medium`,children:`Label`}),E(`th`,{className:`text-left px-3 py-1.5 font-medium`,children:`Includes`}),E(`th`,{className:`text-right px-3 py-1.5 font-medium`,children:`Size`}),E(`th`,{className:`text-right px-3 py-1.5 font-medium w-52`,children:`Actions`})]})}),E(`tbody`,{children:_.map(r=>b(`tr`,{className:`border-t border-border hover:bg-primary/5`,children:[E(`td`,{className:`px-3 py-1.5 text-foreground tabular-nums`,children:ge(r.createdAt)}),E(`td`,{className:`px-3 py-1.5 text-foreground`,children:r.label??E(`span`,{className:`text-foreground-subtle italic`,children:`—`})}),E(`td`,{className:`px-3 py-1.5 text-foreground-subtle`,children:r.locations.join(`, `)}),E(`td`,{className:`px-3 py-1.5 text-foreground text-right tabular-nums`,children:W(r.sizeBytes)}),E(`td`,{className:`px-3 py-1.5`,children:b(`div`,{className:`flex items-center justify-end gap-1`,children:[b(`button`,{onClick:()=>{g(r)},disabled:p===r.id,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-foreground-subtle hover:text-foreground hover:bg-primary/10 disabled:opacity-50`,title:`Download archive`,children:[p===r.id?E(R,{className:`h-3 w-3 animate-spin`}):E(P,{className:`h-3 w-3`}),`Download`]}),t&&n&&b(`button`,{onClick:()=>n({destinationId:e,archiveId:r.id}),className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-primary hover:bg-primary/10`,title:`Restore from this archive`,children:[E(I,{className:`h-3 w-3`}),`Restore`]}),E(`button`,{onClick:()=>{f(r)},disabled:l.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10 disabled:opacity-50`,title:`Delete archive`,children:l.isPending?E(R,{className:`h-3 w-3 animate-spin`}):E(H,{className:`h-3 w-3`})})]})})]},r.id))})]})})}function he(e,t){return`/api/backup/download/${encodeURIComponent(e)}/${encodeURIComponent(t)}`}function ge(e){return new Date(e).toLocaleString(void 0,{day:`2-digit`,month:`short`,year:`numeric`,hour:`2-digit`,minute:`2-digit`})}y();var Y=[[`backup`,`listSchedules`]];function _e({onEdit:e,onOpenRestoreWizard:t}){let{data:n,isLoading:r,isError:a}=s(),o=n??[],c=i().data??[],l=x(()=>{let e=new Map;for(let t of c)e.set(t.id,t);return e},[c]),[u,d]=T(null),f=e=>{d(t=>t===e?null:e)};return r?E(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:`Loading backup entries…`}):a?E(`div`,{className:`text-xs text-danger`,children:`Failed to load backup entries`}):o.length===0?E(`div`,{className:`rounded-lg border border-border bg-surface px-4 py-8 text-center`,children:E(`p`,{className:`text-xs text-foreground-subtle`,children:`No backup entries yet. Create one to schedule backups across one or more storage locations.`})}):E(`div`,{className:`rounded-lg border border-border bg-surface overflow-x-auto`,children:b(`table`,{className:`w-full text-xs min-w-[820px]`,children:[E(`thead`,{children:b(`tr`,{className:`text-foreground-subtle border-b border-border bg-background/40`,children:[E(`th`,{className:`text-left px-3 py-2 font-medium w-6`}),E(`th`,{className:`text-left px-3 py-2 font-medium`,children:`Entry`}),E(`th`,{className:`text-left px-3 py-2 font-medium w-20`,children:`Enabled`}),E(`th`,{className:`text-left px-3 py-2 font-medium`,children:`Locations`}),E(`th`,{className:`text-left px-3 py-2 font-medium w-24`,children:`Retention`}),E(`th`,{className:`text-left px-3 py-2 font-medium w-48`,children:`Schedule`}),E(`th`,{className:`text-right px-3 py-2 font-medium w-52`,children:`Actions`})]})}),E(`tbody`,{children:o.map(n=>E(ve,{row:n,destById:l,isOpen:u===n.id,onToggle:()=>f(n.id),onEdit:()=>e(n),...t?{onOpenRestoreWizard:t}:{}},n.id))})]})})}function ve({row:e,destById:t,isOpen:n,onToggle:r,onEdit:i,onOpenRestoreWizard:o}){let s=w(),c=h(),l=f({onSuccess:()=>{s.invalidateQueries({queryKey:Y})}}),u=a({onSuccess:()=>{s.invalidateQueries({queryKey:Y})}}),d=p({onSuccess:()=>{s.invalidateQueries({queryKey:[[`backup`,`listArchives`]]}),s.invalidateQueries({queryKey:[[`backup`,`listDestinations`]]})}}),[m,g]=T(String(e.retentionCount));D(()=>{g(String(e.retentionCount))},[e.retentionCount]);let _=x(()=>({id:e.id,label:e.label,cron:e.cron,locationIds:[...e.locationIds],retentionCount:e.retentionCount,...e.dataSources?{dataSources:[...e.dataSources]}:{}}),[e]),y=v(e=>{l.mutate({..._,enabled:e})},[l,_]),S=v(()=>{let t=Number.parseInt(m,10);if(Number.isNaN(t)||t<1){g(String(e.retentionCount));return}t!==e.retentionCount&&l.mutate({..._,enabled:e.enabled,retentionCount:t})},[l,_,m,e.retentionCount,e.enabled]),O=v(()=>{e.locationIds.length!==0&&d.mutate({destinations:[...e.locationIds],...e.dataSources&&e.dataSources.length>0?{locations:[...e.dataSources]}:{},label:e.label,retentionCount:e.retentionCount})},[d,e]),k=v(async()=>{await c({title:`Delete backup entry?`,message:`"${e.label||e.id}" will stop running. Existing archives are kept.`,confirmLabel:`Delete`,variant:`warning`})&&u.mutate({id:e.id})},[c,u,e.id,e.label]),A=e.cron.trim().length>0,j=l.isPending||u.isPending;return b(C,{children:[b(`tr`,{className:`border-t border-border first:border-t-0 hover:bg-primary/5`,children:[E(`td`,{className:`px-2 py-2`,children:E(`button`,{onClick:r,className:`inline-flex items-center justify-center rounded p-1 text-foreground-subtle hover:bg-primary/10 hover:text-foreground`,title:n?`Hide archives`:`Show archives`,children:E(n?re:ne,{className:`h-3.5 w-3.5`})})}),E(`td`,{className:`px-3 py-2`,children:b(`button`,{onClick:i,className:`text-left hover:underline focus:outline-none`,children:[E(`div`,{className:`text-foreground font-medium`,children:e.label||`(unnamed)`}),e.lastRunAt!==void 0&&b(`div`,{className:`text-[10px] text-foreground-subtle mt-0.5`,children:[`last run `,new Date(e.lastRunAt).toLocaleString()]})]})}),E(`td`,{className:`px-3 py-2`,children:E(`label`,{className:`inline-flex items-center cursor-pointer`,children:E(`input`,{type:`checkbox`,className:`accent-primary`,checked:e.enabled,disabled:j,onChange:e=>y(e.target.checked)})})}),E(`td`,{className:`px-3 py-2`,children:b(`div`,{className:`flex flex-wrap gap-1`,children:[e.locationIds.length===0&&E(`span`,{className:`text-[11px] text-danger italic`,children:`No locations`}),e.locationIds.map(e=>E(`span`,{className:`inline-flex items-center rounded border border-border bg-background px-1.5 py-0.5 text-[10px] text-foreground`,title:e,children:t.get(e)?.displayName??e},e))]})}),E(`td`,{className:`px-3 py-2`,children:E(`input`,{type:`number`,min:1,max:1e3,value:m,disabled:j,onChange:e=>g(e.target.value),onBlur:S,onKeyDown:t=>{t.key===`Enter`&&t.target.blur(),t.key===`Escape`&&g(String(e.retentionCount))},className:`w-16 rounded border border-border bg-background px-2 py-1 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`})}),E(`td`,{className:`px-3 py-2`,children:b(`button`,{onClick:i,className:`group flex flex-col items-start gap-0.5 text-left`,title:`Edit schedule`,children:[b(`span`,{className:`inline-flex items-center gap-1`,children:[E(oe,{className:`h-3 w-3 text-foreground-subtle group-hover:text-foreground`}),E(`span`,{className:`font-mono text-[11px] text-foreground`,children:A?e.cron:`Manual`})]}),A&&e.nextRunAt!==void 0&&b(`span`,{className:`text-[10px] text-foreground-subtle`,children:[`next `,new Date(e.nextRunAt).toLocaleString()]})]})}),E(`td`,{className:`px-3 py-2`,children:b(`div`,{className:`flex items-center justify-end gap-1.5`,children:[b(`button`,{onClick:O,disabled:d.isPending||e.locationIds.length===0,className:`inline-flex items-center gap-1 rounded bg-primary px-2 py-1 text-[11px] font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,title:`Run this entry now`,children:[d.isPending?E(R,{className:`h-3 w-3 animate-spin`}):E(ee,{className:`h-3 w-3`}),`Run now`]}),E(`button`,{onClick:i,className:`inline-flex items-center justify-center rounded border border-border p-1 text-foreground-subtle hover:text-foreground hover:bg-primary/5`,title:`Edit entry`,children:E(F,{className:`h-3 w-3`})}),E(`button`,{onClick:()=>{k()},disabled:j,className:`inline-flex items-center justify-center rounded border border-border p-1 text-foreground-subtle hover:text-danger hover:border-danger/40 disabled:opacity-50`,title:`Delete entry`,children:E(H,{className:`h-3 w-3`})})]})})]}),n&&E(`tr`,{className:`border-t border-border bg-background/30`,children:b(`td`,{colSpan:7,className:`px-4 py-3 space-y-4`,children:[e.locationIds.length===0&&E(`p`,{className:`text-xs text-foreground-subtle italic`,children:`This entry has no locations selected.`}),e.locationIds.map(e=>b(`div`,{className:`space-y-1.5`,children:[E(`div`,{className:`text-[11px] font-medium text-foreground-subtle`,children:t.get(e)?.displayName??e}),E(me,{destinationId:e,restoreSupported:t.get(e)?.restoreSupported??!0,...o?{onOpenRestoreWizard:o}:{}})]},e))]})})]})}y();var X=[{id:`manual`,label:`Manual only`,cron:``},{id:`hourly`,label:`Every hour`,cron:`0 * * * *`,description:`On the hour`},{id:`every-3h`,label:`Every 3 hours`,cron:`0 */3 * * *`,description:`00:00, 03:00, 06:00, 09:00 …`},{id:`every-6h`,label:`Every 6 hours`,cron:`0 */6 * * *`,description:`00:00, 06:00, 12:00, 18:00`},{id:`daily-3am`,label:`Daily at 03:00`,cron:`0 3 * * *`,description:`Every night at 3 AM`},{id:`weekly-sun`,label:`Weekly Sunday 03:00`,cron:`0 3 * * 0`,description:`Sunday morning at 3 AM`}];function ye(e){let t=e.trim();for(let e of X)if(e.cron===t)return e.id;return`custom`}function be({value:e,onChange:t,previewCount:n=5,disabled:r=!1}){let i=ye(e),[a,o]=T(i===`custom`);D(()=>{i!==`custom`&&o(!1)},[i]);let s=Ce(e,250),c=g({cron:s,count:n},{enabled:s.trim().length>0}),l=c.data??null,u=e=>{o(!1),t(e.cron)},d=a||i===`custom`;return b(`div`,{className:`space-y-3`,children:[b(`div`,{className:`space-y-1`,children:[E(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Schedule preset`}),b(`div`,{className:`flex flex-wrap gap-1.5`,children:[X.map(e=>E(`button`,{type:`button`,onClick:()=>u(e),disabled:r,className:`rounded border px-2 py-1 text-[11px] transition-colors disabled:opacity-50 `+(!a&&i===e.id?`border-primary bg-primary/10 text-primary`:`border-border bg-background text-foreground-subtle hover:bg-primary/5 hover:text-foreground`),title:e.description??e.label,children:e.label},e.id)),E(`button`,{type:`button`,onClick:()=>{o(!0),e.trim().length===0&&t(`0 3 * * *`)},disabled:r,className:`rounded border px-2 py-1 text-[11px] transition-colors disabled:opacity-50 `+(d?`border-primary bg-primary/10 text-primary`:`border-border bg-background text-foreground-subtle hover:bg-primary/5 hover:text-foreground`),children:`Custom…`})]})]}),d&&b(`div`,{className:`space-y-1`,children:[E(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Cron expression (5-field POSIX)`}),E(`input`,{type:`text`,value:e,onChange:e=>t(e.target.value),disabled:r,placeholder:`0 3 * * *`,spellCheck:!1,className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs font-mono text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-1 focus:ring-primary`}),b(`p`,{className:`text-[10px] text-foreground-subtle`,children:[`Format: `,E(`span`,{className:`font-mono`,children:`minute hour day-of-month month day-of-week`}),` · all times server-local`]})]}),E(xe,{cron:s,preview:l,loading:c.isFetching})]})}function xe({cron:e,preview:t,loading:n}){return n&&t===null?b(`div`,{className:`flex items-center gap-2 rounded border border-border bg-background/40 px-3 py-2 text-[11px] text-foreground-subtle`,children:[E(R,{className:`h-3 w-3 animate-spin`}),`Validating…`]}):t===null?null:t.ok?t.nextRuns.length===0?E(`div`,{className:`rounded border border-border bg-background/40 px-3 py-2 text-[11px] text-foreground-subtle`,children:`No future runs match this expression.`}):b(`div`,{className:`space-y-1`,children:[E(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Next runs`}),E(`ul`,{className:`rounded border border-border bg-background/40 divide-y divide-border`,children:t.nextRuns.map((e,t)=>b(`li`,{className:`flex items-center justify-between px-3 py-1.5 text-[11px]`,children:[E(`span`,{className:`text-foreground tabular-nums`,children:new Date(e).toLocaleString()}),E(`span`,{className:`text-foreground-subtle text-[10px] tabular-nums`,children:Se(e)})]},`${e}-${t}`))})]}):E(`div`,{className:`rounded border border-danger/40 bg-danger/10 px-3 py-2 text-[11px] text-danger`,children:t.error??`Invalid cron expression`})}function Se(e){let t=e-Date.now();if(t<=0)return`now`;let n=Math.floor(t/1e3);if(n<60)return`in ${n}s`;let r=Math.floor(n/60);if(r<60)return`in ${r}m`;let i=Math.floor(r/60);return i<24?`in ${i}h`:`in ${Math.floor(i/24)}d`}function Ce(e,t){let[n,r]=T(e),i=x(()=>e,[e]);return D(()=>{let e=setTimeout(()=>r(i),t);return()=>clearTimeout(e)},[i,t]),n}y();var we=[[`backup`,`listSchedules`]];function Te({entry:e,onClose:t,onSaved:n}){let r=w(),a=i(),o=a.data??[],[s,c]=T(e?.label??``),[l,u]=T(e?.cron??`0 3 * * *`),[d,p]=T(e?.enabled??!0),[m,h]=T(String(e?.retentionCount??7)),[g,_]=T(new Set(e?.locationIds??[])),v=f({onSuccess:()=>{r.invalidateQueries({queryKey:we}),n()}}),y=e=>{_(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},S=Number.parseInt(m,10),C=x(()=>s.trim().length>0&&g.size>0&&!Number.isNaN(S)&&S>=1&&S<=1e3,[s,g,S]),D=()=>{C&&v.mutate({...e?{id:e.id}:{},label:s.trim(),cron:l.trim(),enabled:d,locationIds:Array.from(g),retentionCount:S})},O=v.error instanceof Error?v.error.message:null;return E(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm`,onClick:t,children:b(`div`,{className:`w-full max-w-lg rounded-xl border border-border bg-surface shadow-2xl max-h-[90vh] overflow-y-auto`,onClick:e=>e.stopPropagation(),children:[b(`div`,{className:`flex items-start justify-between border-b border-border px-4 py-3 sticky top-0 bg-surface`,children:[E(`h2`,{className:`text-sm font-semibold text-foreground`,children:e?`Edit backup entry`:`New backup entry`}),E(`button`,{onClick:t,className:`text-foreground-subtle hover:text-foreground`,children:E(B,{className:`h-4 w-4`})})]}),b(`div`,{className:`p-4 space-y-4`,children:[b(`div`,{className:`space-y-1`,children:[E(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:`Name`}),E(`input`,{type:`text`,value:s,onChange:e=>c(e.target.value),placeholder:`Nightly offsite`,className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-1 focus:ring-primary`})]}),b(`div`,{className:`space-y-1.5`,children:[b(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:[`Locations (`,g.size,` selected)`]}),a.isLoading&&b(`div`,{className:`flex items-center gap-2 px-1 py-2 text-xs text-foreground-subtle`,children:[E(R,{className:`h-3.5 w-3.5 animate-spin`}),`Loading locations…`]}),!a.isLoading&&o.length===0&&E(`div`,{className:`rounded border border-border bg-background px-3 py-2 text-xs text-foreground-subtle italic`,children:"No `backups` storage locations configured. Add one in Settings → Storage first."}),o.length>0&&E(`div`,{className:`rounded border border-border bg-background divide-y divide-border max-h-52 overflow-y-auto`,children:o.map(e=>b(`label`,{className:`flex items-center justify-between px-3 py-2 text-xs hover:bg-primary/5 cursor-pointer`,children:[b(`div`,{className:`flex items-center gap-2`,children:[E(`input`,{type:`checkbox`,checked:g.has(e.id),onChange:()=>y(e.id),className:`accent-primary`}),E(`span`,{className:`text-foreground`,children:e.displayName})]}),b(`div`,{className:`flex items-center gap-1.5`,children:[E(`span`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle bg-surface border border-border rounded px-1.5 py-0.5`,children:e.kind}),E(`span`,{className:`text-[10px] text-foreground-subtle font-mono`,children:e.id})]})]},e.id))})]}),b(`div`,{className:`grid grid-cols-2 gap-3`,children:[b(`div`,{className:`space-y-1`,children:[E(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:`Retention (archives kept)`}),E(`input`,{type:`number`,min:1,max:1e3,value:m,onChange:e=>h(e.target.value),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`})]}),b(`div`,{className:`space-y-1`,children:[E(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:`Enabled`}),b(`label`,{className:`inline-flex items-center gap-2 py-1.5 cursor-pointer`,children:[E(`input`,{type:`checkbox`,checked:d,onChange:e=>p(e.target.checked),className:`accent-primary`}),E(`span`,{className:`text-xs text-foreground-subtle`,children:`Run on schedule`})]})]})]}),b(`div`,{className:`space-y-1.5 border-t border-border pt-3`,children:[E(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:`Schedule`}),E(be,{value:l,onChange:u,disabled:v.isPending})]}),O&&E(`div`,{className:`rounded border border-danger/40 bg-danger/10 px-3 py-2 text-[11px] text-danger`,children:O})]}),b(`div`,{className:`flex justify-end gap-2 border-t border-border px-4 py-3 sticky bottom-0 bg-surface`,children:[E(`button`,{onClick:t,className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:`Cancel`}),b(`button`,{onClick:D,disabled:!C||v.isPending,className:`inline-flex items-center gap-1.5 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,children:[v.isPending&&E(R,{className:`h-3.5 w-3.5 animate-spin`}),e?`Save`:`Create entry`]})]})]})})}y();var Ee=[[`backup`,`list`]];function De({initialDestinationId:e,initialArchiveId:t,onClose:n,onScheduled:r}){let a=w(),[s,c]=T(e&&t?2:1),[u,f]=T(e),[p,m]=T(t),[h,g]=T(new Set),{data:_}=i(),v=_??[],{data:y,isLoading:S}=d({destinationId:u??``},{enabled:!!u}),C=y??[];D(()=>{if(u!==void 0)return;let e=v.filter(e=>e.restoreSupported);e.length===1&&f(e[0].id)},[u,v]);let{data:O}=l({destinationId:u??``,backupId:p??``},{enabled:!!u&&!!p}),k=x(()=>O?.locations??[],[O]);D(()=>{k.length!==0&&g(e=>e.size===0?new Set(k):e)},[k]);let A=o({onSuccess:()=>{a.invalidateQueries({queryKey:Ee}),r(),n()}}),j=e=>{g(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},M=!!u&&!!p,N=h.size>0,P=M&&N&&!A.isPending,F=()=>{!u||!p||A.mutate({destinationId:u,backupId:p,locations:[...h]})};return E(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm`,onClick:n,children:b(`div`,{className:`w-full max-w-md rounded-xl border border-border bg-surface shadow-2xl`,onClick:e=>e.stopPropagation(),children:[b(`div`,{className:`flex items-start justify-between border-b border-border px-4 py-3`,children:[b(`div`,{className:`space-y-0.5`,children:[E(`h2`,{className:`text-sm font-semibold text-foreground`,children:`Restore Backup`}),b(`p`,{className:`text-xs text-foreground-subtle`,children:[`Step `,s,` of 3 —`,` `,s===1?`pick source`:s===2?`pick locations`:`confirm`]})]}),E(`button`,{onClick:n,className:`text-foreground-subtle hover:text-foreground`,children:E(B,{className:`h-4 w-4`})})]}),s===1&&E(Oe,{destinations:v,destinationId:u,onPickDestination:e=>{f(e),m(void 0),g(new Set)},archives:C,archivesLoading:S,archiveId:p,onPickArchive:m}),s===2&&E(ke,{locations:k,picked:h,onToggle:j}),s===3&&E(Z,{destinationName:v.find(e=>e.id===u)?.displayName??u??``,archive:C.find(e=>e.id===p),picked:[...h]}),b(`div`,{className:`flex justify-between gap-2 border-t border-border px-4 py-3`,children:[E(`div`,{children:s>1&&b(`button`,{onClick:()=>c(e=>e===3?2:1),className:`inline-flex items-center gap-1 rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:[E(z,{className:`h-3 w-3`}),`Back`]})}),b(`div`,{className:`flex items-center gap-2`,children:[E(`button`,{onClick:n,className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:`Cancel`}),s<3?b(`button`,{disabled:s===1&&!M||s===2&&!N,onClick:()=>c(e=>e===1?2:3),className:`inline-flex items-center gap-1 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,children:[`Next`,E(J,{className:`h-3 w-3`})]}):b(`button`,{onClick:F,disabled:!P,className:`inline-flex items-center gap-1.5 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,children:[A.isPending?E(R,{className:`h-3.5 w-3.5 animate-spin`}):E(I,{className:`h-3.5 w-3.5`}),`Schedule Restore`]})]})]})]})})}function Oe({destinations:e,destinationId:t,onPickDestination:n,archives:r,archivesLoading:i,archiveId:a,onPickArchive:o}){let s=e.filter(e=>e.restoreSupported);return b(`div`,{className:`p-4 space-y-3`,children:[b(`div`,{className:`space-y-1.5`,children:[E(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:`Destination`}),b(`select`,{value:t??``,onChange:e=>n(e.target.value),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`,children:[E(`option`,{value:``,disabled:!0,children:`Select destination…`}),s.map(e=>b(`option`,{value:e.id,children:[e.displayName,` (`,e.kind,`)`]},e.id))]})]}),b(`div`,{className:`space-y-1.5`,children:[E(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:`Archive`}),!t&&E(`div`,{className:`text-xs text-foreground-subtle italic`,children:`Pick a destination first.`}),t&&i&&E(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:`Reading archives…`}),t&&!i&&r.length===0&&E(`div`,{className:`text-xs text-foreground-subtle italic`,children:`No archives available at this destination.`}),t&&r.length>0&&E(`div`,{className:`rounded border border-border bg-background divide-y divide-border max-h-64 overflow-y-auto`,children:r.map(e=>{let t=a===e.id;return b(`label`,{className:`flex items-center justify-between px-3 py-2 text-xs cursor-pointer ${t?`bg-primary/10`:`hover:bg-primary/5`}`,children:[b(`div`,{className:`flex items-center gap-2`,children:[E(`input`,{type:`radio`,name:`archive`,checked:t,onChange:()=>o(e.id),className:`accent-primary`}),b(`div`,{children:[E(`div`,{className:`font-medium text-foreground`,children:e.label??e.id}),E(`div`,{className:`text-[10px] text-foreground-subtle`,children:new Date(e.createdAt).toLocaleString()})]})]}),E(`span`,{className:`text-[10px] text-foreground-subtle tabular-nums`,children:W(e.sizeBytes)})]},e.id)})})]})]})}function ke({locations:e,picked:t,onToggle:n}){return e.length===0?E(`div`,{className:`p-4`,children:E(`div`,{className:`text-xs text-foreground-subtle`,children:`Loading archive manifest… If this persists, the archive may predate manifests — restoring will apply everything in the tarball.`})}):b(`div`,{className:`p-4 space-y-3`,children:[E(`div`,{className:`rounded border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-[11px] text-amber-700 dark:text-amber-300`,children:`Selected entries will overwrite live data on the next server restart. Unchecked entries stay current.`}),b(`div`,{className:`space-y-1.5`,children:[E(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:`Apply`}),E(`div`,{className:`rounded border border-border bg-background divide-y divide-border max-h-64 overflow-y-auto`,children:e.map(e=>b(`label`,{className:`flex items-center gap-2 px-3 py-2 text-xs hover:bg-primary/5 cursor-pointer`,children:[E(`input`,{type:`checkbox`,checked:t.has(e),onChange:()=>n(e),className:`accent-primary`}),E(`span`,{className:`font-mono text-foreground`,children:e}),E(`span`,{className:`ml-auto text-[10px] text-foreground-subtle`,children:je(e)})]},e))})]})]})}function Z({destinationName:e,archive:t,picked:n}){return b(`div`,{className:`p-4 space-y-3 text-xs`,children:[E(`div`,{className:`rounded border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-amber-700 dark:text-amber-300`,children:`Restore is applied at next server boot. Active connections will drop when you restart.`}),b(`dl`,{className:`space-y-1.5`,children:[E(Q,{term:`Destination`,value:e}),E(Q,{term:`Archive`,value:t?.label??t?.id??`—`}),t&&E(Q,{term:`Created`,value:`${new Date(t.createdAt).toLocaleString()} · ${W(t.sizeBytes)}`}),E(Q,{term:`Locations`,value:n.length>0?n.join(`, `):`— (full archive)`})]})]})}function Q({term:e,value:t}){return b(`div`,{className:`flex justify-between gap-3`,children:[E(`dt`,{className:`text-foreground-subtle`,children:e}),E(`dd`,{className:`text-foreground font-mono text-right truncate`,children:t})]})}var Ae={db:`Database`,addons:`Addon configs`,"addons-data":`Addon data`,tls:`TLS certificates`,cache:`Cache`,data:`Top-level data`};function je(e){return Ae[e]??``}y();function Me(){let e=h(),t=r(),[n,i]=T(null),[a,o]=T(!1),[s,c]=T(!1),[l,u]=T(void 0),d=async()=>{await e({title:`Restart server now?`,message:`Active connections will drop and the apply-backup hook will run before boot.`,confirmLabel:`Restart`,variant:`warning`})&&t.mutate({confirm:!0})};return b(U,{children:[b(`div`,{className:`flex items-center justify-end gap-2 flex-wrap`,children:[b(`button`,{onClick:()=>o(!0),className:`inline-flex items-center gap-1.5 rounded-lg bg-surface border border-border px-3 py-1.5 text-xs font-medium text-foreground hover:bg-primary/5 hover:border-primary/30`,children:[E(I,{className:`h-3.5 w-3.5`}),`Restore…`]}),b(`button`,{onClick:()=>u(null),className:`inline-flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90`,children:[E(te,{className:`h-3.5 w-3.5`}),`New entry`]})]}),s&&E(`div`,{className:`rounded-lg border border-amber-500/30 bg-amber-500/10 px-3 py-2.5 text-xs text-amber-700 dark:text-amber-300`,children:b(`div`,{className:`flex items-center justify-between gap-3`,children:[b(`div`,{className:`flex items-center gap-2`,children:[E(I,{className:`h-3.5 w-3.5`}),E(`span`,{children:`Restore scheduled. Restart the server to apply.`})]}),b(`button`,{onClick:()=>{d()},disabled:t.isPending,className:`inline-flex items-center gap-1.5 rounded bg-amber-500/20 px-2 py-1 font-medium text-amber-800 dark:text-amber-200 hover:bg-amber-500/30 disabled:opacity-50`,children:[t.isPending?E(R,{className:`h-3.5 w-3.5 animate-spin`}):E(I,{className:`h-3.5 w-3.5`}),`Restart Now`]})]})}),E(_e,{onEdit:e=>u(e),onOpenRestoreWizard:e=>i(e)}),l!==void 0&&E(Te,{entry:l,onClose:()=>u(void 0),onSaved:()=>u(void 0)}),(n||a)&&E(De,{...n?{initialDestinationId:n.destinationId,initialArchiveId:n.archiveId}:{},onClose:()=>{i(null),o(!1)},onScheduled:()=>c(!0)})]})}y();var $=5e3,Ne={"winston-logging":`Rotated log files on this node’s disk.`,"console-logging":`stdout / stderr of the node process.`,"loki-logging":`Pushes to a Grafana Loki instance. Off until enabled with a URL.`,"hub-forwarder":`Agent-only — forwards this node’s entries to the hub.`};function Pe(){let e=_({capName:`log-destination`},{refetchInterval:$}),t=m(void 0,{refetchInterval:$}),n=x(()=>K(t.data??[]),[t.data]),r=x(()=>{let e=new Map;for(let n of t.data??[]){let t=n.description,r=n.id;typeof r==`string`&&typeof t==`string`&&t.length>0&&e.set(r,t)}return e},[t.data]);return E(G,{title:`Logging`,subtitle:`Every registered log destination. Entries are fanned to all enabled destinations at once — enabling one does not disable another. Each destination's own configuration is docked under it.`,pageIcon:V,itemIcon:se,capability:`log-destination`,installButtonLabel:`Add destination`,items:x(()=>(e.data??[]).map(e=>({addonId:e.addonId,displayName:n.get(e.addonId)??e.addonId,isActive:e.isActive,caption:r.get(e.addonId)??Ne[e.addonId]??``})),[e.data,n,r]),isLoading:e.isLoading,emptyTitle:`No log destinations registered`,emptyDescription:`This should not happen — the console and rotated-file destinations are builtins. If the list is empty, the node is still booting.`,renderStatusBadges:e=>e.caption.length>0?E(`span`,{className:`text-[10px] text-foreground-subtle`,children:e.caption}):null})}function Fe(){return E(`div`,{className:`flex flex-col p-4`,children:E(ae,{tabs:[{id:`storage`,label:`Storage`,icon:A,content:E(de,{})},{id:`backup`,label:`Backup`,icon:q,content:E(Me,{})},{id:`logging`,label:`Logging`,icon:V,content:E(Pe,{})}]})})}export{Fe as DataPage};
@@ -0,0 +1 @@
1
+ import{$n as e,Bo as t,Go as n,Io as r,Jn as i,Jo as a,Lo as o,Nn as s,Qn as c,Ro as l,Vo as u,Xn as d,Yn as f,Zn as p,ar as m,er as h,ir as g,nr as _,oo as v,or as y,po as b,qo as x,rr as S,tr as C,zo as w}from"./src-RAEsAO7u.js";import{K as T,Q as E,S as D,W as O,b as k,o as A,q as j,x as M,z as N}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DTufy7Ue.js";import{$ as P}from"./src-CrugYgqk.js";import{a as F,i as I,n as L,r as ee,t as R}from"./face-bbox-DOKrhacR.js";import{a as te,c as ne,f as z,i as re,l as ie,m as B,n as V,o as ae,p as H,r as oe,s as se,t as ce,u as le}from"./debounced-invalidate-D5kf3uDk.js";import{t as U}from"./pencil-Chd1XFvs.js";import{t as W}from"./plus-CLA9DCBk.js";import{t as ue}from"./refresh-cw-Blid1l_b.js";import{t as G}from"./square-check-big-rQeR1daL.js";import{t as de}from"./square-BAUrJi-y.js";import{t as K}from"./undo-2-DWkYdwKX.js";import{F as q,G as fe,L as pe,R as me,S as J,h as Y,i as X,l as he,s as Z}from"./index-D1Lv9nnm.js";import{t as Q}from"./AdminPage-Dq33XE9j.js";import{r as ge,t as _e}from"./authed-media-B8T1dsFh.js";var ve=fe(`user-round`,[[`circle`,{cx:`12`,cy:`8`,r:`5`,key:`1hypcn`}],[`path`,{d:`M20 21a8 8 0 0 0-16 0`,key:`rfgkzh`}]]);E();var $=[[`faceGallery`]];function ye({identityId:e}){let t=A(),{data:n,isLoading:r}=h({identityId:e}),i=_();function a(n){i.mutate({identityId:e,sampleId:n.id},{onSettled:()=>{t.invalidateQueries({queryKey:$})}})}return r?D(`div`,{className:`flex items-center gap-2 py-3 text-xs text-foreground-subtle`,children:[M(J,{className:`h-3.5 w-3.5 animate-spin`}),`Loading samples…`]}):!n||n.length===0?M(`p`,{className:`py-2 text-xs text-foreground-subtle`,children:`No samples yet.`}):M(`div`,{className:`mt-2 grid grid-cols-4 gap-2 sm:grid-cols-6 md:grid-cols-8`,children:n.map(e=>D(`div`,{className:`group relative aspect-square overflow-hidden rounded-md border border-border bg-surface`,children:[e.base64?M(`img`,{src:`data:image/jpeg;base64,${e.base64}`,alt:`Sample`,className:`h-full w-full object-cover`}):M(`div`,{className:`flex h-full w-full items-center justify-center text-foreground-subtle`,children:M(ve,{className:`h-6 w-6`})}),M(`button`,{type:`button`,onClick:()=>a(e),disabled:i.isPending,className:`absolute inset-0 flex items-center justify-center bg-black/50 opacity-0 transition-opacity group-hover:opacity-100 disabled:cursor-not-allowed`,"aria-label":`Remove sample`,children:M(X,{className:`h-4 w-4 text-white`})})]},e.id))})}function be({identity:e,expanded:i,onToggle:s}){let c=A(),[d,f]=j(``),[m,h]=j(!1),[g,_]=j(!1),v=S(),y=p();function b(){f(e.name),h(!0)}function C(){h(!1),f(``)}function T(){let t=d.trim();if(!t||t===e.name){C();return}v.mutate({id:e.id,name:t},{onSettled:()=>{c.invalidateQueries({queryKey:$}),C()}})}function E(){y.mutate({id:e.id},{onSettled:()=>{c.invalidateQueries({queryKey:$}),_(!1)}})}return D(`div`,{className:`rounded-md border border-border bg-surface`,children:[D(`div`,{className:`flex items-center gap-2 px-3 py-2`,children:[M(`div`,{className:`h-8 w-8 shrink-0 overflow-hidden rounded-full border border-border bg-surface-hover`,children:e.coverBase64?M(`img`,{src:`data:image/jpeg;base64,${e.coverBase64}`,alt:e.name,className:`h-full w-full object-cover`}):M(`div`,{className:`flex h-full w-full items-center justify-center`,children:M(ve,{className:`h-4 w-4 text-foreground-subtle`})})}),M(`div`,{className:`flex flex-1 min-w-0 items-center gap-2`,children:m?D(k,{children:[M(n,{value:d,onChange:e=>f(e.target.value),onKeyDown:e=>{e.key===`Enter`&&T(),e.key===`Escape`&&C()},className:`h-6 text-xs`,autoFocus:!0}),M(`button`,{type:`button`,onClick:T,disabled:v.isPending,className:`text-success hover:text-success/80 disabled:opacity-50`,"aria-label":`Confirm rename`,children:M(me,{className:`h-3.5 w-3.5`})}),M(`button`,{type:`button`,onClick:C,className:`text-foreground-subtle hover:text-foreground`,"aria-label":`Cancel rename`,children:M(X,{className:`h-3.5 w-3.5`})})]}):M(`span`,{className:`truncate text-sm font-medium text-foreground`,children:e.name})}),M(x,{variant:`default`,className:`text-[10px]`,children:e.sampleCount}),!m&&D(`div`,{className:`flex items-center gap-1`,children:[M(`button`,{type:`button`,onClick:b,className:`p-1 rounded hover:bg-surface-hover text-foreground-subtle hover:text-foreground`,"aria-label":`Rename`,children:M(U,{className:`h-3.5 w-3.5`})}),M(`button`,{type:`button`,onClick:()=>_(!0),className:`p-1 rounded hover:bg-danger/10 text-foreground-subtle hover:text-danger`,"aria-label":`Delete`,children:M(Z,{className:`h-3.5 w-3.5`})})]}),M(`button`,{type:`button`,onClick:s,className:`p-1 rounded hover:bg-surface-hover text-foreground-subtle`,"aria-label":i?`Collapse`:`Expand`,children:M(i?pe:q,{className:`h-3.5 w-3.5`})})]}),i&&M(`div`,{className:`border-t border-border px-3 pb-3 pt-2`,children:M(ye,{identityId:e.id})}),M(r,{open:g,onOpenChange:e=>!e&&_(!1),children:D(o,{children:[D(t,{children:[M(u,{children:`Delete person`}),D(l,{children:[`Delete `,M(`strong`,{children:e.name}),` and all their samples? This cannot be undone.`]})]}),D(w,{children:[M(a,{variant:`secondary`,onClick:()=>_(!1),children:`Cancel`}),D(a,{variant:`danger`,onClick:E,disabled:y.isPending,children:[y.isPending?M(J,{className:`h-3.5 w-3.5 animate-spin`}):null,`Delete`]})]})]})})]})}function xe(){let e=A(),[t,r]=j(``),i=f();function o(){let n=t.trim();n&&i.mutate({name:n},{onSettled:()=>{e.invalidateQueries({queryKey:$}),r(``)}})}return D(`div`,{className:`flex items-center gap-2 pt-2`,children:[M(n,{placeholder:`New person name…`,value:t,onChange:e=>r(e.target.value),onKeyDown:e=>{e.key===`Enter`&&o()},className:`h-7 text-xs flex-1`}),D(a,{variant:`primary`,size:`sm`,onClick:o,disabled:i.isPending||!t.trim(),children:[i.isPending?M(J,{className:`h-3.5 w-3.5 animate-spin`}):M(W,{className:`h-3.5 w-3.5`}),`Add`]})]})}function Se(){let{data:t,isLoading:n}=e(),[r,i]=j(null);function a(e){i(t=>t===e?null:e)}return n?D(`div`,{className:`flex items-center gap-2 py-4 text-xs text-foreground-subtle`,children:[M(J,{className:`h-4 w-4 animate-spin`}),`Loading people…`]}):D(`div`,{className:`space-y-2`,children:[(!t||t.length===0)&&M(`p`,{className:`py-2 text-xs text-foreground-subtle`,children:`No people enrolled yet. Add one below.`}),t?.map(e=>M(be,{identity:e,expanded:r===e.id,onToggle:()=>a(e.id)},e.id)),M(xe,{})]})}function Ce(e){let t=e.cropUrl!==void 0&&e.cropUrl.length>0,n=e.base64!==void 0&&e.base64.length>0;return!t&&!n}function we(e){return e.filter(Ce).map(e=>e.faceId)}function Te(e){let t=0;for(let n of e)Ce(n)&&(t+=1);return t}function Ee(e){return e==null?null:e.cropUrl!==void 0&&e.cropUrl.length>0?e.cropUrl:e.base64!==void 0&&e.base64.length>0?`data:image/jpeg;base64,${e.base64}`:null}E();var De=[[`faceGallery`]];function Oe({faceIds:e,identities:s,onDone:c}){let d=A(),p=i(),m=f(),[h,g]=j(``),[_,v]=j(!1),[y,b]=j(null),x=e!==null&&e.length>0,S=e?.length??0;function C(){v(!1),g(``),b(null)}function T(){C(),c()}function E(t){!e||e.length===0||p.mutate({faceIds:[...e],identityId:t},{onSettled:()=>{d.invalidateQueries({queryKey:De}),T()}})}function O(){!e||!h.trim()||m.mutate({name:h.trim()},{onSuccess:e=>{e?.id&&E(e.id)},onError:()=>{d.invalidateQueries({queryKey:De}),T()}})}let k=p.isPending||m.isPending;return M(r,{open:x,onOpenChange:e=>!e&&T(),children:D(o,{children:[D(t,{children:[M(u,{children:S>1?`Assign ${String(S)} faces to person`:`Assign face to person`}),M(l,{children:`Select an existing person or create a new one.`})]}),M(`div`,{className:`space-y-1 max-h-56 overflow-y-auto`,children:s.map(e=>D(`button`,{type:`button`,onClick:()=>b(e.id),className:`w-full rounded-md px-3 py-2 text-left text-xs transition-colors ${y===e.id?`bg-primary/12 text-primary`:`hover:bg-surface-hover text-foreground`}`,children:[M(`span`,{className:`font-medium`,children:e.name}),D(`span`,{className:`ml-2 text-foreground-subtle`,children:[e.sampleCount,` samples`]})]},e.id))}),_?M(`div`,{className:`flex items-center gap-2 pt-2 border-t border-border`,children:M(n,{placeholder:`New person name…`,value:h,onChange:e=>g(e.target.value),onKeyDown:e=>{e.key===`Enter`&&O()},autoFocus:!0,className:`flex-1`})}):M(`button`,{type:`button`,onClick:()=>{b(null),v(!0)},className:`mt-2 w-full rounded-md border border-dashed border-border px-3 py-2 text-left text-xs text-foreground-subtle hover:border-primary hover:text-primary transition-colors`,children:`+ New person…`}),D(w,{children:[M(a,{variant:`secondary`,onClick:T,disabled:k,children:`Cancel`}),_?D(a,{variant:`primary`,onClick:O,disabled:k||!h.trim(),children:[k&&M(J,{className:`h-3.5 w-3.5 animate-spin`}),`Create & assign`]}):D(a,{variant:`primary`,onClick:()=>y&&E(y),disabled:k||!y,children:[k&&M(J,{className:`h-3.5 w-3.5 animate-spin`}),`Assign`,S>1?` ${String(S)}`:``]})]})]})})}E();function ke(e){let[t,n]=j(null),[r,i]=j(null),[a,o]=j(!1);return N(()=>{if(n(null),i(null),o(!1),!e)return;let t=!1,r=null;return(async()=>{try{let i=await ge(`${_e}/${encodeURIComponent(e)}`);if(t)return;r=URL.createObjectURL(i),n(r)}catch{t||o(!0)}})(),()=>{t=!0,r&&URL.revokeObjectURL(r)}},[e]),N(()=>{if(!t)return;let e=new Image;return e.onload=()=>i({width:e.naturalWidth,height:e.naturalHeight}),e.onerror=()=>o(!0),e.src=t,()=>{e.onload=null,e.onerror=null}},[t]),{frameSrc:t,naturalWidth:r?.width??null,naturalHeight:r?.height??null,failed:a}}function Ae(e){let t=e.filter(e=>e.base64.length>0);return t.length===0?null:t.find(e=>/crop|face/i.test(e.kind))??t[0]}function je({label:e,value:t}){return D(`div`,{className:`flex items-baseline justify-between gap-3 py-1.5 border-b border-border/60 last:border-0`,children:[M(`span`,{className:`shrink-0 text-[11px] uppercase tracking-wide text-foreground-subtle`,children:e}),M(`span`,{className:`min-w-0 truncate text-right text-xs font-medium text-foreground`,children:t})]})}function Me({box:e}){return M(`div`,{className:`pointer-events-none absolute rounded-[3px] border-2 border-primary shadow-[0_0_0_9999px_rgba(0,0,0,0.28)]`,style:{left:`${String(e.x*100)}%`,top:`${String(e.y*100)}%`,width:`${String(e.width*100)}%`,height:`${String(e.height*100)}%`},children:M(`span`,{className:`absolute -top-4 left-0 rounded bg-primary px-1 text-[9px] font-semibold uppercase tracking-wide text-white`,children:`Face`})})}function Ne({face:e,cameraName:t,onClose:n,onAssign:i,onUnassign:s,onDelete:l,actionsPending:u}){let{data:d,isFetching:f}=c({faceId:e?.faceId??``},{enabled:e!==null}),[p,m]=j(`frame`),{frameSrc:h,naturalWidth:g,naturalHeight:_,failed:v}=ke(e?.keyFrameMediaKey),y=O(()=>{let t=Ae(d??[]);return t?`data:image/jpeg;base64,${t.base64}`:Ee(e)},[d,e]),b=O(()=>!e?.faceBbox||g===null||_===null?null:R(e.faceBbox,g,_),[e?.faceBbox,g,_]);if(e===null)return null;let x=typeof e.keyFrameMediaKey==`string`&&e.keyFrameMediaKey.length>0&&!v,S=x&&p===`frame`,C=e.assigned?e.identityName??`Assigned`:e.recognizedIdentityId?`${e.identityName??`Recognized`} (suggested)`:`Unassigned`;return M(r,{open:!0,onOpenChange:e=>!e&&n(),children:D(o,{width:`lg`,placement:`sheet-on-mobile`,"aria-label":`Face detail`,className:`flex max-h-[92dvh] flex-col gap-0 overflow-hidden p-0 bottom-0 left-0 right-0 top-auto w-full max-w-full translate-x-0 translate-y-0 rounded-b-none md:bottom-auto md:left-1/2 md:right-auto md:top-1/2 md:w-[calc(100vw-2rem)] md:max-w-xl md:-translate-x-1/2 md:-translate-y-1/2 md:rounded-lg md:max-h-[calc(100dvh-2rem)]`,children:[D(`header`,{className:`flex shrink-0 items-start justify-between gap-2 border-b border-border px-4 py-3`,children:[D(`div`,{className:`min-w-0`,children:[M(`div`,{className:`truncate text-sm font-semibold text-foreground`,children:`Face detail`}),M(`div`,{className:`mt-0.5 truncate text-[11px] text-foreground-subtle`,children:t})]}),M(`button`,{type:`button`,onClick:n,className:`rounded p-1 text-foreground-subtle hover:bg-surface-hover hover:text-foreground`,"aria-label":`Close`,children:M(X,{className:`h-4 w-4`})})]}),D(`div`,{className:`min-h-0 flex-1 space-y-3 overflow-y-auto overscroll-contain px-4 py-3`,children:[x&&D(`div`,{className:`flex items-center gap-1 rounded-md border border-border p-0.5 text-xs`,children:[D(`button`,{type:`button`,onClick:()=>m(`frame`),className:`flex flex-1 items-center justify-center gap-1 rounded px-2 py-1 transition-colors ${p===`frame`?`bg-primary/12 font-medium text-primary`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:[M(I,{className:`h-3.5 w-3.5`}),` Full frame`]}),D(`button`,{type:`button`,onClick:()=>m(`crop`),className:`flex flex-1 items-center justify-center gap-1 rounded px-2 py-1 transition-colors ${p===`crop`?`bg-primary/12 font-medium text-primary`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:[M(F,{className:`h-3.5 w-3.5`}),` Crop`]})]}),S&&h?M(`div`,{className:`overflow-hidden rounded-lg border border-border bg-background`,children:M(V,{src:h,alt:`Full frame with detected face`,fit:`natural`,className:`w-full`,overlay:b?M(Me,{box:b}):void 0})}):y?D(`div`,{className:`relative aspect-square w-full overflow-hidden rounded-lg border border-border`,children:[M(V,{src:y,alt:`Detected face`,className:`h-full w-full`}),f&&M(`div`,{className:`absolute right-2 top-2 rounded-full bg-black/50 p-1 text-white`,children:M(J,{className:`h-3.5 w-3.5 animate-spin`})})]}):D(`div`,{className:`flex aspect-square w-full flex-col items-center justify-center gap-1.5 rounded-lg border border-border bg-warning/5 text-foreground-subtle`,children:[M(B,{className:`h-8 w-8 text-warning/70`}),M(`span`,{className:`text-[11px] font-medium uppercase tracking-wide text-warning/80`,children:`No image`}),M(`span`,{className:`px-6 text-center text-[10px] text-foreground-subtle`,children:`The crop media for this face could not be resolved (a pre-fix orphan). Safe to delete.`})]}),D(`div`,{className:`rounded-lg border border-border bg-surface px-3 py-1`,children:[M(je,{label:`Camera`,value:t}),M(je,{label:`Captured`,value:H(e.timestamp)}),M(je,{label:`Track`,value:e.trackId}),M(je,{label:`Identity`,value:C})]})]}),D(`footer`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-border px-4 py-3 pb-[max(0.75rem,env(safe-area-inset-bottom))]`,children:[e.assigned?D(a,{variant:`secondary`,onClick:()=>s(e.faceId),disabled:u,children:[M(L,{className:`h-3.5 w-3.5`}),` Detach`]}):D(a,{variant:`primary`,onClick:()=>i(e.faceId),disabled:u,children:[M(ee,{className:`h-3.5 w-3.5`}),` Assign`]}),D(a,{variant:`secondary`,onClick:()=>l(e.faceId),disabled:u,children:[M(Z,{className:`h-3.5 w-3.5`}),` Delete`]})]})]})})}function Pe(e,t){let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n}function Fe(e,t){return e.faceIds.filter(e=>!t.has(e))}function Ie(e,t){return e.faceIds.filter(e=>t(e))}E();var Le=[[`faceGallery`]],Re=20,ze=.3,Be=.9,Ve=.05,He=.5,Ue=2,We=10,Ge=2;function Ke({cluster:e,face:t,active:n,onSelect:r}){let i=Ee(t);return D(`button`,{type:`button`,onClick:r,className:`flex shrink-0 flex-col items-center gap-1.5 rounded-md border p-2 text-center transition-colors md:w-full md:flex-row md:gap-2.5 md:text-left ${n?`border-primary bg-primary/8`:`border-border bg-surface hover:bg-surface-hover`}`,children:[M(`div`,{className:`h-24 w-24 shrink-0 overflow-hidden rounded bg-surface-hover`,children:i===null?M(B,{className:`h-24 w-24 p-6 text-foreground-subtle`}):M(`img`,{src:i,alt:``,loading:`lazy`,decoding:`async`,className:`h-24 w-24 object-cover`})}),D(`span`,{className:`w-24 text-[11px] leading-tight text-foreground-subtle md:w-auto`,children:[e.size,` faces · `,Math.round(e.cohesion*100),`% alike`]})]})}function qe({face:e,cameraName:t,nowMs:n,excluded:r,onToggleExclude:i,onDelete:a,deletePending:o}){let s=Ee(e);return D(`div`,{className:`relative flex flex-col rounded-md border bg-surface overflow-hidden transition-opacity ${r?`border-border opacity-40 grayscale`:`border-border`}`,children:[D(`div`,{className:`aspect-square relative overflow-hidden bg-surface-hover`,children:[s===null?D(`div`,{className:`flex h-full w-full flex-col items-center justify-center gap-1 bg-warning/5 text-foreground-subtle`,children:[M(B,{className:`h-7 w-7 text-warning/70`}),M(`span`,{className:`text-[9px] font-medium uppercase tracking-wide text-warning/80`,children:`No crop`})]}):M(V,{src:s,alt:`Face from ${t}`,className:`h-full w-full`}),M(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),i()},className:`absolute right-1 top-1 z-10 rounded-full bg-black/50 p-1.5 text-white hover:bg-black/70`,"aria-label":r?`Include face`:`Exclude face`,title:r?`Include`:`Exclude`,children:M(r?K:X,{className:`h-3.5 w-3.5`})})]}),D(`div`,{className:`min-w-0 px-2 pt-1.5 space-y-0.5`,children:[M(`p`,{className:`text-[10px] font-medium text-foreground truncate`,title:t,children:t}),M(`p`,{className:`text-[10px] text-foreground-subtle truncate`,children:z(e.timestamp,n)})]}),M(`div`,{className:`mt-1 flex items-center justify-end border-t border-border/60 px-1 py-0.5`,children:M(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),a()},disabled:o,className:`rounded p-1.5 text-foreground-subtle transition-colors hover:bg-danger/10 hover:text-danger disabled:opacity-40`,"aria-label":`Delete face`,title:`Delete face`,children:o?M(J,{className:`h-4 w-4 animate-spin`}):M(Z,{className:`h-4 w-4`})})})]})}function Je({open:e,onClose:t,byId:n,cameraName:i,nowMs:s,identities:c,selectMany:l}){let u=A(),f=v(),p=d(),[m,h]=j(He),[_,y]=j(Ge),[b,x]=j(null),[S,C]=j({}),[w,T]=j(null),{data:E,isFetching:P,refetch:F}=g({threshold:m,minClusterSize:_,limit:Re},{enabled:e}),I=E??[];N(()=>{C({})},[m,_]),N(()=>{if(I.length===0){x(null);return}I.some(e=>e.representativeFaceId===b)||x(I[0]?.representativeFaceId??null)},[I]);let L=O(()=>I.find(e=>e.representativeFaceId===b)??null,[I,b]),R=L?S[L.representativeFaceId]??new Set:new Set,te=O(()=>L?Ie(L,e=>n.has(e)):[],[L,n]),ne=L?L.faceIds.length-te.length:0,z=L?Fe({...L,faceIds:te},R):[];function re(e){if(!L)return;let t=L.representativeFaceId;C(n=>({...n,[t]:Pe(n[t]??new Set,e)}))}function ie(){u.invalidateQueries({queryKey:Le})}async function B(e){await f({title:`Delete face`,message:`Permanently deletes this face crop. This cannot be undone.`,confirmLabel:`Delete`,variant:`danger`})&&p.mutate({faceId:e},{onSettled:ie})}function V(){T(null),t()}function ae(){z.length!==0&&(l(z),V())}return D(r,{open:e,onOpenChange:e=>!e&&V(),children:[D(o,{placement:`sheet-on-mobile`,width:`lg`,"aria-label":`Look-alike groups`,className:`flex max-h-[92dvh] flex-col gap-0 overflow-hidden p-0 md:max-w-4xl`,children:[D(`header`,{className:`flex shrink-0 flex-col gap-2 border-b border-border px-4 py-3`,children:[D(`div`,{className:`flex items-center justify-between gap-2`,children:[D(`div`,{className:`flex items-center gap-1.5 text-sm font-semibold text-foreground`,children:[M(he,{className:`h-4 w-4 text-primary`}),` Look-alike groups`]}),M(`button`,{type:`button`,onClick:V,className:`rounded p-1 text-foreground-subtle hover:bg-surface-hover hover:text-foreground`,"aria-label":`Close`,children:M(X,{className:`h-4 w-4`})})]}),D(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2`,children:[D(`label`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[`Threshold`,M(`input`,{type:`range`,min:ze,max:Be,step:Ve,value:m,onChange:e=>h(Number(e.target.value)),className:`h-1.5 w-28 cursor-pointer accent-primary`}),M(`span`,{className:`w-8 shrink-0 text-right font-mono text-[11px] tabular-nums text-foreground`,children:m.toFixed(2)})]}),D(`label`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[`Min size`,M(`input`,{type:`number`,min:Ue,max:We,step:1,value:_,onChange:e=>y(Math.min(We,Math.max(Ue,Number(e.target.value)||Ue))),className:`w-12 rounded border border-border bg-background px-1.5 py-0.5 text-xs text-foreground`})]}),D(a,{variant:`secondary`,onClick:()=>{C({}),F()},disabled:P,children:[P?M(J,{className:`h-3.5 w-3.5 animate-spin`}):M(ue,{className:`h-3.5 w-3.5`}),`Re-analyze`]})]})]}),M(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 overflow-hidden px-4 py-3 md:flex-row`,children:P&&I.length===0?D(`div`,{className:`flex flex-1 items-center justify-center gap-2 py-8 text-xs text-foreground-subtle`,children:[M(J,{className:`h-4 w-4 animate-spin`}),` Finding similar faces…`]}):I.length===0?M(`div`,{className:`flex flex-1 items-center justify-center py-8 text-xs text-foreground-subtle`,children:`No look-alike groups at this threshold.`}):D(k,{children:[M(`div`,{className:`flex gap-2 overflow-x-auto pb-1 md:hidden`,children:I.map(e=>M(Ke,{cluster:e,face:n.get(e.representativeFaceId),active:e.representativeFaceId===b,onSelect:()=>x(e.representativeFaceId)},e.representativeFaceId))}),M(`div`,{className:`hidden shrink-0 flex-col gap-2 overflow-y-auto md:flex md:w-56`,children:I.map(e=>M(Ke,{cluster:e,face:n.get(e.representativeFaceId),active:e.representativeFaceId===b,onSelect:()=>x(e.representativeFaceId)},e.representativeFaceId))}),M(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:L&&D(k,{children:[ne>0&&D(`p`,{className:`mb-2 text-[11px] text-foreground-subtle`,children:[ne,` not loaded — excluded from actions`]}),M(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(13rem,1fr))] gap-2`,children:te.map(e=>{let t=n.get(e);return t?M(qe,{face:t,cameraName:i(t.deviceId),nowMs:s,excluded:R.has(e),onToggleExclude:()=>re(e),onDelete:()=>void B(e),deletePending:p.isPending&&p.variables?.faceId===e},e):null})})]})})]})}),D(`footer`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-border px-4 py-3 pb-[max(0.75rem,env(safe-area-inset-bottom))]`,children:[M(a,{variant:`secondary`,onClick:ae,disabled:z.length===0,children:`Select in gallery`}),D(a,{variant:`primary`,onClick:()=>T(z),disabled:z.length===0,children:[M(ee,{className:`h-3.5 w-3.5`}),` Adopt (`,z.length,`)`]})]})]}),M(Oe,{faceIds:w,identities:c,onDone:()=>T(null)})]})}E();var Ye=[[`faceGallery`]],Xe=500,Ze=120;function Qe({face:e,cameraName:t,nowMs:n,selected:r,onToggleSelect:i,onAssign:a,onOpenDetail:o}){let s=A(),c=m(),l=d(),u=()=>{s.invalidateQueries({queryKey:Ye})},f=()=>o(e.faceId),p=Ee(e);return D(`div`,{className:`relative flex flex-col rounded-md border bg-surface overflow-hidden ${r?`border-primary ring-1 ring-primary`:`border-border`}`,children:[D(`div`,{className:`aspect-square relative overflow-hidden bg-surface-hover`,children:[p===null?D(`button`,{type:`button`,onClick:f,className:`flex h-full w-full flex-col items-center justify-center gap-1 bg-warning/5 text-foreground-subtle`,title:`No crop image — the face's crop media is missing (a pre-fix orphan). Safe to delete.`,children:[M(B,{className:`h-7 w-7 text-warning/70`}),M(`span`,{className:`text-[9px] font-medium uppercase tracking-wide text-warning/80`,children:`No crop`})]}):M(`img`,{src:p,alt:`Face from ${t}`,onClick:f,loading:`lazy`,decoding:`async`,className:`h-full w-full cursor-zoom-in object-cover`}),M(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),i(e.faceId)},className:`absolute left-0 top-0 z-10 rounded-br-md bg-black/50 p-1.5 text-white hover:bg-black/70`,"aria-label":r?`Deselect`:`Select`,children:r?M(G,{className:`h-4 w-4 text-primary`}):M(de,{className:`h-4 w-4`})})]}),D(`div`,{className:`min-w-0 px-2 pt-1.5 space-y-0.5`,children:[M(`p`,{className:`text-[10px] font-medium text-foreground truncate`,title:t,children:t}),M(`p`,{className:`text-[10px] text-foreground-subtle truncate`,children:z(e.timestamp,n)}),e.identityName&&M(`p`,{className:`text-[10px] font-medium text-primary truncate`,title:e.identityName,children:e.identityName})]}),D(`div`,{className:`mt-1 flex items-center gap-0.5 border-t border-border/60 px-1 py-0.5`,children:[e.assigned?M(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),c.mutate({faceId:e.faceId},{onSettled:u})},disabled:c.isPending,className:`rounded p-1.5 text-foreground-subtle transition-colors hover:bg-warning/10 hover:text-warning disabled:opacity-40`,"aria-label":`Detach face`,title:`Detach`,children:c.isPending?M(J,{className:`h-4 w-4 animate-spin`}):M(L,{className:`h-4 w-4`})}):M(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),a(e.faceId)},className:`rounded p-1.5 text-foreground-subtle transition-colors hover:bg-primary/10 hover:text-primary`,"aria-label":`Assign face to person`,title:`Assign to person`,children:M(ee,{className:`h-4 w-4`})}),M(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),l.mutate({faceId:e.faceId},{onSettled:u})},disabled:l.isPending,className:`ml-auto rounded p-1.5 text-foreground-subtle transition-colors hover:bg-danger/10 hover:text-danger disabled:opacity-40`,"aria-label":`Delete face`,title:`Delete face`,children:l.isPending?M(J,{className:`h-4 w-4 animate-spin`}):M(Z,{className:`h-4 w-4`})})]})]})}var $e=[{label:`All`,value:`all`},{label:`Unassigned`,value:`unassigned`},{label:`Recognized`,value:`recognized`}];function et(){let t=A(),[n,r]=j(`all`),[o,c]=j(se),[l,u]=j(new Set),[f,p]=j(new Set),[h,g]=j(null),[_,v]=j(!1),[b,x]=j(null),{data:S,isLoading:w}=C({limit:Xe,filter:n,includeCrops:!1},{refetchInterval:3e4}),{data:T=[]}=e(),{data:E}=s({}),N=i(),P=m(),F=y(),I=d(),R=Date.now(),z=S??[],V=O(()=>{let e=new Map;for(let t of E??[])e.set(t.id,t.name);return e},[E]),H=e=>V.get(e)??`Camera #${String(e)}`,ce=O(()=>ne(z).map(e=>({id:e,name:H(e)})).sort((e,t)=>e.name.localeCompare(t.name)),[z,V]),U=O(()=>ie(le(z,o),l),[z,o,l]),W=ae(U,Ze,O(()=>JSON.stringify([n,o.fromMs,o.toMs,[...l].sort((e,t)=>e-t)]),[n,o.fromMs,o.toMs,l])),ue=O(()=>new Map(z.map(e=>[e.faceId,e])),[z]),G=O(()=>Te(U),[U]),de=b===null?null:ue.get(b)??null,K=()=>{t.invalidateQueries({queryKey:Ye})},q=()=>p(new Set);function fe(e){p(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}function pe(e){p(t=>{let n=new Set(t);for(let t of e)n.add(t);return n})}function me(){pe(we(U))}let Y=[...f],Q=N.isPending||F.isPending||I.isPending,ge=P.isPending||I.isPending;function _e(){Y.length!==0&&F.mutate({faceIds:Y},{onSettled:()=>{K(),q()}})}function ve(){Y.length!==0&&Promise.allSettled(Y.map(e=>I.mutateAsync({faceId:e}))).then(()=>{K(),q()})}function $(e){x(null),g([e])}function ye(e){P.mutate({faceId:e},{onSettled:K}),x(null)}function be(e){I.mutate({faceId:e},{onSettled:K}),x(null)}let xe=U.length!==z.length;return D(`div`,{className:`relative space-y-3`,children:[D(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[M(`div`,{className:`flex items-center gap-1`,children:$e.map(e=>M(`button`,{type:`button`,onClick:()=>r(e.value),className:`rounded-md px-2.5 py-1 text-xs transition-colors ${n===e.value?`bg-primary/12 text-primary font-medium`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:e.label},e.value))}),M(oe,{onChange:c}),M(re,{cameras:ce,selected:l,onChange:u}),D(`button`,{type:`button`,onClick:()=>v(!0),className:`flex items-center gap-1 rounded-md px-2.5 py-1 text-xs transition-colors ${_?`bg-primary/12 text-primary font-medium`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:[M(he,{className:`h-3.5 w-3.5`}),` Similar groups`]}),!w&&G>0&&D(`button`,{type:`button`,onClick:me,className:`ml-auto flex items-center gap-1 rounded-md px-2.5 py-1 text-xs text-warning/90 transition-colors hover:bg-warning/10`,title:`Select every visible face whose crop image is missing so you can delete the orphans in one pass`,children:[M(B,{className:`h-3.5 w-3.5`}),` Select `,G,` crop-less`]}),!w&&M(`span`,{className:`text-[10px] text-foreground-subtle ${G>0?`ml-2`:`ml-auto`}`,children:xe?`${String(U.length)} of ${String(z.length)} faces`:`${String(U.length)} face${U.length===1?``:`s`}`})]}),f.size>0&&D(`div`,{className:`flex flex-wrap items-center gap-2 rounded-md border border-primary/40 bg-primary/8 px-3 py-2`,children:[D(`span`,{className:`text-xs font-medium text-foreground`,children:[f.size,` selected`]}),D(`div`,{className:`ml-auto flex flex-wrap items-center gap-1.5`,children:[D(a,{variant:`primary`,onClick:()=>g(Y),disabled:Q,children:[M(ee,{className:`h-3.5 w-3.5`}),` Assign`]}),D(a,{variant:`secondary`,onClick:_e,disabled:Q,children:[F.isPending?M(J,{className:`h-3.5 w-3.5 animate-spin`}):M(L,{className:`h-3.5 w-3.5`}),` `,`Detach`]}),D(a,{variant:`secondary`,onClick:ve,disabled:Q,children:[M(Z,{className:`h-3.5 w-3.5`}),` Delete`]}),M(a,{variant:`ghost`,onClick:q,disabled:Q,children:M(X,{className:`h-3.5 w-3.5`})})]})]}),w&&D(`div`,{className:`flex items-center gap-2 py-4 text-xs text-foreground-subtle`,children:[M(J,{className:`h-4 w-4 animate-spin`}),` Loading faces…`]}),!w&&U.length===0&&M(`p`,{className:`py-4 text-xs text-foreground-subtle`,children:z.length>0?`No faces match the current date / camera filters.`:`No faces found for this filter.`}),!w&&U.length>0&&D(k,{children:[M(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(6.5rem,1fr))] gap-2`,children:W.pageItems.map(e=>M(Qe,{face:e,cameraName:H(e.deviceId),nowMs:R,selected:f.has(e.faceId),onToggleSelect:fe,onAssign:e=>g([e]),onOpenDetail:x},e.faceId))}),M(te,{currentPage:W.page,totalItems:W.totalItems,pageSize:W.pageSize,onPageChange:W.setPage,itemNoun:`faces`})]}),M(Ne,{face:de,cameraName:de?H(de.deviceId):``,onClose:()=>x(null),onAssign:$,onUnassign:ye,onDelete:be,actionsPending:ge}),M(Oe,{faceIds:h,identities:T,onDone:()=>{g(null),q()}}),M(Je,{open:_,onClose:()=>v(!1),byId:ue,cameraName:H,nowMs:R,identities:T,selectMany:pe})]})}E();var tt=[[`faceGallery`]],nt=2e3;function rt(){let e=A(),t=T(e);t.current=e;let n=T(void 0);n.current||=ce({delayMs:nt,invalidate:()=>{t.current.invalidateQueries({queryKey:tt})}}),N(()=>()=>n.current?.cancel(),[]),b(P.PipelineAnalyticsFaceGalleryChanged,()=>{n.current?.trigger()})}function it(){return rt(),M(Q,{icon:Y,title:`Faces`,subtitle:`Manage enrolled identities and assign detected face crops to people.`,children:D(`section`,{className:`space-y-3`,children:[D(`div`,{children:[M(`h2`,{className:`text-sm font-semibold text-foreground mb-1`,children:`People`}),M(`p`,{className:`text-xs text-foreground-subtle mb-3`,children:`Enrolled identities used for face recognition. Expand a row to view or remove training samples.`}),M(Se,{})]}),D(`div`,{className:`pt-4 border-t border-border`,children:[M(`h2`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Recent detected faces`}),M(`p`,{className:`text-xs text-foreground-subtle mb-3`,children:`Face crops captured by the detection pipeline. Assign them to a person to build recognition training data.`}),M(et,{})]})]})})}export{it as DetectionIntelligencePage};
@@ -1 +1 @@
1
- import{Aa as e,Dn as t,Gn as n,Ln as r,On as i,Wn as a,ka as o}from"./src-DB2IsJfq.js";import{I as s,K as c,Q as l,S as u,W as d,o as f,q as p,x as m}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DTufy7Ue.js";import{U as h}from"./src-wWV0FeEw.js";import{t as g}from"./FormBuilder-BJU_ZIZk.js";import{S as _,r as v}from"./index-C8SRsMDj.js";import{n as y,r as b,t as x}from"./SchemaTabBar-BrF8ZUiR.js";import{t as S}from"./StableTabPanel-p16epZGa.js";l();function C({schema:e,values:t,pendingKeys:n,onChange:r,onAction:i,onSave:a,onDiscard:o,disabled:s,activeSubTab:c,onSubTabChange:l,flattenTabs:f=!1,deviceId:h}){let _=e.tabs??[],v=d(()=>{let t=new Map;for(let n of e.sections){let e=n.tab??`general`,r=t.get(e)??[];r.push(n),t.set(e,r)}return t},[e.sections]),b=new Set(_.map(e=>e.id)),C=[..._,...[...v.keys()].filter(e=>!b.has(e)).map(e=>({id:e,label:e,icon:`wrench`,order:100}))],w=C[0]?.id??`general`,[T,E]=p(w),D=l!==void 0,O=new Set(C.map(e=>e.id)),k=D?c&&O.has(c)?c:w:O.has(T)?T:w,A=e=>{D?l(e):E(e)},j=v.get(k)??[],M={sections:j.length<=1?j.length===1?[{...j[0],title:``}]:j:j.every(e=>!e.title)?[{...j[0],title:``,fields:j.flatMap(e=>e.fields)}]:j},N=m(y,{pendingCount:n.length,onSave:()=>a(n),onDiscard:()=>o(n),saving:s});if(f||C.length<=1)return u(`div`,{className:`flex flex-col gap-3`,children:[m(g,{schema:e,values:t,onChange:r,onAction:i,disabled:s,deviceId:h}),N]});let P=new Map,F=new Map;for(let[e,t]of v){P.set(e,t.length);let r=new Set,i=e=>{for(let t of e)if(`key`in t&&typeof t.key==`string`&&r.add(t.key),t.type===`group`)i(t.fields);else if(t.type===`sub-tabs`)for(let e of t.tabs)i(e.fields)};for(let e of t)i(e.fields);let a=n.filter(e=>r.has(e)).length;a>0&&F.set(e,a)}return u(`div`,{className:`flex flex-col gap-3`,children:[m(x,{tabs:C.map(e=>({id:e.id,label:e.label})),activeId:k,onChange:A,countByTab:P,pendingByTab:F}),m(S,{tabKey:k,children:m(g,{schema:M,values:t,onChange:r,onAction:i,disabled:s,deviceId:h})}),N]})}var w=`device-export`,T=`export`,E=`Export`;function D(e){return e.type===`separator`||e.type===`info`||e.type===`object-array`||e.type===`widget`||e.type===`addon-action-button`||e.type===`device-action-button`?!1:e.type===`group`?e.fields.some(D):e.type===`sub-tabs`?e.tabs.some(e=>e.fields.some(D)):e.writerCapName===w}function O(e){return e.fields.some(D)}l();function k(e,t){return t&&t===`admin`?e:!0}function A(e){if(!e)return null;let t={sections:[...e.sections].toSorted((e,t)=>{let n=e.tab??`general`,r=t.tab??`general`;return n===r?O(e)&&O(t)?e.id.localeCompare(t.id):(e.order??0)-(t.order??0):n.localeCompare(r)})};return e.tabs?{...t,tabs:e.tabs}:t}function j(e){return e.type===`separator`||e.type===`info`||e.type===`button`||e.type===`widget`||e.type===`addon-action-button`||e.type===`device-action-button`}function M(e){return e.key}function N(e){if(!j(e))return e.value}function P(e){return j(e)?null:e}function F(e,t){for(let n of e)if(t(n),n.type===`group`)F(n.fields,t);else if(n.type===`sub-tabs`)for(let e of n.tabs)F(e.fields,t)}function I(e){if(!e)return{};let t={};for(let n of e.sections)F(n.fields,e=>{let n=M(e);n!==null&&(t[n]=N(e))});return t}function L(e,t){if(!e)return null;let n=null;for(let r of e.sections)if(F(r.fields,e=>{if(n!==null||M(e)!==t)return;let r=P(e);r&&r.writerCapName&&r.writerAddonId&&(n={capName:r.writerCapName,addonId:r.writerAddonId})}),n!==null)break;return n}function R(e){return{...e,fields:e.fields.map(z)}}function z(e){return e.type===`separator`||e.type===`info`||e.type===`button`||e.type===`object-array`?e:{...e,readonlyField:!0}}function B(e,t){return e&&{...e,sections:e.sections.map(e=>({...e,fields:e.fields.map(e=>{let n=P(e);return n?k(t,n.minRole)?e:z(e):e})}))}}function V({deviceId:l,sectionFilter:p,activeSubTab:g,onSubTabChange:y,flattenSubTabs:x,subTabGrouping:S}){let w=f(),{user:T}=v(),E=T?.isAdmin===!0,D=c(!1),{data:k,isLoading:j}=i({deviceId:l},{refetchInterval:()=>D.current?!1:2500,enabled:Number.isFinite(l)}),{data:M}=t({deviceId:l},{enabled:Number.isFinite(l)}),N=k?.settings??null,P=k?.live??null,F=d(()=>{if(!N&&!P)return null;let e=N?.sections??[],t=(P?.sections??[]).map(R),n=[...e,...t],r=p?n.filter(p):n.filter(e=>e.location!==`top-tab`&&!O(e));if(r.length===0)return null;if(S){let e=r.map(e=>({...e,tab:S.groupOf(e)})),t=new Set(e.map(e=>e.tab)),n=S.tabs.filter(e=>t.has(e.id));return n.length>0?{tabs:n,sections:e}:{sections:e}}let i=new Set;for(let e of r)i.add(e.tab??`general`);let a=[...N?.tabs??[],...(P?.tabs??[]).filter(e=>!(N?.tabs??[]).some(t=>t.id===e.id))].filter(e=>i.has(e.id));return a.length>0?{tabs:a,sections:r}:{sections:r}},[N,P,p,S]),z=d(()=>A(F),[F]),V=d(()=>B(z,E),[z,E]),H=d(()=>I(V),[V]),U=e(),W=o(),G=a(),K=r(),q=n({onSuccess:()=>{w.invalidateQueries({queryKey:[[`deviceManager`,`getDeviceAggregate`]]})}}),J={isPending:q.isPending,mutate:e=>{q.mutate({deviceId:l,changes:[...e]})}},Y=b({schema:V,serverValues:H,onImmediateSave:s(e=>{let t=Object.entries(e).map(([e,t])=>{let n=L(V,e);return n?{writerCapName:n.capName,writerAddonId:n.addonId,key:e,value:t}:null}).filter(e=>e!==null);t.length>0&&J.mutate(t)},[V,J]),onDeferredSave:s(e=>{let t=Object.entries(e).map(([e,t])=>{let n=L(V,e);return n?{writerCapName:n.capName,writerAddonId:n.addonId,key:e,value:t}:null}).filter(e=>e!==null);t.length>0&&J.mutate(t)},[V,J])}),{values:X,pendingKeys:Z,handleChange:Q,handleSave:$,handleDiscard:ee}=Y;if(D.current=Y.editingPaused,j)return u(`div`,{className:`flex items-center justify-center py-12 text-foreground-subtle`,children:[m(_,{className:`h-4 w-4 animate-spin mr-2`}),m(`span`,{className:`text-xs`,children:`Loading device aggregate…`})]});if(!V||V.sections.length===0)return m(`div`,{className:`text-xs text-foreground-subtle italic py-4 text-center`,children:`No aggregate contributions for this device.`});async function te(e,t,n){if(e===`regenerate-rtsp-token`){let e=[`rtspUrl:`,`regenerateToken:`].find(e=>t.startsWith(e));if(!e)throw Error(`regenerate-rtsp-token: unrecognised key "${t}" (expected "rtspUrl:<streamId>" or "regenerateToken:<streamId>")`);let n=t.slice(e.length);if(!n)throw Error(`regenerate-rtsp-token: key "${t}" has no streamId after prefix`);let r=h(l,n);await U.mutateAsync({brokerId:r}),w.invalidateQueries({queryKey:[[`deviceManager`,`getDeviceAggregate`]]});return}if(e===`test-probe`){if(!M)return{status:`error`,error:`Device metadata not loaded yet`};try{return await G.mutateAsync({addonId:M.addonId,type:M.type,key:t,value:n})}catch(e){return{status:`error`,error:e instanceof Error?e.message:String(e)}}}if(e===`refresh-probe`){if(!t.startsWith(`probedInfo:`))throw Error(`refresh-probe: unrecognised key "${t}" (expected "probedInfo:<streamId>")`);let e=t.slice(11);if(!e)throw Error(`refresh-probe: key "${t}" has no streamId after prefix`);let n=h(l,e),r=await W.mutateAsync({brokerId:n});return w.invalidateQueries({queryKey:[[`deviceManager`,`getDeviceAggregate`]]}),r}if(e===`device-custom-action`){let e=await K.mutateAsync({deviceId:l,action:t,input:n});return w.invalidateQueries({queryKey:[[`deviceManager`,`getDeviceAggregate`]]}),e}throw Error(`[device-aggregate] unknown action "${e}"`)}return m(C,{schema:V,values:X,pendingKeys:Z,onChange:Q,onAction:te,onSave:$,onDiscard:ee,disabled:J.isPending,activeSubTab:g,onSubTabChange:y,flattenTabs:x,deviceId:l})}export{O as i,T as n,E as r,V as t};
1
+ import{An as e,Kn as t,Ma as n,ja as r,kn as i,qn as a,zn as o}from"./src-RAEsAO7u.js";import{I as s,K as c,Q as l,S as u,W as d,o as f,q as p,x as m}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DTufy7Ue.js";import{X as h}from"./src-CrugYgqk.js";import{t as g}from"./FormBuilder-BrkB_Vuo.js";import{S as _,r as v}from"./index-D1Lv9nnm.js";import{n as y,r as b,t as x}from"./SchemaTabBar-BrF8ZUiR.js";import{t as S}from"./StableTabPanel-p16epZGa.js";l();function C({schema:e,values:t,pendingKeys:n,onChange:r,onAction:i,onSave:a,onDiscard:o,disabled:s,activeSubTab:c,onSubTabChange:l,flattenTabs:f=!1,deviceId:h}){let _=e.tabs??[],v=d(()=>{let t=new Map;for(let n of e.sections){let e=n.tab??`general`,r=t.get(e)??[];r.push(n),t.set(e,r)}return t},[e.sections]),b=new Set(_.map(e=>e.id)),C=[..._,...[...v.keys()].filter(e=>!b.has(e)).map(e=>({id:e,label:e,icon:`wrench`,order:100}))],w=C[0]?.id??`general`,[T,E]=p(w),D=l!==void 0,O=new Set(C.map(e=>e.id)),k=D?c&&O.has(c)?c:w:O.has(T)?T:w,A=e=>{D?l(e):E(e)},j=v.get(k)??[],M={sections:j.length<=1?j.length===1?[{...j[0],title:``}]:j:j.every(e=>!e.title)?[{...j[0],title:``,fields:j.flatMap(e=>e.fields)}]:j},N=m(y,{pendingCount:n.length,onSave:()=>a(n),onDiscard:()=>o(n),saving:s});if(f||C.length<=1)return u(`div`,{className:`flex flex-col gap-3`,children:[m(g,{schema:e,values:t,onChange:r,onAction:i,disabled:s,deviceId:h}),N]});let P=new Map,F=new Map;for(let[e,t]of v){P.set(e,t.length);let r=new Set,i=e=>{for(let t of e)if(`key`in t&&typeof t.key==`string`&&r.add(t.key),t.type===`group`)i(t.fields);else if(t.type===`sub-tabs`)for(let e of t.tabs)i(e.fields)};for(let e of t)i(e.fields);let a=n.filter(e=>r.has(e)).length;a>0&&F.set(e,a)}return u(`div`,{className:`flex flex-col gap-3`,children:[m(x,{tabs:C.map(e=>({id:e.id,label:e.label})),activeId:k,onChange:A,countByTab:P,pendingByTab:F}),m(S,{tabKey:k,children:m(g,{schema:M,values:t,onChange:r,onAction:i,disabled:s,deviceId:h})}),N]})}var w=`device-export`,T=`export`,E=`Export`;function D(e){return e.type===`separator`||e.type===`info`||e.type===`object-array`||e.type===`widget`||e.type===`addon-action-button`||e.type===`device-action-button`?!1:e.type===`group`?e.fields.some(D):e.type===`sub-tabs`?e.tabs.some(e=>e.fields.some(D)):e.writerCapName===w}function O(e){return e.fields.some(D)}l();function k(e,t){return t&&t===`admin`?e:!0}function A(e){if(!e)return null;let t={sections:[...e.sections].toSorted((e,t)=>{let n=e.tab??`general`,r=t.tab??`general`;return n===r?O(e)&&O(t)?e.id.localeCompare(t.id):(e.order??0)-(t.order??0):n.localeCompare(r)})};return e.tabs?{...t,tabs:e.tabs}:t}function j(e){return e.type===`separator`||e.type===`info`||e.type===`button`||e.type===`widget`||e.type===`addon-action-button`||e.type===`device-action-button`}function M(e){return e.key}function N(e){if(!j(e))return e.value}function P(e){return j(e)?null:e}function F(e,t){for(let n of e)if(t(n),n.type===`group`)F(n.fields,t);else if(n.type===`sub-tabs`)for(let e of n.tabs)F(e.fields,t)}function I(e){if(!e)return{};let t={};for(let n of e.sections)F(n.fields,e=>{let n=M(e);n!==null&&(t[n]=N(e))});return t}function L(e,t){if(!e)return null;let n=null;for(let r of e.sections)if(F(r.fields,e=>{if(n!==null||M(e)!==t)return;let r=P(e);r&&r.writerCapName&&r.writerAddonId&&(n={capName:r.writerCapName,addonId:r.writerAddonId})}),n!==null)break;return n}function R(e){return{...e,fields:e.fields.map(z)}}function z(e){return e.type===`separator`||e.type===`info`||e.type===`button`||e.type===`object-array`?e:{...e,readonlyField:!0}}function B(e,t){return e&&{...e,sections:e.sections.map(e=>({...e,fields:e.fields.map(e=>{let n=P(e);return n?k(t,n.minRole)?e:z(e):e})}))}}function V({deviceId:l,sectionFilter:p,activeSubTab:g,onSubTabChange:y,flattenSubTabs:x,subTabGrouping:S}){let w=f(),{user:T}=v(),E=T?.isAdmin===!0,D=c(!1),{data:k,isLoading:j}=e({deviceId:l},{refetchInterval:()=>D.current?!1:2500,enabled:Number.isFinite(l)}),{data:M}=i({deviceId:l},{enabled:Number.isFinite(l)}),N=k?.settings??null,P=k?.live??null,F=d(()=>{if(!N&&!P)return null;let e=N?.sections??[],t=(P?.sections??[]).map(R),n=[...e,...t],r=p?n.filter(p):n.filter(e=>e.location!==`top-tab`&&!O(e));if(r.length===0)return null;if(S){let e=r.map(e=>({...e,tab:S.groupOf(e)})),t=new Set(e.map(e=>e.tab)),n=S.tabs.filter(e=>t.has(e.id));return n.length>0?{tabs:n,sections:e}:{sections:e}}let i=new Set;for(let e of r)i.add(e.tab??`general`);let a=[...N?.tabs??[],...(P?.tabs??[]).filter(e=>!(N?.tabs??[]).some(t=>t.id===e.id))].filter(e=>i.has(e.id));return a.length>0?{tabs:a,sections:r}:{sections:r}},[N,P,p,S]),z=d(()=>A(F),[F]),V=d(()=>B(z,E),[z,E]),H=d(()=>I(V),[V]),U=n(),W=r(),G=t(),K=o(),q=a({onSuccess:()=>{w.invalidateQueries({queryKey:[[`deviceManager`,`getDeviceAggregate`]]})}}),J={isPending:q.isPending,mutate:e=>{q.mutate({deviceId:l,changes:[...e]})}},Y=b({schema:V,serverValues:H,onImmediateSave:s(e=>{let t=Object.entries(e).map(([e,t])=>{let n=L(V,e);return n?{writerCapName:n.capName,writerAddonId:n.addonId,key:e,value:t}:null}).filter(e=>e!==null);t.length>0&&J.mutate(t)},[V,J]),onDeferredSave:s(e=>{let t=Object.entries(e).map(([e,t])=>{let n=L(V,e);return n?{writerCapName:n.capName,writerAddonId:n.addonId,key:e,value:t}:null}).filter(e=>e!==null);t.length>0&&J.mutate(t)},[V,J])}),{values:X,pendingKeys:Z,handleChange:Q,handleSave:$,handleDiscard:ee}=Y;if(D.current=Y.editingPaused,j)return u(`div`,{className:`flex items-center justify-center py-12 text-foreground-subtle`,children:[m(_,{className:`h-4 w-4 animate-spin mr-2`}),m(`span`,{className:`text-xs`,children:`Loading device aggregate…`})]});if(!V||V.sections.length===0)return m(`div`,{className:`text-xs text-foreground-subtle italic py-4 text-center`,children:`No aggregate contributions for this device.`});async function te(e,t,n){if(e===`regenerate-rtsp-token`){let e=[`rtspUrl:`,`regenerateToken:`].find(e=>t.startsWith(e));if(!e)throw Error(`regenerate-rtsp-token: unrecognised key "${t}" (expected "rtspUrl:<streamId>" or "regenerateToken:<streamId>")`);let n=t.slice(e.length);if(!n)throw Error(`regenerate-rtsp-token: key "${t}" has no streamId after prefix`);let r=h(l,n);await U.mutateAsync({brokerId:r}),w.invalidateQueries({queryKey:[[`deviceManager`,`getDeviceAggregate`]]});return}if(e===`test-probe`){if(!M)return{status:`error`,error:`Device metadata not loaded yet`};try{return await G.mutateAsync({addonId:M.addonId,type:M.type,key:t,value:n})}catch(e){return{status:`error`,error:e instanceof Error?e.message:String(e)}}}if(e===`refresh-probe`){if(!t.startsWith(`probedInfo:`))throw Error(`refresh-probe: unrecognised key "${t}" (expected "probedInfo:<streamId>")`);let e=t.slice(11);if(!e)throw Error(`refresh-probe: key "${t}" has no streamId after prefix`);let n=h(l,e),r=await W.mutateAsync({brokerId:n});return w.invalidateQueries({queryKey:[[`deviceManager`,`getDeviceAggregate`]]}),r}if(e===`device-custom-action`){let e=await K.mutateAsync({deviceId:l,action:t,input:n});return w.invalidateQueries({queryKey:[[`deviceManager`,`getDeviceAggregate`]]}),e}throw Error(`[device-aggregate] unknown action "${e}"`)}return m(C,{schema:V,values:X,pendingKeys:Z,onChange:Q,onAction:te,onSave:$,onDiscard:ee,disabled:J.isPending,activeSubTab:g,onSubTabChange:y,flattenTabs:x,deviceId:l})}export{O as i,T as n,E as r,V as t};
@@ -0,0 +1,2 @@
1
+ import{$ as e,$o as t,An as n,Bn as r,Bt as i,Co as a,D as o,Di as s,E as c,En as l,Eo as u,F as d,Fn as f,Gi as p,Gn as m,H as h,Hn as g,J as _,Ki as v,Lr as y,Mn as b,N as x,O as S,Oi as C,Oo as w,P as T,Pi as ee,Pn as te,Q as E,Qi as ne,Rn as re,T as D,Ti as O,Tn as ie,To as k,Tt as A,U as ae,Un as oe,Vn as j,W as M,Wi as N,Wn as P,Wr as se,X as ce,Y as le,Z as ue,_n as F,_r as I,a as de,at as fe,bn as pe,bo as L,cn as me,dr as he,es as R,et as ge,f as _e,g as ve,gi as ye,go as be,ho as xe,i as Se,ji as Ce,kn as we,l as Te,ln as z,m as Ee,n as De,no as Oe,ns as ke,o as Ae,oo as je,ot as Me,p as Ne,pa as Pe,r as Fe,ro as Ie,rt as Le,st as Re,ts as ze,tt as Be,u as Ve,vo as He,vr as Ue,wo as We,xo as Ge,y as Ke,yo as qe,yr as Je}from"./src-RAEsAO7u.js";import{I as B,K as V,Q as H,S as U,W,a as Ye,b as Xe,o as G,q as K,t as Ze,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{M as Qe,P as Y,Z as $e,a as et,i as tt}from"./src-CrugYgqk.js";import{c as nt,k as rt,p as X,r as it,t as at,u as ot}from"./player-overlays-RSBJ34HJ.js";import{t as st}from"./CapabilityBadges-BrUlJxX7.js";import{t as ct}from"./boxes-rTzctUbU.js";import{t as lt}from"./ProviderIcon-D3veqTWe.js";import{a as ut,c as dt,l as ft,n as pt,o as mt}from"./NodeInferenceDevices-LHaBTVxw.js";import{n as ht}from"./FormBuilder-BrkB_Vuo.js";import{t as gt}from"./pencil-Chd1XFvs.js";import{t as _t}from"./refresh-cw-Blid1l_b.js";import{t as vt}from"./rotate-ccw-twRh3mwW.js";import{t as yt}from"./rotate-cw-CMVPPwHk.js";import{t as bt}from"./server-CsrhvWyN.js";import{t as xt}from"./wifi-CRvgXCEx.js";import{B as St,G as Ct,H as wt,J as Tt,M as Et,R as Dt,S as Ot,W as kt,Y as At,a as jt,c as Mt,i as Nt,j as Pt,m as Ft,o as It,q as Lt,s as Rt,t as zt,v as Bt,y as Vt}from"./index-D1Lv9nnm.js";import{t as Ht}from"./StatusBadge-Dcr2bw58.js";import{t as Ut}from"./useEventInvalidation-CINRwQED.js";import{i as Wt,n as Gt,r as Kt,t as qt}from"./DeviceAggregateSection-BGpxGM1L.js";var Jt=Ct(`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`}]]),Yt=Ct(`hand`,[[`path`,{d:`M18 11V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2`,key:`1fvzgz`}],[`path`,{d:`M14 10V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2`,key:`1kc0my`}],[`path`,{d:`M10 10.5V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2v8`,key:`10h0bg`}],[`path`,{d:`M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15`,key:`1s1gnw`}]]),Xt=Ct(`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`}]]),Zt=Ct(`mouse-pointer-click`,[[`path`,{d:`M14 4.1 12 6`,key:`ita8i4`}],[`path`,{d:`m5.1 8-2.9-.8`,key:`1go3kf`}],[`path`,{d:`m6 12-1.9 2`,key:`mnht97`}],[`path`,{d:`M7.2 2.2 8 5.1`,key:`1cfko1`}],[`path`,{d:`M9.037 9.69a.498.498 0 0 1 .653-.653l11 4.5a.5.5 0 0 1-.074.949l-4.349 1.041a1 1 0 0 0-.74.739l-1.04 4.35a.5.5 0 0 1-.95.074z`,key:`s0h3yz`}]]),Qt=Ct(`power`,[[`path`,{d:`M12 2v10`,key:`mnfbl`}],[`path`,{d:`M18.4 6.6a9 9 0 1 1-12.77.04`,key:`obofu9`}]]),$t=Ct(`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`}]]);H();function en({parentDeviceId:e}){let{t}=zt(),n=Lt(),r=X(),{data:i,isLoading:a,isError:o}=mt(e),{data:s}=we({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 c=(i??[]).filter(e=>e.display?.hidden!==!0);if(c.length===0)return null;let l=ce(s?.stableId??``,c,s?.childLayout),u=l.ungrouped,d=e=>n(`/devices/${String(e)}`),f=s?.name??``,p=(e,t)=>q(_,{trpc:r.trpcClient,device:{...t,name:ge(t,f)},variant:`minimal`,onNavigate:d},e),m=u.some(e=>!!e.role),h=u.some(e=>!e.role),g=m&&!h?t(`device.accessories`,{defaultValue:`Accessories`}):!m&&h?t(`device.adoptedDevices`,{defaultValue:`Adopted devices`}):t(`device.children`,{defaultValue:`Children`}),v=u.length>0?U(`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:g}),q(`div`,{className:`space-y-1`,children:u.map(e=>p(e.id,e))})]}):null,y=l.disabledSection===void 0?null:q(le,{title:t(`device.disabledSection`,{defaultValue:`Disabled`}),count:l.disabledSection.children.length,defaultOpen:!1,children:q(`div`,{className:`opacity-60 space-y-1`,children:l.disabledSection.children.map(e=>p(e.id,e))})},l.disabledSection.title);return l.sections.length===0?y===null?v:U(`div`,{className:`space-y-2`,children:[v,y]}):U(`div`,{className:`space-y-2`,children:[l.sections.map(e=>q(le,{title:e.title,count:e.children.length,defaultOpen:e.defaultOpen,children:e.children.map(e=>p(e.id,e))},e.title)),v,y]})}function tn({deviceId:e}){let t=X(),{data:n,isLoading:r}=ut(e),{data:i,isLoading:a}=mt(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(ae,{trpc:t.trpcClient,children:s,linkDeviceId:c,primaryChildEntityId:l})})}function nn({dev:e,busy:t,setBusy:n}){let r=e?.motionTrigger,i=ot(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 U(`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(kt,{className:`h-3 w-3`}),q(`span`,{children:a?s?`Disabling…`:`Enabling…`:c?s?`On motion: on`:`On motion: off`:`On motion: …`})]})}H();function Z({deviceId:e,deviceType:t,features:n}){let r=X(),i=Me(t)?.HeroCard??Oe,a=nt(r.trpcClient,e),o=ot(a?.state.deviceStatus),[s,c]=K(!1),l=o!==void 0&&o.online===!1,u=l?o.lastChangedAt:null;return U(`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(M,{lastChangedAt:u})}):null,q(i,{trpc:r.trpcClient,deviceId:e,features:n}),q(`div`,{className:`flex justify-center`,children:q(nn,{dev:a,busy:s,setBusy:c})})]})}function rn({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(Ie,{trpc:X().trpcClient,deviceId:e,features:t})})}function an({deviceId:e,features:t}){return q(`div`,{className:`flex h-full w-full flex-col items-stretch p-3 sm:p-4`,children:q(Oe,{trpc:X().trpcClient,deviceId:e,features:t})})}function on(e){if(!e)return null;let t=e.channel;return typeof t!=`number`||!Number.isInteger(t)||t<0?null:t}function sn(e){if(!e)return null;let t=on(e.data);return t===null?e.eventType:`Button ${String(t)} · ${e.eventType}`}var cn=1e3,ln=60*cn,un=60*ln,dn=24*un;function fn(e,t){if(e==null||e<=0)return`—`;let n=t-e;return n<cn?`just now`:n<ln?`${String(Math.floor(n/cn))}s ago`:n<un?`${String(Math.floor(n/ln))}m ago`:n<dn?`${String(Math.floor(n/un))}h ago`:`${String(Math.floor(n/dn))}d ago`}H();var pn=1500,mn=15e3,hn=1e3;function gn({deviceId:e}){let t=nt(X().trpcClient,e)?.state.eventEmitter,n=ot(t);J(()=>{if(!t)return;t.refresh();let e=setInterval(()=>{t.refresh()},mn);return()=>{clearInterval(e)}},[t]);let r=n?.lastEvent??null,i=r?.seq??null,a=V(null),[o,s]=K(!1);J(()=>{if(i===null)return;let e=a.current;if(a.current=i,e===null||e===i)return;s(!0);let t=setTimeout(()=>{s(!1)},pn);return()=>{clearTimeout(t)}},[i]);let[c,l]=K(()=>Date.now());J(()=>{let e=setInterval(()=>{l(Date.now())},hn);return()=>{clearInterval(e)}},[]);let u=sn(r),d=n?.eventTypes??[],f=n?.eventCountSinceStart??0,p=n!==void 0,m=on(r?.data);return U(`div`,{className:`flex h-full w-full flex-col items-center justify-center gap-3 p-4`,children:[q(`div`,{"data-testid":`event-emitter-indicator`,"data-flashing":String(o),className:`flex h-24 w-24 items-center justify-center rounded-full border-2 transition-all ${o?`border-primary bg-primary/20 text-primary shadow-lg shadow-primary/30 scale-105`:`border-border bg-surface text-foreground-subtle`}`,"aria-live":`polite`,title:u??`No press recorded`,children:q(o?Zt:Yt,{className:`h-10 w-10`})}),U(`div`,{className:`text-center`,children:[m!==null&&q(`div`,{className:`text-xs font-semibold uppercase tracking-wide text-primary`,children:`Button ${String(m)}`}),q(`div`,{"data-testid":`event-emitter-headline`,className:`text-sm font-semibold ${u?`text-foreground`:`text-foreground-subtle`}`,children:u??(p?`No press recorded`:`Awaiting state…`)}),q(`div`,{className:`text-[10px] text-foreground-subtle mt-0.5`,children:r?fn(r.timestamp,c):`Waiting for the first event`})]}),d.length>0&&q(`div`,{className:`flex max-w-full flex-wrap justify-center gap-1`,children:d.map(e=>q(`span`,{"data-testid":`event-emitter-chip`,className:`rounded-full border px-2 py-0.5 text-[10px] font-medium ${e===r?.eventType?`border-primary bg-primary/15 text-primary`:`border-border bg-surface text-foreground-subtle`}`,children:e},e))}),q(`div`,{className:`text-[10px] text-foreground-subtle`,children:`${String(f)} ${f===1?`event`:`events`} since start`})]})}function _n({deviceName:e,deviceType:t,provider:n,isOnline:r,features:i}){return U(`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(lt,{type:n,size:`lg`}),U(`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})]}),U(`div`,{className:`flex items-center gap-2 flex-wrap justify-center`,children:[q(Ht,{status:r?`online`:`offline`}),i.length>0&&q(st,{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.`})]})}H();function vn({deviceId:e}){let t=G(),n=me({deviceId:e},{refetchInterval:1e4,retry:!1}),r=z({onSuccess:()=>{t.invalidateQueries({queryKey:[[`deviceDiscovery`,`listDiscovered`]]}),t.invalidateQueries({queryKey:[[`deviceDiscovery`,`getStatus`]]})}}),i=W(()=>yn(n.data??[]),[n.data]);return U(`div`,{className:`flex h-full w-full flex-col gap-3 p-3 sm:p-4`,children:[U(`div`,{className:`flex flex-wrap items-stretch gap-2 sm:gap-3`,children:[q(bn,{label:`Discovered`,value:i.total,icon:q(Bt,{className:`h-3.5 w-3.5`})}),q(bn,{label:`Adopted`,value:i.adopted,accent:`success`}),q(bn,{label:`Available`,value:i.available,accent:i.available>0?`primary`:void 0}),U(`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(Ot,{className:`h-3.5 w-3.5 animate-spin`}):q(_t,{className:`h-3.5 w-3.5`}),q(`span`,{className:`hidden sm:inline`,children:`Discover`})]})]}),U(`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(xn,{icon:q(xt,{className:`h-3 w-3 text-emerald-500`}),label:`${i.online} online`}),q(xn,{icon:q(Vt,{className:`h-3 w-3 text-amber-500`}),label:`${i.sleeping} sleeping`}),q(xn,{icon:q(jt,{className:`h-3 w-3 text-destructive`}),label:`${i.offline} offline`}),i.unknown>0?q(xn,{icon:q(Jt,{className:`h-3 w-3 text-foreground-subtle`}),label:`${i.unknown} unknown`}):null]})]})}function yn(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 bn({label:e,value:t,icon:n,accent:r}){return U(`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:[U(`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 xn({icon:e,label:t}){return U(`span`,{className:`inline-flex items-center gap-1`,children:[e,q(`span`,{children:t})]})}var Sn={[Y.Switch]:Z,[Y.Siren]:Z,[Y.Light]:Z,[Y.Sensor]:Z,[Y.Button]:Z,[Y.Hub]:vn,[Y.Cover]:rn,[Y.Valve]:Z,[Y.Humidifier]:Z,[Y.WaterHeater]:Z,[Y.Container]:tn,[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]:an,[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 Cn(e){return Sn[e]??_n}function wn(e){return q(Cn(e.deviceType),{...e})}function Tn(e){return de(X().trpcClient,e)}H();function En(e){let[t,n]=K(`idle`),[r,i]=K(null),a=V(null),o=V(null),s=V(null),c=V(!0),l=Ue(),u=I(),d=Je(),f=B(()=>{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=B(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=B(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`}}H();var Dn=0;function Q(){return++Dn}function On(e){switch(e.type){case`system`:return`system`;case`device`:return`#${e.deviceId}`;case`provider`:return e.providerId;case`addon`:return e.addonId}}function kn(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 An(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 jn(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 Mn({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: ${On(e)} — type help or context for available commands`}),n}),[o,s]=K(``),[c,l]=K([]),[u,d]=K(-1),f=V(null),p=V(null);J(()=>{let e=p.current;e&&(e.scrollTop=e.scrollHeight)},[i]);let m=B(()=>{f.current?.focus()},[]),h=Ze({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: ${On(e)}`}]),s(``);return}if(n===`help`){a(t=>[...t,{id:Q(),kind:`input`,text:`> ${n}`},...kn(e).map(e=>({id:Q(),kind:`info`,text:e}))]),s(``);return}if(n===`context`){a(t=>[...t,{id:Q(),kind:`input`,text:`> ${n}`},...jn(e).map(e=>({id:Q(),kind:`info`,text:e}))]),s(``);return}if(n===`examples`){a(t=>[...t,{id:Q(),kind:`input`,text:`> ${n}`},...An(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: ${On(e)}`}]))}let v={input:`text-zinc-300`,result:`text-emerald-300`,error:`text-red-300`,info:`text-zinc-400`};return U(`div`,{className:`flex flex-col bg-[#0c0a09] rounded-lg border border-border overflow-hidden font-mono text-xs ${n??``}`,onClick:m,children:[U(`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`})]}),U(`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 Nn({deviceId:e,intercomAvailable:t=!1}){let n=X(),r=typeof window<`u`?window.location.origin:``,i=Number.isFinite(e),a=Tn(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(i?e:null,{width:Rn}),_=En(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=it(),C=S(),w=typeof window<`u`?window.localStorage.getItem(`camstack_admin_token`):null,T=x.length>0?q(Xe,{children:x.map(e=>q(`div`,{className:`absolute inset-0`,children:e.node},e.id))}):null;return q(Ke,{serverUrl:r,createSession:c,sendAnswer:l,handleOffer:u,getIceServers:d,addIceCandidate:f,getIceCandidates:p,closeSession:m,getSessionState:h,...C.request?{playbackUrl:C.request.url,playbackAuthToken:w,...C.request.label?{playbackLabel:C.request.label}:{},onExitPlayback:()=>C.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:T,chromeless:!0,className:`h-full`})}function Pn({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})}):U(`div`,{className:`flex items-center justify-center h-full text-[11px] text-foreground-subtle italic`,children:[`Device #`,e,` not loaded.`]})}function Fn({deviceId:e}){if(!Number.isFinite(e))return U(`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(Mn,{scope:{type:`device`,deviceId:e},greeting:t,className:`h-full border-0 rounded-none`})}function In({deviceId:e}){return Number.isFinite(e)?q(`div`,{className:`flex flex-col h-full overflow-y-auto`,children:q(Ee,{deviceId:e,limit:50,maxHeight:`max-h-full`})}):U(`div`,{className:`flex items-center justify-center h-full text-[11px] text-foreground-subtle italic`,children:[`Device #`,e,` not loaded.`]})}function Ln({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`})}):U(`div`,{className:`flex items-center justify-center h-full text-[11px] text-foreground-subtle italic`,children:[`Device #`,e,` not loaded.`]})}var Rn=960,zn={"no-provider":`Not available — nothing in this installation provides it.`,"source-unreachable":`Unknown — the service that owns this did not answer.`,"not-configured":`Nothing set up yet — configure it first (Image → Privacy Mask).`};function Bn({deviceId:e}){let t=G(),{data:n,isLoading:r,error:i}=C({deviceId:e},{enabled:Number.isFinite(e)});Ut([`pipelineOrchestrator`,`getCameraSwitches`],[`capability.binding-changed`]);let a=[[`pipelineOrchestrator`,`getCameraSwitches`],{input:{deviceId:e}}],o=v({onMutate:async e=>{await t.cancelQueries({queryKey:a});let n=t.getQueryData(a);return n!==void 0&&t.setQueryData(a,{...n,switches:n.switches.map(t=>t.id===e.switchId&&t.available?{...t,enabled:e.enabled}:t)}),{previous:n}},onError:(e,n,r)=>{r?.previous!==void 0&&t.setQueryData(a,r.previous)},onSuccess:e=>{t.setQueryData(a,e),t.invalidateQueries({queryKey:[[`deviceManager`]]}),t.invalidateQueries({queryKey:[[`recording`]]})}});return r?U(`div`,{className:`flex items-center gap-2 text-xs text-muted`,children:[q(Ot,{className:`h-3 w-3 animate-spin`}),` Loading camera functions…`]}):i||!n?U(`div`,{className:`flex items-start gap-2 rounded-lg border border-border p-3 text-xs text-muted`,children:[q(It,{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(Vn,{row:t,busy:o.isPending&&o.variables?.switchId===t.id,onToggle:n=>o.mutate({deviceId:e,switchId:t.id,enabled:n})},t.id))})}function Vn({row:e,busy:t,onToggle:n}){let r=e.available&&!e.enabled;return U(`div`,{className:`rounded-lg border p-3 ${r?`border-warning/50 bg-warning/5`:`border-border`}`,children:[U(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[U(`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?zn[e.unavailableReason]:`Not available.`})]}),q(`p`,{className:`mt-1.5 text-xs leading-snug text-muted`,children:e.costWhenOff})]})}function Hn({deviceId:e}){let t=G(),n=Number.isFinite(e),{data:r}=we({deviceId:e},{enabled:n}),i=typeof r?.type==`string`?r.type:`camera`;Ut([`deviceManager`,`getBindings`],[`capability.binding-changed`]);let{data:a,isLoading:o,isError:s,error:c}=l({deviceId:e},{enabled:n}),{data:u}=te({deviceType:i},{enabled:!!i}),d=m({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(s)return U(`div`,{className:`p-4 text-xs text-red-400`,children:[`Failed to load bindings: `,c instanceof Error?c.message:String(c)]});let f=new Map,p={};for(let e of u??[])p[e.capName]=e.wrappers;for(let e of a?.entries??[])f.set(e.capName,{...e,wrappers:p[e.capName]??[]});for(let e of u??[])f.has(e.capName)||f.set(e.capName,{capName:e.capName,kind:`unbound`,providerAddonId:``,providerNodeId:``,nativeAddonId:``,wrappers:e.wrappers});let h=[...f.values()].toSorted((e,t)=>e.capName.localeCompare(t.capName));if(h.length===0)return U(`div`,{className:`flex flex-col items-center justify-center gap-2 p-8 text-foreground-subtle`,children:[q(ct,{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 U(`div`,{className:`flex flex-col gap-3 p-1`,children:[i===`camera`?U(`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(Bn,{deviceId:e})]}):null,U(`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(L,{columns:[{key:`capability`,header:`Capability`,render:e=>q(`span`,{className:`font-mono text-foreground`,children:e.capName})},{key:`kind`,header:`Kind`,render:e=>q(Un,{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(Wn,{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(Gn,{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 Un({kind:e}){return e===`native`?U(`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(bt,{className:`h-3 w-3`}),`native`]}):e===`wrapped`?U(`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(ft,{className:`h-3 w-3`}),`wrapped`]}):e===`linked`?U(`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(Xt,{className:`h-3 w-3`}),`linked`]}):U(`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(dt,{className:`h-3 w-3`}),`unbound`]})}function Wn({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 Gn({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 U(`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?Dt:vt,{className:`h-3 w-3`}),e]},e)})})}function Kn({deviceId:e,activeSubTab:t,onSubTabChange:n}){return q(`div`,{className:`flex flex-col gap-3`,children:q(qt,{deviceId:e,activeSubTab:t,onSubTabChange:n})})}H();var qn=new Set([`package-detection`]);function Jn(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 Yn(e){return e?e.modelId!==void 0||e.settings!==void 0:!1}function Xn({deviceId:e,refreshToken:t}){let n=G(),r=X().trpcClient,[i,a]=K(null),[o,c]=K(null),[l,u]=K(null),d=O({deviceId:e},{refetchOnMount:`always`}),f=s({deviceId:e},{refetchOnMount:`always`}),m=ee(void 0,{refetchOnMount:`always`});Ut([`nodes`,`topology`],[`agent.online`,`agent.offline`,`agent.unregistered`,`addon.installed`,`addon.uninstalled`]);let h=se(void 0,{refetchOnMount:`always`}),g=W(()=>{let e=new Set;for(let t of h.data??[])t.isOnline&&e.add(t.id);return e},[h.data]),_=W(()=>(m.data??[]).filter(e=>g.has(e.nodeId)).map(e=>e.nodeId),[m.data,g]),v=_[0]??``,y=ye({nodeId:v},{enabled:v!==``,refetchOnMount:`always`}),b=Ye({enabled:_.length>0,queryKey:[[`pipelineOrchestrator`,`getNodeInferenceDevices`],`device-step`,_.join(`,`),t],queryFn:async()=>{let e={};for(let t of _)try{e[t]=(await r.pipelineOrchestrator.getNodeInferenceDevices.query({nodeId:t})).devices}catch{e[t]=[]}return e}}),x=()=>{n.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCameraSettings`]]}),n.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCameraStepOverrides`]]})},S=N({onSuccess:x}),C=p({onSuccess:x}),w=W(()=>y.data?He(y.data):[],[y.data]),T=W(()=>{let e=m.data??[],t=g.size===0?[]:e.filter(e=>g.has(e.nodeId)),n=[];for(let e of t){let t=(b.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:pt(r).label});else n.push({agentNodeId:e.nodeId,engineLabel:t[0]?.format??`(engine unknown)`})}return n},[m.data,b.data,g]),te=(e,t)=>b.data?.[e]?.find(e=>e.key===t)??null,E=e=>{if(e.deviceKey!==void 0)return e.deviceKey;let t=b.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},ne=(e,t,n)=>f.data?.[e]?.[t]?.[n]??null,re=e=>{if(qn.has(e))return{kind:`zone-driven`};let t=Jn(y.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=Jn(y.data??null,e);if(n)return R(n,t)},ie=(e,t)=>{let n=re(e),r=n.kind===`gate`?n.effectiveOn:!1,i=Jn(y.data??null,e),a=E(t),o=a===null?null:te(t.agentNodeId,a);if(!ke(i?.models??[],o?.format))return r?{kind:`skip`}:{kind:`na`};let s=a===null?null:ne(t.agentNodeId,a,e),c=o?.steps?.[e];return{kind:`enabled`,modelId:(i?ze({catalog:i,device:o,override:s?.modelId,base:c?.modelId}):void 0)??`Auto`,overridden:Yn(s)}},k=i&&y.data?Jn(y.data,i.addonId):null,A=i?te(i.agentNodeId,i.deviceKey):null,ae=A?.format??`coreml`,oe=i?Yn(ne(i.agentNodeId,i.deviceKey,i.addonId)):!1,j=i?D(i.addonId,A):void 0,M=W(()=>{if(!i||!A)return null;let e=A.steps?.[i.addonId];return{enabled:!0,...e?.modelId===void 0?{}:{modelId:e.modelId},settings:e?.settings??{}}},[i,A]),P=()=>{a(null),c(null)},ce=(e,t)=>{let n=E(t);n!==null&&(a({addonId:e,agentNodeId:t.agentNodeId,deviceKey:n}),c(ne(t.agentNodeId,n,e)))},le=(t,n)=>{C.mutate({deviceId:e,addonId:t,enabled:n})},ue=()=>{i&&S.mutate({deviceId:e,agentNodeId:i.agentNodeId,deviceKey:i.deviceKey,addonId:i.addonId,patch:o},{onSuccess:P})},F=()=>{i&&S.mutate({deviceId:e,agentNodeId:i.agentNodeId,deviceKey:i.deviceKey,addonId:i.addonId,patch:null},{onSuccess:P})};if(m.isLoading||v!==``&&y.isLoading)return q(`div`,{className:`text-xs text-foreground-subtle animate-pulse p-4`,children:`Loading pipeline…`});if(T.length===0)return q(`div`,{className:`text-xs text-foreground-subtle p-4`,children:`No online agents.`});if(!y.data)return q(`div`,{className:`text-xs text-foreground-subtle p-4`,children:`Catalog unavailable.`});let I=i!==null&&k!==null&&A!==null;return U(`div`,{className:`relative h-full w-full space-y-3`,children:[U(`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.`]}),U(`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:I?`md:pr-[360px]`:``,children:w.length>0?q(xe,{tree:w,agents:T,gateFor:re,getCellState:ie,onCellClick:ce,selectedCell:i,onSetGate:le,gateBusy:C.isPending,fallbackNodeId:l,onFallbackNodeChange:u}):q(`div`,{className:`text-xs text-foreground-subtle`,children:`Catalog empty.`})}),q(qe,{open:I,onClose:P,title:k?.name??``,subtitle:i&&A?`${i.agentNodeId} · ${pt(A).label} · ${A.format}`:``,footer:U(Xe,{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:!oe||S.isPending,onClick:F,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:P,children:`Cancel`}),q(`button`,{type:`button`,disabled:!i||!M||S.isPending,className:`px-3 py-1 text-xs bg-primary text-primary-foreground rounded disabled:opacity-50`,onClick:ue,children:S.isPending?`Saving…`:`Save`})]}),children:k&&i&&M?q(be,{mode:`device`,addon:k,agentDefault:M,agentNodeId:i.agentNodeId,currentPatch:o,engineFormat:ae,effectiveModelId:j,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 Zn=[{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`}],Qn={"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 $n(e){return Qn[e]??`object-detection`}H();var er=`steps`,tr=`settings`,nr=new Set([er,tr]);function rr(e){return e.location===`top-tab`&&(e.tab===`detection-pipeline`||e.tab===`zones`)}function ir({deviceId:e,activeSubTab:t,onSubTabChange:n}){return U(a,{value:t&&nr.has(t)?t:er,onValueChange:B(e=>{n?.(e)},[n]),className:`flex flex-col`,children:[U(k,{className:`flex-shrink-0`,children:[q(u,{value:er,children:`Steps`}),q(u,{value:tr,children:`Settings`})]}),q(We,{value:er,children:q(Xn,{deviceId:e,refreshToken:0})}),q(We,{value:tr,children:q(qt,{deviceId:e,sectionFilter:rr,subTabGrouping:{groupOf:e=>$n(e.id),tabs:Zn}})})]})}function $({label:e,value:t}){return U(`div`,{className:`${rt} 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})]})}H();function ar({deviceId:e,initialName:t}){let n=G(),[r,i]=K(!1),[a,o]=K(t),[s,c]=K(!1),l=V(null);J(()=>{r||o(t)},[t,r]),J(()=>{r&&l.current?.focus()},[r]);let u=g({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:U(`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(Dt,{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(Nt,{className:`h-3 w-3`})})]})}):q($,{label:`Name`,value:U(`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(gt,{className:`h-3.5 w-3.5`})})]})})}H();function or({deviceId:e,initialLocation:t}){let n=G(),[r,i]=K(!1),[a,o]=K(t??``),[s,c]=K(!1),l=V(null),{data:u}=f(void 0,{enabled:r}),d=u??[];J(()=>{r||o(t??``)},[t,r]),J(()=>{r&&l.current?.focus()},[r]);let p=j({onSuccess:()=>{n.invalidateQueries({queryKey:[[`deviceManager`,`getDevice`]]}),n.invalidateQueries({queryKey:[[`deviceManager`,`listAll`]]}),n.invalidateQueries({queryKey:[[`deviceManager`,`getDeviceAggregate`]]}),n.invalidateQueries({queryKey:[[`deviceManager`,`listLocations`]]})}}),m=W(()=>{let e=a.trim().toLowerCase();return e.length===0?d:d.filter(t=>t.toLowerCase()!==e&&t.toLowerCase().includes(e))},[d,a]),h=a.trim().length>0&&!d.some(e=>e.toLowerCase()===a.trim().toLowerCase()),g=async n=>{let r=(n??a).trim(),o=r.length===0?null:r;if(o===(t??null)){i(!1);return}c(!0);try{await p.mutateAsync({deviceId:e,location:o}),i(!1)}catch{}finally{c(!1)}},_=()=>{o(t??``),i(!1)};return r?q($,{label:`Location`,value:U(`div`,{className:`relative`,children:[U(`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`?g():e.key===`Escape`&&_()},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 g(),disabled:s,className:`p-0.5 rounded hover:bg-success/10 text-success disabled:opacity-50`,"aria-label":`Save`,children:q(Dt,{className:`h-3 w-3`})}),q(`button`,{type:`button`,onClick:_,disabled:s,className:`p-0.5 rounded hover:bg-danger/10 text-danger disabled:opacity-50`,"aria-label":`Cancel`,children:q(Nt,{className:`h-3 w-3`})})]}),(m.length>0||h)&&U(`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:[m.map(e=>U(`button`,{type:`button`,onClick:()=>{o(e),g(e)},className:`w-full flex items-center gap-2 px-2 py-1 text-left text-[11px] hover:bg-surface-hover`,children:[q(ht,{className:`h-3 w-3 text-foreground-subtle flex-shrink-0`}),q(`span`,{className:`truncate`,children:e})]},e)),h&&U(`button`,{type:`button`,onClick:()=>void g(),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`}),U(`span`,{className:`font-medium truncate`,children:[`"`,a.trim(),`"`]})]})]})]})}):q($,{label:`Location`,value:U(`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(gt,{className:`h-3.5 w-3.5`})})]})})}H();function sr({deviceId:e}){let t=G(),{data:n}=ut(e),{data:r}=mt(e),[i,a]=K(null),o=oe({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=fe(s,typeof n.linkDeviceId==`number`?n.linkDeviceId:null,typeof n.primaryChildEntityId==`string`?n.primaryChildEntityId:null);return U(Xe,{children:[q($,{label:`Primary child`,value:q(h,{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})]})}H();var cr=[`manufacturer`,`model`,`hardware`,`firmware`,`serialNumber`,`uid`,`mac`,`itemNo`];function lr(e){return e.replace(/([a-z])([A-Z])/g,`$1 $2`).replace(/^./,e=>e.toUpperCase())}function ur(e){return e==null?`—`:typeof e==`string`||typeof e==`number`||typeof e==`boolean`?String(e):JSON.stringify(e)}function dr(){let e=T(),t=d(),{data:n}=we({deviceId:e??0},{enabled:e!==null}),{data:r}=l({deviceId:e??0},{enabled:e!==null}),i=n??t??null,[a,o]=K(`identity`);if(e===null||!i)return null;let s=String(i.stableId??``),c=String(i.name??``),u=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 U(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[U(`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&&U(`div`,{className:`flex items-center gap-1 rounded-md bg-surface-hover p-0.5`,children:[q(fr,{active:a===`identity`,onClick:()=>o(`identity`),label:`Identity`}),q(fr,{active:a===`hardware`,onClick:()=>o(`hardware`),label:`Hardware`})]})]}),(!y||a===`identity`)&&U(`div`,{className:`divide-y divide-border`,children:[q($,{label:`ID`,value:U(`span`,{className:`font-mono text-[11px] text-foreground`,children:[`#${e}`,U(`span`,{className:`ml-1.5 text-foreground-subtle`,children:[`(`,s,`)`]})]})}),q(ar,{deviceId:e,initialName:c}),q(or,{deviceId:e,initialLocation:_}),q(sr,{deviceId:e}),q($,{label:`Type`,value:u}),q($,{label:`Provider`,value:q(lt,{type:f,size:`sm`,showLabel:!0})}),q($,{label:`Capabilities`,value:g.length>0?q(st,{capabilities:g,showLabels:!0}):q(`span`,{className:`text-[11px] text-foreground-subtle`,children:`None`})})]}),y&&a===`hardware`&&q(pr,{metadata:v})]})}function fr({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 pr({metadata:e}){let t=cr.filter(t=>t in e),n=Object.keys(e).filter(e=>!cr.includes(e)).toSorted(),r=[...t,...n];return U(`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:lr(t),value:q(`span`,{className:`font-mono text-[11px] text-foreground break-all`,children:ur(e[t])})},t))})]})}H();function mr({deviceId:e}){let[t,n]=K(null),r=F({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 U(`div`,{className:`rounded-lg border border-border bg-surface px-4 py-3`,children:[U(`div`,{className:`flex items-center justify-between gap-3`,children:[U(`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.`})]}),U(`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(_t,{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})]})}H();var hr={icon:``,label:``,unit:``,precision:``,hidden:!1};function gr(e){return{icon:e?.icon??``,label:e?.label??``,unit:e?.unit??``,precision:e?.precision===void 0?``:String(e.precision),hidden:e?.hidden===!0}}function _r(e){if(typeof e!=`object`||!e)return;let t=e.unit;return typeof t==`string`?t:void 0}function vr(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 yr({deviceId:e}){let t=X(),n=G(),{data:i}=we({deviceId:e},{enabled:e>0}),a=typeof i?.role==`string`?i.role:null,o=a===null?void 0:Re[a],s=o?.kind===`numeric`,c=De(t.trpcClient,e,a??``),l=o?.kind===`numeric`?o.canonicalUnit:void 0,u=_r(c)??l,d=u===void 0?void 0:tt(u),f=W(()=>d===void 0?[]:et(d),[d]),[p,m]=K(null),h=p??gr(i?.display),g=r({onSuccess:()=>{n.invalidateQueries({queryKey:[[`deviceManager`]]})}}),{data:_}=b({},{staleTime:6e4}),v=P({onSuccess:()=>{n.invalidateQueries({queryKey:[[`deviceManager`]]})}});if(i===void 0||a===null)return null;let y=e=>{m({...h,...e})},x=()=>{g.mutate({deviceId:e,display:vr(h)})},S=()=>{m(hr),g.mutate({deviceId:e,display:null})},C=()=>{let e={...h.icon===``?{}:{icon:h.icon},...h.unit===``?{}:{unit:h.unit},...h.precision.trim()!==``&&Number.isFinite(Number.parseInt(h.precision,10))?{precision:Number.parseInt(h.precision,10)}:{}},t={..._?.defaults??{},[a]:e};v.mutate({defaults:t})},w=Le(a).label,T=Object.keys(Be);return U(`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`})}),U(`div`,{className:`p-4 space-y-3`,children:[U(`label`,{className:`block`,children:[q(`span`,{className:`text-[11px] text-foreground-subtle`,children:`Icon`}),U(`select`,{className:`mt-1 w-full rounded border border-border bg-surface px-2 py-1 text-sm text-foreground`,value:h.icon,onChange:e=>y({icon:e.target.value}),children:[U(`option`,{value:``,children:[`Default (`,w,`)`]}),T.map(e=>q(`option`,{value:e,children:e},e))]})]}),U(`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:h.label,onChange:e=>y({label:e.target.value})})]}),s&&U(`div`,{className:`grid grid-cols-2 gap-3`,children:[U(`label`,{className:`block`,children:[q(`span`,{className:`text-[11px] text-foreground-subtle`,children:`Unit`}),U(`select`,{className:`mt-1 w-full rounded border border-border bg-surface px-2 py-1 text-sm text-foreground`,value:h.unit,onChange:e=>y({unit:e.target.value}),disabled:f.length===0,children:[U(`option`,{value:``,children:[`Source`,u?` (${u})`:``]}),f.map(e=>q(`option`,{value:e,children:e},e))]})]}),U(`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:h.precision,onChange:e=>y({precision:e.target.value})})]})]}),U(`label`,{className:`flex items-center gap-2`,children:[q(`input`,{type:`checkbox`,checked:h.hidden,onChange:e=>y({hidden:e.target.checked})}),q(`span`,{className:`text-sm text-foreground`,children:`Hide from device lists`})]}),U(`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:x,disabled:g.isPending,children:`Save`}),q(`button`,{type:`button`,className:`rounded border border-border px-3 py-1 text-sm text-foreground-subtle`,onClick:S,disabled:g.isPending,children:`Reset`}),U(`button`,{type:`button`,className:`rounded border border-border px-3 py-1 text-sm text-foreground-subtle`,onClick:C,disabled:v.isPending,title:`Apply this unit / precision / icon as the default for every ${w} sensor`,children:[`Set as default for all `,w,` sensors`]})]})]})]})}function br(e){return e<1e3?`${e.toFixed(0)} kbps`:`${(e/1e3).toFixed(1)} Mbps`}function xr({device:e}){let t=Lt(),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(Qe.Resyncable),{data:l}=y({deviceId:n??0},{enabled:n!==null&&i,refetchInterval:5e3}),u=l?.streams??{},d=Object.entries(u),f=s.includes(Qe.DoorbellButton),p=Fe(f?{deviceId:n??void 0,historyLimit:10}:void 0),m=p.latest?Date.now()-p.latest.timestamp<3e4:!1;return U(`div`,{className:`space-y-5`,children:[a&&n!==null&&q(Ne,{deviceId:n,onOpenChild:e=>t(`/devices/${e}`)}),c&&n!==null&&q(mr,{deviceId:n}),i&&n!==null&&q(D,{widgetId:`pipeline-orchestrator/pipeline-quick-stats`,host:`device-tab`,deviceId:n}),f&&q(Ve,{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&&U(`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])=>U(`div`,{className:`px-4 py-2.5`,children:[U(`div`,{className:`flex items-center gap-2 mb-2`,children:[q(xt,{className:`h-3 w-3 text-foreground-subtle`}),q(`span`,{className:`text-[11px] font-medium text-foreground`,children:e})]}),U(`div`,{className:`grid grid-cols-2 @[640px]:grid-cols-4 gap-2`,children:[q(Sr,{label:`Nominal`,value:br(t.nominalBitrateKbps??0)}),q(Sr,{label:`Observed`,value:br(t.observedBitrateKbps??0)}),q(Sr,{label:`Peak`,value:br(t.peakBitrateKbps??0)}),q(Sr,{label:`Packet Loss`,value:`${(t.packetLossPercent??0).toFixed(2)}%`,warning:(t.packetLossPercent??0)>1})]})]},e))})]}),q(dr,{}),o&&n!==null&&q(yr,{deviceId:n})]})}function Sr({label:e,value:t,warning:n}){return U(`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})]})}H();var Cr=[{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}];function wr(e){let t=e===Y.Camera;return Cr.filter(e=>t||!e.cameraOnly).map(({id:e,label:t})=>({id:e,label:t}))}var Tr=[{id:`logs`,icon:Ft,label:`Logs`},{id:`repl`,icon:Mt,label:`REPL`},{id:`events`,icon:wt,label:`Events`},{id:`state`,icon:Pt,label:`State`}];function Er(){let t=Tt(),r=Number(t.deviceId),a=Number.isFinite(r),s=Lt(),l=G(),u=je(),d=X(),[f,p]=At(),m=f.get(`tab`)??`overview`,h=f.get(`sub`),[g,_]=K(`logs`),v=`device-detail.left-col-width-px`,[y,b]=K(()=>{if(typeof window>`u`)return null;let e=window.localStorage.getItem(v),t=e?Number(e):NaN;return Number.isFinite(t)&&t>0?t:null}),S=V(y);S.current=y;function C(e){e.preventDefault();let t=e.clientX,n=e.currentTarget.previousElementSibling?.getBoundingClientRect().width??y??0,r=Math.max(330,Math.floor(window.innerWidth*.7)),i=e=>{b(Math.max(280,Math.min(r,n+(e.clientX-t))))},a=()=>{document.removeEventListener(`mousemove`,i),document.removeEventListener(`mouseup`,a);let e=S.current;if(e!==null)try{window.localStorage.setItem(v,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:T,isLoading:ee,isError:te}=we({deviceId:r},{enabled:a,refetchInterval:5e3,retry:1}),{data:E}=n({deviceId:r},{enabled:a}),D=W(()=>{let e=E?.settings?.sections??[],t=E?.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(Wt)&&r.add(Gt),[...r].map(e=>e===`export`?{id:e,label:Kt,isAddonContrib:!0}:{id:e,label:$e[e]?.label??e,isAddonContrib:!0})},[E]),O=T,k=String(O?.name??t.deviceId??`Device`),ae=O?.online===!0,oe=ae?`online`:`offline`,j=String(O?.addonId??`rtsp`),M=O?.features??[],N=O?.type,P=N===Y.Camera,{data:se}=mt(a?r:0),ce=N===Y.Container,le=W(()=>(se??[]).map(e=>({id:e.id,stableId:e.stableId,type:e.type,...e.sourceInfo?{sourceInfo:{id:e.sourceInfo.id}}:{}})),[se]),F=W(()=>ce?fe(le,typeof O?.linkDeviceId==`number`?O.linkDeviceId:null,typeof O?.primaryChildEntityId==`string`?O.primaryChildEntityId:null)?.id??null:null,[ce,le,O?.linkDeviceId,O?.primaryChildEntityId]),{data:I}=n({deviceId:F??0},{enabled:F!==null}),de=W(()=>{if(F===null)return[];let e=I?.settings?.sections??[],t=I?.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:$e[e]?.label??e,isAddonContrib:!0,childDeviceId:F}))},[F,I]),L=typeof O?.parentDeviceId==`number`?O.parentDeviceId:null,{data:me}=we({deviceId:L??0},{enabled:L!==null}),R=w(),ge=O?.disabled!==!0,_e=W(()=>{let e=new Set,t=[];for(let n of[...wr(N),...D,...de])e.has(n.id)||(e.add(n.id),t.push(n));return t},[N,D,de]),ve=W(()=>_e.some(e=>e.id===m)?m:`overview`,[_e,m]),ye=B(e=>{p(t=>{let n=new URLSearchParams(t);return e===`overview`?n.delete(`tab`):n.set(`tab`,e),n.delete(`sub`),n},{replace:!0})},[p]),be=B(e=>{p(t=>{let n=new URLSearchParams(t);return n.set(`sub`,e),n},{replace:!0})},[p]),xe=(se??[]).length>0,Se=W(()=>Tr.filter(({featureGate:e})=>!e||M.includes(e)),[M]),{data:z}=he({addonId:j},{enabled:!!j&&j!==`rtsp`}),Ee=re({onSuccess:()=>{l.invalidateQueries({queryKey:[[`deviceManager`]]}),s(z?.id?`/integrations/${z.id}`:`/integrations`)}}),De=ie({onSuccess:()=>{l.invalidateQueries({queryKey:[[`deviceManager`]]})}}),Oe=pe({onSuccess:()=>{l.invalidateQueries({queryKey:[[`deviceManager`]]})}}),ke=Pe(),Me=A({onSuccess:()=>{l.invalidateQueries({queryKey:[[`deviceManager`]]})}}),Ne=M.includes(Qe.Rebootable),Fe=M.includes(Qe.BatteryOperated),Ie=e(d.trpcClient,Fe&&a?r:null),[Le,Re]=K(!1),ze=nt(d.trpcClient,a?r:null),Be=async()=>{if(!(Le||!ze)){Re(!0);try{await ze.snapshot?.invalidateCache({});let e=await ze.snapshot?.getSnapshot({});if(!e)return;let t=`data:${e.contentType};base64,${e.base64}`,n=e.contentType.includes(`png`)?`png`:`jpg`,r=k.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{Re(!1)}}},Ve=De.isPending||Oe.isPending,{data:He}=Ce({deviceId:r},{enabled:a,refetchInterval:1e4}),Ue=He?.agentNodeId??null,We=typeof Ue==`string`&&Ue.length>0&&!Ue.startsWith(`addon:`)?Ue:void 0,{data:Ke}=ne({deviceId:r,...We?{nodeId:We}:{}},{enabled:a,refetchInterval:3e3,retry:!1}),{data:qe}=i({deviceId:r},{enabled:a,refetchInterval:3e3,retry:!1}),Je=qe?.level?.dbfs??null;function H(){if(!a)return null;switch(ve){case`overview`:return q(xr,{device:O??{}});case`config`:return q(Kn,{deviceId:r,activeSubTab:h,onSubTabChange:be});case`detection-pipeline`:return q(ir,{deviceId:r,activeSubTab:h,onSubTabChange:be});case`bindings`:return q(Hn,{deviceId:r});default:{let e=ve,t=D.some(t=>t.id===e),n=de.find(t=>t.id===e);if(!t&&n===void 0)return null;let i=n?.childDeviceId??r;if(e===`export`)return q(qt,{deviceId:r,sectionFilter:Wt,activeSubTab:h,onSubTabChange:be});let a=q(qt,{deviceId:i,sectionFilter:t=>t.location===`top-tab`&&(t.tab===e||e===`detection-pipeline`&&t.tab===`zones`),flattenSubTabs:e===`detection-pipeline`,activeSubTab:h,onSubTabChange:be});return n!==void 0&&i!==r?q(x,{deviceId:i,children:a}):a}}}return a?ee?U(`div`,{className:`flex flex-col h-full`,children:[U(`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`})})]}):te||!T?U(`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`}),U(`p`,{className:`text-xs`,children:[`No device with ID`,` `,U(`code`,{className:`font-mono bg-surface px-1.5 py-0.5 rounded text-[11px]`,children:[`#`,r]})]}),q(`button`,{onClick:()=>s(`/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`})]}):U(`div`,{className:`absolute inset-0 flex flex-col overflow-hidden`,children:[U(`div`,{className:`border-b border-border bg-surface px-6 py-3 flex-shrink-0`,children:[q(`div`,{className:`mb-2`,children:q(Ge,{items:[{label:`Integrations`,onClick:()=>s(`/integrations`)},{label:z?.name??j,onClick:()=>z?.id&&s(`/integrations/${z.id}`)},{label:k}]})}),U(`div`,{className:`flex items-center gap-2 sm:gap-3`,children:[q(lt,{type:j,size:`lg`}),U(`div`,{className:`min-w-0 flex-1`,children:[U(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[q(`h1`,{className:`text-sm sm:text-base font-semibold text-foreground truncate`,children:k}),q(Ht,{status:oe}),Fe&&q(ue,{status:Ie,variant:`full`})]}),L!==null&&me&&U(`button`,{type:`button`,onClick:()=>s(`/devices/${L}`),className:`text-[10px] text-foreground-subtle hover:text-primary transition-colors mt-0.5 inline-flex items-center gap-1`,title:`Open parent device ${me.name}`,children:[q(`span`,{children:`↑`}),q(`span`,{className:`truncate`,children:String(me.name??`Device #${L}`)})]}),q(`div`,{className:`hidden md:flex items-center gap-3 mt-0.5 text-[10px] text-foreground-subtle`,children:M.length>0&&q(st,{capabilities:M})})]}),Ke&&q(`div`,{className:`hidden lg:flex`,children:q(Dr,{metrics:Ke,dbfs:Je})}),U(`div`,{className:`flex items-center gap-1 shrink-0`,children:[U(`button`,{onClick:async()=>{ge?await u({title:`Disable "${k}"?`,message:`The device will stop processing streams and events. You can re-enable it later.`,confirmLabel:`Disable`,variant:`danger`})&&Oe.mutate({deviceId:r}):De.mutate({deviceId:r})},disabled:Ve,title:ge?`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 ${ge?`border-success/30 text-success hover:bg-success/10`:`border-border text-foreground-subtle/50 hover:text-foreground hover:bg-surface-hover`}`,children:[q(Qt,{className:`h-3.5 w-3.5`}),q(`span`,{className:`hidden sm:inline`,children:Ve?`Updating…`:ge?`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:St,disabled:Le,onClick:()=>{Be()}},{id:`reboot`,label:`Reboot device`,description:`Camera goes offline for ~30 seconds.`,icon:yt,hidden:!Ne,disabled:ke.isPending,danger:!0,onClick:async()=>{await u({title:`Reboot "${k}"?`,message:`The camera will go offline for around 30 seconds while the firmware reboots.`,confirmLabel:`Reboot`,variant:`danger`})&&ke.mutate({deviceId:r})}},{id:`restart-addon`,label:`Restart addon`,description:`Bounces every device served by ${z?.name??j}.`,icon:_t,disabled:Me.isPending,danger:!0,onClick:async()=>{await u({title:`Restart "${z?.name??j}"?`,message:`Restarting the addon will briefly disconnect every device served by it (not just "${k}"). Streams will reconnect automatically.`,confirmLabel:`Restart`,variant:`danger`})&&Me.mutate({addonId:j})}},{id:`delete`,label:`Delete device`,description:`Remove the device and all its settings.`,icon:Rt,separatorBefore:!0,disabled:Ee.isPending,danger:!0,onClick:async()=>{await u({title:`Delete "${k}"?`,message:`This will remove the device and all its settings. This action cannot be undone.`,confirmLabel:`Delete`,variant:`danger`})&&Ee.mutate({deviceId:r})}}]})]})]})]}),q(x,{deviceId:r,device:O??void 0,children:q(o,{children:q(c,{children:q(at,{children:q(Ae,{children:U(`main`,{className:R?`flex-1 overflow-y-auto flex flex-col`:`flex-1 min-h-0 overflow-hidden flex flex-row`,children:[U(`div`,{className:R?`flex flex-col bg-surface`:`${y===null?`w-1/2 lg:w-1/3`:``} flex-shrink-0 flex flex-col bg-surface min-h-0 overflow-hidden`,style:!R&&y!==null?{width:`${String(y)}px`}:void 0,children:[q(`div`,{className:P?`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:P?q(Nn,{deviceId:r,intercomAvailable:M.includes(Qe.TwoWayAudio)}):q(wn,{deviceId:r,deviceName:k,deviceType:N??`unknown`,provider:j,isOnline:ae,features:M})}),U(`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:Se.map(({id:e,label:t,icon:n})=>U(`button`,{onClick:()=>_(e),title:t,className:`flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium transition-colors flex-shrink-0 ${g===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))})}),U(`div`,{className:R?`h-72 overflow-hidden`:`flex-1 min-h-0 overflow-hidden`,children:[g===`logs`&&q(Pn,{deviceId:r,containerDeviceId:N===`container`?r:void 0}),g===`repl`&&q(Fn,{deviceId:r}),g===`events`&&q(In,{deviceId:r}),g===`state`&&q(Ln,{deviceId:r})]})]})]}),!R&&q(`div`,{role:`separator`,"aria-orientation":`vertical`,title:`Drag to resize`,onMouseDown:C,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`})}),U(`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:_e.map(e=>{let t=ve===e.id;return U(`button`,{onClick:()=>ye(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)})})}),U(`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:[ve===`overview`&&xe&&q(en,{parentDeviceId:r}),H()]})]})]})})})})})})]}):U(`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`}),U(`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:()=>s(`/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 Dr({metrics:e,dbfs:n}){let r=t(e.phase??`idle`);return U(`div`,{className:`flex items-center gap-3 flex-shrink-0`,children:[U(`div`,{className:`flex items-center gap-1.5`,children:[q(`span`,{className:`h-1.5 w-1.5 rounded-full ${r.dotClass}`}),q(`span`,{className:`text-[10px] font-medium ${r.textColor}`,children:r.label})]}),q(`div`,{className:`h-3 w-px bg-border`}),U(`div`,{className:`flex items-center gap-1 text-[10px] text-foreground-subtle`,children:[q(kt,{className:`h-3 w-3`}),q(`span`,{className:`text-foreground tabular-nums`,children:(e.actualFps??0).toFixed(1)}),q(`span`,{children:`fps`})]}),U(`div`,{className:`flex items-center gap-1 text-[10px] text-foreground-subtle`,children:[q(Et,{className:`h-3 w-3`}),q(`span`,{className:`text-foreground tabular-nums`,children:(e.avgInferenceTimeMs??0).toFixed(0)}),q(`span`,{children:`ms`})]}),U(`div`,{className:`flex items-center gap-1 text-[10px] text-foreground-subtle`,title:`Current audio level (dBFS)`,children:[q($t,{className:`h-3 w-3`}),q(`span`,{className:`text-foreground tabular-nums`,children:n==null?`—`:n.toFixed(0)}),q(`span`,{children:`dB`})]}),(e.queueDepth??0)>0&&U(`span`,{className:`text-[10px] text-warning tabular-nums`,children:[`q:`,e.queueDepth]})]})}export{Er as DeviceDetailPage};
@@ -1 +1 @@
1
- import{Cn as e,G as t,In as n,dr as r,jn as i,vn as a}from"./src-DB2IsJfq.js";import{I as o,Q as s,S as c,W as l,o as u,x as d}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DTufy7Ue.js";import{p as f}from"./player-overlays-DELm4F-u.js";import{t as p}from"./ProviderIcon-B5LCn3Mf.js";import{B as m,o as h,q as g,t as _}from"./index-C8SRsMDj.js";import{t as v}from"./AdminPage-Dq33XE9j.js";import{t as y}from"./useEventInvalidation-D-wl8gip.js";s();function b(){let{t:s}=_(),b=g(),x=f(),S=u();y([`deviceManager`],[`device.registered`,`device.unregistered`,`device.online`,`device.offline`,`device.disabled`,`device.enabled`]),y([`integrations`],[`integration.enabled`,`integration.disabled`,`integration.deleted`,`provider.started`,`provider.stopped`,`addon.installed`,`addon.uninstalled`,`addon.started`,`addon.stopped`]);let{data:C}=i({}),{data:w}=r(void 0),T=n({onSuccess:()=>{S.invalidateQueries({queryKey:[[`deviceManager`]]})}}),E=a({onSuccess:()=>{S.invalidateQueries({queryKey:[[`deviceManager`]]})}}),D=e({onSuccess:()=>{S.invalidateQueries({queryKey:[[`deviceManager`]]})}}),O=l(()=>C??[],[C]),{activeDevices:k,orphanDevices:A}=l(()=>{let e=new Set((w??[]).map(e=>e.addonId)),t=t=>typeof t.addonId==`string`&&t.addonId.length>0&&!e.has(t.addonId),n=new Set;for(let e of O)t(e)&&n.add(e.id);let r=new Set(n),i=new Map;for(let e of O)i.set(e.id,e);let a=(e,t=0)=>{if(t>32)return!1;if(n.has(e.id))return!0;if(e.parentDeviceId==null)return!1;let r=i.get(e.parentDeviceId);return r?a(r,t+1):!1};for(let e of O)a(e)&&r.add(e.id);let o=[],s=[];for(let e of O)r.has(e.id)?s.push(e):o.push(e);return{activeDevices:o,orphanDevices:s}},[O,w]),j=l(()=>{let e=new Map;for(let t of O)e.set(t.id,{id:t.id,name:t.name??t.stableId??`#${String(t.id)}`});return e},[O]),M=o(e=>j.get(e)??null,[j]),N=l(()=>(w??[]).map(e=>({id:e.addonId,name:e.name??e.addonId,icon:d(p,{type:e.addonId,size:`sm`})})),[w]),P=o(e=>d(p,{type:e,size:`sm`}),[]),F=o(e=>b(`/devices/${String(e)}`),[b]);return c(v,{icon:m,title:s(`nav.devices`,`Devices`),children:[d(t,{context:`devices`,devices:k,trpc:x.trpcClient,filters:{addons:N},resolveIntegrationIcon:P,resolveParent:M,onNavigate:F,batchActions:{remove:T.mutate,disable:E.mutate,enable:D.mutate}}),A.length>0&&c(`div`,{className:`mt-6 space-y-2`,children:[c(`div`,{className:`flex items-baseline gap-2`,children:[d(h,{className:`h-3.5 w-3.5 text-warning shrink-0`}),d(`h2`,{className:`text-sm font-semibold text-foreground`,children:`Orphan devices`}),c(`span`,{className:`text-[10px] text-foreground-subtle`,children:[A.length,` device`,A.length===1?``:`s`,` pointing at integrations no longer registered`]})]}),c(`div`,{className:`rounded-lg border border-warning/30 bg-warning/5 p-2`,children:[d(`p`,{className:`text-[11px] text-foreground-subtle px-2 pb-2`,children:"These devices reference an addonId that has no matching integration. Delete them, or re-install the missing integration to bring them back online. The provider scope (`addonId`) shown beside each row is what's failing to resolve."}),d(t,{context:`devices`,devices:A,trpc:x.trpcClient,filters:{addons:N},urlScope:`nested`,lsKey:`devices:orphan`,resolveIntegrationIcon:P,resolveParent:M,onNavigate:F})]})]})]})}export{b as DevicesPage};
1
+ import{G as e,Nn as t,Rn as n,Tn as r,bn as i,pr as a}from"./src-RAEsAO7u.js";import{I as o,Q as s,S as c,W as l,o as u,x as d}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DTufy7Ue.js";import{p as f}from"./player-overlays-RSBJ34HJ.js";import{t as p}from"./ProviderIcon-D3veqTWe.js";import{B as m,o as h,q as g,t as _}from"./index-D1Lv9nnm.js";import{t as v}from"./AdminPage-Dq33XE9j.js";import{t as y}from"./useEventInvalidation-CINRwQED.js";s();function b(){let{t:s}=_(),b=g(),x=f(),S=u();y([`deviceManager`],[`device.registered`,`device.unregistered`,`device.online`,`device.offline`,`device.disabled`,`device.enabled`]),y([`integrations`],[`integration.enabled`,`integration.disabled`,`integration.deleted`,`provider.started`,`provider.stopped`,`addon.installed`,`addon.uninstalled`,`addon.started`,`addon.stopped`]);let{data:C}=t({}),{data:w}=a(void 0),T=n({onSuccess:()=>{S.invalidateQueries({queryKey:[[`deviceManager`]]})}}),E=i({onSuccess:()=>{S.invalidateQueries({queryKey:[[`deviceManager`]]})}}),D=r({onSuccess:()=>{S.invalidateQueries({queryKey:[[`deviceManager`]]})}}),O=l(()=>C??[],[C]),{activeDevices:k,orphanDevices:A}=l(()=>{let e=new Set((w??[]).map(e=>e.addonId)),t=t=>typeof t.addonId==`string`&&t.addonId.length>0&&!e.has(t.addonId),n=new Set;for(let e of O)t(e)&&n.add(e.id);let r=new Set(n),i=new Map;for(let e of O)i.set(e.id,e);let a=(e,t=0)=>{if(t>32)return!1;if(n.has(e.id))return!0;if(e.parentDeviceId==null)return!1;let r=i.get(e.parentDeviceId);return r?a(r,t+1):!1};for(let e of O)a(e)&&r.add(e.id);let o=[],s=[];for(let e of O)r.has(e.id)?s.push(e):o.push(e);return{activeDevices:o,orphanDevices:s}},[O,w]),j=l(()=>{let e=new Map;for(let t of O)e.set(t.id,{id:t.id,name:t.name??t.stableId??`#${String(t.id)}`});return e},[O]),M=o(e=>j.get(e)??null,[j]),N=l(()=>(w??[]).map(e=>({id:e.addonId,name:e.name??e.addonId,icon:d(p,{type:e.addonId,size:`sm`})})),[w]),P=o(e=>d(p,{type:e,size:`sm`}),[]),F=o(e=>b(`/devices/${String(e)}`),[b]);return c(v,{icon:m,title:s(`nav.devices`,`Devices`),children:[d(e,{context:`devices`,devices:k,trpc:x.trpcClient,filters:{addons:N},resolveIntegrationIcon:P,resolveParent:M,onNavigate:F,batchActions:{remove:T.mutate,disable:E.mutate,enable:D.mutate}}),A.length>0&&c(`div`,{className:`mt-6 space-y-2`,children:[c(`div`,{className:`flex items-baseline gap-2`,children:[d(h,{className:`h-3.5 w-3.5 text-warning shrink-0`}),d(`h2`,{className:`text-sm font-semibold text-foreground`,children:`Orphan devices`}),c(`span`,{className:`text-[10px] text-foreground-subtle`,children:[A.length,` device`,A.length===1?``:`s`,` pointing at integrations no longer registered`]})]}),c(`div`,{className:`rounded-lg border border-warning/30 bg-warning/5 p-2`,children:[d(`p`,{className:`text-[11px] text-foreground-subtle px-2 pb-2`,children:"These devices reference an addonId that has no matching integration. Delete them, or re-install the missing integration to bring them back online. The provider scope (`addonId`) shown beside each row is what's failing to resolve."}),d(e,{context:`devices`,devices:A,trpc:x.trpcClient,filters:{addons:N},urlScope:`nested`,lsKey:`devices:orphan`,resolveIntegrationIcon:P,resolveParent:M,onNavigate:F})]})]})]})}export{b as DevicesPage};