@dominevo/addon-admin-ui 0.1.2 → 0.1.4

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 (90) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/assets/{Addons-Ck90J9_n.js → Addons-Dqwyi0aS.js} +1 -1
  3. package/dist/assets/{AdminPage-CA4Sxydy.js → AdminPage-Bd8R8RtF.js} +1 -1
  4. package/dist/assets/{AdminSectionedPage-3XsaKUPh.js → AdminSectionedPage-Cwi1kvmM.js} +1 -1
  5. package/dist/assets/{AiProfiles-8UssQtkR.js → AiProfiles-SI2Iyt3F.js} +1 -1
  6. package/dist/assets/{Archive-5WNTy09R.js → Archive-ByC3bXel.js} +1 -1
  7. package/dist/assets/{BootstrapSettingsForm-CQLdqB1p.js → BootstrapSettingsForm-Cy8mCpHP.js} +1 -1
  8. package/dist/assets/{Build-B6m8-obM.js → Build-DfH4qlmf.js} +1 -1
  9. package/dist/assets/{Calendars-BbmdZy07.js → Calendars-K1Z15Ly2.js} +1 -1
  10. package/dist/assets/{Cluster-CzmgBDwN.js → Cluster-Ul0y1bLm.js} +1 -1
  11. package/dist/assets/{CompositionBlockEditor-DjJGal7a.js → CompositionBlockEditor-Kc1vM2A7.js} +1 -1
  12. package/dist/assets/{CompositionEditorPage-MACY9CFt.js → CompositionEditorPage-DOy1_xa6.js} +1 -1
  13. package/dist/assets/{Data-B2mmPVLY.js → Data-wkMPgPIi.js} +1 -1
  14. package/dist/assets/{DeviceDetail-D7GFYFEm.js → DeviceDetail-BxkGFnI2.js} +1 -1
  15. package/dist/assets/{Devices-NJ52UGWV.js → Devices-Dv9L-Kji.js} +1 -1
  16. package/dist/assets/{EmbedDevicePage-F1NEkMUT.js → EmbedDevicePage-DcLTsAsw.js} +1 -1
  17. package/dist/assets/{EmbedPlayerPage-BKq1BRg_.js → EmbedPlayerPage-C2A2ZfFZ.js} +1 -1
  18. package/dist/assets/{FormBuilder-BjcOGVVa.js → FormBuilder-TrrVPEZX.js} +1 -1
  19. package/dist/assets/{History-CqTLHyoj.js → History-Am70bV1z.js} +1 -1
  20. package/dist/assets/Identity-BzYQSoVB.js +1 -0
  21. package/dist/assets/{InstancesTable-CCUTp360.js → InstancesTable-BhClC6c7.js} +1 -1
  22. package/dist/assets/{IntegrationDetail-CCyZhNWc.js → IntegrationDetail-CXJ4DIj2.js} +1 -1
  23. package/dist/assets/{Integrations-D1Ybtztv.js → Integrations-B7lFcabS.js} +1 -1
  24. package/dist/assets/{Integrations-B_Inbdpc.js → Integrations-ClCrv1nX.js} +1 -1
  25. package/dist/assets/{Jobs-BDZ-S8az.js → Jobs-D9dl7u2u.js} +1 -1
  26. package/dist/assets/{Library-BJXSgpWZ.js → Library-FfhywvlF.js} +1 -1
  27. package/dist/assets/{Locations-CEsFxXK8.js → Locations-DKSaqyPH.js} +1 -1
  28. package/dist/assets/{Logs-DrLmsP4V.js → Logs-C13uuzLz.js} +1 -1
  29. package/dist/assets/{MaskShapeCanvas-T6ZNfW4J.js → MaskShapeCanvas-B5mehyBe.js} +1 -1
  30. package/dist/assets/{MotionZonesSettings-B5KDfHoK.js → MotionZonesSettings-jMkiUUQz.js} +1 -1
  31. package/dist/assets/{MyAccess-CAtcn_a3.js → MyAccess-Dq0fJGPb.js} +1 -1
  32. package/dist/assets/{Network-BUfXtVhQ.js → Network-BVOnr0mt.js} +1 -1
  33. package/dist/assets/{NewExportModal-D64AhGe8.js → NewExportModal-weUsUP2K.js} +1 -1
  34. package/dist/assets/{NodeAddonsSettingsPanel-hnXBekcO.js → NodeAddonsSettingsPanel-BvlLXdhN.js} +1 -1
  35. package/dist/assets/{Notifications-CrrX9yK9.js → Notifications-DF8en3Zl.js} +1 -1
  36. package/dist/assets/{Pipeline-BGOu-2v_.js → Pipeline-D6QSFY4L.js} +1 -1
  37. package/dist/assets/{PrivacyMaskSettings-CERwQtiu.js → PrivacyMaskSettings-C4XdrpKI.js} +1 -1
  38. package/dist/assets/{SceneMonitorEditor-DxTYd8U2.js → SceneMonitorEditor-3kjADoN0.js} +1 -1
  39. package/dist/assets/SessionsList-BOKuwFwJ.js +2 -0
  40. package/dist/assets/{Showroom-CprRp6yl.js → Showroom-DSZ7_JVJ.js} +1 -1
  41. package/dist/assets/{StorageLocationsTable-B81bi89X.js → StorageLocationsTable-B_3fPv7s.js} +1 -1
  42. package/dist/assets/{System-D3mpSwHc.js → System-C2tFswFM.js} +1 -1
  43. package/dist/assets/{TemplateEditorDialog-CwArOYwD.js → TemplateEditorDialog-AIrV7BKf.js} +1 -1
  44. package/dist/assets/{Terminal-Dqxv-P1E.js → Terminal-CD78nora.js} +1 -1
  45. package/dist/assets/{TrainingProviders-CGpG1PvO.js → TrainingProviders-BsfUFtDp.js} +1 -1
  46. package/dist/assets/{Viewer-9ydpkUg6.js → Viewer-2F_bb_FE.js} +1 -1
  47. package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-Cc7iYWcG.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-DD163xl-.js} +1 -1
  48. package/dist/assets/{ai-page.helpers-CiDsxXp3.js → ai-page.helpers-CH0oD27E.js} +1 -1
  49. package/dist/assets/{assignment-candidates-BfhoJg-T.js → assignment-candidates-mv6nvb2M.js} +1 -1
  50. package/dist/assets/{auth-context-CkfOTCG-.js → auth-context-CU5snbq3.js} +1 -1
  51. package/dist/assets/{authed-media-C-zK1a1B.js → authed-media-BavZM6fk.js} +1 -1
  52. package/dist/assets/{board-model-BvqJSvTB.js → board-model-BJOCdYZi.js} +1 -1
  53. package/dist/assets/{broker-oauth-popup-B_GRcwxo.js → broker-oauth-popup-C7Be_Cjq.js} +1 -1
  54. package/dist/assets/{camera-block-model-QrJ_0XZY.js → camera-block-model-Cg9j-LS6.js} +1 -1
  55. package/dist/assets/{device-integration-icon-B63imyJJ.js → device-integration-icon-C9zQRrG0.js} +1 -1
  56. package/dist/assets/device-picker-model-Bi7qSGNi.js +1 -0
  57. package/dist/assets/{dist-2ETbjdqB.js → dist-DMgC_62x.js} +1 -1
  58. package/dist/assets/{dist-B0ixn42U.js → dist-DUZyedAc.js} +3 -3
  59. package/dist/assets/{format-D43HvBR0.js → format-M1wlEHJl.js} +1 -1
  60. package/dist/assets/{hostInit-BjOFEl3v.js → hostInit-BDJZ4Hxi.js} +1 -1
  61. package/dist/assets/i18n-kurEJu5K.js +1 -0
  62. package/dist/assets/{icons-CNI0rnl8.js → icons-nvRYK39P.js} +1 -1
  63. package/dist/assets/{index-CuIsX0Bx.js → index-BHcNBXxj.js} +3 -3
  64. package/dist/assets/{linked-devices-model-Dl4vHeXt.js → linked-devices-model-B3xUuhef.js} +1 -1
  65. package/dist/assets/{mf-entry-bootstrap-0-395ec2fe.js → mf-entry-bootstrap-0-bed506dd.js} +2 -2
  66. package/dist/assets/mount-Bi7qSGNi.js +1 -0
  67. package/dist/assets/{notification-rule-status-T3SwZb2I.js → notification-rule-status-JiMjbzwM.js} +1 -1
  68. package/dist/assets/{player-overlays-qzCoRsrQ.js → player-overlays-Cs69NgAR.js} +1 -1
  69. package/dist/assets/remoteEntry-BFUfVr12.js +1 -0
  70. package/dist/assets/{src-Cf1Uvi4o.js → src-Bb9LsNcW.js} +4 -4
  71. package/dist/assets/{src-CJoX3s-1.js → src-BwDSKCnh.js} +3 -3
  72. package/dist/assets/{sso-popup-CPavla3I.js → sso-popup-DVrI_KPY.js} +1 -1
  73. package/dist/assets/{step-inspector-model-CMrG9Xaa.js → step-inspector-model-B-1rSpjV.js} +1 -1
  74. package/dist/assets/{use-scenes-feed-CosaOMpn.js → use-scenes-feed-Cm1QR46I.js} +1 -1
  75. package/dist/assets/{useAdminDeviceRemoval-C5EQsX7f.js → useAdminDeviceRemoval-C6mofiow.js} +1 -1
  76. package/dist/assets/{useDevice-JbC1lVOL.js → useDevice-B_IWTz7U.js} +1 -1
  77. package/dist/assets/useEventInvalidation-Bi7qSGNi.js +1 -0
  78. package/dist/assets/{useFaultTypeOptions-BCjpEaI1.js → useFaultTypeOptions-DaOrnWNh.js} +1 -1
  79. package/dist/assets/{useNodeUrlSelection-uTbHSv6T.js → useNodeUrlSelection-ESSKAIP0.js} +1 -1
  80. package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-BZ1YRJXZ.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-B4AKnF2Y.js} +2 -2
  81. package/dist/index.html +12 -12
  82. package/dist/server/addon.js +1 -1
  83. package/package.json +2 -2
  84. package/dist/assets/Identity-8tZo1PB_.js +0 -1
  85. package/dist/assets/SessionsList-CriK5VLX.js +0 -2
  86. package/dist/assets/device-picker-model-CYNi1aEm.js +0 -1
  87. package/dist/assets/i18n-BHLBFC1-.js +0 -1
  88. package/dist/assets/mount-CYNi1aEm.js +0 -1
  89. package/dist/assets/remoteEntry-Dc97BJQ9.js +0 -1
  90. package/dist/assets/useEventInvalidation-CYNi1aEm.js +0 -1
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./Devices-NJ52UGWV.js","./player-overlays-qzCoRsrQ.js","./chevron-down-CBb-F8DT.js","./src-CJoX3s-1.js","./compat-muhdrMna.js","./src-Cf1Uvi4o.js","./useTranslation-uIxPZ_3N.js","./chunk-4ZMWKKQ3-BCeNTgXs.js","./AdminPage-CA4Sxydy.js","./device-integration-icon-B63imyJJ.js","./useAdminDeviceRemoval-C5EQsX7f.js","./useEventInvalidation-CYNi1aEm.js","./addon-kind-filter-CEGKkC1O.js","./Integrations-B_Inbdpc.js","./i18n-BHLBFC1-.js","./table-2-DMxm3oyu.js","./IntegrationDetail-CCyZhNWc.js","./search-x-C5ra3Aft.js","./FormBuilder-BjcOGVVa.js","./Pipeline-BGOu-2v_.js","./terminal-BncJ-1sF.js","./usb-P4R9CjYI.js","./crop-B-t0rzRY.js","./layers-BH9u1mrE.js","./NodeAddonsSettingsPanel-hnXBekcO.js","./settings-section-shape-DbQZZpNL.js","./step-inspector-model-CMrG9Xaa.js","./board-model-BvqJSvTB.js","./useDevice-JbC1lVOL.js","./DeviceDetail-D7GFYFEm.js","./divide-Bmm9r7CP.js","./circle-slash-Duh934sZ.js","./scan-eye-C862nWtV.js","./shapes-D4IRNSXI.js","./file-up-2YD_M6f_.js","./unlink-D3-IGpS8.js","./CompositionBlockEditor-DjJGal7a.js","./camera-block-model-QrJ_0XZY.js","./assignment-candidates-BfhoJg-T.js","./device-picker-model-CYNi1aEm.js","./TemplateEditorDialog-CwArOYwD.js","./command-vocab-CiIfJEGh.js","./linked-devices-model-Dl4vHeXt.js","./format-D43HvBR0.js","./auth-context-CkfOTCG-.js","./mount-CYNi1aEm.js","./authed-media-C-zK1a1B.js","./notification-rule-status-T3SwZb2I.js","./Showroom-CprRp6yl.js","./EmbedPlayerPage-BKq1BRg_.js","./EmbedDevicePage-F1NEkMUT.js","./Library-BJXSgpWZ.js","./user-x-DkWcmF99.js","./square-check-big-DAcFGNUN.js","./AdminSectionedPage-3XsaKUPh.js","./NewExportModal-D64AhGe8.js","./use-scenes-feed-CosaOMpn.js","./format-size-DIxKXxtj.js","./Archive-5WNTy09R.js","./scissors-DpiKUioV.js","./StorageLocationsTable-B81bi89X.js","./eraser-B3lnG9yK.js","./hard-drive-download-C6N6tovA.js","./InstancesTable-CCUTp360.js","./link-2-off-DmsjRAt7.js","./broker-oauth-popup-B_GRcwxo.js","./sso-popup-CPavla3I.js","./Viewer-9ydpkUg6.js","./monitor-off-DnOkDa2s.js","./Build-B6m8-obM.js","./variable-DTEpBbRf.js","./useFaultTypeOptions-BCjpEaI1.js","./CompositionEditorPage-MACY9CFt.js","./Locations-CEsFxXK8.js","./Addons-Ck90J9_n.js","./useNodeUrlSelection-uTbHSv6T.js","./AiProfiles-8UssQtkR.js","./flask-conical-D7tbJQpj.js","./message-square-plus-_aGccjyj.js","./ai-page.helpers-CiDsxXp3.js","./MyAccess-CAtcn_a3.js","./monitor-smartphone-DPI9EQus.js","./SessionsList-CriK5VLX.js","./Logs-DrLmsP4V.js","./timer-reset-5221y6Jb.js","./Identity-8tZo1PB_.js","./key-CH4aXNMz.js","./BootstrapSettingsForm-CQLdqB1p.js","./Network-BUfXtVhQ.js","./waypoints-CuxO4XzY.js","./useInvalidateAddonSettings-CyofQfBo.js","./Network-DtxX27Jz.css","./Integrations-D1Ybtztv.js","./TrainingProviders-CGpG1PvO.js","./Data-B2mmPVLY.js","./database-zap-DHuELz_w.js","./System-D3mpSwHc.js","./ruler-Buxogset.js","./Cluster-CzmgBDwN.js","./memory-stick-BQrJMbEW.js","./Terminal-Dqxv-P1E.js","./Terminal-kHJ-D0s7.css","./Notifications-CrrX9yK9.js","./languages-Du_pOBpX.js","./History-CqTLHyoj.js","./Jobs-BDZ-S8az.js","./Calendars-BbmdZy07.js"])))=>i.map(i=>d[i]);
2
- import{a as e,t}from"./rolldown-runtime-Cyuzqnbw.js";import"./virtual_mf-exposes___mfe_internal__admin_ui_host__remoteEntry-_hash_-DnnXQRkG.js";import{a as n,o as r,r as i}from"./virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-BZ1YRJXZ.js";import{t as a}from"./vite-preload-helper-kNaey6uv.js";import{A as o,C as s,D as c,F as l,H as u,J as d,K as f,M as p,N as m,O as h,Q as g,R as _,S as v,V as y,X as b,Y as x,Z as S,a as C,d as w,et as T,i as E,k as D,o as O,t as k,u 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-CEyXHAdg.js";import{$n as N,Bi as P,Ci as F,Co as ee,Cr as te,D as ne,Da as re,Di as ie,Dt as ae,Ea as oe,Fa as se,Gi as ce,Gt as I,Ha as le,Hr as ue,Ia as de,It as fe,J as pe,Ja as L,Jr as R,K as z,Kt as me,Lr as B,Lt as he,O as ge,Oa as _e,Oi as ve,Oo as ye,Ot as be,Pa as xe,Q as Se,Qi as Ce,Ri as we,Rr as Te,T as Ee,Ua as De,Un as Oe,Ur as ke,V as Ae,Va as je,Wr as Me,Wt as Ne,X as Pe,Xi as Fe,Xr as Ie,Y as Le,Yt as Re,Zn as ze,Zt as Be,_a as Ve,_n as He,at as V,ba as Ue,bo as We,br as Ge,bt as Ke,ci as qe,da as Je,dt as Ye,ei as Xe,fo as Ze,ga as Qe,gr as $e,hr as et,ht as tt,in as nt,ir as rt,it,jn as at,ka as ot,ki as st,kt as ct,li as lt,mi as ut,nr as dt,oi as H,or as ft,pt,q as mt,qt as ht,r as gt,ri as _t,sr as vt,to as yt,ut as bt,vi as xt,vr as St,wi as Ct,wo as wt,wr as Tt,xn as Et,xo as Dt,xt as U,yt as W,za as Ot,zi as kt,zn as At,zt as G}from"./player-overlays-qzCoRsrQ.js";import{Bc as jt,Dl as Mt,Fl as Nt,Il as Pt,Jl as Ft,Jo as It,Mc as K,Ml as Lt,Na as Rt,Nc as q,Nl as zt,Pl as Bt,Qc as Vt,Qr as Ht,Vl as Ut,Zn as Wt,_a as Gt,_c as Kt,a as qt,ba as Jt,d as Yt,ec as Xt,f as Zt,i as Qt,jc as $t,jl as en,l as tn,ms as nn,n as rn,o as an,r as on,s as sn,si as cn,t as ln,u as un,vc as dn,ws as fn,xl as pn}from"./src-CJoX3s-1.js";import{t as mn}from"./chevron-down-CBb-F8DT.js";import{a as hn,c as gn,d as _n,f as vn,g as yn,h as bn,i as xn,l as Sn,m as Cn,n as wn,o as Tn,p as En,r as Dn,s as On,t as kn,u as An}from"./terminal-BncJ-1sF.js";import{$a as jn,$c as Mn,$i as Nn,$o as Pn,$t as Fn,Ac as In,Am as Ln,Ar as Rn,Ba as zn,Bf as Bn,Bl as Vn,Br as Hn,Bt as Un,Ci as Wn,D as Gn,Dc as Kn,Dm as qn,Do as Jn,Ei as Yn,Em as Xn,Er as Zn,Fc as Qn,Fm as $n,Fn as er,Fo as tr,Fs as nr,Ft as rr,Gc as ir,Gi as ar,Gr as or,Gt as sr,Ha as cr,Hi as lr,Hl as ur,Ht as dr,I as fr,Ic as pr,If as mr,Il as hr,Im as gr,In as _r,Io as vr,Ir as yr,Ja as br,Ji as xr,Jp as Sr,K as Cr,Ki as wr,Kl as Tr,Kt as Er,La as Dr,Lf as Or,Ln as kr,Ls as Ar,Lt as jr,Mc as Mr,Mt as Nr,Nr as Pr,Oc as Fr,Om as Ir,Or as Lr,Ou as Rr,Pa as zr,Qc as Br,Qn as Vr,Qo as Hr,Qt as Ur,Ra as Wr,Ri as Gr,Rl as Kr,Rn as qr,Rt as Jr,Sc as Yr,Sm as Xr,Sr as Zr,St as Qr,Tp as $r,Ua as ei,Ur as ti,Ut as ni,Va as ri,Vp as ii,Vr as ai,Wa as oi,Wc as si,Xl as ci,Xt as li,Yi as ui,Yl as di,Yt as fi,Za as pi,Zc as mi,Zi as hi,Zl as gi,Zo as _i,Zt as vi,_c as yi,_i as bi,_l as xi,_m as Si,_o as Ci,_r as wi,aa as Ti,ac as Ei,al as Di,ao as Oi,bc as ki,bm as Ai,br as ji,c as Mi,cl as Ni,cm as Pi,dl as Fi,do as Ii,ea as Li,en as Ri,eo as zi,es as Bi,et as Vi,eu as Hi,f as Ui,fl as Wi,fu as Gi,g as Ki,gm as qi,gr as Ji,hi as Yi,hm as Xi,hr as Zi,i as Qi,ia as $i,il as ea,j as ta,ja as na,jm as ra,jo as ia,jp as aa,kt as oa,l as sa,li as ca,lo as la,m as ua,mc as da,mi as fa,mm as pa,n as ma,na as ha,nn as ga,nt as _a,nu as va,ol as ya,qa as ba,qf as xa,ql as Sa,qt as Ca,r as wa,ra as Ta,rl as Ea,rm as Da,rn as Oa,ru as ka,sn as Aa,so as ja,st as Ma,ta as Na,tn as Pa,ts as Fa,tu as Ia,ul as La,uo as Ra,vc as za,vi as Ba,vm as Va,vn as Ha,vp as Ua,vr as Wa,wc as Ga,wf as Ka,wm as qa,wt as Ja,xc as Ya,xm as Xa,xo as Za,xr as Qa,yc as $a,ym as eo,yp as to,yr as no,yu as ro,za as io,zc as ao,zf as oo,zn as so,zo as co,zt as lo}from"./src-Cf1Uvi4o.js";import{r as uo,t as fo}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare__react_mf_2_dom__loadShare__.js-BPba2g2p.js";import{t as po}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare__react_mf_2_dom_mf_1_client__loadShare__.js-ZBKFTPET.js";import{a as J,c as mo,d as ho,f as go,i as Y,l as _o,n as vo,o as yo,r as bo,s as xo,t as So,u as Co}from"./chunk-4ZMWKKQ3-BCeNTgXs.js";import{n as wo,t as X}from"./i18n-BHLBFC1-.js";import{a as To,c as Eo,d as Do,l as Oo,o as ko,r as Ao,s as jo,t as Z,u as Mo}from"./useTranslation-uIxPZ_3N.js";import"./mount-CYNi1aEm.js";import{a as No,c as Po,d as Fo,i as Io,n as Lo,o as Ro,r as zo,s as Bo,t as Vo,u as Ho}from"./sso-popup-CPavla3I.js";import{n as Uo,r as Wo,t as Go}from"./broker-oauth-popup-B_GRcwxo.js";import{n as Ko,t as qo}from"./FormBuilder-BjcOGVVa.js";import{C as Jo,S as Yo,a as Xo,b as Zo,c as Qo,d as $o,f as es,g as ts,h as ns,i as rs,l as is,m as as,n as os,o as ss,p as cs,r as ls,s as us,t as ds,u as fs,v as ps,x as ms,y as hs}from"./auth-context-CkfOTCG-.js";import{n as gs,t as _s}from"./useDevice-JbC1lVOL.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})(),T(),uo();var vs=`dominevo.debugLayers`,ys=/(transform|opacity|filter|perspective)/;function bs(e){return e!==``&&e!==`none`}function xs(e,t,n=120){if(t.width<=0||t.height<=0||t.top>=n||t.bottom<=0)return null;let r=[];e.position===`fixed`&&r.push(`fixed`),e.position===`sticky`&&r.push(`sticky`),(bs(e.backdropFilter)||bs(e.webkitBackdropFilter))&&r.push(`backdrop-filter`),bs(e.filter)&&r.push(`filter`);let i=Number.parseFloat(e.opacity);return Number.isFinite(i)&&i<1&&r.push(`opacity`),bs(e.transform)&&r.push(`transform`),bs(e.perspective)&&r.push(`perspective`),e.isolation===`isolate`&&r.push(`isolation`),e.mixBlendMode!==``&&e.mixBlendMode!==`normal`&&r.push(`mix-blend-mode`),ys.test(e.willChange)&&r.push(`will-change`),r.length===0?null:{reasons:r,zIndex:e.zIndex}}function Ss(e,t,n,r){let i=n!==null&&n!==``?`[${n}]`:t.split(/\s+/).filter(e=>e!==``).slice(0,3).map(e=>`.${e}`).join(``);return`${e.toLowerCase()}${i} z=${r.zIndex} ${r.reasons.join(`+`)}`}function Cs(e,t){let n=new URLSearchParams(e).get(`debugLayers`);return n===`1`?{on:!0,persist:`1`}:n===`0`?{on:!1,persist:null}:{on:t===`1`,persist:`keep`}}var ws=`dominevo.debugLayers.noBlur`,Ts=`dominevo.debugLayers.outlines`,Es=`dominevo.debugLayers.topLayer`,Ds=`debug-no-backdrop-blur`;function Os(e,t){try{return e===null?null:e.getItem(t)}catch{return null}}function ks(e,t,n){try{if(e===null)return;n===null?e.removeItem(t):e.setItem(t,n)}catch{}}function As(e,t){let n=Cs(t,Os(e,vs));n.persist!==`keep`&&ks(e,vs,n.persist);let r={on:n.on,noBlur:Os(e,ws)===`1`,outlines:Os(e,Ts)!==`0`,topLayer:Os(e,Es)!==`0`},i=new Set,a=e=>{r=e;for(let e of i)e()};return{getState:()=>r,subscribe:e=>(i.add(e),()=>{i.delete(e)}),setOn:t=>{if(ks(e,vs,t?`1`:null),!t){ks(e,ws,null),ks(e,Ts,null),ks(e,Es,null),a({on:t,noBlur:!1,outlines:!0,topLayer:!0});return}a({...r,on:t})},setNoBlur:t=>{ks(e,ws,t?`1`:null),a({...r,noBlur:t})},setOutlines:t=>{ks(e,Ts,t?null:`0`),a({...r,outlines:t})},setTopLayer:t=>{ks(e,Es,t?null:`0`),a({...r,topLayer:t})}}}var js=[`transform`,`will-change`,`position`,`backdrop-filter`,`filter`,`opacity`];function Ms(e){return js.map(t=>`${t}: ${e===null?`n/a`:e(t)||`-`}`)}var Ns=null;function Ps(){try{return window.sessionStorage}catch{return null}}function Fs(){return Ns===null&&(Ns=As(Ps(),window.location.search)),Ns}function Is(){let e=Fs();return{...b(e.subscribe,e.getState),setOn:e.setOn,setNoBlur:e.setNoBlur,setOutlines:e.setOutlines,setTopLayer:e.setTopLayer}}T();var Ls=`data-debug-layers`,Rs=250,zs=60;function Bs(){let e=[],t=document.body.querySelectorAll(`*`);for(let n of Array.from(t)){if(e.length>=zs)break;if(n.closest(`[${Ls}]`)!==null)continue;let t=n.getBoundingClientRect();if(t.width<=0||t.height<=0||t.top>=120||t.bottom<=0)continue;let r=getComputedStyle(n),i=xs({position:r.position,zIndex:r.zIndex,opacity:r.opacity,filter:r.filter,backdropFilter:r.backdropFilter,webkitBackdropFilter:r.getPropertyValue(`-webkit-backdrop-filter`),transform:r.transform,perspective:r.perspective,isolation:r.isolation,mixBlendMode:r.mixBlendMode,willChange:r.willChange},t);if(i===null)continue;let a=n.getAttribute(`data-testid`);e.push({id:e.length,top:t.top,left:t.left,width:t.width,height:t.height,label:Ss(n.tagName,typeof n.className==`string`?n.className:``,a===null?null:`data-testid=${a}`,i),reasons:i.reasons})}return e}function Vs(e){let t=getComputedStyle(e),n=e=>Number.parseFloat(e)||0;return{top:n(t.paddingTop),right:n(t.paddingRight),bottom:n(t.paddingBottom),left:n(t.paddingLeft)}}function Hs(e){return e.includes(`backdrop-filter`)||e.includes(`filter`)?{outline:`outline-danger`,chip:`bg-danger`}:e.includes(`opacity`)||e.includes(`mix-blend-mode`)?{outline:`outline-warning`,chip:`bg-warning`}:e.includes(`fixed`)||e.includes(`sticky`)?{outline:`outline-info`,chip:`bg-info`}:{outline:`outline-primary`,chip:`bg-primary`}}function Us(){let e=Reflect.get(navigator,`standalone`);return window.matchMedia(`(display-mode: standalone)`).matches||e===!0}function Ws(){return`0.1.2`}function Gs(e,t){if(!(e===null||typeof e.showPopover!=`function`))try{e.matches(`:popover-open`)&&e.hidePopover(),t&&e.showPopover()}catch{}}function Ks(){let e=document.querySelector(`[data-debug-header]`),t=e===null?null:e.querySelector(`img`),n=e=>Ms(e===null?null:t=>getComputedStyle(e).getPropertyValue(t));return{header:n(e),logo:n(t)}}function qs({noBlur:e,onNoBlurChange:t,outlines:n,onOutlinesChange:r,topLayer:i,onTopLayerChange:a}){let[o,c]=x([]),[l,u]=x({top:0,right:0,bottom:0,left:0}),f=d(null),p=d(null),m=d(null),[h,g]=x(Ks),b=_(()=>{Gs(p.current,i),c(n?Bs():[]),g(Ks()),f.current!==null&&u(Vs(f.current))},[n,i]),S=_(()=>{m.current===null&&(m.current=window.setTimeout(()=>{m.current=null,b()},Rs))},[b]);return y(()=>{b();let e=new MutationObserver(e=>{e.some(e=>!(e.target instanceof Element&&e.target.closest(`[${Ls}]`)!==null))&&S()});return e.observe(document.body,{childList:!0,subtree:!0,attributes:!0}),window.addEventListener(`resize`,S),window.addEventListener(`orientationchange`,S),window.addEventListener(`scroll`,S,!0),()=>{e.disconnect(),window.removeEventListener(`resize`,S),window.removeEventListener(`orientationchange`,S),window.removeEventListener(`scroll`,S,!0),m.current!==null&&window.clearTimeout(m.current)}},[b,S]),fo(s(`div`,{[Ls]:``,ref:p,popover:`manual`,className:`pointer-events-none fixed inset-0 z-[2147483647] m-0 h-full w-full overflow-visible border-0 bg-transparent p-0`,children:[v(`div`,{ref:f,"aria-hidden":!0,className:`invisible absolute h-0 w-0`,style:{paddingTop:`env(safe-area-inset-top)`,paddingRight:`env(safe-area-inset-right)`,paddingBottom:`env(safe-area-inset-bottom)`,paddingLeft:`env(safe-area-inset-left)`}}),o.map(e=>{let t=Hs(e.reasons);return v(`div`,{"data-testid":`debug-layer-box`,className:ee(`absolute outline outline-1 -outline-offset-1`,t.outline),style:{top:e.top,left:e.left,width:e.width,height:e.height},children:v(`span`,{className:ee(`absolute left-0 max-w-[90vw] truncate px-1 font-mono text-[9px] leading-3 text-primary-foreground`,t.chip),style:{top:e.id%6*12},children:e.label})},e.id)}),s(`div`,{"data-testid":`debug-layers-badge`,className:`absolute right-1 top-14 rounded-md bg-background-elevated px-2 py-1 font-mono text-[10px] leading-4 text-foreground outline outline-1 outline-border`,children:[s(`div`,{children:[`admin-ui `,Ws()]}),s(`div`,{children:[`inset t`,l.top,` r`,l.right,` b`,l.bottom,` l`,l.left]}),s(`div`,{children:[`display-mode standalone:`,` `,window.matchMedia(`(display-mode: standalone)`).matches?`yes`:`no`,` · `,`navigator.standalone: `,Us()?`yes`:`no`]}),s(`div`,{children:[window.innerWidth,`x`,window.innerHeight,` · `,o.length,` layers`]}),v(Wn,{checked:e,onCheckedChange:t,label:`no backdrop blur`,className:`pointer-events-auto mt-1 text-[10px]`}),v(Wn,{checked:n,onCheckedChange:r,label:`outlines`,className:`pointer-events-auto mt-1 text-[10px]`}),v(Wn,{checked:i,onCheckedChange:a,label:`top layer`,className:`pointer-events-auto mt-1 text-[10px]`}),s(`div`,{"data-testid":`debug-header-styles`,className:`mt-1`,children:[v(`div`,{children:`header`}),h.header.map(e=>v(`div`,{children:e},e)),v(`div`,{children:`header logo`}),h.logo.map(e=>v(`div`,{children:e},e))]})]})]}),document.body)}function Js(){let{on:e,noBlur:t,setNoBlur:n,outlines:r,setOutlines:i,topLayer:a,setTopLayer:o}=Is();return y(()=>{let n=e&&t;return document.documentElement.classList.toggle(Ds,n),()=>document.documentElement.classList.remove(Ds)},[e,t]),e?v(qs,{noBlur:t,onNoBlurChange:n,outlines:r,onOutlinesChange:i,topLayer:a,onTopLayerChange:o}):null}var Ys=`camera`;function Xs(e){return e===null||!/^\d+$/.test(e)?null:Number(e)}function Zs(e,t){return t===null?e:e.filter(e=>e.deviceId===t)}function Qs(e,t){let n=new Set(e.map(e=>e.deviceId));return t!==null&&n.add(t),[...n].sort((e,t)=>e-t)}var $s=`/archive`,ec=`/addon/training`,tc=`/library?tab=exports`,nc=`section`,rc=`camera`,ic=`view`;function ac(e,t){let n=`${$s}?${nc}=cameras&${rc}=${String(e)}`;return t===void 0?n:`${n}&${ic}=${t}`}function oc(e){return e===void 0?tc:`${tc}&${Ys}=${String(e)}`}var sc={settings:`settings`,space:`health`,health:`health`,events:`review`,review:`review`},cc={storage:$s,events:$s,cameras:$s,exports:tc,activity:`${$s}#activity`,management:`${$s}#tools`},lc=/^\/archive\/(\d+)\/?$/;function uc(e,t){let n=new URLSearchParams(t);if(e===`/recordings`){let e=n.get(`tab`);return e===null?$s:cc[e]??`/archive`}if(e===`/library`&&n.get(`tab`)===`events`)return n.get(`section`)===`retrain`?ec:$s;let r=lc.exec(e);if(r?.[1]!==void 0){let e=Number(r[1]),t=n.get(nc);return t===`exports`?oc(e):ac(e,t===null?void 0:sc[t])}return null}var dc=e(t(((e,t)=>{t.exports={area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0}}))()),fc=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g;function pc(e){var t={type:`tag`,name:``,voidElement:!1,attrs:{},children:[]},n=e.match(/<\/?([^\s]+?)[/\s>]/);if(n&&(t.name=n[1],(dc.default[n[1]]||e.charAt(e.length-2)===`/`)&&(t.voidElement=!0),t.name.startsWith(`!--`))){var r=e.indexOf(`-->`);return{type:`comment`,comment:r===-1?``:e.slice(4,r)}}for(var i=new RegExp(fc),a=null;(a=i.exec(e))!==null;)if(a[0].trim())if(a[1]){var o=a[1].trim(),s=[o,``];o.indexOf(`=`)>-1&&(s=o.split(`=`)),t.attrs[s[0]]=s[1],i.lastIndex--}else a[2]&&(t.attrs[a[2]]=a[3].trim().substring(1,a[3].length-1));return t}var mc=/<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g,hc=/^\s*$/,gc=Object.create(null);function _c(e,t){switch(t.type){case`text`:return e+t.content;case`tag`:return e+=`<`+t.name+(t.attrs?function(e){var t=[];for(var n in e)t.push(n+`="`+e[n]+`"`);return t.length?` `+t.join(` `):``}(t.attrs):``)+(t.voidElement?`/>`:`>`),t.voidElement?e:e+t.children.reduce(_c,``)+`</`+t.name+`>`;case`comment`:return e+`<!--`+t.comment+`-->`}}var vc={parse:function(e,t){t||={},t.components||=gc;var n,r=[],i=[],a=-1,o=!1;if(e.indexOf(`<`)!==0){var s=e.indexOf(`<`);r.push({type:`text`,content:s===-1?e:e.substring(0,s)})}return e.replace(mc,function(s,c){if(o){if(s!==`</`+n.name+`>`)return;o=!1}var l,u=s.charAt(1)!==`/`,d=s.startsWith(`<!--`),f=c+s.length,p=e.charAt(f);if(d){var m=pc(s);return a<0?(r.push(m),r):((l=i[a]).children.push(m),r)}if(u&&(a++,(n=pc(s)).type===`tag`&&t.components[n.name]&&(n.type=`component`,o=!0),n.voidElement||o||!p||p===`<`||n.children.push({type:`text`,content:e.slice(f,e.indexOf(`<`,f))}),a===0&&r.push(n),(l=i[a-1])&&l.children.push(n),i[a]=n),(!u||n.voidElement)&&(a>-1&&(n.voidElement||n.name===s.slice(2,-1))&&(a--,n=a===-1?r:i[a]),!o&&p!==`<`&&p)){l=a===-1?r:i[a].children;var h=e.indexOf(`<`,f),g=e.slice(f,h===-1?void 0:h);hc.test(g)&&(g=` `),(h>-1&&a+l.length>=0||g!==` `)&&l.push({type:`text`,content:g})}}),r},stringify:function(e){return e.reduce(function(e,t){return e+_c(``,t)},``)}};T();var yc=(e,t)=>{if(!e)return!1;let n=e.props?.children??e.children;return t?n.length>0:!!n},bc=e=>{if(!e)return[];let t=e.props?.children??e.children;return e.props?.i18nIsDynamicList?Sc(t):t},xc=e=>Array.isArray(e)&&e.every(p),Sc=e=>Array.isArray(e)?e:[e],Cc=(e,t)=>{let n={...t};return n.props={...t.props,...e.props},n},wc=e=>{let t={};if(!e)return t;let n=e=>{Sc(e).forEach(e=>{Oo(e)||(yc(e)?n(bc(e)):Eo(e)&&!p(e)&&Object.assign(t,e))})};return n(e),t},Tc=(e,t,n,r)=>{if(!e)return``;let i=``,a=Sc(e),o=t?.transSupportBasicHtmlNodes?t.transKeepBasicHtmlNodesFor??[]:[];return a.forEach((e,a)=>{if(Oo(e)){i+=`${e}`;return}if(p(e)){let{props:s,type:c}=e,l=Object.keys(s).length,u=o.indexOf(c)>-1,d=s.children;if(!d&&u&&!l){i+=`<${c}/>`;return}if(!d&&(!u||l)||s.i18nIsDynamicList){i+=`<${a}></${a}>`;return}if(u&&l<=1){let e=Oo(d)?d:Tc(d,t,n,r);i+=`<${c}>${e}</${c}>`;return}let f=Tc(d,t,n,r);i+=`<${a}>${f}</${a}>`;return}if(e===null){Mo(n,`TRANS_NULL_VALUE`,`Passed in a null value as child`,{i18nKey:r});return}if(Eo(e)){let{format:t,...a}=e,o=Object.keys(a);if(o.length===1){let e=t?`${o[0]}, ${t}`:o[0];i+=`{{${e}}}`;return}Mo(n,`TRANS_INVALID_OBJ`,`Invalid child - Object should only have keys {{ value, format }} (format is optional).`,{i18nKey:r,child:e});return}Mo(n,`TRANS_INVALID_VAR`,`Passed in a variable like {number} - pass variables for interpolation as full objects like {{number}}.`,{i18nKey:r,child:e})}),i},Ec=(e,t=[],n={})=>{if(!e)return e;let r=Object.keys(n),i=[...t,...r],a=``,o=0;for(;o<e.length;)if(e[o]===`<`){let t=!1,n=e.slice(o).match(/^<\/(\d+|[a-zA-Z][a-zA-Z0-9_-]*)>/);if(n){let e=n[1];(/^\d+$/.test(e)||i.includes(e))&&(t=!0,a+=n[0],o+=n[0].length)}if(!t){let n=e.slice(o).match(/^<(\d+|[a-zA-Z][a-zA-Z0-9_-]*)(\s+[\w-]+(?:=(?:"[^"]*"|'[^']*'|[^\s>]+))?)*\s*(\/)?>/);if(n){let e=n[1];(/^\d+$/.test(e)||i.includes(e))&&(t=!0,a+=n[0],o+=n[0].length)}}t||(a+=`&lt;`,o+=1)}else a+=e[o],o+=1;return a},Dc=(e,t,n,r,i,a,s)=>{if(n===``)return[];let l=i.transKeepBasicHtmlNodesFor||[],d=n&&new RegExp(l.map(e=>`<${e}`).join(`|`)).test(n);if(!e&&!t&&!d&&!s)return[n];let f=t??{},m=e=>{Sc(e).forEach(e=>{Oo(e)||(yc(e)?m(bc(e)):Eo(e)&&!p(e)&&Object.assign(f,e))})};m(e);let g=Ec(n,l,f),_=vc.parse(`<0>${g}</0>`),v={...f,...a},y=(e,t,n)=>{let r=bc(e),i=x(r,t.children,n);return xc(r)&&i.length===0||e.props?.i18nIsDynamicList?r:i},b=(e,t,n,r,i)=>{e.dummy?(e.children=t,n.push(h(e,{key:r},i?void 0:t))):n.push(...c.map([e],e=>{if(e.type===u||e.props?.i18nIsDynamicList!==void 0){let n={key:r};return e&&e.props&&Object.keys(e.props).forEach(t=>{t===`children`||t===`i18nIsDynamicList`||(n[t]=e.props[t])}),o(e.type,n,i?null:t)}let n={key:r};return e&&e.props&&Object.keys(e.props).forEach(t=>{t===`ref`||t===`children`||(n[t]=e.props[t])}),h(e,n,i?null:t)}))},x=(e,n,a)=>{let c=Sc(e),u=Sc(n),f={};return u.reduce((e,n,u)=>{let m=n.children?.[0]?.content&&r.services.interpolator.interpolate(n.children[0].content,v,r.language);if(n.type===`tag`){let h=c[parseInt(n.name,10)];!h&&t&&(h=t[n.name]),a.length===1&&!h&&(h=a[0][n.name]),h||={};let g={...n.attrs};s&&Object.keys(g).forEach(e=>{let t=g[e];Oo(t)&&(g[e]=jo(t))});let _=Object.keys(g).length===0?h:Cc({props:g},h),S=p(_),C=S&&yc(n,!0)&&!n.voidElement,w=d&&Eo(_)&&_.dummy&&!S,T=Eo(t)&&Object.hasOwnProperty.call(t,n.name);if(Oo(_)){let t=r.services.interpolator.interpolate(_,v,r.language);e.push(t)}else if(yc(_)||C)b(_,y(_,n,a),e,u);else if(w)b(_,x(c,n.children,a),e,u);else if(Number.isNaN(parseFloat(n.name)))if(T)b(_,y(_,n,a),e,u,n.voidElement);else if(i.transSupportBasicHtmlNodes&&l.indexOf(n.name)>-1)if(n.voidElement)e.push(o(n.name,{key:`${n.name}-${u}`}));else{let t=f[n.name]||0;f[n.name]=t+1;let r,i=0;for(let e=0;e<c.length;e+=1){let a=c[e];if(p(a)&&a.type===n.name){if(i===t){r=a;break}i+=1}}let s=x(r?Sc(bc(r)):c,n.children,a);e.push(o(n.name,{key:`${n.name}-${u}`},s))}else if(n.voidElement)e.push(`<${n.name} />`);else{let t=x(c,n.children,a);e.push(`<${n.name}>${t}</${n.name}>`)}else if(Eo(_)&&!S){let t=n.children[0]?m:null;t&&e.push(t)}else b(_,m,e,u,n.children.length!==1||!m)}else if(n.type===`text`){let t=i.transWrapTextNodes,a=typeof i.unescape==`function`?i.unescape:ko().unescape,c=s?a(r.services.interpolator.interpolate(n.content,v,r.language)):r.services.interpolator.interpolate(n.content,v,r.language);t?e.push(o(t,{key:`${n.name}-${u}`},c)):e.push(c)}return e},[])};return bc(x([{dummy:!0,children:e||[]}],_,Sc(e||[]))[0])},Oc=(e,t,n)=>{let r=e.key||t,i=h(e,{key:r});if(!i.props||!i.props.children||n.indexOf(`${t}/>`)<0&&n.indexOf(`${t} />`)<0)return i;function a(){return o(u,null,i)}return o(a,{key:r})},kc=(e,t)=>e.map((e,n)=>Oc(e,n,t)),Ac=(e,t)=>{let n={};return Object.keys(e).forEach(r=>{Object.assign(n,{[r]:Oc(e[r],r,t)})}),n},jc=(e,t,n,r)=>e?Array.isArray(e)?kc(e,t):Eo(e)?Ac(e,t):(Do(n,`TRANS_INVALID_COMPONENTS`,`<Trans /> "components" prop expects an object or array`,{i18nKey:r}),null):null,Mc=e=>!Eo(e)||Array.isArray(e)?!1:Object.keys(e).reduce((e,t)=>e&&Number.isNaN(Number.parseFloat(t)),!0);function Nc({children:e,count:t,parent:n,i18nKey:r,context:i,tOptions:a={},values:s,defaults:c,components:l,ns:u,i18n:d,t:f,shouldUnescape:p,...m}){let h=d||To();if(!h)return Do(h,`NO_I18NEXT_INSTANCE`,`Trans: You need to pass in an i18next instance using i18nextReactModule`,{i18nKey:r}),e;let g=f||h.t.bind(h)||(e=>e),_={...ko(),...h.options?.react},v=u||g.ns||h.options?.defaultNS;v=Oo(v)?[v]:v||[`translation`];let{transDefaultProps:y}=_,b=y?.tOptions?{...y.tOptions,...a}:a,x=p??y?.shouldUnescape,S=y?.values?{...y.values,...s}:s,C=y?.components?{...y.components,...l}:l,w=Tc(e,_,h,r),T=c||b?.defaultValue||w||_.transEmptyNodeValue||(typeof r==`function`?wo(r):r),{hashTransKey:E}=_,D=r||(E?E(w||T):w||T);s=h.options?.interpolation?.defaultVariables?S&&Object.keys(S).length>0?{...S,...h.options.interpolation.defaultVariables}:{...h.options.interpolation.defaultVariables}:S;let O=wc(e);O&&typeof O.count==`number`&&t===void 0&&(t=O.count);let k=s||t!==void 0&&!h.options?.interpolation?.alwaysFormat||!e?b.interpolation:{interpolation:{...b.interpolation,prefix:`#$?`,suffix:`?$#`}},A={...b,context:i||b.context,count:t,...s,...k,defaultValue:T,ns:v},j=D?g(D,A):T;j===D&&T&&(j=T);let M=jc(C,j,h,r),N=M||e,P=null;Mc(M)&&(P=M,N=e);let F=Dc(N,P,j,h,_,A,x),ee=n??_.defaultTransParent;return ee?o(ee,m,F):F}T();function Pc({children:e,count:t,parent:n,i18nKey:r,context:i,tOptions:a={},values:o,defaults:s,components:c,ns:l,i18n:u,t:d,shouldUnescape:f,...p}){let{i18n:m,defaultNS:h}=M(Ao)||{},g=u||m||To(),_=d||g?.t.bind(g);return Nc({children:e,count:t,parent:n,i18nKey:r,context:i,tOptions:a,values:o,defaults:s,components:c,ns:l||_?.ns||h||g?.options?.defaultNS,i18n:g,t:d,shouldUnescape:f,...p})}T();function Fc({i18n:e,defaultNS:t,children:n}){let r=f(()=>({i18n:e,defaultNS:t}),[e,t]);return o(Ao.Provider,{value:r},n)}var Ic=[`starting`,`awaiting-login`,`captured`,`error`,`cancelled`],Lc=[`awaiting-code`,`captured`,`expired`,`error`,`cancelled`];function Rc(e){return typeof e==`object`&&!!e}function zc(e){return Rc(e)&&typeof e.sessionId==`string`&&typeof e.loginUrl==`string`}function Bc(e){return Rc(e)&&typeof e.sessionId==`string`&&typeof e.phase==`string`&&Ic.includes(e.phase)}function Vc(e){return Rc(e)&&typeof e.sessionId==`string`&&typeof e.userCode==`string`&&typeof e.verificationUrl==`string`&&typeof e.expiresAt==`number`}function Hc(e){return Vc(e)&&Rc(e)&&typeof e.phase==`string`&&Lc.includes(e.phase)}function Uc(e){return Rc(e)&&typeof e.brokerId==`string`}function Wc(){return{"Content-Type":`application/json`,Authorization:`Bearer ${localStorage.getItem(`dominevo_admin_token`)??``}`}}async function Gc(e,t){try{return await e.json()}catch{throw Error(`${t} failed: HTTP ${e.status}`)}}function Kc(e){let t=Rc(e)&&typeof e.error==`string`?e.error:`Unknown error`;return Error(t)}async function qc(e,t,n){let r=await fetch(V(e),{method:`POST`,headers:Wc(),body:JSON.stringify(t)}),i=await Gc(r,`Sign-in ${e.split(`/`).pop()??`request`}`);if(!r.ok)throw Kc(i);if(!n(i))throw Error(`Unexpected response from server`);return i}function Jc(e,t){return qc(`${e}/start`,t,zc)}function Yc(e,t){return qc(`${e}/code/start`,t,Vc)}async function Xc(e,t){let n=new URLSearchParams({sessionId:t}),r=await fetch(V(`${e}/status?${n.toString()}`),{headers:{Authorization:Wc().Authorization??``}}),i=await Gc(r,`Sign-in status`);if(!r.ok)throw Kc(i);if(!Hc(i))throw Error(`Unexpected status response from server`);return i}async function Zc(e,t){let n=new URLSearchParams({sessionId:t}),r=await fetch(V(`${e}/status?${n.toString()}`),{headers:{Authorization:Wc().Authorization??``}}),i=await Gc(r,`Sign-in status`);if(!r.ok)throw Kc(i);if(!Bc(i))throw Error(`Unexpected status response from server`);return i}function Qc(e,t){return qc(`${e}/commit`,{...t},Uc)}async function $c(e,t){try{await fetch(V(`${e}/cancel`),{method:`POST`,headers:Wc(),body:JSON.stringify({sessionId:t})})}catch{}}T();var el=2e3,tl=1e3;function nl(e){let t=Math.max(0,Math.ceil(e/1e3));return`${Math.floor(t/60)}:${(t%60).toString().padStart(2,`0`)}`}function rl({expiresAt:e}){let{t}=Z(),[n,r]=x(()=>Date.now());return y(()=>{let e=setInterval(()=>r(Date.now()),tl);return()=>clearInterval(e)},[]),v(`span`,{className:`text-[11px] text-foreground-subtle`,children:t(`brokers.signIn.codeExpiresIn`,{time:nl(e-n)})})}function il({basePath:e,name:t,brokerId:n,getSettings:r,disabled:i,onSignedIn:a}){let{t:o}=Z(),[c,l]=x({kind:`idle`}),u=d(!0),f=d(null),p=d(null),m=_(()=>{p.current!==null&&clearInterval(p.current),p.current=null},[]),h=_(()=>{m();let t=f.current;f.current=null,t!==null&&$c(e,t)},[e,m]);y(()=>(u.current=!0,()=>{u.current=!1,h()}),[h]);let g=_(e=>{m(),u.current&&l({kind:`error`,message:e})},[m]),b=_(async r=>{m(),u.current&&l({kind:`committing`});try{let i=await Qc(e,{sessionId:r,name:t,...n===void 0?{}:{brokerId:n}});f.current=null,u.current&&a(i.brokerId)}catch(e){g(e instanceof Error?e.message:String(e))}},[e,n,g,t,a,m]),S=_(t=>{m(),p.current=setInterval(()=>{(async()=>{try{let n=await Xc(e,t);if(n.phase===`captured`)return void await b(t);if(n.phase===`error`)return g(n.error??o(`brokers.signIn.proxyError`));if(n.phase===`expired`){m(),u.current&&l({kind:`expired`});return}n.phase===`cancelled`&&(m(),u.current&&l({kind:`idle`}))}catch{}})()},el)},[e,b,g,m,o]),C=async()=>{h(),l({kind:`starting`});try{let t=await Yc(e,r());f.current=t.sessionId,l({kind:`waiting`,code:t}),S(t.sessionId)}catch(e){g(e instanceof Error?e.message:String(e))}},w=()=>{h(),l({kind:`idle`})};if(c.kind===`idle`||c.kind===`error`||c.kind===`expired`)return s(`div`,{className:`space-y-2`,children:[c.kind===`error`&&v(pi,{message:c.message}),c.kind===`expired`&&v(`p`,{className:`text-xs text-warning`,children:o(`brokers.signIn.codeExpired`)}),v(`p`,{className:`text-xs text-foreground-muted`,children:o(`brokers.signIn.codeIntro`)}),s(W,{variant:`primary`,size:`sm`,disabled:i===!0||t.trim().length===0,onClick:()=>void C(),children:[c.kind===`idle`?v(hn,{className:`h-3.5 w-3.5`}):v(et,{className:`h-3.5 w-3.5`}),` `,c.kind===`idle`?o(`brokers.signIn.getCode`):o(`brokers.signIn.newCode`)]})]});if(c.kind===`starting`||c.kind===`committing`)return s(`div`,{className:`flex items-center gap-2 rounded-lg border border-border bg-surface px-3 py-3 text-xs text-foreground-subtle`,children:[v(H,{className:`h-4 w-4 animate-spin flex-shrink-0`}),c.kind===`starting`?o(`brokers.signIn.starting`):o(`brokers.signIn.saving`)]});let{code:T}=c;return s(`div`,{className:`space-y-3 rounded-lg border border-border bg-surface p-3`,children:[v(`p`,{className:`text-xs text-foreground-muted`,children:o(`brokers.signIn.codeInstructions`)}),s(`div`,{className:`flex items-center justify-between gap-2 rounded-md border border-border-subtle bg-background px-3 py-2`,children:[v(`span`,{"data-testid":`device-code`,className:`font-mono text-2xl font-semibold tracking-widest text-foreground break-all`,children:T.userCode}),v(Pr,{value:T.userCode,srLabel:o(`brokers.signIn.copyCode`)})]}),s(W,{variant:`primary`,size:`sm`,onClick:()=>window.open(T.verificationUrl,`_blank`,`noopener,noreferrer`),children:[v(P,{className:`h-3.5 w-3.5`}),` `,o(`brokers.signIn.openCodePage`,{host:al(T.verificationUrl)})]}),s(`div`,{className:`flex flex-wrap items-center justify-between gap-2 pt-1`,children:[s(`span`,{className:`flex min-w-0 flex-col text-[11px] text-foreground-subtle`,children:[s(`span`,{className:`flex items-center gap-2`,children:[v(H,{className:`h-3 w-3 animate-spin flex-shrink-0`}),` `,o(`brokers.signIn.waitingForCode`)]}),v(rl,{expiresAt:T.expiresAt})]}),v(W,{variant:`outline`,size:`sm`,className:`shrink-0 whitespace-nowrap`,onClick:w,children:o(`brokers.signIn.cancel`)})]})]})}function al(e){try{let t=new URL(e);return`${t.host}${t.pathname===`/`?``:t.pathname}`}catch{return e}}T();var ol=2e3;function sl(e){return e.startsWith(`/`)&&!e.startsWith(`//`)?new URL(e,window.location.origin).toString():e}function cl({basePath:e,name:t,brokerId:n,getSettings:r,disabled:i,onSignedIn:a}){let{t:o}=Z(),[c,l]=x({kind:`idle`}),u=d(!0),f=d(null),p=d(null),m=_(()=>{p.current!==null&&clearInterval(p.current),p.current=null},[]),h=_(()=>{m();let t=f.current;f.current=null,t!==null&&$c(e,t)},[e,m]);y(()=>(u.current=!0,()=>{u.current=!1,h()}),[h]);let g=_(e=>{m(),u.current&&l({kind:`error`,message:e})},[m]),b=_(async r=>{m(),u.current&&l({kind:`committing`});try{let i=await Qc(e,{sessionId:r,name:t,...n===void 0?{}:{brokerId:n}});f.current=null,u.current&&a(i.brokerId)}catch(e){g(e instanceof Error?e.message:String(e))}},[e,n,g,t,a,m]),S=_(t=>{m(),p.current=setInterval(()=>{(async()=>{try{let n=await Zc(e,t);if(n.phase===`captured`)return void await b(t);if(n.phase===`error`)return g(n.error??o(`brokers.signIn.proxyError`));if(n.phase===`cancelled`){m(),u.current&&l({kind:`idle`});return}u.current&&l({kind:`waiting`,loginUrl:n.loginUrl,ready:n.phase===`awaiting-login`})}catch{}})()},ol)},[e,b,g,m,o]),C=async()=>{h(),l({kind:`starting`});try{let t=await Jc(e,r());f.current=t.sessionId,l({kind:`waiting`,loginUrl:t.loginUrl,ready:!1}),S(t.sessionId)}catch(e){g(e instanceof Error?e.message:String(e))}};return c.kind===`idle`||c.kind===`error`?s(`div`,{className:`space-y-2`,children:[c.kind===`error`&&v(pi,{message:c.message}),v(`p`,{className:`text-xs text-foreground-muted`,children:o(`brokers.signIn.intro`)}),s(W,{variant:`primary`,size:`sm`,disabled:i===!0||t.trim().length===0,onClick:()=>void C(),children:[v(hn,{className:`h-3.5 w-3.5`}),` `,c.kind===`error`?o(`common.retry`):o(`brokers.signIn.start`)]})]}):c.kind===`starting`||c.kind===`committing`?s(`div`,{className:`flex items-center gap-2 rounded-lg border border-border bg-surface px-3 py-3 text-xs text-foreground-subtle`,children:[v(H,{className:`h-4 w-4 animate-spin flex-shrink-0`}),c.kind===`starting`?o(`brokers.signIn.starting`):o(`brokers.signIn.saving`)]}):s(`div`,{className:`space-y-2 rounded-lg border border-border bg-surface p-3`,children:[c.ready?s(j,{children:[v(`p`,{className:`text-xs font-semibold text-foreground`,children:o(`brokers.signIn.openLink`)}),v(`p`,{className:`text-[11px] text-foreground-subtle`,children:o(`brokers.signIn.afterLogin`)}),s(W,{variant:`primary`,size:`sm`,onClick:()=>window.open(sl(c.loginUrl),`_blank`,`noopener,noreferrer`),children:[v(P,{className:`h-3.5 w-3.5`}),` `,o(`brokers.signIn.openLoginPage`)]})]}):s(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[v(H,{className:`h-4 w-4 animate-spin flex-shrink-0`}),o(`brokers.signIn.waitingForProxy`)]}),s(`div`,{className:`flex items-center justify-between gap-2 pt-1`,children:[s(`span`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[v(H,{className:`h-3 w-3 animate-spin`}),` `,o(`brokers.signIn.waitingForLogin`)]}),v(W,{variant:`outline`,size:`sm`,onClick:()=>{h(),l({kind:`idle`})},children:o(`brokers.signIn.cancel`)})]})]})}T();var ll=[`device-code`];function ul({methods:e,...t}){let{t:n}=Z(),r=e!==void 0&&e.length>0?e:ll,[i,a]=x(null),o=i!==null&&r.includes(i)?i:r[0]??`device-code`;return s(`div`,{className:`space-y-2`,children:[r.length>1&&v(Yi,{value:o,onValueChange:e=>a(e===`device-code`?e:`proxy`),appearance:`pills`,children:v(bi,{"aria-label":n(`brokers.signIn.method`),children:r.map(e=>v(Ba,{value:e,children:n(e===`device-code`?`brokers.signIn.methodDeviceCode`:`brokers.signIn.methodProxy`)},e))})}),o===`device-code`?v(il,{...t},`device-code`):v(cl,{...t},`proxy`)]})}function dl(e){return{status:e.status===`validated`||e.status===`rejected`||e.status===`inconclusive`||e.status===`unsupported`?e.status:e.success?`validated`:`rejected`,...e.error===void 0?{}:{error:e.error},...e.detail===void 0?{}:{detail:e.detail}}}var fl={validated:`border-success/30 bg-success/5 text-success`,rejected:`border-danger/30 bg-danger/5 text-danger`,inconclusive:`border-warning/30 bg-warning/5 text-warning`,unsupported:`border-border bg-surface text-foreground-subtle`};function pl({verdict:e}){let{t}=Z(),n=(()=>{switch(e.status){case`validated`:return e.detail?`${t(`integrations.connectionSuccess`)} — ${e.detail}`:t(`integrations.connectionSuccess`);case`rejected`:return`${t(`integrations.errorPrefix`)} ${e.error??``}`;case`inconclusive`:return`${t(`integrations.connectionInconclusive`,{defaultValue:`Could not be checked:`})} ${e.error??``}`;case`unsupported`:return e.error??t(`integrations.connectionUntestable`,{defaultValue:`This integration cannot be tested before it is created.`})}})();return v(`div`,{className:`rounded-lg border px-3 py-2 text-xs ${fl[e.status]}`,"data-testid":`connection-test-verdict`,children:n})}var ml=new Set;function hl(e){for(let t of ml)t(e)}function gl(e){return ml.add(e),()=>{ml.delete(e)}}T();var _l=`notification-output`;function vl(e){return e.map(e=>({id:e.id,name:e.name,kind:Lt(e.recordKind),addonId:e.addonId,enabled:e.enabled,config:{...e.formValues}}))}function yl(){let e=ba({functionCap:_l});return{data:f(()=>e.data===void 0?void 0:vl(e.data),[e.data]),isError:e.isError}}var bl=`members`,xl=Bt.options,Sl=[1,2,3,4,5],Cl={title:`Person at the front door`,body:`A person was seen on Front door`,priority:4};function wl(e){return Qt(e)}function Tl(e,t){return{...e,[bl]:t}}function El(e){return e.kind!==rn}function Dl(e,t,n){let r=new Set(t.map(e=>e.targetId)),i=n.trim().toLowerCase();return e.filter(e=>El(e)&&!r.has(e.id)&&(i===``||e.name.toLowerCase().includes(i)||e.kind.toLowerCase().includes(i)))}function Ol(e,t){let n={...e};return delete n[t],n}var kl={kind:`schedule`,schedule:{windows:[{days:[1,2,3,4,5],startMinute:540,endMinute:1080}]}};function Al(e){let t=qt(e,{...Cl,format:`text`});return{title:t.title??``,body:t.body}}function jl(e,t){return e?.find(e=>e.kind===t.kind&&e.addonId===t.addonId)?.label??t.kind}var Ml=on.options;function Nl(e){let t=e.filter?.eventKinds;return new Set(t===void 0?[]:Ml.filter(e=>!t.includes(e)))}function Pl(e,t){return t.eventKinds===void 0&&t.classes===void 0?Ol(e,`filter`):{...e,filter:t}}function Fl(e,t){let{eventKinds:n,...r}=e.filter??{};return Pl(e,t.length===0||t.length===Ml.length?r:{...r,eventKinds:[...t]})}function Il(e){return(e.filter?.classes??[]).join(`, `)}function Ll(e,t){let n=t.split(`,`).map(e=>e.trim()).filter(e=>e!==``),{classes:r,...i}=e.filter??{};return Pl(e,n.length===0?i:{...i,classes:n})}function Rl(e,t){let n=e.findIndex(e=>e.targetId===t);return n<=0?[]:e.slice(0,n)}function zl(e,t){return t===void 0?Ol(e,`onlyIfUndelivered`):{...e,onlyIfUndelivered:[t]}}function Bl(e,t){return e.filter(e=>e.targetId!==t).map(e=>{if(e.onlyIfUndelivered===void 0||!e.onlyIfUndelivered.includes(t))return e;let n=e.onlyIfUndelivered.filter(e=>e!==t);return n.length===0?Ol(e,`onlyIfUndelivered`):{...e,onlyIfUndelivered:n}})}T();var Vl=It.options,Hl=[`always`,`schedule`,`alarm`],Ul=``,Wl=``;function Gl(e){let t=e.fields;return new Set(t===void 0?[]:xl.filter(e=>!t.includes(e)))}function Kl({member:e,name:t,kindLabel:n,known:r,defaultOpen:i,fallbackChoices:a,onChange:o,onRemove:c}){let{t:l}=Z(),[u,d]=x(i),f=e.when??{kind:`always`},p=e.enabled!==!1,m=Al(e),h=e=>l(`notifierGroup.field.${e}`,e),g=t=>{o(t===`always`?Ol(e,`when`):t===`schedule`?{...e,when:kl}:{...e,when:{kind:`alarm`,deviceId:0,states:[`armed_away`]}})},_=(t,n)=>{let r={...e.templates,[t]:n};n===``&&delete r[t],r.title===void 0&&r.body===void 0?o(Ol(e,`templates`)):o({...e,templates:r})};return s(`div`,{className:`rounded-md border border-border bg-surface`,"data-testid":`group-member-${e.targetId}`,children:[s(`div`,{className:`flex items-center gap-2 p-2`,children:[v(pa,{icon:u?mn:oe,variant:`ghost`,size:`sm`,"aria-label":u?l(`notifierGroup.collapse`,`Hide policy`):l(`notifierGroup.expand`,`Show policy`),onClick:()=>d(!u)}),s(`div`,{className:`min-w-0 flex-1`,children:[v(`p`,{className:`truncate text-sm ${r?`text-foreground`:`text-danger`}`,children:r?t:l(`notifierGroup.missingTarget`,`Missing target {{id}}`,{id:t})}),v(`p`,{className:`truncate text-xs text-foreground-muted`,children:n})]}),!p&&v(jn,{variant:`default`,children:l(`notifierGroup.paused`,`paused`)}),v(Wn,{checked:p,"aria-label":l(`notifierGroup.enabled`,`Deliver to this member`),onCheckedChange:t=>o(t?Ol(e,`enabled`):{...e,enabled:!1})}),v(pa,{icon:Et,variant:`ghost`,size:`sm`,"aria-label":l(`notifierGroup.remove`,`Remove {{name}} from the group`,{name:t}),onClick:c})]}),u&&s(`div`,{className:`space-y-3 border-t border-border-subtle p-3`,children:[s(`div`,{className:`space-y-1`,children:[v(Yn,{children:l(`notifierGroup.when`,`Receives`)}),v(Ke,{value:f.kind,onChange:e=>{let t=Hl.find(t=>t===e.target.value);t!==void 0&&g(t)},options:Hl.map(e=>({value:e,label:l(`notifierGroup.when_${e}`,e)}))}),f.kind===`schedule`&&v(Ko,{value:f.schedule,onChange:t=>o(t===void 0?Ol(e,`when`):{...e,when:{kind:`schedule`,schedule:t}}),emptyHint:l(`notifierGroup.scheduleEmpty`,`Always — add a window to restrict when it receives.`)}),f.kind===`alarm`&&s(`div`,{className:`space-y-2`,children:[v(br,{pick:`device`,noun:`device`,fixedTypes:[q.AlarmPanel],recentKey:`notifier-group-alarm`,value:f.deviceId>0?{deviceId:f.deviceId}:null,onChange:t=>o({...e,when:{...f,deviceId:t?.deviceId??0}})}),v(Rn,{chips:Vl.map(e=>({id:e,label:l(`notifierGroup.alarm.${e}`,e)})),off:new Set(Vl.filter(e=>!f.states.includes(e))),allLabel:l(`notifierGroup.allStates`,`Any state`),ariaLabel:l(`notifierGroup.alarmStates`,`Alarm states that deliver`),onChange:t=>{let n=Vl.filter(e=>!t.has(e));n.length>0&&o({...e,when:{...f,states:n}})}})]})]}),(a.length>0||e.onlyIfUndelivered!==void 0)&&s(`div`,{className:`space-y-1`,children:[v(Yn,{children:l(`notifierGroup.fallback`,`Escalation`)}),v(Ke,{value:e.onlyIfUndelivered?.[0]??Wl,"aria-label":l(`notifierGroup.fallback`,`Escalation`),onChange:t=>o(zl(e,t.target.value===Wl?void 0:t.target.value)),options:[{value:Wl,label:l(`notifierGroup.fallbackAlways`,`Always delivered`)},...a.map(e=>({value:e.targetId,label:l(`notifierGroup.fallbackFor`,`Only if {{name}} did not receive it`,{name:e.name})}))]})]}),s(`div`,{className:`space-y-1`,children:[v(Yn,{children:l(`notifierGroup.eventKinds`,`Only these events`)}),v(Rn,{chips:Ml.map(e=>({id:e,label:l(`notifierGroup.eventKind.${e}`,e)})),off:Nl(e),allLabel:l(`notifierGroup.allEvents`,`All events`),ariaLabel:l(`notifierGroup.eventKinds`,`Only these events`),onChange:t=>o(Fl(e,Ml.filter(e=>!t.has(e))))}),v(U,{value:Il(e),placeholder:l(`notifierGroup.classesPlaceholder`,`Any class (e.g. person, car)`),"aria-label":l(`notifierGroup.classes`,`Only these detected classes`),onChange:t=>o(Ll(e,t.target.value))})]}),s(`div`,{className:`space-y-1`,children:[v(Yn,{children:l(`notifierGroup.fields`,`Fields to deliver`)}),v(Rn,{chips:xl.map(e=>({id:e,label:h(e)})),off:Gl(e),allLabel:l(`notifierGroup.allFields`,`All`),ariaLabel:l(`notifierGroup.fields`,`Fields to deliver`),onChange:t=>{let n=xl.filter(e=>!t.has(e));o(n.length===xl.length?Ol(e,`fields`):{...e,fields:n})}})]}),s(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:[s(`div`,{className:`space-y-1`,children:[v(Yn,{children:l(`notifierGroup.titleTemplate`,`Title template`)}),v(U,{value:e.templates?.title??``,placeholder:`{{title}}`,onChange:e=>_(`title`,e.target.value)})]}),s(`div`,{className:`space-y-1`,children:[v(Yn,{children:l(`notifierGroup.bodyTemplate`,`Body template`)}),v(U,{value:e.templates?.body??``,placeholder:`{{body}}`,onChange:e=>_(`body`,e.target.value)})]})]}),v(`p`,{className:`text-xs text-foreground-subtle`,children:l(`notifierGroup.templateHint`,`Use {{title}} and {{body}} for the notification text. Empty keeps the original.`)}),s(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:[s(`div`,{className:`space-y-1`,children:[v(Yn,{children:l(`notifierGroup.minPriority`,`Minimum priority`)}),v(Ke,{value:e.minPriority===void 0?Ul:String(e.minPriority),onChange:t=>{let n=Sl.find(e=>String(e)===t.target.value);o(n===void 0?Ol(e,`minPriority`):{...e,minPriority:n})},options:[{value:Ul,label:l(`notifierGroup.anyPriority`,`Any priority`)},...Sl.map(e=>({value:String(e),label:String(e)}))]})]}),s(`div`,{className:`space-y-1`,children:[v(Yn,{children:l(`notifierGroup.throttle`,`At most one per (seconds)`)}),v(Se,{"aria-label":l(`notifierGroup.throttle`,`At most one per (seconds)`),value:e.throttleSec??0,min:0,onChange:t=>o(t>0?{...e,throttleSec:t}:Ol(e,`throttleSec`))})]})]})]}),s(`div`,{className:`border-t border-border-subtle px-3 py-2 text-xs text-foreground-muted`,"data-testid":`member-preview`,children:[s(`span`,{className:`font-medium text-foreground`,children:[l(`notifierGroup.receives`,`Receives`),`:`,` `]}),m.title===``&&m.body===``?l(`notifierGroup.receivesNothing`,`nothing (every field is off)`):[m.title,m.body].filter(e=>e!==``).join(` — `)]})]})}function ql(){let e=G();return{data:C({queryKey:[`notificationOutput`,`listTargetKinds`],queryFn:()=>e.trpcClient.notificationOutput.listTargetKinds.query({})}).data}}T();var Jl=`notifier/group-members`,Yl=6;function Xl(){return[bl]}function Zl({values:e,onValuesChange:t}){let{t:n}=Z(),r=yl(),i=ql(),[a,o]=x(``),[c,l]=x(new Set),{members:u,invalid:d}=wl(e),f=new Map((r.data??[]).map(e=>[e.id,e])),p=Dl(r.data??[],u,a).slice(0,Yl),m=n=>{t(Tl(e,[...u,{targetId:n.id}])),l(new Set([...c,n.id])),o(``)};return s(`div`,{className:`space-y-2`,"data-testid":`group-members`,children:[s(`p`,{className:`text-xs font-medium text-foreground-muted`,children:[n(`notifierGroup.members`,`Members`),` (`,u.length,`)`]}),d>0&&v(`p`,{className:`text-xs text-danger`,children:n(`notifierGroup.invalidRows`,`{{count}} saved member(s) could not be read and are left out.`,{count:d})}),u.length===0?v(zr,{title:n(`notifierGroup.emptyTitle`,`No members yet`),description:n(`notifierGroup.emptyHint`,`Search a notifier below to add it to this group.`)}):v(`div`,{className:`space-y-2`,children:u.map(n=>{let a=f.get(n.targetId);return v(Kl,{member:n,name:a?.name??n.targetId,kindLabel:a===void 0?``:jl(i.data,a),known:a!==void 0||r.data===void 0,defaultOpen:c.has(n.targetId),fallbackChoices:Rl(u,n.targetId).map(e=>({targetId:e.targetId,name:f.get(e.targetId)?.name??e.targetId})),onChange:r=>t(Tl(e,u.map(e=>e.targetId===n.targetId?r:e))),onRemove:()=>t(Tl(e,Bl(u,n.targetId)))},n.targetId)})}),s(`div`,{className:`space-y-1`,children:[s(`div`,{className:`relative`,children:[v(ft,{className:`pointer-events-none absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-foreground-subtle`}),v(U,{className:`pl-7`,value:a,placeholder:n(`notifierGroup.search`,`Search notifiers to add`),"aria-label":n(`notifierGroup.search`,`Search notifiers to add`),onChange:e=>o(e.target.value)})]}),r.data===void 0?v(zi,{className:`h-8 w-full`}):p.length===0?v(`p`,{className:`text-xs text-foreground-subtle`,children:n(`notifierGroup.noCandidates`,`No other notifier matches. Groups cannot be members.`)}):v(`ul`,{className:`space-y-1`,children:p.map(e=>s(`li`,{className:`flex items-center gap-2 rounded-md border border-border-subtle px-2 py-1`,children:[v(`span`,{className:`min-w-0 flex-1 truncate text-sm text-foreground`,children:e.name}),v(`span`,{className:`text-xs text-foreground-muted`,children:jl(i.data,e)}),s(W,{size:`sm`,variant:`ghost`,onClick:()=>m(e),children:[v(Tt,{className:`h-3.5 w-3.5`}),n(`notifierGroup.add`,`Add`)]})]},e.id))})]})]})}var Ql=new Set([`proc`,`sys`,`dev`,`run`,`boot`,`lost+found`,`snap`,`bin`,`sbin`,`lib`,`lib32`,`lib64`,`libx32`,`usr`,`etc`,`var`,`opt`,`tmp`,`srv`,`root`,`System`,`Library`,`Applications`,`cores`,`private`]),$l=[`recordings`,`data`,`mnt`,`media`,`Volumes`];function eu(e){let t=$l.findIndex(t=>t===`recordings`?e.startsWith(t):e===t);return t===-1?$l.length:t}function tu(e){return e.filter(e=>!e.name.startsWith(`.`)&&!Ql.has(e.name)).toSorted((e,t)=>{let n=eu(e.name)-eu(t.name);return n===0?e.name.localeCompare(t.name):n}).map(e=>e.path)}T();function nu({nodeId:e,value:t,onChange:n}){let{t:r}=Z(),i=G().trpcClient,[a,o]=x([]),[c,l]=x(t),[u,d]=x(null),[f,p]=x(null),[m,h]=x(``),g=_(async(t,r)=>{p(null);try{let a=await i.filesystemBrowse.browse.query({nodeId:e,path:t});d(a),l(a.path),r&&n(a.path)}catch(e){p(e instanceof Error?e.message:`browse failed`)}},[i,e,n]);y(()=>{l(t),(async()=>{let n=await i.filesystemBrowse.browse.query({nodeId:e,path:`/`}).then(e=>e).catch(()=>null);if(n){o(tu(n.entries)),await g(t.startsWith(`/`)?t:`/`,!1);return}try{let n=await i.filesystemBrowse.listAllowedRoots.query({nodeId:e});o(n),await g(t&&n.some(e=>t.startsWith(e))?t:n[0]??``,!1)}catch(e){o([]),d(null),p(e instanceof Error&&/not available on node/i.test(e.message)?`This node can't be browsed remotely. Enter the path manually.`:e instanceof Error?e.message:`browse unavailable`)}})()},[e]);let b=async()=>{if(!(!m.trim()||!u)){p(null);try{let t=`${u.path.replace(/\/+$/,``)}/${m.trim()}`;await i.filesystemBrowse.createDir.mutate({nodeId:e,path:t}),h(``),await g(u.path,!0)}catch(e){p(e instanceof Error?e.message:`create failed`)}}},S=e=>`${(e/1e9).toFixed(1)} GB`;return s(`div`,{className:`space-y-2 rounded border border-border p-2`,children:[v(`div`,{className:`flex flex-wrap gap-1`,children:a.map(e=>v(W,{variant:`unstyled`,onClick:()=>void g(e,!0),className:`rounded border border-border px-2 py-0.5 text-[10px] font-mono hover:border-primary/40`,children:e},e))}),v(U,{value:c,onChange:e=>{l(e.target.value),n(e.target.value)},placeholder:`/absolute/path`,className:`w-full rounded border border-border bg-background px-2 py-1 text-[11px] font-mono`}),u&&v(`div`,{className:`text-[10px] text-foreground-subtle`,children:r(`storage.pathBrowser.free`,{free:S(u.freeBytes),total:S(u.totalBytes)})}),v(`div`,{className:`max-h-40 space-y-0.5 overflow-y-auto`,children:u?.entries.map(e=>s(W,{variant:`unstyled`,onClick:()=>void g(e.path,!0),className:`block w-full truncate rounded px-2 py-1 text-left text-xs hover:bg-primary/5`,children:[`📁 `,e.name]},e.path))}),s(`div`,{className:`flex gap-1`,children:[v(U,{value:m,onChange:e=>h(e.target.value),placeholder:r(`storage.pathBrowser.newFolder`,`new folder`),className:`flex-1 rounded border border-border bg-background px-2 py-1 text-xs`}),v(W,{variant:`unstyled`,onClick:()=>void b(),className:`rounded border border-border px-2 py-1 text-xs hover:border-primary/40`,children:r(`storage.pathBrowser.create`,`Create`)})]}),f&&v(`div`,{className:`text-[10px] text-danger`,children:f})]})}var ru=`storage/path-browser`,iu=`nodeId`,au=`providerId`,ou=`basePath`,su=`hub`;function cu(e,t){let n=e[t];return typeof n==`string`?n:``}function lu(e,t){let n=e.sections.flatMap(e=>e.fields),r=n.find(e=>e.key===iu);if(r===void 0)return null;let i=cu(t,au),a=`showWhen`in r?r.showWhen:void 0;return a!==void 0&&!(i!==``&&a.in?.includes(i))?null:(i===``?[ou]:[`${i}.${ou}`,ou]).find(e=>n.some(t=>t.key===e))??null}function uu(e,t){let n=lu(e,t);return n===null?[]:[n]}function du({schema:e,values:t,onValuesChange:n}){let{t:r}=Z(),i=lu(e,t);if(i===null)return null;let a=cu(t,iu);return s(`div`,{className:`space-y-1`,children:[v(`p`,{className:`text-xs font-medium text-foreground-muted`,children:r(`storage.pathBrowser.label`,`Folder on the node`)}),v(nu,{nodeId:a===``?su:a,value:cu(t,i),onChange:e=>n({...t,[i]:e})})]})}var fu=new Map([[ru,{Component:du,ownedKeys:uu}],[Jl,{Component:Zl,ownedKeys:Xl}]]);function pu(e){return fu.get(e)??null}function mu(e,t){return t.length===0?e:{...e,sections:e.sections.map(e=>({...e,fields:e.fields.filter(e=>!t.includes(e.key))})).filter(e=>e.fields.length>0)}}T();function hu({field:e,values:t,onLabels:n}){let{t:r}=Z(),{query:i,found:a}=wr(e,t);return y(()=>{n(new Map(a.map(e=>[e.value,e.label])))},[a.map(e=>`${e.value}\u0000${e.label}`).join(``),n]),i.isError?v(`p`,{"data-testid":`create-many-labels-failed`,className:`text-xs text-warning`,children:r(`providerInstances.createManyLabelsFailed`,`The names of the choices could not be read ({{message}}); each is named after its value.`,{message:i.error?.message??``})}):null}function gu(e){for(let t of e?.sections??[])for(let e of t.fields)if(e.type===`select`&&e.discoverOptions?.pickManyOnCreate===!0)return e;return null}function _u(e,t){return e.type!==`select`||e.key!==t||e.discoverOptions===void 0?e:{...e,discoverOptions:{...e.discoverOptions,multiple:!0}}}function vu(e,t){return{...e,sections:e.sections.map(e=>({...e,fields:e.fields.map(e=>_u(e,t))}))}}function yu(e){let{key:t,picked:n,labels:r,typedName:i,values:a}=e;return n.map(e=>({name:n.length===1&&i.length>0?i:r.get(e)??e,values:{...a,[t]:e}}))}function bu(e,t){let n=[];for(let r of e.links??[]){let e=t[r.field],i=Array.isArray(e)?e:[e];for(let e of i)typeof e!=`string`||e===``||n.some(t=>t.field===r.field&&t.instanceId===e)||n.push({field:r.field,cap:r.to.cap,...r.to.kind===void 0?{}:{kind:r.to.kind},instanceId:e})}return n}function xu(e,t){return e.find(e=>e.id===t.instanceId&&(t.kind===void 0||e.kind===t.kind))}function Su(e){let t=new Map(e.holders.map(e=>[e.addonId,e])),n=[];for(let r of e.functionProviders){let i=e.displayNames.get(r.addonId)??r.addonId,a=t.get(r.addonId);if(a===void 0){n.push({kind:`fixed`,key:`fixed:${r.addonId}`,addonId:r.addonId,providerName:i,name:i,description:e.descriptions.get(r.addonId)??``,isActive:r.isActive});continue}let o=e.notRunning?.get(r.addonId);for(let e of a.instances){let t=ku(a.description,e.kind),s=bu(a.description,e.formValues);n.push({kind:`instance`,key:`${r.addonId}:${e.id}`,addonId:r.addonId,providerName:i,id:e.id,name:e.name,configured:e.configured,enabled:e.enabled??!0,status:e.status,canTest:t?.canTest??a.description.canTest,...e.kind===void 0?{}:{kindId:e.kind},...e.kind===void 0?{}:{kindLabel:t?.label??e.kind},...t?.iconUrl===void 0?{}:{kindIconUrl:t.iconUrl},...e.lastCheckedAt===void 0?{}:{lastCheckedAt:e.lastCheckedAt},...t?.connectPath===void 0?{}:{connectPath:t.connectPath},...t?.disconnectPath===void 0?{}:{disconnectPath:t.disconnectPath},...o===void 0?{}:{notRunning:o},...s.length>0?{links:s}:{}})}}return n}var Cu=new Set([`running`,`unknown`]);function wu(e){return e!==void 0&&!Cu.has(e)}function Tu(e,t){return typeof e==`object`&&e?Reflect.get(e,t):void 0}function Eu(e){let t=new Map;for(let n of e){let e=Tu(Tu(n,`manifest`),`id`),r=Tu(Tu(n,`process`),`state`);typeof e!=`string`||typeof r!=`string`||wu(r)&&t.set(e,r)}return t}function Du(e){let t=new Map;for(let n of e){let e=Tu(n,`manifest`),r=Tu(e,`id`);if(typeof r!=`string`||r.length===0)continue;let i=Tu(e,`name`),a=Tu(e,`packageDisplayName`);t.set(r,typeof i==`string`?i:typeof a==`string`?a:r)}return t}function Ou(e){let t=new Map;for(let n of e){let e=Tu(n,`manifest`),r=Tu(e,`id`),i=Tu(e,`description`);typeof r!=`string`||typeof i!=`string`||i.length>0&&t.set(r,i)}return t}function ku(e,t){return t===void 0?void 0:e.kinds?.find(e=>e.id===t)}function Au(e,t,n){let r=e.kinds;if(r===void 0||r.length===0)return e;let i=r.filter(e=>n===void 0?e.functionCap===t:e.id===n&&zt(e,t));return i.length===0?null:{...e,kinds:i}}function ju(e,t){let n=Au(e.description,t);if(n===null)return null;let r=n.kinds;if(e.description.kinds===void 0||r===void 0)return e;let i=new Set(r.map(e=>e.id));return{...e,description:n,instances:e.instances.filter(e=>e.kind===void 0||i.has(e.kind))}}function Mu(e){return(e.kinds?.length??0)>1}function Nu(e,t,n){return Mu(e)&&t!==void 0?t.label:n}function Pu(e){return e.label!==void 0&&e.label.length>0?e.label:e.state}function Fu(e){let t=new Set,n=[];for(let r of e)t.has(r.addonId)||(t.add(r.addonId),n.push({addonId:r.addonId,name:r.providerName}));return n}var Iu={error:3,unknown:2,ok:1,off:0};function Lu(e){return e.enabled?e.status===void 0?e.configured?`ok`:`unknown`:e.status.state:`off`}function Ru(e){let t=null;for(let n of e){let e=Lu(n);(t===null||Iu[e]>Iu[t])&&(t=e)}return t??`unknown`}function zu(e,t,n){return e.map(e=>{let r=n.get(e.addonId)??e.addonId,i=t.filter(t=>t.addonId===e.addonId),a=i.filter(e=>e.kind===`instance`),o=i.find(e=>e.kind===`fixed`);return o===void 0?{addonId:e.addonId,name:r,count:a.length,health:Ru(a)}:{addonId:e.addonId,name:r,count:1,health:o.isActive?`ok`:`off`}})}function Bu(e,t){return t===null?e:e.filter(e=>e.addonId===t)}function Vu(e){return e.filter(e=>e.description.instanceMode===`multiple`||e.instances.length===0)}function Hu(e,t){return e.flatMap(e=>{let n=t(e.addonId),r=e.description.kinds??[];return r.length===0?[{addonId:e.addonId,label:n,providerName:n}]:r.filter(e=>e.creatable!==!1).map(t=>({addonId:e.addonId,kind:t.id,label:t.label,providerName:n,...t.iconUrl===void 0?{}:{iconUrl:t.iconUrl}}))})}function Uu(e){return e.some(e=>e.isError)?`error`:e.some(e=>e.isPending)?`pending`:`ready`}function Wu(e,t){if(Object.is(e,t))return!0;if(typeof e!=`object`||typeof t!=`object`||e===null||t===null||Array.isArray(e)!==Array.isArray(t))return!1;let n=e,r=t,i=new Set([...Object.keys(n),...Object.keys(r)]);for(let e of i)if(!Wu(n[e],r[e]))return!1;return!0}var Gu=`enabled`;function Ku(e,t){return t?.sections.some(e=>e.fields.some(e=>e.key===Gu))===!0?{...e}:Object.fromEntries(Object.entries(e).filter(([e])=>e!==Gu))}function qu(e,t){let n={};for(let[r,i]of Object.entries(t))i!==void 0&&(Wu(e[r],i)||(n[r]=i));return n}function Ju(e,t){let n={...e};for(let[e,r]of Object.entries(t))r!==void 0&&(n[e]=r);return n}function Yu(e,t){return e.mintsId===!0?!1:(t?.role??e.role)!==`devices`}function Xu(e,t,n){return e===`single`?t:`inst-${n()}`}function Zu(){let e=crypto.getRandomValues(new Uint8Array(4));return Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``)}var Qu=`+`;function $u(e,t,n){return t===void 0?e:t===null?`${e}:${Qu}${n??``}`:`${e}:${t}`}function ed(e){let t=e.indexOf(`:`);if(t<0)return{kind:`fixed`,addonId:e};let n=e.slice(0,t),r=e.slice(t+1);if(!r.startsWith(Qu))return{kind:`instance`,addonId:n,id:r};let i=r.slice(1);return i===``?{kind:`create`,addonId:n}:{kind:`create`,addonId:n,kindId:i}}var td=`sendWith`,nd=`smtpInstanceId`;function rd(e,t){return e.filter(e=>e.formValues[td]===t||e.formValues[nd]===t).map(e=>e.name)}var id=/^[a-z0-9][a-z0-9-]{0,63}$/;function ad(e,t){return t===``?`empty`:e.pattern.test(t)?`ok`:`invalid`}T();var od=5e3,sd=`integration-instances`,cd=`provider-instances-holder`;function ld(e){let t=G(),n=vr({capName:e},{refetchInterval:od}),r=vr({capName:sd},{refetchInterval:od}),i=tr(void 0,{refetchInterval:od}),a=f(()=>(n.data??[]).map(e=>({addonId:e.addonId,isActive:e.isActive})),[n.data]),o=E({queries:f(()=>{let e=new Set((r.data??[]).map(e=>e.addonId));return a.map(e=>e.addonId).filter(t=>e.has(t))},[a,r.data]).map(e=>({queryKey:[cd,e],refetchInterval:od,queryFn:async()=>{let n=t.trpcClient.integrationInstances,[r,i]=await Promise.all([n.describe.query({addonId:e}),n.listInstances.query({addonId:e})]);return{addonId:e,description:r,instances:i}}}))}),s=Uu([n,r,...o]),c=f(()=>o.flatMap(t=>{let n=t.data===void 0?null:ju(t.data,e);return n===null?[]:[n]}),[o,e]),l=f(()=>Du(i.data??[]),[i.data]),u=f(()=>Ou(i.data??[]),[i.data]),d=f(()=>Eu(i.data??[]),[i.data]),p=f(()=>Su({functionProviders:a,holders:c,displayNames:l,descriptions:u,notRunning:d}),[a,c,l,u,d]),m=n.error??r.error??o.find(e=>e.error)?.error??null,h=_(()=>{n.refetch(),r.refetch();for(let e of o)e.refetch()},[n,r,o]);return{state:s,error:m===null?null:m.message,functionProviders:a,rows:p,holders:c,displayNames:l,descriptions:u,refetch:h}}T();var ud=D(null);function dd(){let e=M(ud);if(e===null)throw Error(`A dialog lead must be rendered inside InstanceEditorDialog`);return e}T();var fd=`name`,pd=`kind`,md=`restore`,hd=`restoreId`,gd=`typedId`,_d={};function vd(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function yd(e,t){let n=vd(e)?e:{};return t===null?{...n}:{...n,integrationId:t}}function bd({addonId:e,providerName:t,description:n,instance:r,onClose:i,onSaved:a,lead:o,typedId:c,testLabel:l,testHint:u}){let{t:p}=Z(),m=G(),h=O(),g=r?.id??null,b=async(t,n,r)=>{let i=await m.trpcClient.addons.custom.mutate({addonId:e,action:t,input:yd(r,g)});return g!==null&&h.invalidateQueries({queryKey:[cd]}),i},S=n.kinds??[],w=Nu(n,ku(n,r?.kind??S[0]?.id),t),[T,E]=x({[fd]:r?.name??w,[pd]:r?.kind??S[0]?.id??``,[md]:!1,[hd]:``,[gd]:``}),D=d(w),A=T[pd];y(()=>{if(r!==null||typeof A!=`string`)return;let e=Nu(n,ku(n,A),t),i=D.current;D.current=e,E(t=>t[fd]===i?{...t,[fd]:e}:t)},[A,n,r,t]);let M=e=>{let t=T[e];return typeof t==`string`?t.trim():``},N=M(fd),P=M(pd),F=ku(n,P===``?void 0:P),ee=T[md]===!0,te=M(hd),ne=r===null&&n.allowRestoreId===!0&&F?.signIn===void 0,re=ne&&ee&&te===``,ie=r===null&&F?.signIn===void 0&&!(ne&&ee)?c?.(P===``?void 0:P):void 0,ae=M(gd),oe=ie===void 0?`ok`:ad(ie,ae),[se,ce]=x({...r?.formValues??_d}),[I,le]=x(null),ue=f(()=>({sections:[{id:`instance-identity`,title:p(`providerInstances.identity`,`Identity`),columns:1,fields:[...r===null&&Mu(n)?[{type:`select`,key:pd,label:p(`providerInstances.colKind`,`Kind`),options:S.map(e=>({value:e.id,label:e.label}))}]:[],{type:`text`,key:fd,label:p(`providerInstances.colName`,`Name`),required:!0},...ie===void 0?[]:[{type:`text`,key:gd,label:p(`providerInstances.typedId`,`Id`),required:!0,description:oe===`invalid`?p(`providerInstances.typedIdInvalid`,`Lowercase letters, digits and dashes, starting with a letter or digit (up to 64).`):p(`providerInstances.typedIdHint`,`Chosen once; it cannot be changed after the record is created.`)}],...ne?[{type:`boolean`,key:md,label:p(`providerInstances.restore`,`Restore under its old id`),description:p(`providerInstances.restoreHint`,`Re-adding something that was removed under its original id keeps everything that points at it working.`)},{type:`text`,key:hd,label:p(`providerInstances.originalId`,`Original id`),required:!0,showWhen:{field:md,equals:!0}}]:[]]}]}),[ne,n,ie,r,S,p,oe]),[de,fe]=x(null),pe=g===null&&P!==``?P:void 0,L=C({queryKey:[`provider-instance-form`,e,g,pe??null],queryFn:()=>m.trpcClient.integrationInstances.instanceFormSchema.query({addonId:e,id:g,...pe===void 0?{}:{kind:pe}})}),R=f(()=>r===null?_d:Ku(r.formValues,L.data),[r,L.data]),z=f(()=>Ku(se,L.data),[se,L.data]),me=r===null?gu(L.data):null,B=me?.key,he=f(()=>L.data&&B!==void 0?vu(L.data,B):L.data,[L.data,B]),ge=me===null?[]:ar(se[me.key]),_e=ge.length>1,[ve,ye]=x(()=>new Map),be=_(e=>{ye(e)},[]),xe=f(()=>he?Ut(he,{...R}):null,[he,R]),Se=L.isSuccess&&!L.data,Ce=(F?.widgets??[]).flatMap(e=>{let t=e.placement===`connection`?pu(e.id):null;return t===null?[]:[{id:e.id,widget:t}]}),we=xe===null?[]:Ce.flatMap(({widget:e})=>e.ownedKeys(xe,se)),[Te,Ee]=x({}),De=_(e=>{Ee(t=>({...t,...e}))},[]),Oe=d(z);y(()=>{let e=Oe.current;Oe.current=z,Ee(t=>{let n=Object.entries(t).filter(([t])=>JSON.stringify(e[t])===JSON.stringify(z[t]));return n.length===Object.keys(t).length?t:Object.fromEntries(n)})},[z]);let ke=f(()=>({values:{...Ju(R,z),...Te},patch:De}),[R,z,Te,De]),Ae=k({mutationFn:async()=>{let t=m.trpcClient.integrationInstances,i={...qu(R,z),...Te},a=me!==null&&ge.length===1?{...i,[me.key]:ge[0]}:i;if(r===null&&me!==null&&_e){let r=yu({key:me.key,picked:ge,labels:ve,typedName:N,values:a}),i=``;for(let[a,o]of r.entries())try{i=(await t.createInstance.mutate({addonId:e,name:o.name,...Yu(n,F)?{id:Xu(n.instanceMode,e,Zu)}:{},...P===``?{}:{kind:P},...Object.keys(o.values).length>0?{values:o.values}:{}})).id}catch(e){throw h.invalidateQueries({queryKey:[cd]}),Error(p(`providerInstances.createManyStopped`,`{{done}} of {{total}} created: {{message}}`,{done:a,total:r.length,message:e instanceof Error?e.message:String(e)}))}return i}if(r===null){let r=ne&&ee?te:ie===void 0?Yu(n,F)?Xu(n.instanceMode,e,Zu):void 0:ae;return(await t.createInstance.mutate({addonId:e,name:N,...r===void 0?{}:{id:r},...P===``?{}:{kind:P},...Object.keys(a).length>0?{values:a}:{}})).id}return await t.updateInstance.mutate({addonId:e,id:r.id,name:N,values:a}),r.id},onSuccess:e=>{h.invalidateQueries({queryKey:[cd]}),hl({title:p(`providerInstances.saved`,`Saved`),message:_e?String(ge.length):N,severity:`info`}),a?.(e),i()},onError:e=>le(e.message)}),je=k({mutationFn:()=>m.trpcClient.integrationInstances.testInstance.mutate({addonId:e,id:g,values:qu(R,z),...g===null&&F!==void 0?{kind:F.id}:{}}),onSuccess:e=>fe(dl(e)),onError:e=>fe({status:`inconclusive`,error:e.message})});return v(Vi,{open:!0,onClose:i,title:r===null?p(`providerInstances.createTitle`,`Add {{provider}}`,{provider:Nu(n,F,t)}):p(`providerInstances.editTitle`,`Edit {{name}}`,{name:r.name}),error:I??(L.isError?L.error.message:null),width:`lg`,footer:s(j,{children:[(F?.canTest??n.canTest)&&s(W,{size:`sm`,variant:`outline`,type:`button`,disabled:je.isPending||xe===null&&!Se,onClick:()=>{fe(null),je.mutate()},children:[je.isPending?v(H,{className:`h-3.5 w-3.5 animate-spin`}):null,l??p(`providerInstances.test`,`Test connection`)]}),s(W,{size:`sm`,type:`button`,disabled:Ae.isPending||xe===null&&!Se||N.length===0&&!_e||!_e&&(re||oe!==`ok`),onClick:()=>{le(null),Ae.mutate()},children:[Ae.isPending?v(H,{className:`h-3.5 w-3.5 animate-spin`}):null,r===null&&_e?p(`providerInstances.createMany`,`Create {{count}}`,{count:ge.length}):r===null?p(`providerInstances.create`,`Create`):p(`providerInstances.saveChanges`,`Save changes`)]})]}),children:s(`div`,{className:`space-y-4`,children:[r===null?null:v(ud.Provider,{value:ke,children:o}),v(qo,{schema:_e?mu(ue,[fd,gd,md,hd]):ue,values:T,onChange:E}),me!==null&&_e&&v(hu,{field:me,values:se,onLabels:be}),F?.signIn!==void 0&&v(ul,{basePath:F.signIn.basePath,...F.signIn.methods===void 0?{}:{methods:F.signIn.methods},name:N,...r===null?{}:{brokerId:r.id},getSettings:()=>Ju(R,z),disabled:N.length===0,onSignedIn:e=>{h.invalidateQueries({queryKey:[`provider-instances-holder`]}),a?.(e),i()}}),r!==null&&F?.connectPath!==void 0&&s(W,{size:`sm`,variant:`outline`,type:`button`,onClick:()=>Wo(Uo(F.connectPath??``,r.id),()=>void h.invalidateQueries({queryKey:[`provider-instances-holder`]})),children:[v(lt,{className:`h-3.5 w-3.5`}),p(`providerInstances.connect`,`Connect account`)]}),xe===null?L.isError?null:Se?v(`p`,{className:`text-xs text-foreground-muted`,children:p(`providerInstances.noForm`,`This record has no configuration form beyond its name.`)}):s(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[v(H,{className:`h-3 w-3 animate-spin`}),p(`providerInstances.loading`,`Loading…`)]}):s(j,{children:[v(lr,{schema:mu(xe,we),values:se,onChange:ce,onAction:b}),Ce.map(({id:e,widget:{Component:t}})=>v(t,{schema:xe,values:se,onValuesChange:ce},e))]}),u!==void 0&&(F?.canTest??n.canTest)&&v(`p`,{className:`text-xs text-foreground-subtle`,children:u}),de!==null&&v(pl,{verdict:de})]})})}T();var xd=`integration-instances`,Sd=`instance-kinds-describe`;function Cd(e,t){let n=[];for(let r of e)if(!(t.addonId!==void 0&&r.addonId!==t.addonId))for(let e of r.description.kinds??[]){if(!(t.match===`link`?zt(e,t.functionCap):e.functionCap===t.functionCap))continue;let i=e.brokerKind??e.id;t.kind!==void 0&&i!==t.kind&&e.id!==t.kind||n.push({addonId:r.addonId,kind:e.id,brokerKind:i,label:e.label,...e.connectPath===void 0?{}:{connectPath:e.connectPath},...e.disconnectPath===void 0?{}:{disconnectPath:e.disconnectPath},...e.signIn===void 0?{}:{signInBasePath:e.signIn.basePath},...e.iconUrl===void 0?{}:{iconUrl:e.iconUrl},canTest:e.canTest??r.description.canTest===!0})}return n}function wd(e){let t=G(),n=vr({capName:e.functionCap}),r=vr({capName:xd}),i=E({queries:f(()=>{let e=new Set((r.data??[]).map(e=>e.addonId));return(n.data??[]).map(e=>e.addonId).filter(t=>e.has(t))},[n.data,r.data]).map(e=>({queryKey:[Sd,e],queryFn:async()=>({addonId:e,description:await t.trpcClient.integrationInstances.describe.query({addonId:e})})}))}),a=f(()=>i.flatMap(e=>e.data===void 0?[]:[e.data]),[i]);return{options:f(()=>Cd(a,e),[a,e.functionCap,e.addonId,e.kind,e.match]),holders:a,isLoading:n.isLoading===!0||r.isLoading===!0||i.some(e=>e.isLoading)}}function Td({children:e,onClose:t}){return v(Nn,{open:!0,onOpenChange:e=>!e&&t(),children:s(Na,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[v($i,{children:v(Ti,{children:`\xA0`})}),v(Li,{children:e})]})})}function Ed({functionCap:e,kind:t,addonId:n,onClose:r,onSaved:i,typedId:a,match:o}){let{t:s}=Z(),c=G(),l=O(),u=wd({functionCap:e,...n===void 0?{}:{addonId:n},...t===void 0?{}:{kind:t},...o===void 0?{}:{match:o}}),d=u.options[0],f=n??d?.addonId,p=C({queryKey:[`instance-create-description`,f,e,d?.kind??null],enabled:f!==void 0,queryFn:async()=>Au(await c.trpcClient.integrationInstances.describe.query({addonId:f??``}),e,d?.kind)});return f===void 0||p.data===null?v(Td,{onClose:r,children:f===void 0&&u.isLoading?v(H,{className:`h-4 w-4 animate-spin`}):v(pi,{message:s(`brokers.editor.noProvider`)})}):p.isError?v(Td,{onClose:r,children:v(pi,{message:p.error.message})}):p.data===void 0?v(Td,{onClose:r,children:v(H,{className:`h-4 w-4 animate-spin`})}):v(bd,{addonId:f,providerName:d?.label??``,description:p.data,instance:null,onClose:r,...a===void 0?{}:{typedId:a},onSaved:e=>{l.invalidateQueries(),i(e)}})}T();var Dd={ok:`success`,off:`default`,unknown:`default`,error:`danger`};function Od({kind:e,value:t,onChange:n,optional:r=!1,noneLabel:i,disabled:a=!1}){let{t:o}=Z(),[c,l]=x(!1),u=Qi({kind:e}),d=wa(u.data??[],t),f=d[0]?.id??null,p=!u.isLoading&&!u.isError&&u.data!==void 0;return y(()=>{!r&&!a&&p&&t===null&&f!==null&&n(f)},[r,a,p,t,f,n]),s(`div`,{className:`space-y-2`,children:[u.isLoading&&s(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[v(H,{className:`h-3.5 w-3.5 animate-spin`}),` `,o(`brokers.picker.loading`)]}),u.isError&&v(pi,{message:o(`brokers.picker.loadFailed`,{message:u.error?.message??o(`common.unknownError`)})}),!u.isLoading&&!u.isError&&d.length===0&&v(`p`,{className:`rounded-lg border border-border bg-surface px-3 py-4 text-center text-xs text-foreground-subtle`,children:o(`brokers.picker.none`)}),r&&v(`button`,{type:`button`,"aria-pressed":t===null,disabled:a,onClick:()=>n(null),className:`flex w-full items-center rounded-lg border bg-surface p-3 text-left text-xs text-foreground-subtle transition-colors ${t===null?`border-primary ring-1 ring-primary`:`border-border hover:border-foreground-subtle/30`}`,children:i??o(`brokers.picker.noneChoice`)}),d.map(e=>s(`button`,{type:`button`,"aria-pressed":t===e.id,disabled:a,onClick:()=>n(e.id),className:`flex w-full items-center justify-between gap-3 rounded-lg border bg-surface p-3 text-left transition-colors ${t===e.id?`border-primary ring-1 ring-primary`:`border-border hover:border-foreground-subtle/30`}`,children:[v(`span`,{className:`text-xs font-semibold text-foreground`,children:e.name}),v(jn,{variant:Dd[e.state],className:`text-[10px]`,children:e.stateLabel??e.state})]},e.id)),s(W,{variant:`outline`,size:`sm`,disabled:a,onClick:()=>l(!0),children:[v(Tt,{className:`h-3.5 w-3.5`}),` `,o(`brokers.picker.createNew`)]}),c&&v(Ed,{functionCap:`broker`,kind:e,onClose:()=>l(!1),onSaved:e=>{l(!1),n(e)}})]})}var kd=Nt;function Ad(e,t){let n=t[0];if(n===void 0)return null;let r=t.find(t=>t.id===e);return r===void 0?n.id:r.id}function jd(e,t){return Pt(e,t)}function Md(e){return e?.id?jd(e.addonId,e.id):`/integrations`}T();function Nd(e=!0){y(()=>{if(!e)return;let t=document.body.style.overflow;return document.body.style.overflow=`hidden`,()=>{document.body.style.overflow=t}},[e])}T();function Pd(e,t){let[n,r]=x(!1);return y(()=>{if(!e){r(!1);return}r(!1);let n=setTimeout(()=>r(!0),t);return()=>clearTimeout(n)},[e,t]),n}T();function Fd({kind:e,onResolved:t,onBack:n}){let{t:r}=Z(),[i,a]=x(null);return s(`div`,{className:`space-y-4`,children:[s(W,{variant:`ghost`,size:`sm`,onClick:n,children:[v(re,{className:`h-3.5 w-3.5`}),` `,r(`common.back`)]}),v(Od,{kind:e,value:i,onChange:a}),v(`div`,{className:`flex justify-end pt-1`,children:v(W,{variant:`primary`,size:`sm`,disabled:i===null,onClick:()=>i!==null&&t(i),children:r(`integrations.brokerStep.useThisBroker`,`Use this broker`)})})]})}T();function Id({providerId:e,onImport:t,onSkip:n}){let{t:r}=Z(),[i,a]=x(new Set),o=za(),c=o.data,l=o.isPending||!o.data&&!o.isError;y(()=>{e&&(o.isPending||o.data||o.mutate({addonId:e}))},[e,o]);function u(e){a(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}if(l)return s(`div`,{className:`flex flex-col items-center py-12`,children:[v(`div`,{className:`h-6 w-6 animate-spin rounded-full border-2 border-primary border-t-transparent`}),v(`p`,{className:`mt-3 text-xs text-foreground-subtle`,children:r(`integrations.searchingDevices`)})]});let d=c??[];return s(`div`,{className:`space-y-4`,children:[v(`p`,{className:`text-xs text-foreground-subtle`,children:d.length>0?r(`integrations.foundDevices`,{count:d.length}):r(`integrations.noDevicesFound`)}),d.length>0&&v(`div`,{className:`space-y-1.5 max-h-64 overflow-y-auto`,children:d.map(e=>{let t=e.stableId,n=e.suggestedName??t,a=i.has(t),o=e.alreadyOnboarded===!0;return s(W,{variant:`unstyled`,onClick:()=>{o||u(t)},disabled:o,title:o?r(`integrations.alreadyAddedHint`,{defaultValue:`Already added as "{{name}}" — re-adding would overwrite its settings.`,name:e.onboardedName??n}):void 0,className:`flex w-full items-center gap-3 rounded-lg border p-3 text-left transition-colors ${o?`border-border bg-surface opacity-60 cursor-not-allowed`:a?`border-primary/40 bg-primary/5`:`border-border bg-surface hover:border-foreground-subtle/30`}`,children:[v(`div`,{className:`flex h-5 w-5 items-center justify-center rounded border flex-shrink-0 ${a&&!o?`border-primary bg-primary`:`border-border`}`,children:a&&!o&&v(_e,{className:`h-3 w-3 text-primary-foreground`})}),v(xe,{className:`h-3.5 w-3.5 text-foreground-subtle flex-shrink-0`}),v(`span`,{className:`text-xs font-medium text-foreground truncate`,children:n}),o&&v(`span`,{className:`ml-auto flex-shrink-0 rounded bg-surface-muted px-1.5 py-0.5 text-[10px] font-medium text-foreground-subtle`,children:r(`integrations.alreadyAdded`,{defaultValue:`Already added`})})]},t)})}),s(`div`,{className:`flex items-center justify-between pt-2`,children:[v(W,{variant:`unstyled`,onClick:n,className:`rounded-lg border border-border px-3 py-1.5 text-xs text-foreground-subtle hover:text-foreground transition-colors`,children:r(`integrations.skip`)}),d.length>0&&s(W,{variant:`unstyled`,onClick:()=>t(Array.from(i)),disabled:i.size===0,className:`rounded-lg bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground shadow-sm disabled:opacity-50`,children:[r(`integrations.importSelected`),` (`,i.size,`)`]})]})]})}T();function Ld({addonId:e,configSchema:t,canTest:n=!0,instanceKind:r,initialName:i,initialConfig:a,submitLabel:o,hideName:c=!1,saving:l=!1,onScan:u,onSave:d,onBack:f}){let{t:p}=Z(),[m,h]=x(i??``),[g,_]=x(a??{}),[y,b]=x(null),S=ur({onSuccess:e=>b(dl(e)),onError:e=>b({status:`inconclusive`,error:String(e)})}),C=Jn(),w=!n||y?.status===`validated`,T=!c&&m.trim().length===0,E=!T&&w;return s(`div`,{className:`space-y-4`,children:[!c&&s(`div`,{children:[v(`label`,{htmlFor:`integration-name`,className:`block text-[11px] font-medium text-foreground mb-1`,children:p(`integrations.integrationName`)}),v(U,{id:`integration-name`,type:`text`,value:m,onChange:e=>h(e.target.value),placeholder:p(`integrations.integrationNamePlaceholder`),"aria-invalid":T,"aria-describedby":T?`integration-name-error`:void 0,className:`w-full rounded-lg border bg-surface px-3 py-2 text-xs text-foreground placeholder:text-foreground-subtle focus:outline-none ${T?`border-danger focus:border-danger`:`border-border focus:border-primary/50`}`}),T&&v(`p`,{id:`integration-name-error`,"data-testid":`integration-name-error`,className:`mt-1 text-xs text-danger`,children:p(`integrations.nameRequired`,`Name is required`)})]}),t&&v(qo,{schema:t,values:g,onChange:e=>{_(e),b(null)},onAction:async(i,a,o)=>{let s=await C.mutateAsync({addonId:e,action:i,input:o??{}});if(n&&typeof s==`object`&&s){let n=s;if(!(typeof n.token==`string`||typeof n.sslCertificate==`string`||typeof n.host==`string`))return s;let i={...g};for(let[e,t]of Object.entries(n))typeof t==`string`&&e!==`summary`&&(i[e]=t);let a=Ft(t,i);_(a),b(null),S.mutate({addonId:e,id:null,values:a,...r===void 0?{}:{kind:r}})}return s}}),y&&v(pl,{verdict:y}),s(`div`,{className:`flex items-center justify-between pt-2`,children:[v(W,{variant:`unstyled`,onClick:f,className:`rounded-lg border border-border px-3 py-1.5 text-xs text-foreground-subtle hover:text-foreground transition-colors`,children:p(`integrations.back`)}),s(`div`,{className:`flex items-center gap-2`,children:[u&&s(W,{variant:`outline`,size:`sm`,onClick:u,"data-testid":`integration-scan`,children:[v(St,{className:`h-3.5 w-3.5`}),p(`integrations.scanFromForm`,`Scan the network`)]}),n&&v(W,{variant:`unstyled`,onClick:()=>S.mutate({addonId:e,id:null,values:Ft(t,g),...r===void 0?{}:{kind:r}}),disabled:S.isPending,className:`rounded-lg border border-border px-3 py-1.5 text-xs text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50 disabled:cursor-not-allowed`,children:S.isPending?p(`integrations.testing`):p(`integrations.testConnection`)}),s(`div`,{className:`flex flex-col items-end gap-1`,children:[T&&v(`p`,{"data-testid":`integration-name-submit-error`,className:`text-xs text-danger`,children:p(`integrations.nameRequiredSubmit`,`Enter a name before continuing.`)}),v(W,{variant:`unstyled`,onClick:()=>{T||d({name:m,config:Ft(t,g)})},disabled:!E||l,className:`rounded-lg bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground shadow-sm disabled:opacity-50`,children:l?p(`integrations.saving`,{defaultValue:`Saving…`}):o??p(`integrations.forward`)})]})]})]})]})}var Rd=new Set([`@dominevo/server`,`@dominevo/types`,`@dominevo/sdk`,`@dominevo/shm-ring`,`@dominevo/ui-library`]);function zd(e){return e!==void 0&&Rd.has(e)}var Bd=`@dominevo/addon-agent-ui`;function Vd(e){return zd(e)||e===Bd}function Hd(e){return e.integrationSection===void 0?zd(e.packageName)?`system`:`providers`:e.integrationSection}function Ud(e){let t=new Set;for(let n of e??[])Hd(n.manifest)===`system`&&t.add(n.manifest.id);return t}function Wd(e,t){return{providers:e.filter(e=>!t.has(e.addonId)),system:e.filter(e=>t.has(e.addonId))}}function Gd(e,t){return[...e].sort((e,n)=>e.name.localeCompare(n.name,t,{sensitivity:`base`}))}var Kd=/\.(svg|png|jpe?g|webp)$/i,qd=`provider-`;function Jd(e){return typeof e==`string`&&Kd.test(e)&&!e.includes(`..`)}function Yd(e){let t=[];for(let n of e??[]){let e=n,r=e?.manifest?.id;if(typeof r!=`string`||r.length===0)continue;let i=e?.declaration?.icon??e?.manifest?.icon;Jd(i)&&t.push([r,i])}return new Map(t)}function Xd(e,t){if(!t)return null;let n=t.startsWith(qd)?[t]:[t,`${qd}${t}`];for(let t of n){let n=e.get(t);if(n)return V(`/api/addon-assets/${encodeURIComponent(t)}/${n}`)}return null}T();var Zd=5*6e4,Qd=D(new Map);function $d({children:e}){let{data:t}=tr(void 0,{staleTime:Zd}),n=f(()=>Yd(t),[t]);return v(Qd.Provider,{value:n,children:e})}function ef(e){return Xd(M(Qd),e)}T();var tf={amcrest:{icon:bn,color:`#3b82f6`,label:`Amcrest`},hikvision:{icon:rt,color:`#a855f7`,label:`Hikvision`},reolink:{icon:$e,color:`#06b6d4`,label:`Reolink`},homeassistant:{icon:xt,color:`#22d3ee`,label:`Home Assistant`},rtsp:{icon:Re,color:`#78716c`,label:`RTSP`},onvif:{icon:Re,color:`#78716c`,label:`ONVIF`}},nf={sm:`h-4 w-4`,md:`h-5 w-5`,lg:`h-6 w-6`,xl:`h-16 w-16`},rf={sm:`h-7 w-7`,md:`h-8 w-8`,lg:`h-10 w-10`,xl:`h-16 w-16`};function af(e){let t=e.toLowerCase();return t.startsWith(`provider-`)?t.slice(9):t}function of(e){return tf[af(e)]??{icon:bn,color:`#78716c`,label:e}}function sf({type:e,size:t=`md`,showLabel:n,iconUrl:r}){let i=of(e),a=i.icon,[o,c]=x(new Set),l=[r,ef(e)].find(e=>typeof e==`string`&&e!==``&&!o.has(e));return s(`div`,{className:`flex items-center gap-2`,children:[v(`div`,{className:`flex items-center justify-center rounded-lg ${rf[t]}`,style:{backgroundColor:`${i.color}15`},children:l===void 0?v(a,{className:nf[t],style:{color:i.color}}):v(`img`,{src:l,alt:i.label,className:nf[t],onError:()=>c(e=>new Set([...e,l]))})}),n&&v(`span`,{className:`text-xs font-medium text-foreground-subtle`,children:i.label})]})}function cf({children:e}){return v(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-2 sm:gap-3 lg:grid-cols-3`,children:e})}function lf({addonId:e,name:t,openLabel:n,onOpen:r,body:i,footer:a,disabled:o=!1,testId:c,buttonTestId:l,iconUrl:u}){return s(`article`,{"data-testid":c,className:`relative flex min-w-0 items-stretch gap-3 overflow-x-clip rounded-lg border border-border bg-surface p-3`,children:[v(W,{type:`button`,variant:`ghost`,"aria-label":n,disabled:o,"data-testid":l,onClick:r,className:`absolute inset-0 z-0 h-auto w-auto rounded-lg p-0 focus-visible:ring-2 focus-visible:ring-primary`}),v(`div`,{className:`pointer-events-none relative z-10 flex w-20 shrink-0 items-center justify-center`,children:v(sf,{type:e,size:`xl`,...u===void 0?{}:{iconUrl:u}})}),s(`div`,{className:`pointer-events-none relative z-10 grid min-w-0 flex-1 grid-rows-[1fr_auto_1fr] gap-1`,children:[v(`p`,{className:`min-w-0 self-start truncate text-sm font-semibold text-foreground`,children:t}),i,v(`div`,{className:`self-end justify-self-start`,children:a})]})]})}function uf({kind:e,children:t}){let{t:n}=Z(),r=`integrations-section-${e}`;return s(`section`,{"aria-labelledby":r,"data-testid":r,className:`min-w-0 space-y-2`,children:[v(`h2`,{id:r,className:Ae,children:e===`providers`?n(`integrations.sections.providers`,`Providers`):n(`integrations.sections.system`,`System`)}),t]})}var df=`(hover: none) and (pointer: coarse)`;function ff(){if(typeof window>`u`||typeof window.matchMedia!=`function`)return!0;try{return!window.matchMedia(df).matches}catch{return!0}}T();function pf(e,t){return`${e.name} ${e.description} ${e.addonId}`.toLowerCase().includes(t)}function mf({onSelect:e,onClose:t,pendingAddonId:n=null,source:r}){let{t:i,i18n:a}=Z(),o=_o(),[c,l]=x(``),u=d(null),p=Tr(void 0,{enabled:r===void 0}),m=r===void 0?p.data:void 0,h=r===void 0&&p.isLoading;y(()=>{h||!ff()||u.current?.focus()},[h]);let{data:g}=tr(void 0),_=n!==null,b=f(()=>r===void 0?(m??[]).map(n=>{let r=n.instanceMode===`unique`&&n.existingInstances.length>0;return{key:n.addonId,addonId:n.addonId,name:n.name,description:n.description??``,open:()=>{let i=n.existingInstances[0];r&&i!==void 0?(t(),o(jd(n.addonId,i.id))):e(n.addonId,n.instanceMode,n.discoveryMode,n.providerLabel??n.name,n.kind,n.brokerKind,n.mode,n.canTest)},footer:r?s(`span`,{className:`flex items-center gap-1 text-xs font-medium text-foreground-subtle`,children:[v(dt,{className:`h-3 w-3`}),i(`integrations.manage`)]}):null}}):r.providers.map(e=>({...e,key:e.kind===void 0?e.addonId:`${e.addonId}-${e.kind}`,open:()=>r.onPick(e.addonId,e.kind),footer:null})),[r,m,t,e,o,i]),S=f(()=>{let e=c.trim().toLowerCase();return e.length===0?b:b.filter(t=>pf(t,e))},[b,c]),C=f(()=>{let e=Wd(S,Ud(g));return{providers:Gd(e.providers,a.language),system:Gd(e.system,a.language)}},[S,g,a.language]);if(h)return v(`div`,{className:`grid grid-cols-1 gap-2 p-2 sm:grid-cols-2 lg:grid-cols-3`,children:[1,2,3,4].map(e=>v(`div`,{className:`h-24 rounded-lg bg-surface animate-pulse`},e))});let w=e=>v(cf,{children:e.map(e=>v(lf,{testId:`provider-card-${e.key}`,buttonTestId:`provider-pick-${e.key}`,addonId:e.addonId,...e.iconUrl===void 0?{}:{iconUrl:e.iconUrl},name:e.name,openLabel:e.name,disabled:_,onOpen:e.open,body:e.description.length>0?v(`p`,{className:`line-clamp-2 text-xs text-foreground-muted`,children:e.description}):v(`span`,{}),footer:n===e.addonId?v(H,{className:`h-4 w-4 animate-spin text-primary`}):e.footer},e.key))});return s(`div`,{className:`space-y-3`,"data-testid":`provider-picker`,children:[s(`div`,{className:`relative`,children:[v(ft,{className:`pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-foreground-subtle`,"aria-hidden":!0}),v(U,{ref:u,type:`search`,value:c,onChange:e=>l(e.target.value),placeholder:i(`integrations.searchProviders`,`Search integrations…`),className:`pl-8`,"data-testid":`provider-picker-search`,"data-dialog-autofocus":!0,"aria-label":i(`integrations.searchProviders`,`Search integrations…`)})]}),C.providers.length>0&&v(uf,{kind:`providers`,children:w(C.providers)}),C.system.length>0&&v(uf,{kind:`system`,children:w(C.system)}),S.length===0&&v(`div`,{className:`py-8 text-center text-xs text-foreground-subtle`,children:b.length===0?i(`integrations.noProviders`):i(`integrations.noProvidersMatch`,`No integrations match your search.`)})]})}function hf(e){return e.setupIntegration===!0||e.prefilledConfig.setupIntegration===!0}function gf(e,t,n){let r={};for(let[e,n]of Object.entries(t.prefilledConfig))e!==`setupIntegration`&&(r[e]=typeof n==`string`&&e===`host`?n.trim():n);let i=n?.trim()??``;return{addonId:e,name:i.length>0?Yt(i):t.suggestedName,config:r,...t.stableId===void 0?{}:{originStableId:t.stableId}}}function _f(e,t,n){return hf(t)?gf(e,t,n):null}function vf(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function yf(e){if(!vf(e)||!vf(e.integrationSeed))return null;let t=e.integrationSeed,n=t.addonId,r=t.name,i=t.config;if(typeof n!=`string`||n.length===0||typeof r!=`string`||!vf(i))return null;let a={};for(let[e,t]of Object.entries(i))a[e]=t;let o=t.originStableId;return{addonId:n,name:r,config:a,...typeof o==`string`&&o.length>0?{originStableId:o}:{}}}function bf(e){let t=new Map;for(let n of e)t.set(n.stableId,n);let n=e=>{let n=e.parentStableId;if(n===void 0||n===e.stableId)return null;let r=t.get(n);if(r===void 0)return null;let i=new Set([e.stableId]),a=r;for(;a!==void 0;){if(i.has(a.stableId))return null;i.add(a.stableId),a=a.parentStableId===void 0?void 0:t.get(a.parentStableId)}return r},r=new Map,i=[];for(let t of e){let e=n(t);if(e===null){i.push(t);continue}let a=r.get(e.stableId)??[];a.push(t),r.set(e.stableId,a)}let a=e=>({candidate:e,children:(r.get(e.stableId)??[]).map(a)});return i.map(a)}function xf(e){return e.flatMap(e=>[e.candidate,...xf(e.children)])}T();var Sf=6e4;function Cf(){let e=Qn({},{refetchInterval:Sf}),{refetch:t}=e,n=_(()=>void t(),[t]);return{count:e.data===void 0?null:e.data.proposals.length,refresh:n}}function wf({count:e}){return e===null||e===0?null:v(jn,{variant:`info`,style:`fill`,size:`sm`,"data-testid":`discovery-pill`,children:e})}function Tf({onSetupIntegration:e}){let{t}=Z(),n=Qn({},{refetchInterval:Sf}),r=Ei(),i=Ya(),[a,o]=x(new Set),{refetch:c}=n,l=_(async(e,t)=>{o(t=>new Set(t).add(e));try{await t(),c()}catch{}finally{o(t=>{let n=new Set(t);return n.delete(e),n})}},[c]),u=_(async t=>{let n=_f(t.addonId,t.candidate);if(n!==null){e(n);return}await l(t.id,()=>r.mutateAsync({addonId:t.addonId,candidate:t.candidate}))},[r,e,l]),d=_(e=>l(e.id,()=>i.mutateAsync({id:e.id})),[i,l]),f=n.data?.proposals??[];return f.length===0?null:s(`section`,{className:`space-y-2`,"data-testid":`discovery-proposals`,children:[s(`h3`,{className:`flex items-center gap-2`,children:[v(`span`,{className:Ae,children:t(`integrations.discoveryProposals.title`,`Found in the background`)}),s(`span`,{className:`text-[10px] text-foreground-subtle`,children:[`(`,f.length,`)`]})]}),v(`div`,{className:`space-y-1.5`,children:f.map(e=>s(`div`,{"data-testid":`discovery-proposal`,className:`flex items-center gap-2 rounded-lg border border-border bg-surface px-3 py-2`,children:[s(`div`,{className:`min-w-0 flex-1`,children:[v(`p`,{className:`truncate text-sm font-medium text-foreground`,children:e.candidate.suggestedName}),v(`p`,{className:`truncate text-xs text-foreground-muted`,children:e.addonId})]}),a.has(e.id)?v(H,{className:`h-4 w-4 animate-spin text-foreground-muted`,"aria-hidden":!0}):s(j,{children:[v(W,{variant:`secondary`,size:`sm`,onClick:()=>void d(e),children:t(`integrations.discoveryProposals.dismiss`,`Dismiss`)}),s(W,{size:`sm`,onClick:()=>void u(e),children:[v(_e,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),t(`integrations.discoveryProposals.adopt`,`Adopt`)]})]})]},e.id))})]})}var Ef=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\/(\d{1,2})$/;function Df(e){let t=Ef.exec(e.trim());if(t===null)return{ok:!1,reason:`format`};let n=[t[1],t[2],t[3],t[4]].map(e=>Number(e));if(n.some(e=>e>255))return{ok:!1,reason:`format`};let r=Number(t[5]);return r>32?{ok:!1,reason:`format`}:r<22?{ok:!1,reason:`prefix`}:{ok:!0,cidr:`${n.join(`.`)}/${r}`}}T();function Of(){let{t:e}=Z(),t=ro(),n=Rr({onSuccess:()=>void t.refetch()}),[r,i]=x(``),[a,o]=x(null),c=t.data?.subnets??[],l=async t=>{try{return await n.mutateAsync({subnets:[...t]}),!0}catch{return o(e(`integrations.scanNetworkModal.subnets.saveFailed`,`The network list could not be saved.`)),!1}},u=async()=>{let t=Df(r);if(!t.ok){o(t.reason===`prefix`?e(`integrations.scanNetworkModal.subnets.errorPrefix`,`A network larger than a /22 cannot be scanned.`):e(`integrations.scanNetworkModal.subnets.errorFormat`,`Enter a network like 192.0.2.0/24.`));return}if(c.includes(t.cidr)){o(e(`integrations.scanNetworkModal.subnets.errorDuplicate`,`Already in the list.`));return}o(null),await l([...c,t.cidr])&&i(``)};return s(`section`,{className:`space-y-2`,"data-testid":`scan-subnets`,children:[v(`h3`,{className:Ae,children:e(`integrations.scanNetworkModal.subnets.title`,`Extra networks to scan`)}),v(`p`,{className:`text-xs text-foreground-muted`,children:c.length===0?e(`integrations.scanNetworkModal.subnets.none`,`Only this hub's own networks are scanned.`):e(`integrations.scanNetworkModal.subnets.hint`,`Every scan covers this hub's own networks and these.`)}),c.length>0&&v(`div`,{className:`flex flex-wrap gap-1.5`,children:c.map(e=>v(Da,{label:e,testId:`scan-subnet-${e}`,onRemove:()=>void l(c.filter(t=>t!==e))},e))}),s(`div`,{className:`flex items-start gap-2`,children:[s(`div`,{className:`min-w-0 flex-1`,children:[v(U,{value:r,onChange:e=>{i(e.target.value),o(null)},onKeyDown:e=>{e.key===`Enter`&&u()},placeholder:`192.0.2.0/24`,state:a===null?`default`:`error`,"aria-label":e(`integrations.scanNetworkModal.subnets.title`,`Extra networks to scan`),"data-testid":`scan-subnet-input`}),a!==null&&v(`p`,{className:`mt-1 text-xs text-danger`,children:a})]}),s(W,{variant:`outline`,size:`sm`,onClick:()=>void u(),disabled:n.isPending||r.trim().length===0,"data-testid":`scan-subnet-add`,children:[v(Tt,{className:`h-3.5 w-3.5`}),e(`integrations.scanNetworkModal.subnets.add`,`Add network`)]})]})]})}T();function kf({open:e,onClose:t,scope:n,onSetupIntegration:r,pickMode:i=`adopt`,onAdopted:a}){let{t:o}=Z(),c=Ei(),[l,u]=x(new Set),[d,p]=x(new Set),[m,h]=x(new Set),{data:g}=Mr({projection:`slim`}),y=f(()=>new Set((g??[]).map(e=>e.stableId)),[g]),b=_(async(e,t)=>{p(e=>new Set(e).add(t.stableId));try{await c.mutateAsync({addonId:e,candidate:t}),a?.(),u(e=>new Set(e).add(t.stableId)),h(e=>{let n=new Set(e);return n.delete(t.stableId),n})}catch{}finally{p(e=>{let n=new Set(e);return n.delete(t.stableId),n})}},[c,a]),S=_(async(e,n)=>{let a=i===`fill`?gf(e,n):_f(e,n);if(a!==null){r?.(a),t();return}await b(e,n)},[b,t,r,i]),C=_(e=>{h(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),w=_(()=>{u(new Set),h(new Set)},[]),T=f(()=>({existingStableIds:y,adopted:l,adopting:d,selection:{selected:m,toggle:C},pick:S,adoptOne:b,fill:i===`fill`}),[y,l,d,m,C,S,i]),E=n?o(`integrations.scanNetworkModal.titleScoped`,`Scan network — {{label}}`,{label:n.label}):o(`integrations.scanNetworkModal.title`,`Scan network for devices`);return v(Nn,{open:e,onOpenChange:e=>!e&&t(),children:s(Na,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,children:[v($i,{children:v(Ti,{children:s(`span`,{className:`flex items-center gap-2`,children:[v(St,{className:`h-4 w-4 text-primary`}),E]})})}),s(Li,{className:`space-y-4`,children:[v(Of,{}),!n&&i===`adopt`&&r&&v(Tf,{onSetupIntegration:e=>{t(),r(e)}}),n?v(If,{scope:n,row:T,onReset:w}):v(Ff,{row:T,onReset:w})]})]})})}function Af(e,t){return!t&&e.selectable!==!1&&!hf(e)}function jf({addonId:e,nodes:t,row:n,depth:r}){return v(`div`,{className:r===0?`space-y-1.5`:`ml-4 space-y-1.5 border-l border-border pl-3`,"data-testid":r===0?void 0:`scan-children`,children:t.map(t=>s(`div`,{className:`space-y-1.5`,children:[v(Mf,{addonId:e,candidate:t.candidate,row:n}),t.children.length>0&&v(jf,{addonId:e,nodes:t.children,row:n,depth:r+1})]},t.candidate.stableId))})}function Mf({addonId:e,candidate:t,row:n}){let{t:r}=Z(),i=t.prefilledConfig.host,a=typeof i==`string`?i:null,o=n.existingStableIds.has(t.stableId)||t.alreadyOnboarded===!0||t.onboardedDeviceId!==void 0,c=n.adopted.has(t.stableId)||o,l=n.adopting.has(t.stableId),u=n.fill||hf(t),d=!c&&(u||t.selectable!==!1),f=d&&Af(t,n.fill);return s(`div`,{className:`flex items-center gap-3 rounded-lg border border-border bg-surface px-3 py-2`,"data-testid":`scan-row-${t.stableId}`,children:[f&&v(Dt,{checked:n.selection.selected.has(t.stableId),onChange:()=>n.selection.toggle(t.stableId),disabled:l,"aria-label":r(`integrations.scanNetworkModal.select`,`Select {{name}}`,{name:t.suggestedName})}),s(`div`,{className:`min-w-0 flex-1`,children:[v(`p`,{className:`truncate text-xs font-medium text-foreground`,children:t.suggestedName}),a&&v(`p`,{className:`truncate font-mono text-[10px] text-foreground-subtle`,children:a}),o&&t.onboardedName!==void 0&&v(`p`,{className:`truncate text-[10px] text-foreground-subtle`,children:t.onboardedName})]}),c?s(`span`,{className:`flex items-center gap-1 text-[11px] text-foreground-subtle`,children:[v(_e,{className:`h-3.5 w-3.5`}),` `,o?r(`integrations.scanNetworkModal.alreadyAdded`,`Already added`):r(`integrations.scanNetworkModal.added`,`Added`)]}):d?s(W,{size:`sm`,variant:u?`outline`:`primary`,onClick:()=>void n.pick(e,t),disabled:l,children:[l?v(H,{className:`h-3.5 w-3.5 animate-spin`}):u?null:v(ce,{className:`h-3.5 w-3.5`}),u?n.fill?r(`integrations.scanNetworkModal.use`,`Use`):r(`integrations.scanNetworkModal.setUp`,`Set up`):r(`common.add`,`Add`)]}):null]})}function Nf({addonId:e,label:t,candidates:n,row:r}){let i=f(()=>bf(n),[n]);return s(`section`,{className:`space-y-2`,"data-testid":`scan-group-${e}`,children:[s(`h3`,{className:`flex items-center gap-2`,children:[v(sf,{type:e,size:`sm`}),v(`span`,{className:Ae,children:t}),s(`span`,{className:`text-[10px] text-foreground-subtle`,children:[`(`,n.length,`)`]})]}),v(jf,{addonId:e,nodes:i,row:r,depth:0})]})}function Pf(e,t){return e.flatMap(e=>xf(bf(e.candidates)).filter(e=>Af(e,t)).map(t=>({addonId:e.addonId,candidate:t})))}function Ff({row:e,onReset:t}){let{t:n}=Z(),r=yi(),i=_(()=>{t(),r.mutate({})},[r,t]);y(()=>{!r.isPending&&!r.data&&i()},[]);let a=f(()=>(r.data?.groups??[]).filter(e=>e.candidates.length>0),[r.data]),o=f(()=>a.reduce((e,t)=>e+t.candidates.length,0),[a]),c=f(()=>Pf(a,e.fill),[a,e.fill]);return s(`div`,{className:`space-y-4`,children:[s(`div`,{className:`flex items-center justify-between gap-2`,children:[v(`p`,{className:`text-xs text-foreground-subtle`,children:!r.isPending&&a.length>0?n(`integrations.scanNetworkModal.found`,{count:o}):null}),s(`div`,{className:`flex items-center gap-2`,children:[v(Lf,{entries:c,row:e}),s(W,{variant:`outline`,size:`sm`,onClick:i,disabled:r.isPending,children:[v(et,{className:`h-3.5 w-3.5 ${r.isPending?`animate-spin`:``}`}),n(`integrations.scanNetworkModal.reScan`,`Re-scan`)]})]})]}),r.isPending&&v(zf,{label:n(`integrations.scanNetworkModal.scanningTheLocalNetwork`,`Scanning the local network…`)}),!r.isPending&&r.isError&&v(Bf,{}),!r.isPending&&r.data&&a.length===0&&v(Rf,{}),!r.isPending&&a.map(t=>v(Nf,{addonId:t.addonId,label:t.label,candidates:t.candidates,row:e},t.addonId))]})}function If({scope:e,row:t,onReset:n}){let{t:r}=Z(),i=si({addonId:e.addonId}).data??null,[a,o]=x({}),c=$a(),l=_(()=>{n(),c.mutate({addonId:e.addonId,params:a})},[c,e.addonId,a,n]),u=f(()=>c.data?.candidates??[],[c.data]),d=f(()=>Pf([{addonId:e.addonId,candidates:u}],t.fill),[e.addonId,u,t.fill]);return s(`div`,{className:`space-y-4`,children:[i&&v(qo,{schema:i,values:a,onChange:o}),s(W,{onClick:l,disabled:c.isPending,children:[c.isPending?v(H,{className:`h-3.5 w-3.5 animate-spin`}):v(St,{className:`h-3.5 w-3.5`}),c.isPending?r(`integrations.scanNetworkModal.scanning`,`Scanning…`):r(`integrations.scanNetworkModal.scan`,`Scan`)]}),v(Lf,{entries:d,row:t}),c.isError&&v(Bf,{}),!c.isPending&&c.data&&u.length===0&&v(Rf,{}),!c.isPending&&u.length>0&&s(`div`,{className:`space-y-2`,children:[v(`p`,{className:`text-xs text-foreground-subtle`,children:r(`integrations.scanNetworkModal.foundShort`,{count:u.length})}),v(Nf,{addonId:e.addonId,label:e.label,candidates:u,row:t})]})]})}function Lf({entries:e,row:t}){let{t:n}=Z(),r=e.filter(e=>t.selection.selected.has(e.candidate.stableId));if(r.length===0)return null;let i=async()=>{for(let e of r)await t.adoptOne(e.addonId,e.candidate)};return s(W,{size:`sm`,onClick:()=>void i(),"data-testid":`scan-add-selected`,children:[v(ce,{className:`h-3.5 w-3.5`}),n(`integrations.scanNetworkModal.addSelected`,`Add selected ({{count}})`,{count:r.length})]})}function Rf(){let{t:e}=Z();return v(`p`,{className:`py-6 text-center text-xs text-foreground-subtle`,children:e(`integrations.scanNetworkModal.noDevicesRespondedToThe`,`No devices responded to the scan.`)})}function zf({label:e}){return s(`div`,{className:`flex flex-col items-center py-12`,children:[v(H,{className:`h-6 w-6 animate-spin text-primary`}),v(`p`,{className:`mt-3 text-xs text-foreground-subtle`,children:e})]})}function Bf(){let{t:e}=Z();return s(`div`,{className:`flex items-start gap-3 rounded-lg border border-danger/40 bg-danger/10 px-4 py-3`,children:[v(He,{className:`mt-0.5 h-4 w-4 shrink-0 text-danger`}),v(`p`,{className:`text-xs text-danger`,children:e(`integrations.scanNetworkModal.theScanFailedTryAgain`,`The scan failed. Try again.`)})]})}T();function Vf(e){let t=e=>{if(e.type===`separator`||e.type===`info`||e.type===`button`)return e;if(e.type===`group`)return{...e,fields:e.fields.map(e=>t(e))};let{value:n,...r}=e;return r};return{...e.tabs?{tabs:e.tabs}:{},sections:e.sections.map(e=>({...e,fields:e.fields.map(t)}))}}var Hf=2e4,Uf=`device-provider`;function Wf({open:e,onClose:t,seed:n=null,pickFrom:r}){let{t:i}=Z(),a=_o(),o=O(),[c,l]=x(`picker`),[u,d]=x(null),[p,m]=x(null),[h,g]=x(`manual`),[_,b]=x(null),[S,C]=x(``),[w,T]=x(null),[E,D]=x(null),[k,A]=x(!1),[M,N]=x({}),[P,F]=x(``),[ee,te]=x(!1),[ne,re]=x(0),[ie,ae]=x(``),oe=ki({},{enabled:e&&c===`config`}),se=Kr({addonId:u??``},{enabled:e&&(c===`config`||c===`broker`)&&u!==null}),ce=(se.data?.kinds??[]).filter(e=>e.canTest!==!1),I=ce.length===1?ce[0]?.id:void 0,le=(se.data?.kinds??[]).filter(e=>e.functionCap===Uf),ue=le.length===1?le[0]?.id:void 0,de=u!==null&&(oe.data?.providers??[]).some(e=>e.addonId===u),fe=n?.config.host,pe=n===null?``:`${n.addonId}\0${n.name}\0${typeof fe==`string`?fe:``}`;e&&n!==null&&P!==pe&&(F(pe),d(n.addonId),C(n.name),N({...n.config}),l(`config`));let L=Tr(void 0,{enabled:e&&n!==null}),R=L.data?.find(e=>e.addonId===u)?.mode??`account`,{data:z}=Vn({addonId:u??``,id:null,mode:R,...n?.originStableId===void 0?{}:{candidateStableId:n.originStableId}},{enabled:u!=null}),me=f(()=>z?Vf(z):null,[z]),B=hr({onSuccess:()=>{o.invalidateQueries({queryKey:[[`integrations`]]}),o.invalidateQueries({queryKey:[[`integrationInstances`]]})}}),he=za(),ge=he.data;y(()=>{if(!e||n===null)return;let t=L.data?.find(e=>e.addonId===n.addonId);if(!t)return;A(t.canTest),g(t.discoveryMode);let r=t.providerLabel??t.name;typeof r==`string`&&r.length>0&&C(Zt({providerLabel:r,mode:t.mode,brokerKind:t.brokerKind}))},[e,n,L.data]),y(()=>{c!==`discovery`||!p||!u||he.isPending||he.data||he.mutate({addonId:u})},[c,p,u,he]);let _e=Ei({onSuccess:()=>o.invalidateQueries({queryKey:[[`deviceManager`]]})});function ve(e,t,n,r,i,a,o,s){if(B.isPending)return;let c=Zt({providerLabel:r,mode:o,brokerKind:a});if(d(e),A(s),g(n),C(c),D(null),B.reset(),o===`broker`){if(!a){D(`Addon '${e}' declares mode 'broker' but no brokerKind in its manifest`);return}b(a),l(`broker`);return}if(o===`account`){l(`config`);return}ye(e,c)}async function ye(e,n){try{let r=await B.mutateAsync({addonId:e,name:n,values:{}});t(),we(),a(`${jd(e,r.id)}&add=1`)}catch{}}async function be(e){if(u)try{let t=await B.mutateAsync({addonId:u,name:e.name,values:e.config,...I===void 0?{}:{kind:I},...n!==null&&n.addonId===u&&n.originStableId!==void 0?{originStableId:n.originStableId}:{}});m(t.id),T(t.id),h===`auto`||h===`both`?l(`discovery`):Ce(t.id,{openAdd:!0})}catch{}}async function xe(e){if(u)try{let t=await B.mutateAsync({addonId:u,name:S,values:{brokerId:e},...ue===void 0?{}:{kind:ue}});T(t.id),m(t.id),Ce(t.id)}catch{}}async function Se(e){if(u){for(let t of e){let e=ge?.find(e=>e.stableId===t);e&&await _e.mutateAsync({addonId:u,candidate:e,...w===null?{}:{integrationId:w}})}Ce()}}function Ce(e,n){let r=e??p??u;if(t(),we(),r&&u){let e=jd(u,r);a(n?.openAdd===!0?`${e}&add=1`:e)}}function we(){l(`picker`),d(null),m(null),g(`manual`),b(null),C(``),T(null),D(null),B.reset(),A(!1),N({}),F(``)}function Te(){t(),we()}Nd(e);let Ee=B.isPending,De=Pd(Ee,Hf);if(!e)return null;let Oe={picker:r?.title??i(`integrations.newIntegration`),config:i(`integrations.configureIntegration`),discovery:i(`integrations.importDevices`),broker:i(`integrations.connectBroker`,{defaultValue:`Connect a broker`})},ke=Ee?u:null,Ae=B.error,je=Ee&&!De;return s(j,{children:[v(Nn,{open:!0,onOpenChange:e=>{!e&&!je&&Te()},children:s(Na,{width:c===`picker`?`xl`:`lg`,scroll:`body`,onCancel:e=>{je&&e.preventDefault()},children:[v($i,{children:v(Ti,{children:Oe[c]})}),s(Li,{children:[Ae&&!Ee&&v(`div`,{className:`mb-3 rounded-lg border border-danger/40 bg-danger/10 px-3 py-2 text-xs text-danger`,children:Ae instanceof Error?Ae.message:String(Ae)}),c===`picker`&&s(j,{children:[E&&v(`div`,{className:`mb-3 rounded-lg border border-danger/40 bg-danger/10 px-3 py-2 text-xs text-danger`,children:E}),v(mf,{onSelect:ve,onClose:Te,pendingAddonId:ke,...r===void 0?{}:{source:r}})]}),c===`config`&&u&&v(Ld,{addonId:u,configSchema:me??null,canTest:k,...I===void 0?{}:{instanceKind:I},initialName:S.length>0?S:void 0,initialConfig:{...M},onScan:de?()=>{ae(S.length>0?S:u),te(!0)}:void 0,onSave:be,onBack:()=>{N({}),l(`picker`)}},`${pe.length>0?pe:u}:${S}:${ne}`),c===`broker`&&_&&v(Fd,{kind:_,onResolved:e=>{xe(e)},onBack:()=>l(`picker`)}),c===`discovery`&&p&&v(Id,{providerId:p,onImport:Se,onSkip:Ce})]}),Ee&&s(`div`,{className:`absolute inset-0 z-20 flex flex-col items-center justify-center gap-2 rounded-lg bg-background/85 backdrop-blur-sm px-6 text-center`,children:[v(H,{className:`h-6 w-6 animate-spin text-primary`}),v(`p`,{className:`text-xs font-medium text-foreground`,children:i(`integrations.creating`,{defaultValue:`Creating integration…`})}),!De&&v(`p`,{className:`text-[10px] text-foreground-subtle`,children:i(`integrations.creatingHint`,{defaultValue:`Waiting for the addon to restart and register`})}),De&&s(j,{children:[v(`p`,{className:`text-[10px] text-foreground-subtle max-w-xs`,children:i(`integrations.creatingOverdue`,{defaultValue:`This is taking longer than expected. The integration may already have been created — close this dialog and refresh to check.`})}),v(W,{variant:`unstyled`,onClick:Te,className:`mt-1 rounded-md border border-border bg-surface px-3 py-1.5 text-[11px] font-medium text-foreground hover:bg-surface-hover transition-colors`,children:i(`integrations.closeAndRefresh`,{defaultValue:`Close`})})]})]})]})}),ee&&u!==null&&v(kf,{open:ee,scope:{addonId:u,label:ie},pickMode:`fill`,onClose:()=>te(!1),onSetupIntegration:e=>{C(e.name),N({...e.config}),re(e=>e+1)}})]})}T();function Gf({functionCap:e,disabled:t,onCreated:n}){let{t:r}=Z(),{options:i}=wd({functionCap:e,match:`link`}),[a,o]=x({at:`closed`});if(i.length===0)return null;let c=()=>o({at:`closed`});return s(j,{children:[s(W,{variant:`outline`,size:`sm`,disabled:t,onClick:()=>{let e=i.length===1?i[0]:void 0;o(e===void 0?{at:`choose`}:{at:`edit`,option:e})},children:[v(Tt,{className:`h-3.5 w-3.5`}),` `,r(`brokers.picker.createNew`)]}),a.at===`choose`&&v(Wf,{open:!0,onClose:c,pickFrom:{title:r(`brokers.picker.createNew`),providers:i.map(e=>({addonId:e.addonId,kind:e.kind,name:e.label,description:``,...e.iconUrl===void 0?{}:{iconUrl:e.iconUrl}})),onPick:(e,t)=>{let n=i.find(n=>n.addonId===e&&n.kind===t);o(n===void 0?{at:`closed`}:{at:`edit`,option:n})}}}),a.at===`edit`&&v(Ed,{functionCap:e,addonId:a.option.addonId,kind:a.option.kind,match:`link`,onClose:c,onSaved:e=>{c(),n(e)}})]})}var Kf=`broker`;function qf({functionCap:e,kind:t,noneLabel:n,required:r,disabled:i,value:a,onChange:o}){return e===Kf&&t!==void 0?v(Od,{kind:t,value:a,onChange:o,optional:r===!1,disabled:i===!0,...n===void 0?{}:{noneLabel:n}}):s(`div`,{className:`space-y-2`,children:[v(xr,{functionCap:e,...t===void 0?{}:{kind:t},...n===void 0?{}:{noneLabel:n},value:a??``,disabled:i===!0,onChange:e=>o(e===``?null:e),controlId:`instance-picker-${e}-${t??`any`}`}),t===void 0&&v(`div`,{children:v(Gf,{functionCap:e,disabled:i===!0,onCreated:o})})]})}function Jf({deviceId:e}){let{t}=Z(),n=Fn(G().trpcClient,e);return n===null?null:v(or,{headingId:`device-web-interface-${String(e)}`,title:t(`device.webInterface.title`,`Web interface`),icon:Sn,testId:`device-web-interface-card`,children:s(`div`,{className:`flex flex-wrap items-center justify-between gap-2 px-3 py-2 sm:px-4`,children:[s(`div`,{className:`min-w-0 text-xs`,children:[v(`div`,{className:`font-medium text-foreground`,children:n.label}),v(`div`,{className:`break-all text-foreground-muted`,children:n.host})]}),s(W,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>window.open(n.url,`_blank`,`noopener,noreferrer`),children:[v(P,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),t(`device.webInterface.open`,`Open`)]})]})})}function Yf(e,t){return e.icon===t.icon&&e.label===t.label&&e.unit===t.unit&&e.precision===t.precision&&e.hidden===t.hidden}function Xf(e){return{icon:e?.icon??``,label:e?.label??``,unit:e?.unit??``,precision:e?.precision===void 0?``:String(e.precision),hidden:e?.hidden===!0}}function Zf(e){if(e.trim()===``)return;let t=Number.parseInt(e,10);return Number.isFinite(t)?t:void 0}function Qf(e,t){let n=Zf(e.precision),r={...e.icon===``?{}:{icon:e.icon},...e.label.trim()===``?{}:{label:e.label.trim()},...e.unit===``?{}:{unit:e.unit},...n===void 0?{}:{precision:n},...e.hidden?{hidden:!0}:{},...t?.perCap===void 0?{}:{perCap:t.perCap}};return Object.keys(r).length===0?null:r}function $f(e){let t=Xf(e.display),n=e.tags??[];return{name:e.name,location:e.location,role:e.role,display:t,tags:n,baseName:e.name,baseLocation:e.location,baseRole:e.role,baseDisplay:t,baseTags:n,persistedDisplay:e.display}}function ep(e,t){if(e===null)return $f(t);let n=Xf(t.display),r=e.name===t.name&&e.location===t.location&&e.role===t.role&&np(e.tags,t.tags??[])&&Yf(e.display,n);return!tp(e)||r?$f(t):e}function tp(e){return e===null?!1:e.name!==e.baseName||e.location!==e.baseLocation||e.role!==e.baseRole||!np(e.tags,e.baseTags)||!Yf(e.display,e.baseDisplay)}function np(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}function rp(e){return e.name.trim().length===0?`name`:null}function ip(e){let t=e.name.trim(),n=e.location.trim();return{...t===e.baseName?{}:{name:t},...n===e.baseLocation?{}:{location:n===``?null:n},...e.role===e.baseRole?{}:{role:e.role},...np(e.tags,e.baseTags)?{}:{tags:[...e.tags]},...Yf(e.display,e.baseDisplay)?{}:{display:Qf(e.display,e.persistedDisplay)}}}function ap(e){let t=e.map(e=>e.error).filter(e=>e!==null&&e.length>0);return{dirty:e.some(e=>e.dirty),saving:e.some(e=>e.saving),error:t.length===0?null:t.join(`; `)}}T();var op=D(null);function sp(){return M(op)}function cp({deviceId:e,seed:t,onClose:n,children:r}){let[i,a]=x(null),[o,s]=x([]),{t:c}=Z(),l=_o(),u=tt(),p=d(new Map);if(t!==null){let e=ep(i,t);(i===null||e.name!==i.name||e.location!==i.location||e.role!==i.role||!np(e.tags,i.tags)||!np(e.baseTags,i.baseTags)||!Yf(e.display,i.display)||e.baseName!==i.baseName||e.baseLocation!==i.baseLocation||e.baseRole!==i.baseRole||!Yf(e.baseDisplay,i.baseDisplay)||e.persistedDisplay!==i.persistedDisplay)&&a(e)}let m=_(e=>(p.current.set(e.id,{save:e.save,discard:e.discard}),s(t=>{let n=t.find(t=>t.id===e.id);return n!==void 0&&n.dirty===e.dirty&&n.saving===e.saving&&n.error===e.error?t:[...t.filter(t=>t.id!==e.id),{...e,save:()=>p.current.get(e.id)?.save()??Promise.resolve(),discard:()=>{p.current.get(e.id)?.discard()}}]}),()=>{p.current.delete(e.id),s(t=>t.filter(t=>t.id!==e.id))}),[]),h=ap([{dirty:tp(i),saving:!1,error:null},...o]).dirty,g=_(e=>{(async()=>{h&&!await u({title:c(`deviceQuickDetail.leaveTitle`,`Discard unsaved changes?`),message:c(`deviceQuickDetail.leaveMessage`,`Unsaved edits on this device will be discarded.`),confirmLabel:c(`deviceQuickDetail.discard`,`Discard`),variant:`warning`})||(l(e),n?.())})()},[h,u,c,l,n]),y=_(()=>g(`/devices/${String(e)}`),[g,e]),b=f(()=>({identity:i,setIdentityName:e=>{a(t=>t===null?t:{...t,name:e})},setIdentityLocation:e=>{a(t=>t===null?t:{...t,location:e})},setIdentityRole:e=>{a(t=>t===null?t:{...t,role:e})},setIdentityTags:e=>{a(t=>t===null?t:{...t,tags:e})},setIdentityDisplay:e=>{a(t=>t===null?t:{...t,display:{...t.display,...e}})},register:m,openDevicePage:y,leaveTo:g}),[i,m,y,g]);return v(op.Provider,{value:b,children:v(lp,{deviceId:e,identity:i,contributions:o,onIdentitySaved:e=>a(e),children:r})})}function lp({deviceId:e,identity:t,contributions:n,onIdentitySaved:r,children:i}){return s(j,{children:[i,v(dp,{deviceId:e,identity:t,contributions:n,onIdentitySaved:r})]})}function up(e){return e instanceof Error?e.message:String(e)}function dp({deviceId:e,identity:t,contributions:n,onIdentitySaved:r}){let{t:i}=Z(),a=O(),[o,c]=x(null),[l,u]=x(!1),d=Ea(),f=Mn(),p=Di(),m=Br(),h=Ni(),g=ap([{dirty:tp(t),saving:l,error:o},...n]),_=()=>{a.invalidateQueries({queryKey:[[`deviceManager`]]})};return!g.dirty&&!g.saving&&g.error===null?null:s(`div`,{className:`sticky bottom-0 z-10 mt-auto flex flex-col gap-2 border-t border-border bg-background px-1 pt-3`,children:[g.error!==null&&v(`p`,{className:`text-xs text-danger`,children:g.error}),v(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:s(`div`,{className:`flex items-center gap-2`,children:[v(W,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>{t!==null&&r({...t,name:t.baseName,location:t.baseLocation,role:t.baseRole,display:t.baseDisplay,tags:t.baseTags});for(let e of n)e.discard();c(null)},disabled:!g.dirty||g.saving,children:i(`deviceQuickDetail.discard`,`Discard`)}),v(W,{type:`button`,size:`sm`,onClick:()=>{if(t!==null&&tp(t)&&rp(t)===`name`){c(i(`deviceQuickDetail.nameRequired`,`Name is required`));return}c(null),u(!0),(async()=>{try{let i=t===null?{}:ip(t);if(t!==null&&i.name!==void 0&&await d.mutateAsync({deviceId:e,name:i.name}),t!==null&&i.location!==void 0&&await f.mutateAsync({deviceId:e,location:i.location}),t!==null&&i.role!==void 0&&await p.mutateAsync({deviceId:e,role:i.role}),t!==null&&i.tags!==void 0&&await h.mutateAsync({deviceId:e,tags:i.tags}),t!==null&&i.display!==void 0&&await m.mutateAsync({deviceId:e,display:i.display}),t!==null){let e=t.name.trim(),n=t.location.trim();r({...t,name:e,location:n,baseName:e,baseLocation:n,baseRole:t.role,baseDisplay:t.display,baseTags:t.tags,persistedDisplay:i.display===void 0?t.persistedDisplay:i.display??void 0})}for(let e of n)e.dirty&&await e.save();_()}catch(e){c(up(e))}finally{u(!1)}})()},disabled:!g.dirty||g.saving,children:g.saving?i(`deviceQuickDetail.saving`,`Saving…`):i(`deviceQuickDetail.save`,`Save`)})]})})]})}function fp({label:e,value:t,layout:n=`inline`}){return n===`stacked`?s(`div`,{className:`min-w-0 flex flex-col gap-0.5 px-0.5`,children:[v(`span`,{className:`text-[11px] text-foreground-subtle`,children:e}),v(`div`,{className:`min-w-0 text-[11px] text-foreground`,children:t})]}):s(`div`,{className:`${Ee} flex items-start gap-2 sm:gap-3`,children:[v(`span`,{className:`w-20 sm:w-28 flex-shrink-0 text-[11px] text-foreground-subtle`,children:e}),v(`div`,{className:`flex-1 min-w-0 text-[11px] text-foreground`,children:t})]})}function pp({initialName:e,label:t=`Name`,layout:n=`inline`,bound:r}){return v(fp,{label:t,layout:n,value:v(U,{type:`text`,value:r.value,"aria-label":t,placeholder:e,onChange:e=>r.onChange(e.target.value),className:`flex-1 min-w-0 w-full px-1.5 py-0.5 text-[11px] bg-background border border-border rounded focus:outline-none focus:border-primary`})})}T();function mp({label:e=`Location`,layout:t=`inline`,bound:n}){let{t:r}=Z(),{data:i}=ao(),a=i??[],o=n.value.trim().toLowerCase(),c=f(()=>o.length===0?[]:a.filter(e=>e.toLowerCase()!==o&&e.toLowerCase().includes(o)),[a,o]);return v(fp,{label:e,layout:t,value:s(`div`,{className:`relative`,children:[v(U,{type:`text`,value:n.value,"aria-label":e,onChange:e=>n.onChange(e.target.value),placeholder:r(`shared.locationRow.roomAreaOrLeaveEmpty`,`Room / area (or leave empty to clear)`),className:`flex-1 min-w-0 w-full px-1.5 py-0.5 text-[11px] bg-background border border-border rounded focus:outline-none focus:border-primary`}),c.length>0&&v(`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:c.map(e=>s(`button`,{type:`button`,onClick:()=>n.onChange(e),className:`w-full flex items-center gap-2 px-2 py-1 text-left text-[11px] hover:bg-surface-hover`,children:[v(Xe,{className:`h-3 w-3 text-foreground-subtle flex-shrink-0`}),v(`span`,{className:`truncate`,children:e})]},e))})]})})}var hp=`w-full min-w-0 px-1.5 py-0.5 text-[11px] bg-background border border-border rounded focus:outline-none focus:border-primary disabled:opacity-50 disabled:cursor-not-allowed`,gp=0,_p=10;function vp(e){if(e.trim()===``)return``;let t=Number.parseInt(e,10);return Number.isFinite(t)?String(t<gp?gp:t>_p?_p:t):``}function yp({value:e,onChange:t,disabled:n=!1,placeholder:r,className:i,id:a,"aria-label":o}){return v(U,{type:`number`,min:gp,max:_p,step:1,id:a,className:i??hp,"aria-label":o,placeholder:r,value:e,onChange:e=>{t(vp(e.target.value))},disabled:n})}function bp({deviceName:e,value:t,inheritedIcon:n,inheritedLabel:r,disabled:i,onChange:a}){let{t:o}=Z(),c={trigger:o(`deviceDisplay.pickIcon`,{name:e}),panel:o(`deviceDisplay.iconFor`,{name:e}),searchPlaceholder:o(`deviceDisplay.iconSearchPlaceholder`),clear:r,noMatches:o(`deviceDisplay.iconNoMatches`)};return s(`div`,{className:`flex items-center gap-2`,children:[v(Xi,{value:t===``?null:t,onPick:e=>a(e??``),categoryLabel:e=>o(`deviceDisplay.iconCategory.${e}`,{defaultValue:Vt(e)}),fallbackGlyph:n,labels:c,disabled:i}),v(`span`,{className:`text-[11px] text-foreground-subtle`,children:t===``?r:t})]})}var xp=`w-full min-w-0 px-1.5 py-0.5 text-[11px] bg-background border border-border rounded focus:outline-none focus:border-primary disabled:opacity-50`;function Sp(e){if(e.trim()===``)return;let t=Number.parseInt(e,10);return Number.isFinite(t)?t:void 0}function Cp({device:e,role:t,display:n,onChange:r}){let i=ye();qa();let{t:a}=Z(),o=O(),c=t===null?void 0:Ca[t],l=c?.kind===`numeric`,u=t!==null||e.parentDeviceId!==null&&e.parentDeviceId!==void 0,d=e.sourceInfo?.quantity,f=c?.kind===`numeric`?c.quantity??(d!==void 0&&d!==`device`?d:void 0):void 0,p=f===void 0?void 0:Mt(f),m=p===void 0?void 0:Xt(p),{data:h}=In({},{staleTime:6e4,enabled:t!==null}),g=ya({onSuccess:()=>{o.invalidateQueries({queryKey:[[`deviceManager`]]})}}),_=()=>{if(t===null)return;let e=Sp(n.precision),r={...n.icon===``?{}:{icon:n.icon},...n.unit===``?{}:{unit:n.unit},...e===void 0?{}:{precision:e}};g.mutate({defaults:{...h?.defaults,[t]:r}})},y=t===null?void 0:h?.defaults?.[t]?.icon,b=y===void 0?void 0:Xr(y),x=t===null?Ir(e.type,i):qn(t,i),S={icon:b??Xn(e.type,t),label:b===void 0?x.label:String(y)},C=t===null&&e.type===q.Container?a(`deviceDisplay.inheritedContainer`):b===void 0?a(`deviceDisplay.inherited`,{name:S.label}):a(`deviceDisplay.inheritedRoleDefault`,{icon:S.label,role:x.label}),w=t===null?``:qn(t,i).label;return s(`div`,{className:`mt-3 divide-y divide-border border-t border-border`,children:[v(fp,{label:a(`deviceDisplay.icon`),value:v(bp,{deviceName:e.name,value:n.icon,inheritedIcon:S.icon,inheritedLabel:C,disabled:!1,onChange:e=>r({icon:e})})}),u&&v(fp,{label:a(`deviceDisplay.label`),value:v(U,{type:`text`,className:xp,"aria-label":a(`deviceDisplay.label`),placeholder:t===null?e.name:w,value:n.label,onChange:e=>r({label:e.target.value})})}),l&&s(j,{children:[v(fp,{label:a(`deviceDisplay.unit`),value:v(Gn,{dimension:m,value:n.unit,onChange:e=>r({unit:e}),disabled:!1,"aria-label":a(`deviceDisplay.unit`),inheritLabel:a(`deviceDisplay.unitSource`,{unit:p===void 0?``:` (${p})`}),emptyReason:a(`deviceDisplay.unitSource`,{unit:``})})}),v(fp,{label:a(`deviceDisplay.precision`),value:v(yp,{"aria-label":a(`deviceDisplay.precision`),placeholder:a(`deviceDisplay.precisionInherit`),value:n.precision,onChange:e=>r({precision:e}),disabled:!1})})]}),t!==null&&v(`div`,{className:`px-3 sm:px-4 py-2`,children:v(W,{type:`button`,variant:`outline`,size:`sm`,onClick:_,disabled:g.isPending,title:a(`deviceDisplay.setRoleDefaultTitle`,{role:w}),children:a(`deviceDisplay.setRoleDefault`,{role:w})})})]})}var wp=new Set(Object.values(K));function Tp(e){return wp.has(e)}var Ep={[q.Switch]:[K.Siren,K.Floodlight,K.Spotlight,K.PirSensor,K.Chime,K.Autotrack,K.Nightvision,K.PrivacyMask,K.BinaryHelper,K.SwitchHeater,K.SwitchFan,K.SwitchLight],[q.Climate]:[K.ClimateThermostat,K.ClimateAc,K.ClimateFloor,K.ClimateRadiator,K.ClimateHeater,K.ClimateHeatPumpCircuit,K.ClimateVehicle],[q.Lock]:[K.LockVehicle],[q.MediaPlayer]:[K.MediaPlayerTv],[q.Light]:[K.Floodlight,K.Spotlight,K.Nightvision],[q.Siren]:[K.Siren],[q.Button]:[K.Doorbell],[q.Cover]:[K.CoverBlind,K.CoverShutter,K.CoverAwning,K.CoverCurtain,K.CoverGarage,K.CoverGate,K.CoverDoor,K.CoverWindow],[q.Sensor]:[K.MotionSensor,K.ContactSensor,K.LeakSensor,K.SmokeSensor,K.COSensor,K.GasSensor,K.TamperSensor,K.VibrationSensor,K.ConnectivitySensor,K.SoundSensor,K.BinarySensor,K.TemperatureSensor,K.HumiditySensor,K.AmbientLightSensor,K.PressureSensor,K.WindSensor,K.RainSensor,K.UvSensor,K.SolarRadiationSensor,K.SoilMoistureSensor,K.PowerSensor,K.EnergySensor,K.VoltageSensor,K.CurrentSensor,K.AirQualitySensor,K.AmbientMonitor,K.BatterySensor,K.NumericSensor,K.EnumSensor,K.DateTimeSensor,K.GenericSensor],[q.Control]:[K.NumericControl,K.SelectControl,K.TextControl,K.DateTimeControl],[q.Notifier]:[K.MobilePushNotifier,K.MessagingNotifier,K.EmailNotifier,K.GenericNotifier],[q.Workload]:[...Ht]};function Dp(e){for(let t of Object.values(q))if(t===e)return!0;return!1}function Op(e){return Dp(e)?Ep[e]??[]:[]}function kp(e,t){let n=Op(t);return e==null||e===``||n.includes(e)?n:[...n,e]}function Ap({device:e,basic:t=!1,readOnly:n=!1}){let{t:r}=Z(),i=ye(),a=sp(),o=Ja(),c=a?.identity??null,l=c?.name??e.name,u=c?.location??e.location??``,d=c?.role??e.role??null,f=c?.tags??e.tags??[],p=c?.display.hidden??e.display?.hidden===!0,m=a!==null&&c!==null&&!n;return s(`section`,{"aria-label":r(`customize.identity.title`),className:`${ge} ${ne}`,children:[s(`div`,{className:t?`grid grid-cols-1 gap-3 sm:grid-cols-3`:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-4`,children:[m?v(pp,{deviceId:e.id,initialName:l,label:r(`customize.identity.name`),layout:`stacked`,bound:{value:l,onChange:a.setIdentityName}}):v(fp,{label:r(`customize.identity.name`),layout:`stacked`,value:l}),m?v(mp,{deviceId:e.id,initialLocation:u,label:r(`customize.identity.room`),layout:`stacked`,bound:{value:u,onChange:a.setIdentityLocation}}):v(fp,{label:r(`customize.identity.room`),layout:`stacked`,value:u===``?r(`common.unset`):u}),t?null:s(j,{children:[v(fp,{label:r(`common.tags`,`Tags`),layout:`stacked`,value:m?v(Ki,{value:f,onChange:a.setIdentityTags,label:r(`common.tags`,`Tags`)}):f.length>0?v(oa,{tags:f,entries:o.entries}):r(`common.unset`)}),v(fp,{label:r(`customize.identity.type`),layout:`stacked`,value:e.type}),v(fp,{label:r(`customize.identity.hidden`),layout:`stacked`,value:v(Dt,{"aria-label":r(`deviceDisplay.hideFromLists`),checked:p,disabled:!m,onChange:e=>a?.setIdentityDisplay({hidden:e.target.checked})})})]}),v(fp,{label:r(`customize.identity.role`),layout:`stacked`,value:m?v(Ke,{"aria-label":r(`customize.identity.role`),value:d??``,options:[{value:``,label:r(`customize.identity.noRole`)},...kp(d,e.type).map(e=>({value:e,label:jp(e,r(`customize.identity.noRole`),i)}))],onChange:e=>a.setIdentityRole(e.target.value===``?null:e.target.value)}):v(`span`,{children:jp(d,r(`customize.identity.noRole`),i)})})]}),!t&&!n&&c!==null&&a!==null&&v(Cp,{device:e,role:d,display:c.display,onChange:a.setIdentityDisplay})]})}function jp(e,t,n){return e==null||e===``?t:Tp(e)?qn(e,n).label:e}var Mp={streaming:{icon:nt,labelKey:`capabilityBadges.streaming`},detection:{icon:we,labelKey:`capabilityBadges.detection`},recording:{icon:Qe,labelKey:`capabilityBadges.recording`},audio:{icon:R,labelKey:`capabilityBadges.audio`},snapshot:{icon:xe,labelKey:`capabilityBadges.snapshot`},motion:{icon:Ne,labelKey:`capabilityBadges.motion`},ptz:{icon:dt,labelKey:`capabilityBadges.ptz`},webrtc:{icon:$e,labelKey:`capabilityBadges.webrtc`},onvif:{icon:ze,labelKey:`capabilityBadges.onvif`},analytics:{icon:Ce,labelKey:`capabilityBadges.analytics`},"battery-operated":{icon:yt,labelKey:`capabilityBadges.battery`},"native-snapshot":{icon:xe,labelKey:`capabilityBadges.nativeSnapshot`},"pan-tilt-zoom":{icon:dt,labelKey:`capabilityBadges.ptz`},"two-way-audio":{icon:R,labelKey:`capabilityBadges.twoWayAudio`},"doorbell-button":{icon:L,labelKey:`capabilityBadges.doorbell`},rebootable:{icon:et,labelKey:`capabilityBadges.rebootable`},"vacuum-has-ai":{icon:At,labelKey:`capabilityBadges.aiObstacle`},"mower-has-targeted-mowing":{icon:ie,labelKey:`capabilityBadges.targetedMowing`}},Np=le;function Pp({capabilities:e,showLabels:t=!1}){let{t:n}=Z();return v(`div`,{className:`flex items-center gap-1 flex-wrap`,children:e.map(e=>{let r=Mp[e],i=r?.icon??Np,a=r?n(r.labelKey):e;return s(`span`,{className:`inline-flex items-center gap-1 rounded-md bg-surface-hover px-1.5 py-0.5 text-[10px] text-foreground-subtle`,title:a,children:[v(i,{className:`h-3 w-3`}),t&&v(`span`,{children:a})]},e)})})}var Fp=`customize`,Ip=`/build/compositions/new`,Lp=`/build/compositions/:blockId`,Rp=`/build?tab=custom-device`;function zp(e){return`/devices/${e}`}function Bp(e){return`/devices/${e}?tab=${Fp}`}function Vp(e){return`/build/compositions/${encodeURIComponent(e)}`}var Hp=`template`,Up=`terminalId`;function Wp(e){return`/build?${new URLSearchParams({tab:`custom-device`,new:`helper`,[Hp]:`terminal`,[Up]:e}).toString()}`}T();function Gp(e,t){return e.kind===`same-device`?`same-device`:e.a.deviceId===t?`powers`:`powered-by`}function Kp(e){if(!e.ok)throw Error(e.message);return e.link}function qp(e){return e.filter(e=>e.state!==`dismissed`)}function Jp(e){return e.filter(e=>e.state===`dismissed`)}function Yp({deviceId:e}){let{t}=Z(),n=pr({deviceId:e}),r=v(`div`,{className:`px-3 sm:px-4 py-1.5 text-[10px] text-foreground-subtle border-y border-border`,children:t(`overviewAdapters.identityLinks.header`,`Linked devices, matched on the identifiers above.`)});if(n.error)return s(j,{children:[r,v(`p`,{className:`px-3 sm:px-4 py-2 text-xs text-foreground-muted`,children:t(`overviewAdapters.identityLinks.unavailable`,`Linked devices could not be read.`)})]});if(n.data===void 0)return s(j,{children:[r,v(`div`,{className:`px-3 sm:px-4 py-2`,"data-testid":`identity-links-pending`,children:v(zi,{className:`h-4 w-1/2`})})]});if(n.data.status===`not-loaded`)return s(j,{children:[r,v(`p`,{className:`px-3 sm:px-4 py-2 text-xs text-foreground-muted`,children:t(`overviewAdapters.identityLinks.notLoaded`,`Linked devices are not read yet.`)})]});let i=qp(n.data.links),a=Jp(n.data.links);return s(j,{children:[r,i.length===0?v(`p`,{className:`px-3 sm:px-4 py-2 text-xs text-foreground-muted`,children:t(`overviewAdapters.identityLinks.none`,`No linked devices.`)}):v(`div`,{className:`divide-y divide-border`,children:i.map(t=>v(Xp,{link:t,deviceId:e},t.id))}),a.length>0&&v(`div`,{className:`divide-y divide-border`,"data-testid":`identity-links-dismissed`,children:a.map(t=>v(Xp,{link:t,deviceId:e},t.id))})]})}function Xp({link:e,deviceId:t}){let{t:n}=Z(),r=e.a.deviceId===t?e.b:e.a,{data:i}=Kn({deviceId:r.deviceId}),a=O(),o={onSuccess:()=>void a.invalidateQueries({queryKey:[[`deviceManager`]]})},c=da(o),l=Yr(o),u=Fi(o),d=ir(o),f={"same-device":n(`overviewAdapters.identityLinks.sameDevice`,`Same device`),"powered-by":n(`overviewAdapters.identityLinks.poweredBy`,`Powered by`),powers:n(`overviewAdapters.identityLinks.powers`,`Powers`)},[p,m]=x(null),h=e=>{m(null),e.then(Kp).catch(e=>{m(e instanceof Error?e.message:String(e))})},g=i?.name??`#${r.deviceId}`,_=e.state===`proposed`,y=e.state===`dismissed`;return v(fp,{label:f[Gp(e,t)],value:s(`div`,{className:`flex flex-wrap items-center gap-2 min-w-0`,children:[v(vo,{to:zp(r.deviceId),className:`text-primary hover:underline truncate`,children:g}),_&&v(`span`,{className:`text-[11px] text-warning`,children:n(`overviewAdapters.identityLinks.proposed`,`Suggested`)}),e.evidenceGone===!0&&v(`span`,{className:`text-[11px] text-foreground-subtle`,children:n(`overviewAdapters.identityLinks.evidenceGone`,`No longer matched`)}),y&&v(`span`,{className:`text-[11px] text-foreground-subtle`,children:n(`overviewAdapters.identityLinks.dismissedState`,`Unlinked`)}),v(`span`,{className:`ml-auto flex gap-1.5`,children:y?v(W,{size:`sm`,variant:`outline`,disabled:d.isPending,onClick:()=>h(d.mutateAsync({linkId:e.id})),children:n(`overviewAdapters.identityLinks.relink`,`Relink`)}):_?s(j,{children:[v(W,{size:`sm`,disabled:c.isPending,onClick:()=>h(c.mutateAsync({linkId:e.id})),children:n(`overviewAdapters.identityLinks.confirm`,`Confirm`)}),v(W,{size:`sm`,variant:`outline`,disabled:l.isPending,onClick:()=>h(l.mutateAsync({linkId:e.id})),children:n(`overviewAdapters.identityLinks.dismiss`,`Dismiss`)})]}):v(yr,{size:`sm`,label:n(`overviewAdapters.identityLinks.unlink`,`Unlink`),title:n(`overviewAdapters.identityLinks.unlinkTitle`,`Unlink these devices?`),description:n(`overviewAdapters.identityLinks.unlinkBody`,`The link is removed and not suggested again. Anything it added in Customize is removed with it.`),action:async()=>Kp(await u.mutateAsync({linkId:e.id}))})}),p!==null&&v(`span`,{className:`basis-full text-[11px] text-danger`,children:p})]})})}T();function Zp({deviceId:e}){let{t}=Z(),n=O(),{data:r}=_s(e),{data:i}=gs(e),[a,o]=x(null),c=ea({onSuccess:()=>{o(null),n.invalidateQueries({queryKey:[[`deviceManager`]]})},onError:e=>{o(`Could not change primary child: ${e.message}`)}});if(r==null)return null;let l=String(r.type??``);if(l!==q.Container)return null;let u=String(r.name??``),d=(i??[]).map(e=>({id:e.id,stableId:e.stableId,type:e.type,name:Nr(e,u),...e.sourceInfo?{sourceInfo:{id:e.sourceInfo.id}}:{}}));if(d.length<=1)return null;let f=Un(d,typeof r.linkDeviceId==`number`?r.linkDeviceId:null,typeof r.primaryChildEntityId==`string`?r.primaryChildEntityId:null,l,Wt(r)),p=f===null?d[0].id:f.id;return s(j,{children:[v(fp,{label:t(`shared.primaryChildRow.primaryChild`,`Primary child`),value:v(Jr,{childrenList:d,selectedId:p,onSetPrimary:t=>c.mutate({deviceId:e,primaryChildEntityId:t}),disabled:c.isPending})}),a!==null&&v(`p`,{role:`alert`,className:`px-3 sm:px-4 py-1.5 text-[11px] text-danger`,children:a})]})}T();var Qp=[`manufacturer`,`model`,`hardware`,`firmware`,`serialNumber`,`uid`,`mac`,`itemNo`],$p=[`mac`,`serial`,`vendor-uid`,`machine-uuid`,`hostname`,`ip`];function em(e){let t=Jt.safeParse(e);if(!t.success)return[];let n=t.data;return $p.flatMap(e=>{if(e===`mac`)return(n.mac??[]).map(t=>({key:e,value:t.value,derived:t.origin===`derived`}));let t=n[e];return t?[{key:e,value:t.value,derived:t.origin===`derived`}]:[]})}function tm(e){return e.replace(/([a-z])([A-Z])/g,`$1 $2`).replace(/^./,e=>e.toUpperCase())}function nm(e){return e==null?`—`:typeof e==`string`||typeof e==`number`||typeof e==`boolean`?String(e):JSON.stringify(e)}function rm(){let{t:e}=Z(),t=cr(),n=ei(),{data:r}=Kn({deviceId:t??0},{enabled:t!==null}),{data:i}=Ga({deviceId:t??0},{enabled:t!==null}),{data:a}=pr({deviceId:t??0},{enabled:t!==null}),o=r??n??null,[c,l]=x(`identity`);if(t===null||!o)return null;let u=String(o.stableId??``),d=String(o.addonId??``),f=typeof o.integrationId==`string`&&o.integrationId.length>0?o.integrationId:null,p=typeof o.parentDeviceId==`number`?o.parentDeviceId:null,m=o.features??[],h=new Set([`device-status`,`feature-probe`,`device-ops`]),g=(i?.entries??[]).filter(e=>e.kind===`native`&&!h.has(e.capName)).map(e=>e.capName),_=m.length>0?m:g,y=o.metadata??null,b=em(o.identifiers),S=a?.status===`answered`&&qp(a.links).length>0,C=y!==null&&Object.keys(y).length>0||b.length>0||S;return s(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[s(`div`,{className:`border-b border-border px-3 sm:px-4 py-2 flex items-center justify-between gap-3`,children:[v(`h2`,{className:`text-[11px] font-semibold text-foreground uppercase tracking-wider`,children:e(`overviewAdapters.deviceInfoAdapter.deviceInfo`,`Device Info`)}),C&&s(`div`,{className:`flex items-center gap-1 rounded-md bg-surface-hover p-0.5`,children:[v(im,{active:c===`identity`,onClick:()=>l(`identity`),label:e(`overviewAdapters.deviceInfoAdapter.identity`,`Identity`)}),v(im,{active:c===`hardware`,onClick:()=>l(`hardware`),label:e(`overviewAdapters.deviceInfoAdapter.hardware`,`Hardware`)})]})]}),(!C||c===`identity`)&&s(`div`,{className:`divide-y divide-border`,children:[v(fp,{label:`ID`,value:s(`span`,{className:`font-mono text-[11px] text-foreground`,children:[`#${t}`,s(`span`,{className:`ml-1.5 text-foreground-subtle`,children:[`(`,u,`)`]})]})}),v(Zp,{deviceId:t}),f!==null&&v(fp,{label:e(`overviewAdapters.deviceInfoAdapter.integration`,`Integration`),value:v(`span`,{className:`font-mono text-[11px]`,children:f})}),p!==null&&v(fp,{label:e(`overviewAdapters.deviceInfoAdapter.parent`,`Parent`),value:v(`span`,{className:`font-mono text-[11px]`,children:`#${String(p)}`})}),v(fp,{label:e(`overviewAdapters.deviceInfoAdapter.provider`,`Provider`),value:v(sf,{type:d,size:`sm`,showLabel:!0})}),v(fp,{label:e(`overviewAdapters.deviceInfoAdapter.capabilities`,`Capabilities`),value:_.length>0?v(Pp,{capabilities:_,showLabels:!0}):v(`span`,{className:`text-[11px] text-foreground-subtle`,children:e(`overviewAdapters.deviceInfoAdapter.none`,`None`)})})]}),C&&c===`hardware`&&v(am,{deviceId:t,metadata:y??{},identifiers:b})]})}function im({active:e,onClick:t,label:n}){return v(W,{variant:`unstyled`,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 am({deviceId:e,metadata:t,identifiers:n}){let{t:r}=Z(),i={mac:r(`overviewAdapters.deviceInfoAdapter.identifierMac`,`MAC address`),serial:r(`overviewAdapters.deviceInfoAdapter.identifierSerial`,`Serial number`),"vendor-uid":r(`overviewAdapters.deviceInfoAdapter.identifierVendorUid`,`Vendor ID`),"machine-uuid":r(`overviewAdapters.deviceInfoAdapter.identifierMachineUuid`,`Machine UUID`),hostname:r(`overviewAdapters.deviceInfoAdapter.identifierHostname`,`Hostname`),ip:r(`overviewAdapters.deviceInfoAdapter.identifierIp`,`IP address`)},a=Qp.filter(e=>e in t),o=Object.keys(t).filter(e=>!Qp.includes(e)).toSorted(),c=[...a,...o];return s(`div`,{children:[v(`div`,{className:`px-3 sm:px-4 py-1.5 text-[10px] text-foreground-subtle border-b border-border`,children:r(`overviewAdapters.deviceInfoAdapter.autoPopulatedByTheDriver`,`Auto-populated by the driver on every connect. Read-only.`)}),v(`div`,{className:`divide-y divide-border`,children:c.map(e=>v(fp,{label:tm(e),value:v(`span`,{className:`font-mono text-[11px] text-foreground break-all`,children:nm(t[e])})},e))}),n.length>0&&s(j,{children:[v(`div`,{className:`px-3 sm:px-4 py-1.5 text-[10px] text-foreground-subtle border-y border-border`,children:r(`overviewAdapters.deviceInfoAdapter.identifiersDeclared`,`Identifiers declared by the provider. Read-only.`)}),v(`div`,{className:`divide-y divide-border`,children:n.map(e=>v(fp,{label:i[e.key],value:s(`span`,{className:`font-mono text-[11px] text-foreground break-all`,children:[e.value,e.derived&&v(`span`,{className:`ml-1.5 text-foreground-subtle`,children:r(`overviewAdapters.deviceInfoAdapter.identifierDerived`,`(derived)`)})]})},`${e.key}:${e.value}`))})]}),v(Yp,{deviceId:e})]})}function om(e){return(t,n,r)=>e(t,{...typeof n==`string`?{defaultValue:n}:{defaultValue_one:n.one,defaultValue_other:n.other},...r})}var sm=(e,t,n)=>om(X.t.bind(X))(e,t,n);function cm(e,t){return e===`present`&&t.status===`ok`&&(t.data?.length??0)>0}function lm(e){return sa(G().trpcClient,e)}var um=15e3,dm={rows:[],unreadableCount:0};function fm(e){let t=G(),n=e.length>0,r=[...e].sort((e,t)=>e-t),{data:i,isLoading:a}=C({queryKey:[`stationary-objects`,r],enabled:n,staleTime:um,refetchInterval:um,queryFn:async()=>{let e=await t.trpcClient.zoneAnalytics.getCurrentSnapshotBatch.query({deviceIds:r}),n=[],i=0;for(let t of e){if(t.read===`unreadable`){i++;continue}for(let e of t.snapshot?.stationaryObjects??[])n.push({...e,deviceId:t.deviceId})}return{rows:n,unreadableCount:i}}}),o=i??dm;return{rows:o.rows.toSorted((e,t)=>t.becameStationaryAt-e.becameStationaryAt),isLoading:n&&a,unreadableCount:o.unreadableCount}}T();function pm(e){let[t,n]=x(`idle`),[r,i]=x(null),a=d(null),o=d(null),s=d(null),c=d(!0),l=ci(),u=di(),f=gi(),p=_(()=>{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},[]),m=_(async()=>{if(t===`idle`)return;n(`stopping`);let r=s.current;if(r&&e!==null)try{await Promise.race([f.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)}p(),c.current&&(n(`idle`),i(null))},[t,e,f,p]),h=_(async()=>{if(e===null||t!==`idle`&&t!==`error`)return;i(null);let r=null,d=null,p=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});p=t.sessionId,s.current=p,n(`connecting`),d=new RTCPeerConnection,a.current=d,d.oniceconnectionstatechange=()=>{if(!c.current)return;let e=d.iceConnectionState;e===`connected`||e===`completed`?n(`talking`):(e===`failed`||e===`closed`||e===`disconnected`)&&c.current&&(i(e===`failed`?`WebRTC connection failed`:null),m())};for(let e of r.getAudioTracks())d.addTrack(e,r);await d.setRemoteDescription({type:`offer`,sdp:t.sdpOffer});let f=await d.createAnswer();await d.setLocalDescription(f);let h=d.localDescription?.sdp??f.sdp??``;await u.mutateAsync({deviceId:e,sessionId:p,sdpAnswer:h})}catch(t){let l=t instanceof Error?t.message:String(t);if(console.warn(`[intercom] start failed`,t),d)try{d.close()}catch{}if(r)for(let e of r.getTracks())try{e.stop()}catch{}if(a.current=null,o.current=null,p!==null)try{await f.mutateAsync({deviceId:e,sessionId:p})}catch{}s.current=null,c.current&&(i(l),n(`error`))}},[e,t,l,u,f,m]);return y(()=>(c.current=!0,()=>{c.current=!1;let t=s.current;if(t!==null&&e!==null&&f.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:h,stop:m,isTalking:t===`talking`}}T();var mm=0;function hm(){return++mm}function gm(e){switch(e.type){case`system`:return`system`;case`device`:return`#${e.deviceId}`;case`provider`:return e.providerId;case`addon`:return e.addonId}}function _m(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 vm(e){switch(e.type){case`device`:return[``,`── State (sync, zero round-trip) ─────────────────────────`,` device.state.battery.value`,` device.state.battery.value?.level`,` 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.level < 20).length`,` sm.mapState('battery', s => s.level)`,` 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 ym(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.level < 20)`,` sm.mapState('battery', s => s.level)`,` 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?.level`,` device.state.motion.value?.detected`,` device.state.switch.value?.on`,` device.state.brightness.value?.level`,` 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({ level: 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 bm({scope:e,greeting:t,className:n}){let{t:r}=Z(),i=G(),[a,o]=x(()=>{let n=[];return t&&n.push({id:hm(),kind:`info`,text:t}),n.push({id:hm(),kind:`info`,text:`scope: ${gm(e)} — type help or context for available commands`}),n}),[c,l]=x(``),[u,f]=x([]),[p,m]=x(-1),h=d(null),g=d(null);y(()=>{let e=g.current;e&&(e.scrollTop=e.scrollHeight)},[a]);let b=_(()=>{h.current?.focus()},[]),S=k({mutationFn:t=>i.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`;o(e=>[...e,{id:hm(),kind:r?`error`:`result`,text:n}])},onError:e=>{let t=e instanceof Error?e.message:String(e);o(e=>[...e,{id:hm(),kind:`error`,text:t}])}});function C(t){let n=t.trim();if(n){if(n===`clear`){o([{id:hm(),kind:`info`,text:`scope: ${gm(e)}`}]),l(``);return}if(n===`help`){o(t=>[...t,{id:hm(),kind:`input`,text:`> ${n}`},..._m(e).map(e=>({id:hm(),kind:`info`,text:e}))]),l(``);return}if(n===`context`){o(t=>[...t,{id:hm(),kind:`input`,text:`> ${n}`},...ym(e).map(e=>({id:hm(),kind:`info`,text:e}))]),l(``);return}if(n===`examples`){o(t=>[...t,{id:hm(),kind:`input`,text:`> ${n}`},...vm(e).map(e=>({id:hm(),kind:`info`,text:e}))]),l(``);return}f(e=>[...e,n]),m(-1),o(e=>[...e,{id:hm(),kind:`input`,text:`> ${n}`}]),l(``),S.mutate(n)}}function w(t){if(t.key===`Enter`){t.preventDefault(),C(c);return}if(t.key===`ArrowUp`){if(t.preventDefault(),u.length===0)return;let e=p===-1?u.length-1:Math.max(0,p-1);m(e),l(u[e]??``);return}if(t.key===`ArrowDown`){if(t.preventDefault(),p===-1)return;let e=p+1;e>=u.length?(m(-1),l(``)):(m(e),l(u[e]??``));return}t.ctrlKey&&t.key===`l`&&(t.preventDefault(),o([{id:hm(),kind:`info`,text:`scope: ${gm(e)}`}]))}let T={input:`text-zinc-300`,result:`text-emerald-300`,error:`text-red-300`,info:`text-zinc-400`};return s(`div`,{className:`flex flex-col bg-[#0c0a09] rounded-lg border border-border overflow-hidden font-mono text-xs ${n??``}`,onClick:b,children:[s(`div`,{ref:g,className:`flex-1 overflow-y-auto p-3 space-y-1 min-h-[120px]`,children:[a.map(e=>v(`pre`,{className:`whitespace-pre-wrap break-words leading-relaxed ${T[e.kind]}`,children:e.text},e.id)),S.isPending&&v(`span`,{className:`text-zinc-500 animate-pulse`,children:r(`shared.replTerminal.thinking`,`…thinking`)})]}),s(`div`,{className:`flex items-center gap-2 border-t border-zinc-800 px-3 py-2 bg-[#0c0a09]`,children:[v(`span`,{className:`text-emerald-400 flex-shrink-0 select-none font-bold`,children:r(`shared.replTerminal.text`,`>`)}),v(U,{ref:h,value:c,onChange:e=>l(e.target.value),onKeyDown:w,disabled:S.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 xm(e,t){return e===null?null:{playbackUrl:e.url,...e.format===void 0?{}:{playbackFormat:e.format},playbackAuthToken:t,...e.label===void 0?{}:{playbackLabel:e.label}}}function Sm(e){return{frame:e.filter(e=>e.placement!==`image`),image:e.filter(e=>e.placement===`image`)}}function Cm(e){return e.length===0?null:v(j,{children:e.map(e=>v(`div`,{className:`absolute inset-0`,children:e.node},e.id))})}T();function wm({deviceId:e,intercomAvailable:t=!1,stillFirst:n=!1}){let r=G(),i=typeof window<`u`?it():``,a=Number.isFinite(e),o=ai(a?e:null),s=lm(a?e:null),c=fm(a?[e]:[]),l=f(()=>{if(!a)return;let e=[];for(let t of c.rows){let n=Mi(t);n!==null&&e.push(n)}return e},[a,c.rows]),{streams:u,pipelineMetrics:d,createSession:p,sendAnswer:m,handleOffer:h,getIceServers:g,addIceCandidate:_,getIceCandidates:y,closeSession:b,getSessionState:x,applyDownlinkProbe:S}=ti(r.trpcClient,a?e:null),C=z(a?e:null,{width:km}),w=pm(a&&t?e:null),T=w.state===`requesting-mic`||w.state===`starting`||w.state===`connecting`||w.state===`stopping`,E=w.isTalking||T,D=()=>{w.state===`idle`||w.state===`error`?w.start():w.state!==`stopping`&&w.stop()},O=gt(),k=na(),A=typeof window<`u`?window.localStorage.getItem(`dominevo_admin_token`):null,j=xm(k.request,A),{frame:M,image:N}=Sm(O),P=Cm(M),F=Cm(N);return v(fr,{serverUrl:i,createSession:p,sendAnswer:m,handleOffer:h,getIceServers:g,addIceCandidate:_,getIceCandidates:y,closeSession:b,getSessionState:x,applyDownlinkProbe:S,...j===null?{}:{...j,onExitPlayback:()=>k.clear()},streams:u,pipelineMetrics:d,phase:s.phase,detections:s,...l===void 0?{}:{stationaryObjects:l},defaultShowDetections:!n,defaultShowMotion:!n,...n?{detectionsOnSnapshot:!0,snapshotDownloadName:`snapshot-${String(e)}.jpg`}:{},...a&&o===`present`?{zonesOverlay:v(Hn,{deviceId:e})}:{},showPlayStop:!0,snapshotSrc:C.src,...C.src?{posterUrl:C.src}:{},snapshotLoading:C.loading,onRefreshSnapshot:C.refresh,intercomAvailable:t,intercomShown:E,onIntercomToggle:D,extraOverlay:P,...F===null?{}:{imageExtraOverlay:F},chromeless:!0,className:`h-full`})}function Tm({deviceId:e,containerDeviceId:t}){let{t:n}=Z();return Number.isFinite(e)?v(`div`,{className:`flex flex-col h-full`,children:v(Wa,{...t===void 0?{deviceId:e}:{containerDeviceId:t},limit:50,maxHeight:`max-h-full`,showScope:!1,showFilters:!1})}):v(`div`,{className:`flex items-center justify-center h-full text-[11px] text-foreground-subtle italic`,children:n(`device.panelContent.notLoaded`,{id:e})})}function Em({deviceId:e}){let{t}=Z();if(!Number.isFinite(e))return v(`div`,{className:`flex items-center justify-center h-full text-[11px] text-foreground-subtle italic`,children:t(`device.panelContent.notLoaded`,{id:e})});let n=[`Dominevo 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(`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./Devices-Dv9L-Kji.js","./player-overlays-Cs69NgAR.js","./chevron-down-CBb-F8DT.js","./src-BwDSKCnh.js","./compat-muhdrMna.js","./src-Bb9LsNcW.js","./useTranslation-uIxPZ_3N.js","./chunk-4ZMWKKQ3-BCeNTgXs.js","./AdminPage-Bd8R8RtF.js","./device-integration-icon-C9zQRrG0.js","./useAdminDeviceRemoval-C6mofiow.js","./useEventInvalidation-Bi7qSGNi.js","./addon-kind-filter-CEGKkC1O.js","./Integrations-ClCrv1nX.js","./i18n-kurEJu5K.js","./table-2-DMxm3oyu.js","./IntegrationDetail-CXJ4DIj2.js","./search-x-C5ra3Aft.js","./FormBuilder-TrrVPEZX.js","./Pipeline-D6QSFY4L.js","./terminal-BncJ-1sF.js","./usb-P4R9CjYI.js","./crop-B-t0rzRY.js","./layers-BH9u1mrE.js","./NodeAddonsSettingsPanel-BvlLXdhN.js","./settings-section-shape-DbQZZpNL.js","./step-inspector-model-B-1rSpjV.js","./board-model-BJOCdYZi.js","./useDevice-B_IWTz7U.js","./DeviceDetail-BxkGFnI2.js","./divide-Bmm9r7CP.js","./circle-slash-Duh934sZ.js","./scan-eye-C862nWtV.js","./shapes-D4IRNSXI.js","./file-up-2YD_M6f_.js","./unlink-D3-IGpS8.js","./CompositionBlockEditor-Kc1vM2A7.js","./camera-block-model-Cg9j-LS6.js","./assignment-candidates-mv6nvb2M.js","./device-picker-model-Bi7qSGNi.js","./TemplateEditorDialog-AIrV7BKf.js","./command-vocab-CiIfJEGh.js","./linked-devices-model-B3xUuhef.js","./format-M1wlEHJl.js","./auth-context-CU5snbq3.js","./mount-Bi7qSGNi.js","./authed-media-BavZM6fk.js","./notification-rule-status-JiMjbzwM.js","./Showroom-DSZ7_JVJ.js","./EmbedPlayerPage-C2A2ZfFZ.js","./EmbedDevicePage-DcLTsAsw.js","./Library-FfhywvlF.js","./user-x-DkWcmF99.js","./square-check-big-DAcFGNUN.js","./AdminSectionedPage-Cwi1kvmM.js","./NewExportModal-weUsUP2K.js","./use-scenes-feed-Cm1QR46I.js","./format-size-DIxKXxtj.js","./Archive-ByC3bXel.js","./scissors-DpiKUioV.js","./StorageLocationsTable-B_3fPv7s.js","./eraser-B3lnG9yK.js","./hard-drive-download-C6N6tovA.js","./InstancesTable-BhClC6c7.js","./link-2-off-DmsjRAt7.js","./broker-oauth-popup-C7Be_Cjq.js","./sso-popup-DVrI_KPY.js","./Viewer-2F_bb_FE.js","./monitor-off-DnOkDa2s.js","./Build-DfH4qlmf.js","./variable-DTEpBbRf.js","./useFaultTypeOptions-DaOrnWNh.js","./CompositionEditorPage-DOy1_xa6.js","./Locations-DKSaqyPH.js","./Addons-Dqwyi0aS.js","./useNodeUrlSelection-ESSKAIP0.js","./AiProfiles-SI2Iyt3F.js","./flask-conical-D7tbJQpj.js","./message-square-plus-_aGccjyj.js","./ai-page.helpers-CH0oD27E.js","./MyAccess-Dq0fJGPb.js","./monitor-smartphone-DPI9EQus.js","./SessionsList-BOKuwFwJ.js","./Logs-C13uuzLz.js","./timer-reset-5221y6Jb.js","./Identity-BzYQSoVB.js","./key-CH4aXNMz.js","./BootstrapSettingsForm-Cy8mCpHP.js","./Network-BVOnr0mt.js","./waypoints-CuxO4XzY.js","./useInvalidateAddonSettings-CyofQfBo.js","./Network-DtxX27Jz.css","./Integrations-B7lFcabS.js","./TrainingProviders-BsfUFtDp.js","./Data-wkMPgPIi.js","./database-zap-DHuELz_w.js","./System-C2tFswFM.js","./ruler-Buxogset.js","./Cluster-Ul0y1bLm.js","./memory-stick-BQrJMbEW.js","./Terminal-CD78nora.js","./Terminal-kHJ-D0s7.css","./Notifications-DF8en3Zl.js","./languages-Du_pOBpX.js","./History-Am70bV1z.js","./Jobs-D9dl7u2u.js","./Calendars-K1Z15Ly2.js"])))=>i.map(i=>d[i]);
2
+ import{a as e,t}from"./rolldown-runtime-Cyuzqnbw.js";import"./virtual_mf-exposes___mfe_internal__admin_ui_host__remoteEntry-_hash_-DnnXQRkG.js";import{a as n,o as r,r as i}from"./virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-B4AKnF2Y.js";import{t as a}from"./vite-preload-helper-kNaey6uv.js";import{A as o,C as s,D as c,F as l,H as u,J as d,K as f,M as p,N as m,O as h,Q as g,R as _,S as v,V as y,X as b,Y as x,Z as S,a as C,d as w,et as T,i as E,k as D,o as O,t as k,u 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-CEyXHAdg.js";import{$n as N,Bi as P,Ci as F,Co as ee,Cr as te,D as ne,Da as re,Di as ie,Dt as ae,Ea as oe,Fa as se,Gi as ce,Gt as I,Ha as le,Hr as ue,Ia as de,It as fe,J as pe,Ja as L,Jr as R,K as z,Kt as me,Lr as B,Lt as he,O as ge,Oa as _e,Oi as ve,Oo as ye,Ot as be,Pa as xe,Q as Se,Qi as Ce,Ri as we,Rr as Te,T as Ee,Ua as De,Un as Oe,Ur as ke,V as Ae,Va as je,Wr as Me,Wt as Ne,X as Pe,Xi as Fe,Xr as Ie,Y as Le,Yt as Re,Zn as ze,Zt as Be,_a as Ve,_n as He,at as V,ba as Ue,bo as We,br as Ge,bt as Ke,ci as qe,da as Je,dt as Ye,ei as Xe,fo as Ze,ga as Qe,gr as $e,hr as et,ht as tt,in as nt,ir as rt,it,jn as at,ka as ot,ki as st,kt as ct,li as lt,mi as ut,nr as dt,oi as H,or as ft,pt,q as mt,qt as ht,r as gt,ri as _t,sr as vt,to as yt,ut as bt,vi as xt,vr as St,wi as Ct,wo as wt,wr as Tt,xn as Et,xo as Dt,xt as U,yt as W,za as Ot,zi as kt,zn as At,zt as G}from"./player-overlays-Cs69NgAR.js";import{Bc as jt,Dl as Mt,Fl as Nt,Il as Pt,Jl as Ft,Jo as It,Mc as K,Ml as Lt,Na as Rt,Nc as q,Nl as zt,Pl as Bt,Qc as Vt,Qr as Ht,Vl as Ut,Zn as Wt,_a as Gt,_c as Kt,a as qt,ba as Jt,d as Yt,ec as Xt,f as Zt,i as Qt,jc as $t,jl as en,l as tn,ms as nn,n as rn,o as an,r as on,s as sn,si as cn,t as ln,u as un,vc as dn,ws as fn,xl as pn}from"./src-BwDSKCnh.js";import{t as mn}from"./chevron-down-CBb-F8DT.js";import{a as hn,c as gn,d as _n,f as vn,g as yn,h as bn,i as xn,l as Sn,m as Cn,n as wn,o as Tn,p as En,r as Dn,s as On,t as kn,u as An}from"./terminal-BncJ-1sF.js";import{$a as jn,$c as Mn,$i as Nn,$o as Pn,$t as Fn,Ac as In,Am as Ln,Ar as Rn,Ba as zn,Bf as Bn,Bl as Vn,Br as Hn,Bt as Un,Ci as Wn,D as Gn,Dc as Kn,Dm as qn,Do as Jn,Ei as Yn,Em as Xn,Er as Zn,Fc as Qn,Fm as $n,Fn as er,Fo as tr,Fs as nr,Ft as rr,Gc as ir,Gi as ar,Gr as or,Gt as sr,Ha as cr,Hi as lr,Hl as ur,Ht as dr,I as fr,Ic as pr,If as mr,Il as hr,Im as gr,In as _r,Io as vr,Ir as yr,Ja as br,Ji as xr,Jp as Sr,K as Cr,Ki as wr,Kl as Tr,Kt as Er,La as Dr,Lf as Or,Ln as kr,Ls as Ar,Lt as jr,Mc as Mr,Mt as Nr,Nr as Pr,Oc as Fr,Om as Ir,Or as Lr,Ou as Rr,Pa as zr,Qc as Br,Qn as Vr,Qo as Hr,Qt as Ur,Ra as Wr,Ri as Gr,Rl as Kr,Rn as qr,Rt as Jr,Sc as Yr,Sm as Xr,Sr as Zr,St as Qr,Tp as $r,Ua as ei,Ur as ti,Ut as ni,Va as ri,Vp as ii,Vr as ai,Wa as oi,Wc as si,Xl as ci,Xt as li,Yi as ui,Yl as di,Yt as fi,Za as pi,Zc as mi,Zi as hi,Zl as gi,Zo as _i,Zt as vi,_c as yi,_i as bi,_l as xi,_m as Si,_o as Ci,_r as wi,aa as Ti,ac as Ei,al as Di,ao as Oi,bc as ki,bm as Ai,br as ji,c as Mi,cl as Ni,cm as Pi,dl as Fi,do as Ii,ea as Li,en as Ri,eo as zi,es as Bi,et as Vi,eu as Hi,f as Ui,fl as Wi,fu as Gi,g as Ki,gm as qi,gr as Ji,hi as Yi,hm as Xi,hr as Zi,i as Qi,ia as $i,il as ea,j as ta,ja as na,jm as ra,jo as ia,jp as aa,kt as oa,l as sa,li as ca,lo as la,m as ua,mc as da,mi as fa,mm as pa,n as ma,na as ha,nn as ga,nt as _a,nu as va,ol as ya,qa as ba,qf as xa,ql as Sa,qt as Ca,r as wa,ra as Ta,rl as Ea,rm as Da,rn as Oa,ru as ka,sn as Aa,so as ja,st as Ma,ta as Na,tn as Pa,ts as Fa,tu as Ia,ul as La,uo as Ra,vc as za,vi as Ba,vm as Va,vn as Ha,vp as Ua,vr as Wa,wc as Ga,wf as Ka,wm as qa,wt as Ja,xc as Ya,xm as Xa,xo as Za,xr as Qa,yc as $a,ym as eo,yp as to,yr as no,yu as ro,za as io,zc as ao,zf as oo,zn as so,zo as co,zt as lo}from"./src-Bb9LsNcW.js";import{r as uo,t as fo}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare__react_mf_2_dom__loadShare__.js-BPba2g2p.js";import{t as po}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare__react_mf_2_dom_mf_1_client__loadShare__.js-ZBKFTPET.js";import{a as J,c as mo,d as ho,f as go,i as Y,l as _o,n as vo,o as yo,r as bo,s as xo,t as So,u as Co}from"./chunk-4ZMWKKQ3-BCeNTgXs.js";import{n as wo,t as X}from"./i18n-kurEJu5K.js";import{a as To,c as Eo,d as Do,l as Oo,o as ko,r as Ao,s as jo,t as Z,u as Mo}from"./useTranslation-uIxPZ_3N.js";import"./mount-Bi7qSGNi.js";import{a as No,c as Po,d as Fo,i as Io,n as Lo,o as Ro,r as zo,s as Bo,t as Vo,u as Ho}from"./sso-popup-DVrI_KPY.js";import{n as Uo,r as Wo,t as Go}from"./broker-oauth-popup-C7Be_Cjq.js";import{n as Ko,t as qo}from"./FormBuilder-TrrVPEZX.js";import{C as Jo,S as Yo,a as Xo,b as Zo,c as Qo,d as $o,f as es,g as ts,h as ns,i as rs,l as is,m as as,n as os,o as ss,p as cs,r as ls,s as us,t as ds,u as fs,v as ps,x as ms,y as hs}from"./auth-context-CU5snbq3.js";import{n as gs,t as _s}from"./useDevice-B_IWTz7U.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})(),T(),uo();var vs=`dominevo.debugLayers`,ys=/(transform|opacity|filter|perspective)/;function bs(e){return e!==``&&e!==`none`}function xs(e,t,n=120){if(t.width<=0||t.height<=0||t.top>=n||t.bottom<=0)return null;let r=[];e.position===`fixed`&&r.push(`fixed`),e.position===`sticky`&&r.push(`sticky`),(bs(e.backdropFilter)||bs(e.webkitBackdropFilter))&&r.push(`backdrop-filter`),bs(e.filter)&&r.push(`filter`);let i=Number.parseFloat(e.opacity);return Number.isFinite(i)&&i<1&&r.push(`opacity`),bs(e.transform)&&r.push(`transform`),bs(e.perspective)&&r.push(`perspective`),e.isolation===`isolate`&&r.push(`isolation`),e.mixBlendMode!==``&&e.mixBlendMode!==`normal`&&r.push(`mix-blend-mode`),ys.test(e.willChange)&&r.push(`will-change`),r.length===0?null:{reasons:r,zIndex:e.zIndex}}function Ss(e,t,n,r){let i=n!==null&&n!==``?`[${n}]`:t.split(/\s+/).filter(e=>e!==``).slice(0,3).map(e=>`.${e}`).join(``);return`${e.toLowerCase()}${i} z=${r.zIndex} ${r.reasons.join(`+`)}`}function Cs(e,t){let n=new URLSearchParams(e).get(`debugLayers`);return n===`1`?{on:!0,persist:`1`}:n===`0`?{on:!1,persist:null}:{on:t===`1`,persist:`keep`}}var ws=`dominevo.debugLayers.noBlur`,Ts=`dominevo.debugLayers.outlines`,Es=`dominevo.debugLayers.topLayer`,Ds=`debug-no-backdrop-blur`;function Os(e,t){try{return e===null?null:e.getItem(t)}catch{return null}}function ks(e,t,n){try{if(e===null)return;n===null?e.removeItem(t):e.setItem(t,n)}catch{}}function As(e,t){let n=Cs(t,Os(e,vs));n.persist!==`keep`&&ks(e,vs,n.persist);let r={on:n.on,noBlur:Os(e,ws)===`1`,outlines:Os(e,Ts)!==`0`,topLayer:Os(e,Es)!==`0`},i=new Set,a=e=>{r=e;for(let e of i)e()};return{getState:()=>r,subscribe:e=>(i.add(e),()=>{i.delete(e)}),setOn:t=>{if(ks(e,vs,t?`1`:null),!t){ks(e,ws,null),ks(e,Ts,null),ks(e,Es,null),a({on:t,noBlur:!1,outlines:!0,topLayer:!0});return}a({...r,on:t})},setNoBlur:t=>{ks(e,ws,t?`1`:null),a({...r,noBlur:t})},setOutlines:t=>{ks(e,Ts,t?null:`0`),a({...r,outlines:t})},setTopLayer:t=>{ks(e,Es,t?null:`0`),a({...r,topLayer:t})}}}var js=[`transform`,`will-change`,`position`,`backdrop-filter`,`filter`,`opacity`];function Ms(e){return js.map(t=>`${t}: ${e===null?`n/a`:e(t)||`-`}`)}var Ns=null;function Ps(){try{return window.sessionStorage}catch{return null}}function Fs(){return Ns===null&&(Ns=As(Ps(),window.location.search)),Ns}function Is(){let e=Fs();return{...b(e.subscribe,e.getState),setOn:e.setOn,setNoBlur:e.setNoBlur,setOutlines:e.setOutlines,setTopLayer:e.setTopLayer}}T();var Ls=`data-debug-layers`,Rs=250,zs=60;function Bs(){let e=[],t=document.body.querySelectorAll(`*`);for(let n of Array.from(t)){if(e.length>=zs)break;if(n.closest(`[${Ls}]`)!==null)continue;let t=n.getBoundingClientRect();if(t.width<=0||t.height<=0||t.top>=120||t.bottom<=0)continue;let r=getComputedStyle(n),i=xs({position:r.position,zIndex:r.zIndex,opacity:r.opacity,filter:r.filter,backdropFilter:r.backdropFilter,webkitBackdropFilter:r.getPropertyValue(`-webkit-backdrop-filter`),transform:r.transform,perspective:r.perspective,isolation:r.isolation,mixBlendMode:r.mixBlendMode,willChange:r.willChange},t);if(i===null)continue;let a=n.getAttribute(`data-testid`);e.push({id:e.length,top:t.top,left:t.left,width:t.width,height:t.height,label:Ss(n.tagName,typeof n.className==`string`?n.className:``,a===null?null:`data-testid=${a}`,i),reasons:i.reasons})}return e}function Vs(e){let t=getComputedStyle(e),n=e=>Number.parseFloat(e)||0;return{top:n(t.paddingTop),right:n(t.paddingRight),bottom:n(t.paddingBottom),left:n(t.paddingLeft)}}function Hs(e){return e.includes(`backdrop-filter`)||e.includes(`filter`)?{outline:`outline-danger`,chip:`bg-danger`}:e.includes(`opacity`)||e.includes(`mix-blend-mode`)?{outline:`outline-warning`,chip:`bg-warning`}:e.includes(`fixed`)||e.includes(`sticky`)?{outline:`outline-info`,chip:`bg-info`}:{outline:`outline-primary`,chip:`bg-primary`}}function Us(){let e=Reflect.get(navigator,`standalone`);return window.matchMedia(`(display-mode: standalone)`).matches||e===!0}function Ws(){return`0.1.4`}function Gs(e,t){if(!(e===null||typeof e.showPopover!=`function`))try{e.matches(`:popover-open`)&&e.hidePopover(),t&&e.showPopover()}catch{}}function Ks(){let e=document.querySelector(`[data-debug-header]`),t=e===null?null:e.querySelector(`img`),n=e=>Ms(e===null?null:t=>getComputedStyle(e).getPropertyValue(t));return{header:n(e),logo:n(t)}}function qs({noBlur:e,onNoBlurChange:t,outlines:n,onOutlinesChange:r,topLayer:i,onTopLayerChange:a}){let[o,c]=x([]),[l,u]=x({top:0,right:0,bottom:0,left:0}),f=d(null),p=d(null),m=d(null),[h,g]=x(Ks),b=_(()=>{Gs(p.current,i),c(n?Bs():[]),g(Ks()),f.current!==null&&u(Vs(f.current))},[n,i]),S=_(()=>{m.current===null&&(m.current=window.setTimeout(()=>{m.current=null,b()},Rs))},[b]);return y(()=>{b();let e=new MutationObserver(e=>{e.some(e=>!(e.target instanceof Element&&e.target.closest(`[${Ls}]`)!==null))&&S()});return e.observe(document.body,{childList:!0,subtree:!0,attributes:!0}),window.addEventListener(`resize`,S),window.addEventListener(`orientationchange`,S),window.addEventListener(`scroll`,S,!0),()=>{e.disconnect(),window.removeEventListener(`resize`,S),window.removeEventListener(`orientationchange`,S),window.removeEventListener(`scroll`,S,!0),m.current!==null&&window.clearTimeout(m.current)}},[b,S]),fo(s(`div`,{[Ls]:``,ref:p,popover:`manual`,className:`pointer-events-none fixed inset-0 z-[2147483647] m-0 h-full w-full overflow-visible border-0 bg-transparent p-0`,children:[v(`div`,{ref:f,"aria-hidden":!0,className:`invisible absolute h-0 w-0`,style:{paddingTop:`env(safe-area-inset-top)`,paddingRight:`env(safe-area-inset-right)`,paddingBottom:`env(safe-area-inset-bottom)`,paddingLeft:`env(safe-area-inset-left)`}}),o.map(e=>{let t=Hs(e.reasons);return v(`div`,{"data-testid":`debug-layer-box`,className:ee(`absolute outline outline-1 -outline-offset-1`,t.outline),style:{top:e.top,left:e.left,width:e.width,height:e.height},children:v(`span`,{className:ee(`absolute left-0 max-w-[90vw] truncate px-1 font-mono text-[9px] leading-3 text-primary-foreground`,t.chip),style:{top:e.id%6*12},children:e.label})},e.id)}),s(`div`,{"data-testid":`debug-layers-badge`,className:`absolute right-1 top-14 rounded-md bg-background-elevated px-2 py-1 font-mono text-[10px] leading-4 text-foreground outline outline-1 outline-border`,children:[s(`div`,{children:[`admin-ui `,Ws()]}),s(`div`,{children:[`inset t`,l.top,` r`,l.right,` b`,l.bottom,` l`,l.left]}),s(`div`,{children:[`display-mode standalone:`,` `,window.matchMedia(`(display-mode: standalone)`).matches?`yes`:`no`,` · `,`navigator.standalone: `,Us()?`yes`:`no`]}),s(`div`,{children:[window.innerWidth,`x`,window.innerHeight,` · `,o.length,` layers`]}),v(Wn,{checked:e,onCheckedChange:t,label:`no backdrop blur`,className:`pointer-events-auto mt-1 text-[10px]`}),v(Wn,{checked:n,onCheckedChange:r,label:`outlines`,className:`pointer-events-auto mt-1 text-[10px]`}),v(Wn,{checked:i,onCheckedChange:a,label:`top layer`,className:`pointer-events-auto mt-1 text-[10px]`}),s(`div`,{"data-testid":`debug-header-styles`,className:`mt-1`,children:[v(`div`,{children:`header`}),h.header.map(e=>v(`div`,{children:e},e)),v(`div`,{children:`header logo`}),h.logo.map(e=>v(`div`,{children:e},e))]})]})]}),document.body)}function Js(){let{on:e,noBlur:t,setNoBlur:n,outlines:r,setOutlines:i,topLayer:a,setTopLayer:o}=Is();return y(()=>{let n=e&&t;return document.documentElement.classList.toggle(Ds,n),()=>document.documentElement.classList.remove(Ds)},[e,t]),e?v(qs,{noBlur:t,onNoBlurChange:n,outlines:r,onOutlinesChange:i,topLayer:a,onTopLayerChange:o}):null}var Ys=`camera`;function Xs(e){return e===null||!/^\d+$/.test(e)?null:Number(e)}function Zs(e,t){return t===null?e:e.filter(e=>e.deviceId===t)}function Qs(e,t){let n=new Set(e.map(e=>e.deviceId));return t!==null&&n.add(t),[...n].sort((e,t)=>e-t)}var $s=`/archive`,ec=`/addon/training`,tc=`/library?tab=exports`,nc=`section`,rc=`camera`,ic=`view`;function ac(e,t){let n=`${$s}?${nc}=cameras&${rc}=${String(e)}`;return t===void 0?n:`${n}&${ic}=${t}`}function oc(e){return e===void 0?tc:`${tc}&${Ys}=${String(e)}`}var sc={settings:`settings`,space:`health`,health:`health`,events:`review`,review:`review`},cc={storage:$s,events:$s,cameras:$s,exports:tc,activity:`${$s}#activity`,management:`${$s}#tools`},lc=/^\/archive\/(\d+)\/?$/;function uc(e,t){let n=new URLSearchParams(t);if(e===`/recordings`){let e=n.get(`tab`);return e===null?$s:cc[e]??`/archive`}if(e===`/library`&&n.get(`tab`)===`events`)return n.get(`section`)===`retrain`?ec:$s;let r=lc.exec(e);if(r?.[1]!==void 0){let e=Number(r[1]),t=n.get(nc);return t===`exports`?oc(e):ac(e,t===null?void 0:sc[t])}return null}var dc=e(t(((e,t)=>{t.exports={area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0}}))()),fc=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g;function pc(e){var t={type:`tag`,name:``,voidElement:!1,attrs:{},children:[]},n=e.match(/<\/?([^\s]+?)[/\s>]/);if(n&&(t.name=n[1],(dc.default[n[1]]||e.charAt(e.length-2)===`/`)&&(t.voidElement=!0),t.name.startsWith(`!--`))){var r=e.indexOf(`-->`);return{type:`comment`,comment:r===-1?``:e.slice(4,r)}}for(var i=new RegExp(fc),a=null;(a=i.exec(e))!==null;)if(a[0].trim())if(a[1]){var o=a[1].trim(),s=[o,``];o.indexOf(`=`)>-1&&(s=o.split(`=`)),t.attrs[s[0]]=s[1],i.lastIndex--}else a[2]&&(t.attrs[a[2]]=a[3].trim().substring(1,a[3].length-1));return t}var mc=/<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g,hc=/^\s*$/,gc=Object.create(null);function _c(e,t){switch(t.type){case`text`:return e+t.content;case`tag`:return e+=`<`+t.name+(t.attrs?function(e){var t=[];for(var n in e)t.push(n+`="`+e[n]+`"`);return t.length?` `+t.join(` `):``}(t.attrs):``)+(t.voidElement?`/>`:`>`),t.voidElement?e:e+t.children.reduce(_c,``)+`</`+t.name+`>`;case`comment`:return e+`<!--`+t.comment+`-->`}}var vc={parse:function(e,t){t||={},t.components||=gc;var n,r=[],i=[],a=-1,o=!1;if(e.indexOf(`<`)!==0){var s=e.indexOf(`<`);r.push({type:`text`,content:s===-1?e:e.substring(0,s)})}return e.replace(mc,function(s,c){if(o){if(s!==`</`+n.name+`>`)return;o=!1}var l,u=s.charAt(1)!==`/`,d=s.startsWith(`<!--`),f=c+s.length,p=e.charAt(f);if(d){var m=pc(s);return a<0?(r.push(m),r):((l=i[a]).children.push(m),r)}if(u&&(a++,(n=pc(s)).type===`tag`&&t.components[n.name]&&(n.type=`component`,o=!0),n.voidElement||o||!p||p===`<`||n.children.push({type:`text`,content:e.slice(f,e.indexOf(`<`,f))}),a===0&&r.push(n),(l=i[a-1])&&l.children.push(n),i[a]=n),(!u||n.voidElement)&&(a>-1&&(n.voidElement||n.name===s.slice(2,-1))&&(a--,n=a===-1?r:i[a]),!o&&p!==`<`&&p)){l=a===-1?r:i[a].children;var h=e.indexOf(`<`,f),g=e.slice(f,h===-1?void 0:h);hc.test(g)&&(g=` `),(h>-1&&a+l.length>=0||g!==` `)&&l.push({type:`text`,content:g})}}),r},stringify:function(e){return e.reduce(function(e,t){return e+_c(``,t)},``)}};T();var yc=(e,t)=>{if(!e)return!1;let n=e.props?.children??e.children;return t?n.length>0:!!n},bc=e=>{if(!e)return[];let t=e.props?.children??e.children;return e.props?.i18nIsDynamicList?Sc(t):t},xc=e=>Array.isArray(e)&&e.every(p),Sc=e=>Array.isArray(e)?e:[e],Cc=(e,t)=>{let n={...t};return n.props={...t.props,...e.props},n},wc=e=>{let t={};if(!e)return t;let n=e=>{Sc(e).forEach(e=>{Oo(e)||(yc(e)?n(bc(e)):Eo(e)&&!p(e)&&Object.assign(t,e))})};return n(e),t},Tc=(e,t,n,r)=>{if(!e)return``;let i=``,a=Sc(e),o=t?.transSupportBasicHtmlNodes?t.transKeepBasicHtmlNodesFor??[]:[];return a.forEach((e,a)=>{if(Oo(e)){i+=`${e}`;return}if(p(e)){let{props:s,type:c}=e,l=Object.keys(s).length,u=o.indexOf(c)>-1,d=s.children;if(!d&&u&&!l){i+=`<${c}/>`;return}if(!d&&(!u||l)||s.i18nIsDynamicList){i+=`<${a}></${a}>`;return}if(u&&l<=1){let e=Oo(d)?d:Tc(d,t,n,r);i+=`<${c}>${e}</${c}>`;return}let f=Tc(d,t,n,r);i+=`<${a}>${f}</${a}>`;return}if(e===null){Mo(n,`TRANS_NULL_VALUE`,`Passed in a null value as child`,{i18nKey:r});return}if(Eo(e)){let{format:t,...a}=e,o=Object.keys(a);if(o.length===1){let e=t?`${o[0]}, ${t}`:o[0];i+=`{{${e}}}`;return}Mo(n,`TRANS_INVALID_OBJ`,`Invalid child - Object should only have keys {{ value, format }} (format is optional).`,{i18nKey:r,child:e});return}Mo(n,`TRANS_INVALID_VAR`,`Passed in a variable like {number} - pass variables for interpolation as full objects like {{number}}.`,{i18nKey:r,child:e})}),i},Ec=(e,t=[],n={})=>{if(!e)return e;let r=Object.keys(n),i=[...t,...r],a=``,o=0;for(;o<e.length;)if(e[o]===`<`){let t=!1,n=e.slice(o).match(/^<\/(\d+|[a-zA-Z][a-zA-Z0-9_-]*)>/);if(n){let e=n[1];(/^\d+$/.test(e)||i.includes(e))&&(t=!0,a+=n[0],o+=n[0].length)}if(!t){let n=e.slice(o).match(/^<(\d+|[a-zA-Z][a-zA-Z0-9_-]*)(\s+[\w-]+(?:=(?:"[^"]*"|'[^']*'|[^\s>]+))?)*\s*(\/)?>/);if(n){let e=n[1];(/^\d+$/.test(e)||i.includes(e))&&(t=!0,a+=n[0],o+=n[0].length)}}t||(a+=`&lt;`,o+=1)}else a+=e[o],o+=1;return a},Dc=(e,t,n,r,i,a,s)=>{if(n===``)return[];let l=i.transKeepBasicHtmlNodesFor||[],d=n&&new RegExp(l.map(e=>`<${e}`).join(`|`)).test(n);if(!e&&!t&&!d&&!s)return[n];let f=t??{},m=e=>{Sc(e).forEach(e=>{Oo(e)||(yc(e)?m(bc(e)):Eo(e)&&!p(e)&&Object.assign(f,e))})};m(e);let g=Ec(n,l,f),_=vc.parse(`<0>${g}</0>`),v={...f,...a},y=(e,t,n)=>{let r=bc(e),i=x(r,t.children,n);return xc(r)&&i.length===0||e.props?.i18nIsDynamicList?r:i},b=(e,t,n,r,i)=>{e.dummy?(e.children=t,n.push(h(e,{key:r},i?void 0:t))):n.push(...c.map([e],e=>{if(e.type===u||e.props?.i18nIsDynamicList!==void 0){let n={key:r};return e&&e.props&&Object.keys(e.props).forEach(t=>{t===`children`||t===`i18nIsDynamicList`||(n[t]=e.props[t])}),o(e.type,n,i?null:t)}let n={key:r};return e&&e.props&&Object.keys(e.props).forEach(t=>{t===`ref`||t===`children`||(n[t]=e.props[t])}),h(e,n,i?null:t)}))},x=(e,n,a)=>{let c=Sc(e),u=Sc(n),f={};return u.reduce((e,n,u)=>{let m=n.children?.[0]?.content&&r.services.interpolator.interpolate(n.children[0].content,v,r.language);if(n.type===`tag`){let h=c[parseInt(n.name,10)];!h&&t&&(h=t[n.name]),a.length===1&&!h&&(h=a[0][n.name]),h||={};let g={...n.attrs};s&&Object.keys(g).forEach(e=>{let t=g[e];Oo(t)&&(g[e]=jo(t))});let _=Object.keys(g).length===0?h:Cc({props:g},h),S=p(_),C=S&&yc(n,!0)&&!n.voidElement,w=d&&Eo(_)&&_.dummy&&!S,T=Eo(t)&&Object.hasOwnProperty.call(t,n.name);if(Oo(_)){let t=r.services.interpolator.interpolate(_,v,r.language);e.push(t)}else if(yc(_)||C)b(_,y(_,n,a),e,u);else if(w)b(_,x(c,n.children,a),e,u);else if(Number.isNaN(parseFloat(n.name)))if(T)b(_,y(_,n,a),e,u,n.voidElement);else if(i.transSupportBasicHtmlNodes&&l.indexOf(n.name)>-1)if(n.voidElement)e.push(o(n.name,{key:`${n.name}-${u}`}));else{let t=f[n.name]||0;f[n.name]=t+1;let r,i=0;for(let e=0;e<c.length;e+=1){let a=c[e];if(p(a)&&a.type===n.name){if(i===t){r=a;break}i+=1}}let s=x(r?Sc(bc(r)):c,n.children,a);e.push(o(n.name,{key:`${n.name}-${u}`},s))}else if(n.voidElement)e.push(`<${n.name} />`);else{let t=x(c,n.children,a);e.push(`<${n.name}>${t}</${n.name}>`)}else if(Eo(_)&&!S){let t=n.children[0]?m:null;t&&e.push(t)}else b(_,m,e,u,n.children.length!==1||!m)}else if(n.type===`text`){let t=i.transWrapTextNodes,a=typeof i.unescape==`function`?i.unescape:ko().unescape,c=s?a(r.services.interpolator.interpolate(n.content,v,r.language)):r.services.interpolator.interpolate(n.content,v,r.language);t?e.push(o(t,{key:`${n.name}-${u}`},c)):e.push(c)}return e},[])};return bc(x([{dummy:!0,children:e||[]}],_,Sc(e||[]))[0])},Oc=(e,t,n)=>{let r=e.key||t,i=h(e,{key:r});if(!i.props||!i.props.children||n.indexOf(`${t}/>`)<0&&n.indexOf(`${t} />`)<0)return i;function a(){return o(u,null,i)}return o(a,{key:r})},kc=(e,t)=>e.map((e,n)=>Oc(e,n,t)),Ac=(e,t)=>{let n={};return Object.keys(e).forEach(r=>{Object.assign(n,{[r]:Oc(e[r],r,t)})}),n},jc=(e,t,n,r)=>e?Array.isArray(e)?kc(e,t):Eo(e)?Ac(e,t):(Do(n,`TRANS_INVALID_COMPONENTS`,`<Trans /> "components" prop expects an object or array`,{i18nKey:r}),null):null,Mc=e=>!Eo(e)||Array.isArray(e)?!1:Object.keys(e).reduce((e,t)=>e&&Number.isNaN(Number.parseFloat(t)),!0);function Nc({children:e,count:t,parent:n,i18nKey:r,context:i,tOptions:a={},values:s,defaults:c,components:l,ns:u,i18n:d,t:f,shouldUnescape:p,...m}){let h=d||To();if(!h)return Do(h,`NO_I18NEXT_INSTANCE`,`Trans: You need to pass in an i18next instance using i18nextReactModule`,{i18nKey:r}),e;let g=f||h.t.bind(h)||(e=>e),_={...ko(),...h.options?.react},v=u||g.ns||h.options?.defaultNS;v=Oo(v)?[v]:v||[`translation`];let{transDefaultProps:y}=_,b=y?.tOptions?{...y.tOptions,...a}:a,x=p??y?.shouldUnescape,S=y?.values?{...y.values,...s}:s,C=y?.components?{...y.components,...l}:l,w=Tc(e,_,h,r),T=c||b?.defaultValue||w||_.transEmptyNodeValue||(typeof r==`function`?wo(r):r),{hashTransKey:E}=_,D=r||(E?E(w||T):w||T);s=h.options?.interpolation?.defaultVariables?S&&Object.keys(S).length>0?{...S,...h.options.interpolation.defaultVariables}:{...h.options.interpolation.defaultVariables}:S;let O=wc(e);O&&typeof O.count==`number`&&t===void 0&&(t=O.count);let k=s||t!==void 0&&!h.options?.interpolation?.alwaysFormat||!e?b.interpolation:{interpolation:{...b.interpolation,prefix:`#$?`,suffix:`?$#`}},A={...b,context:i||b.context,count:t,...s,...k,defaultValue:T,ns:v},j=D?g(D,A):T;j===D&&T&&(j=T);let M=jc(C,j,h,r),N=M||e,P=null;Mc(M)&&(P=M,N=e);let F=Dc(N,P,j,h,_,A,x),ee=n??_.defaultTransParent;return ee?o(ee,m,F):F}T();function Pc({children:e,count:t,parent:n,i18nKey:r,context:i,tOptions:a={},values:o,defaults:s,components:c,ns:l,i18n:u,t:d,shouldUnescape:f,...p}){let{i18n:m,defaultNS:h}=M(Ao)||{},g=u||m||To(),_=d||g?.t.bind(g);return Nc({children:e,count:t,parent:n,i18nKey:r,context:i,tOptions:a,values:o,defaults:s,components:c,ns:l||_?.ns||h||g?.options?.defaultNS,i18n:g,t:d,shouldUnescape:f,...p})}T();function Fc({i18n:e,defaultNS:t,children:n}){let r=f(()=>({i18n:e,defaultNS:t}),[e,t]);return o(Ao.Provider,{value:r},n)}var Ic=[`starting`,`awaiting-login`,`captured`,`error`,`cancelled`],Lc=[`awaiting-code`,`captured`,`expired`,`error`,`cancelled`];function Rc(e){return typeof e==`object`&&!!e}function zc(e){return Rc(e)&&typeof e.sessionId==`string`&&typeof e.loginUrl==`string`}function Bc(e){return Rc(e)&&typeof e.sessionId==`string`&&typeof e.phase==`string`&&Ic.includes(e.phase)}function Vc(e){return Rc(e)&&typeof e.sessionId==`string`&&typeof e.userCode==`string`&&typeof e.verificationUrl==`string`&&typeof e.expiresAt==`number`}function Hc(e){return Vc(e)&&Rc(e)&&typeof e.phase==`string`&&Lc.includes(e.phase)}function Uc(e){return Rc(e)&&typeof e.brokerId==`string`}function Wc(){return{"Content-Type":`application/json`,Authorization:`Bearer ${localStorage.getItem(`dominevo_admin_token`)??``}`}}async function Gc(e,t){try{return await e.json()}catch{throw Error(`${t} failed: HTTP ${e.status}`)}}function Kc(e){let t=Rc(e)&&typeof e.error==`string`?e.error:`Unknown error`;return Error(t)}async function qc(e,t,n){let r=await fetch(V(e),{method:`POST`,headers:Wc(),body:JSON.stringify(t)}),i=await Gc(r,`Sign-in ${e.split(`/`).pop()??`request`}`);if(!r.ok)throw Kc(i);if(!n(i))throw Error(`Unexpected response from server`);return i}function Jc(e,t){return qc(`${e}/start`,t,zc)}function Yc(e,t){return qc(`${e}/code/start`,t,Vc)}async function Xc(e,t){let n=new URLSearchParams({sessionId:t}),r=await fetch(V(`${e}/status?${n.toString()}`),{headers:{Authorization:Wc().Authorization??``}}),i=await Gc(r,`Sign-in status`);if(!r.ok)throw Kc(i);if(!Hc(i))throw Error(`Unexpected status response from server`);return i}async function Zc(e,t){let n=new URLSearchParams({sessionId:t}),r=await fetch(V(`${e}/status?${n.toString()}`),{headers:{Authorization:Wc().Authorization??``}}),i=await Gc(r,`Sign-in status`);if(!r.ok)throw Kc(i);if(!Bc(i))throw Error(`Unexpected status response from server`);return i}function Qc(e,t){return qc(`${e}/commit`,{...t},Uc)}async function $c(e,t){try{await fetch(V(`${e}/cancel`),{method:`POST`,headers:Wc(),body:JSON.stringify({sessionId:t})})}catch{}}T();var el=2e3,tl=1e3;function nl(e){let t=Math.max(0,Math.ceil(e/1e3));return`${Math.floor(t/60)}:${(t%60).toString().padStart(2,`0`)}`}function rl({expiresAt:e}){let{t}=Z(),[n,r]=x(()=>Date.now());return y(()=>{let e=setInterval(()=>r(Date.now()),tl);return()=>clearInterval(e)},[]),v(`span`,{className:`text-[11px] text-foreground-subtle`,children:t(`brokers.signIn.codeExpiresIn`,{time:nl(e-n)})})}function il({basePath:e,name:t,brokerId:n,getSettings:r,disabled:i,onSignedIn:a}){let{t:o}=Z(),[c,l]=x({kind:`idle`}),u=d(!0),f=d(null),p=d(null),m=_(()=>{p.current!==null&&clearInterval(p.current),p.current=null},[]),h=_(()=>{m();let t=f.current;f.current=null,t!==null&&$c(e,t)},[e,m]);y(()=>(u.current=!0,()=>{u.current=!1,h()}),[h]);let g=_(e=>{m(),u.current&&l({kind:`error`,message:e})},[m]),b=_(async r=>{m(),u.current&&l({kind:`committing`});try{let i=await Qc(e,{sessionId:r,name:t,...n===void 0?{}:{brokerId:n}});f.current=null,u.current&&a(i.brokerId)}catch(e){g(e instanceof Error?e.message:String(e))}},[e,n,g,t,a,m]),S=_(t=>{m(),p.current=setInterval(()=>{(async()=>{try{let n=await Xc(e,t);if(n.phase===`captured`)return void await b(t);if(n.phase===`error`)return g(n.error??o(`brokers.signIn.proxyError`));if(n.phase===`expired`){m(),u.current&&l({kind:`expired`});return}n.phase===`cancelled`&&(m(),u.current&&l({kind:`idle`}))}catch{}})()},el)},[e,b,g,m,o]),C=async()=>{h(),l({kind:`starting`});try{let t=await Yc(e,r());f.current=t.sessionId,l({kind:`waiting`,code:t}),S(t.sessionId)}catch(e){g(e instanceof Error?e.message:String(e))}},w=()=>{h(),l({kind:`idle`})};if(c.kind===`idle`||c.kind===`error`||c.kind===`expired`)return s(`div`,{className:`space-y-2`,children:[c.kind===`error`&&v(pi,{message:c.message}),c.kind===`expired`&&v(`p`,{className:`text-xs text-warning`,children:o(`brokers.signIn.codeExpired`)}),v(`p`,{className:`text-xs text-foreground-muted`,children:o(`brokers.signIn.codeIntro`)}),s(W,{variant:`primary`,size:`sm`,disabled:i===!0||t.trim().length===0,onClick:()=>void C(),children:[c.kind===`idle`?v(hn,{className:`h-3.5 w-3.5`}):v(et,{className:`h-3.5 w-3.5`}),` `,c.kind===`idle`?o(`brokers.signIn.getCode`):o(`brokers.signIn.newCode`)]})]});if(c.kind===`starting`||c.kind===`committing`)return s(`div`,{className:`flex items-center gap-2 rounded-lg border border-border bg-surface px-3 py-3 text-xs text-foreground-subtle`,children:[v(H,{className:`h-4 w-4 animate-spin flex-shrink-0`}),c.kind===`starting`?o(`brokers.signIn.starting`):o(`brokers.signIn.saving`)]});let{code:T}=c;return s(`div`,{className:`space-y-3 rounded-lg border border-border bg-surface p-3`,children:[v(`p`,{className:`text-xs text-foreground-muted`,children:o(`brokers.signIn.codeInstructions`)}),s(`div`,{className:`flex items-center justify-between gap-2 rounded-md border border-border-subtle bg-background px-3 py-2`,children:[v(`span`,{"data-testid":`device-code`,className:`font-mono text-2xl font-semibold tracking-widest text-foreground break-all`,children:T.userCode}),v(Pr,{value:T.userCode,srLabel:o(`brokers.signIn.copyCode`)})]}),s(W,{variant:`primary`,size:`sm`,onClick:()=>window.open(T.verificationUrl,`_blank`,`noopener,noreferrer`),children:[v(P,{className:`h-3.5 w-3.5`}),` `,o(`brokers.signIn.openCodePage`,{host:al(T.verificationUrl)})]}),s(`div`,{className:`flex flex-wrap items-center justify-between gap-2 pt-1`,children:[s(`span`,{className:`flex min-w-0 flex-col text-[11px] text-foreground-subtle`,children:[s(`span`,{className:`flex items-center gap-2`,children:[v(H,{className:`h-3 w-3 animate-spin flex-shrink-0`}),` `,o(`brokers.signIn.waitingForCode`)]}),v(rl,{expiresAt:T.expiresAt})]}),v(W,{variant:`outline`,size:`sm`,className:`shrink-0 whitespace-nowrap`,onClick:w,children:o(`brokers.signIn.cancel`)})]})]})}function al(e){try{let t=new URL(e);return`${t.host}${t.pathname===`/`?``:t.pathname}`}catch{return e}}T();var ol=2e3;function sl(e){return e.startsWith(`/`)&&!e.startsWith(`//`)?new URL(e,window.location.origin).toString():e}function cl({basePath:e,name:t,brokerId:n,getSettings:r,disabled:i,onSignedIn:a}){let{t:o}=Z(),[c,l]=x({kind:`idle`}),u=d(!0),f=d(null),p=d(null),m=_(()=>{p.current!==null&&clearInterval(p.current),p.current=null},[]),h=_(()=>{m();let t=f.current;f.current=null,t!==null&&$c(e,t)},[e,m]);y(()=>(u.current=!0,()=>{u.current=!1,h()}),[h]);let g=_(e=>{m(),u.current&&l({kind:`error`,message:e})},[m]),b=_(async r=>{m(),u.current&&l({kind:`committing`});try{let i=await Qc(e,{sessionId:r,name:t,...n===void 0?{}:{brokerId:n}});f.current=null,u.current&&a(i.brokerId)}catch(e){g(e instanceof Error?e.message:String(e))}},[e,n,g,t,a,m]),S=_(t=>{m(),p.current=setInterval(()=>{(async()=>{try{let n=await Zc(e,t);if(n.phase===`captured`)return void await b(t);if(n.phase===`error`)return g(n.error??o(`brokers.signIn.proxyError`));if(n.phase===`cancelled`){m(),u.current&&l({kind:`idle`});return}u.current&&l({kind:`waiting`,loginUrl:n.loginUrl,ready:n.phase===`awaiting-login`})}catch{}})()},ol)},[e,b,g,m,o]),C=async()=>{h(),l({kind:`starting`});try{let t=await Jc(e,r());f.current=t.sessionId,l({kind:`waiting`,loginUrl:t.loginUrl,ready:!1}),S(t.sessionId)}catch(e){g(e instanceof Error?e.message:String(e))}};return c.kind===`idle`||c.kind===`error`?s(`div`,{className:`space-y-2`,children:[c.kind===`error`&&v(pi,{message:c.message}),v(`p`,{className:`text-xs text-foreground-muted`,children:o(`brokers.signIn.intro`)}),s(W,{variant:`primary`,size:`sm`,disabled:i===!0||t.trim().length===0,onClick:()=>void C(),children:[v(hn,{className:`h-3.5 w-3.5`}),` `,c.kind===`error`?o(`common.retry`):o(`brokers.signIn.start`)]})]}):c.kind===`starting`||c.kind===`committing`?s(`div`,{className:`flex items-center gap-2 rounded-lg border border-border bg-surface px-3 py-3 text-xs text-foreground-subtle`,children:[v(H,{className:`h-4 w-4 animate-spin flex-shrink-0`}),c.kind===`starting`?o(`brokers.signIn.starting`):o(`brokers.signIn.saving`)]}):s(`div`,{className:`space-y-2 rounded-lg border border-border bg-surface p-3`,children:[c.ready?s(j,{children:[v(`p`,{className:`text-xs font-semibold text-foreground`,children:o(`brokers.signIn.openLink`)}),v(`p`,{className:`text-[11px] text-foreground-subtle`,children:o(`brokers.signIn.afterLogin`)}),s(W,{variant:`primary`,size:`sm`,onClick:()=>window.open(sl(c.loginUrl),`_blank`,`noopener,noreferrer`),children:[v(P,{className:`h-3.5 w-3.5`}),` `,o(`brokers.signIn.openLoginPage`)]})]}):s(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[v(H,{className:`h-4 w-4 animate-spin flex-shrink-0`}),o(`brokers.signIn.waitingForProxy`)]}),s(`div`,{className:`flex items-center justify-between gap-2 pt-1`,children:[s(`span`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[v(H,{className:`h-3 w-3 animate-spin`}),` `,o(`brokers.signIn.waitingForLogin`)]}),v(W,{variant:`outline`,size:`sm`,onClick:()=>{h(),l({kind:`idle`})},children:o(`brokers.signIn.cancel`)})]})]})}T();var ll=[`device-code`];function ul({methods:e,...t}){let{t:n}=Z(),r=e!==void 0&&e.length>0?e:ll,[i,a]=x(null),o=i!==null&&r.includes(i)?i:r[0]??`device-code`;return s(`div`,{className:`space-y-2`,children:[r.length>1&&v(Yi,{value:o,onValueChange:e=>a(e===`device-code`?e:`proxy`),appearance:`pills`,children:v(bi,{"aria-label":n(`brokers.signIn.method`),children:r.map(e=>v(Ba,{value:e,children:n(e===`device-code`?`brokers.signIn.methodDeviceCode`:`brokers.signIn.methodProxy`)},e))})}),o===`device-code`?v(il,{...t},`device-code`):v(cl,{...t},`proxy`)]})}function dl(e){return{status:e.status===`validated`||e.status===`rejected`||e.status===`inconclusive`||e.status===`unsupported`?e.status:e.success?`validated`:`rejected`,...e.error===void 0?{}:{error:e.error},...e.detail===void 0?{}:{detail:e.detail}}}var fl={validated:`border-success/30 bg-success/5 text-success`,rejected:`border-danger/30 bg-danger/5 text-danger`,inconclusive:`border-warning/30 bg-warning/5 text-warning`,unsupported:`border-border bg-surface text-foreground-subtle`};function pl({verdict:e}){let{t}=Z(),n=(()=>{switch(e.status){case`validated`:return e.detail?`${t(`integrations.connectionSuccess`)} — ${e.detail}`:t(`integrations.connectionSuccess`);case`rejected`:return`${t(`integrations.errorPrefix`)} ${e.error??``}`;case`inconclusive`:return`${t(`integrations.connectionInconclusive`,{defaultValue:`Could not be checked:`})} ${e.error??``}`;case`unsupported`:return e.error??t(`integrations.connectionUntestable`,{defaultValue:`This integration cannot be tested before it is created.`})}})();return v(`div`,{className:`rounded-lg border px-3 py-2 text-xs ${fl[e.status]}`,"data-testid":`connection-test-verdict`,children:n})}var ml=new Set;function hl(e){for(let t of ml)t(e)}function gl(e){return ml.add(e),()=>{ml.delete(e)}}T();var _l=`notification-output`;function vl(e){return e.map(e=>({id:e.id,name:e.name,kind:Lt(e.recordKind),addonId:e.addonId,enabled:e.enabled,config:{...e.formValues}}))}function yl(){let e=ba({functionCap:_l});return{data:f(()=>e.data===void 0?void 0:vl(e.data),[e.data]),isError:e.isError}}var bl=`members`,xl=Bt.options,Sl=[1,2,3,4,5],Cl={title:`Person at the front door`,body:`A person was seen on Front door`,priority:4};function wl(e){return Qt(e)}function Tl(e,t){return{...e,[bl]:t}}function El(e){return e.kind!==rn}function Dl(e,t,n){let r=new Set(t.map(e=>e.targetId)),i=n.trim().toLowerCase();return e.filter(e=>El(e)&&!r.has(e.id)&&(i===``||e.name.toLowerCase().includes(i)||e.kind.toLowerCase().includes(i)))}function Ol(e,t){let n={...e};return delete n[t],n}var kl={kind:`schedule`,schedule:{windows:[{days:[1,2,3,4,5],startMinute:540,endMinute:1080}]}};function Al(e){let t=qt(e,{...Cl,format:`text`});return{title:t.title??``,body:t.body}}function jl(e,t){return e?.find(e=>e.kind===t.kind&&e.addonId===t.addonId)?.label??t.kind}var Ml=on.options;function Nl(e){let t=e.filter?.eventKinds;return new Set(t===void 0?[]:Ml.filter(e=>!t.includes(e)))}function Pl(e,t){return t.eventKinds===void 0&&t.classes===void 0?Ol(e,`filter`):{...e,filter:t}}function Fl(e,t){let{eventKinds:n,...r}=e.filter??{};return Pl(e,t.length===0||t.length===Ml.length?r:{...r,eventKinds:[...t]})}function Il(e){return(e.filter?.classes??[]).join(`, `)}function Ll(e,t){let n=t.split(`,`).map(e=>e.trim()).filter(e=>e!==``),{classes:r,...i}=e.filter??{};return Pl(e,n.length===0?i:{...i,classes:n})}function Rl(e,t){let n=e.findIndex(e=>e.targetId===t);return n<=0?[]:e.slice(0,n)}function zl(e,t){return t===void 0?Ol(e,`onlyIfUndelivered`):{...e,onlyIfUndelivered:[t]}}function Bl(e,t){return e.filter(e=>e.targetId!==t).map(e=>{if(e.onlyIfUndelivered===void 0||!e.onlyIfUndelivered.includes(t))return e;let n=e.onlyIfUndelivered.filter(e=>e!==t);return n.length===0?Ol(e,`onlyIfUndelivered`):{...e,onlyIfUndelivered:n}})}T();var Vl=It.options,Hl=[`always`,`schedule`,`alarm`],Ul=``,Wl=``;function Gl(e){let t=e.fields;return new Set(t===void 0?[]:xl.filter(e=>!t.includes(e)))}function Kl({member:e,name:t,kindLabel:n,known:r,defaultOpen:i,fallbackChoices:a,onChange:o,onRemove:c}){let{t:l}=Z(),[u,d]=x(i),f=e.when??{kind:`always`},p=e.enabled!==!1,m=Al(e),h=e=>l(`notifierGroup.field.${e}`,e),g=t=>{o(t===`always`?Ol(e,`when`):t===`schedule`?{...e,when:kl}:{...e,when:{kind:`alarm`,deviceId:0,states:[`armed_away`]}})},_=(t,n)=>{let r={...e.templates,[t]:n};n===``&&delete r[t],r.title===void 0&&r.body===void 0?o(Ol(e,`templates`)):o({...e,templates:r})};return s(`div`,{className:`rounded-md border border-border bg-surface`,"data-testid":`group-member-${e.targetId}`,children:[s(`div`,{className:`flex items-center gap-2 p-2`,children:[v(pa,{icon:u?mn:oe,variant:`ghost`,size:`sm`,"aria-label":u?l(`notifierGroup.collapse`,`Hide policy`):l(`notifierGroup.expand`,`Show policy`),onClick:()=>d(!u)}),s(`div`,{className:`min-w-0 flex-1`,children:[v(`p`,{className:`truncate text-sm ${r?`text-foreground`:`text-danger`}`,children:r?t:l(`notifierGroup.missingTarget`,`Missing target {{id}}`,{id:t})}),v(`p`,{className:`truncate text-xs text-foreground-muted`,children:n})]}),!p&&v(jn,{variant:`default`,children:l(`notifierGroup.paused`,`paused`)}),v(Wn,{checked:p,"aria-label":l(`notifierGroup.enabled`,`Deliver to this member`),onCheckedChange:t=>o(t?Ol(e,`enabled`):{...e,enabled:!1})}),v(pa,{icon:Et,variant:`ghost`,size:`sm`,"aria-label":l(`notifierGroup.remove`,`Remove {{name}} from the group`,{name:t}),onClick:c})]}),u&&s(`div`,{className:`space-y-3 border-t border-border-subtle p-3`,children:[s(`div`,{className:`space-y-1`,children:[v(Yn,{children:l(`notifierGroup.when`,`Receives`)}),v(Ke,{value:f.kind,onChange:e=>{let t=Hl.find(t=>t===e.target.value);t!==void 0&&g(t)},options:Hl.map(e=>({value:e,label:l(`notifierGroup.when_${e}`,e)}))}),f.kind===`schedule`&&v(Ko,{value:f.schedule,onChange:t=>o(t===void 0?Ol(e,`when`):{...e,when:{kind:`schedule`,schedule:t}}),emptyHint:l(`notifierGroup.scheduleEmpty`,`Always — add a window to restrict when it receives.`)}),f.kind===`alarm`&&s(`div`,{className:`space-y-2`,children:[v(br,{pick:`device`,noun:`device`,fixedTypes:[q.AlarmPanel],recentKey:`notifier-group-alarm`,value:f.deviceId>0?{deviceId:f.deviceId}:null,onChange:t=>o({...e,when:{...f,deviceId:t?.deviceId??0}})}),v(Rn,{chips:Vl.map(e=>({id:e,label:l(`notifierGroup.alarm.${e}`,e)})),off:new Set(Vl.filter(e=>!f.states.includes(e))),allLabel:l(`notifierGroup.allStates`,`Any state`),ariaLabel:l(`notifierGroup.alarmStates`,`Alarm states that deliver`),onChange:t=>{let n=Vl.filter(e=>!t.has(e));n.length>0&&o({...e,when:{...f,states:n}})}})]})]}),(a.length>0||e.onlyIfUndelivered!==void 0)&&s(`div`,{className:`space-y-1`,children:[v(Yn,{children:l(`notifierGroup.fallback`,`Escalation`)}),v(Ke,{value:e.onlyIfUndelivered?.[0]??Wl,"aria-label":l(`notifierGroup.fallback`,`Escalation`),onChange:t=>o(zl(e,t.target.value===Wl?void 0:t.target.value)),options:[{value:Wl,label:l(`notifierGroup.fallbackAlways`,`Always delivered`)},...a.map(e=>({value:e.targetId,label:l(`notifierGroup.fallbackFor`,`Only if {{name}} did not receive it`,{name:e.name})}))]})]}),s(`div`,{className:`space-y-1`,children:[v(Yn,{children:l(`notifierGroup.eventKinds`,`Only these events`)}),v(Rn,{chips:Ml.map(e=>({id:e,label:l(`notifierGroup.eventKind.${e}`,e)})),off:Nl(e),allLabel:l(`notifierGroup.allEvents`,`All events`),ariaLabel:l(`notifierGroup.eventKinds`,`Only these events`),onChange:t=>o(Fl(e,Ml.filter(e=>!t.has(e))))}),v(U,{value:Il(e),placeholder:l(`notifierGroup.classesPlaceholder`,`Any class (e.g. person, car)`),"aria-label":l(`notifierGroup.classes`,`Only these detected classes`),onChange:t=>o(Ll(e,t.target.value))})]}),s(`div`,{className:`space-y-1`,children:[v(Yn,{children:l(`notifierGroup.fields`,`Fields to deliver`)}),v(Rn,{chips:xl.map(e=>({id:e,label:h(e)})),off:Gl(e),allLabel:l(`notifierGroup.allFields`,`All`),ariaLabel:l(`notifierGroup.fields`,`Fields to deliver`),onChange:t=>{let n=xl.filter(e=>!t.has(e));o(n.length===xl.length?Ol(e,`fields`):{...e,fields:n})}})]}),s(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:[s(`div`,{className:`space-y-1`,children:[v(Yn,{children:l(`notifierGroup.titleTemplate`,`Title template`)}),v(U,{value:e.templates?.title??``,placeholder:`{{title}}`,onChange:e=>_(`title`,e.target.value)})]}),s(`div`,{className:`space-y-1`,children:[v(Yn,{children:l(`notifierGroup.bodyTemplate`,`Body template`)}),v(U,{value:e.templates?.body??``,placeholder:`{{body}}`,onChange:e=>_(`body`,e.target.value)})]})]}),v(`p`,{className:`text-xs text-foreground-subtle`,children:l(`notifierGroup.templateHint`,`Use {{title}} and {{body}} for the notification text. Empty keeps the original.`)}),s(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:[s(`div`,{className:`space-y-1`,children:[v(Yn,{children:l(`notifierGroup.minPriority`,`Minimum priority`)}),v(Ke,{value:e.minPriority===void 0?Ul:String(e.minPriority),onChange:t=>{let n=Sl.find(e=>String(e)===t.target.value);o(n===void 0?Ol(e,`minPriority`):{...e,minPriority:n})},options:[{value:Ul,label:l(`notifierGroup.anyPriority`,`Any priority`)},...Sl.map(e=>({value:String(e),label:String(e)}))]})]}),s(`div`,{className:`space-y-1`,children:[v(Yn,{children:l(`notifierGroup.throttle`,`At most one per (seconds)`)}),v(Se,{"aria-label":l(`notifierGroup.throttle`,`At most one per (seconds)`),value:e.throttleSec??0,min:0,onChange:t=>o(t>0?{...e,throttleSec:t}:Ol(e,`throttleSec`))})]})]})]}),s(`div`,{className:`border-t border-border-subtle px-3 py-2 text-xs text-foreground-muted`,"data-testid":`member-preview`,children:[s(`span`,{className:`font-medium text-foreground`,children:[l(`notifierGroup.receives`,`Receives`),`:`,` `]}),m.title===``&&m.body===``?l(`notifierGroup.receivesNothing`,`nothing (every field is off)`):[m.title,m.body].filter(e=>e!==``).join(` — `)]})]})}function ql(){let e=G();return{data:C({queryKey:[`notificationOutput`,`listTargetKinds`],queryFn:()=>e.trpcClient.notificationOutput.listTargetKinds.query({})}).data}}T();var Jl=`notifier/group-members`,Yl=6;function Xl(){return[bl]}function Zl({values:e,onValuesChange:t}){let{t:n}=Z(),r=yl(),i=ql(),[a,o]=x(``),[c,l]=x(new Set),{members:u,invalid:d}=wl(e),f=new Map((r.data??[]).map(e=>[e.id,e])),p=Dl(r.data??[],u,a).slice(0,Yl),m=n=>{t(Tl(e,[...u,{targetId:n.id}])),l(new Set([...c,n.id])),o(``)};return s(`div`,{className:`space-y-2`,"data-testid":`group-members`,children:[s(`p`,{className:`text-xs font-medium text-foreground-muted`,children:[n(`notifierGroup.members`,`Members`),` (`,u.length,`)`]}),d>0&&v(`p`,{className:`text-xs text-danger`,children:n(`notifierGroup.invalidRows`,`{{count}} saved member(s) could not be read and are left out.`,{count:d})}),u.length===0?v(zr,{title:n(`notifierGroup.emptyTitle`,`No members yet`),description:n(`notifierGroup.emptyHint`,`Search a notifier below to add it to this group.`)}):v(`div`,{className:`space-y-2`,children:u.map(n=>{let a=f.get(n.targetId);return v(Kl,{member:n,name:a?.name??n.targetId,kindLabel:a===void 0?``:jl(i.data,a),known:a!==void 0||r.data===void 0,defaultOpen:c.has(n.targetId),fallbackChoices:Rl(u,n.targetId).map(e=>({targetId:e.targetId,name:f.get(e.targetId)?.name??e.targetId})),onChange:r=>t(Tl(e,u.map(e=>e.targetId===n.targetId?r:e))),onRemove:()=>t(Tl(e,Bl(u,n.targetId)))},n.targetId)})}),s(`div`,{className:`space-y-1`,children:[s(`div`,{className:`relative`,children:[v(ft,{className:`pointer-events-none absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-foreground-subtle`}),v(U,{className:`pl-7`,value:a,placeholder:n(`notifierGroup.search`,`Search notifiers to add`),"aria-label":n(`notifierGroup.search`,`Search notifiers to add`),onChange:e=>o(e.target.value)})]}),r.data===void 0?v(zi,{className:`h-8 w-full`}):p.length===0?v(`p`,{className:`text-xs text-foreground-subtle`,children:n(`notifierGroup.noCandidates`,`No other notifier matches. Groups cannot be members.`)}):v(`ul`,{className:`space-y-1`,children:p.map(e=>s(`li`,{className:`flex items-center gap-2 rounded-md border border-border-subtle px-2 py-1`,children:[v(`span`,{className:`min-w-0 flex-1 truncate text-sm text-foreground`,children:e.name}),v(`span`,{className:`text-xs text-foreground-muted`,children:jl(i.data,e)}),s(W,{size:`sm`,variant:`ghost`,onClick:()=>m(e),children:[v(Tt,{className:`h-3.5 w-3.5`}),n(`notifierGroup.add`,`Add`)]})]},e.id))})]})]})}var Ql=new Set([`proc`,`sys`,`dev`,`run`,`boot`,`lost+found`,`snap`,`bin`,`sbin`,`lib`,`lib32`,`lib64`,`libx32`,`usr`,`etc`,`var`,`opt`,`tmp`,`srv`,`root`,`System`,`Library`,`Applications`,`cores`,`private`]),$l=[`recordings`,`data`,`mnt`,`media`,`Volumes`];function eu(e){let t=$l.findIndex(t=>t===`recordings`?e.startsWith(t):e===t);return t===-1?$l.length:t}function tu(e){return e.filter(e=>!e.name.startsWith(`.`)&&!Ql.has(e.name)).toSorted((e,t)=>{let n=eu(e.name)-eu(t.name);return n===0?e.name.localeCompare(t.name):n}).map(e=>e.path)}T();function nu({nodeId:e,value:t,onChange:n}){let{t:r}=Z(),i=G().trpcClient,[a,o]=x([]),[c,l]=x(t),[u,d]=x(null),[f,p]=x(null),[m,h]=x(``),g=_(async(t,r)=>{p(null);try{let a=await i.filesystemBrowse.browse.query({nodeId:e,path:t});d(a),l(a.path),r&&n(a.path)}catch(e){p(e instanceof Error?e.message:`browse failed`)}},[i,e,n]);y(()=>{l(t),(async()=>{let n=await i.filesystemBrowse.browse.query({nodeId:e,path:`/`}).then(e=>e).catch(()=>null);if(n){o(tu(n.entries)),await g(t.startsWith(`/`)?t:`/`,!1);return}try{let n=await i.filesystemBrowse.listAllowedRoots.query({nodeId:e});o(n),await g(t&&n.some(e=>t.startsWith(e))?t:n[0]??``,!1)}catch(e){o([]),d(null),p(e instanceof Error&&/not available on node/i.test(e.message)?`This node can't be browsed remotely. Enter the path manually.`:e instanceof Error?e.message:`browse unavailable`)}})()},[e]);let b=async()=>{if(!(!m.trim()||!u)){p(null);try{let t=`${u.path.replace(/\/+$/,``)}/${m.trim()}`;await i.filesystemBrowse.createDir.mutate({nodeId:e,path:t}),h(``),await g(u.path,!0)}catch(e){p(e instanceof Error?e.message:`create failed`)}}},S=e=>`${(e/1e9).toFixed(1)} GB`;return s(`div`,{className:`space-y-2 rounded border border-border p-2`,children:[v(`div`,{className:`flex flex-wrap gap-1`,children:a.map(e=>v(W,{variant:`unstyled`,onClick:()=>void g(e,!0),className:`rounded border border-border px-2 py-0.5 text-[10px] font-mono hover:border-primary/40`,children:e},e))}),v(U,{value:c,onChange:e=>{l(e.target.value),n(e.target.value)},placeholder:`/absolute/path`,className:`w-full rounded border border-border bg-background px-2 py-1 text-[11px] font-mono`}),u&&v(`div`,{className:`text-[10px] text-foreground-subtle`,children:r(`storage.pathBrowser.free`,{free:S(u.freeBytes),total:S(u.totalBytes)})}),v(`div`,{className:`max-h-40 space-y-0.5 overflow-y-auto`,children:u?.entries.map(e=>s(W,{variant:`unstyled`,onClick:()=>void g(e.path,!0),className:`block w-full truncate rounded px-2 py-1 text-left text-xs hover:bg-primary/5`,children:[`📁 `,e.name]},e.path))}),s(`div`,{className:`flex gap-1`,children:[v(U,{value:m,onChange:e=>h(e.target.value),placeholder:r(`storage.pathBrowser.newFolder`,`new folder`),className:`flex-1 rounded border border-border bg-background px-2 py-1 text-xs`}),v(W,{variant:`unstyled`,onClick:()=>void b(),className:`rounded border border-border px-2 py-1 text-xs hover:border-primary/40`,children:r(`storage.pathBrowser.create`,`Create`)})]}),f&&v(`div`,{className:`text-[10px] text-danger`,children:f})]})}var ru=`storage/path-browser`,iu=`nodeId`,au=`providerId`,ou=`basePath`,su=`hub`;function cu(e,t){let n=e[t];return typeof n==`string`?n:``}function lu(e,t){let n=e.sections.flatMap(e=>e.fields),r=n.find(e=>e.key===iu);if(r===void 0)return null;let i=cu(t,au),a=`showWhen`in r?r.showWhen:void 0;return a!==void 0&&!(i!==``&&a.in?.includes(i))?null:(i===``?[ou]:[`${i}.${ou}`,ou]).find(e=>n.some(t=>t.key===e))??null}function uu(e,t){let n=lu(e,t);return n===null?[]:[n]}function du({schema:e,values:t,onValuesChange:n}){let{t:r}=Z(),i=lu(e,t);if(i===null)return null;let a=cu(t,iu);return s(`div`,{className:`space-y-1`,children:[v(`p`,{className:`text-xs font-medium text-foreground-muted`,children:r(`storage.pathBrowser.label`,`Folder on the node`)}),v(nu,{nodeId:a===``?su:a,value:cu(t,i),onChange:e=>n({...t,[i]:e})})]})}var fu=new Map([[ru,{Component:du,ownedKeys:uu}],[Jl,{Component:Zl,ownedKeys:Xl}]]);function pu(e){return fu.get(e)??null}function mu(e,t){return t.length===0?e:{...e,sections:e.sections.map(e=>({...e,fields:e.fields.filter(e=>!t.includes(e.key))})).filter(e=>e.fields.length>0)}}T();function hu({field:e,values:t,onLabels:n}){let{t:r}=Z(),{query:i,found:a}=wr(e,t);return y(()=>{n(new Map(a.map(e=>[e.value,e.label])))},[a.map(e=>`${e.value}\u0000${e.label}`).join(``),n]),i.isError?v(`p`,{"data-testid":`create-many-labels-failed`,className:`text-xs text-warning`,children:r(`providerInstances.createManyLabelsFailed`,`The names of the choices could not be read ({{message}}); each is named after its value.`,{message:i.error?.message??``})}):null}function gu(e){for(let t of e?.sections??[])for(let e of t.fields)if(e.type===`select`&&e.discoverOptions?.pickManyOnCreate===!0)return e;return null}function _u(e,t){return e.type!==`select`||e.key!==t||e.discoverOptions===void 0?e:{...e,discoverOptions:{...e.discoverOptions,multiple:!0}}}function vu(e,t){return{...e,sections:e.sections.map(e=>({...e,fields:e.fields.map(e=>_u(e,t))}))}}function yu(e){let{key:t,picked:n,labels:r,typedName:i,values:a}=e;return n.map(e=>({name:n.length===1&&i.length>0?i:r.get(e)??e,values:{...a,[t]:e}}))}function bu(e,t){let n=[];for(let r of e.links??[]){let e=t[r.field],i=Array.isArray(e)?e:[e];for(let e of i)typeof e!=`string`||e===``||n.some(t=>t.field===r.field&&t.instanceId===e)||n.push({field:r.field,cap:r.to.cap,...r.to.kind===void 0?{}:{kind:r.to.kind},instanceId:e})}return n}function xu(e,t){return e.find(e=>e.id===t.instanceId&&(t.kind===void 0||e.kind===t.kind))}function Su(e){let t=new Map(e.holders.map(e=>[e.addonId,e])),n=[];for(let r of e.functionProviders){let i=e.displayNames.get(r.addonId)??r.addonId,a=t.get(r.addonId);if(a===void 0){n.push({kind:`fixed`,key:`fixed:${r.addonId}`,addonId:r.addonId,providerName:i,name:i,description:e.descriptions.get(r.addonId)??``,isActive:r.isActive});continue}let o=e.notRunning?.get(r.addonId);for(let e of a.instances){let t=ku(a.description,e.kind),s=bu(a.description,e.formValues);n.push({kind:`instance`,key:`${r.addonId}:${e.id}`,addonId:r.addonId,providerName:i,id:e.id,name:e.name,configured:e.configured,enabled:e.enabled??!0,status:e.status,canTest:t?.canTest??a.description.canTest,...e.kind===void 0?{}:{kindId:e.kind},...e.kind===void 0?{}:{kindLabel:t?.label??e.kind},...t?.iconUrl===void 0?{}:{kindIconUrl:t.iconUrl},...e.lastCheckedAt===void 0?{}:{lastCheckedAt:e.lastCheckedAt},...t?.connectPath===void 0?{}:{connectPath:t.connectPath},...t?.disconnectPath===void 0?{}:{disconnectPath:t.disconnectPath},...o===void 0?{}:{notRunning:o},...s.length>0?{links:s}:{}})}}return n}var Cu=new Set([`running`,`unknown`]);function wu(e){return e!==void 0&&!Cu.has(e)}function Tu(e,t){return typeof e==`object`&&e?Reflect.get(e,t):void 0}function Eu(e){let t=new Map;for(let n of e){let e=Tu(Tu(n,`manifest`),`id`),r=Tu(Tu(n,`process`),`state`);typeof e!=`string`||typeof r!=`string`||wu(r)&&t.set(e,r)}return t}function Du(e){let t=new Map;for(let n of e){let e=Tu(n,`manifest`),r=Tu(e,`id`);if(typeof r!=`string`||r.length===0)continue;let i=Tu(e,`name`),a=Tu(e,`packageDisplayName`);t.set(r,typeof i==`string`?i:typeof a==`string`?a:r)}return t}function Ou(e){let t=new Map;for(let n of e){let e=Tu(n,`manifest`),r=Tu(e,`id`),i=Tu(e,`description`);typeof r!=`string`||typeof i!=`string`||i.length>0&&t.set(r,i)}return t}function ku(e,t){return t===void 0?void 0:e.kinds?.find(e=>e.id===t)}function Au(e,t,n){let r=e.kinds;if(r===void 0||r.length===0)return e;let i=r.filter(e=>n===void 0?e.functionCap===t:e.id===n&&zt(e,t));return i.length===0?null:{...e,kinds:i}}function ju(e,t){let n=Au(e.description,t);if(n===null)return null;let r=n.kinds;if(e.description.kinds===void 0||r===void 0)return e;let i=new Set(r.map(e=>e.id));return{...e,description:n,instances:e.instances.filter(e=>e.kind===void 0||i.has(e.kind))}}function Mu(e){return(e.kinds?.length??0)>1}function Nu(e,t,n){return Mu(e)&&t!==void 0?t.label:n}function Pu(e){return e.label!==void 0&&e.label.length>0?e.label:e.state}function Fu(e){let t=new Set,n=[];for(let r of e)t.has(r.addonId)||(t.add(r.addonId),n.push({addonId:r.addonId,name:r.providerName}));return n}var Iu={error:3,unknown:2,ok:1,off:0};function Lu(e){return e.enabled?e.status===void 0?e.configured?`ok`:`unknown`:e.status.state:`off`}function Ru(e){let t=null;for(let n of e){let e=Lu(n);(t===null||Iu[e]>Iu[t])&&(t=e)}return t??`unknown`}function zu(e,t,n){return e.map(e=>{let r=n.get(e.addonId)??e.addonId,i=t.filter(t=>t.addonId===e.addonId),a=i.filter(e=>e.kind===`instance`),o=i.find(e=>e.kind===`fixed`);return o===void 0?{addonId:e.addonId,name:r,count:a.length,health:Ru(a)}:{addonId:e.addonId,name:r,count:1,health:o.isActive?`ok`:`off`}})}function Bu(e,t){return t===null?e:e.filter(e=>e.addonId===t)}function Vu(e){return e.filter(e=>e.description.instanceMode===`multiple`||e.instances.length===0)}function Hu(e,t){return e.flatMap(e=>{let n=t(e.addonId),r=e.description.kinds??[];return r.length===0?[{addonId:e.addonId,label:n,providerName:n}]:r.filter(e=>e.creatable!==!1).map(t=>({addonId:e.addonId,kind:t.id,label:t.label,providerName:n,...t.iconUrl===void 0?{}:{iconUrl:t.iconUrl}}))})}function Uu(e){return e.some(e=>e.isError)?`error`:e.some(e=>e.isPending)?`pending`:`ready`}function Wu(e,t){if(Object.is(e,t))return!0;if(typeof e!=`object`||typeof t!=`object`||e===null||t===null||Array.isArray(e)!==Array.isArray(t))return!1;let n=e,r=t,i=new Set([...Object.keys(n),...Object.keys(r)]);for(let e of i)if(!Wu(n[e],r[e]))return!1;return!0}var Gu=`enabled`;function Ku(e,t){return t?.sections.some(e=>e.fields.some(e=>e.key===Gu))===!0?{...e}:Object.fromEntries(Object.entries(e).filter(([e])=>e!==Gu))}function qu(e,t){let n={};for(let[r,i]of Object.entries(t))i!==void 0&&(Wu(e[r],i)||(n[r]=i));return n}function Ju(e,t){let n={...e};for(let[e,r]of Object.entries(t))r!==void 0&&(n[e]=r);return n}function Yu(e,t){return e.mintsId===!0?!1:(t?.role??e.role)!==`devices`}function Xu(e,t,n){return e===`single`?t:`inst-${n()}`}function Zu(){let e=crypto.getRandomValues(new Uint8Array(4));return Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``)}var Qu=`+`;function $u(e,t,n){return t===void 0?e:t===null?`${e}:${Qu}${n??``}`:`${e}:${t}`}function ed(e){let t=e.indexOf(`:`);if(t<0)return{kind:`fixed`,addonId:e};let n=e.slice(0,t),r=e.slice(t+1);if(!r.startsWith(Qu))return{kind:`instance`,addonId:n,id:r};let i=r.slice(1);return i===``?{kind:`create`,addonId:n}:{kind:`create`,addonId:n,kindId:i}}var td=`sendWith`,nd=`smtpInstanceId`;function rd(e,t){return e.filter(e=>e.formValues[td]===t||e.formValues[nd]===t).map(e=>e.name)}var id=/^[a-z0-9][a-z0-9-]{0,63}$/;function ad(e,t){return t===``?`empty`:e.pattern.test(t)?`ok`:`invalid`}T();var od=5e3,sd=`integration-instances`,cd=`provider-instances-holder`;function ld(e){let t=G(),n=vr({capName:e},{refetchInterval:od}),r=vr({capName:sd},{refetchInterval:od}),i=tr(void 0,{refetchInterval:od}),a=f(()=>(n.data??[]).map(e=>({addonId:e.addonId,isActive:e.isActive})),[n.data]),o=E({queries:f(()=>{let e=new Set((r.data??[]).map(e=>e.addonId));return a.map(e=>e.addonId).filter(t=>e.has(t))},[a,r.data]).map(e=>({queryKey:[cd,e],refetchInterval:od,queryFn:async()=>{let n=t.trpcClient.integrationInstances,[r,i]=await Promise.all([n.describe.query({addonId:e}),n.listInstances.query({addonId:e})]);return{addonId:e,description:r,instances:i}}}))}),s=Uu([n,r,...o]),c=f(()=>o.flatMap(t=>{let n=t.data===void 0?null:ju(t.data,e);return n===null?[]:[n]}),[o,e]),l=f(()=>Du(i.data??[]),[i.data]),u=f(()=>Ou(i.data??[]),[i.data]),d=f(()=>Eu(i.data??[]),[i.data]),p=f(()=>Su({functionProviders:a,holders:c,displayNames:l,descriptions:u,notRunning:d}),[a,c,l,u,d]),m=n.error??r.error??o.find(e=>e.error)?.error??null,h=_(()=>{n.refetch(),r.refetch();for(let e of o)e.refetch()},[n,r,o]);return{state:s,error:m===null?null:m.message,functionProviders:a,rows:p,holders:c,displayNames:l,descriptions:u,refetch:h}}T();var ud=D(null);function dd(){let e=M(ud);if(e===null)throw Error(`A dialog lead must be rendered inside InstanceEditorDialog`);return e}T();var fd=`name`,pd=`kind`,md=`restore`,hd=`restoreId`,gd=`typedId`,_d={};function vd(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function yd(e,t){let n=vd(e)?e:{};return t===null?{...n}:{...n,integrationId:t}}function bd({addonId:e,providerName:t,description:n,instance:r,onClose:i,onSaved:a,lead:o,typedId:c,testLabel:l,testHint:u}){let{t:p}=Z(),m=G(),h=O(),g=r?.id??null,b=async(t,n,r)=>{let i=await m.trpcClient.addons.custom.mutate({addonId:e,action:t,input:yd(r,g)});return g!==null&&h.invalidateQueries({queryKey:[cd]}),i},S=n.kinds??[],w=Nu(n,ku(n,r?.kind??S[0]?.id),t),[T,E]=x({[fd]:r?.name??w,[pd]:r?.kind??S[0]?.id??``,[md]:!1,[hd]:``,[gd]:``}),D=d(w),A=T[pd];y(()=>{if(r!==null||typeof A!=`string`)return;let e=Nu(n,ku(n,A),t),i=D.current;D.current=e,E(t=>t[fd]===i?{...t,[fd]:e}:t)},[A,n,r,t]);let M=e=>{let t=T[e];return typeof t==`string`?t.trim():``},N=M(fd),P=M(pd),F=ku(n,P===``?void 0:P),ee=T[md]===!0,te=M(hd),ne=r===null&&n.allowRestoreId===!0&&F?.signIn===void 0,re=ne&&ee&&te===``,ie=r===null&&F?.signIn===void 0&&!(ne&&ee)?c?.(P===``?void 0:P):void 0,ae=M(gd),oe=ie===void 0?`ok`:ad(ie,ae),[se,ce]=x({...r?.formValues??_d}),[I,le]=x(null),ue=f(()=>({sections:[{id:`instance-identity`,title:p(`providerInstances.identity`,`Identity`),columns:1,fields:[...r===null&&Mu(n)?[{type:`select`,key:pd,label:p(`providerInstances.colKind`,`Kind`),options:S.map(e=>({value:e.id,label:e.label}))}]:[],{type:`text`,key:fd,label:p(`providerInstances.colName`,`Name`),required:!0},...ie===void 0?[]:[{type:`text`,key:gd,label:p(`providerInstances.typedId`,`Id`),required:!0,description:oe===`invalid`?p(`providerInstances.typedIdInvalid`,`Lowercase letters, digits and dashes, starting with a letter or digit (up to 64).`):p(`providerInstances.typedIdHint`,`Chosen once; it cannot be changed after the record is created.`)}],...ne?[{type:`boolean`,key:md,label:p(`providerInstances.restore`,`Restore under its old id`),description:p(`providerInstances.restoreHint`,`Re-adding something that was removed under its original id keeps everything that points at it working.`)},{type:`text`,key:hd,label:p(`providerInstances.originalId`,`Original id`),required:!0,showWhen:{field:md,equals:!0}}]:[]]}]}),[ne,n,ie,r,S,p,oe]),[de,fe]=x(null),pe=g===null&&P!==``?P:void 0,L=C({queryKey:[`provider-instance-form`,e,g,pe??null],queryFn:()=>m.trpcClient.integrationInstances.instanceFormSchema.query({addonId:e,id:g,...pe===void 0?{}:{kind:pe}})}),R=f(()=>r===null?_d:Ku(r.formValues,L.data),[r,L.data]),z=f(()=>Ku(se,L.data),[se,L.data]),me=r===null?gu(L.data):null,B=me?.key,he=f(()=>L.data&&B!==void 0?vu(L.data,B):L.data,[L.data,B]),ge=me===null?[]:ar(se[me.key]),_e=ge.length>1,[ve,ye]=x(()=>new Map),be=_(e=>{ye(e)},[]),xe=f(()=>he?Ut(he,{...R}):null,[he,R]),Se=L.isSuccess&&!L.data,Ce=(F?.widgets??[]).flatMap(e=>{let t=e.placement===`connection`?pu(e.id):null;return t===null?[]:[{id:e.id,widget:t}]}),we=xe===null?[]:Ce.flatMap(({widget:e})=>e.ownedKeys(xe,se)),[Te,Ee]=x({}),De=_(e=>{Ee(t=>({...t,...e}))},[]),Oe=d(z);y(()=>{let e=Oe.current;Oe.current=z,Ee(t=>{let n=Object.entries(t).filter(([t])=>JSON.stringify(e[t])===JSON.stringify(z[t]));return n.length===Object.keys(t).length?t:Object.fromEntries(n)})},[z]);let ke=f(()=>({values:{...Ju(R,z),...Te},patch:De}),[R,z,Te,De]),Ae=k({mutationFn:async()=>{let t=m.trpcClient.integrationInstances,i={...qu(R,z),...Te},a=me!==null&&ge.length===1?{...i,[me.key]:ge[0]}:i;if(r===null&&me!==null&&_e){let r=yu({key:me.key,picked:ge,labels:ve,typedName:N,values:a}),i=``;for(let[a,o]of r.entries())try{i=(await t.createInstance.mutate({addonId:e,name:o.name,...Yu(n,F)?{id:Xu(n.instanceMode,e,Zu)}:{},...P===``?{}:{kind:P},...Object.keys(o.values).length>0?{values:o.values}:{}})).id}catch(e){throw h.invalidateQueries({queryKey:[cd]}),Error(p(`providerInstances.createManyStopped`,`{{done}} of {{total}} created: {{message}}`,{done:a,total:r.length,message:e instanceof Error?e.message:String(e)}))}return i}if(r===null){let r=ne&&ee?te:ie===void 0?Yu(n,F)?Xu(n.instanceMode,e,Zu):void 0:ae;return(await t.createInstance.mutate({addonId:e,name:N,...r===void 0?{}:{id:r},...P===``?{}:{kind:P},...Object.keys(a).length>0?{values:a}:{}})).id}return await t.updateInstance.mutate({addonId:e,id:r.id,name:N,values:a}),r.id},onSuccess:e=>{h.invalidateQueries({queryKey:[cd]}),hl({title:p(`providerInstances.saved`,`Saved`),message:_e?String(ge.length):N,severity:`info`}),a?.(e),i()},onError:e=>le(e.message)}),je=k({mutationFn:()=>m.trpcClient.integrationInstances.testInstance.mutate({addonId:e,id:g,values:qu(R,z),...g===null&&F!==void 0?{kind:F.id}:{}}),onSuccess:e=>fe(dl(e)),onError:e=>fe({status:`inconclusive`,error:e.message})});return v(Vi,{open:!0,onClose:i,title:r===null?p(`providerInstances.createTitle`,`Add {{provider}}`,{provider:Nu(n,F,t)}):p(`providerInstances.editTitle`,`Edit {{name}}`,{name:r.name}),error:I??(L.isError?L.error.message:null),width:`lg`,footer:s(j,{children:[(F?.canTest??n.canTest)&&s(W,{size:`sm`,variant:`outline`,type:`button`,disabled:je.isPending||xe===null&&!Se,onClick:()=>{fe(null),je.mutate()},children:[je.isPending?v(H,{className:`h-3.5 w-3.5 animate-spin`}):null,l??p(`providerInstances.test`,`Test connection`)]}),s(W,{size:`sm`,type:`button`,disabled:Ae.isPending||xe===null&&!Se||N.length===0&&!_e||!_e&&(re||oe!==`ok`),onClick:()=>{le(null),Ae.mutate()},children:[Ae.isPending?v(H,{className:`h-3.5 w-3.5 animate-spin`}):null,r===null&&_e?p(`providerInstances.createMany`,`Create {{count}}`,{count:ge.length}):r===null?p(`providerInstances.create`,`Create`):p(`providerInstances.saveChanges`,`Save changes`)]})]}),children:s(`div`,{className:`space-y-4`,children:[r===null?null:v(ud.Provider,{value:ke,children:o}),v(qo,{schema:_e?mu(ue,[fd,gd,md,hd]):ue,values:T,onChange:E}),me!==null&&_e&&v(hu,{field:me,values:se,onLabels:be}),F?.signIn!==void 0&&v(ul,{basePath:F.signIn.basePath,...F.signIn.methods===void 0?{}:{methods:F.signIn.methods},name:N,...r===null?{}:{brokerId:r.id},getSettings:()=>Ju(R,z),disabled:N.length===0,onSignedIn:e=>{h.invalidateQueries({queryKey:[`provider-instances-holder`]}),a?.(e),i()}}),r!==null&&F?.connectPath!==void 0&&s(W,{size:`sm`,variant:`outline`,type:`button`,onClick:()=>Wo(Uo(F.connectPath??``,r.id),()=>void h.invalidateQueries({queryKey:[`provider-instances-holder`]})),children:[v(lt,{className:`h-3.5 w-3.5`}),p(`providerInstances.connect`,`Connect account`)]}),xe===null?L.isError?null:Se?v(`p`,{className:`text-xs text-foreground-muted`,children:p(`providerInstances.noForm`,`This record has no configuration form beyond its name.`)}):s(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[v(H,{className:`h-3 w-3 animate-spin`}),p(`providerInstances.loading`,`Loading…`)]}):s(j,{children:[v(lr,{schema:mu(xe,we),values:se,onChange:ce,onAction:b}),Ce.map(({id:e,widget:{Component:t}})=>v(t,{schema:xe,values:se,onValuesChange:ce},e))]}),u!==void 0&&(F?.canTest??n.canTest)&&v(`p`,{className:`text-xs text-foreground-subtle`,children:u}),de!==null&&v(pl,{verdict:de})]})})}T();var xd=`integration-instances`,Sd=`instance-kinds-describe`;function Cd(e,t){let n=[];for(let r of e)if(!(t.addonId!==void 0&&r.addonId!==t.addonId))for(let e of r.description.kinds??[]){if(!(t.match===`link`?zt(e,t.functionCap):e.functionCap===t.functionCap))continue;let i=e.brokerKind??e.id;t.kind!==void 0&&i!==t.kind&&e.id!==t.kind||n.push({addonId:r.addonId,kind:e.id,brokerKind:i,label:e.label,...e.connectPath===void 0?{}:{connectPath:e.connectPath},...e.disconnectPath===void 0?{}:{disconnectPath:e.disconnectPath},...e.signIn===void 0?{}:{signInBasePath:e.signIn.basePath},...e.iconUrl===void 0?{}:{iconUrl:e.iconUrl},canTest:e.canTest??r.description.canTest===!0})}return n}function wd(e){let t=G(),n=vr({capName:e.functionCap}),r=vr({capName:xd}),i=E({queries:f(()=>{let e=new Set((r.data??[]).map(e=>e.addonId));return(n.data??[]).map(e=>e.addonId).filter(t=>e.has(t))},[n.data,r.data]).map(e=>({queryKey:[Sd,e],queryFn:async()=>({addonId:e,description:await t.trpcClient.integrationInstances.describe.query({addonId:e})})}))}),a=f(()=>i.flatMap(e=>e.data===void 0?[]:[e.data]),[i]);return{options:f(()=>Cd(a,e),[a,e.functionCap,e.addonId,e.kind,e.match]),holders:a,isLoading:n.isLoading===!0||r.isLoading===!0||i.some(e=>e.isLoading)}}function Td({children:e,onClose:t}){return v(Nn,{open:!0,onOpenChange:e=>!e&&t(),children:s(Na,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[v($i,{children:v(Ti,{children:`\xA0`})}),v(Li,{children:e})]})})}function Ed({functionCap:e,kind:t,addonId:n,onClose:r,onSaved:i,typedId:a,match:o}){let{t:s}=Z(),c=G(),l=O(),u=wd({functionCap:e,...n===void 0?{}:{addonId:n},...t===void 0?{}:{kind:t},...o===void 0?{}:{match:o}}),d=u.options[0],f=n??d?.addonId,p=C({queryKey:[`instance-create-description`,f,e,d?.kind??null],enabled:f!==void 0,queryFn:async()=>Au(await c.trpcClient.integrationInstances.describe.query({addonId:f??``}),e,d?.kind)});return f===void 0||p.data===null?v(Td,{onClose:r,children:f===void 0&&u.isLoading?v(H,{className:`h-4 w-4 animate-spin`}):v(pi,{message:s(`brokers.editor.noProvider`)})}):p.isError?v(Td,{onClose:r,children:v(pi,{message:p.error.message})}):p.data===void 0?v(Td,{onClose:r,children:v(H,{className:`h-4 w-4 animate-spin`})}):v(bd,{addonId:f,providerName:d?.label??``,description:p.data,instance:null,onClose:r,...a===void 0?{}:{typedId:a},onSaved:e=>{l.invalidateQueries(),i(e)}})}T();var Dd={ok:`success`,off:`default`,unknown:`default`,error:`danger`};function Od({kind:e,value:t,onChange:n,optional:r=!1,noneLabel:i,disabled:a=!1}){let{t:o}=Z(),[c,l]=x(!1),u=Qi({kind:e}),d=wa(u.data??[],t),f=d[0]?.id??null,p=!u.isLoading&&!u.isError&&u.data!==void 0;return y(()=>{!r&&!a&&p&&t===null&&f!==null&&n(f)},[r,a,p,t,f,n]),s(`div`,{className:`space-y-2`,children:[u.isLoading&&s(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[v(H,{className:`h-3.5 w-3.5 animate-spin`}),` `,o(`brokers.picker.loading`)]}),u.isError&&v(pi,{message:o(`brokers.picker.loadFailed`,{message:u.error?.message??o(`common.unknownError`)})}),!u.isLoading&&!u.isError&&d.length===0&&v(`p`,{className:`rounded-lg border border-border bg-surface px-3 py-4 text-center text-xs text-foreground-subtle`,children:o(`brokers.picker.none`)}),r&&v(`button`,{type:`button`,"aria-pressed":t===null,disabled:a,onClick:()=>n(null),className:`flex w-full items-center rounded-lg border bg-surface p-3 text-left text-xs text-foreground-subtle transition-colors ${t===null?`border-primary ring-1 ring-primary`:`border-border hover:border-foreground-subtle/30`}`,children:i??o(`brokers.picker.noneChoice`)}),d.map(e=>s(`button`,{type:`button`,"aria-pressed":t===e.id,disabled:a,onClick:()=>n(e.id),className:`flex w-full items-center justify-between gap-3 rounded-lg border bg-surface p-3 text-left transition-colors ${t===e.id?`border-primary ring-1 ring-primary`:`border-border hover:border-foreground-subtle/30`}`,children:[v(`span`,{className:`text-xs font-semibold text-foreground`,children:e.name}),v(jn,{variant:Dd[e.state],className:`text-[10px]`,children:e.stateLabel??e.state})]},e.id)),s(W,{variant:`outline`,size:`sm`,disabled:a,onClick:()=>l(!0),children:[v(Tt,{className:`h-3.5 w-3.5`}),` `,o(`brokers.picker.createNew`)]}),c&&v(Ed,{functionCap:`broker`,kind:e,onClose:()=>l(!1),onSaved:e=>{l(!1),n(e)}})]})}var kd=Nt;function Ad(e,t){let n=t[0];if(n===void 0)return null;let r=t.find(t=>t.id===e);return r===void 0?n.id:r.id}function jd(e,t){return Pt(e,t)}function Md(e){return e?.id?jd(e.addonId,e.id):`/integrations`}T();function Nd(e=!0){y(()=>{if(!e)return;let t=document.body.style.overflow;return document.body.style.overflow=`hidden`,()=>{document.body.style.overflow=t}},[e])}T();function Pd(e,t){let[n,r]=x(!1);return y(()=>{if(!e){r(!1);return}r(!1);let n=setTimeout(()=>r(!0),t);return()=>clearTimeout(n)},[e,t]),n}T();function Fd({kind:e,onResolved:t,onBack:n}){let{t:r}=Z(),[i,a]=x(null);return s(`div`,{className:`space-y-4`,children:[s(W,{variant:`ghost`,size:`sm`,onClick:n,children:[v(re,{className:`h-3.5 w-3.5`}),` `,r(`common.back`)]}),v(Od,{kind:e,value:i,onChange:a}),v(`div`,{className:`flex justify-end pt-1`,children:v(W,{variant:`primary`,size:`sm`,disabled:i===null,onClick:()=>i!==null&&t(i),children:r(`integrations.brokerStep.useThisBroker`,`Use this broker`)})})]})}T();function Id({providerId:e,onImport:t,onSkip:n}){let{t:r}=Z(),[i,a]=x(new Set),o=za(),c=o.data,l=o.isPending||!o.data&&!o.isError;y(()=>{e&&(o.isPending||o.data||o.mutate({addonId:e}))},[e,o]);function u(e){a(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}if(l)return s(`div`,{className:`flex flex-col items-center py-12`,children:[v(`div`,{className:`h-6 w-6 animate-spin rounded-full border-2 border-primary border-t-transparent`}),v(`p`,{className:`mt-3 text-xs text-foreground-subtle`,children:r(`integrations.searchingDevices`)})]});let d=c??[];return s(`div`,{className:`space-y-4`,children:[v(`p`,{className:`text-xs text-foreground-subtle`,children:d.length>0?r(`integrations.foundDevices`,{count:d.length}):r(`integrations.noDevicesFound`)}),d.length>0&&v(`div`,{className:`space-y-1.5 max-h-64 overflow-y-auto`,children:d.map(e=>{let t=e.stableId,n=e.suggestedName??t,a=i.has(t),o=e.alreadyOnboarded===!0;return s(W,{variant:`unstyled`,onClick:()=>{o||u(t)},disabled:o,title:o?r(`integrations.alreadyAddedHint`,{defaultValue:`Already added as "{{name}}" — re-adding would overwrite its settings.`,name:e.onboardedName??n}):void 0,className:`flex w-full items-center gap-3 rounded-lg border p-3 text-left transition-colors ${o?`border-border bg-surface opacity-60 cursor-not-allowed`:a?`border-primary/40 bg-primary/5`:`border-border bg-surface hover:border-foreground-subtle/30`}`,children:[v(`div`,{className:`flex h-5 w-5 items-center justify-center rounded border flex-shrink-0 ${a&&!o?`border-primary bg-primary`:`border-border`}`,children:a&&!o&&v(_e,{className:`h-3 w-3 text-primary-foreground`})}),v(xe,{className:`h-3.5 w-3.5 text-foreground-subtle flex-shrink-0`}),v(`span`,{className:`text-xs font-medium text-foreground truncate`,children:n}),o&&v(`span`,{className:`ml-auto flex-shrink-0 rounded bg-surface-muted px-1.5 py-0.5 text-[10px] font-medium text-foreground-subtle`,children:r(`integrations.alreadyAdded`,{defaultValue:`Already added`})})]},t)})}),s(`div`,{className:`flex items-center justify-between pt-2`,children:[v(W,{variant:`unstyled`,onClick:n,className:`rounded-lg border border-border px-3 py-1.5 text-xs text-foreground-subtle hover:text-foreground transition-colors`,children:r(`integrations.skip`)}),d.length>0&&s(W,{variant:`unstyled`,onClick:()=>t(Array.from(i)),disabled:i.size===0,className:`rounded-lg bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground shadow-sm disabled:opacity-50`,children:[r(`integrations.importSelected`),` (`,i.size,`)`]})]})]})}T();function Ld({addonId:e,configSchema:t,canTest:n=!0,instanceKind:r,initialName:i,initialConfig:a,submitLabel:o,hideName:c=!1,saving:l=!1,onScan:u,onSave:d,onBack:f}){let{t:p}=Z(),[m,h]=x(i??``),[g,_]=x(a??{}),[y,b]=x(null),S=ur({onSuccess:e=>b(dl(e)),onError:e=>b({status:`inconclusive`,error:String(e)})}),C=Jn(),w=!n||y?.status===`validated`,T=!c&&m.trim().length===0,E=!T&&w;return s(`div`,{className:`space-y-4`,children:[!c&&s(`div`,{children:[v(`label`,{htmlFor:`integration-name`,className:`block text-[11px] font-medium text-foreground mb-1`,children:p(`integrations.integrationName`)}),v(U,{id:`integration-name`,type:`text`,value:m,onChange:e=>h(e.target.value),placeholder:p(`integrations.integrationNamePlaceholder`),"aria-invalid":T,"aria-describedby":T?`integration-name-error`:void 0,className:`w-full rounded-lg border bg-surface px-3 py-2 text-xs text-foreground placeholder:text-foreground-subtle focus:outline-none ${T?`border-danger focus:border-danger`:`border-border focus:border-primary/50`}`}),T&&v(`p`,{id:`integration-name-error`,"data-testid":`integration-name-error`,className:`mt-1 text-xs text-danger`,children:p(`integrations.nameRequired`,`Name is required`)})]}),t&&v(qo,{schema:t,values:g,onChange:e=>{_(e),b(null)},onAction:async(i,a,o)=>{let s=await C.mutateAsync({addonId:e,action:i,input:o??{}});if(n&&typeof s==`object`&&s){let n=s;if(!(typeof n.token==`string`||typeof n.sslCertificate==`string`||typeof n.host==`string`))return s;let i={...g};for(let[e,t]of Object.entries(n))typeof t==`string`&&e!==`summary`&&(i[e]=t);let a=Ft(t,i);_(a),b(null),S.mutate({addonId:e,id:null,values:a,...r===void 0?{}:{kind:r}})}return s}}),y&&v(pl,{verdict:y}),s(`div`,{className:`flex items-center justify-between pt-2`,children:[v(W,{variant:`unstyled`,onClick:f,className:`rounded-lg border border-border px-3 py-1.5 text-xs text-foreground-subtle hover:text-foreground transition-colors`,children:p(`integrations.back`)}),s(`div`,{className:`flex items-center gap-2`,children:[u&&s(W,{variant:`outline`,size:`sm`,onClick:u,"data-testid":`integration-scan`,children:[v(St,{className:`h-3.5 w-3.5`}),p(`integrations.scanFromForm`,`Scan the network`)]}),n&&v(W,{variant:`unstyled`,onClick:()=>S.mutate({addonId:e,id:null,values:Ft(t,g),...r===void 0?{}:{kind:r}}),disabled:S.isPending,className:`rounded-lg border border-border px-3 py-1.5 text-xs text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50 disabled:cursor-not-allowed`,children:S.isPending?p(`integrations.testing`):p(`integrations.testConnection`)}),s(`div`,{className:`flex flex-col items-end gap-1`,children:[T&&v(`p`,{"data-testid":`integration-name-submit-error`,className:`text-xs text-danger`,children:p(`integrations.nameRequiredSubmit`,`Enter a name before continuing.`)}),v(W,{variant:`unstyled`,onClick:()=>{T||d({name:m,config:Ft(t,g)})},disabled:!E||l,className:`rounded-lg bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground shadow-sm disabled:opacity-50`,children:l?p(`integrations.saving`,{defaultValue:`Saving…`}):o??p(`integrations.forward`)})]})]})]})]})}var Rd=new Set([`@dominevo/server`,`@dominevo/types`,`@dominevo/sdk`,`@dominevo/shm-ring`,`@dominevo/ui-library`]);function zd(e){return e!==void 0&&Rd.has(e)}var Bd=`@dominevo/addon-agent-ui`;function Vd(e){return zd(e)||e===Bd}function Hd(e){return e.integrationSection===void 0?zd(e.packageName)?`system`:`providers`:e.integrationSection}function Ud(e){let t=new Set;for(let n of e??[])Hd(n.manifest)===`system`&&t.add(n.manifest.id);return t}function Wd(e,t){return{providers:e.filter(e=>!t.has(e.addonId)),system:e.filter(e=>t.has(e.addonId))}}function Gd(e,t){return[...e].sort((e,n)=>e.name.localeCompare(n.name,t,{sensitivity:`base`}))}var Kd=/\.(svg|png|jpe?g|webp)$/i,qd=`provider-`;function Jd(e){return typeof e==`string`&&Kd.test(e)&&!e.includes(`..`)}function Yd(e){let t=[];for(let n of e??[]){let e=n,r=e?.manifest?.id;if(typeof r!=`string`||r.length===0)continue;let i=e?.declaration?.icon??e?.manifest?.icon;Jd(i)&&t.push([r,i])}return new Map(t)}function Xd(e,t){if(!t)return null;let n=t.startsWith(qd)?[t]:[t,`${qd}${t}`];for(let t of n){let n=e.get(t);if(n)return V(`/api/addon-assets/${encodeURIComponent(t)}/${n}`)}return null}T();var Zd=5*6e4,Qd=D(new Map);function $d({children:e}){let{data:t}=tr(void 0,{staleTime:Zd}),n=f(()=>Yd(t),[t]);return v(Qd.Provider,{value:n,children:e})}function ef(e){return Xd(M(Qd),e)}T();var tf={amcrest:{icon:bn,color:`#3b82f6`,label:`Amcrest`},hikvision:{icon:rt,color:`#a855f7`,label:`Hikvision`},reolink:{icon:$e,color:`#06b6d4`,label:`Reolink`},homeassistant:{icon:xt,color:`#22d3ee`,label:`Home Assistant`},rtsp:{icon:Re,color:`#78716c`,label:`RTSP`},onvif:{icon:Re,color:`#78716c`,label:`ONVIF`}},nf={sm:`h-4 w-4`,md:`h-5 w-5`,lg:`h-6 w-6`,xl:`h-16 w-16`},rf={sm:`h-7 w-7`,md:`h-8 w-8`,lg:`h-10 w-10`,xl:`h-16 w-16`};function af(e){let t=e.toLowerCase();return t.startsWith(`provider-`)?t.slice(9):t}function of(e){return tf[af(e)]??{icon:bn,color:`#78716c`,label:e}}function sf({type:e,size:t=`md`,showLabel:n,iconUrl:r}){let i=of(e),a=i.icon,[o,c]=x(new Set),l=[r,ef(e)].find(e=>typeof e==`string`&&e!==``&&!o.has(e));return s(`div`,{className:`flex items-center gap-2`,children:[v(`div`,{className:`flex items-center justify-center rounded-lg ${rf[t]}`,style:{backgroundColor:`${i.color}15`},children:l===void 0?v(a,{className:nf[t],style:{color:i.color}}):v(`img`,{src:l,alt:i.label,className:nf[t],onError:()=>c(e=>new Set([...e,l]))})}),n&&v(`span`,{className:`text-xs font-medium text-foreground-subtle`,children:i.label})]})}function cf({children:e}){return v(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-2 sm:gap-3 lg:grid-cols-3`,children:e})}function lf({addonId:e,name:t,openLabel:n,onOpen:r,body:i,footer:a,disabled:o=!1,testId:c,buttonTestId:l,iconUrl:u}){return s(`article`,{"data-testid":c,className:`relative flex min-w-0 items-stretch gap-3 overflow-x-clip rounded-lg border border-border bg-surface p-3`,children:[v(W,{type:`button`,variant:`ghost`,"aria-label":n,disabled:o,"data-testid":l,onClick:r,className:`absolute inset-0 z-0 h-auto w-auto rounded-lg p-0 focus-visible:ring-2 focus-visible:ring-primary`}),v(`div`,{className:`pointer-events-none relative z-10 flex w-20 shrink-0 items-center justify-center`,children:v(sf,{type:e,size:`xl`,...u===void 0?{}:{iconUrl:u}})}),s(`div`,{className:`pointer-events-none relative z-10 grid min-w-0 flex-1 grid-rows-[1fr_auto_1fr] gap-1`,children:[v(`p`,{className:`min-w-0 self-start truncate text-sm font-semibold text-foreground`,children:t}),i,v(`div`,{className:`self-end justify-self-start`,children:a})]})]})}function uf({kind:e,children:t}){let{t:n}=Z(),r=`integrations-section-${e}`;return s(`section`,{"aria-labelledby":r,"data-testid":r,className:`min-w-0 space-y-2`,children:[v(`h2`,{id:r,className:Ae,children:e===`providers`?n(`integrations.sections.providers`,`Providers`):n(`integrations.sections.system`,`System`)}),t]})}var df=`(hover: none) and (pointer: coarse)`;function ff(){if(typeof window>`u`||typeof window.matchMedia!=`function`)return!0;try{return!window.matchMedia(df).matches}catch{return!0}}T();function pf(e,t){return`${e.name} ${e.description} ${e.addonId}`.toLowerCase().includes(t)}function mf({onSelect:e,onClose:t,pendingAddonId:n=null,source:r}){let{t:i,i18n:a}=Z(),o=_o(),[c,l]=x(``),u=d(null),p=Tr(void 0,{enabled:r===void 0}),m=r===void 0?p.data:void 0,h=r===void 0&&p.isLoading;y(()=>{h||!ff()||u.current?.focus()},[h]);let{data:g}=tr(void 0),_=n!==null,b=f(()=>r===void 0?(m??[]).map(n=>{let r=n.instanceMode===`unique`&&n.existingInstances.length>0;return{key:n.addonId,addonId:n.addonId,name:n.name,description:n.description??``,open:()=>{let i=n.existingInstances[0];r&&i!==void 0?(t(),o(jd(n.addonId,i.id))):e(n.addonId,n.instanceMode,n.discoveryMode,n.providerLabel??n.name,n.kind,n.brokerKind,n.mode,n.canTest)},footer:r?s(`span`,{className:`flex items-center gap-1 text-xs font-medium text-foreground-subtle`,children:[v(dt,{className:`h-3 w-3`}),i(`integrations.manage`)]}):null}}):r.providers.map(e=>({...e,key:e.kind===void 0?e.addonId:`${e.addonId}-${e.kind}`,open:()=>r.onPick(e.addonId,e.kind),footer:null})),[r,m,t,e,o,i]),S=f(()=>{let e=c.trim().toLowerCase();return e.length===0?b:b.filter(t=>pf(t,e))},[b,c]),C=f(()=>{let e=Wd(S,Ud(g));return{providers:Gd(e.providers,a.language),system:Gd(e.system,a.language)}},[S,g,a.language]);if(h)return v(`div`,{className:`grid grid-cols-1 gap-2 p-2 sm:grid-cols-2 lg:grid-cols-3`,children:[1,2,3,4].map(e=>v(`div`,{className:`h-24 rounded-lg bg-surface animate-pulse`},e))});let w=e=>v(cf,{children:e.map(e=>v(lf,{testId:`provider-card-${e.key}`,buttonTestId:`provider-pick-${e.key}`,addonId:e.addonId,...e.iconUrl===void 0?{}:{iconUrl:e.iconUrl},name:e.name,openLabel:e.name,disabled:_,onOpen:e.open,body:e.description.length>0?v(`p`,{className:`line-clamp-2 text-xs text-foreground-muted`,children:e.description}):v(`span`,{}),footer:n===e.addonId?v(H,{className:`h-4 w-4 animate-spin text-primary`}):e.footer},e.key))});return s(`div`,{className:`space-y-3`,"data-testid":`provider-picker`,children:[s(`div`,{className:`relative`,children:[v(ft,{className:`pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-foreground-subtle`,"aria-hidden":!0}),v(U,{ref:u,type:`search`,value:c,onChange:e=>l(e.target.value),placeholder:i(`integrations.searchProviders`,`Search integrations…`),className:`pl-8`,"data-testid":`provider-picker-search`,"data-dialog-autofocus":!0,"aria-label":i(`integrations.searchProviders`,`Search integrations…`)})]}),C.providers.length>0&&v(uf,{kind:`providers`,children:w(C.providers)}),C.system.length>0&&v(uf,{kind:`system`,children:w(C.system)}),S.length===0&&v(`div`,{className:`py-8 text-center text-xs text-foreground-subtle`,children:b.length===0?i(`integrations.noProviders`):i(`integrations.noProvidersMatch`,`No integrations match your search.`)})]})}function hf(e){return e.setupIntegration===!0||e.prefilledConfig.setupIntegration===!0}function gf(e,t,n){let r={};for(let[e,n]of Object.entries(t.prefilledConfig))e!==`setupIntegration`&&(r[e]=typeof n==`string`&&e===`host`?n.trim():n);let i=n?.trim()??``;return{addonId:e,name:i.length>0?Yt(i):t.suggestedName,config:r,...t.stableId===void 0?{}:{originStableId:t.stableId}}}function _f(e,t,n){return hf(t)?gf(e,t,n):null}function vf(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function yf(e){if(!vf(e)||!vf(e.integrationSeed))return null;let t=e.integrationSeed,n=t.addonId,r=t.name,i=t.config;if(typeof n!=`string`||n.length===0||typeof r!=`string`||!vf(i))return null;let a={};for(let[e,t]of Object.entries(i))a[e]=t;let o=t.originStableId;return{addonId:n,name:r,config:a,...typeof o==`string`&&o.length>0?{originStableId:o}:{}}}function bf(e){let t=new Map;for(let n of e)t.set(n.stableId,n);let n=e=>{let n=e.parentStableId;if(n===void 0||n===e.stableId)return null;let r=t.get(n);if(r===void 0)return null;let i=new Set([e.stableId]),a=r;for(;a!==void 0;){if(i.has(a.stableId))return null;i.add(a.stableId),a=a.parentStableId===void 0?void 0:t.get(a.parentStableId)}return r},r=new Map,i=[];for(let t of e){let e=n(t);if(e===null){i.push(t);continue}let a=r.get(e.stableId)??[];a.push(t),r.set(e.stableId,a)}let a=e=>({candidate:e,children:(r.get(e.stableId)??[]).map(a)});return i.map(a)}function xf(e){return e.flatMap(e=>[e.candidate,...xf(e.children)])}T();var Sf=6e4;function Cf(){let e=Qn({},{refetchInterval:Sf}),{refetch:t}=e,n=_(()=>void t(),[t]);return{count:e.data===void 0?null:e.data.proposals.length,refresh:n}}function wf({count:e}){return e===null||e===0?null:v(jn,{variant:`info`,style:`fill`,size:`sm`,"data-testid":`discovery-pill`,children:e})}function Tf({onSetupIntegration:e}){let{t}=Z(),n=Qn({},{refetchInterval:Sf}),r=Ei(),i=Ya(),[a,o]=x(new Set),{refetch:c}=n,l=_(async(e,t)=>{o(t=>new Set(t).add(e));try{await t(),c()}catch{}finally{o(t=>{let n=new Set(t);return n.delete(e),n})}},[c]),u=_(async t=>{let n=_f(t.addonId,t.candidate);if(n!==null){e(n);return}await l(t.id,()=>r.mutateAsync({addonId:t.addonId,candidate:t.candidate}))},[r,e,l]),d=_(e=>l(e.id,()=>i.mutateAsync({id:e.id})),[i,l]),f=n.data?.proposals??[];return f.length===0?null:s(`section`,{className:`space-y-2`,"data-testid":`discovery-proposals`,children:[s(`h3`,{className:`flex items-center gap-2`,children:[v(`span`,{className:Ae,children:t(`integrations.discoveryProposals.title`,`Found in the background`)}),s(`span`,{className:`text-[10px] text-foreground-subtle`,children:[`(`,f.length,`)`]})]}),v(`div`,{className:`space-y-1.5`,children:f.map(e=>s(`div`,{"data-testid":`discovery-proposal`,className:`flex items-center gap-2 rounded-lg border border-border bg-surface px-3 py-2`,children:[s(`div`,{className:`min-w-0 flex-1`,children:[v(`p`,{className:`truncate text-sm font-medium text-foreground`,children:e.candidate.suggestedName}),v(`p`,{className:`truncate text-xs text-foreground-muted`,children:e.addonId})]}),a.has(e.id)?v(H,{className:`h-4 w-4 animate-spin text-foreground-muted`,"aria-hidden":!0}):s(j,{children:[v(W,{variant:`secondary`,size:`sm`,onClick:()=>void d(e),children:t(`integrations.discoveryProposals.dismiss`,`Dismiss`)}),s(W,{size:`sm`,onClick:()=>void u(e),children:[v(_e,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),t(`integrations.discoveryProposals.adopt`,`Adopt`)]})]})]},e.id))})]})}var Ef=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\/(\d{1,2})$/;function Df(e){let t=Ef.exec(e.trim());if(t===null)return{ok:!1,reason:`format`};let n=[t[1],t[2],t[3],t[4]].map(e=>Number(e));if(n.some(e=>e>255))return{ok:!1,reason:`format`};let r=Number(t[5]);return r>32?{ok:!1,reason:`format`}:r<22?{ok:!1,reason:`prefix`}:{ok:!0,cidr:`${n.join(`.`)}/${r}`}}T();function Of(){let{t:e}=Z(),t=ro(),n=Rr({onSuccess:()=>void t.refetch()}),[r,i]=x(``),[a,o]=x(null),c=t.data?.subnets??[],l=async t=>{try{return await n.mutateAsync({subnets:[...t]}),!0}catch{return o(e(`integrations.scanNetworkModal.subnets.saveFailed`,`The network list could not be saved.`)),!1}},u=async()=>{let t=Df(r);if(!t.ok){o(t.reason===`prefix`?e(`integrations.scanNetworkModal.subnets.errorPrefix`,`A network larger than a /22 cannot be scanned.`):e(`integrations.scanNetworkModal.subnets.errorFormat`,`Enter a network like 192.0.2.0/24.`));return}if(c.includes(t.cidr)){o(e(`integrations.scanNetworkModal.subnets.errorDuplicate`,`Already in the list.`));return}o(null),await l([...c,t.cidr])&&i(``)};return s(`section`,{className:`space-y-2`,"data-testid":`scan-subnets`,children:[v(`h3`,{className:Ae,children:e(`integrations.scanNetworkModal.subnets.title`,`Extra networks to scan`)}),v(`p`,{className:`text-xs text-foreground-muted`,children:c.length===0?e(`integrations.scanNetworkModal.subnets.none`,`Only this hub's own networks are scanned.`):e(`integrations.scanNetworkModal.subnets.hint`,`Every scan covers this hub's own networks and these.`)}),c.length>0&&v(`div`,{className:`flex flex-wrap gap-1.5`,children:c.map(e=>v(Da,{label:e,testId:`scan-subnet-${e}`,onRemove:()=>void l(c.filter(t=>t!==e))},e))}),s(`div`,{className:`flex items-start gap-2`,children:[s(`div`,{className:`min-w-0 flex-1`,children:[v(U,{value:r,onChange:e=>{i(e.target.value),o(null)},onKeyDown:e=>{e.key===`Enter`&&u()},placeholder:`192.0.2.0/24`,state:a===null?`default`:`error`,"aria-label":e(`integrations.scanNetworkModal.subnets.title`,`Extra networks to scan`),"data-testid":`scan-subnet-input`}),a!==null&&v(`p`,{className:`mt-1 text-xs text-danger`,children:a})]}),s(W,{variant:`outline`,size:`sm`,onClick:()=>void u(),disabled:n.isPending||r.trim().length===0,"data-testid":`scan-subnet-add`,children:[v(Tt,{className:`h-3.5 w-3.5`}),e(`integrations.scanNetworkModal.subnets.add`,`Add network`)]})]})]})}T();function kf({open:e,onClose:t,scope:n,onSetupIntegration:r,pickMode:i=`adopt`,onAdopted:a}){let{t:o}=Z(),c=Ei(),[l,u]=x(new Set),[d,p]=x(new Set),[m,h]=x(new Set),{data:g}=Mr({projection:`slim`}),y=f(()=>new Set((g??[]).map(e=>e.stableId)),[g]),b=_(async(e,t)=>{p(e=>new Set(e).add(t.stableId));try{await c.mutateAsync({addonId:e,candidate:t}),a?.(),u(e=>new Set(e).add(t.stableId)),h(e=>{let n=new Set(e);return n.delete(t.stableId),n})}catch{}finally{p(e=>{let n=new Set(e);return n.delete(t.stableId),n})}},[c,a]),S=_(async(e,n)=>{let a=i===`fill`?gf(e,n):_f(e,n);if(a!==null){r?.(a),t();return}await b(e,n)},[b,t,r,i]),C=_(e=>{h(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),w=_(()=>{u(new Set),h(new Set)},[]),T=f(()=>({existingStableIds:y,adopted:l,adopting:d,selection:{selected:m,toggle:C},pick:S,adoptOne:b,fill:i===`fill`}),[y,l,d,m,C,S,i]),E=n?o(`integrations.scanNetworkModal.titleScoped`,`Scan network — {{label}}`,{label:n.label}):o(`integrations.scanNetworkModal.title`,`Scan network for devices`);return v(Nn,{open:e,onOpenChange:e=>!e&&t(),children:s(Na,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,children:[v($i,{children:v(Ti,{children:s(`span`,{className:`flex items-center gap-2`,children:[v(St,{className:`h-4 w-4 text-primary`}),E]})})}),s(Li,{className:`space-y-4`,children:[v(Of,{}),!n&&i===`adopt`&&r&&v(Tf,{onSetupIntegration:e=>{t(),r(e)}}),n?v(If,{scope:n,row:T,onReset:w}):v(Ff,{row:T,onReset:w})]})]})})}function Af(e,t){return!t&&e.selectable!==!1&&!hf(e)}function jf({addonId:e,nodes:t,row:n,depth:r}){return v(`div`,{className:r===0?`space-y-1.5`:`ml-4 space-y-1.5 border-l border-border pl-3`,"data-testid":r===0?void 0:`scan-children`,children:t.map(t=>s(`div`,{className:`space-y-1.5`,children:[v(Mf,{addonId:e,candidate:t.candidate,row:n}),t.children.length>0&&v(jf,{addonId:e,nodes:t.children,row:n,depth:r+1})]},t.candidate.stableId))})}function Mf({addonId:e,candidate:t,row:n}){let{t:r}=Z(),i=t.prefilledConfig.host,a=typeof i==`string`?i:null,o=n.existingStableIds.has(t.stableId)||t.alreadyOnboarded===!0||t.onboardedDeviceId!==void 0,c=n.adopted.has(t.stableId)||o,l=n.adopting.has(t.stableId),u=n.fill||hf(t),d=!c&&(u||t.selectable!==!1),f=d&&Af(t,n.fill);return s(`div`,{className:`flex items-center gap-3 rounded-lg border border-border bg-surface px-3 py-2`,"data-testid":`scan-row-${t.stableId}`,children:[f&&v(Dt,{checked:n.selection.selected.has(t.stableId),onChange:()=>n.selection.toggle(t.stableId),disabled:l,"aria-label":r(`integrations.scanNetworkModal.select`,`Select {{name}}`,{name:t.suggestedName})}),s(`div`,{className:`min-w-0 flex-1`,children:[v(`p`,{className:`truncate text-xs font-medium text-foreground`,children:t.suggestedName}),a&&v(`p`,{className:`truncate font-mono text-[10px] text-foreground-subtle`,children:a}),o&&t.onboardedName!==void 0&&v(`p`,{className:`truncate text-[10px] text-foreground-subtle`,children:t.onboardedName})]}),c?s(`span`,{className:`flex items-center gap-1 text-[11px] text-foreground-subtle`,children:[v(_e,{className:`h-3.5 w-3.5`}),` `,o?r(`integrations.scanNetworkModal.alreadyAdded`,`Already added`):r(`integrations.scanNetworkModal.added`,`Added`)]}):d?s(W,{size:`sm`,variant:u?`outline`:`primary`,onClick:()=>void n.pick(e,t),disabled:l,children:[l?v(H,{className:`h-3.5 w-3.5 animate-spin`}):u?null:v(ce,{className:`h-3.5 w-3.5`}),u?n.fill?r(`integrations.scanNetworkModal.use`,`Use`):r(`integrations.scanNetworkModal.setUp`,`Set up`):r(`common.add`,`Add`)]}):null]})}function Nf({addonId:e,label:t,candidates:n,row:r}){let i=f(()=>bf(n),[n]);return s(`section`,{className:`space-y-2`,"data-testid":`scan-group-${e}`,children:[s(`h3`,{className:`flex items-center gap-2`,children:[v(sf,{type:e,size:`sm`}),v(`span`,{className:Ae,children:t}),s(`span`,{className:`text-[10px] text-foreground-subtle`,children:[`(`,n.length,`)`]})]}),v(jf,{addonId:e,nodes:i,row:r,depth:0})]})}function Pf(e,t){return e.flatMap(e=>xf(bf(e.candidates)).filter(e=>Af(e,t)).map(t=>({addonId:e.addonId,candidate:t})))}function Ff({row:e,onReset:t}){let{t:n}=Z(),r=yi(),i=_(()=>{t(),r.mutate({})},[r,t]);y(()=>{!r.isPending&&!r.data&&i()},[]);let a=f(()=>(r.data?.groups??[]).filter(e=>e.candidates.length>0),[r.data]),o=f(()=>a.reduce((e,t)=>e+t.candidates.length,0),[a]),c=f(()=>Pf(a,e.fill),[a,e.fill]);return s(`div`,{className:`space-y-4`,children:[s(`div`,{className:`flex items-center justify-between gap-2`,children:[v(`p`,{className:`text-xs text-foreground-subtle`,children:!r.isPending&&a.length>0?n(`integrations.scanNetworkModal.found`,{count:o}):null}),s(`div`,{className:`flex items-center gap-2`,children:[v(Lf,{entries:c,row:e}),s(W,{variant:`outline`,size:`sm`,onClick:i,disabled:r.isPending,children:[v(et,{className:`h-3.5 w-3.5 ${r.isPending?`animate-spin`:``}`}),n(`integrations.scanNetworkModal.reScan`,`Re-scan`)]})]})]}),r.isPending&&v(zf,{label:n(`integrations.scanNetworkModal.scanningTheLocalNetwork`,`Scanning the local network…`)}),!r.isPending&&r.isError&&v(Bf,{}),!r.isPending&&r.data&&a.length===0&&v(Rf,{}),!r.isPending&&a.map(t=>v(Nf,{addonId:t.addonId,label:t.label,candidates:t.candidates,row:e},t.addonId))]})}function If({scope:e,row:t,onReset:n}){let{t:r}=Z(),i=si({addonId:e.addonId}).data??null,[a,o]=x({}),c=$a(),l=_(()=>{n(),c.mutate({addonId:e.addonId,params:a})},[c,e.addonId,a,n]),u=f(()=>c.data?.candidates??[],[c.data]),d=f(()=>Pf([{addonId:e.addonId,candidates:u}],t.fill),[e.addonId,u,t.fill]);return s(`div`,{className:`space-y-4`,children:[i&&v(qo,{schema:i,values:a,onChange:o}),s(W,{onClick:l,disabled:c.isPending,children:[c.isPending?v(H,{className:`h-3.5 w-3.5 animate-spin`}):v(St,{className:`h-3.5 w-3.5`}),c.isPending?r(`integrations.scanNetworkModal.scanning`,`Scanning…`):r(`integrations.scanNetworkModal.scan`,`Scan`)]}),v(Lf,{entries:d,row:t}),c.isError&&v(Bf,{}),!c.isPending&&c.data&&u.length===0&&v(Rf,{}),!c.isPending&&u.length>0&&s(`div`,{className:`space-y-2`,children:[v(`p`,{className:`text-xs text-foreground-subtle`,children:r(`integrations.scanNetworkModal.foundShort`,{count:u.length})}),v(Nf,{addonId:e.addonId,label:e.label,candidates:u,row:t})]})]})}function Lf({entries:e,row:t}){let{t:n}=Z(),r=e.filter(e=>t.selection.selected.has(e.candidate.stableId));if(r.length===0)return null;let i=async()=>{for(let e of r)await t.adoptOne(e.addonId,e.candidate)};return s(W,{size:`sm`,onClick:()=>void i(),"data-testid":`scan-add-selected`,children:[v(ce,{className:`h-3.5 w-3.5`}),n(`integrations.scanNetworkModal.addSelected`,`Add selected ({{count}})`,{count:r.length})]})}function Rf(){let{t:e}=Z();return v(`p`,{className:`py-6 text-center text-xs text-foreground-subtle`,children:e(`integrations.scanNetworkModal.noDevicesRespondedToThe`,`No devices responded to the scan.`)})}function zf({label:e}){return s(`div`,{className:`flex flex-col items-center py-12`,children:[v(H,{className:`h-6 w-6 animate-spin text-primary`}),v(`p`,{className:`mt-3 text-xs text-foreground-subtle`,children:e})]})}function Bf(){let{t:e}=Z();return s(`div`,{className:`flex items-start gap-3 rounded-lg border border-danger/40 bg-danger/10 px-4 py-3`,children:[v(He,{className:`mt-0.5 h-4 w-4 shrink-0 text-danger`}),v(`p`,{className:`text-xs text-danger`,children:e(`integrations.scanNetworkModal.theScanFailedTryAgain`,`The scan failed. Try again.`)})]})}T();function Vf(e){let t=e=>{if(e.type===`separator`||e.type===`info`||e.type===`button`)return e;if(e.type===`group`)return{...e,fields:e.fields.map(e=>t(e))};let{value:n,...r}=e;return r};return{...e.tabs?{tabs:e.tabs}:{},sections:e.sections.map(e=>({...e,fields:e.fields.map(t)}))}}var Hf=2e4,Uf=`device-provider`;function Wf({open:e,onClose:t,seed:n=null,pickFrom:r}){let{t:i}=Z(),a=_o(),o=O(),[c,l]=x(`picker`),[u,d]=x(null),[p,m]=x(null),[h,g]=x(`manual`),[_,b]=x(null),[S,C]=x(``),[w,T]=x(null),[E,D]=x(null),[k,A]=x(!1),[M,N]=x({}),[P,F]=x(``),[ee,te]=x(!1),[ne,re]=x(0),[ie,ae]=x(``),oe=ki({},{enabled:e&&c===`config`}),se=Kr({addonId:u??``},{enabled:e&&(c===`config`||c===`broker`)&&u!==null}),ce=(se.data?.kinds??[]).filter(e=>e.canTest!==!1),I=ce.length===1?ce[0]?.id:void 0,le=(se.data?.kinds??[]).filter(e=>e.functionCap===Uf),ue=le.length===1?le[0]?.id:void 0,de=u!==null&&(oe.data?.providers??[]).some(e=>e.addonId===u),fe=n?.config.host,pe=n===null?``:`${n.addonId}\0${n.name}\0${typeof fe==`string`?fe:``}`;e&&n!==null&&P!==pe&&(F(pe),d(n.addonId),C(n.name),N({...n.config}),l(`config`));let L=Tr(void 0,{enabled:e&&n!==null}),R=L.data?.find(e=>e.addonId===u)?.mode??`account`,{data:z}=Vn({addonId:u??``,id:null,mode:R,...n?.originStableId===void 0?{}:{candidateStableId:n.originStableId}},{enabled:u!=null}),me=f(()=>z?Vf(z):null,[z]),B=hr({onSuccess:()=>{o.invalidateQueries({queryKey:[[`integrations`]]}),o.invalidateQueries({queryKey:[[`integrationInstances`]]})}}),he=za(),ge=he.data;y(()=>{if(!e||n===null)return;let t=L.data?.find(e=>e.addonId===n.addonId);if(!t)return;A(t.canTest),g(t.discoveryMode);let r=t.providerLabel??t.name;typeof r==`string`&&r.length>0&&C(Zt({providerLabel:r,mode:t.mode,brokerKind:t.brokerKind}))},[e,n,L.data]),y(()=>{c!==`discovery`||!p||!u||he.isPending||he.data||he.mutate({addonId:u})},[c,p,u,he]);let _e=Ei({onSuccess:()=>o.invalidateQueries({queryKey:[[`deviceManager`]]})});function ve(e,t,n,r,i,a,o,s){if(B.isPending)return;let c=Zt({providerLabel:r,mode:o,brokerKind:a});if(d(e),A(s),g(n),C(c),D(null),B.reset(),o===`broker`){if(!a){D(`Addon '${e}' declares mode 'broker' but no brokerKind in its manifest`);return}b(a),l(`broker`);return}if(o===`account`){l(`config`);return}ye(e,c)}async function ye(e,n){try{let r=await B.mutateAsync({addonId:e,name:n,values:{}});t(),we(),a(`${jd(e,r.id)}&add=1`)}catch{}}async function be(e){if(u)try{let t=await B.mutateAsync({addonId:u,name:e.name,values:e.config,...I===void 0?{}:{kind:I},...n!==null&&n.addonId===u&&n.originStableId!==void 0?{originStableId:n.originStableId}:{}});m(t.id),T(t.id),h===`auto`||h===`both`?l(`discovery`):Ce(t.id,{openAdd:!0})}catch{}}async function xe(e){if(u)try{let t=await B.mutateAsync({addonId:u,name:S,values:{brokerId:e},...ue===void 0?{}:{kind:ue}});T(t.id),m(t.id),Ce(t.id)}catch{}}async function Se(e){if(u){for(let t of e){let e=ge?.find(e=>e.stableId===t);e&&await _e.mutateAsync({addonId:u,candidate:e,...w===null?{}:{integrationId:w}})}Ce()}}function Ce(e,n){let r=e??p??u;if(t(),we(),r&&u){let e=jd(u,r);a(n?.openAdd===!0?`${e}&add=1`:e)}}function we(){l(`picker`),d(null),m(null),g(`manual`),b(null),C(``),T(null),D(null),B.reset(),A(!1),N({}),F(``)}function Te(){t(),we()}Nd(e);let Ee=B.isPending,De=Pd(Ee,Hf);if(!e)return null;let Oe={picker:r?.title??i(`integrations.newIntegration`),config:i(`integrations.configureIntegration`),discovery:i(`integrations.importDevices`),broker:i(`integrations.connectBroker`,{defaultValue:`Connect a broker`})},ke=Ee?u:null,Ae=B.error,je=Ee&&!De;return s(j,{children:[v(Nn,{open:!0,onOpenChange:e=>{!e&&!je&&Te()},children:s(Na,{width:c===`picker`?`xl`:`lg`,scroll:`body`,onCancel:e=>{je&&e.preventDefault()},children:[v($i,{children:v(Ti,{children:Oe[c]})}),s(Li,{children:[Ae&&!Ee&&v(`div`,{className:`mb-3 rounded-lg border border-danger/40 bg-danger/10 px-3 py-2 text-xs text-danger`,children:Ae instanceof Error?Ae.message:String(Ae)}),c===`picker`&&s(j,{children:[E&&v(`div`,{className:`mb-3 rounded-lg border border-danger/40 bg-danger/10 px-3 py-2 text-xs text-danger`,children:E}),v(mf,{onSelect:ve,onClose:Te,pendingAddonId:ke,...r===void 0?{}:{source:r}})]}),c===`config`&&u&&v(Ld,{addonId:u,configSchema:me??null,canTest:k,...I===void 0?{}:{instanceKind:I},initialName:S.length>0?S:void 0,initialConfig:{...M},onScan:de?()=>{ae(S.length>0?S:u),te(!0)}:void 0,onSave:be,onBack:()=>{N({}),l(`picker`)}},`${pe.length>0?pe:u}:${S}:${ne}`),c===`broker`&&_&&v(Fd,{kind:_,onResolved:e=>{xe(e)},onBack:()=>l(`picker`)}),c===`discovery`&&p&&v(Id,{providerId:p,onImport:Se,onSkip:Ce})]}),Ee&&s(`div`,{className:`absolute inset-0 z-20 flex flex-col items-center justify-center gap-2 rounded-lg bg-background/85 backdrop-blur-sm px-6 text-center`,children:[v(H,{className:`h-6 w-6 animate-spin text-primary`}),v(`p`,{className:`text-xs font-medium text-foreground`,children:i(`integrations.creating`,{defaultValue:`Creating integration…`})}),!De&&v(`p`,{className:`text-[10px] text-foreground-subtle`,children:i(`integrations.creatingHint`,{defaultValue:`Waiting for the addon to restart and register`})}),De&&s(j,{children:[v(`p`,{className:`text-[10px] text-foreground-subtle max-w-xs`,children:i(`integrations.creatingOverdue`,{defaultValue:`This is taking longer than expected. The integration may already have been created — close this dialog and refresh to check.`})}),v(W,{variant:`unstyled`,onClick:Te,className:`mt-1 rounded-md border border-border bg-surface px-3 py-1.5 text-[11px] font-medium text-foreground hover:bg-surface-hover transition-colors`,children:i(`integrations.closeAndRefresh`,{defaultValue:`Close`})})]})]})]})}),ee&&u!==null&&v(kf,{open:ee,scope:{addonId:u,label:ie},pickMode:`fill`,onClose:()=>te(!1),onSetupIntegration:e=>{C(e.name),N({...e.config}),re(e=>e+1)}})]})}T();function Gf({functionCap:e,disabled:t,onCreated:n}){let{t:r}=Z(),{options:i}=wd({functionCap:e,match:`link`}),[a,o]=x({at:`closed`});if(i.length===0)return null;let c=()=>o({at:`closed`});return s(j,{children:[s(W,{variant:`outline`,size:`sm`,disabled:t,onClick:()=>{let e=i.length===1?i[0]:void 0;o(e===void 0?{at:`choose`}:{at:`edit`,option:e})},children:[v(Tt,{className:`h-3.5 w-3.5`}),` `,r(`brokers.picker.createNew`)]}),a.at===`choose`&&v(Wf,{open:!0,onClose:c,pickFrom:{title:r(`brokers.picker.createNew`),providers:i.map(e=>({addonId:e.addonId,kind:e.kind,name:e.label,description:``,...e.iconUrl===void 0?{}:{iconUrl:e.iconUrl}})),onPick:(e,t)=>{let n=i.find(n=>n.addonId===e&&n.kind===t);o(n===void 0?{at:`closed`}:{at:`edit`,option:n})}}}),a.at===`edit`&&v(Ed,{functionCap:e,addonId:a.option.addonId,kind:a.option.kind,match:`link`,onClose:c,onSaved:e=>{c(),n(e)}})]})}var Kf=`broker`;function qf({functionCap:e,kind:t,noneLabel:n,required:r,disabled:i,value:a,onChange:o}){return e===Kf&&t!==void 0?v(Od,{kind:t,value:a,onChange:o,optional:r===!1,disabled:i===!0,...n===void 0?{}:{noneLabel:n}}):s(`div`,{className:`space-y-2`,children:[v(xr,{functionCap:e,...t===void 0?{}:{kind:t},...n===void 0?{}:{noneLabel:n},value:a??``,disabled:i===!0,onChange:e=>o(e===``?null:e),controlId:`instance-picker-${e}-${t??`any`}`}),t===void 0&&v(`div`,{children:v(Gf,{functionCap:e,disabled:i===!0,onCreated:o})})]})}function Jf({deviceId:e}){let{t}=Z(),n=Fn(G().trpcClient,e);return n===null?null:v(or,{headingId:`device-web-interface-${String(e)}`,title:t(`device.webInterface.title`,`Web interface`),icon:Sn,testId:`device-web-interface-card`,children:s(`div`,{className:`flex flex-wrap items-center justify-between gap-2 px-3 py-2 sm:px-4`,children:[s(`div`,{className:`min-w-0 text-xs`,children:[v(`div`,{className:`font-medium text-foreground`,children:n.label}),v(`div`,{className:`break-all text-foreground-muted`,children:n.host})]}),s(W,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>window.open(n.url,`_blank`,`noopener,noreferrer`),children:[v(P,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),t(`device.webInterface.open`,`Open`)]})]})})}function Yf(e,t){return e.icon===t.icon&&e.label===t.label&&e.unit===t.unit&&e.precision===t.precision&&e.hidden===t.hidden}function Xf(e){return{icon:e?.icon??``,label:e?.label??``,unit:e?.unit??``,precision:e?.precision===void 0?``:String(e.precision),hidden:e?.hidden===!0}}function Zf(e){if(e.trim()===``)return;let t=Number.parseInt(e,10);return Number.isFinite(t)?t:void 0}function Qf(e,t){let n=Zf(e.precision),r={...e.icon===``?{}:{icon:e.icon},...e.label.trim()===``?{}:{label:e.label.trim()},...e.unit===``?{}:{unit:e.unit},...n===void 0?{}:{precision:n},...e.hidden?{hidden:!0}:{},...t?.perCap===void 0?{}:{perCap:t.perCap}};return Object.keys(r).length===0?null:r}function $f(e){let t=Xf(e.display),n=e.tags??[];return{name:e.name,location:e.location,role:e.role,display:t,tags:n,baseName:e.name,baseLocation:e.location,baseRole:e.role,baseDisplay:t,baseTags:n,persistedDisplay:e.display}}function ep(e,t){if(e===null)return $f(t);let n=Xf(t.display),r=e.name===t.name&&e.location===t.location&&e.role===t.role&&np(e.tags,t.tags??[])&&Yf(e.display,n);return!tp(e)||r?$f(t):e}function tp(e){return e===null?!1:e.name!==e.baseName||e.location!==e.baseLocation||e.role!==e.baseRole||!np(e.tags,e.baseTags)||!Yf(e.display,e.baseDisplay)}function np(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}function rp(e){return e.name.trim().length===0?`name`:null}function ip(e){let t=e.name.trim(),n=e.location.trim();return{...t===e.baseName?{}:{name:t},...n===e.baseLocation?{}:{location:n===``?null:n},...e.role===e.baseRole?{}:{role:e.role},...np(e.tags,e.baseTags)?{}:{tags:[...e.tags]},...Yf(e.display,e.baseDisplay)?{}:{display:Qf(e.display,e.persistedDisplay)}}}function ap(e){let t=e.map(e=>e.error).filter(e=>e!==null&&e.length>0);return{dirty:e.some(e=>e.dirty),saving:e.some(e=>e.saving),error:t.length===0?null:t.join(`; `)}}T();var op=D(null);function sp(){return M(op)}function cp({deviceId:e,seed:t,onClose:n,children:r}){let[i,a]=x(null),[o,s]=x([]),{t:c}=Z(),l=_o(),u=tt(),p=d(new Map);if(t!==null){let e=ep(i,t);(i===null||e.name!==i.name||e.location!==i.location||e.role!==i.role||!np(e.tags,i.tags)||!np(e.baseTags,i.baseTags)||!Yf(e.display,i.display)||e.baseName!==i.baseName||e.baseLocation!==i.baseLocation||e.baseRole!==i.baseRole||!Yf(e.baseDisplay,i.baseDisplay)||e.persistedDisplay!==i.persistedDisplay)&&a(e)}let m=_(e=>(p.current.set(e.id,{save:e.save,discard:e.discard}),s(t=>{let n=t.find(t=>t.id===e.id);return n!==void 0&&n.dirty===e.dirty&&n.saving===e.saving&&n.error===e.error?t:[...t.filter(t=>t.id!==e.id),{...e,save:()=>p.current.get(e.id)?.save()??Promise.resolve(),discard:()=>{p.current.get(e.id)?.discard()}}]}),()=>{p.current.delete(e.id),s(t=>t.filter(t=>t.id!==e.id))}),[]),h=ap([{dirty:tp(i),saving:!1,error:null},...o]).dirty,g=_(e=>{(async()=>{h&&!await u({title:c(`deviceQuickDetail.leaveTitle`,`Discard unsaved changes?`),message:c(`deviceQuickDetail.leaveMessage`,`Unsaved edits on this device will be discarded.`),confirmLabel:c(`deviceQuickDetail.discard`,`Discard`),variant:`warning`})||(l(e),n?.())})()},[h,u,c,l,n]),y=_(()=>g(`/devices/${String(e)}`),[g,e]),b=f(()=>({identity:i,setIdentityName:e=>{a(t=>t===null?t:{...t,name:e})},setIdentityLocation:e=>{a(t=>t===null?t:{...t,location:e})},setIdentityRole:e=>{a(t=>t===null?t:{...t,role:e})},setIdentityTags:e=>{a(t=>t===null?t:{...t,tags:e})},setIdentityDisplay:e=>{a(t=>t===null?t:{...t,display:{...t.display,...e}})},register:m,openDevicePage:y,leaveTo:g}),[i,m,y,g]);return v(op.Provider,{value:b,children:v(lp,{deviceId:e,identity:i,contributions:o,onIdentitySaved:e=>a(e),children:r})})}function lp({deviceId:e,identity:t,contributions:n,onIdentitySaved:r,children:i}){return s(j,{children:[i,v(dp,{deviceId:e,identity:t,contributions:n,onIdentitySaved:r})]})}function up(e){return e instanceof Error?e.message:String(e)}function dp({deviceId:e,identity:t,contributions:n,onIdentitySaved:r}){let{t:i}=Z(),a=O(),[o,c]=x(null),[l,u]=x(!1),d=Ea(),f=Mn(),p=Di(),m=Br(),h=Ni(),g=ap([{dirty:tp(t),saving:l,error:o},...n]),_=()=>{a.invalidateQueries({queryKey:[[`deviceManager`]]})};return!g.dirty&&!g.saving&&g.error===null?null:s(`div`,{className:`sticky bottom-0 z-10 mt-auto flex flex-col gap-2 border-t border-border bg-background px-1 pt-3`,children:[g.error!==null&&v(`p`,{className:`text-xs text-danger`,children:g.error}),v(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:s(`div`,{className:`flex items-center gap-2`,children:[v(W,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>{t!==null&&r({...t,name:t.baseName,location:t.baseLocation,role:t.baseRole,display:t.baseDisplay,tags:t.baseTags});for(let e of n)e.discard();c(null)},disabled:!g.dirty||g.saving,children:i(`deviceQuickDetail.discard`,`Discard`)}),v(W,{type:`button`,size:`sm`,onClick:()=>{if(t!==null&&tp(t)&&rp(t)===`name`){c(i(`deviceQuickDetail.nameRequired`,`Name is required`));return}c(null),u(!0),(async()=>{try{let i=t===null?{}:ip(t);if(t!==null&&i.name!==void 0&&await d.mutateAsync({deviceId:e,name:i.name}),t!==null&&i.location!==void 0&&await f.mutateAsync({deviceId:e,location:i.location}),t!==null&&i.role!==void 0&&await p.mutateAsync({deviceId:e,role:i.role}),t!==null&&i.tags!==void 0&&await h.mutateAsync({deviceId:e,tags:i.tags}),t!==null&&i.display!==void 0&&await m.mutateAsync({deviceId:e,display:i.display}),t!==null){let e=t.name.trim(),n=t.location.trim();r({...t,name:e,location:n,baseName:e,baseLocation:n,baseRole:t.role,baseDisplay:t.display,baseTags:t.tags,persistedDisplay:i.display===void 0?t.persistedDisplay:i.display??void 0})}for(let e of n)e.dirty&&await e.save();_()}catch(e){c(up(e))}finally{u(!1)}})()},disabled:!g.dirty||g.saving,children:g.saving?i(`deviceQuickDetail.saving`,`Saving…`):i(`deviceQuickDetail.save`,`Save`)})]})})]})}function fp({label:e,value:t,layout:n=`inline`}){return n===`stacked`?s(`div`,{className:`min-w-0 flex flex-col gap-0.5 px-0.5`,children:[v(`span`,{className:`text-[11px] text-foreground-subtle`,children:e}),v(`div`,{className:`min-w-0 text-[11px] text-foreground`,children:t})]}):s(`div`,{className:`${Ee} flex items-start gap-2 sm:gap-3`,children:[v(`span`,{className:`w-20 sm:w-28 flex-shrink-0 text-[11px] text-foreground-subtle`,children:e}),v(`div`,{className:`flex-1 min-w-0 text-[11px] text-foreground`,children:t})]})}function pp({initialName:e,label:t=`Name`,layout:n=`inline`,bound:r}){return v(fp,{label:t,layout:n,value:v(U,{type:`text`,value:r.value,"aria-label":t,placeholder:e,onChange:e=>r.onChange(e.target.value),className:`flex-1 min-w-0 w-full px-1.5 py-0.5 text-[11px] bg-background border border-border rounded focus:outline-none focus:border-primary`})})}T();function mp({label:e=`Location`,layout:t=`inline`,bound:n}){let{t:r}=Z(),{data:i}=ao(),a=i??[],o=n.value.trim().toLowerCase(),c=f(()=>o.length===0?[]:a.filter(e=>e.toLowerCase()!==o&&e.toLowerCase().includes(o)),[a,o]);return v(fp,{label:e,layout:t,value:s(`div`,{className:`relative`,children:[v(U,{type:`text`,value:n.value,"aria-label":e,onChange:e=>n.onChange(e.target.value),placeholder:r(`shared.locationRow.roomAreaOrLeaveEmpty`,`Room / area (or leave empty to clear)`),className:`flex-1 min-w-0 w-full px-1.5 py-0.5 text-[11px] bg-background border border-border rounded focus:outline-none focus:border-primary`}),c.length>0&&v(`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:c.map(e=>s(`button`,{type:`button`,onClick:()=>n.onChange(e),className:`w-full flex items-center gap-2 px-2 py-1 text-left text-[11px] hover:bg-surface-hover`,children:[v(Xe,{className:`h-3 w-3 text-foreground-subtle flex-shrink-0`}),v(`span`,{className:`truncate`,children:e})]},e))})]})})}var hp=`w-full min-w-0 px-1.5 py-0.5 text-[11px] bg-background border border-border rounded focus:outline-none focus:border-primary disabled:opacity-50 disabled:cursor-not-allowed`,gp=0,_p=10;function vp(e){if(e.trim()===``)return``;let t=Number.parseInt(e,10);return Number.isFinite(t)?String(t<gp?gp:t>_p?_p:t):``}function yp({value:e,onChange:t,disabled:n=!1,placeholder:r,className:i,id:a,"aria-label":o}){return v(U,{type:`number`,min:gp,max:_p,step:1,id:a,className:i??hp,"aria-label":o,placeholder:r,value:e,onChange:e=>{t(vp(e.target.value))},disabled:n})}function bp({deviceName:e,value:t,inheritedIcon:n,inheritedLabel:r,disabled:i,onChange:a}){let{t:o}=Z(),c={trigger:o(`deviceDisplay.pickIcon`,{name:e}),panel:o(`deviceDisplay.iconFor`,{name:e}),searchPlaceholder:o(`deviceDisplay.iconSearchPlaceholder`),clear:r,noMatches:o(`deviceDisplay.iconNoMatches`)};return s(`div`,{className:`flex items-center gap-2`,children:[v(Xi,{value:t===``?null:t,onPick:e=>a(e??``),categoryLabel:e=>o(`deviceDisplay.iconCategory.${e}`,{defaultValue:Vt(e)}),fallbackGlyph:n,labels:c,disabled:i}),v(`span`,{className:`text-[11px] text-foreground-subtle`,children:t===``?r:t})]})}var xp=`w-full min-w-0 px-1.5 py-0.5 text-[11px] bg-background border border-border rounded focus:outline-none focus:border-primary disabled:opacity-50`;function Sp(e){if(e.trim()===``)return;let t=Number.parseInt(e,10);return Number.isFinite(t)?t:void 0}function Cp({device:e,role:t,display:n,onChange:r}){let i=ye();qa();let{t:a}=Z(),o=O(),c=t===null?void 0:Ca[t],l=c?.kind===`numeric`,u=t!==null||e.parentDeviceId!==null&&e.parentDeviceId!==void 0,d=e.sourceInfo?.quantity,f=c?.kind===`numeric`?c.quantity??(d!==void 0&&d!==`device`?d:void 0):void 0,p=f===void 0?void 0:Mt(f),m=p===void 0?void 0:Xt(p),{data:h}=In({},{staleTime:6e4,enabled:t!==null}),g=ya({onSuccess:()=>{o.invalidateQueries({queryKey:[[`deviceManager`]]})}}),_=()=>{if(t===null)return;let e=Sp(n.precision),r={...n.icon===``?{}:{icon:n.icon},...n.unit===``?{}:{unit:n.unit},...e===void 0?{}:{precision:e}};g.mutate({defaults:{...h?.defaults,[t]:r}})},y=t===null?void 0:h?.defaults?.[t]?.icon,b=y===void 0?void 0:Xr(y),x=t===null?Ir(e.type,i):qn(t,i),S={icon:b??Xn(e.type,t),label:b===void 0?x.label:String(y)},C=t===null&&e.type===q.Container?a(`deviceDisplay.inheritedContainer`):b===void 0?a(`deviceDisplay.inherited`,{name:S.label}):a(`deviceDisplay.inheritedRoleDefault`,{icon:S.label,role:x.label}),w=t===null?``:qn(t,i).label;return s(`div`,{className:`mt-3 divide-y divide-border border-t border-border`,children:[v(fp,{label:a(`deviceDisplay.icon`),value:v(bp,{deviceName:e.name,value:n.icon,inheritedIcon:S.icon,inheritedLabel:C,disabled:!1,onChange:e=>r({icon:e})})}),u&&v(fp,{label:a(`deviceDisplay.label`),value:v(U,{type:`text`,className:xp,"aria-label":a(`deviceDisplay.label`),placeholder:t===null?e.name:w,value:n.label,onChange:e=>r({label:e.target.value})})}),l&&s(j,{children:[v(fp,{label:a(`deviceDisplay.unit`),value:v(Gn,{dimension:m,value:n.unit,onChange:e=>r({unit:e}),disabled:!1,"aria-label":a(`deviceDisplay.unit`),inheritLabel:a(`deviceDisplay.unitSource`,{unit:p===void 0?``:` (${p})`}),emptyReason:a(`deviceDisplay.unitSource`,{unit:``})})}),v(fp,{label:a(`deviceDisplay.precision`),value:v(yp,{"aria-label":a(`deviceDisplay.precision`),placeholder:a(`deviceDisplay.precisionInherit`),value:n.precision,onChange:e=>r({precision:e}),disabled:!1})})]}),t!==null&&v(`div`,{className:`px-3 sm:px-4 py-2`,children:v(W,{type:`button`,variant:`outline`,size:`sm`,onClick:_,disabled:g.isPending,title:a(`deviceDisplay.setRoleDefaultTitle`,{role:w}),children:a(`deviceDisplay.setRoleDefault`,{role:w})})})]})}var wp=new Set(Object.values(K));function Tp(e){return wp.has(e)}var Ep={[q.Switch]:[K.Siren,K.Floodlight,K.Spotlight,K.PirSensor,K.Chime,K.Autotrack,K.Nightvision,K.PrivacyMask,K.BinaryHelper,K.SwitchHeater,K.SwitchFan,K.SwitchLight],[q.Climate]:[K.ClimateThermostat,K.ClimateAc,K.ClimateFloor,K.ClimateRadiator,K.ClimateHeater,K.ClimateHeatPumpCircuit,K.ClimateVehicle],[q.Lock]:[K.LockVehicle],[q.MediaPlayer]:[K.MediaPlayerTv],[q.Light]:[K.Floodlight,K.Spotlight,K.Nightvision],[q.Siren]:[K.Siren],[q.Button]:[K.Doorbell],[q.Cover]:[K.CoverBlind,K.CoverShutter,K.CoverAwning,K.CoverCurtain,K.CoverGarage,K.CoverGate,K.CoverDoor,K.CoverWindow],[q.Sensor]:[K.MotionSensor,K.ContactSensor,K.LeakSensor,K.SmokeSensor,K.COSensor,K.GasSensor,K.TamperSensor,K.VibrationSensor,K.ConnectivitySensor,K.SoundSensor,K.BinarySensor,K.TemperatureSensor,K.HumiditySensor,K.AmbientLightSensor,K.PressureSensor,K.WindSensor,K.RainSensor,K.UvSensor,K.SolarRadiationSensor,K.SoilMoistureSensor,K.PowerSensor,K.EnergySensor,K.VoltageSensor,K.CurrentSensor,K.AirQualitySensor,K.AmbientMonitor,K.BatterySensor,K.NumericSensor,K.EnumSensor,K.DateTimeSensor,K.GenericSensor],[q.Control]:[K.NumericControl,K.SelectControl,K.TextControl,K.DateTimeControl],[q.Notifier]:[K.MobilePushNotifier,K.MessagingNotifier,K.EmailNotifier,K.GenericNotifier],[q.Workload]:[...Ht]};function Dp(e){for(let t of Object.values(q))if(t===e)return!0;return!1}function Op(e){return Dp(e)?Ep[e]??[]:[]}function kp(e,t){let n=Op(t);return e==null||e===``||n.includes(e)?n:[...n,e]}function Ap({device:e,basic:t=!1,readOnly:n=!1}){let{t:r}=Z(),i=ye(),a=sp(),o=Ja(),c=a?.identity??null,l=c?.name??e.name,u=c?.location??e.location??``,d=c?.role??e.role??null,f=c?.tags??e.tags??[],p=c?.display.hidden??e.display?.hidden===!0,m=a!==null&&c!==null&&!n;return s(`section`,{"aria-label":r(`customize.identity.title`),className:`${ge} ${ne}`,children:[s(`div`,{className:t?`grid grid-cols-1 gap-3 sm:grid-cols-3`:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-4`,children:[m?v(pp,{deviceId:e.id,initialName:l,label:r(`customize.identity.name`),layout:`stacked`,bound:{value:l,onChange:a.setIdentityName}}):v(fp,{label:r(`customize.identity.name`),layout:`stacked`,value:l}),m?v(mp,{deviceId:e.id,initialLocation:u,label:r(`customize.identity.room`),layout:`stacked`,bound:{value:u,onChange:a.setIdentityLocation}}):v(fp,{label:r(`customize.identity.room`),layout:`stacked`,value:u===``?r(`common.unset`):u}),t?null:s(j,{children:[v(fp,{label:r(`common.tags`,`Tags`),layout:`stacked`,value:m?v(Ki,{value:f,onChange:a.setIdentityTags,label:r(`common.tags`,`Tags`)}):f.length>0?v(oa,{tags:f,entries:o.entries}):r(`common.unset`)}),v(fp,{label:r(`customize.identity.type`),layout:`stacked`,value:e.type}),v(fp,{label:r(`customize.identity.hidden`),layout:`stacked`,value:v(Dt,{"aria-label":r(`deviceDisplay.hideFromLists`),checked:p,disabled:!m,onChange:e=>a?.setIdentityDisplay({hidden:e.target.checked})})})]}),v(fp,{label:r(`customize.identity.role`),layout:`stacked`,value:m?v(Ke,{"aria-label":r(`customize.identity.role`),value:d??``,options:[{value:``,label:r(`customize.identity.noRole`)},...kp(d,e.type).map(e=>({value:e,label:jp(e,r(`customize.identity.noRole`),i)}))],onChange:e=>a.setIdentityRole(e.target.value===``?null:e.target.value)}):v(`span`,{children:jp(d,r(`customize.identity.noRole`),i)})})]}),!t&&!n&&c!==null&&a!==null&&v(Cp,{device:e,role:d,display:c.display,onChange:a.setIdentityDisplay})]})}function jp(e,t,n){return e==null||e===``?t:Tp(e)?qn(e,n).label:e}var Mp={streaming:{icon:nt,labelKey:`capabilityBadges.streaming`},detection:{icon:we,labelKey:`capabilityBadges.detection`},recording:{icon:Qe,labelKey:`capabilityBadges.recording`},audio:{icon:R,labelKey:`capabilityBadges.audio`},snapshot:{icon:xe,labelKey:`capabilityBadges.snapshot`},motion:{icon:Ne,labelKey:`capabilityBadges.motion`},ptz:{icon:dt,labelKey:`capabilityBadges.ptz`},webrtc:{icon:$e,labelKey:`capabilityBadges.webrtc`},onvif:{icon:ze,labelKey:`capabilityBadges.onvif`},analytics:{icon:Ce,labelKey:`capabilityBadges.analytics`},"battery-operated":{icon:yt,labelKey:`capabilityBadges.battery`},"native-snapshot":{icon:xe,labelKey:`capabilityBadges.nativeSnapshot`},"pan-tilt-zoom":{icon:dt,labelKey:`capabilityBadges.ptz`},"two-way-audio":{icon:R,labelKey:`capabilityBadges.twoWayAudio`},"doorbell-button":{icon:L,labelKey:`capabilityBadges.doorbell`},rebootable:{icon:et,labelKey:`capabilityBadges.rebootable`},"vacuum-has-ai":{icon:At,labelKey:`capabilityBadges.aiObstacle`},"mower-has-targeted-mowing":{icon:ie,labelKey:`capabilityBadges.targetedMowing`}},Np=le;function Pp({capabilities:e,showLabels:t=!1}){let{t:n}=Z();return v(`div`,{className:`flex items-center gap-1 flex-wrap`,children:e.map(e=>{let r=Mp[e],i=r?.icon??Np,a=r?n(r.labelKey):e;return s(`span`,{className:`inline-flex items-center gap-1 rounded-md bg-surface-hover px-1.5 py-0.5 text-[10px] text-foreground-subtle`,title:a,children:[v(i,{className:`h-3 w-3`}),t&&v(`span`,{children:a})]},e)})})}var Fp=`customize`,Ip=`/build/compositions/new`,Lp=`/build/compositions/:blockId`,Rp=`/build?tab=custom-device`;function zp(e){return`/devices/${e}`}function Bp(e){return`/devices/${e}?tab=${Fp}`}function Vp(e){return`/build/compositions/${encodeURIComponent(e)}`}var Hp=`template`,Up=`terminalId`;function Wp(e){return`/build?${new URLSearchParams({tab:`custom-device`,new:`helper`,[Hp]:`terminal`,[Up]:e}).toString()}`}T();function Gp(e,t){return e.kind===`same-device`?`same-device`:e.a.deviceId===t?`powers`:`powered-by`}function Kp(e){if(!e.ok)throw Error(e.message);return e.link}function qp(e){return e.filter(e=>e.state!==`dismissed`)}function Jp(e){return e.filter(e=>e.state===`dismissed`)}function Yp({deviceId:e}){let{t}=Z(),n=pr({deviceId:e}),r=v(`div`,{className:`px-3 sm:px-4 py-1.5 text-[10px] text-foreground-subtle border-y border-border`,children:t(`overviewAdapters.identityLinks.header`,`Linked devices, matched on the identifiers above.`)});if(n.error)return s(j,{children:[r,v(`p`,{className:`px-3 sm:px-4 py-2 text-xs text-foreground-muted`,children:t(`overviewAdapters.identityLinks.unavailable`,`Linked devices could not be read.`)})]});if(n.data===void 0)return s(j,{children:[r,v(`div`,{className:`px-3 sm:px-4 py-2`,"data-testid":`identity-links-pending`,children:v(zi,{className:`h-4 w-1/2`})})]});if(n.data.status===`not-loaded`)return s(j,{children:[r,v(`p`,{className:`px-3 sm:px-4 py-2 text-xs text-foreground-muted`,children:t(`overviewAdapters.identityLinks.notLoaded`,`Linked devices are not read yet.`)})]});let i=qp(n.data.links),a=Jp(n.data.links);return s(j,{children:[r,i.length===0?v(`p`,{className:`px-3 sm:px-4 py-2 text-xs text-foreground-muted`,children:t(`overviewAdapters.identityLinks.none`,`No linked devices.`)}):v(`div`,{className:`divide-y divide-border`,children:i.map(t=>v(Xp,{link:t,deviceId:e},t.id))}),a.length>0&&v(`div`,{className:`divide-y divide-border`,"data-testid":`identity-links-dismissed`,children:a.map(t=>v(Xp,{link:t,deviceId:e},t.id))})]})}function Xp({link:e,deviceId:t}){let{t:n}=Z(),r=e.a.deviceId===t?e.b:e.a,{data:i}=Kn({deviceId:r.deviceId}),a=O(),o={onSuccess:()=>void a.invalidateQueries({queryKey:[[`deviceManager`]]})},c=da(o),l=Yr(o),u=Fi(o),d=ir(o),f={"same-device":n(`overviewAdapters.identityLinks.sameDevice`,`Same device`),"powered-by":n(`overviewAdapters.identityLinks.poweredBy`,`Powered by`),powers:n(`overviewAdapters.identityLinks.powers`,`Powers`)},[p,m]=x(null),h=e=>{m(null),e.then(Kp).catch(e=>{m(e instanceof Error?e.message:String(e))})},g=i?.name??`#${r.deviceId}`,_=e.state===`proposed`,y=e.state===`dismissed`;return v(fp,{label:f[Gp(e,t)],value:s(`div`,{className:`flex flex-wrap items-center gap-2 min-w-0`,children:[v(vo,{to:zp(r.deviceId),className:`text-primary hover:underline truncate`,children:g}),_&&v(`span`,{className:`text-[11px] text-warning`,children:n(`overviewAdapters.identityLinks.proposed`,`Suggested`)}),e.evidenceGone===!0&&v(`span`,{className:`text-[11px] text-foreground-subtle`,children:n(`overviewAdapters.identityLinks.evidenceGone`,`No longer matched`)}),y&&v(`span`,{className:`text-[11px] text-foreground-subtle`,children:n(`overviewAdapters.identityLinks.dismissedState`,`Unlinked`)}),v(`span`,{className:`ml-auto flex gap-1.5`,children:y?v(W,{size:`sm`,variant:`outline`,disabled:d.isPending,onClick:()=>h(d.mutateAsync({linkId:e.id})),children:n(`overviewAdapters.identityLinks.relink`,`Relink`)}):_?s(j,{children:[v(W,{size:`sm`,disabled:c.isPending,onClick:()=>h(c.mutateAsync({linkId:e.id})),children:n(`overviewAdapters.identityLinks.confirm`,`Confirm`)}),v(W,{size:`sm`,variant:`outline`,disabled:l.isPending,onClick:()=>h(l.mutateAsync({linkId:e.id})),children:n(`overviewAdapters.identityLinks.dismiss`,`Dismiss`)})]}):v(yr,{size:`sm`,label:n(`overviewAdapters.identityLinks.unlink`,`Unlink`),title:n(`overviewAdapters.identityLinks.unlinkTitle`,`Unlink these devices?`),description:n(`overviewAdapters.identityLinks.unlinkBody`,`The link is removed and not suggested again. Anything it added in Customize is removed with it.`),action:async()=>Kp(await u.mutateAsync({linkId:e.id}))})}),p!==null&&v(`span`,{className:`basis-full text-[11px] text-danger`,children:p})]})})}T();function Zp({deviceId:e}){let{t}=Z(),n=O(),{data:r}=_s(e),{data:i}=gs(e),[a,o]=x(null),c=ea({onSuccess:()=>{o(null),n.invalidateQueries({queryKey:[[`deviceManager`]]})},onError:e=>{o(`Could not change primary child: ${e.message}`)}});if(r==null)return null;let l=String(r.type??``);if(l!==q.Container)return null;let u=String(r.name??``),d=(i??[]).map(e=>({id:e.id,stableId:e.stableId,type:e.type,name:Nr(e,u),...e.sourceInfo?{sourceInfo:{id:e.sourceInfo.id}}:{}}));if(d.length<=1)return null;let f=Un(d,typeof r.linkDeviceId==`number`?r.linkDeviceId:null,typeof r.primaryChildEntityId==`string`?r.primaryChildEntityId:null,l,Wt(r)),p=f===null?d[0].id:f.id;return s(j,{children:[v(fp,{label:t(`shared.primaryChildRow.primaryChild`,`Primary child`),value:v(Jr,{childrenList:d,selectedId:p,onSetPrimary:t=>c.mutate({deviceId:e,primaryChildEntityId:t}),disabled:c.isPending})}),a!==null&&v(`p`,{role:`alert`,className:`px-3 sm:px-4 py-1.5 text-[11px] text-danger`,children:a})]})}T();var Qp=[`manufacturer`,`model`,`hardware`,`firmware`,`serialNumber`,`uid`,`mac`,`itemNo`],$p=[`mac`,`serial`,`vendor-uid`,`machine-uuid`,`hostname`,`ip`];function em(e){let t=Jt.safeParse(e);if(!t.success)return[];let n=t.data;return $p.flatMap(e=>{if(e===`mac`)return(n.mac??[]).map(t=>({key:e,value:t.value,derived:t.origin===`derived`}));let t=n[e];return t?[{key:e,value:t.value,derived:t.origin===`derived`}]:[]})}function tm(e){return e.replace(/([a-z])([A-Z])/g,`$1 $2`).replace(/^./,e=>e.toUpperCase())}function nm(e){return e==null?`—`:typeof e==`string`||typeof e==`number`||typeof e==`boolean`?String(e):JSON.stringify(e)}function rm(){let{t:e}=Z(),t=cr(),n=ei(),{data:r}=Kn({deviceId:t??0},{enabled:t!==null}),{data:i}=Ga({deviceId:t??0},{enabled:t!==null}),{data:a}=pr({deviceId:t??0},{enabled:t!==null}),o=r??n??null,[c,l]=x(`identity`);if(t===null||!o)return null;let u=String(o.stableId??``),d=String(o.addonId??``),f=typeof o.integrationId==`string`&&o.integrationId.length>0?o.integrationId:null,p=typeof o.parentDeviceId==`number`?o.parentDeviceId:null,m=o.features??[],h=new Set([`device-status`,`feature-probe`,`device-ops`]),g=(i?.entries??[]).filter(e=>e.kind===`native`&&!h.has(e.capName)).map(e=>e.capName),_=m.length>0?m:g,y=o.metadata??null,b=em(o.identifiers),S=a?.status===`answered`&&qp(a.links).length>0,C=y!==null&&Object.keys(y).length>0||b.length>0||S;return s(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[s(`div`,{className:`border-b border-border px-3 sm:px-4 py-2 flex items-center justify-between gap-3`,children:[v(`h2`,{className:`text-[11px] font-semibold text-foreground uppercase tracking-wider`,children:e(`overviewAdapters.deviceInfoAdapter.deviceInfo`,`Device Info`)}),C&&s(`div`,{className:`flex items-center gap-1 rounded-md bg-surface-hover p-0.5`,children:[v(im,{active:c===`identity`,onClick:()=>l(`identity`),label:e(`overviewAdapters.deviceInfoAdapter.identity`,`Identity`)}),v(im,{active:c===`hardware`,onClick:()=>l(`hardware`),label:e(`overviewAdapters.deviceInfoAdapter.hardware`,`Hardware`)})]})]}),(!C||c===`identity`)&&s(`div`,{className:`divide-y divide-border`,children:[v(fp,{label:`ID`,value:s(`span`,{className:`font-mono text-[11px] text-foreground`,children:[`#${t}`,s(`span`,{className:`ml-1.5 text-foreground-subtle`,children:[`(`,u,`)`]})]})}),v(Zp,{deviceId:t}),f!==null&&v(fp,{label:e(`overviewAdapters.deviceInfoAdapter.integration`,`Integration`),value:v(`span`,{className:`font-mono text-[11px]`,children:f})}),p!==null&&v(fp,{label:e(`overviewAdapters.deviceInfoAdapter.parent`,`Parent`),value:v(`span`,{className:`font-mono text-[11px]`,children:`#${String(p)}`})}),v(fp,{label:e(`overviewAdapters.deviceInfoAdapter.provider`,`Provider`),value:v(sf,{type:d,size:`sm`,showLabel:!0})}),v(fp,{label:e(`overviewAdapters.deviceInfoAdapter.capabilities`,`Capabilities`),value:_.length>0?v(Pp,{capabilities:_,showLabels:!0}):v(`span`,{className:`text-[11px] text-foreground-subtle`,children:e(`overviewAdapters.deviceInfoAdapter.none`,`None`)})})]}),C&&c===`hardware`&&v(am,{deviceId:t,metadata:y??{},identifiers:b})]})}function im({active:e,onClick:t,label:n}){return v(W,{variant:`unstyled`,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 am({deviceId:e,metadata:t,identifiers:n}){let{t:r}=Z(),i={mac:r(`overviewAdapters.deviceInfoAdapter.identifierMac`,`MAC address`),serial:r(`overviewAdapters.deviceInfoAdapter.identifierSerial`,`Serial number`),"vendor-uid":r(`overviewAdapters.deviceInfoAdapter.identifierVendorUid`,`Vendor ID`),"machine-uuid":r(`overviewAdapters.deviceInfoAdapter.identifierMachineUuid`,`Machine UUID`),hostname:r(`overviewAdapters.deviceInfoAdapter.identifierHostname`,`Hostname`),ip:r(`overviewAdapters.deviceInfoAdapter.identifierIp`,`IP address`)},a=Qp.filter(e=>e in t),o=Object.keys(t).filter(e=>!Qp.includes(e)).toSorted(),c=[...a,...o];return s(`div`,{children:[v(`div`,{className:`px-3 sm:px-4 py-1.5 text-[10px] text-foreground-subtle border-b border-border`,children:r(`overviewAdapters.deviceInfoAdapter.autoPopulatedByTheDriver`,`Auto-populated by the driver on every connect. Read-only.`)}),v(`div`,{className:`divide-y divide-border`,children:c.map(e=>v(fp,{label:tm(e),value:v(`span`,{className:`font-mono text-[11px] text-foreground break-all`,children:nm(t[e])})},e))}),n.length>0&&s(j,{children:[v(`div`,{className:`px-3 sm:px-4 py-1.5 text-[10px] text-foreground-subtle border-y border-border`,children:r(`overviewAdapters.deviceInfoAdapter.identifiersDeclared`,`Identifiers declared by the provider. Read-only.`)}),v(`div`,{className:`divide-y divide-border`,children:n.map(e=>v(fp,{label:i[e.key],value:s(`span`,{className:`font-mono text-[11px] text-foreground break-all`,children:[e.value,e.derived&&v(`span`,{className:`ml-1.5 text-foreground-subtle`,children:r(`overviewAdapters.deviceInfoAdapter.identifierDerived`,`(derived)`)})]})},`${e.key}:${e.value}`))})]}),v(Yp,{deviceId:e})]})}function om(e){return(t,n,r)=>e(t,{...typeof n==`string`?{defaultValue:n}:{defaultValue_one:n.one,defaultValue_other:n.other},...r})}var sm=(e,t,n)=>om(X.t.bind(X))(e,t,n);function cm(e,t){return e===`present`&&t.status===`ok`&&(t.data?.length??0)>0}function lm(e){return sa(G().trpcClient,e)}var um=15e3,dm={rows:[],unreadableCount:0};function fm(e){let t=G(),n=e.length>0,r=[...e].sort((e,t)=>e-t),{data:i,isLoading:a}=C({queryKey:[`stationary-objects`,r],enabled:n,staleTime:um,refetchInterval:um,queryFn:async()=>{let e=await t.trpcClient.zoneAnalytics.getCurrentSnapshotBatch.query({deviceIds:r}),n=[],i=0;for(let t of e){if(t.read===`unreadable`){i++;continue}for(let e of t.snapshot?.stationaryObjects??[])n.push({...e,deviceId:t.deviceId})}return{rows:n,unreadableCount:i}}}),o=i??dm;return{rows:o.rows.toSorted((e,t)=>t.becameStationaryAt-e.becameStationaryAt),isLoading:n&&a,unreadableCount:o.unreadableCount}}T();function pm(e){let[t,n]=x(`idle`),[r,i]=x(null),a=d(null),o=d(null),s=d(null),c=d(!0),l=ci(),u=di(),f=gi(),p=_(()=>{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},[]),m=_(async()=>{if(t===`idle`)return;n(`stopping`);let r=s.current;if(r&&e!==null)try{await Promise.race([f.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)}p(),c.current&&(n(`idle`),i(null))},[t,e,f,p]),h=_(async()=>{if(e===null||t!==`idle`&&t!==`error`)return;i(null);let r=null,d=null,p=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});p=t.sessionId,s.current=p,n(`connecting`),d=new RTCPeerConnection,a.current=d,d.oniceconnectionstatechange=()=>{if(!c.current)return;let e=d.iceConnectionState;e===`connected`||e===`completed`?n(`talking`):(e===`failed`||e===`closed`||e===`disconnected`)&&c.current&&(i(e===`failed`?`WebRTC connection failed`:null),m())};for(let e of r.getAudioTracks())d.addTrack(e,r);await d.setRemoteDescription({type:`offer`,sdp:t.sdpOffer});let f=await d.createAnswer();await d.setLocalDescription(f);let h=d.localDescription?.sdp??f.sdp??``;await u.mutateAsync({deviceId:e,sessionId:p,sdpAnswer:h})}catch(t){let l=t instanceof Error?t.message:String(t);if(console.warn(`[intercom] start failed`,t),d)try{d.close()}catch{}if(r)for(let e of r.getTracks())try{e.stop()}catch{}if(a.current=null,o.current=null,p!==null)try{await f.mutateAsync({deviceId:e,sessionId:p})}catch{}s.current=null,c.current&&(i(l),n(`error`))}},[e,t,l,u,f,m]);return y(()=>(c.current=!0,()=>{c.current=!1;let t=s.current;if(t!==null&&e!==null&&f.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:h,stop:m,isTalking:t===`talking`}}T();var mm=0;function hm(){return++mm}function gm(e){switch(e.type){case`system`:return`system`;case`device`:return`#${e.deviceId}`;case`provider`:return e.providerId;case`addon`:return e.addonId}}function _m(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 vm(e){switch(e.type){case`device`:return[``,`── State (sync, zero round-trip) ─────────────────────────`,` device.state.battery.value`,` device.state.battery.value?.level`,` 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.level < 20).length`,` sm.mapState('battery', s => s.level)`,` 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 ym(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.level < 20)`,` sm.mapState('battery', s => s.level)`,` 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?.level`,` device.state.motion.value?.detected`,` device.state.switch.value?.on`,` device.state.brightness.value?.level`,` 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({ level: 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 bm({scope:e,greeting:t,className:n}){let{t:r}=Z(),i=G(),[a,o]=x(()=>{let n=[];return t&&n.push({id:hm(),kind:`info`,text:t}),n.push({id:hm(),kind:`info`,text:`scope: ${gm(e)} — type help or context for available commands`}),n}),[c,l]=x(``),[u,f]=x([]),[p,m]=x(-1),h=d(null),g=d(null);y(()=>{let e=g.current;e&&(e.scrollTop=e.scrollHeight)},[a]);let b=_(()=>{h.current?.focus()},[]),S=k({mutationFn:t=>i.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`;o(e=>[...e,{id:hm(),kind:r?`error`:`result`,text:n}])},onError:e=>{let t=e instanceof Error?e.message:String(e);o(e=>[...e,{id:hm(),kind:`error`,text:t}])}});function C(t){let n=t.trim();if(n){if(n===`clear`){o([{id:hm(),kind:`info`,text:`scope: ${gm(e)}`}]),l(``);return}if(n===`help`){o(t=>[...t,{id:hm(),kind:`input`,text:`> ${n}`},..._m(e).map(e=>({id:hm(),kind:`info`,text:e}))]),l(``);return}if(n===`context`){o(t=>[...t,{id:hm(),kind:`input`,text:`> ${n}`},...ym(e).map(e=>({id:hm(),kind:`info`,text:e}))]),l(``);return}if(n===`examples`){o(t=>[...t,{id:hm(),kind:`input`,text:`> ${n}`},...vm(e).map(e=>({id:hm(),kind:`info`,text:e}))]),l(``);return}f(e=>[...e,n]),m(-1),o(e=>[...e,{id:hm(),kind:`input`,text:`> ${n}`}]),l(``),S.mutate(n)}}function w(t){if(t.key===`Enter`){t.preventDefault(),C(c);return}if(t.key===`ArrowUp`){if(t.preventDefault(),u.length===0)return;let e=p===-1?u.length-1:Math.max(0,p-1);m(e),l(u[e]??``);return}if(t.key===`ArrowDown`){if(t.preventDefault(),p===-1)return;let e=p+1;e>=u.length?(m(-1),l(``)):(m(e),l(u[e]??``));return}t.ctrlKey&&t.key===`l`&&(t.preventDefault(),o([{id:hm(),kind:`info`,text:`scope: ${gm(e)}`}]))}let T={input:`text-zinc-300`,result:`text-emerald-300`,error:`text-red-300`,info:`text-zinc-400`};return s(`div`,{className:`flex flex-col bg-[#0c0a09] rounded-lg border border-border overflow-hidden font-mono text-xs ${n??``}`,onClick:b,children:[s(`div`,{ref:g,className:`flex-1 overflow-y-auto p-3 space-y-1 min-h-[120px]`,children:[a.map(e=>v(`pre`,{className:`whitespace-pre-wrap break-words leading-relaxed ${T[e.kind]}`,children:e.text},e.id)),S.isPending&&v(`span`,{className:`text-zinc-500 animate-pulse`,children:r(`shared.replTerminal.thinking`,`…thinking`)})]}),s(`div`,{className:`flex items-center gap-2 border-t border-zinc-800 px-3 py-2 bg-[#0c0a09]`,children:[v(`span`,{className:`text-emerald-400 flex-shrink-0 select-none font-bold`,children:r(`shared.replTerminal.text`,`>`)}),v(U,{ref:h,value:c,onChange:e=>l(e.target.value),onKeyDown:w,disabled:S.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 xm(e,t){return e===null?null:{playbackUrl:e.url,...e.format===void 0?{}:{playbackFormat:e.format},playbackAuthToken:t,...e.label===void 0?{}:{playbackLabel:e.label}}}function Sm(e){return{frame:e.filter(e=>e.placement!==`image`),image:e.filter(e=>e.placement===`image`)}}function Cm(e){return e.length===0?null:v(j,{children:e.map(e=>v(`div`,{className:`absolute inset-0`,children:e.node},e.id))})}T();function wm({deviceId:e,intercomAvailable:t=!1,stillFirst:n=!1}){let r=G(),i=typeof window<`u`?it():``,a=Number.isFinite(e),o=ai(a?e:null),s=lm(a?e:null),c=fm(a?[e]:[]),l=f(()=>{if(!a)return;let e=[];for(let t of c.rows){let n=Mi(t);n!==null&&e.push(n)}return e},[a,c.rows]),{streams:u,pipelineMetrics:d,createSession:p,sendAnswer:m,handleOffer:h,getIceServers:g,addIceCandidate:_,getIceCandidates:y,closeSession:b,getSessionState:x,applyDownlinkProbe:S}=ti(r.trpcClient,a?e:null),C=z(a?e:null,{width:km}),w=pm(a&&t?e:null),T=w.state===`requesting-mic`||w.state===`starting`||w.state===`connecting`||w.state===`stopping`,E=w.isTalking||T,D=()=>{w.state===`idle`||w.state===`error`?w.start():w.state!==`stopping`&&w.stop()},O=gt(),k=na(),A=typeof window<`u`?window.localStorage.getItem(`dominevo_admin_token`):null,j=xm(k.request,A),{frame:M,image:N}=Sm(O),P=Cm(M),F=Cm(N);return v(fr,{serverUrl:i,createSession:p,sendAnswer:m,handleOffer:h,getIceServers:g,addIceCandidate:_,getIceCandidates:y,closeSession:b,getSessionState:x,applyDownlinkProbe:S,...j===null?{}:{...j,onExitPlayback:()=>k.clear()},streams:u,pipelineMetrics:d,phase:s.phase,detections:s,...l===void 0?{}:{stationaryObjects:l},defaultShowDetections:!n,defaultShowMotion:!n,...n?{detectionsOnSnapshot:!0,snapshotDownloadName:`snapshot-${String(e)}.jpg`}:{},...a&&o===`present`?{zonesOverlay:v(Hn,{deviceId:e})}:{},showPlayStop:!0,snapshotSrc:C.src,...C.src?{posterUrl:C.src}:{},snapshotLoading:C.loading,onRefreshSnapshot:C.refresh,intercomAvailable:t,intercomShown:E,onIntercomToggle:D,extraOverlay:P,...F===null?{}:{imageExtraOverlay:F},chromeless:!0,className:`h-full`})}function Tm({deviceId:e,containerDeviceId:t}){let{t:n}=Z();return Number.isFinite(e)?v(`div`,{className:`flex flex-col h-full`,children:v(Wa,{...t===void 0?{deviceId:e}:{containerDeviceId:t},limit:50,maxHeight:`max-h-full`,showScope:!1,showFilters:!1})}):v(`div`,{className:`flex items-center justify-center h-full text-[11px] text-foreground-subtle italic`,children:n(`device.panelContent.notLoaded`,{id:e})})}function Em({deviceId:e}){let{t}=Z();if(!Number.isFinite(e))return v(`div`,{className:`flex items-center justify-center h-full text-[11px] text-foreground-subtle italic`,children:t(`device.panelContent.notLoaded`,{id:e})});let n=[`Dominevo 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(`
3
3
  `);return v(bm,{scope:{type:`device`,deviceId:e},greeting:n,className:`h-full border-0 rounded-none`})}function Dm({deviceId:e}){let{t}=Z();return Number.isFinite(e)?v(`div`,{className:`flex flex-col h-full overflow-y-auto`,children:v(wi,{deviceId:e,limit:50,maxHeight:`max-h-full`})}):v(`div`,{className:`flex items-center justify-center h-full text-[11px] text-foreground-subtle italic`,children:t(`device.panelContent.notLoaded`,{id:e})})}function Om({deviceId:e}){let{t}=Z();return Number.isFinite(e)?v(`div`,{className:`flex flex-col h-full overflow-y-auto`,children:v(Ji,{deviceId:e,limit:50,maxHeight:`max-h-full`})}):v(`div`,{className:`flex items-center justify-center h-full text-[11px] text-foreground-subtle italic`,children:t(`device.panelContent.notLoaded`,{id:e})})}var km=960;T();function Am({deviceId:e,deviceName:t}){let{t:n}=Z(),r=Ln(`remote`),i=oo({deviceId:e},{enabled:r===`present`}),[a,o]=x(!1);return r!==`present`||(i.data?.commands.length??0)===0&&(i.data?.sources.length??0)===0?null:s(`div`,{className:`flex flex-wrap items-center justify-center gap-1`,children:[s(W,{size:`sm`,variant:`outline`,onClick:()=>o(!0),"data-testid":`hero-remote`,children:[v(Zi,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),n(`remote.hero.open`)]}),a&&v(jm,{deviceId:e,deviceName:t,onClose:()=>o(!1)})]})}function jm({deviceId:e,deviceName:t,onClose:n}){let{t:r}=Z(),i=Or({deviceId:e}),a=aa({kind:`remote`}),o=oo({deviceId:e}),c=Bn(),l=mr({deviceId:e}),[u,d]=x(null),f=i.data?.layoutTemplateId??null,p=(a.data??[]).find(e=>e.id===f),m=p===void 0?null:Vr(p.payload),h=new Set((o.data?.commands??[]).map(e=>e.role)),g=async t=>{let n=m?.buttons.find(e=>e.id===t)?.role;if(!(n===void 0||!h.has(n))){d(null);try{let t=await c.mutateAsync({deviceId:e,role:n,repeat:1});t.status===`refused`&&d(r(`remote.test.refused.${t.reason}`,{detail:t.detail??``}))}catch(e){d(e instanceof Error?e.message:String(e))}}};return v(Nn,{open:!0,onOpenChange:e=>!e&&n(),children:s(Na,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[v($i,{children:v(Ti,{children:r(`remote.hero.title`,{name:t})})}),s(Li,{className:`space-y-3`,children:[i.status===`error`?v(pi,{title:r(`remote.dialog.unreadable`),message:i.error?.message??``,onRetry:()=>void i.refetch()}):m===null?v(`p`,{className:`text-xs text-foreground-muted`,children:r(`remote.hero.noLayout`)}):v(`div`,{className:`mx-auto w-full max-w-xs`,"data-testid":`remote-press`,children:v(so,{grid:m,label:r(`remote.hero.title`,{name:t}),boundRoles:h,onSelect:e=>void g(e),renderWidget:(t,n)=>v(qr,{deviceId:e,button:t,sources:o.data?.sources??[],current:l.data?.source??``,placement:n})})}),u!==null&&v(`p`,{role:`alert`,className:`text-xs text-danger`,children:u})]})]})})}T();var Mm=D({});function Nm({value:e,children:t}){return v(Mm.Provider,{value:e,children:t})}function Pm(){return M(Mm)}T();var Fm={"off-while-running":{title:`Turn off while running?`,message:`The device is running. Cutting its power now interrupts what it is doing.`,confirm:`Turn off`},unlock:{title:`Unlock?`,message:`The lock will open.`,confirm:`Unlock`},install:{title:`Install the update?`,message:`The device may restart and be unavailable for a while.`,confirm:`Install`},press:{title:`Run it now?`,message:`The device acts as soon as you confirm.`,confirm:`Run`}},Im=e=>e===`off-while-running`?`deviceHero.model.confirmOff`:`deviceHero.model.confirm.${e}`;function Lm(){let{t:e,i18n:t}=Z(),n=t.language;return f(()=>{let t=t=>({title:e(`${Im(t)}.title`,Fm[t].title),message:e(`${Im(t)}.message`,Fm[t].message),confirm:e(`${Im(t)}.confirm`,Fm[t].confirm)});return{noValue:e(`deviceHero.model.noValue`,`–`),callFailed:e(`deviceHero.model.callFailed`,`The device did not accept the command`),historyTooltip:e(`deviceHero.utility.history.tooltip`,`Opens the history of this device.`),consumables:{label:e(`deviceHero.utility.consumables.label`,`Consumables`),low:t=>e(`deviceHero.utility.consumables.low`,`{{count}} low`,{count:t}),ok:e(`deviceHero.utility.consumables.ok`,`OK`),tooltip:e(`deviceHero.utility.consumables.tooltip`,`Shows the level of each consumable and which ones need attention.`)},power:{label:e(`deviceHero.utility.power.label`,`Power source`),on:e(`deviceHero.utility.power.on`,`On`),off:e(`deviceHero.utility.power.off`,`Off`),tooltip:e(`deviceHero.utility.power.tooltip`,`Opens a menu to cut or restore the power feeding this device, or to restart it.`),tooltipReadOnly:e(`deviceHero.utility.power.tooltipReadOnly`,`Whether the power source feeding this device is on. Your session cannot change it.`)},confirm:{"off-while-running":t(`off-while-running`),unlock:t(`unlock`),install:t(`install`),press:t(`press`)}}},[e,n])}T();function Rm(e){let[t]=x(()=>new w({defaultOptions:{queries:{retry:!1,staleTime:5e3}}}));return e??t}function zm({deviceId:e,kind:t,canActuate:n,onDrawn:r,showName:i}){let a=Xa();return y(()=>{r?.(!0)},[r]),v(`div`,{className:`flex h-full justify-center`,children:v(li,{kind:t,deviceId:e,canActuate:n,orientation:a?`vertical`:`horizontal`,showName:i!==!1})})}function Bm({deviceId:e,canActuate:t,onDrawn:n,showName:r,intercomAvailable:i}){let{onNavigate:a}=Pm();return y(()=>{n?.(!0)},[n]),v(`div`,{className:`flex h-full justify-center`,children:v(Pa,{deviceId:e,canActuate:t,showName:r!==!1,...a===void 0?{}:{onNavigate:a},scene:v(wm,{deviceId:e,intercomAvailable:i,stillFirst:!0})})})}function Vm(e){let t=vi(e.deviceId),n=Kn({deviceId:e.deviceId});return n.status===`pending`?v(zi,{className:`h-72 w-full`}):n.data?.type===q.Camera?v(Bm,{deviceId:e.deviceId,canActuate:e.canActuate,onDrawn:e.onDrawn,showName:e.showName,intercomAvailable:(n.data.features??[]).includes($t.TwoWayAudio)}):t===`pending`?v(zi,{className:`h-72 w-full`}):t===null?v(Hm,{...e}):v(zm,{deviceId:e.deviceId,kind:t,canActuate:e.canActuate,onDrawn:e.onDrawn,showName:e.showName})}function Hm(e){let t=Xa();return v(`div`,{className:`flex h-full justify-center`,children:v(fi,{deviceId:e.deviceId,canActuate:e.canActuate,orientation:t?`vertical`:`horizontal`,showName:e.showName!==!1,placeholder:v(zi,{className:`h-72 w-full`}),fallback:v(`div`,{className:`w-full`,children:v(Um,{...e})}),...e.onDrawn===void 0?{}:{onDrawn:e.onDrawn}})})}function Um({deviceId:e,canActuate:t,fallback:n,onDrawn:r,defaultHistoryOpen:i,showName:a}){let{t:o,i18n:c}=Z(),l=Lm(),[u,d]=x(i===!0),f=Aa(e),p=_r()&&cm(f.presence,f.list),m=_(()=>d(!0),[]);return s(j,{children:[v(jr,{deviceId:e,canActuate:t,lang:Ri(c.language),labels:l,renderRemote:t=>v(Am,{deviceId:e,deviceName:t}),fallback:n??null,showName:a!==!1,...p?{onOpenHistory:m}:{},...r===void 0?{}:{onDrawn:r}}),u?v(Nn,{open:!0,onOpenChange:e=>!e&&d(!1),children:s(Na,{width:`xl`,scroll:`body`,children:[v($i,{children:v(Ti,{children:o(`deviceModule.history`,`History`)})}),v(Li,{className:`mt-3`,children:v(Oa,{deviceId:e})})]})}):null]})}function Wm({deviceId:e,trpcClient:t,theme:n,locale:r,canActuate:i=!1,defaultHistoryOpen:a,queryClient:o,fallback:s,onDrawn:c,onOpenDevice:l,onOpenCamera:u,onClose:d,onNavigate:p,showName:m}){let h=Rm(o),g=f(()=>X.cloneInstance({lng:r}),[r]),_=f(()=>om(g.t.bind(g)),[g]),y=f(()=>({onOpenDevice:l,onOpenCamera:u,onClose:d,onNavigate:p}),[l,u,d,p]);return v(`div`,{className:`${n} h-full`,"data-theme":n,"data-testid":`device-detail-module`,children:v(Fc,{i18n:g,children:v(wt,{t:_,children:v(he,{client:t,children:v(gr.Provider,{client:t,queryClient:h,children:v(A,{client:h,children:v(Ye,{children:v(Nm,{value:y,children:v(Vm,{deviceId:e,canActuate:i,fallback:s,onDrawn:c,defaultHistoryOpen:a,showName:m})})})})})})})})})}function Gm({deviceId:e}){let t=G(),{data:n,isLoading:r}=_s(e),{data:i,isLoading:a}=gs(e),o=r||a,s=(i??[]).map(e=>({id:e.id,stableId:e.stableId,type:e.type,...typeof e.role==`string`?{role:e.role}:{},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,u=typeof n?.type==`string`?n.type:void 0;return o?v(`div`,{className:`h-full min-h-32 w-full animate-pulse rounded-lg bg-surface`,"aria-hidden":`true`}):v(`div`,{className:`flex h-full w-full flex-col`,children:v(lo,{trpc:t.trpcClient,children:s,linkDeviceId:c,primaryChildEntityId:l,containerType:u,primaryChildPreference:n?Wt(n):void 0})})}T();function Km({dev:e,busy:t,setBusy:n}){let{t:r}=Z(),i=e?.motionTrigger,a=Le(e?.state.motionTrigger),[o,c]=x(!1);if(!i)return null;let l=a===void 0?void 0:ga(a),u=l===`on`,d=l===`unknown`,f=a!==void 0,p=async()=>{if(t||!f)return;let e=!u;n(!0),c(!0);try{await i.setMotionTrigger({enabled:e})}finally{n(!1),c(!1)}},m=o?u?`Disabling…`:`Enabling…`:f?d?`On motion: not read yet`:u?`On motion: on`:`On motion: off`:`On motion: …`;return s(W,{variant:`unstyled`,type:`button`,onClick:()=>{p()},disabled:t||!f,title:f?d?r(`hero.motionTriggerToggle.unknownTriggerOnMotion`,`Not read from the camera yet. Click to enable`):u?r(`hero.motionTriggerToggle.disableTriggerOnMotion`,`Disable trigger on motion`):r(`hero.motionTriggerToggle.enableTriggerOnMotion`,`Enable trigger on motion`):r(`hero.motionTriggerToggle.awaitingState`,`Awaiting state…`),"aria-pressed":d?`mixed`:u,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 ${u?`border-primary/50 bg-primary/15 text-primary`:d?`border-dashed border-border bg-surface text-foreground-subtle hover:text-foreground`:`border-border bg-surface text-foreground-subtle hover:text-foreground`}`,children:[v(We,{className:`h-3 w-3`}),v(`span`,{children:m})]})}T();function Q({deviceId:e,deviceName:t,deviceType:n,deviceRole:r,features:i}){let a=G(),o=ni(n,r)?.HeroCard??sr,c=mt(a.trpcClient,e),l=Le(c?.state.deviceStatus),[u,d]=x(!1),f=l!==void 0&&l.online===!1&&l.unknown!==!0,p=f?l.lastChangedAt:null;return s(`div`,{className:`flex h-full w-full flex-col items-stretch gap-3 p-3 sm:p-4`,children:[f?v(`div`,{className:`flex justify-center`,children:v(dr,{lastChangedAt:p})}):null,v(o,{trpc:a.trpcClient,deviceId:e,features:i}),n===q.MediaPlayer?v(Am,{deviceId:e,deviceName:t}):null,v(`div`,{className:`flex justify-center`,children:v(Km,{dev:c,busy:u,setBusy:d})})]})}function qm({deviceId:e,features:t}){return v(`div`,{className:`flex h-full w-full flex-col items-stretch gap-3 p-3 sm:p-4`,children:v(Er,{trpc:G().trpcClient,deviceId:e,features:t})})}function Jm({deviceId:e}){let{t}=Z(),n=Ka({deviceId:e},{staleTime:15e3}).data;if(n===void 0||n.linked!==!0||n.switchOn===null)return v(j,{});let r=n.switchOn===!0?t(`deviceHero.powerLine.on`,`Power switch on`):t(`deviceHero.powerLine.off`,`Power switch off`);return v(`p`,{className:`px-3 pt-1 text-[11px] text-foreground-muted sm:px-4`,children:n.switchName===null||n.switchName===``?r:t(`deviceHero.powerLine.withName`,`{{state}} · {{name}}`,{state:r,name:n.switchName})})}function Ym({deviceId:e,features:t}){return v(`div`,{className:`flex h-full w-full flex-col items-stretch p-3 sm:p-4`,children:v(sr,{trpc:G().trpcClient,deviceId:e,features:t})})}function Xm(e){if(!e)return null;let t=e.channel;return typeof t!=`number`||!Number.isInteger(t)||t<0?null:t}var Zm=1e3,Qm=60*Zm,$m=60*Qm,eh=24*$m;function th(e,t){if(e==null||e<=0)return`—`;let n=t-e;return n<Zm?X.t(`helpers.relativeTime.justNow`):n<Qm?X.t(`helpers.relativeTime.secondsAgo`,{count:Math.floor(n/Zm)}):n<$m?X.t(`helpers.relativeTime.minutesAgo`,{count:Math.floor(n/Qm)}):n<eh?X.t(`helpers.relativeTime.hoursAgo`,{count:Math.floor(n/$m)}):X.t(`helpers.relativeTime.daysAgo`,{count:Math.floor(n/eh)})}function nh(e){let t=null;for(let n of e){let e=n.description;if(!(e===void 0||e.length===0)){if(t===null){t=e;continue}if(t!==e)return null}}return t}function rh(e){let t=new Map,n=[];for(let r of e){if(r.source===void 0){n.push(r);continue}let e=t.get(r.source.id);t.set(r.source.id,{source:r.source,entries:[...e?.entries??[],r]})}return[...t.values(),...n.length===0?[]:[{source:null,entries:n}]]}function ih(e,t){if(!e)return null;let n=(Kt(t,e.eventType,e.sourceId)??Kt(t,e.eventType))?.label??e.eventType;if(e.sourceId!==void 0)return{source:t.find(t=>t.source?.id===e.sourceId)?.source?.label??null,label:n};let r=Xm(e.data);return{source:r===null?null:X.t(`hero.eventEmitterHero.button`,{value1:String(r)}),label:n}}T();var ah=1500,oh=15e3,sh=1e3;function ch({deviceId:e}){let{t}=Z(),n=mt(G().trpcClient,e)?.state.eventEmitter,r=Le(n);y(()=>{if(!n)return;n.refresh();let e=setInterval(()=>{n.refresh()},oh);return()=>{clearInterval(e)}},[n]);let i=r?.lastEvent??null,a=i?.seq??null,o=d(null),[c,l]=x(!1);y(()=>{if(a===null)return;let e=o.current;if(o.current=a,e===null||e===a)return;l(!0);let t=setTimeout(()=>{l(!1)},ah);return()=>{clearTimeout(t)}},[a]);let[u,f]=x(()=>Date.now());y(()=>{let e=setInterval(()=>{f(Date.now())},sh);return()=>{clearInterval(e)}},[]);let p=r===void 0?[]:dn(r),m=rh(p),h=nh(p),g=ih(i,p),_=g===null?null:g.source===null?g.label:`${g.source} · ${g.label}`,b=i===null?void 0:Kt(p,i.eventType,i.sourceId),S=r?.eventCountSinceStart??0,C=r!==void 0;return s(`div`,{className:`flex h-full w-full flex-col items-center justify-center gap-3 p-4`,children:[v(`div`,{"data-testid":`event-emitter-indicator`,"data-flashing":String(c),className:`flex h-24 w-24 items-center justify-center rounded-full border-2 transition-all ${c?`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:_??t(`hero.eventEmitterHero.noPressRecorded`,`No press recorded`),children:v(c?ue:F,{className:`h-10 w-10`})}),s(`div`,{className:`text-center`,children:[g!==null&&g.source!==null&&v(`div`,{"data-testid":`event-emitter-source`,className:`text-xs font-semibold uppercase tracking-wide text-primary`,children:g.source}),v(`div`,{"data-testid":`event-emitter-headline`,className:`text-sm font-semibold ${_?`text-foreground`:`text-foreground-subtle`}`,children:_??(C?t(`hero.eventEmitterHero.noPressRecorded`,`No press recorded`):t(`hero.eventEmitterHero.awaitingState`,`Awaiting state…`))}),v(`div`,{className:`text-[10px] text-foreground-subtle mt-0.5`,children:i?th(i.timestamp,u):t(`hero.eventEmitterHero.waitingForTheFirstEvent`,`Waiting for the first event`)})]}),h!==null&&v(`p`,{"data-testid":`event-emitter-notice`,className:`max-w-full text-center text-xs text-foreground-subtle`,children:h}),m.length>0&&v(`div`,{className:`flex max-w-full flex-col items-center gap-1`,children:m.map(e=>s(`div`,{"data-testid":`event-emitter-source-row`,className:`flex max-w-full flex-wrap items-center justify-center gap-1`,children:[e.source!==null&&v(`span`,{className:`text-[10px] font-semibold text-foreground-subtle`,children:e.source.label}),e.entries.map(t=>v(`span`,{"data-testid":`event-emitter-chip`,title:t.description??t.id,className:`rounded-full border px-2 py-0.5 text-[10px] font-medium ${t===b?`border-primary bg-primary/15 text-primary`:`border-border bg-surface text-foreground-subtle`}`,children:t.label},`${e.source?.id??``}:${t.id}`))]},e.source?.id??``))}),v(`div`,{className:`text-[10px] text-foreground-subtle`,children:t(`hero.eventEmitterHero.sinceStart`,{count:S})})]})}function lh({deviceName:e,deviceType:t,provider:n,isOnline:r,features:i}){let{t:a}=Z();return s(`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:[v(sf,{type:n,size:`lg`}),s(`div`,{children:[v(`div`,{className:`text-sm font-semibold text-foreground`,children:e}),v(`div`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wider mt-0.5`,children:t})]}),s(`div`,{className:`flex items-center gap-2 flex-wrap justify-center`,children:[!r&&v(Cr,{status:`offline`}),i.length>0&&v(Pp,{capabilities:i})]}),v(`div`,{className:`text-[10px] text-foreground-subtle italic max-w-xs mt-1`,children:a(`hero.genericHero.noLiveViewForThis`,`No live view for this device type. Use the Config tab or the shortcut row to interact.`)})]})}var uh={[q.Switch]:Q,[q.Siren]:Q,[q.Light]:Q,[q.Sensor]:Q,[q.Button]:Q,[q.Cover]:qm,[q.Valve]:Q,[q.Humidifier]:Q,[q.WaterHeater]:Q,[q.Container]:Gm,[q.Lock]:Q,[q.Fan]:Q,[q.Climate]:Q,[q.MediaPlayer]:Q,[q.Control]:Q,[q.AlarmPanel]:Q,[q.EventEmitter]:ch,[q.Notifier]:Ym,[q.Script]:Q,[q.Automation]:Q,[q.Presence]:Q,[q.Update]:Q,[q.Vacuum]:Q,[q.LawnMower]:Q,[q.Weather]:Q,[q.WeatherStation]:Q,[q.Image]:Q,[q.PetFeeder]:Q,[q.PetFountain]:Q,[q.Dishwasher]:Q,[q.Washer]:Q,[q.Dryer]:Q,[q.EnergySystem]:Q,[q.Workload]:Q,[q.Gateway]:Q,[q.HeatPump]:Q};function dh(e){return uh[e]??lh}function fh({deviceId:e}){let t=pe(G().trpcClient,e,e=>e.runningState);if(t===void 0||t.running!==!0&&t.running!==!1)return v(j,{});let n=t.running;return v(ca,{running:n,since:t?.since??null,phase:t?.phase??null,className:`px-3 pt-2 sm:px-4`})}function ph(e){let t=dh(e.deviceType);return s(j,{children:[v(fh,{deviceId:e.deviceId}),v(Jm,{deviceId:e.deviceId}),v(t,{...e})]})}function mh({deviceId:e,device:t,deviceName:n,defaultHistoryOpen:r=!1,legacyFallback:i=!0,onDrawn:a,onNavigate:o}){let{i18n:s}=Z(),{resolvedMode:c}=ji(),l=_o(),u=O(),d=G(),{user:f}=os(),p=t?.features??[],m=e=>{o===void 0?l(e):o(e)};return v(Wm,{deviceId:e,trpcClient:d.trpcClient,queryClient:u,theme:c,locale:Ri(s.language),canActuate:f?.isAdmin===!0,showName:!1,defaultHistoryOpen:r,...a===void 0?{}:{onDrawn:a},onOpenDevice:e=>m(`/devices/${String(e)}`),onOpenCamera:e=>m(`/devices/${String(e)}`),onNavigate:m,...i?{fallback:v(ph,{deviceId:e,deviceName:n,deviceType:t?.type??`unknown`,deviceRole:t?.role??null,provider:String(t?.addonId??`rtsp`),isOnline:t?.online===!0,features:p})}:{}})}T();function hh(e,t){for(let n of e)for(let e of n.fields){if(!(`key`in e)||e.key!==t)continue;if(e.type===`button`||e.type===`separator`||e.type===`info`)return!0;let r=e.immediate;return r===!0?!0:r===!1?!1:n.immediate===!0}return!1}function gh({schema:e,serverValues:t,onImmediateSave:n,onDeferredSave:r}){let[i,a]=x({}),[o,s]=x({}),[c,l]=x(!1),u=d(null),p=e?.sections??[],m=Object.keys(i).length>0,h=f(()=>({...t,...o,...i}),[t,o,i]);y(()=>{if(m||Object.keys(o).length>0){l(!0);return}u.current&&clearTimeout(u.current),u.current=setTimeout(()=>l(!1),500)},[m,o]),y(()=>()=>{u.current&&clearTimeout(u.current)},[]);let g=_(()=>{l(!0),u.current&&clearTimeout(u.current),u.current=setTimeout(()=>l(!1),2e3)},[]),v=_(e=>{g();let r={},o={},s={...t,...i};for(let[t,n]of Object.entries(e))s[t]!==n&&(hh(p,t)?r[t]=n:o[t]=n);Object.keys(r).length>0&&n(r),a(e=>{let t={...e};for(let e of Object.keys(r))delete t[e];for(let[e,n]of Object.entries(o))t[e]=n;return t})},[g,t,i,p,n]),b=_(e=>{let t={},n={};for(let[r,a]of Object.entries(i))e.includes(r)?t[r]=a:n[r]=a;if(a(n),Object.keys(t).length===0)return;let o=Object.keys(t),c=r(t);if(c===void 0||typeof c.then!=`function`)return;s(e=>({...e,...t}));let l=()=>s(e=>{let t={...e};for(let e of o)delete t[e];return t});c.then(l,()=>{l(),a(e=>{let n={...e};for(let e of o)e in n||(n[e]=t[e]);return n})})},[i,r]),S=_(e=>{a(t=>{let n={...t};for(let t of e)delete n[t];return n})},[]),C=_(()=>{a({})},[]);return{values:h,pendingKeys:Object.keys(i),hasPendingEdits:m,editingPaused:c,handleChange:v,handleSave:b,handleDiscard:S,resetAll:C}}function _h({tabs:e,activeId:t,onChange:n,countByTab:r,pendingByTab:i}){return e.length===0?null:v(`div`,{className:`flex flex-wrap items-center gap-1 border-b border-border shrink-0`,children:e.map(e=>{let a=e.id===t,o=r?.get(e.id)??0,c=i?.get(e.id)??0;return s(W,{variant:`unstyled`,type:`button`,onClick:()=>n(e.id),className:`relative shrink-0 px-3 py-1.5 text-xs font-medium rounded-t-md transition-colors -mb-px border-b-2 whitespace-nowrap ${a?`text-primary border-primary bg-primary/5`:`text-foreground-subtle border-transparent hover:text-foreground hover:bg-surface-hover`}`,children:[e.label,o>0&&s(`span`,{className:`ml-1.5 text-[10px] opacity-60`,children:[`(`,o,`)`]}),c>0&&v(`span`,{className:`ml-1.5 inline-flex h-1.5 w-1.5 rounded-full bg-primary`})]},e.id)})})}T();function vh({schema:e,values:t,pendingKeys:n,onChange:r,onAction:i,onSave:a,onDiscard:o,disabled:c,activeSubTab:l,onSubTabChange:u,flattenTabs:p=!1,visibilityContext:m,hideSaveBar:h=!1,leadingTabs:g=[]}){let _=e.tabs??[],y=f(()=>{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)),S=[...g.map(e=>({id:e.id,label:e.label})),..._,...[...y.keys()].filter(e=>!b.has(e)).map(e=>({id:e,label:e,icon:`wrench`,order:100}))],C=S[0]?.id??`general`,[w,T]=x(C),E=u!==void 0,D=new Set(S.map(e=>e.id)),O=d(new Set);for(let e of D)O.current.add(e);let k=O.current,A=(e=>e&&(D.has(e)||k.has(e))?e:C)(E?l:w),j=e=>{E?u(e):T(e)},M=g.find(e=>e.id===A),N=y.get(A)??[],P={sections:N.length<=1?N.length===1?[{...N[0],title:``}]:N:N.every(e=>!e.title)?[{...N[0],title:``,fields:N.flatMap(e=>e.fields)}]:N},F=h?null:v(Pe,{pendingCount:n.length,onSave:()=>a(n),onDiscard:()=>o(n),saving:c});if(g.length===0&&(p||S.length<=1))return s(`div`,{className:`flex flex-col gap-3`,children:[v(qo,{schema:e,values:t,onChange:r,onAction:i,disabled:c,visibilityContext:m}),F]});let ee=new Map,te=new Map;for(let[e,t]of y){ee.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&&te.set(e,a)}return s(`div`,{className:`flex flex-col gap-3`,children:[v(_h,{tabs:S.map(e=>({id:e.id,label:e.label})),activeId:A,onChange:j,countByTab:ee,pendingByTab:te}),v(_a,{tabKey:A,children:M===void 0?v(qo,{schema:P,values:t,onChange:r,onAction:i,disabled:c,visibilityContext:m}):M.content}),F]})}var yh=`device-export`,bh=`export`,xh=`Export`;function Sh(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(Sh):e.type===`sub-tabs`?e.tabs.some(e=>e.fields.some(Sh)):e.writerCapName===yh}function Ch(e){return e.tab===`export`?!0:e.fields.some(Sh)}var wh=`host/extensions-panel`;function Th(e){return e.type===`widget`?e.widgetId===wh:e.type===`group`?e.fields.some(Th):e.type===`sub-tabs`?e.tabs.some(e=>e.fields.some(Th)):!1}function Eh(e){return e.fields.some(Th)}function Dh(e,t){return!t&&e!==void 0&&Gt.includes(e)}function Oh(e){return e.location!==`top-tab`&&e.location!==`hero`&&!Ch(e)&&!Eh(e)}function kh(e,t,n,r){return!r||Dh(t,n)?!0:(e??[]).some(Oh)}function Ah(e,t){for(let n of e){if(n.type===`group`){Ah(n.fields,t);continue}if(n.type===`sub-tabs`){for(let e of n.tabs)Ah(e.fields,t);continue}if(!(`value`in n))continue;let e=n.value===void 0?n.default:n.value;e!==void 0&&(t[n.key]=e)}}function jh(e){let t={};for(let n of e)Ah(n.fields,t);return t}T();function Mh(e,t){return t&&t===`admin`?e:!0}function Nh(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?Ch(e)&&Ch(t)?e.id.localeCompare(t.id):(e.order??0)-(t.order??0):n.localeCompare(r)})};return e.tabs?{...t,tabs:e.tabs}:t}function Ph(e){return e.type===`separator`||e.type===`info`||e.type===`button`||e.type===`widget`||e.type===`addon-action-button`||e.type===`device-action-button`||e.type===`account-sign-in`||e.type===`secret-presence`}function Fh(e){return e.key}function Ih(e){if(!Ph(e))return e.value}function Lh(e){return Ph(e)?null:e}function Rh(e,t){for(let n of e)if(t(n),n.type===`group`)Rh(n.fields,t);else if(n.type===`sub-tabs`)for(let e of n.tabs)Rh(e.fields,t)}function zh(e){if(!e)return{};let t={};for(let n of e.sections)Rh(n.fields,e=>{let n=Fh(e);n!==null&&(t[n]=Ih(e))});return t}function Bh(e,t){if(!e)return null;let n=null;for(let r of e.sections)if(Rh(r.fields,e=>{if(n!==null||Fh(e)!==t)return;let r=Lh(e);r&&r.writerCapName&&r.writerAddonId&&(n={capName:r.writerCapName,addonId:r.writerAddonId})}),n!==null)break;return n}function Vh(e){return{...e,fields:e.fields.map(Hh)}}function Hh(e){return e.type===`separator`||e.type===`info`||e.type===`button`||e.type===`object-array`?e:{...e,readonlyField:!0}}function Uh(e,t){return e&&{...e,sections:e.sections.map(e=>({...e,fields:e.fields.map(e=>{let n=Lh(e);return n?Mh(t,n.minRole)?e:Hh(e):e})}))}}var Wh={sections:[]};function Gh({deviceId:e,sectionFilter:t,activeSubTab:n,onSubTabChange:r,flattenSubTabs:i,subTabGrouping:a,leadingTabs:o}){let{t:c}=Z(),l=O(),{user:u}=os(),p=u?.isAdmin===!0,m=d(!1),{data:h,isLoading:g}=Fr({deviceId:e},{refetchInterval:()=>m.current?!1:2500,enabled:Number.isFinite(e)}),{data:b}=Kn({deviceId:e},{enabled:Number.isFinite(e)}),x=h?.settings??null,S=h?.live??null,C=f(()=>{if(!x&&!S)return null;let e=x?.sections??[],n=(S?.sections??[]).map(Vh),r=[...e,...n],i=t?r.filter(t):r.filter(Oh);if(i.length===0)return null;if(a){let e=i.map(e=>({...e,tab:a.groupOf(e)})),t=new Set(e.map(e=>e.tab)),n=a.tabs.filter(e=>t.has(e.id));return n.length>0?{tabs:n,sections:e}:{sections:e}}let o=new Set;for(let e of i)o.add(e.tab??`general`);let s=[...x?.tabs??[],...(S?.tabs??[]).filter(e=>!(x?.tabs??[]).some(t=>t.id===e.id))].filter(e=>o.has(e.id));return s.length>0?{tabs:s,sections:i}:{sections:i}},[x,S,t,a]),w=f(()=>jh([...x?.sections??[],...S?.sections??[]]),[x,S]),T=f(()=>Nh(C),[C]),E=f(()=>Uh(T,p),[T,p]),D=f(()=>zh(E),[E]),k=to(),A=Ua(),j=La(),M=mi(),N=Wi({onSuccess:()=>{l.invalidateQueries({queryKey:[[`deviceManager`,`getDeviceAggregate`]]})}}),P={isPending:N.isPending,mutate:t=>{N.mutate({deviceId:e,changes:[...t]})}},F=gh({schema:E,serverValues:D,onImmediateSave:_(e=>{let t=Object.entries(e).map(([e,t])=>{let n=Bh(E,e);return n?{writerCapName:n.capName,writerAddonId:n.addonId,key:e,value:t}:null}).filter(e=>e!==null);t.length>0&&P.mutate(t)},[E,P]),onDeferredSave:_(async t=>{let n=Object.entries(t).map(([e,t])=>{let n=Bh(E,e);return n?{writerCapName:n.capName,writerAddonId:n.addonId,key:e,value:t}:null}).filter(e=>e!==null);if(n.length!==0)try{let t=await N.mutateAsync({deviceId:e,changes:n});if(t.failures.length>0)throw Error(t.failures.map(e=>e.error).join(`; `))}finally{await l.invalidateQueries({queryKey:[[`deviceManager`,`getDeviceAggregate`]]})}},[E,N,e,l])}),{values:ee,pendingKeys:te,handleChange:ne,handleSave:re,handleDiscard:ie}=F;m.current=F.editingPaused;let ae=sp(),oe=d(re),se=d(ie);oe.current=re,se.current=ie;let ce=ae?.register,I=N.isError?N.error instanceof Error?N.error.message:String(N.error):null,le=te.join(`\0`);y(()=>{if(ce===void 0)return;let e=le===``?[]:le.split(`\0`);return ce({id:`export`,dirty:e.length>0,saving:N.isPending,error:I,save:()=>(oe.current(e),Promise.resolve()),discard:()=>se.current(e)})},[ce,le,N.isPending,I]);let ue=o!==void 0&&o.length>0;if(g&&!ue)return s(`div`,{className:`flex items-center justify-center py-12 text-foreground-subtle`,children:[v(H,{className:`h-4 w-4 animate-spin mr-2`}),v(`span`,{className:`text-xs`,children:c(`device.deviceAggregateSection.loadingDeviceAggregate`,`Loading device aggregate…`)})]});if(!ue&&(!E||E.sections.length===0))return v(`div`,{className:`text-xs text-foreground-subtle italic py-4 text-center`,children:c(`device.deviceAggregateSection.noAggregateContributionsForThis`,`No aggregate contributions for this device.`)});async function de(t,n,r){if(t===`regenerate-rtsp-token`){let t=[`rtspUrl:`,`regenerateToken:`].find(e=>n.startsWith(e));if(!t)throw Error(`regenerate-rtsp-token: unrecognised key "${n}" (expected "rtspUrl:<streamId>" or "regenerateToken:<streamId>")`);let r=n.slice(t.length);if(!r)throw Error(`regenerate-rtsp-token: key "${n}" has no streamId after prefix`);let i=pn(e,r);await k.mutateAsync({brokerId:i}),l.invalidateQueries({queryKey:[[`deviceManager`,`getDeviceAggregate`]]});return}if(t===`test-probe`){if(!b)return{status:`error`,error:c(`device.deviceAggregateSection.metadataNotLoaded`)};try{return await j.mutateAsync({addonId:b.addonId,type:b.type,key:n,value:r})}catch(e){return{status:`error`,error:e instanceof Error?e.message:String(e)}}}if(t===`refresh-probe`){if(!n.startsWith(`probedInfo:`))throw Error(`refresh-probe: unrecognised key "${n}" (expected "probedInfo:<streamId>")`);let t=n.slice(11);if(!t)throw Error(`refresh-probe: key "${n}" has no streamId after prefix`);let r=pn(e,t),i=await A.mutateAsync({brokerId:r});return l.invalidateQueries({queryKey:[[`deviceManager`,`getDeviceAggregate`]]}),i}if(t===`device-custom-action`){let t=await M.mutateAsync({deviceId:e,action:n,input:r});return l.invalidateQueries({queryKey:[[`deviceManager`,`getDeviceAggregate`]]}),t}throw Error(`[device-aggregate] unknown action "${t}"`)}return v(vh,{schema:E??Wh,values:ee,pendingKeys:te,onChange:ne,onAction:de,onSave:re,onDiscard:ie,hideSaveBar:ae!==null,disabled:P.isPending,activeSubTab:n,onSubTabChange:r,flattenTabs:i,leadingTabs:o,visibilityContext:w})}var Kh=`device-transitions`;function qh(e,t){return e===`present`&&t.status===`success`&&t.entries.some(e=>e.capName===`device-transitions`)}T();function Jh({deviceId:e,device:t,name:n,onDrawn:r}){let i=sp();return v(er,{frame:`bare`,fill:!0,historyView:!1,children:v(mh,{deviceId:e,device:t,deviceName:n,legacyFallback:!1,onDrawn:r,...i===null?{}:{onNavigate:i.leaveTo}})})}function Yh(){let{t:e}=Z(),t=sp();return t===null?null:v(W,{type:`button`,variant:`outline`,size:`sm`,onClick:t.openDevicePage,children:e(`deviceQuickDetail.openPage`,`Open device page`)})}function Xh({deviceId:e,onClose:t}){let{t:n}=Z(),[r,i]=x(`info`),[a,o]=x(null),{user:c}=os(),l=Aa(e),u=cm(l.presence,l.list),d=Ln(Kh),f=Ga({deviceId:e},{enabled:e>0}),p=qh(d,{status:f.status,entries:f.data?.entries??[]}),m=r===`history`&&!u||r===`actions`&&!p?`info`:r,{data:h}=Kn({deviceId:e},{enabled:e>0}),g=typeof h?.name==`string`?h.name:``,_=ja(e,`full`,g.length>0?g:`#${String(e)}`),y=typeof h?.location==`string`?h.location:``,b=[[`info`,n(`deviceQuickDetail.tabInfo`,{defaultValue:`Device info`})],...u?[[`history`,n(`deviceQuickDetail.tabHistory`,{defaultValue:`History`})]]:[],...p?[[`actions`,n(`deviceQuickDetail.tabActions`,{defaultValue:`Actions`})]]:[],[`export`,n(`deviceQuickDetail.tabExport`,{defaultValue:`Export`})]];return v(Nn,{open:!0,onOpenChange:e=>!e&&t(),children:v(Na,{width:`lg`,scroll:`body`,className:`md:h-[85dvh]`,children:s(cp,{deviceId:e,seed:h==null?null:{name:g,location:y,role:typeof h.role==`string`?h.role:null,display:h.display,tags:h.tags},onClose:t,children:[v($i,{children:s(`div`,{className:`flex flex-wrap items-center justify-between gap-2 pr-8`,children:[v(Ti,{children:_}),v(Yh,{})]})}),v(Yi,{appearance:`pills`,value:m,onValueChange:e=>i(b.find(([t])=>t===e)?.[0]??m),className:`mt-3`,children:v(bi,{children:b.map(([e,t])=>v(Ba,{value:e,children:t},e))})}),v(Li,{className:`mt-3`,children:s(ri,{deviceId:e,device:h??void 0,children:[s(`div`,{className:m===`info`?`flex flex-col gap-3`:`hidden`,children:[v(`div`,{className:a===!0?`h-[26rem] min-h-0`:`hidden`,children:v(Jh,{deviceId:e,device:h,name:_,onDrawn:o})}),h==null?null:v(Ap,{device:h,basic:!0,readOnly:c?.isAdmin!==!0}),v(Jf,{deviceId:e}),v(rm,{})]}),m===`history`?v(Oa,{deviceId:e}):null,m===`actions`?v(kr,{deviceId:e}):null,v(`div`,{className:m===`export`?void 0:`hidden`,children:v(Gh,{deviceId:e,sectionFilter:Ch})})]})})]})})})}function Zh({children:e}){let[t,n]=x(null),r=_(e=>n(e),[]),i=_(()=>n(null),[]);return s(Ur,{open:r,children:[e,t===null?null:v(Xh,{deviceId:t,onClose:i})]})}T();function Qh({tabs:e,active:t,onChange:n}){return v(`div`,{className:`flex rounded-lg border border-border bg-surface p-0.5 gap-0.5`,children:e.map(e=>v(W,{variant:`unstyled`,type:`button`,onClick:()=>n(e.id),className:[`flex-1 rounded-md px-3 py-1.5 text-xs font-medium transition-colors`,t===e.id?`bg-primary/12 text-primary`:`text-foreground-subtle hover:text-foreground hover:bg-surface-hover`].join(` `),children:e.label},e.id))})}function $h(e){let t=e.formats;if(!t)return``;let n=Object.values(t).filter(e=>e!==void 0&&e.sizeMB>0).map(e=>e.sizeMB);if(n.length===0)return``;let r=Math.min(...n),i=Math.max(...n);return r===i?`${r} MB`:`${r}-${i} MB`}function eg(e){return`${e.inputSize.width}x${e.inputSize.height}`}function tg(e){return e.formats?Object.keys(e.formats).filter(t=>e.formats[t]!==void 0):[]}function ng({entry:e,selected:t,onSelect:n,disabled:r}){let{t:i}=Z(),a=$h(e),o=eg(e),c=tg(e);return s(W,{variant:`unstyled`,type:`button`,onClick:n,disabled:r,className:[`w-full text-left rounded-lg border p-3 transition-all`,t?`border-primary bg-primary/5 ring-1 ring-primary/30`:`border-border bg-background hover:border-foreground-subtle/40 hover:bg-surface-hover/50`,r?`opacity-50 cursor-not-allowed`:`cursor-pointer`].join(` `),children:[v(`div`,{className:`flex items-start justify-between gap-2`,children:s(`div`,{className:`flex-1 min-w-0`,children:[s(`div`,{className:`flex items-center gap-2`,children:[v(`span`,{className:`text-xs font-semibold text-foreground truncate`,children:e.name}),t&&v(_e,{className:`h-3.5 w-3.5 text-primary shrink-0`})]}),v(`p`,{className:`text-[10px] text-foreground-subtle mt-0.5 line-clamp-2`,children:e.description})]})}),s(`div`,{className:`flex items-center gap-3 mt-2 flex-wrap`,children:[s(`span`,{className:`inline-flex items-center gap-1 text-[10px] text-foreground-subtle`,children:[v(Ce,{className:`h-3 w-3`}),o]}),a&&v(`span`,{className:`text-[10px] text-foreground-subtle`,children:a}),c.length>0&&v(`div`,{className:`flex gap-1`,children:c.map(e=>v(`span`,{className:`text-[9px] uppercase rounded bg-surface border border-border px-1 py-0.5 text-foreground-subtle font-mono`,children:e},e))}),e.labels.length>0&&v(`span`,{className:`text-[10px] text-foreground-subtle`,children:i(`common.labels`,{count:e.labels.length})})]})]})}function rg({field:e,value:t,onChange:n,disabled:r}){let{t:i}=Z(),a=e.catalog??[],o=a.length>0,c=jt(a).length>0,l=e.allowCustomPath!==!1||e.allowCustom===!0,u=[...o?[{id:`catalog`,label:i(`formBuilder.modelSelector.models`,`Models ({{length}})`,{length:a.length})}]:[],...l?[{id:`custom`,label:i(`formBuilder.modelSelector.customPath`,`Custom Path`)}]:[]],[d,f]=x(o?`catalog`:`custom`),p=t==null?``:String(t);return s(`div`,{className:`space-y-3`,children:[u.length>1&&v(Qh,{tabs:u,active:d,onChange:f}),d===`catalog`&&o&&c&&v(Gr,{catalog:a,value:p,onChange:e=>n(e),disabled:r||e.disabled}),d===`catalog`&&o&&!c&&v(`div`,{className:`space-y-1.5 max-h-[320px] overflow-y-auto pr-1`,children:a.filter(e=>e.legacy!==!0).map(t=>v(ng,{entry:t,selected:p===t.id,onSelect:()=>n(t.id),disabled:r||e.disabled},t.id))}),d===`catalog`&&!o&&s(`div`,{className:`rounded-md border border-info/30 bg-info/5 px-3 py-2 flex items-start gap-2`,children:[v(ut,{className:`h-3.5 w-3.5 text-info shrink-0 mt-0.5`}),v(`p`,{className:`text-[11px] text-foreground-subtle leading-relaxed`,children:i(`formBuilder.modelSelector.noPredefinedModelsAvailableUse`,`No predefined models available. Use the Custom Path tab to specify a model file path or URL.`)})]}),d===`custom`&&l&&s(`div`,{className:`space-y-2`,children:[v(U,{type:`text`,className:`w-full rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground focus:border-primary focus:ring-1 focus:ring-primary/30 outline-none disabled:opacity-50`,placeholder:i(`formBuilder.modelSelector.enterPathLikeDataModels`,`Enter path like /data/models/custom.onnx or https://...`),value:p,disabled:r||e.disabled,onChange:e=>n(e.target.value)}),e.acceptFormats&&e.acceptFormats.length>0&&s(`p`,{className:`text-[10px] text-foreground-subtle`,children:[i(`formBuilder.modelSelector.acceptedFormats`,`Accepted formats:`),` `,e.acceptFormats.join(`, `)]})]}),(e.compatibilityNote||e.conversionGuideUrl)&&s(`div`,{className:`flex items-start justify-between gap-3 pt-1`,children:[e.compatibilityNote&&s(`p`,{className:`flex items-start gap-1 text-[10px] text-foreground-subtle`,children:[v(ut,{className:`h-3 w-3 mt-0.5 shrink-0`}),e.compatibilityNote]}),e.conversionGuideUrl&&s(`a`,{href:e.conversionGuideUrl,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1 text-[11px] text-primary hover:underline shrink-0`,children:[i(`formBuilder.modelSelector.howToConvertYourModel`,`How to convert your model`),v(P,{className:`h-3 w-3`})]})]})]})}function ig({to:e}){let{search:t}=mo();return v(Y,{to:`${e}${t}`,replace:!0})}T();function ag(){return X.t(`helpers.keychainRevealHost.forbidden`)}function og(e){if(typeof e!=`object`||!e)return null;let t=Reflect.get(e,`data`);if(typeof t!=`object`||!t)return null;let n=Reflect.get(t,`code`);return typeof n==`string`?n:null}function sg(e){let t=og(e);if(t===`FORBIDDEN`||t===`UNAUTHORIZED`)return ag();let n=e instanceof Error?e.message:String(e);return n.length>0?X.t(`helpers.keychainRevealHost.failedWith`,{message:n}):X.t(`helpers.keychainRevealHost.failed`)}function cg({children:e}){let t=Gi();return v(Pi,{reveal:_(async e=>{try{return(await t.mutateAsync({ref:e})).value}catch(e){throw Error(sg(e))}},[t]),children:e})}T();function lg(){let e=G(),t=O(),[n,r]=x(()=>e.isConnected()?`connected`:`disconnected`),i=d(!1),[a,o]=x(0),[s,c]=x([]);y(()=>e.subscribeConnectionEvents(e=>{r(t=>(t!==`connected`&&e===`connected`&&i.current&&o(e=>e+1),e!==`connected`&&(i.current=!0),e))}),[e]),y(()=>{a!==0&&t.invalidateQueries({queryKey:[[`addons`,`getLastRestart`]]})},[a,t]);let{data:l}=ia(void 0,{enabled:n===`connected`&&a>0,staleTime:0,refetchOnMount:!1,refetchOnWindowFocus:!1}),u=d(null);return y(()=>{if(l==null||l.requestedAt===u.current)return;u.current=l.requestedAt;let e=dg(l);c(t=>[...t,e]);let t=window.setTimeout(()=>{c(t=>t.filter(t=>t.id!==e.id))},6e3);return()=>window.clearTimeout(t)},[l]),v(j,{children:s.length>0&&v(ug,{toasts:s})})}function ug({toasts:e}){return v(`div`,{className:`fixed top-[calc(env(safe-area-inset-top)+1rem)] right-[calc(env(safe-area-inset-right)+1rem)] z-50 flex flex-col gap-2 max-w-sm w-full pointer-events-none`,children:e.map(e=>s(`div`,{className:`pointer-events-auto flex items-start gap-2 px-3 py-2.5 rounded-md border border-green-500/30 bg-green-500/10 shadow-lg`,children:[v(Ve,{className:`w-4 h-4 shrink-0 mt-0.5 text-green-400`}),s(`div`,{children:[v(`div`,{className:`text-[11px] font-semibold text-foreground`,children:e.title}),v(`div`,{className:`text-[10px] text-foreground-subtle mt-0.5`,children:e.message})]})]},e.id))})}function dg(e){let t=`restart-${e.requestedAt}`;if(e.kind===`framework-update`&&e.packageName!==void 0&&e.toVersion!==void 0){let n=e.fromVersion===void 0?`v${e.toVersion}`:`v${e.fromVersion} → v${e.toVersion}`;return{id:t,title:X.t(`system.reconnectOverlay.frameworkUpdated`,`Framework updated`),message:X.t(`system.reconnectOverlay.isNow`,`{{packageName}} is now {{fromTo}}.`,{packageName:e.packageName,fromTo:n})}}return{id:t,title:X.t(`system.reconnectOverlay.serverRestarted`,`Server restarted`),message:e.requestedBy===void 0?X.t(`system.reconnectOverlay.manualRestartCompleted`,`Manual restart completed.`):X.t(`system.reconnectOverlay.manualRestartByCompleted`,`Manual restart by {{requestedBy}} completed.`,{requestedBy:e.requestedBy})}}var fg=`/system/settings`,pg=[{path:`/system/capabilities`,tab:`capabilities`},{path:`/system/api-explorer`,tab:`api-explorer`}];function mg(e,t=``){let n=new URLSearchParams(t);return n.delete(`tab`),n.set(`tab`,e),`${fg}?${n.toString()}`}var hg=`/system/data`,gg=`/system/secrets`;function _g(e=``){let t=new URLSearchParams(e),n=t.get(`view`);return t.delete(`view`),t.set(`tab`,`secrets`),n===`audit`&&t.set(`secretsView`,`audit`),`${hg}?${t.toString()}`}function vg({tab:e}){let{search:t,hash:n}=mo();return v(Y,{to:`${mg(e,t)}${n}`,replace:!0})}function yg(){let{search:e,hash:t}=mo();return v(Y,{to:`${_g(e)}${t}`,replace:!0})}T();var bg={info:{bg:`bg-info/10`,border:`border-info/30`,icon:ut},warning:{bg:`bg-warning/10`,border:`border-warning/30`,icon:He},critical:{bg:`bg-danger/10`,border:`border-danger/30`,icon:Ue}};function xg({toast:e,onDismiss:t}){let n=bg[e.severity]??bg.info,r=n.icon;return y(()=>{let n=e.duration??5e3;if(n<=0)return;let r=setTimeout(()=>t(e.id),n);return()=>clearTimeout(r)},[e.id,e.duration,t]),v(`div`,{className:`rounded-lg bg-surface shadow-lg animate-in slide-in-from-right-5 fade-in duration-200`,children:s(`div`,{className:`flex items-start gap-3 px-4 py-3 rounded-lg border ${n.border} ${n.bg}`,children:[v(r,{className:`h-4 w-4 shrink-0 mt-0.5 text-foreground-subtle`}),s(`div`,{className:`flex-1 min-w-0`,children:[v(`div`,{className:`text-xs font-semibold text-foreground`,children:e.title}),v(`div`,{className:`text-[11px] text-foreground-subtle mt-0.5`,children:e.message})]}),v(W,{variant:`unstyled`,type:`button`,onClick:()=>t(e.id),className:`shrink-0 p-0.5 rounded hover:bg-surface-hover transition-colors`,children:v(I,{className:`h-3.5 w-3.5 text-foreground-subtle`})})]})})}function Sg(){let[e,t]=x([]),n=_(e=>{t(t=>t.filter(t=>t.id!==e))},[]),r=_(e=>{let n=`toast-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;t(t=>[...t,{...e,id:n,timestamp:Date.now()}])},[]);return ii(void 0,{onData:e=>r(e)}),y(()=>gl(r),[r]),e.length===0?null:v(`div`,{className:`fixed bottom-[calc(env(safe-area-inset-bottom)+1rem)] right-[calc(env(safe-area-inset-right)+1rem)] z-50 flex flex-col gap-2 max-w-sm w-full pointer-events-none`,children:e.map(e=>v(`div`,{className:`pointer-events-auto`,children:v(xg,{toast:e,onDismiss:n})},e.id))})}T();function Cg({children:e}){let{t}=Z();return v(wt,{t:f(()=>om(t),[t]),children:e})}T();function wg(e){if(typeof e!=`object`||!e)return;let{data:t}=e;return t?.code}function Tg(e,t){let n=wg(e);return n===`UNAUTHORIZED`||n===`FORBIDDEN`?!0:/UNAUTHORIZED|FORBIDDEN/.test(t)}function Eg(e,t,n,r){let[i,a]=x(!1),[o,s]=x(null);return y(()=>{if(a(!1),s(null),!t){a(!0);return}let i=!1;e.init().catch(()=>void 0);let o=t=>{e.awaitConnected().then(()=>{i||a(!0)},e=>{if(i)return;let c=e instanceof Error?e.message:String(e);if(Tg(e,c)){if(t&&r!==void 0){r().then(e=>{if(!i){if(e){o(!1);return}console.warn(`[boot-gate] logout: probe UNAUTHORIZED and the refresh was refused`),n()}},()=>{i||(console.warn(`[boot-gate] logout: probe UNAUTHORIZED and recovery failed`),n())});return}console.warn(`[boot-gate] logout: probe UNAUTHORIZED after a successful refresh`,c),n();return}s(c),a(!0)})};return o(!0),()=>{i=!0}},[e,t,n,r]),{bootReady:i,bootError:o}}T();var Dg=3e4;function Og(e){let t=d(e);t.current=e,y(()=>{let e=null,n=()=>{if(document.visibilityState===`hidden`){e=Date.now();return}if(document.visibilityState===`visible`&&e!==null){let n=Date.now()-e;e=null,n>=Dg&&t.current()}},r=()=>{t.current()},i=e=>{e.persisted&&t.current()};return document.addEventListener(`visibilitychange`,n),window.addEventListener(`online`,r),window.addEventListener(`pageshow`,i),()=>{document.removeEventListener(`visibilitychange`,n),window.removeEventListener(`online`,r),window.removeEventListener(`pageshow`,i)}},[])}var kg=`@dominevo/ui-library`;function Ag(e){return typeof e==`object`&&!!e}var jg=/^>=\s*(\d+)\.(\d+)\.(\d+)/,Mg=/^(\d+)\.(\d+)\.(\d+)/;function Ng(e){return e===null?null:[Number(e[1]),Number(e[2]),Number(e[3])]}function Pg(e,t){for(let n=0;n<3;n++){let r=e[n]??0,i=t[n]??0;if(r!==i)return r<i}return!1}function Fg(e,t){let n=[];for(let r of Object.values(e)){let e=r[kg];if(!(typeof e!=`object`||!e))for(let r of Object.values(e)){if(!Ag(r)||r.from!==t)continue;let e=r.shareConfig?.requiredVersion;typeof e==`string`&&n.push(e)}}return n}function Ig(e,t){let n=e===null?null:Ng(e.match(Mg));if(n===null||e===null)return null;for(let r of t){let t=Ng(r.match(jg));if(t!==null&&Pg(n,t))return{required:t.join(`.`),host:e}}return null}T();function Lg(){let{t:e}=Z();return s(`div`,{role:`status`,"aria-busy":`true`,"aria-label":e(`layouts.addonPageLoader.loading`,`Loading page`),"data-testid":`addon-page-loading`,className:`flex flex-col gap-4 p-2 sm:p-4`,children:[v(zi,{className:`h-7 w-48`}),v(zi,{className:`h-5 w-72 max-w-full`}),v(zi,{className:`h-40`})]})}function Rg({message:e}){let{t}=Z();return v(`div`,{className:`p-2 sm:p-4`,"data-testid":`addon-page-error`,children:v(pi,{title:t(`layouts.addonPageLoader.failedTitle`,`This page could not be shown`),message:e})})}var zg=class extends l{state={error:null,resetKey:this.props.resetKey};static getDerivedStateFromError(e){return{error:e instanceof Error?e:Error(String(e))}}static getDerivedStateFromProps(e,t){return e.resetKey===t.resetKey?null:{error:null,resetKey:e.resetKey}}componentDidCatch(e,t){console.error(`[addon-page] ${this.props.resetKey} crashed`,e,t.componentStack)}render(){return this.state.error===null?this.props.children:v(Rg,{message:this.state.error.message})}};function Bg({resetKey:e,children:t}){return v(zg,{resetKey:e,children:t})}function Vg({pageKey:e,children:t}){return v(zg,{resetKey:e,children:v(g,{fallback:v(Lg,{}),children:t})})}function Hg(e){let t=new Set,n=new Set,r=e=>e.page.remoteName.includes(e.addonId.replace(/[^a-zA-Z0-9]+/g,`_`)),i=[...e.filter(r),...e.filter(e=>!r(e))],a=[];for(let e of i){let r=`${e.addonId}::${e.page.id}`;t.has(r)||n.has(e.page.path)||(t.add(r),n.add(e.page.path),a.push({id:e.page.id,addonId:e.addonId,label:e.page.label,icon:e.page.icon,path:e.page.path,remoteName:e.page.remoteName,bundle:e.page.bundle,bundleUrl:e.bundleUrl,...e.page.section===void 0?{}:{section:e.page.section},...e.page.sectionLabel===void 0?{}:{sectionLabel:e.page.sectionLabel}}))}return a}T();var Ug=2e4;function Wg(e,t){let[n,r]=x(!1);return y(()=>{if(!e){r(!1);return}let n=setTimeout(()=>r(!0),t);return()=>clearTimeout(n)},[e,t]),n}var Gg=new Map,Kg=new Map,qg=new Set;function Jg(e){return!e||typeof e!=`object`?!1:typeof e.default==`function`}var Yg=class extends Error{problem;constructor(e){super(`ui-library ${e.host} is older than the ${e.required} this page requires`),this.problem=e}};function Xg(e){let t=i()?.shareScopeMap;if(!t)return;let n=Ig(ua,Fg(t,e));if(n!==null)throw new Yg(n)}async function Zg(e,t){let i=Gg.get(e);if(i)return i;let a=Kg.get(e);if(a)return a;qg.has(e)||(zn(),r([{name:e,entry:V(t),type:`module`}],{force:!1}),qg.add(e));let o=n(`${e}/page`).then(n=>{if(Xg(e),!Jg(n))throw Error(`Addon page remote ${e} (${t}) does not expose a default React component on './page'`);return Gg.set(e,n.default),Kg.delete(e),n.default}).catch(t=>{throw Kg.delete(e),Xg(e),t});return Kg.set(e,o),o}function Qg(){let{t:e}=Z(),{pagePath:t}=go(),n=_o(),r=G(),{data:i,isError:a,error:o}=Za(void 0),s=f(()=>i?Hg(i):void 0,[i]),c=s?.find(e=>e.path===`/addon/${t}`),l=c?.remoteName,u=c?.bundleUrl,[d,p]=x(null),[m,h]=x(null);y(()=>{if(!l||!u)return;h(null);let t=Gg.get(l);if(t){p(()=>t);return}p(null);let n=!1;return Zg(l,u).then(e=>{n||p(()=>e)}).catch(t=>{n||h(t instanceof Yg?e(`layouts.addonPageLoader.hostTooOld`,{defaultValue:`This page needs a newer admin UI (UI library {{required}} or later; this one has {{host}}). Update admin-ui.`,required:t.problem.required,host:t.problem.host}):t instanceof Error?t.message:String(t))}),()=>{n=!0}},[l,u]);let g=Wg(!s&&!a,Ug),_=Wg(c!==void 0&&!d&&!m,Ug);return s?c?m?v(Rg,{message:m}):d?v(Vg,{pageKey:c.remoteName,children:v(d,{trpc:r.trpcClient,theme:{isDark:document.documentElement.classList.contains(`dark`)},navigate:e=>{n(e.startsWith(`/`)?e:`/${e}`)}})}):_?v(Rg,{message:e(`layouts.addonPageLoader.remoteStalled`,`The page did not load. Its addon may be starting or unreachable.`)}):v(Lg,{}):v(`div`,{className:`flex items-center justify-center h-full text-foreground-subtle`,children:e(`layouts.addonPageLoader.addonPageNotFound`,`Addon page not found`)}):a?v(Rg,{message:o?.message??e(`layouts.addonPageLoader.listFailed`,`The page list could not be loaded.`)}):g?v(Rg,{message:e(`layouts.addonPageLoader.listStalled`,`The hub did not send the page list. Try again in a moment.`)}):v(Lg,{})}var $g={"/system/pipeline":`pipeline-orchestrator`,"/system/history":`device-history`,"/system/ai":`llm`},e_=[{key:`top`,labelKey:null,fallback:``,items:[{labelKey:`nav.devices`,fallback:`Devices`,icon:`camera`,path:`/devices`},{labelKey:`nav.integrations`,fallback:`Integrations`,icon:`plug`,path:`/integrations`},{labelKey:`nav.build`,fallback:`Build-your-self`,icon:`hammer`,path:`/build`,adminOnly:!0},{labelKey:`nav.locations`,fallback:`Locations`,icon:`map-pin`,path:`/locations`,adminOnly:!0},{labelKey:`nav.viewer`,fallback:`Viewer`,icon:`monitor`,path:`/live`,hiddenWhenEmbedded:!0}]},{key:`detection`,labelKey:`nav.detectionSection`,fallback:`Detection`,items:[{labelKey:`nav.library`,fallback:`Library`,icon:`library`,path:`/library`,adminOnly:!0,keywords:[`People`,`Vehicles`,`Events`,`Scenes`,`plates`,`faces`,`detection-intelligence`]},{labelKey:`nav.archive`,fallback:`Archive`,icon:`archive`,path:`/archive`,adminOnly:!0}]},{key:`cluster`,labelKey:`nav.clusterSection`,fallback:`Cluster`,items:[{labelKey:`nav.nodes`,fallback:`Nodes`,icon:`network`,path:`/system/nodes`,adminOnly:!0},{labelKey:`nav.history`,fallback:`History`,icon:`line-chart`,path:`/system/history`,adminOnly:!0,keywords:[`charts`,`graphs`,`energy`,`temperature`,`metrics`,`trends`]},{labelKey:`nav.pipeline`,fallback:`Pipeline`,icon:`git-branch`,path:`/system/pipeline`},{labelKey:`system.addons`,fallback:`Addons`,icon:`puzzle`,path:`/system/addons`,adminOnly:!0},{labelKey:`system.ai`,fallback:`AI`,icon:`sparkles`,path:`/system/ai`,adminOnly:!0},{labelKey:`nav.jobs`,fallback:`Jobs`,icon:`activity`,path:`/system/jobs`,adminOnly:!0,keywords:[`activity`,`tasks`,`progress`,`adoption`]}]},{key:`administration`,labelKey:`system.title`,fallback:`Administration`,items:[{labelKey:`system.identity`,fallback:`Identity & Access`,icon:`lock`,path:`/system/identity`,adminOnly:!0},{labelKey:`system.network`,fallback:`Network`,icon:`globe`,path:`/system/network`,adminOnly:!0},{labelKey:`system.integrations`,fallback:`Connectivity`,icon:`plug`,path:`/system/integrations`,adminOnly:!0},{labelKey:`system.data`,fallback:`Data`,icon:`database`,path:`/system/data`,adminOnly:!0},{labelKey:`system.notifications`,fallback:`Notifications`,icon:`bell`,path:`/system/notifications`,adminOnly:!0},{labelKey:`system.calendars`,fallback:`Calendars`,icon:`calendar`,path:`/system/calendars`,adminOnly:!0},{labelKey:`system.systemNav`,fallback:`System`,icon:`settings`,path:fg,adminOnly:!0},{labelKey:`system.logs`,fallback:`Logs`,icon:`scroll-text`,path:`/system/logs`,adminOnly:!0},{labelKey:`system.terminal`,fallback:`Terminal`,icon:`terminal`,path:`/system/terminal`,adminOnly:!0}]}],t_={camera:xe,plug:te,hammer:Ct,"map-pin":Xe,monitor:Me,library:Tn,archive:yn,network:Te,activity:We,"line-chart":ot,"git-branch":An,puzzle:Ge,sparkles:At,lock:_t,globe:Sn,database:Fe,bell:L,calendar:se,settings:dt,"scroll-text":vt,terminal:kn};function n_(e){return t_[e]??Ge}function r_(e,t){let n=$g[e.path];return{label:t(e.labelKey,e.fallback),icon:n_(e.icon),path:e.path,...e.adminOnly===!0?{adminOnly:!0}:{},...e.keywords===void 0?{}:{keywords:e.keywords},...n===void 0?{}:{requiresCapability:n}}}function i_({t:e,isAdmin:t,embeddedByViewer:n=!1}){return e_.map(r=>({key:r.key,label:r.labelKey===null?null:e(r.labelKey,r.fallback),items:r.items.filter(e=>(e.adminOnly!==!0||t)&&!(n&&e.hiddenWhenEmbedded===!0)).map(t=>r_(t,e))}))}var a_={gauge:st,puzzle:Ge,bot:De,cpu:Ce,terminal:kn,box:le,boxes:le,monitor:Me,wrench:me,activity:We,plug:te,"graduation-cap":ve};function o_(e){return a_[e]??Ge}function s_(e,t){for(let n of i_(t))for(let t of n.items)if(t.path===e)return{icon:t.icon,title:t.label,path:t.path};return null}var c_=`/system/addons`;function l_({path:e,children:t}){let n=$g[e];return n===void 0?v(j,{children:t}):v(u_,{path:e,capability:n,children:t})}function u_({path:e,capability:t,children:n}){let{t:r}=Z(),i=_o(),a=Ln(t);if(a===`present`)return v(j,{children:n});if(a===`pending`)return s(`div`,{className:`flex flex-col gap-4 p-2 sm:p-4`,"data-testid":`page-presence-pending`,children:[v(zi,{className:`h-7 w-48`}),v(zi,{className:`h-40`})]});if(a===`unknown`)return v(`div`,{className:`p-2 sm:p-4`,"data-testid":`page-presence-unknown`,children:v(pi,{title:r(`pageRequires.unknownTitle`,`Could not check whether this page is available`),message:r(`pageRequires.unknown`,`The hub did not answer the capability check. Reload the page to try again.`)})});let o=s_(e,{t:r,isAdmin:!0});return v(`div`,{className:`p-2 sm:p-4`,"data-testid":`page-not-installed`,children:v(zr,{icon:o?.icon??Ge,title:r(`pageRequires.absentTitle`,`{{page}} is not installed`,{page:o?.title??e}),description:r(`pageRequires.absentDescription`,`The addon that provides this page is not installed. Install it from System → Addons.`),action:v(W,{variant:`primary`,onClick:()=>i(c_),children:r(`pageRequires.openAddons`,`Open Addons`)})})})}function d_({capability:e,children:t}){return v(j,{children:t(Ln(e)===`absent`)})}function f_({children:e}){return v(Zn,{value:p_(xi({})),children:e})}function p_(e){return e.data===void 0?e.isPending?{status:`pending`}:{status:`unknown`,reason:e.isError?String(e.error):`no palette`}:e.data.status===`unknown`?{status:`unknown`,reason:e.data.reason}:{status:`ready`,palette:e.data}}function m_(){let e=Lr(),{t}=Z();return e.status===`unknown`?v(`p`,{role:`status`,className:`shrink-0 px-4 py-1 text-xs text-warning`,children:t(`pipeline.palette.unknown`,`The stored palette cannot be read ({{reason}}). Boxes use the bundled Dominevo preset.`,{reason:e.reason})}):null}var h_=[`device`,`page`,`automation`,`script`,`scheduler`,`action`,`template`,`customDevice`,`integration`];function g_(e,t,n=200){if(an(t).length===0)return{groups:[],totalMatched:0,truncated:!1};let r=new Map;for(let n of e){let e=sn(t,{label:n.label,keywords:n.keywords,identifiers:n.identifiers});if(e===null)continue;let i=r.get(n.domain)??[];i.push({item:n,rank:e}),r.set(n.domain,i)}let i=0;for(let e of r.values())i+=e.length;let a=n,o=[];for(let e of h_){let t=r.get(e);if(!t||t.length===0||a<=0)continue;t.sort((e,t)=>e.rank-t.rank||e.item.label.localeCompare(t.item.label));let n=t.slice(0,a).map(e=>e.item);a-=n.length,o.push({domain:e,items:n})}return{groups:o,totalMatched:i,truncated:i>n}}function __(e){return e.flatMap(e=>e.items)}var v_=` · `;function y_(e,t,n,r){let i=[`#${t}`];return r!==void 0&&i.push(r),e.stableId.length>0&&e.stableId!==n&&i.push(e.stableId),i.push(e.type),e.disabled&&i.push(`disabled`),i.join(v_)}function b_(e,t=null){let n=ta(e),r=la(X.language.startsWith(`it`)?`it`:`en`),i=Ii(e),a=Qr(t);return e.map(e=>{let t=String(e.id),o=Oi(e,`compact`,i,r),s=o.length>0?o:e.stableId||`#${t}`,c=n.get(e.id),l=c!==void 0&&(s===c||s.split(v_).includes(c)),u=a(e),d=u.kind===`resolved`?u.integration.name:``;return{key:`device:${t}`,domain:`device`,label:s,subtitle:y_(e,t,s,l?void 0:c),identifiers:[t,`#${t}`],keywords:[...e.name.length>0&&e.name!==s?[e.name]:[],e.stableId,e.addonId,e.location??``,c??``,d].filter(e=>e.length>0),path:`/devices/${t}`,icon:rr(e)}})}function x_(e){return e.map(e=>({key:`integration:${e.id}`,domain:`integration`,label:e.name||e.addonId,subtitle:e.enabled?e.addonId:X.t(`helpers.searchItems.disabled`,{addonId:e.addonId}),keywords:[e.addonId,e.processState],path:jd(e.addonId,e.id)}))}function S_(e,t,n){let r=e.section?.trim();return r?t[r]??e.sectionLabel?.trim()??r:n}function C_(e,t,n){let r=e.flatMap(e=>e.items.map(t=>({key:`page:${t.path}`,domain:`page`,label:t.label,subtitle:e.label??void 0,path:t.path,icon:t.icon,...t.keywords!==void 0&&t.keywords.length>0?{keywords:t.keywords}:{}}))),i={detection:n.detection,cluster:n.cluster,administration:n.administration},a=t.map(e=>({key:`page:addon:${e.addonId}:${e.id}`,domain:`page`,label:e.label,subtitle:S_(e,i,n.ungrouped),keywords:[e.addonId],path:e.path,icon:o_(e.icon)}));return[...r,...a]}var w_=`edit`;function T_(e){return`/build?tab=templates&${w_}=${encodeURIComponent(e)}`}var E_=`const AUTOMATION_RECIPE =`,D_=`// EJECTED from the visual automation editor — this file is now hand-owned.
4
4
  // The recipe that produced it was removed with it, on purpose: while it was
5
- // here the editor could re-open this block and overwrite everything below.`;function O_(e){return e.includes(E_)}function k_(e){if(!O_(e))return!1;let t=nn(e);return!(t.status===`recipe`&&t.recipe.template?.templateId===`builtin:linked-trigger`)}function A_(e){return!O_(e.code)}function j_(e){let t=e.indexOf(E_);if(t<0)return null;let n=e.indexOf(`{`,t+25);if(n<0)return null;let r=0,i=!1,a=!1;for(let o=n;o<e.length;o+=1){let s=e.charAt(o);if(i){a?a=!1:s===`\\`?a=!0:s===`"`&&(i=!1);continue}if(s===`"`){i=!0;continue}if(s===`{`)r+=1;else if(s===`}`&&(--r,r===0))return{declStart:t,literalEnd:o+1,json:e.slice(n,o+1)}}return null}function M_(e){let t=j_(e);if(t===null)return{ok:!1,reason:X.t(`helpers.recipeFromCode.noLiteral`)};let n;try{n=JSON.parse(t.json)}catch(e){let t=e instanceof Error?e.message:String(e);return{ok:!1,reason:X.t(`helpers.recipeFromCode.badJson`,{detail:t})}}let r=fn.safeParse(n);if(!r.success){let e=r.error.issues[0];return{ok:!1,reason:e===void 0?X.t(`helpers.recipeFromCode.schemaMismatch`):X.t(`helpers.recipeFromCode.schemaMismatchAt`,{path:e.path.join(`.`),message:e.message})}}return{ok:!0,recipe:r.data}}function N_(e){let t=j_(e);if(t===null)return e;let n=e.slice(t.literalEnd),r=/^\s*as\s+const/.exec(n),i=t.literalEnd+(r===null?0:r[0].length);return`${e.slice(0,t.declStart)}${D_}${e.slice(i)}`}function P_(e,t,n){return`/build?tab=${e}&${t}=${encodeURIComponent(n)}`}function F_(e){return e??[]}function I_(e){let t=[];for(let n of e.blocks??[])if(O_(n.code)){if(!k_(n.code))continue;t.push({key:`automation:${n.id}`,domain:`automation`,label:n.name,keywords:F_(n.tags),path:P_(`automations`,`block`,n.id)})}else Rt(n)===`code`&&A_(n)&&t.push({key:`script:${n.id}`,domain:`script`,label:n.name,keywords:F_(n.tags),path:P_(`scripts`,`block`,n.id)});for(let n of e.schedulers??[])t.push({key:`scheduler:${n.id}`,domain:`scheduler`,label:n.name,keywords:F_(n.tags),path:P_(`schedulers`,`scheduler`,n.id)});for(let n of e.actions??[])t.push({key:`action:${n.id}`,domain:`action`,label:n.name,keywords:F_(n.tags),path:P_(`actions`,`action`,n.id)});for(let n of e.templates??[])t.push({key:`template:${n.id}`,domain:`template`,label:n.name,subtitle:n.kind,keywords:F_(n.tags),path:T_(n.id)});for(let n of e.compositions??[])t.push({key:`customDevice:${n.block.id}`,domain:`customDevice`,label:n.block.name,keywords:F_(n.block.tags),path:Vp(n.block.id)});return t}T();var L_={device:{labelKey:`search.resultsList.devices`,icon:xe},page:{labelKey:`search.resultsList.pages`,icon:vn},integration:{labelKey:`search.resultsList.integrations`,icon:te},automation:{labelKey:`search.resultsList.automations`,icon:ht},script:{labelKey:`search.resultsList.scripts`,icon:En},scheduler:{labelKey:`search.resultsList.schedulers`,icon:de},action:{labelKey:`search.resultsList.actions`,icon:qe},template:{labelKey:`search.resultsList.templates`,icon:On},customDevice:{labelKey:`search.resultsList.customDevices`,icon:je}};function R_({groups:e,activeKey:t,query:n,totalMatched:r,truncated:i,pending:a=!1,onSelect:o,onHover:c}){let{t:l}=Z(),u=d(null);if(y(()=>{t&&(u.current?.querySelector(`[data-key="${CSS.escape(t)}"]`))?.scrollIntoView({block:`nearest`})},[t]),n.trim().length===0)return null;if(e.length===0&&a)return v(`div`,{role:`status`,className:`px-3 py-4 text-center text-[12px] text-foreground-subtle`,"data-testid":`search-pending`,children:l(`search.resultsList.searching`,`Searching…`)});if(e.length===0)return v(`div`,{className:`px-3 py-4 text-center text-[12px] text-foreground-subtle`,children:l(`search.resultsList.noResults`,{query:n})});let f=e.reduce((e,t)=>e+t.items.length,0);return s(j,{children:[v(`div`,{ref:u,role:`listbox`,className:`max-h-[60vh] overflow-y-auto py-1`,children:e.map(e=>{let n=L_[e.domain],r=n.icon;return s(`div`,{className:`px-1 py-1`,children:[s(`div`,{className:`sticky top-0 z-10 flex items-center gap-1.5 bg-surface px-2 py-1 text-[10px] font-semibold uppercase tracking-widest text-foreground-subtle/60`,children:[v(r,{className:`h-3 w-3`}),l(n.labelKey)]}),e.items.map(e=>{let r=e.icon??n.icon,i=e.key===t;return s(W,{variant:`unstyled`,type:`button`,role:`option`,"aria-selected":i,"data-key":e.key,onMouseEnter:()=>c(e),onClick:()=>o(e),className:`flex w-full items-center gap-2.5 rounded-md px-2 py-1.5 text-left text-[12px] transition-colors ${i?`bg-primary/12 text-primary`:`text-foreground hover:bg-surface-hover`}`,children:[v(r,{className:`h-3.5 w-3.5 shrink-0 ${i?`text-primary`:`text-foreground-subtle`}`}),s(`span`,{className:`flex-1 min-w-0`,children:[v(`span`,{className:`block truncate font-medium`,children:e.label}),e.subtitle&&v(`span`,{className:`block truncate text-[10px] text-foreground-subtle`,children:e.subtitle})]})]},e.key)})]},e.domain)})}),i&&v(`div`,{className:`border-t border-border px-3 py-1.5 text-center text-[10px] text-foreground-subtle`,children:l(`search.truncatedResults`,`Showing first {{shown}} of {{total}} — refine your search.`,{shown:f,total:r})})]})}T(),uo();function z_({navSections:e,addonPages:t,compact:n,onNavigated:r,floating:i=!1,request:a=null}){let{t:o}=Z(),c=_o(),l=d(null),u=d(null),p=d(null),[m,h]=x(null),[g,b]=x(``),[S,C]=x(0),[w,T]=x(!1),{data:E}=Mr({projection:`slim`}),{data:D}=Sa(void 0),O=w&&g.trim().length>0,k={enabled:O},A=nr({},k),j=Ci({},k),M=xa({},k),N=aa({},k),P=Ar({},k),F=O&&[A,j,M,N,P].some(e=>e.isLoading),ee=f(()=>{let n={detection:o(`nav.detectionSection`,`Detection`),cluster:o(`nav.clusterSection`,`Cluster`),administration:o(`system.title`,`Administration`),ungrouped:o(`nav.addonPages`,`Addon Pages`)};return[...b_(E??[],D??null),...C_(e,t,n),...x_(D??[]),...I_({blocks:A.data?.blocks,actions:j.data,schedulers:M.data,templates:N.data,compositions:P.data?.state===`loaded`?P.data.views:void 0})]},[E,D,e,t,o,A.data,j.data,M.data,N.data,P.data]),{groups:te,totalMatched:ne,truncated:re}=f(()=>g_(ee,g),[ee,g]),ie=f(()=>__(te),[te]);y(()=>{C(0)},[g,ee]),y(()=>{w&&l.current?.focus()},[w]);let oe=a?.id,se=a?.query;y(()=>{oe!==void 0&&(b(se??``),T(!0))},[oe,se]);let ce=_(()=>{T(!1),b(``),C(0)},[]),le=_(e=>{c(e.path),ce(),l.current?.blur(),r?.()},[c,ce,r]);ae(l,{scope:be}),y(()=>{if(!w)return;function e(e){if(!(e.target instanceof Node))return;let t=u.current?.contains(e.target)===!0,n=p.current?.contains(e.target)===!0;!t&&!n&&T(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[w]);let ue=w&&g.trim().length>0;y(()=>{if(!ue){h(null);return}let e=()=>{let e=l.current?.getBoundingClientRect();e&&h({left:e.left,top:e.bottom+4,width:e.width})};return e(),window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},[ue]);let de=ie[S]?.key??null,fe=o(`search.placeholder`,`Search devices, pages, automations, scripts…`),pe=s(`div`,{className:`relative`,children:[v(ft,{className:`pointer-events-none absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-foreground-subtle`}),v(U,{ref:l,type:`text`,value:g,placeholder:fe,"aria-label":fe,role:`combobox`,"aria-expanded":w&&g.trim().length>0,"aria-controls":`global-search-results`,onChange:e=>{b(e.target.value),T(!0)},onFocus:()=>T(!0),onKeyDown:e=>{if(e.key===`ArrowDown`)e.preventDefault(),ie.length>0&&C(e=>(e+1)%ie.length);else if(e.key===`ArrowUp`)e.preventDefault(),ie.length>0&&C(e=>(e-1+ie.length)%ie.length);else if(e.key===`Enter`){e.preventDefault();let t=ie[S];t&&le(t)}else e.key===`Escape`&&(e.preventDefault(),ce(),l.current?.blur())},className:`w-full rounded-md border border-border bg-surface py-1.5 pl-7 pr-6 text-[12px] text-foreground placeholder:text-foreground-subtle/70 focus:outline-none focus:ring-1 focus:ring-primary/50`}),g.length>0&&v(W,{variant:`unstyled`,type:`button`,"aria-label":o(`search.globalSearch.clearSearch`,`Clear search`),onClick:()=>{b(``),l.current?.focus()},className:`absolute right-1.5 top-1/2 -translate-y-1/2 text-foreground-subtle hover:text-foreground`,children:v(I,{className:`h-3 w-3`})}),ue&&m!==null&&fo(v(`div`,{ref:p,id:`global-search-results`,className:`fixed z-50 w-max max-w-[26rem] rounded-lg border border-border bg-surface shadow-xl`,style:{left:m.left,top:m.top,minWidth:m.width},children:v(R_,{groups:te,activeKey:de,query:g,totalMatched:ne,truncated:re,pending:F,onSelect:le,onHover:e=>{let t=ie.findIndex(t=>t.key===e.key);t>=0&&C(t)}})}),document.body)]});return i?w?v(`div`,{ref:u,className:`fixed inset-x-2 top-[calc(env(safe-area-inset-top)+0.5rem)] z-50 mx-auto max-w-[26rem]`,children:pe}):null:n?v(`div`,{ref:u,className:`px-1.5 pb-1.5`,children:w?v(`div`,{className:`fixed z-50 w-max min-w-72 max-w-[26rem]`,style:{left:`calc(env(safe-area-inset-left) + 3.5rem)`,top:`calc(env(safe-area-inset-top) + 3.5rem)`},children:pe}):v(W,{variant:`unstyled`,type:`button`,onClick:()=>T(!0),"aria-label":fe,title:fe,className:`flex w-full items-center justify-center rounded-md px-0 py-2 text-foreground-subtle hover:bg-surface-hover hover:text-foreground transition-colors`,children:v(ft,{className:`h-3.5 w-3.5 shrink-0`})})}):v(`div`,{ref:u,className:`px-2 pb-2`,children:pe})}var B_=/^(\d{1,3}\.){3}\d{1,3}$/;function V_(e){let t=e.startsWith(`[`)&&e.endsWith(`]`)?e.slice(1,-1):e;return!!(B_.test(t)||t.includes(`:`))}function H_(e,t){return!t||V_(e)?!1:e===t||e.endsWith(`.${t}`)}T();var U_=`auth-webauthn/passkey-enrollment`,W_=`dominevo_passkey_prompt_dismissed:`,G_=720*60*60*1e3;function K_(e){try{let t=localStorage.getItem(`${W_}${e}`);if(!t)return!1;let n=Number(t);return Number.isFinite(n)?Date.now()-n<G_:!1}catch{return!1}}function q_(e){try{localStorage.setItem(`${W_}${e}`,String(Date.now()))}catch{}}function J_(){let{user:e}=os(),{t}=Z(),n=G(),r=io(U_),[i,a]=x(!1),[o,c]=x(!1),l=f(()=>e?K_(e.id):!0,[e]),u=gr.auth.listLoginMethods.useQuery().data?.find(e=>e.kind===`passkey`),d=u!==void 0&&H_(window.location.hostname,u.rpId),p=e!==null&&d&&r!=null&&!l,m=C({queryKey:[`auth`,`listOwnPasskeys`],queryFn:()=>n.listOwnPasskeys(),enabled:p,staleTime:6e4}),h=_(()=>{e&&q_(e.id),a(!0),c(!1)},[e]),g=_(()=>{c(!1),m.refetch()},[m]);return!p||i||m.data===void 0||m.data.length>0?null:s(`div`,{className:`shrink-0 border-b border-primary/20 bg-primary/5`,children:[s(`div`,{className:`flex items-center gap-2.5 px-3 py-2 text-xs text-foreground`,children:[v(_n,{className:`h-4 w-4 text-primary shrink-0`}),v(`span`,{className:`flex-1 min-w-0`,children:t(`passkeyPrompt.message`,`Save a passkey for faster sign-in?`)}),v(W,{variant:`unstyled`,onClick:()=>c(e=>!e),className:`rounded bg-primary px-2.5 py-1 text-[11px] font-semibold text-primary-foreground hover:bg-primary/90`,children:t(`passkeyPrompt.enrollNow`,`Enroll now`)}),v(W,{variant:`unstyled`,onClick:h,className:`inline-flex items-center gap-1 rounded border border-border px-2 py-1 text-[11px] text-foreground-subtle hover:text-foreground hover:bg-surface-hover`,children:t(`passkeyPrompt.notNow`,`Not now`)}),v(W,{variant:`unstyled`,onClick:h,"aria-label":t(`passkeyPrompt.notNow`,`Not now`),className:`p-1 rounded text-foreground-subtle hover:text-foreground`,children:v(I,{className:`h-3.5 w-3.5`})})]}),o&&v(`div`,{className:`px-3 pb-3`,children:s(`div`,{className:`max-w-xl`,children:[v(hi,{widgetId:U_,host:`dashboard`}),v(`div`,{className:`mt-2 flex justify-end`,children:v(W,{variant:`unstyled`,onClick:g,className:`rounded border border-border px-2.5 py-1 text-[11px] text-foreground-subtle hover:text-foreground hover:bg-surface-hover`,children:t(`common.close`,`Close`)})})]})})]})}var Y_=`system-config`,X_=[`system-config`,`bootstrap-form`];function Z_(e){return typeof e==`object`&&!!e&&`sections`in e&&Array.isArray(e.sections)}function Q_(){let e=G();return C({queryKey:X_,queryFn:async()=>{let t=await e.trpcClient.addons.custom.mutate({addonId:Y_,action:`getBootstrapForm`,input:{}});if(!Z_(t))throw Error(`The hub did not return the settings form`);return t}})}function $_(){let e=G(),t=O(),n=k({mutationFn:async t=>{await e.trpcClient.addons.custom.mutate({addonId:Y_,action:`saveBootstrapForm`,input:t})},onSuccess:()=>Promise.all([t.invalidateQueries({queryKey:X_}),t.invalidateQueries({queryKey:[[`system`,`info`]]})])});return{mutateAsync:n.mutateAsync,isPending:n.isPending}}var ev=6e4;function tv(){let e=$r(void 0,{staleTime:ev});return{info:e.data?.serverName??null,isLoading:e.isLoading}}T();var nv=`dominevo_server_name_prompt_dismissed`;function rv(){try{return sessionStorage.getItem(nv)===`1`}catch{return!1}}function iv(){try{sessionStorage.setItem(nv,`1`)}catch{}}function av(e){return e.isAdmin&&e.info!==null&&e.info.isDefault&&!e.dismissed}function ov(){let{user:e}=os(),{info:t}=tv(),[n,r]=x(rv);return av({isAdmin:e?.isAdmin===!0,info:t,dismissed:n})?v(sv,{suggestion:t?.name??``,onLater:()=>{iv(),r(!0)}}):null}function sv({suggestion:e,onLater:t}){let{t:n}=Z(),r=O(),i=$_(),[a,o]=x(e),[c,l]=x(null),u=d(null);y(()=>u.current?.focus(),[]);let f=_(async()=>{let e=cn.safeParse(a);if(!e.success){l(e.error.issues[0]?.message??n(`serverName.invalid`,`Not a valid name`));return}l(null);try{await i.mutateAsync({patch:{name:e.data}}),await r.invalidateQueries({queryKey:[[`system`,`info`]]})}catch(e){l(e instanceof Error&&e.message.length>0?e.message:`Could not save`)}},[r,i,n,a]);return v(Nn,{open:!0,onOpenChange:e=>!e&&t(),children:v(Na,{children:s(`form`,{onSubmit:e=>{e.preventDefault(),i.isPending||f()},children:[s($i,{children:[v(Ti,{children:n(`serverName.title`,`Name this server`)}),v(ha,{children:n(`serverName.description`,`Pick a name for this hub. It shows in the admin UI and on the apps’ sign-in screen. You can change it later in System settings.`)})]}),v(Li,{children:v(Ma,{label:n(`serverName.label`,`Server name`),...c===null?{}:{error:c},children:v(U,{ref:u,value:a,maxLength:48,onChange:e=>o(e.target.value),state:c===null?`default`:`error`,"aria-label":n(`serverName.label`,`Server name`)})})}),s(Ta,{children:[v(W,{type:`button`,variant:`ghost`,onClick:t,disabled:i.isPending,children:n(`serverName.later`,`Later`)}),s(W,{type:`submit`,disabled:i.isPending||a.trim().length===0,children:[i.isPending&&v(H,{className:`h-4 w-4 animate-spin`}),n(`common.save`,`Save`)]})]})]})})})}var cv=4,lv=160,uv=320,dv=`env(safe-area-inset-top)`,fv=`env(safe-area-inset-bottom)`;function pv(e){let{rect:t,viewportWidth:n,viewportHeight:r}=e,i=Math.min(uv,n-16),a={position:`fixed`,left:Math.max(8,Math.min(t.left,n-8-i)),width:i,zIndex:9999};if(r-t.bottom>=t.top){let e=`max(${t.bottom+cv}px, calc(${dv} + 8px))`;return{...a,top:e,maxHeight:`max(${lv}px, calc(100dvh - ${e} - ${fv} - 8px))`}}let o=`max(${r-t.top+cv}px, calc(${fv} + 8px))`;return{...a,bottom:o,maxHeight:`max(${lv}px, calc(100dvh - ${o} - ${dv} - 8px))`}}var mv=!1;function hv(){return mv}function gv(){mv=!0}function _v(e){return!e.read&&e.severity===`critical`}function vv(e){return e.filter(_v)}function yv(e){return e!==void 0&&typeof e.href==`string`&&e.href.length>0}function bv(e){return yv(e)||e!==void 0&&e.invoke!==void 0}var xv=/^\/addon\/[^/?#]+\/oauth\//;function Sv(e){return e.navigation===void 0?xv.test(e.href):e.navigation===`server`}function Cv(e){let t=e.action;if(bv(t)&&!(t.invoke!==void 0&&(e.status===`completed`||e.status===`dismissed`)))return t}T();function wv({action:e,className:t,onActivate:n}){let r=O(),i=G(),{t:a}=Z(),[o,c]=x(!1),[l,u]=x(null);if(e.invoke!==void 0){let{addonId:d,action:f,input:p}=e.invoke;return s(`span`,{className:`inline-flex flex-col items-start gap-0.5`,children:[v(`button`,{type:`button`,className:t,disabled:o,onClick:e=>{e.preventDefault(),n?.(e),c(!0),u(null),i.trpcClient.addons.custom.mutate({addonId:d,action:f,input:p}).then(()=>r.invalidateQueries({queryKey:[[`alerts`]]})).catch(e=>u(e instanceof Error?e.message:String(e))).finally(()=>c(!1))},children:o?a(`ui.alertAction.running`,`Working…`):e.label}),l!==null&&v(`span`,{role:`alert`,className:`text-[10px] text-destructive`,children:l})]})}return yv(e)?Sv(e)?v(`a`,{href:V(e.href),className:t,onClick:t=>{t.preventDefault(),n?.(t),Wo(e.href,()=>{r.invalidateQueries({queryKey:[[`alerts`]]}),r.invalidateQueries({queryKey:[[`broker`]]}),r.invalidateQueries({queryKey:[[`recordEntries`]]})})},children:e.label}):v(vo,{to:e.href,className:t,onClick:n,children:e.label}):v(j,{})}T(),uo();var Tv={info:ut,success:Ve,warning:He,error:Ue,critical:B},Ev={info:`text-info`,success:`text-success`,warning:`text-warning`,error:`text-danger`,critical:`text-danger`},Dv={active:`border-l-info`,"in-progress":`border-l-warning`,completed:`border-l-success`,failed:`border-l-danger`,dismissed:`border-l-foreground-subtle/30`};function Ov(e){let t=Math.floor((Date.now()-e)/1e3);if(t<60)return X.t(`helpers.relativeTime.justNow`);let n=Math.floor(t/60);if(n<60)return X.t(`helpers.relativeTime.minutesAgo`,{count:n});let r=Math.floor(n/60);if(r<24)return X.t(`helpers.relativeTime.hoursAgo`,{count:r});let i=Math.floor(r/24);return X.t(`helpers.relativeTime.daysAgo`,{count:i})}function kv(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Av(e){return typeof e==`string`&&e.length>0?e:void 0}function jv(e){if(kv(e.metadata)){let t=Av(e.metadata.nodeId)??Av(e.metadata.agentId);if(t!==void 0)return t}let t=e.source;if(t!==void 0&&!(t.type!==`node`&&t.type!==`agent`))return Av(t.id)}function Mv({alert:e,onMarkRead:t,onDismiss:n}){let{t:r}=Z(),i=e.severity in Tv?e.severity:`info`,a=Cv(e),o=e.status in Dv?e.status:`active`,c=Tv[i],l=Ev[i],u=Dv[o],{nodes:d}=ra(),f=jv(e),p=f===void 0?void 0:d.find(e=>e.id===f),m=f===void 0?void 0:p?.name??f;return s(`div`,{className:`flex items-start gap-2.5 px-3 py-2.5 border-l-2 ${u} ${e.read?`opacity-60`:``} hover:bg-surface-hover transition-colors`,children:[v(c,{className:`h-3.5 w-3.5 shrink-0 mt-0.5 ${l}`}),s(`div`,{className:`flex-1 min-w-0`,children:[s(`div`,{className:`flex items-center gap-1.5`,children:[v(`span`,{className:`text-[11px] font-semibold ${e.read?`text-foreground-subtle`:`text-foreground`}`,children:e.title}),!e.read&&v(`span`,{className:`h-1.5 w-1.5 rounded-full bg-primary shrink-0`})]}),m!==void 0&&v(`div`,{className:`text-foreground-subtle text-[10px] mt-0.5 truncate`,children:m}),v(`div`,{className:`text-[10px] text-foreground-subtle mt-0.5 line-clamp-2`,children:e.message}),a!==void 0&&v(wv,{action:a,className:`inline-flex mt-1.5 items-center rounded-md bg-primary px-2 py-0.5 text-[10px] font-medium text-primary-foreground hover:bg-primary/90 transition-colors`,onActivate:e=>e.stopPropagation()}),e.status===`in-progress`&&e.progress!==void 0&&s(`div`,{className:`mt-1.5 flex items-center gap-2`,children:[v(`div`,{className:`flex-1 h-1 bg-surface-hover rounded-full overflow-hidden`,children:v(`div`,{className:`h-full bg-primary rounded-full transition-all duration-300`,style:{width:`${String(Math.min(100,Math.max(0,e.progress)))}%`}})}),s(`span`,{className:`text-[9px] text-foreground-subtle font-mono shrink-0`,children:[String(Math.round(e.progress)),`%`]})]}),v(`div`,{className:`text-[9px] text-foreground-subtle/60 mt-1`,children:Ov(e.updatedAt)})]}),s(`div`,{className:`flex items-center gap-0.5 shrink-0`,children:[!e.read&&v(W,{variant:`unstyled`,type:`button`,onClick:n=>{n.stopPropagation(),t(e.id)},className:`p-1 rounded hover:bg-surface-hover transition-colors`,title:r(`ui.alertBell.markAsRead`,`Mark as read`),children:v(_e,{className:`h-3 w-3 text-foreground-subtle`})}),e.status!==`in-progress`&&v(W,{variant:`unstyled`,type:`button`,onClick:t=>{t.stopPropagation(),n(e.id)},className:`p-1 rounded hover:bg-surface-hover transition-colors`,title:r(`ui.alertBell.dismiss`,`Dismiss`),children:v(I,{className:`h-3 w-3 text-foreground-subtle`})})]})]})}function Nv({variant:e=`icon`,compact:t=!1}={}){let{t:n}=Z(),[r,i]=x(!1),[a,o]=x(!1),c=d(null),l=d(null),u=O(),{data:f=0}=Hr(void 0,{refetchInterval:3e4}),{data:p=[],isLoading:m}=Pn({limit:50},{enabled:r}),h=a?p:p.filter(e=>!e.read),g=p.filter(e=>e.read).length,b=()=>{u.invalidateQueries({queryKey:[[`alerts`]]})},S=Fa({onSuccess:b}),C=Bi({onSuccess:b}),w=_i({onSuccess:b});$n(`alert.created`,()=>{u.invalidateQueries({queryKey:[[`alerts`]]})}),$n(`alert.updated`,()=>{u.invalidateQueries({queryKey:[[`alerts`]]})}),y(()=>{if(!r)return;let e=e=>{let t=e.target;c.current&&!c.current.contains(t)&&l.current&&!l.current.contains(t)&&i(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`touchstart`,e),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`touchstart`,e)}},[r]);let T=_(e=>{S.mutate({alertId:e})},[S]),E=_(e=>{e&&w.mutate({alertId:e})},[w]),D=_(()=>{C.mutate(void 0),i(!1)},[C]),k=h.filter(_v),A=new Set(k.map(e=>e.id)),j=h.filter(e=>e.status===`in-progress`&&!A.has(e.id)),M=h.filter(e=>e.status!==`in-progress`&&!A.has(e.id)),[N,P]=x({}),F=_(()=>{let e=l.current;e&&P(pv({rect:e.getBoundingClientRect(),viewportWidth:window.innerWidth,viewportHeight:window.innerHeight}))},[]);return y(()=>{if(!r)return;F();let e=()=>F();return window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},[r,F]),s(`div`,{children:[e===`sidebar`?s(W,{variant:`unstyled`,ref:l,type:`button`,onClick:()=>i(!r),className:`flex w-full items-center gap-2.5 rounded-md ${t?`justify-center px-0 py-2`:`px-2.5 py-1.5`} text-[12px] text-foreground-subtle hover:bg-surface-hover hover:text-foreground transition-colors`,title:t?f>0?n(`ui.alertBell.alertsUnread`,{count:f}):n(`ui.alertBell.alerts`):void 0,children:[s(`span`,{className:`relative inline-flex shrink-0`,children:[v(vt,{className:`h-3.5 w-3.5`}),t&&f>0&&v(`span`,{className:`absolute -top-1 -right-1 h-2 w-2 rounded-full bg-primary`})]}),!t&&v(`span`,{className:`flex-1 text-left`,children:n(`ui.alertBell.alerts`,`Alerts`)}),!t&&f>0&&v(`span`,{className:`flex items-center justify-center h-4 min-w-4 px-1 rounded-full bg-primary text-primary-foreground text-[9px] font-bold leading-none`,children:f>99?`99+`:String(f)})]}):s(W,{variant:`unstyled`,ref:l,type:`button`,onClick:()=>i(!r),className:`relative p-1.5 rounded-md hover:bg-surface-hover text-foreground-subtle hover:text-foreground transition-colors`,"aria-label":n(`ui.alertBell.alerts`,`Alerts`),children:[v(vt,{className:`h-4.5 w-4.5`}),f>0&&v(`span`,{className:`absolute -top-0.5 -right-0.5 flex items-center justify-center h-4 min-w-4 px-0.5 rounded-full bg-primary text-primary-foreground text-[9px] font-bold leading-none`,children:f>99?`99+`:String(f)})]}),r&&fo(s(`div`,{ref:c,style:N,className:`bg-surface border border-border rounded-lg shadow-xl flex flex-col overflow-hidden`,children:[s(`div`,{className:`flex items-center justify-between px-3 py-2 border-b border-border shrink-0`,children:[v(`span`,{className:`text-[12px] font-semibold text-foreground`,children:n(`ui.alertBell.alerts`,`Alerts`)}),s(`div`,{className:`flex items-center gap-2`,children:[g>0&&s(`label`,{className:`flex items-center gap-1 text-[10px] text-foreground-subtle cursor-pointer select-none`,children:[v(Dt,{checked:a,onChange:e=>o(e.target.checked),className:`h-3 w-3 rounded border-border accent-primary cursor-pointer`}),n(`ui.alertBell.showRead`,`Show read`)]}),f>0&&s(W,{variant:`unstyled`,type:`button`,onClick:D,className:`flex items-center gap-1 text-[10px] text-primary hover:text-primary/80 transition-colors`,children:[v(Cn,{className:`h-3 w-3`}),n(`ui.alertBell.markAllRead`,`Mark all read`)]})]})]}),s(`div`,{className:`flex-1 overflow-y-auto`,children:[m&&v(`div`,{className:`flex items-center justify-center py-8`,children:v(H,{className:`h-4 w-4 animate-spin text-foreground-subtle`})}),!m&&h.length===0&&s(`div`,{className:`flex flex-col items-center justify-center py-8 text-foreground-subtle`,children:[v(vt,{className:`h-6 w-6 mb-2 opacity-40`}),v(`span`,{className:`text-[11px]`,children:p.length>0?n(`ui.alertBell.noUnreadAlerts`,`No unread alerts`):n(`ui.alertBell.noAlerts`,`No alerts`)}),p.length>0&&!a&&v(W,{variant:`unstyled`,type:`button`,onClick:()=>o(!0),className:`text-[10px] text-primary mt-1 hover:underline`,children:n(`ui.alertBell.showRead`,{count:g})})]}),k.length>0&&s(`div`,{className:`border-b border-border`,children:[v(`div`,{className:`px-3 py-1.5 bg-danger/5`,children:v(`span`,{className:`text-[9px] font-semibold uppercase tracking-widest text-danger`,children:n(`ui.alertBell.urgent`,`Urgent`)})}),k.map(e=>v(Mv,{alert:e,onMarkRead:T,onDismiss:E},e.id))]}),j.length>0&&s(`div`,{className:`border-b border-border`,children:[v(`div`,{className:`px-3 py-1.5 bg-surface-hover/50`,children:v(`span`,{className:`text-[9px] font-semibold uppercase tracking-widest text-foreground-subtle/60`,children:n(`ui.alertBell.inProgress`,`In Progress`)})}),j.map(e=>v(Mv,{alert:e,onMarkRead:T,onDismiss:E},e.id))]}),M.map(e=>v(Mv,{alert:e,onMarkRead:T,onDismiss:E},e.id))]})]}),document.body)]})}var Pv={queued:`neutral`,running:`info`,done:`success`,failed:`danger`,cancelled:`warning`};function Fv(e){return Pv[e]}function Iv(e){return`activity.state.${e}`}function Lv(e){return e.state===`queued`||e.state===`running`}function Rv(e){let t=e.progress;if(t===null)return e.state===`running`?{kind:`indeterminate`,done:null,unit:null}:{kind:`none`};if(t.total===null||t.total<=0)return{kind:`indeterminate`,done:t.done,unit:t.unit};let n=Math.min(100,Math.max(0,t.done/t.total*100));return{kind:`determinate`,done:t.done,total:t.total,unit:t.unit,percent:n}}function zv(e,t=e=>e){return e.kind===`none`?null:e.kind===`indeterminate`?e.done===null?null:`${String(e.done)} ${t(e.unit??``,e.done)}`.trim():`${String(e.done)} / ${String(e.total)} ${t(e.unit,e.total)}`.trim()}function Bv(e){return`activity.kind.${e.kind.replaceAll(`.`,`_`)}`}var Vv={"not-found":`activity.cancelRefused.notFound`,"not-cancellable":`activity.cancelRefused.notCancellable`,terminal:`activity.cancelRefused.terminal`,"not-allowed":`activity.cancelRefused.notAllowed`,"producer-refused":`activity.cancelRefused.producerRefused`,"producer-unreachable":`activity.cancelRefused.producerUnreachable`};function Hv(e){return e===null?`activity.cancelRefused.unknown`:Vv[e]}function Uv(e){return e.cancellable&&Lv(e)}function Wv(e){return!Lv(e)}function Gv(e){return e.ownerUserId===`system`}function Kv(e){return e==null?0:e.running+(e.unseenFinished??0)}function qv(e){return[...e].sort((e,t)=>{let n=Number(Lv(t))-Number(Lv(e));return n===0?t.createdAt-e.createdAt:n})}T();function Jv({id:e,title:t,icon:n,description:r,actions:i,tone:a=`default`,notice:o=null,onDismissNotice:c,children:l}){return v(or,{headingId:`access-${e}`,title:t,icon:n,actions:i,testId:`access-${e}`,children:s(`div`,{className:`${ne} space-y-3`,children:[v(`div`,{className:ee(`text-[11px] leading-relaxed`,a===`danger`?`rounded-md border border-danger/30 bg-danger/5 px-3 py-2 text-foreground`:`text-foreground-subtle`),children:r}),o!==null&&v(Xv,{notice:o,onDismiss:c}),l]})})}var Yv={success:{icon:Ve,line:`border-success/30 text-foreground`,mark:`text-success`},danger:{icon:B,line:`border-danger/40 text-danger`,mark:`text-danger`}};function Xv({notice:e,onDismiss:t}){let{t:n}=Z(),r=Yv[e.tone],i=r.icon;return s(`div`,{role:e.tone===`danger`?`alert`:`status`,className:ee(`flex items-start gap-2 rounded-md border bg-surface px-3 py-2 text-[11px]`,r.line),children:[v(i,{className:ee(`mt-0.5 h-3.5 w-3.5 shrink-0`,r.mark),"aria-hidden":!0}),v(`span`,{className:`min-w-0 flex-1`,children:e.message}),t!==void 0&&v(pa,{type:`button`,variant:`ghost`,size:`sm`,icon:I,"aria-label":n(`access.accessSection.dismiss`,`Dismiss`),onClick:t,className:`-my-1 h-5 w-5`})]})}function Zv(){let{data:e}=Sr();return f(()=>{let t=new Map;for(let n of e??[])t.set(n.id,n.username);return t},[e])}function Qv(e,t=null){return e===null?t:{tone:`danger`,message:e}}T();function $v(e){let{t}=Z();return t(Bv(e),{defaultValue:e.kind})}function ey(e){let{t}=Z(),n=$v(e);return X.exists(e.titleKey)?t(e.titleKey,e.titleParams):n}function ty({state:e}){let{t}=Z();return v(jn,{variant:Fv(e),className:`text-[10px]`,children:t(Iv(e))})}function ny({job:e}){let t=Rv(e),{t:n}=Z(),r=zv(t,(e,t)=>n(`activity.unit.${e}`,{count:t,defaultValue:e}));return t.kind===`none`?null:s(`div`,{className:`flex items-center gap-2`,children:[v(`div`,{className:`h-1 flex-1 overflow-hidden rounded-full bg-border`,children:t.kind===`determinate`?v(`div`,{className:`h-full rounded-full bg-primary transition-all`,style:{width:`${String(t.percent)}%`},role:`progressbar`,"aria-valuenow":Math.round(t.percent),"aria-valuemin":0,"aria-valuemax":100}):v(`div`,{className:`h-full w-full animate-pulse rounded-full bg-primary/40`,role:`progressbar`})}),r!==null&&v(`span`,{className:`shrink-0 font-mono text-[10px] text-foreground-subtle`,children:r})]})}function ry({job:e}){let{t}=Z(),n=Zv();return Gv(e)?v(j,{children:t(`activity.ownerSystem`)}):v(j,{children:n.get(e.ownerUserId)??e.ownerUserId})}function iy(){let e=O();return()=>{e.invalidateQueries({queryKey:[[`jobs`]]})}}function ay({job:e}){let{t}=Z(),n=pt(),r=iy(),i=Hi({onSuccess:e=>{r(),!e.accepted&&n({title:t(`activity.cancelRefused.title`),message:t(Hv(e.reason))})}}),a=Ia({onSuccess:r}),o=G(),c=_o(),[l,u]=x(!1);return s(`div`,{className:`flex items-center justify-end gap-1.5`,children:[e.state===`done`&&s(W,{variant:`primary`,size:`xs`,disabled:l,onClick:()=>{u(!0),o.trpcClient.jobs.collect.query({jobId:e.jobId}).then(e=>{if(e===null){n({title:t(`activity.openResult`),message:t(`activity.noResult`)});return}e.navigation===`server`?Wo(e.href):c(e.href)}).catch(e=>n({title:t(`activity.openResult`),message:e instanceof Error?e.message:String(e)})).finally(()=>u(!1))},children:[l&&v(H,{className:`h-3 w-3 animate-spin`,"aria-hidden":!0}),t(`activity.openResult`)]}),Uv(e)&&s(W,{variant:`outline`,size:`xs`,disabled:i.isPending,onClick:()=>i.mutate({jobId:e.jobId}),children:[i.isPending&&v(H,{className:`h-3 w-3 animate-spin`,"aria-hidden":!0}),t(`activity.cancel`)]}),Wv(e)&&v(W,{variant:`ghost`,size:`xs`,disabled:a.isPending,onClick:()=>a.mutate({jobId:e.jobId}),"aria-label":t(`activity.dismiss`),title:t(`activity.dismiss`),children:v(I,{className:`h-3 w-3`,"aria-hidden":!0})})]})}T();var oy=15e3,sy=4e3,cy=30;function ly({job:e,showOwner:t}){let{t:n}=Z(),r=ey(e),i=$v(e),a=e.finishedAt??e.createdAt;return s(`li`,{className:`space-y-1.5 border-b border-border px-3 py-2.5 last:border-b-0`,children:[s(`div`,{className:`flex items-start gap-2`,children:[s(`div`,{className:`min-w-0 flex-1`,children:[v(`div`,{className:`truncate text-[12px] font-semibold text-foreground`,title:r,children:r}),s(`div`,{className:`truncate text-[10px] text-foreground-subtle`,children:[i!==r&&i,t&&s(j,{children:[i!==r&&` · `,v(ry,{job:e})]})]})]}),v(ty,{state:e.state})]}),v(ny,{job:e}),e.failure!==null&&v(`div`,{className:`line-clamp-2 text-[10px] text-danger`,children:e.failure.message}),s(`div`,{className:`flex items-center justify-between gap-2`,children:[v(`span`,{className:`text-[10px] text-foreground-subtle`,children:e.finishedAt===null?n(`activity.startedAgo`,{when:Ov(a)}):n(`activity.finishedAgo`,{when:Ov(a)})}),v(ay,{job:e})]})]})}function uy({isAdmin:e}){let{t}=Z(),n=ka({includeDismissed:!1,limit:cy},{refetchInterval:sy}),r=f(()=>qv(n.data??[]),[n.data]);return s(`div`,{className:`flex w-[min(24rem,calc(100vw-1rem))] max-w-full flex-col`,children:[s(`div`,{className:`flex shrink-0 items-center justify-between border-b border-border px-3 py-2`,children:[v(`span`,{className:`text-[12px] font-semibold text-foreground`,children:t(`activity.title`)}),e&&v(vo,{to:`/system/jobs`,className:`text-[10px] text-primary hover:underline`,children:t(`activity.viewAll`)})]}),s(`div`,{className:`max-h-[60vh] overflow-y-auto`,children:[n.isLoading&&s(`div`,{className:`space-y-2 p-3`,children:[v(zi,{className:`h-10 w-full`}),v(zi,{className:`h-10 w-full`})]}),n.isError&&v(`div`,{className:`p-3`,children:v(pi,{title:t(`activity.loadFailed`),message:n.error.message})}),n.data!==void 0&&r.length===0&&v(zr,{icon:We,title:t(`activity.empty`)}),r.length>0&&v(`ul`,{children:r.map(t=>v(ly,{job:t,showOwner:e},t.jobId))})]})]})}function dy({variant:e=`icon`,compact:t=!1}={}){let{t:n}=Z(),{user:r}=os(),i=r?.isAdmin===!0,[a,o]=x(!1),c=Kv(va({},{refetchInterval:oy}).data),l=c>0?n(`activity.buttonCount`,{count:c}):n(`activity.title`),u=c>99?`99+`:String(c);return s(qi,{open:a,onOpenChange:o,className:`block`,children:[e===`sidebar`?s(Va,{className:`flex w-full items-center gap-2.5 rounded-md ${t?`justify-center px-0 py-2`:`px-2.5 py-1.5`} text-[12px] text-foreground-subtle transition-colors hover:bg-surface-hover hover:text-foreground`,title:t?l:void 0,"aria-label":l,children:[s(`span`,{className:`relative inline-flex shrink-0`,children:[v(We,{className:`h-3.5 w-3.5`}),t&&c>0&&v(`span`,{className:`absolute -right-1 -top-1 h-2 w-2 rounded-full bg-primary`})]}),!t&&v(`span`,{className:`flex-1 text-left`,children:n(`activity.title`)}),!t&&c>0&&v(`span`,{className:`flex h-4 min-w-4 items-center justify-center rounded-full bg-primary px-1 text-[9px] font-bold leading-none text-primary-foreground`,children:u})]}):s(Va,{className:`relative rounded-md p-1.5 text-foreground-subtle transition-colors hover:bg-surface-hover hover:text-foreground`,"aria-label":l,children:[v(We,{className:`h-4.5 w-4.5`}),c>0&&v(`span`,{className:`absolute -right-0.5 -top-0.5 flex h-4 min-w-4 items-center justify-center rounded-full bg-primary px-0.5 text-[9px] font-bold leading-none text-primary-foreground`,children:u})]}),v(Si,{align:e===`sidebar`?`start`:`end`,className:`p-0`,children:a&&v(uy,{isAdmin:i})})]})}T(),uo();function fy({alert:e,onMarkRead:t}){let{t:n}=Z(),r=Cv(e);return s(`div`,{className:`border-b border-border last:border-b-0 px-3 py-2.5`,children:[v(`div`,{className:`text-[12px] font-semibold text-foreground`,children:e.title}),v(`div`,{className:`text-[11px] text-foreground-muted mt-0.5`,children:e.message}),s(`div`,{className:`mt-2 flex flex-wrap items-center gap-2`,children:[r!==void 0&&v(wv,{action:r,className:`inline-flex items-center justify-center rounded-md bg-primary px-2.5 py-1 text-[11px] font-medium text-primary-foreground hover:bg-primary/90 transition-colors`}),v(W,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>t(e.id),children:n(`ui.alertBell.markAsRead`,`Mark as read`)})]})]})}function py(){let{t:e}=Z(),t=O(),[n,r]=x(hv()),{data:i=[],isLoading:a}=Pn({limit:50}),o=f(()=>vv(i),[i]),c=Fa({onSuccess:_(()=>{t.invalidateQueries({queryKey:[[`alerts`]]})},[t])}),l=_(e=>{c.mutate({alertId:e})},[c]),u=_(()=>{gv(),r(!0)},[]);return a||n||o.length===0?null:fo(v(`div`,{className:`fixed inset-x-0 bottom-0 z-[10000] flex justify-center p-2 sm:p-4 pb-[max(0.5rem,env(safe-area-inset-bottom))] pointer-events-none`,"data-testid":`critical-alerts-on-load-panel`,children:s(`div`,{className:`pointer-events-auto w-full max-w-lg bg-surface border border-danger/30 rounded-lg shadow-xl flex flex-col max-h-[min(70dvh,32rem)] overflow-hidden`,role:`region`,"aria-labelledby":`critical-alerts-panel-title`,children:[s(`div`,{className:`flex items-start justify-between gap-2 px-3 py-2.5 border-b border-border shrink-0 bg-danger/5`,children:[s(`div`,{children:[v(`h2`,{id:`critical-alerts-panel-title`,className:`text-[12px] font-semibold text-foreground`,children:e(`ui.criticalAlertsPanel.title`,`Urgent alerts`)}),v(`p`,{className:`text-[10px] text-foreground-muted mt-0.5`,children:e(`ui.criticalAlertsPanel.subtitle`,`These need your attention.`)})]}),v(pa,{type:`button`,variant:`ghost`,onClick:u,"aria-label":e(`ui.criticalAlertsPanel.close`,`Close`),"data-testid":`critical-alerts-panel-close`,icon:I})]}),v(`div`,{className:`flex-1 overflow-y-auto`,children:o.map(e=>v(fy,{alert:e,onMarkRead:l},e.id))})]})}),document.body)}T();function my(){let e=Jo();return b(e.subscribe,e.getSnapshot,e.getSnapshot)}var hy=[`detection`,`cluster`,`administration`];function gy(e){return hy.includes(e)}function _y(e){let t=new Map,n=new Map,r=[];for(let i of e){let e=i.section?.trim();if(e===void 0||e.length===0){r.push(i);continue}if(gy(e)){let n=t.get(e)??[];n.push(i),t.set(e,n);continue}let a=n.get(e);a?a.pages.push(i):n.set(e,{label:i.sectionLabel?.trim()||e,pages:[i]})}return{known:t,custom:[...n.entries()].map(([e,t])=>({id:e,label:t.label,pages:t.pages})),ungrouped:r}}var vy=`dominevo:last-path`,yy=512,by=[`/login`,`/change-password`,`/access-denied`,`/logout`];function xy(e){return!e.startsWith(`/`)||e.startsWith(`//`)||e.length>yy?!1:!by.some(t=>e===t||e.startsWith(t+`/`))}function Sy(e){if(!(typeof window>`u`)&&xy(e))try{window.localStorage.setItem(vy,e)}catch{}}function Cy(){if(typeof window>`u`)return null;try{let e=window.localStorage.getItem(vy);return e===null?null:xy(e)?e:null}catch{return null}}var wy=`/devices`;function Ty(e){return e!==void 0&&xy(e)?e:Cy()??wy}function Ey(e){return e.split(`.`)[0]===`0`?`${e} beta`:e}function Dy(e){if(e===null)return null;let t=e.trim();return t.length>0?t:null}function Oy(e){let t=Dy(e.productVersion),n=Dy(e.serverVersion),r=Dy(e.fallbackVersion);return t!==null&&n!==null?{kind:`both`,productLabel:Ey(t),serverVersion:n}:t===null?n===null?r===null?{kind:`none`}:{kind:`fallback`,version:r}:{kind:`server`,serverVersion:n}:{kind:`product`,productLabel:Ey(t)}}function ky(e,t){if(!Object.hasOwn(e,t))return null;let n=Reflect.get(e,t);return typeof n==`string`?n:null}function Ay(e){return typeof e!=`object`||!e?null:{productVersion:ky(e,`productVersion`),serverVersion:ky(e,`serverVersion`)}}T();function jy(e,t){return e.kind===`both`?t(`releaseIdentity.both`,`{{product}} · server {{server}}`,{product:e.productLabel,server:e.serverVersion}):e.kind===`product`?e.productLabel:e.kind===`server`?t(`releaseIdentity.serverOnly`,`server {{version}}`,{version:e.serverVersion}):e.kind===`fallback`?t(`releaseIdentity.fallback`,`v{{version}}`,{version:e.version}):null}function My({placement:e,compact:t=!1}){let{t:n}=Z(),[r,i]=x({kind:`fallback`,version:`0.1.2`});y(()=>{let e=new AbortController;return fetch(V(`/api/release-identity`),{signal:e.signal}).then(async e=>e.ok?Ay(await e.json()):null).then(t=>{e.signal.aborted||t===null||i(Oy({productVersion:t.productVersion,serverVersion:t.serverVersion,fallbackVersion:`0.1.2`}))}).catch(t=>{e.signal.aborted||t instanceof DOMException&&t.name}),()=>e.abort()},[]);let a=jy(r,n);return a===null?null:e===`login`?v(`span`,{"data-testid":`release-identity`,children:a}):v(`div`,{"data-testid":`release-identity`,className:`pt-1 text-[10px] text-foreground-disabled select-none truncate ${t?`text-center`:`px-2`}`,title:a,children:a})}function Ny(e){return typeof e==`object`&&!!e&&typeof Reflect.get(e,`postMessage`)==`function`}function Py(e){let t=Reflect.get(e,`ReactNativeWebView`);return Ny(t)?t:null}function Fy(e=window){return{parent:e.parent===e?null:e.parent,origin:e.location.origin,native:Py(e)!==null}}function Iy(e){if(typeof e!=`string`)return e;try{return JSON.parse(e)}catch{return null}}function Ly(e){return e.startsWith(`/`)&&!e.startsWith(`//`)&&!e.startsWith(`/\\`)}function Ry(e,t){let n=t.parent!==null&&e.source===t.parent&&e.origin===t.origin,r=t.native&&e.source===null&&e.origin===``;if(!n&&!r)return null;let i=en.safeParse(Iy(e.data));return!i.success||i.data.type===`navigate`&&!Ly(i.data.path)?null:i.data}function zy(e=window){let t=Py(e);if(t!==null)return e=>t.postMessage(JSON.stringify(e));if(e.parent===e)return null;let n=e.parent,r=e.location.origin;return e=>n.postMessage(e,r)}function By(e){return`${e.pathname}${e.search}`}T();function Vy(){let e=_o(),t=By(mo()),n=d(t);n.current=t;let[r,i]=x(!1),[a,o]=x(null),s=ji()?.setMode,c=d(0),l=f(()=>zy(),[]);return y(()=>{let t=Fy(),r=n=>{let r=Ry(n,t);r!==null&&(r.type===`hello`?i(!0):r.type===`navigate`?e(r.path):r.type===`search`?(c.current+=1,o({id:c.current,query:r.query})):r.type===`theme`&&s?.(r.mode))};return window.addEventListener(`message`,r),l?.({dominevo:`app-bridge`,v:1,type:`ready`,path:n.current}),()=>window.removeEventListener(`message`,r)},[e,l,s]),y(()=>{l?.({dominevo:`app-bridge`,v:1,type:`path`,path:t,title:document.title})},[l,t]),{chromeless:r,search:a}}function Hy(e=bt()){return e===``?{kind:`frame`,src:V(`/viewer/dominevo/`)}:{kind:`unavailable-under-mount`,mount:e}}function Uy(e=window){if(Reflect.get(e,`__DOMINEVO_VIEWER_EMBED__`)===!0)return!0;try{return e.self!==e.top}catch{return!0}}T();var Wy=D(!0);function Gy(e){return e===`/addon`||e.startsWith(`/addon/`)}function Ky(e,t,n){let r=[...e.filter(e=>e!==t),t];return r.length<=n?r:r.slice(r.length-n)}function qy({maxCached:e=6}){let t=ho(),n=mo(),r=Co(),i=M(yo),a=n.pathname,o=Gy(a),c=d(new Map),l=d([]);if(o){c.current.set(a,{key:a,outlet:t,location:n,navigationType:r,routeContext:i});let o=Ky(l.current,a,e),s=new Set(o);for(let e of c.current.keys())s.has(e)||c.current.delete(e);l.current=o}return s(j,{children:[l.current.map(e=>{let t=c.current.get(e);if(t?.outlet==null)return null;let n=o&&e===a;return v(`div`,{className:n?`h-full min-h-0`:void 0,style:n?void 0:{display:`none`},hidden:!n,"aria-hidden":!n,children:v(Wy.Provider,{value:n,children:v(bo.Provider,{value:{location:t.location,navigationType:t.navigationType},children:v(yo.Provider,{value:t.routeContext,children:t.outlet})})})},e)}),!o&&t!=null?v(`div`,{className:`h-full min-h-0`,children:t},a):null]})}T();var Jy={dark:ke,light:at,system:Me};function Yy(){return v(`div`,{className:`flex h-full min-h-[50vh] items-center justify-center`,children:v(`span`,{className:`h-4 w-4 animate-spin rounded-full border-2 border-primary/30 border-t-primary`})})}function Xy(){let e=mo(),t=_o(),{user:n,logout:r}=os(),i=ji(),{t:a}=Z(),o=Ai(),c=Is(),l=eo(),{info:u}=tv();y(()=>{document.title=u===null?`Dominevo Admin`:`${u.name} \u00b7 Dominevo Admin`},[u]);let p=Yo(my()),[m,h]=x(!1);y(()=>{Sy(e.pathname+e.search)},[e.pathname,e.search]);let[_,b]=x(()=>typeof window>`u`?!1:window.localStorage.getItem(`dominevo:sidebar-collapsed`)===`1`);y(()=>{typeof window>`u`||window.localStorage.setItem(`dominevo:sidebar-collapsed`,_?`1`:`0`)},[_]);let[S]=x(()=>{if(typeof window>`u`)return new Set;try{let e=window.localStorage.getItem(`dominevo:sidebar-collapsed-groups`);if(!e)return new Set;let t=JSON.parse(e);return Array.isArray(t)?new Set(t.filter(e=>typeof e==`string`)):new Set}catch{return new Set}});y(()=>{typeof window>`u`||window.localStorage.setItem(`dominevo:sidebar-collapsed-groups`,JSON.stringify([...S]))},[S]),y(()=>{l&&window.localStorage.getItem(`dominevo:sidebar-collapsed`)===null&&b(!0)},[l]);let{data:C=[]}=co({nodeId:`hub`},{refetchInterval:3e4}),w=C.length,T=O(),E=d(Date.now()),{data:D}=Za(void 0,{staleTime:0,refetchOnMount:`always`,refetchInterval:e=>{let t=e.state.data;return t&&t.length>0||Date.now()-E.current>=3e4?!1:2e3}}),k=f(()=>D&&n?.isAdmin?Hg(D):[],[D,n?.isAdmin]),A=f(()=>_y(k),[k]),M=A.known.get(`detection`)??[],P=A.known.get(`cluster`)??[],F=A.known.get(`administration`)??[];$n(`addon.page-ready`,()=>{T.invalidateQueries({queryKey:[[`addonPages`,`listPages`]]})});let ee=()=>{r(),t(`/login`)},te=t=>!!(e.pathname===t||e.pathname.startsWith(t+`/`)),ne=[`/system/pipeline`,`/live`,`/addon/osd-manager`,`/build`].some(t=>e.pathname===t||e.pathname.startsWith(t+`/`)),ie=n?.isAdmin===!0,ae=f(()=>Uy(),[]),{chromeless:se,search:ce}=Vy(),I=f(()=>i_({t:a,isAdmin:ie,embeddedByViewer:ae}),[a,ie,ae]),le=I[0]?.items??[],ue=I[1]?.items??[],de=I[2]?.items??[],fe=I[3]?.items??[],pe=i?.mode??`system`,L={dark:a(`theme.dark`),light:a(`theme.light`),system:a(`theme.system`)},R=_&&!o,z=(e,t=`md`,n=!1)=>`flex w-full items-center gap-2.5 rounded-md ${R?`justify-center px-0 py-2`:`px-2.5 py-1.5`} ${t===`lg`?`text-[13px] font-medium`:`text-[12px]`} transition-all ${e?t===`lg`?`bg-primary/12 text-primary shadow-sm shadow-primary/5`:`bg-primary/12 text-primary`:n?`text-foreground-disabled hover:bg-surface-hover`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,me=(e,t)=>e===0?null:R?v(`div`,{className:`pt-3 mb-1 mx-2 border-t border-border/60`},`sep-${t}`):v(`div`,{className:`pt-4 pb-1.5 px-2.5`,children:v(`span`,{className:`text-[10px] font-semibold uppercase tracking-widest text-foreground-subtle/60`,children:t})},`hdr-${t}`),B=e=>{let n=te(e.path),r=o_(e.icon);return s(W,{variant:`unstyled`,onClick:()=>{t(e.path),h(!1)},className:z(n),title:R?e.label:void 0,children:[v(r,{className:`h-3.5 w-3.5 shrink-0 ${n?`text-primary`:``}`}),!R&&e.label]},`${e.addonId}::${e.id}`)},he=e=>e.requiresCapability===void 0?ge(e,!1):v(d_,{capability:e.requiresCapability,children:t=>ge(e,t)},e.path),ge=(e,n)=>{let r=e.icon,i=te(e.path),o=e.path===`/system/addons`;return s(W,{variant:`unstyled`,"data-testid":`nav-${e.path.replace(/^\//,``).replace(/\//g,`-`)}`,onClick:()=>{t(e.path),h(!1)},className:z(i,`md`,n),"aria-disabled":n||void 0,title:n?a(`nav.notInstalled`,`{{page}} — not installed`,{page:e.label}):R?e.label:void 0,children:[v(r,{className:`h-3.5 w-3.5 shrink-0 ${i?`text-primary`:``}`}),!R&&s(j,{children:[v(`span`,{className:`flex-1 text-left`,children:e.label}),o&&w>0&&v(`span`,{className:`ml-auto rounded-full bg-primary px-1.5 py-0.5 text-[9px] font-bold text-primary-foreground leading-none`,children:w})]}),R&&o&&w>0&&v(`span`,{className:`absolute mt-[-14px] ml-3 h-2 w-2 rounded-full bg-primary`})]},e.path)},_e=s(j,{children:[s(`div`,{className:`flex h-14 items-center border-b border-border ${R?`justify-center px-1`:`pl-3 pr-4 gap-2`}`,children:[!R&&v(`img`,{src:i?.resolvedMode===`light`?V(`/brand/logo-horizontal-light.svg`):V(`/brand/logo-horizontal-dark.svg`),alt:a(`layouts.appLayout.dominevoAdmin`,`Dominevo Admin`),className:`h-9 flex-1 min-w-0`}),!o&&v(W,{variant:`unstyled`,onClick:()=>b(e=>!e),className:`p-1.5 rounded-md hover:bg-surface-hover text-foreground-subtle transition-colors flex-shrink-0 ${R?``:`mr-2`}`,"aria-label":_?a(`layouts.appLayout.expandSidebar`,`Expand sidebar`):a(`layouts.appLayout.collapseSidebar`,`Collapse sidebar`),title:_?a(`layouts.appLayout.expandSidebar`,`Expand sidebar`):a(`layouts.appLayout.collapseSidebar`,`Collapse sidebar`),children:v(_?oe:re,{className:`h-4 w-4`})})]}),!R&&u!==null&&v(`div`,{"data-testid":`sidebar-server-name`,title:u.name,className:`truncate border-b border-border px-3 py-1.5 text-xs font-medium text-foreground-muted`,children:u.name}),v(`div`,{className:`border-b border-border pt-2`,children:v(z_,{navSections:I,addonPages:k,compact:R,onNavigated:()=>h(!1)})}),s(`nav`,{className:`flex-1 overflow-y-auto py-3 ${R?`px-1.5`:`px-2`} space-y-0.5`,children:[le.map(e=>he(e)),me(ue.length+M.length,a(`nav.detectionSection`,`Detection`)),ue.map(e=>he(e)),M.map(e=>B(e)),me(de.length+P.length,a(`nav.clusterSection`,`Cluster`)),de.map(e=>he(e)),P.map(e=>B(e)),me(fe.length+F.length,a(`system.title`,`Administration`)),fe.map(e=>he(e)),F.map(e=>B(e)),A.custom.map(e=>s(`div`,{className:`contents`,children:[me(e.pages.length,e.label),e.pages.map(e=>B(e))]},`custom-${e.id}`)),me(A.ungrouped.length,a(`nav.addonPages`,`Addon Pages`)),A.ungrouped.map(e=>B(e))]}),s(`div`,{className:`border-t border-border ${R?`p-1.5`:`p-2`} space-y-0.5`,children:[s(W,{variant:`unstyled`,onClick:()=>i?.toggleMode(),className:z(!1),title:R?L[pe]:void 0,children:[(()=>{let e=Jy[pe];return v(e,{className:`h-3.5 w-3.5 shrink-0`})})(),!R&&v(`span`,{children:L[pe]})]}),v(dy,{variant:`sidebar`,compact:R}),v(Nv,{variant:`sidebar`,compact:R}),s(W,{variant:`unstyled`,type:`button`,onClick:()=>t(`/system/my-access`),className:z(te(`/system/my-access`)),title:R?a(`system.myAccess`,`My access`):void 0,children:[v(N,{className:`h-3.5 w-3.5 shrink-0`}),!R&&v(`span`,{className:`truncate`,children:a(`system.myAccess`,`My access`)})]}),s(W,{variant:`unstyled`,type:`button`,onClick:()=>c.setOn(!c.on),className:z(c.on),"aria-pressed":c.on,title:R?a(`layouts.appLayout.debugLayers`,`Debug layers`):void 0,children:[v(Ot,{className:`h-3.5 w-3.5 shrink-0`}),!R&&v(`span`,{className:`truncate`,children:c.on?a(`layouts.appLayout.debugLayersOn`,`Debug layers: on`):a(`layouts.appLayout.debugLayers`,`Debug layers`)})]}),s(W,{variant:`unstyled`,onClick:ee,className:z(!1).replace(`hover:text-foreground`,`hover:text-danger`),title:R?n?.username??a(`layouts.appLayout.logout`,`Logout`):void 0,children:[v(xn,{className:`h-3.5 w-3.5 shrink-0`}),!R&&v(`span`,{className:`truncate`,children:n?.username??a(`layouts.appLayout.user`,`User`)})]}),v(My,{placement:`sidebar`,compact:R})]})]});return s(`div`,{className:`flex h-dvh flex-col overflow-hidden bg-background text-foreground pb-[env(safe-area-inset-bottom)]`,children:[v(`div`,{"aria-hidden":`true`,className:`h-[env(safe-area-inset-top)] shrink-0 bg-surface`}),s(`div`,{className:`flex min-h-0 flex-1`,children:[!se&&!o&&v(`aside`,{className:`flex flex-col border-r border-border bg-surface shrink-0 transition-[width] duration-150 ease-out ${R?`w-12`:`w-48`}`,children:_e}),!se&&o&&v(fa,{open:m,onClose:()=>h(!1),width:`w-64`,children:_e}),s(`div`,{className:`flex flex-1 flex-col min-w-0`,children:[p!==null&&v(`div`,{role:`status`,className:`pointer-events-none fixed inset-x-0 top-[env(safe-area-inset-top)] z-50 flex justify-center`,children:s(`div`,{className:`pointer-events-auto flex items-center justify-center gap-2 rounded-b-md px-3 py-2 text-[12px] font-medium shadow-lg ${p.severity===`danger`?`bg-danger text-white`:`bg-surface text-warning border border-t-0 border-warning/30`}`,children:[p.severity===`danger`?v(Be,{className:`h-3.5 w-3.5`}):v(We,{className:`h-3.5 w-3.5`}),v(`span`,{children:a(p.i18nKey,{defaultValue:p.message,...p.i18nParams})}),p.action===`sign-in`&&v(W,{variant:`unstyled`,onClick:()=>r(),className:`ml-2 rounded border border-white/40 px-2 py-0.5 text-[11px] font-semibold hover:bg-white/10`,children:a(`connection.signIn`,`Sign in`)}),p.showSpinner&&v(H,{className:`h-3.5 w-3.5 animate-spin`})]})}),se&&v(z_,{floating:!0,compact:!1,request:ce,navSections:I,addonPages:k}),v(J_,{}),v(ov,{}),v(py,{}),!se&&o&&s(`header`,{"data-debug-header":``,className:`flex items-center h-12 border-b border-border px-3 shrink-0 bg-surface`,children:[v(W,{variant:`unstyled`,onClick:()=>h(!0),className:`p-1.5 -ml-1.5 rounded-md hover:bg-surface-hover text-foreground-muted transition-colors`,"aria-label":a(`layouts.appLayout.openMenu`,`Open menu`),children:v(Ie,{className:`h-5 w-5`})}),v(`div`,{className:`flex-1 flex justify-center`,children:v(`img`,{src:i?.resolvedMode===`light`?V(`/brand/logo-horizontal-light.svg`):V(`/brand/logo-horizontal-dark.svg`),alt:a(`layouts.appLayout.dominevo`,`Dominevo`),className:`h-7`})}),v(dy,{}),v(Nv,{})]}),s(f_,{children:[v(m_,{}),v(`main`,{className:`relative flex-1 min-h-0 overscroll-contain bg-background ${ne?`overflow-hidden`:`overflow-auto`}`,children:v(Bg,{resetKey:e.pathname,children:v(g,{fallback:v(Yy,{}),children:v(qy,{})})})})]})]})]})]})}function $({children:e,requireAdmin:t}){let{t:n}=Z(),{user:r,loading:i,mustChangePassword:a}=os(),o=mo();return i?v(`div`,{className:`flex h-screen items-center justify-center bg-background text-foreground-subtle`,children:n(`layouts.protectedRoute.loading`,`Loading...`)}):r?a&&o.pathname!==`/change-password`?v(Y,{to:`/change-password`,replace:!0}):t&&!r.isAdmin?v(Y,{to:`/access-denied`,replace:!0}):v(j,{children:e}):v(Y,{to:`/login`,replace:!0,state:{from:o.pathname+o.search}})}var Zy=`integration`,Qy=`section`,$y=[Zy,Qy,`instance`,`instance-new`],eb={connectivity:{path:`/system/integrations`,tab:null},remoteAccess:{path:`/system/network`,tab:`remote-access`},mesh:{path:`/system/network`,tab:`mesh`},turn:{path:`/system/network`,tab:`turn`},authentication:{path:`/system/identity`,tab:`authentication`},access:{path:`/system/identity`,tab:`access`},logging:{path:`/system/logs`,tab:`destinations`}},tb=`activity`;function nb(e,t={}){let{path:n,tab:r}=eb[e],i=new URLSearchParams;r===null?t.kindSection!==void 0&&i.set(`tab`,t.kindSection):i.set(`tab`,r),t.integration!==void 0&&i.set(Zy,t.integration),t.section!==void 0&&i.set(Qy,t.section);let a=i.toString();return a.length>0?`${n}?${a}`:n}function rb(e){let{ids:t,requested:n,answered:r,legacyGroup:i=null,groupFirst:a={}}=e;if(n!==null&&t.includes(n))return{selectedId:n,staleId:null};let o=n!==null&&r?n:null,s=i===null?void 0:a[i];return s!==void 0&&t.includes(s)?{selectedId:s,staleId:o}:{selectedId:t[0]??null,staleId:o}}function ib(e,t,n=null,r=null){let i=new URLSearchParams(e);return i.set(Zy,t),r===null?i.delete(Qy):i.set(Qy,r),n!==null&&i.delete(n),i}function ab(e){return e===`/admin`||e===`/admin/`?`/`:e.startsWith(`/admin/`)?e.slice(6):e}var ob=`--color-surface`;function sb(e){let t=e.querySelector(`meta[name="theme-color"]`);if(t)return t;let n=e.createElement(`meta`);return n.name=`theme-color`,e.head.appendChild(n),n}function cb(e=document){let t=e.defaultView?.getComputedStyle(e.documentElement).getPropertyValue(ob).trim();if(!t)return;let n=sb(e);n.content!==t&&(n.content=t)}function lb(e=document){cb(e);let t=e.defaultView;if(!t)return()=>void 0;let n=new t.MutationObserver(()=>cb(e));return n.observe(e.documentElement,{attributes:!0,attributeFilter:[`class`]}),()=>n.disconnect()}function ub(){let{t:e}=Z(),t=_o();return s(`div`,{className:`flex flex-col items-center justify-center text-foreground py-16 px-4`,children:[v(`div`,{className:`flex h-16 w-16 items-center justify-center rounded-2xl bg-danger/10 mb-4`,children:v(Dn,{className:`h-8 w-8 text-danger`})}),v(`h1`,{className:`text-xl font-bold`,children:e(`accessDenied.accessDenied`,`Access Denied`)}),v(`p`,{className:`mt-2 text-sm text-foreground-subtle`,children:e(`accessDenied.youDonTHavePermission`,`You don't have permission to access this page.`)}),v(W,{variant:`unstyled`,onClick:()=>t(`/devices`),className:`mt-6 rounded-lg bg-primary px-5 py-2.5 text-sm font-medium text-primary-foreground shadow-md shadow-primary/20 hover:shadow-lg transition-all`,children:e(`accessDenied.goToDevices`,`Go to Devices`)})]})}function db(e){let t=new Uint8Array(e),n=``;for(let e of t)n+=String.fromCharCode(e);return btoa(n).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=/g,``)}function fb(e){let t=e.replace(/-/g,`+`).replace(/_/g,`/`),n=(4-t.length%4)%4,r=t.padEnd(t.length+n,`=`),i=atob(r),a=new ArrayBuffer(i.length),o=new Uint8Array(a);for(let e=0;e<i.length;e++)o[e]=i.charCodeAt(e);return a}function pb(){return window?.PublicKeyCredential!==void 0&&typeof window.PublicKeyCredential==`function`}function mb(e){let{id:t}=e;return{...e,id:fb(t),transports:e.transports}}function hb(e){return e===`localhost`||/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(e)}var gb=class extends Error{constructor({message:e,code:t,cause:n,name:r}){super(e,{cause:n}),this.name=r??n.name,this.code=t}},_b=new class{createNewAbortSignal(){if(this.controller){let e=Error(`Cancelling existing WebAuthn API call for new one`);e.name=`AbortError`,this.controller.abort(e)}let e=new AbortController;return this.controller=e,e.signal}cancelCeremony(){if(this.controller){let e=Error(`Manually cancelling existing WebAuthn API call`);e.name=`AbortError`,this.controller.abort(e),this.controller=void 0}}},vb=[`cross-platform`,`platform`];function yb(e){if(e&&!(vb.indexOf(e)<0))return e}function bb(){if(!pb())return new Promise(e=>e(!1));let e=window.PublicKeyCredential;return e.isConditionalMediationAvailable===void 0?new Promise(e=>e(!1)):e.isConditionalMediationAvailable()}function xb({error:e,options:t}){let{publicKey:n}=t;if(!n)throw Error(`options was missing required publicKey property`);if(e.name===`AbortError`){if(t.signal instanceof AbortSignal)return new gb({message:`Authentication ceremony was sent an abort signal`,code:`ERROR_CEREMONY_ABORTED`,cause:e})}else if(e.name===`NotAllowedError`)return new gb({message:e.message,code:`ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY`,cause:e});else if(e.name===`SecurityError`){let t=window.location.hostname;if(!hb(t))return new gb({message:`${window.location.hostname} is an invalid domain`,code:`ERROR_INVALID_DOMAIN`,cause:e});if(n.rpId!==t)return new gb({message:`The RP ID "${n.rpId}" is invalid for this domain`,code:`ERROR_INVALID_RP_ID`,cause:e})}else if(e.name===`UnknownError`)return new gb({message:`The authenticator was unable to process the specified options, or could not create a new assertion signature`,code:`ERROR_AUTHENTICATOR_GENERAL_ERROR`,cause:e});return e}async function Sb(e){let{optionsJSON:t,useBrowserAutofill:n=!1,verifyBrowserAutofillInput:r=!0}=e;if(!pb())throw Error(`WebAuthn is not supported in this browser`);let i;t.allowCredentials?.length!==0&&(i=t.allowCredentials?.map(mb));let a={...t,challenge:fb(t.challenge),allowCredentials:i},o={};if(n){if(!await bb())throw Error(`Browser does not support WebAuthn autofill`);if(document.querySelectorAll(`input[autocomplete$='webauthn']`).length<1&&r)throw Error('No <input> with "webauthn" as the only or last value in its `autocomplete` attribute was detected');o.mediation=`conditional`,a.allowCredentials=[]}o.publicKey=a,o.signal=_b.createNewAbortSignal();let s;try{s=await navigator.credentials.get(o)}catch(e){throw xb({error:e,options:o})}if(!s)throw Error(`Authentication was not completed`);let{id:c,rawId:l,response:u,type:d}=s,f;return u.userHandle&&(f=db(u.userHandle)),{id:c,rawId:db(l),response:{authenticatorData:db(u.authenticatorData),clientDataJSON:db(u.clientDataJSON),signature:db(u.signature),userHandle:f},type:d,clientExtensionResults:s.getClientExtensionResults(),authenticatorAttachment:yb(s.authenticatorAttachment)}}function Cb(e){return typeof e==`object`&&!!e}function wb(e){return Cb(e)&&typeof e.challenge==`string`}T();function Tb(e,t){return e instanceof Error&&e.message.length>0?e.message:t}function Eb(e){let{t}=Z(),n=G(),[r,i]=x(!1),[a,o]=x(``),[c,l]=x(null),[u,f]=x(null),p=d(null),m=_(e=>{p.current?.(e),p.current=null,i(!1),o(``),l(null),f(null)},[]),h=_(()=>new Promise(e=>{p.current?.(null),p.current=e,f(null),i(!0)}),[]),g=async()=>{l(`password`),f(null);try{let{reauthToken:e}=await n.reauthenticate({password:a});m(e)}catch(e){f(Tb(e,`Password is incorrect`)),l(null)}},y=async()=>{l(`passkey`),f(null);try{let{optionsJSON:e}=await n.reauthBeginPasskey();if(!wb(e))throw Error(`passkey authentication options missing challenge`);let t=await Sb({optionsJSON:e}),{reauthToken:r}=await n.reauthenticate({passkeyResponse:Object.fromEntries(Object.entries(t))});m(r)}catch(e){f(Tb(e,`Passkey verification failed`)),l(null)}};return{requestProof:h,dialog:v(Nn,{open:r,onOpenChange:e=>!e&&m(null),children:s(Na,{children:[s($i,{children:[v(Ti,{children:t(`auth.reauthDialog.confirmItSYou`,`Confirm it’s you`)}),v(ha,{children:t(`auth.reauthDialog.needsPassword`,{action:e})})]}),s(`form`,{className:`space-y-3`,onSubmit:e=>{e.preventDefault(),a.length>0&&c===null&&g()},children:[v(U,{type:`password`,autoComplete:`current-password`,placeholder:t(`auth.reauthDialog.currentPassword`,`Current password`),value:a,onChange:e=>o(e.target.value),"aria-label":t(`auth.reauthDialog.currentPassword`,`Current password`)}),u!==null&&v(`p`,{role:`alert`,className:`text-xs text-danger`,children:u}),s(Ta,{className:`flex flex-wrap gap-2`,children:[s(W,{type:`button`,variant:`outline`,disabled:c!==null,onClick:()=>void y(),children:[c===`passkey`?v(H,{className:`h-4 w-4 animate-spin`}):v(gn,{className:`h-4 w-4`}),t(`auth.reauthDialog.useAPasskey`,`Use a passkey`)]}),s(W,{type:`submit`,disabled:a.length===0||c!==null,children:[c===`password`&&v(H,{className:`h-4 w-4 animate-spin`}),t(`common.confirm`,`Confirm`)]})]})]})]})})}}T();function Db(e){return e.ip!==null&&e.approverIp!==null&&e.ip!==e.approverIp}function Ob(e,t){return e instanceof Error&&e.message.length>0?e.message:t}function kb(e){let t=e instanceof Error?e.message:``;return t.startsWith(`Sign in again first`)||t.startsWith(`Confirm it is you`)}function Ab(e,t){let n=Math.max(0,Math.round((t-e)/1e3));return n<5?{key:`justNow`,value:0}:n<60?{key:`seconds`,value:n}:{key:`minutes`,value:Math.round(n/60)}}function jb({onApproved:e,onDenied:t}){let{t:n}=Z(),r=gr.useUtils(),[i,a]=x(``),[o,c]=x(null),[l,u]=x(``),[d,f]=x(null),[p,m]=x(null),{requestProof:h,dialog:g}=Eb(n(`cliLogin.reauthAction`,`Approving a terminal sign-in`)),_=gr.auth.cliLoginApprove.useMutation(),y=gr.auth.cliLoginDeny.useMutation(),b=async e=>{e.preventDefault(),f(`lookup`),m(null);try{c(await r.auth.cliLoginDescribe.fetch({userCode:i})),u(i)}catch(e){c(null),m(Ob(e,n(`cliLogin.unknownCode`,`No pending sign-in with that code. Check the terminal.`)))}finally{f(null)}},S=async r=>{f(r),m(null);try{if(r===`deny`){await y.mutateAsync({userCode:l}),t();return}try{await _.mutateAsync({userCode:l})}catch(e){if(!kb(e))throw e;let t=await h();if(t===null)return;await _.mutateAsync({userCode:l,reauthToken:t})}e()}catch(e){m(Ob(e,n(`cliLogin.failed`,`That did not work. Try again.`)))}finally{f(null)}},C=o===null?null:Ab(o.createdAt,Date.now());return s(`div`,{className:`space-y-4`,"data-testid":`cli-login-approval`,children:[s(`div`,{className:`space-y-1`,children:[s(`h1`,{className:`flex items-center gap-2 text-sm font-semibold text-foreground`,children:[v(wn,{className:`h-4 w-4`,"aria-hidden":!0}),n(`cliLogin.title`,`Approve a terminal sign-in`)]}),v(`p`,{className:`text-xs text-foreground-subtle`,children:n(`cliLogin.intro`,`Type the code your terminal shows. Only approve a sign-in you started yourself.`)})]}),p!==null&&v(`div`,{role:`alert`,className:`rounded-md border border-danger/20 bg-danger/10 px-3 py-2 text-xs text-danger`,children:p}),o===null||C===null?s(`form`,{onSubmit:e=>void b(e),className:`space-y-3`,children:[v(U,{value:i,onChange:e=>a(e.target.value),placeholder:`ABCD-EFGH`,"aria-label":n(`cliLogin.codeLabel`,`Sign-in code`),autoComplete:`off`,autoCapitalize:`characters`,spellCheck:!1,maxLength:16,className:`text-center font-mono tracking-widest`}),s(W,{type:`submit`,variant:`primary`,className:`w-full`,disabled:i.trim().length<8||d!==null,children:[d===`lookup`&&v(H,{className:`h-4 w-4 animate-spin`,"aria-hidden":!0}),n(`cliLogin.continue`,`Continue`)]})]}):s(`div`,{className:`space-y-3`,children:[s(`dl`,{className:`space-y-1 rounded-md border border-border bg-background-elevated p-3 text-xs`,children:[s(`div`,{className:`flex justify-between gap-3`,children:[v(`dt`,{className:`text-foreground-muted`,children:n(`cliLogin.address`,`Terminal address`)}),v(`dd`,{className:`text-foreground`,"data-testid":`cli-login-ip`,children:o.ip??n(`cliLogin.unknownValue`,`Unknown`)})]}),s(`div`,{className:`flex justify-between gap-3`,children:[v(`dt`,{className:`text-foreground-muted`,children:n(`cliLogin.yourAddress`,`Your address`)}),v(`dd`,{className:`text-foreground`,"data-testid":`cli-login-approver-ip`,children:o.approverIp??n(`cliLogin.unknownValue`,`Unknown`)})]}),s(`div`,{className:`flex justify-between gap-3`,children:[v(`dt`,{className:`text-foreground-muted`,children:n(`cliLogin.program`,`Program (seen by the hub)`)}),v(`dd`,{className:`truncate text-foreground`,"data-testid":`cli-login-agent`,children:o.userAgent??n(`cliLogin.unknownValue`,`Unknown`)})]}),s(`div`,{className:`flex justify-between gap-3`,children:[v(`dt`,{className:`text-foreground-muted`,children:n(`cliLogin.client`,`Name it gave itself (unverified)`)}),v(`dd`,{className:`truncate text-foreground-muted`,"data-testid":`cli-login-client`,children:o.client??n(`cliLogin.unknownValue`,`Unknown`)})]}),s(`div`,{className:`flex justify-between gap-3`,children:[v(`dt`,{className:`text-foreground-muted`,children:n(`cliLogin.requested`,`Requested`)}),v(`dd`,{className:`text-foreground`,children:C.key===`justNow`?n(`cliLogin.ageNow`,`just now`):C.key===`seconds`?n(`cliLogin.ageSeconds`,`{{count}} s ago`,{count:C.value}):n(`cliLogin.ageMinutes`,`{{count}} min ago`,{count:C.value})})]})]}),Db(o)&&v(`div`,{role:`alert`,"data-testid":`cli-login-mismatch`,className:`rounded-md border border-warning/20 bg-warning/10 px-3 py-2 text-xs text-warning`,children:n(`cliLogin.mismatch`,`This request comes from a different address than the one you are using now. Approve it only if you started it from another machine of yours.`)}),v(`p`,{className:`text-xs text-foreground-subtle`,"data-testid":`cli-login-grant`,children:n(`cliLogin.grant`,`Approving signs this terminal in as you, with all of your rights, until the session expires or you end it under Tokens & sessions.`)}),s(`div`,{className:`flex gap-2`,children:[v(W,{type:`button`,variant:`ghost`,className:`flex-1`,disabled:d!==null,onClick:()=>void S(`deny`),children:n(`cliLogin.deny`,`Deny`)}),s(W,{type:`button`,variant:`primary`,className:`flex-1`,disabled:d!==null,onClick:()=>void S(`approve`),children:[d===`approve`&&v(H,{className:`h-4 w-4 animate-spin`,"aria-hidden":!0}),n(`cliLogin.approve`,`Approve`)]})]})]}),g]})}T();function Mb(){let{t:e}=Z(),t=ji(),n=_o(),[r,i]=x(!1);return v(`div`,{className:`flex min-h-screen items-center justify-center bg-background p-4`,children:s(`div`,{className:`w-full max-w-sm`,children:[v(`div`,{className:`mb-8 flex justify-center`,children:v(`img`,{src:t?.resolvedMode===`light`?V(`/brand/logo-horizontal-light.svg`):V(`/brand/logo-horizontal-dark.svg`),alt:e(`cliLogin.brand`,`Dominevo`),className:`h-12`})}),v(`div`,{className:`rounded-xl border border-border bg-surface p-6 shadow-xl shadow-black/10`,children:r?s(`div`,{className:`space-y-3 text-center`,"data-testid":`cli-login-denied`,children:[v(`p`,{className:`text-sm text-foreground`,children:e(`cliLogin.deniedBody`,`The sign-in was denied. The terminal stays signed out.`)}),v(W,{type:`button`,variant:`ghost`,onClick:()=>void n(`/`),children:e(`cliLogin.back`,`Back to Dominevo`)})]}):v(jb,{onApproved:()=>window.location.assign(V(tn(null,{status:`success`,action:`cli-login`}))),onDenied:()=>i(!0)})})]})})}var Nb=`auth.password-incorrect`;function Pb(e,t){return typeof e==`object`&&e?Reflect.get(e,t):void 0}function Fb(e){if(!(e instanceof Error))return{kind:`connection-lost`};let t=Pb(e,`data`);return typeof t!=`object`||!t?{kind:`connection-lost`}:Pb(Pb(t,`i18n`),`code`)===Nb?{kind:`wrong-current`}:Pb(t,`code`)===`UNAUTHORIZED`?{kind:`session-ended`}:{kind:`rejected`,message:e.message}}T();var Ib=8;function Lb(e,t){let n=Fb(e);switch(n.kind){case`wrong-current`:return t(`changePassword.errorWrongCurrent`,`The current password is incorrect.`);case`session-ended`:return t(`changePassword.errorSessionEnded`,`Your session ended before the change was confirmed. Sign in again — try the new password first.`);case`connection-lost`:return t(`changePassword.errorConnectionLost`,`The connection to the hub dropped before it confirmed the change. Sign in again — try the new password first.`);case`rejected`:return n.message}}function Rb(){let{t:e}=Z(),{user:t,mustChangePassword:n,clearMustChangePassword:r,logout:i}=os(),a=G(),o=ji(),c=_o(),[l,u]=x(``),[d,f]=x(``),[p,m]=x(``),[h,g]=x(!1),[_,y]=x(``),[b,S]=x(!1),C=n?ls:l;return v(`div`,{className:`flex min-h-screen items-center justify-center bg-background p-4`,children:s(`div`,{className:`w-full max-w-sm`,children:[v(`div`,{className:`flex justify-center mb-8`,children:v(`img`,{src:o?.resolvedMode===`light`?V(`/brand/logo-horizontal-light.svg`):V(`/brand/logo-horizontal-dark.svg`),alt:e(`changePassword.dominevoAdmin`,`Dominevo Admin`),className:`h-12`})}),s(`form`,{onSubmit:async i=>{if(i.preventDefault(),y(``),!t){y(`Not signed in`);return}if(!n&&l.length===0){y(e(`changePassword.enterCurrent`,`Enter your current password`));return}if(d.length<Ib){y(`Password must be at least ${Ib} characters`);return}if(d!==p){y(`The two passwords do not match`);return}if(d===`changeme`){y(`Choose a password different from the seed default`);return}S(!0);try{await a.changeOwnPassword({currentPassword:C,newPassword:d}),r(),c(`/devices`,{replace:!0})}catch(t){y(Lb(t,e))}finally{S(!1)}},className:`space-y-4 rounded-xl border border-border bg-surface p-6 shadow-xl shadow-black/10`,children:[s(`div`,{className:`space-y-1`,children:[v(`h1`,{className:`text-sm font-semibold text-foreground`,children:e(`changePassword.setANewPassword`,`Set a new password`)}),v(`p`,{className:`text-xs text-foreground-subtle`,children:n?e(`changePassword.youMustRotateTheSeed`,`You must rotate the seed password before continuing.`):e(`changePassword.chooseANewPasswordFor`,`Choose a new password for your account.`)})]}),_&&v(`div`,{role:`alert`,className:`rounded-md bg-danger/10 border border-danger/20 px-3 py-2 text-xs text-danger`,children:_}),!n&&s(`div`,{className:`space-y-1.5`,children:[v(`label`,{className:`text-xs font-medium text-foreground-subtle`,children:e(`changePassword.currentPassword`,`Current password`)}),v(U,{"data-testid":`change-password-current`,type:h?`text`:`password`,value:l,onChange:e=>u(e.target.value),autoComplete:`current-password`,className:`w-full rounded-lg border border-border bg-background px-3 py-2.5 text-sm text-foreground placeholder:text-foreground-disabled focus:border-primary focus:ring-1 focus:ring-primary/30 outline-none transition-all`,autoFocus:!0})]}),s(`div`,{className:`space-y-1.5`,children:[v(`label`,{className:`text-xs font-medium text-foreground-subtle`,children:e(`changePassword.newPassword`,`New password`)}),s(`div`,{className:`relative`,children:[v(U,{"data-testid":`change-password-new`,type:h?`text`:`password`,value:d,onChange:e=>f(e.target.value),autoComplete:`new-password`,className:`w-full rounded-lg border border-border bg-background px-3 py-2.5 pr-10 text-sm text-foreground placeholder:text-foreground-disabled focus:border-primary focus:ring-1 focus:ring-primary/30 outline-none transition-all`,autoFocus:n}),v(W,{variant:`unstyled`,type:`button`,onClick:()=>g(!h),className:`absolute right-2.5 top-1/2 -translate-y-1/2 text-foreground-subtle hover:text-foreground transition-colors`,tabIndex:-1,children:v(h?kt:we,{className:`h-4 w-4`})})]})]}),s(`div`,{className:`space-y-1.5`,children:[v(`label`,{className:`text-xs font-medium text-foreground-subtle`,children:e(`changePassword.confirmNewPassword`,`Confirm new password`)}),v(U,{"data-testid":`change-password-confirm`,type:h?`text`:`password`,value:p,onChange:e=>m(e.target.value),autoComplete:`new-password`,className:`w-full rounded-lg border border-border bg-background px-3 py-2.5 text-sm text-foreground placeholder:text-foreground-disabled focus:border-primary focus:ring-1 focus:ring-primary/30 outline-none transition-all`})]}),v(W,{variant:`unstyled`,"data-testid":`change-password-submit`,type:`submit`,disabled:b||!d||!p,className:`w-full rounded-lg bg-primary px-4 py-2.5 text-sm font-semibold text-primary-foreground shadow-md shadow-primary/20 hover:shadow-lg hover:shadow-primary/30 disabled:opacity-50 disabled:shadow-none transition-all`,children:b?e(`changePassword.saving`,`Saving…`):e(`changePassword.saveAndContinue`,`Save and continue`)}),n&&v(W,{variant:`unstyled`,type:`button`,onClick:()=>{i(),c(`/login`,{replace:!0})},className:`w-full text-xs text-foreground-subtle hover:text-foreground transition-colors`,children:e(`changePassword.signOutInstead`,`Sign out instead`)})]})]})})}T();async function zb(e){if(!wb(e))throw Error(`passkey authentication options missing challenge`);let t=await Sb({optionsJSON:e});return Object.fromEntries(Object.entries(t))}function Bb({method:e,challengeToken:t,onComplete:n,onSecondFactor:r,onError:i}){let[a,o]=x(!1),[c,l]=x(null),u=async()=>{l(null),o(!0);try{let e=Zo();if(t){let r=await zb((await e.loginBeginPasskey(t)).optionsJSON),i=await e.loginVerifyPasskey(t,r,{refreshable:!0});n(i.token,i);return}let a=await zb((await e.passkeyLoginBegin()).optionsJSON),o=await e.passkeyLoginFinish(a,{refreshable:!0}),s=o.secondFactors??(o.requiresTotp===!0?[`totp`]:[]);if(s.length>0){if(r)r({challengeToken:o.token,factors:s});else{let e=`Additional verification is required — sign in with your password to continue.`;l(e),i?.(e)}return}n(o.token,o)}catch(e){let n=t?`Passkey verification failed`:`Passkey sign-in failed`,r=e instanceof Error?e.message:n;l(r),i?.(r)}finally{o(!1)}};return s(`div`,{className:`space-y-2`,children:[s(W,{variant:`unstyled`,type:`button`,"data-testid":t?`login-passkey`:`login-passkey-direct`,onClick:()=>void u(),disabled:a,className:`w-full flex items-center justify-center gap-2 rounded-lg border border-border bg-surface px-4 py-2.5 text-sm font-medium text-foreground hover:bg-surface-hover disabled:opacity-50 transition-colors`,children:[a?v(H,{className:`h-4 w-4 animate-spin text-primary`}):v(_n,{className:`h-4 w-4 text-primary`}),e.label]}),c&&v(`div`,{className:`rounded-md bg-danger/10 border border-danger/20 px-3 py-2 text-xs text-danger`,children:c})]})}var Vb=()=>window.location.hostname;function Hb(e,t=Vb,n=null){return n===!1?!1:pb()&&H_(t(),e.rpId)}function Ub(e,t=Vb,n=null){let r=e.filter(e=>e.kind===`passkey`&&e.stage===`second-factor`).filter(e=>Hb(e,t,n));return{passkeyMethods:r,widgetMethods:r.length>0?[]:e.filter(e=>e.kind===`widget`&&e.stage===`second-factor`)}}function Wb(e,t){let n=e.includes(`passkey`),r=t.passkeyMethods.length>0||t.widgetMethods.length>0,i=e.includes(`totp`);return n&&!r&&!i}T();async function Gb(){if(typeof PublicKeyCredential>`u`)return null;let e=PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable;if(typeof e!=`function`)return null;try{return await e.call(PublicKeyCredential)}catch{return null}}var Kb=()=>`dominevoAgentApp`in window;function qb(){let[e,t]=x(null);return y(()=>{if(!Kb())return;let e=!0;return Gb().then(n=>{e&&t(n)}),()=>{e=!1}},[]),e}function Jb(e){let t=e.onComplete,n=e.onSecondFactor;return typeof t==`function`?{onComplete:t,onSecondFactor:typeof n==`function`?n:void 0}:null}function Yb({methods:e,widgetConfig:t,onRedirect:n}){let{t:r}=Z();qa();let i=qb(),a=e.filter(e=>e.kind!==`passkey`||Hb(e,void 0,i));return a.length===0?null:s(`div`,{className:`mt-6 space-y-3`,children:[s(`div`,{className:`flex items-center gap-3`,children:[v(`div`,{className:`h-px flex-1 bg-border`}),v(`span`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle`,children:r(`login.primaryLoginMethods.orContinueWith`,`Or continue with`)}),v(`div`,{className:`h-px flex-1 bg-border`})]}),v(`div`,{className:`space-y-2`,children:a.map(e=>{if(e.kind===`redirect`){let t=(e.icon===void 0?void 0:Xr(e.icon))??N;return s(`a`,{href:e.startUrl,onClick:t=>{n?.(e)===!0&&t.preventDefault()},className:`flex items-center justify-center gap-2 w-full rounded-lg border border-border bg-surface px-4 py-2.5 text-sm font-medium text-foreground hover:bg-surface-hover transition-colors`,children:[v(t,{className:`h-4 w-4 text-primary`}),e.label]},e.id)}if(e.kind===`passkey`){let n=Jb(t);return n?v(Bb,{method:e,onComplete:n.onComplete,onSecondFactor:n.onSecondFactor},e.id):null}return v(Xb,{method:e,config:t},e.id)})})]})}function Xb({method:e,config:t}){let{t:n}=Z(),r=Wr(e.remote,e.bundleUrl);return r===null?s(`div`,{className:`flex items-center justify-center gap-2 rounded-lg border border-border bg-background px-4 py-2.5 text-xs text-foreground-subtle`,children:[v(H,{className:`h-3.5 w-3.5 animate-spin`}),n(`common.loading`,`Loading…`)]}):r===void 0?s(`div`,{"data-testid":`login-method-load-error`,className:`flex items-center justify-center gap-2 rounded-lg border border-danger/20 bg-danger/10 px-4 py-2.5 text-xs text-danger`,children:[v(Ue,{className:`h-3.5 w-3.5 shrink-0`}),n(`login.primaryMethods.loadFailed`)]}):v(r,{instanceId:e.id,host:`dashboard`,config:t})}var Zb=4e3,Qb=/^[A-Za-z0-9._-]{1,64}$/;function $b(e){if(e.action===`cli-login`)return nb(`access`);let t=e.addonId!==void 0&&Qb.test(e.addonId)?e.addonId:null,n=e.integration!==void 0&&Qb.test(e.integration)?e.integration:null;if(t!==null&&e.brokerId!==void 0)return nb(`connectivity`,{integration:t,kindSection:`brokers`});let r=n??t;return nb(`connectivity`,r===null?{}:{integration:r})}function ex(e,t){let n=t.opener;if(n===null||n.closed||Ro(n)!==t.origin)return!1;try{return n.postMessage({type:Go,ok:e.status===`success`,...e.brokerId===void 0?{}:{brokerId:e.brokerId},...e.status===`error`?{error:e.reason??`unknown`}:{}},t.origin),!0}catch{return!1}}T();var tx=500;function nx(e){let{t}=Z();switch(e){case`access_denied`:return t(`oauthLanding.reason.access_denied`,`Access was denied, so nothing was connected.`);case`invalid_state`:return t(`oauthLanding.reason.invalid_state`,`This sign-in link expired or was already used. Start the sign-in again.`);case`invalid_request`:return t(`oauthLanding.reason.invalid_request`,`The request was not valid for this hub. Start the link again from the beginning.`);case`unknown_broker`:return t(`oauthLanding.reason.unknown_broker`,`That connection no longer exists. Add it again, then sign in.`);case`not_configured`:return t(`oauthLanding.reason.not_configured`,`The connection is missing its client ID or secret. Fill them in, save, then sign in.`);case`exchange_failed`:return t(`oauthLanding.reason.exchange_failed`,`The provider did not accept the sign-in. Check the client ID and secret, then try again.`);case`no_authorization_code`:return t(`oauthLanding.reason.no_authorization_code`,`The provider finished the sign-in without granting Dominevo access. Start the sign-in again from the beginning.`);case`no_refresh_token`:return t(`oauthLanding.reason.no_refresh_token`,`The provider returned no long-lived access. Remove Dominevo from the account’s connected apps, then sign in again.`);case`unavailable`:return t(`oauthLanding.reason.unavailable`,`The hub is still starting this integration. Wait a moment and try again.`);case`unknown`:return t(`oauthLanding.reason.unknown`,`Something went wrong. Try again in a moment.`)}}function rx({outcome:e}){let{t}=Z(),n=nx(e.reason??`unknown`);if(e.status===`error`)return s(j,{children:[v(Je,{className:`mx-auto h-8 w-8 text-danger`,"aria-hidden":!0}),v(`h1`,{"data-testid":`oauth-landing-title`,className:`text-sm font-semibold text-foreground`,children:t(`oauthLanding.errorTitle`,`Sign-in did not finish`)}),v(`p`,{"data-testid":`oauth-landing-reason`,className:`rounded-md border border-danger/20 bg-danger/10 px-3 py-2 text-xs text-danger`,children:n})]});if(e.action===`cli-login`)return s(j,{children:[v(Ve,{className:`mx-auto h-8 w-8 text-success`,"aria-hidden":!0}),v(`h1`,{"data-testid":`oauth-landing-title`,className:`text-sm font-semibold text-foreground`,children:t(`oauthLanding.cliLoginTitle`,`Terminal signed in`)}),v(`p`,{className:`text-xs text-foreground-muted`,children:t(`oauthLanding.cliLoginBody`,`Go back to your terminal: it finishes the sign-in by itself.`)})]});let r=e.action===`disconnect`;return s(j,{children:[v(Ve,{className:`mx-auto h-8 w-8 text-success`,"aria-hidden":!0}),v(`h1`,{"data-testid":`oauth-landing-title`,className:`text-sm font-semibold text-foreground`,children:r?t(`oauthLanding.signedOutTitle`,`Signed out`):t(`oauthLanding.successTitle`,`Signed in`)}),v(`p`,{className:`text-xs text-foreground-muted`,children:r?t(`oauthLanding.signedOutBody`,`The account was disconnected from this hub.`):t(`oauthLanding.successBody`,`The account is connected. Returning to Dominevo…`)})]})}function ix({outcome:e,closable:t,onContinue:n,onClose:r}){let{t:i}=Z(),a=$b(e);return y(()=>{if(e.status!==`success`)return;let t=window.setTimeout(()=>n(a),Zb);return()=>window.clearTimeout(t)},[e.status,n,a]),v(`main`,{className:`flex min-h-screen items-center justify-center bg-background p-4`,children:s(`div`,{className:`w-full max-w-sm space-y-4`,children:[v(`div`,{className:`flex justify-center`,children:s(`picture`,{children:[v(`source`,{media:`(prefers-color-scheme: dark)`,srcSet:V(`/brand/logo-horizontal-dark.svg`)}),v(`img`,{src:V(`/brand/logo-horizontal-light.svg`),alt:i(`oauthLanding.brand`,`Dominevo`),className:`h-12`})]})}),s(`div`,{className:`space-y-4 rounded-xl border border-border bg-surface p-6 text-center shadow-xl shadow-black/10`,children:[v(rx,{outcome:e}),s(`div`,{className:`flex flex-col gap-2`,children:[v(W,{type:`button`,variant:`primary`,onClick:()=>n(a),children:i(`oauthLanding.back`,`Back to Dominevo`)}),t&&v(W,{type:`button`,variant:`ghost`,onClick:r,children:i(`oauthLanding.close`,`Close this window`)})]})]})]})})}function ax(e,t){window.history.replaceState(null,``,window.location.pathname);let n=window.opener,r=ex(t,{opener:n,origin:window.location.origin}),i=()=>e.render(v(ix,{outcome:t,closable:r,onContinue:e=>window.location.replace(V(e)),onClose:()=>window.close()}));if(r&&t.status===`success`){window.close(),window.setTimeout(i,tx);return}i()}function ox(e){return un(e)}var sx=`Done — you can close this window.`,cx=500,lx=`dominevo_admin_token`;async function ux(e,t=``){try{let n=ps(new URLSearchParams(t));n!==null&&n.token===e?hs(n):localStorage.setItem(lx,e)}catch{}await fetch(V(`/api/auth/session`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({token:e})}).catch(()=>{})}function dx(){try{let e=localStorage.getItem(lx);return e!==null&&e.length>0?e:null}catch{return null}}function fx(e){let t=ox(window.location.hash);if(t!==null){ax(e,t);return}let n=No(window.location.hash);window.history.replaceState(null,``,window.location.pathname);let r=t=>e.render(v(px,{completion:n,result:t,hasOpener:window.opener!==null}));if(r(null),n===null)return;let i=zo();Vo(n,{opener:window.opener,origin:window.location.origin,channel:i,addEventListener:(e,t)=>window.addEventListener(e,t),removeEventListener:(e,t)=>window.removeEventListener(e,t),close:()=>{window.close(),window.setTimeout(()=>r({kind:`done`,message:sx}),cx)},continueAt:e=>window.location.replace(V(e)),persistSession:e=>ux(e,n.target===`login`?n.fragment:``),showResult:r,setTimeout:(e,t)=>window.setTimeout(e,t)})}function px({completion:e,result:t,hasOpener:n=!0}){let{t:r}=Z();return v(`div`,{className:`flex min-h-screen items-center justify-center bg-background p-4`,children:v(`div`,{className:`flex flex-col items-center gap-3 text-sm text-foreground-subtle`,children:e===null?v(`a`,{className:`text-primary underline`,href:V(`/login`),children:r(`ssoComplete.nothingToFinishHereGo`,`Nothing to finish here — go to sign-in`)}):t===null?s(`span`,{className:`flex items-center gap-3`,children:[v(`span`,{className:`h-4 w-4 animate-spin rounded-full border-2 border-primary/30 border-t-primary`}),r(`ssoComplete.finishingSignIn`,`Finishing sign-in…`)]}):s(j,{children:[v(`span`,{"data-testid":`sso-complete-result`,className:t.kind===`link-error`?`text-danger`:`text-foreground`,children:t.message}),v(W,{variant:`unstyled`,type:`button`,className:`rounded-md border border-border px-3 py-1.5 text-foreground hover:bg-surface-hover`,onClick:()=>window.close(),children:r(`ssoComplete.closeThisWindow`,`Close this window`)}),!n&&v(`a`,{className:`text-primary underline`,href:V(`/login`),children:r(`ssoComplete.backToSignIn`,`Back to sign-in`)})]})})})}T();function mx(e){if(typeof e!=`object`||!e)return!1;let t=Reflect.get(e,`message`),n=Reflect.get(e,`data`);return(typeof n==`object`&&n?Reflect.get(n,`code`):void 0)===`FORBIDDEN`||typeof t==`string`&&/sign in again first/i.test(t)}function hx(){let e=new URLSearchParams(window.location.search);return ss({codeChallenge:e.get(`code_challenge`),codeChallengeMethod:e.get(`code_challenge_method`),state:e.get(`state`),purpose:e.get(`purpose`)})}function gx(e){return Math.min(1e3*2**e,15e3)}function _x(){let{t:e}=Z(),{login:t,verifyTotp:n,finalizePasskeyLogin:r,user:i}=os(),{i18n:a}=Z(),o=ji(),c=_o(),l=mo(),u=new URLSearchParams(window.location.search).get(`next`);y(()=>{is(u)},[u]);let f=new URLSearchParams(window.location.search).get(`redirect`);y(()=>{fs(f)},[f]);let p=hx();y(()=>{Qo(p)},[p?.codeChallenge,p?.state,p?.purpose]);let m=l.state,h=Ty(m?.from),[g,_]=x(``),[b,S]=x(``),[C,w]=x(!1),[T,E]=x(``),[D,O]=x(!1),[k,A]=x(`credentials`),[M,N]=x(``),[P,F]=x([]),[ee,te]=x(``),[ne,re]=x(void 0),[ie,ae]=x(`sso-not-linked`),oe=gr.auth.listLoginMethods.useQuery(void 0,{retry:!0,retryDelay:gx}),se=oe.data===void 0,ce=(oe.data??[]).filter(e=>e.kind!==`device-certificate`),I=gr.auth.getServerName.useQuery().data,le=ce.filter(e=>e.stage===`primary`),ue=Ub(ce,void 0,qb());y(()=>{let e=Ho(window.location.hash);if(e!==null){if(window.history.replaceState({},``,window.location.pathname+window.location.search),e.kind===`challenge`){N(e.challengeToken),F(e.factors),te(``),A(`second-factor`);return}ae(e.code),re(e.provider)}},[]);let de=ne==null?null:ce.find(e=>e.id===ne&&`label`in e)?.label??null,fe=T||(ne===void 0?``:Fo(ie,de)),{passkeyMethods:pe,widgetMethods:L}=ue,R=d(!1),z=async()=>{if(R.current)return;R.current=!0;let e=es(f);if(e?.kind===`app-callback`){await he(e.url);return}else if(e){window.location.assign(V(e.path));return}let t=$o(u);t?window.location.assign(V(t)):c(h,{replace:!0})},[me,B]=x(null),he=async e=>{B({callbackBase:e,mintedUrl:null,failed:!1});try{let t=hx()??Xo();if(t===null)throw Error(`The app sent no PKCE challenge and state`);let{code:n}=await Zo().trpcClient.auth.createHandoffCode.mutate({purpose:t.purpose,codeChallenge:t.codeChallenge,state:t.state}),r=rs(e,n,t.state);B({callbackBase:e,mintedUrl:r,failed:!1}),window.location.assign(r)}catch(t){if(mx(t)){R.current=!1,B(null),E(`Sign in again to confirm it is you.`);return}B({callbackBase:e,mintedUrl:null,failed:!0})}},ge=i!==null,[_e,ve]=x(!1);y(()=>{!ge||!f&&!u||_e||(ve(!0),z())},[ge,f,u,_e]);let ye=async e=>{e.preventDefault(),E(``),re(void 0),O(!0);try{let e=await t(g,b);if(e.kind===`second-factor`){N(e.challengeToken),F(e.factors),A(`second-factor`);return}b===`changeme`?c(`/change-password`,{replace:!0}):await z()}catch(e){E(e instanceof Error?e.message:`Login failed`)}finally{O(!1)}},be=async e=>{e.preventDefault(),E(``),O(!0);try{await n(M,ee.trim()),await z()}catch(e){E(e instanceof Error?e.message:`TOTP verification failed`),te(``)}finally{O(!1)}},xe=async(e,t)=>{try{await r(e,t),await z()}catch(e){E(e instanceof Error?e.message:`Passkey sign-in failed`)}},Se=d(null);y(()=>()=>Se.current?.(),[]);let Ce=async e=>{if(e.target!==`login`)return;let t=ps(new URLSearchParams(e.fragment));if(t!==null){try{await r(t.token,t),await z()}catch(e){E(e instanceof Error?e.message:`Sign-in failed`)}return}let n=Ho(`#${e.fragment}`);if(n!==null){if(n.kind===`challenge`){Ee({challengeToken:n.challengeToken,factors:n.factors});return}ae(n.code),re(n.provider)}},Te=e=>{if(us(f)?.kind===`app-callback`)return!1;let t=Io(V(Po(e.startUrl)));return t===null?!1:(E(``),re(void 0),Se.current?.(),Se.current=Bo(t,{onReturn:e=>{Se.current?.(),Se.current=null,Ce(e)},onDone:e=>{if(Se.current?.(),Se.current=null,e.target!==`login`)return;let t=dx()===null?null:as();t!==null&&Ce({target:`login`,fragment:new URLSearchParams({token:t.token,...t.refreshToken===void 0?{}:{refreshToken:t.refreshToken},...t.expiresAt===void 0?{}:{expiresAt:String(t.expiresAt)}}).toString()})}}),!0)},Ee=e=>{let t=e.factors.filter(e=>e===`totp`||e===`passkey`);N(e.challengeToken),F(t),te(``),E(``),A(`second-factor`)};return me===null?v(`div`,{className:`flex min-h-screen items-center justify-center bg-background p-4`,children:s(`div`,{className:`w-full max-w-sm`,children:[v(`div`,{className:`flex justify-center mb-8`,children:v(`img`,{src:o?.resolvedMode===`light`?V(`/brand/logo-horizontal-light.svg`):V(`/brand/logo-horizontal-dark.svg`),alt:e(`login.dominevoAdmin`,`Dominevo Admin`),className:`h-12`})}),I!==void 0&&!I.isDefault&&v(`p`,{"data-testid":`login-server-name`,className:`-mt-4 mb-6 text-center text-sm text-foreground-muted`,children:v(Pc,{i18nKey:`login.signInTo`,values:{name:I.name},components:{b:v(`span`,{className:`font-semibold text-foreground`})}})}),k===`credentials`?s(`form`,{onSubmit:ye,className:`space-y-4 rounded-xl border border-border bg-surface p-6 shadow-xl shadow-black/10`,children:[fe&&v(`div`,{"data-testid":`login-error`,className:`rounded-md bg-danger/10 border border-danger/20 px-3 py-2 text-xs text-danger`,children:fe}),s(`div`,{className:`space-y-1.5`,children:[v(`label`,{className:`text-xs font-medium text-foreground-subtle`,children:e(`login.username`,`Username`)}),v(U,{"data-testid":`login-username`,type:`text`,placeholder:e(`login.username`,`Username`),value:g,onChange:e=>_(e.target.value),className:`w-full rounded-lg border border-border bg-background px-3 py-2.5 text-sm text-foreground placeholder:text-foreground-disabled focus:border-primary focus:ring-1 focus:ring-primary/30 outline-none transition-all`,autoFocus:!0})]}),s(`div`,{className:`space-y-1.5`,children:[v(`label`,{className:`text-xs font-medium text-foreground-subtle`,children:e(`login.password`,`Password`)}),s(`div`,{className:`relative`,children:[v(U,{"data-testid":`login-password`,type:C?`text`:`password`,placeholder:e(`login.password`,`Password`),value:b,onChange:e=>S(e.target.value),className:`w-full rounded-lg border border-border bg-background px-3 py-2.5 pr-10 text-sm text-foreground placeholder:text-foreground-disabled focus:border-primary focus:ring-1 focus:ring-primary/30 outline-none transition-all`}),v(W,{variant:`unstyled`,type:`button`,onClick:()=>w(!C),className:`absolute right-2.5 top-1/2 -translate-y-1/2 text-foreground-subtle hover:text-foreground transition-colors`,tabIndex:-1,children:v(C?kt:we,{className:`h-4 w-4`})})]})]}),v(W,{variant:`unstyled`,"data-testid":`login-submit`,type:`submit`,disabled:D||!g||!b,className:`w-full rounded-lg bg-primary px-4 py-2.5 text-sm font-semibold text-primary-foreground shadow-md shadow-primary/20 hover:shadow-lg hover:shadow-primary/30 disabled:opacity-50 disabled:shadow-none transition-all`,children:D?s(`span`,{className:`flex items-center justify-center gap-2`,children:[v(`span`,{className:`h-4 w-4 animate-spin rounded-full border-2 border-primary-foreground/30 border-t-primary-foreground`}),e(`login.loggingIn`,`Logging in...`)]}):e(`login.logIn`,`Log in`)})]}):s(`div`,{className:`space-y-4 rounded-xl border border-border bg-surface p-6 shadow-xl shadow-black/10`,children:[s(`div`,{className:`flex items-center gap-2 pb-1 border-b border-border`,children:[v(Oe,{className:`h-4 w-4 text-primary`}),v(`div`,{className:`text-sm font-medium text-foreground`,children:e(`login.twoFactorAuthentication`,`Two-factor authentication`)})]}),v(`p`,{className:`text-xs text-foreground-subtle`,children:g?v(j,{children:v(Pc,{i18nKey:`login.finishSigningInAs`,values:{username:g},components:{mono:v(`span`,{className:`font-mono text-foreground`})}})}):e(`login.finishSigningInAs`,`Finish signing in.`)}),T&&v(`div`,{className:`rounded-md bg-danger/10 border border-danger/20 px-3 py-2 text-xs text-danger`,children:T}),P.includes(`passkey`)&&pe.map(e=>v(Bb,{method:e,challengeToken:M,onComplete:xe},e.id)),P.includes(`passkey`)&&L.map(e=>v(Xb,{method:e,config:{challengeToken:M,onComplete:xe}},e.id)),Wb(P,ue)&&v(`div`,{className:`rounded-md border border-border bg-background px-3 py-2 text-xs text-foreground-subtle`,children:e(`login.passkeyVerificationIsnTAvailable`,`Passkey verification isn't available on this address. Open the hub via its domain URL to complete sign-in.`)}),P.includes(`passkey`)&&P.includes(`totp`)&&s(`div`,{className:`flex items-center gap-3`,children:[v(`div`,{className:`h-px flex-1 bg-border`}),v(`span`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle`,children:`or`}),v(`div`,{className:`h-px flex-1 bg-border`})]}),P.includes(`totp`)&&s(`form`,{onSubmit:be,className:`space-y-4`,children:[s(`div`,{className:`space-y-1.5`,children:[v(`label`,{className:`text-xs font-medium text-foreground-subtle`,children:e(`login.authenticationCode`,`Authentication code`)}),v(U,{"data-testid":`login-totp`,type:`text`,inputMode:`numeric`,autoComplete:`one-time-code`,placeholder:`123456`,value:ee,onChange:e=>te(e.target.value.replace(/\D/g,``).slice(0,6)),className:`w-full rounded-lg border border-border bg-background px-3 py-3 text-center text-2xl font-mono tracking-widest text-foreground placeholder:text-foreground-disabled focus:border-primary focus:ring-1 focus:ring-primary/30 outline-none transition-all`,autoFocus:!0})]}),v(W,{variant:`unstyled`,"data-testid":`login-totp-submit`,type:`submit`,disabled:D||ee.length!==6,className:`w-full rounded-lg bg-primary px-4 py-2.5 text-sm font-semibold text-primary-foreground shadow-md shadow-primary/20 hover:shadow-lg hover:shadow-primary/30 disabled:opacity-50 disabled:shadow-none transition-all`,children:D?s(`span`,{className:`flex items-center justify-center gap-2`,children:[v(`span`,{className:`h-4 w-4 animate-spin rounded-full border-2 border-primary-foreground/30 border-t-primary-foreground`}),e(`login.verifying`,`Verifying...`)]}):e(`login.verifyAndSignIn`,`Verify and sign in`)})]}),s(W,{variant:`unstyled`,type:`button`,onClick:()=>{A(`credentials`),N(``),F([]),te(``),E(``)},className:`w-full flex items-center justify-center gap-1.5 text-xs text-foreground-subtle hover:text-foreground transition-colors`,children:[v(Ze,{className:`h-3 w-3`}),e(`login.backToUsernamePassword`,`Back to username + password`)]})]}),k===`credentials`&&se&&s(`p`,{"data-testid":`login-methods-pending`,role:`status`,className:`mt-4 flex items-center justify-center gap-2 text-xs text-foreground-subtle`,children:[v(`span`,{className:`h-3 w-3 animate-spin rounded-full border-2 border-foreground-subtle/30 border-t-foreground-subtle`}),e(`login.methodsPending`,`Loading other sign-in options...`)]}),k===`credentials`&&v(Yb,{methods:le,widgetConfig:{onComplete:xe,onSecondFactor:Ee,locale:a.language},onRedirect:Te}),v(`p`,{className:`mt-6 text-center text-[10px] text-foreground-subtle/50`,children:v(My,{placement:`login`})})]})}):v(`div`,{className:`flex min-h-screen items-center justify-center bg-background p-4`,children:s(`div`,{className:`w-full max-w-sm rounded-xl border border-border bg-surface p-6 text-center space-y-4`,children:[v(`h1`,{className:`text-sm font-semibold text-foreground`,children:e(`login.returningToTheApp`,`Returning to the app…`)}),me.failed?s(j,{children:[v(`p`,{className:`text-xs text-danger`,children:e(`login.couldNotPrepareTheSign`,`Could not prepare the sign-in handoff. You are logged in — retry below.`)}),v(W,{variant:`unstyled`,onClick:()=>void he(me.callbackBase),className:`inline-flex rounded-lg bg-primary px-4 py-2 text-sm font-medium text-primary-foreground hover:bg-primary/90`,children:e(`common.retry`,`Retry`)})]}):me.mintedUrl===null?v(`p`,{className:`text-xs text-foreground-subtle`,children:e(`login.preparingAOneTimeSign`,`Preparing a one-time sign-in code…`)}):s(j,{children:[v(`p`,{className:`text-xs text-foreground-subtle`,children:e(`login.ifTheAppDoesNot`,`If the app does not open automatically, tap below (the code expires in 60s).`)}),v(`a`,{href:me.mintedUrl,className:`inline-flex rounded-lg bg-primary px-4 py-2 text-sm font-medium text-primary-foreground hover:bg-primary/90`,children:e(`login.openDominevo`,`Open Dominevo`)})]})]})})}function vx(e){let t=new URLSearchParams(e).get(w_),n=new URLSearchParams({tab:`templates`});return t!==null&&n.set(w_,t),`/build?${n.toString()}`}function yx(){let{search:e}=mo();return v(Y,{to:vx(e),replace:!0})}T();function bx(){let{pathname:e,search:t,hash:n}=mo();return v(Y,{to:`${ab(e)}${t}${n}`,replace:!0})}function xx(){let{pathname:e,search:t}=mo();return v(Y,{to:uc(e,t)??`/archive`,replace:!0})}function Sx(){let{nodeId:e=``}=go();return v(Y,{to:`/system/terminal?tab=shells&node=${encodeURIComponent(e)}`,replace:!0})}function Cx(){let{pathname:e,search:t}=mo(),n=uc(e,t);return n===null?v(Nx,{}):v(Y,{to:n,replace:!0})}function wx(){return v(Y,{to:Cy()??`/devices`,replace:!0})}var Tx=m(()=>a(()=>import(`./Devices-NJ52UGWV.js`).then(e=>({default:e.DevicesPage})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12]),import.meta.url)),Ex=m(()=>a(()=>import(`./Integrations-B_Inbdpc.js`).then(e=>({default:e.IntegrationsPage})),__vite__mapDeps([13,1,2,3,4,5,14,6,15,7,8,9,11]),import.meta.url)),Dx=m(()=>a(()=>import(`./IntegrationDetail-CCyZhNWc.js`).then(e=>({default:e.IntegrationDetailPage})),__vite__mapDeps([16,1,2,3,4,5,17,6,7,18,14,9,10]),import.meta.url)),Ox=m(()=>a(()=>import(`./Pipeline-BGOu-2v_.js`).then(e=>({default:e.PipelinePage})),__vite__mapDeps([19,1,2,3,4,5,14,6,20,21,22,23,7,24,18,25,26,27,28,11]),import.meta.url)),kx=m(()=>a(()=>import(`./DeviceDetail-D7GFYFEm.js`).then(e=>({default:e.DeviceDetailPage})),__vite__mapDeps([29,1,2,3,4,5,14,6,20,30,31,32,33,34,23,35,7,36,22,37,38,39,40,41,42,43,26,44,45,28,11,46,47]),import.meta.url)),Ax=m(()=>a(()=>import(`./Showroom-CprRp6yl.js`).then(e=>({default:e.ShowroomPage})),__vite__mapDeps([48,1,2,3,4,5,18,14,6]),import.meta.url)),jx=m(()=>a(()=>import(`./EmbedPlayerPage-BKq1BRg_.js`).then(e=>({default:e.EmbedPlayerPage})),__vite__mapDeps([49,1,2,3,4,5,6]),import.meta.url)),Mx=m(()=>a(()=>import(`./EmbedDevicePage-F1NEkMUT.js`).then(e=>({default:e.EmbedDevicePage})),__vite__mapDeps([50,1,2,3,4,5,6,7,44,14,45]),import.meta.url)),Nx=m(()=>a(()=>import(`./Library-BJXSgpWZ.js`).then(e=>({default:e.LibraryPage})),__vite__mapDeps([51,1,2,3,4,5,14,6,20,52,22,53,7,54,55,56,46,45,57]),import.meta.url)),Px=m(()=>a(()=>import(`./Archive-5WNTy09R.js`).then(e=>({default:e.ArchivePage})),__vite__mapDeps([58,1,2,3,4,5,14,6,20,59,53,7,54,55,60,61,62,63,64,24,18,25,65,45,66,57,46]),import.meta.url)),Fx=m(()=>a(()=>import(`./Viewer-9ydpkUg6.js`).then(e=>({default:e.ViewerPage})),__vite__mapDeps([67,68,2,6]),import.meta.url)),Ix=m(()=>a(()=>import(`./Build-B6m8-obM.js`).then(e=>({default:e.BuildPage})),__vite__mapDeps([69,1,2,3,4,5,14,6,20,33,70,7,54,36,30,22,37,38,39,40,35,41,43,18,28,71]),import.meta.url)),Lx=m(()=>a(()=>import(`./CompositionEditorPage-MACY9CFt.js`).then(e=>({default:e.CompositionEditorPage})),__vite__mapDeps([72,1,2,3,4,5,6,7,8,36,14,20,30,22,37,38,39]),import.meta.url)),Rx=m(()=>a(()=>import(`./Locations-CEsFxXK8.js`).then(e=>({default:e.LocationsPage})),__vite__mapDeps([73,1,2,3,4,5,14,6,7,54,42,38,39]),import.meta.url)),zx=m(()=>a(()=>import(`./Addons-Ck90J9_n.js`).then(e=>({default:e.AddonsPage})),__vite__mapDeps([74,1,2,3,4,5,20,6,7,8,75,24,18,14,25,12,45]),import.meta.url)),Bx=m(()=>a(()=>import(`./AiProfiles-8UssQtkR.js`).then(e=>({default:e.AiProfilesPage})),__vite__mapDeps([76,1,2,3,4,5,14,6,77,78,7,8,54,63,64,24,18,25,65,45,66,79]),import.meta.url)),Vx=m(()=>a(()=>import(`./MyAccess-CAtcn_a3.js`).then(e=>({default:e.MyAccessPage})),__vite__mapDeps([80,1,2,3,4,5,14,6,20,81,35,7,8,54,82,44,45,66]),import.meta.url)),Hx=m(()=>a(()=>import(`./Logs-DrLmsP4V.js`).then(e=>({default:e.LogsPage})),__vite__mapDeps([83,1,2,3,4,5,23,84,6,7,8,54,63,64,24,18,14,25,65,45,66]),import.meta.url)),Ux=m(()=>a(()=>import(`./Identity-8tZo1PB_.js`).then(e=>({default:e.IdentityPage})),__vite__mapDeps([85,1,2,3,4,5,14,6,20,34,86,81,35,7,8,54,63,64,24,18,25,65,45,66,82,44,87]),import.meta.url)),Wx=m(()=>a(()=>import(`./Network-BUfXtVhQ.js`).then(e=>({default:e.NetworkPage})),__vite__mapDeps([88,1,2,3,4,5,14,6,20,89,7,8,54,63,64,24,18,25,65,45,66,90,91]),import.meta.url)),Gx=m(()=>a(()=>import(`./Integrations-D1Ybtztv.js`).then(e=>({default:e.IntegrationsPage})),__vite__mapDeps([92,1,2,3,4,5,6,7,54,63,64,24,18,14,25,65,45,66]),import.meta.url)),Kx=m(()=>a(()=>import(`./TrainingProviders-CGpG1PvO.js`).then(e=>({default:e.TrainingProvidersPage})),__vite__mapDeps([93,1,2,3,4,5,6,7,8,63,64,24,18,14,25,65,45,66]),import.meta.url)),qx=m(()=>a(()=>import(`./Data-B2mmPVLY.js`).then(e=>({default:e.DataPage})),__vite__mapDeps([94,1,2,3,4,5,14,6,20,31,95,62,7,8,54,63,64,24,18,25,65,45,66,60,61,57,46]),import.meta.url)),Jx=m(()=>a(()=>import(`./System-D3mpSwHc.js`).then(e=>({default:e.SystemPage})),__vite__mapDeps([96,1,2,3,4,5,14,6,97,7,8,54,87,18,25,45]),import.meta.url)),Yx=m(()=>a(()=>import(`./Cluster-CzmgBDwN.js`).then(e=>({default:e.ClusterPage})),__vite__mapDeps([98,1,2,3,4,5,14,6,62,99,35,7,8,75,43,24,18,25,27,57]),import.meta.url)),Xx=m(()=>a(()=>import(`./Terminal-Dqxv-P1E.js`).then(e=>({default:e.TerminalPage})),__vite__mapDeps([100,1,2,3,4,5,20,6,7,8,63,64,24,18,14,25,65,45,66,37,43,90,101]),import.meta.url)),Zx=m(()=>a(()=>import(`./Notifications-CrrX9yK9.js`).then(e=>({default:e.NotificationsPage})),__vite__mapDeps([102,1,2,3,4,5,14,6,77,103,7,8,54,63,64,24,18,25,65,45,66,43,56,71,41,79,39,47]),import.meta.url)),Qx=m(()=>a(()=>import(`./History-CqTLHyoj.js`).then(e=>({default:e.HistoryPage})),__vite__mapDeps([104,1,2,3,4,5,20,6,7,8]),import.meta.url)),$x=m(()=>a(()=>import(`./Jobs-BDZ-S8az.js`).then(e=>({default:e.JobsPage})),__vite__mapDeps([105,1,2,3,4,5,14,6,8]),import.meta.url)),eS=m(()=>a(()=>import(`./Calendars-BbmdZy07.js`).then(e=>({default:e.CalendarsPage})),__vite__mapDeps([106,1,2,3,4,5,14,6,7,8]),import.meta.url)),tS=new w({defaultOptions:{queries:{gcTime:0,staleTime:0,retry:!1,refetchOnWindowFocus:!1}}});no(tS);function nS({field:e,value:t,onChange:n,disabled:r}){return v(rg,{field:e,value:t,onChange:n,disabled:r})}var rS={"model-selector":nS};function iS({children:e}){let{t}=Z(),{user:n,logout:r}=os(),[i,a]=x(0),o=d(n?.username??null);y(()=>{let e=n?.username??null;e!==o.current&&(o.current=e,ms(),a(e=>e+1))},[n]);let c=f(()=>Zo(),[i]),l=_(()=>{Zo().reconnect(),a(e=>e+1),tS.invalidateQueries()},[]);Og(_(()=>ns(l),[l])),y(()=>cs(()=>{Zo().isSocketTokenStale()&&l()}),[l]);let u=_(async()=>{let e=await ts();return e&&l(),e},[l]),{bootReady:p,bootError:m}=Eg(c,n??null,r,u);return v(Cg,{children:v(fe,{system:c,children:v(gr.Provider,{client:c.trpcClient,queryClient:tS,children:s(Dr,{children:[v(Ha,{children:v(Ui,{children:v(Ra,{children:p?e:v(aS,{})})})}),p&&v(lg,{}),m!==null&&p&&s(`div`,{className:`fixed bottom-[calc(env(safe-area-inset-bottom)+1rem)] right-[calc(env(safe-area-inset-right)+1rem)] z-50 max-w-sm rounded-lg border border-warning/30 bg-warning/10 px-3 py-2 text-xs text-warning shadow-lg`,children:[t(`app.bootProbeFailed`,`Boot probe failed:`),` `,m,`. Retrying in background.`]})]})})})})}function aS(){let{t:e}=Z();return v(`div`,{className:`flex min-h-screen items-center justify-center bg-background`,children:s(`div`,{className:`flex items-center gap-3 text-sm text-foreground-subtle`,children:[v(`span`,{className:`h-4 w-4 animate-spin rounded-full border-2 border-primary/30 border-t-primary`}),e(`app.connecting`,`Connecting…`)]})})}function oS(){return v(`div`,{className:`flex min-h-screen items-center justify-center bg-background`,children:v(`span`,{className:`h-4 w-4 animate-spin rounded-full border-2 border-primary/30 border-t-primary`})})}function sS(){return y(()=>lb(),[]),v(Qa,{defaultMode:`dark`,children:v(ct,{children:v(A,{client:tS,children:v(ds,{children:v(iS,{children:v(Ye,{children:v(cg,{children:v(oi,{renderers:rS,children:s(ui,{picker:qf,children:[v(So,{basename:bt(),children:v(Zh,{children:v(g,{fallback:v(oS,{}),children:s(xo,{children:[v(J,{path:`/login`,element:v(_x,{})}),v(J,{path:`/admin/*`,element:v(bx,{})}),v(J,{path:`/admin`,element:v(bx,{})}),v(J,{path:`/change-password`,element:v($,{children:v(Rb,{})})}),v(J,{path:`/approve`,element:v($,{children:v(Mb,{})})}),v(J,{path:`/showroom`,element:v(Ax,{})}),v(J,{path:`/embed/player`,element:v(jx,{})}),v(J,{path:`/embed/device/:deviceId`,element:v($,{children:v(Mx,{})})}),s(J,{element:v($,{children:v($d,{children:v(Xy,{})})}),children:[v(J,{index:!0,element:v(wx,{})}),v(J,{path:`/access-denied`,element:v(ub,{})}),v(J,{path:`/dashboard`,element:v(Y,{to:`/devices`,replace:!0})}),v(J,{path:`/devices`,element:v(Tx,{})}),v(J,{path:`/cameras`,element:v(Y,{to:`/devices`,replace:!0})}),v(J,{path:`/integrations`,element:v(Ex,{})}),v(J,{path:`/integrations/:addonId`,element:v(Dx,{})}),v(J,{path:`/system/pipeline`,element:v(l_,{path:`/system/pipeline`,children:v(Ox,{})})}),v(J,{path:`/pipeline`,element:v(Y,{to:`/system/pipeline`,replace:!0})}),v(J,{path:`/live`,element:v(Fx,{})}),v(J,{path:`/devices/:deviceId`,element:v(kx,{})}),v(J,{path:`/system/logs`,element:v($,{requireAdmin:!0,children:v(Hx,{})})}),v(J,{path:`/system/addons`,element:v($,{requireAdmin:!0,children:v(zx,{})})}),v(J,{path:`/system/ai`,element:v($,{requireAdmin:!0,children:v(Bx,{})})}),v(J,{path:`/system/settings`,element:v($,{requireAdmin:!0,children:v(Jx,{})})}),v(J,{path:`/system/nodes`,element:v($,{requireAdmin:!0,children:v(Yx,{})})}),v(J,{path:`/system/notifications`,element:v($,{requireAdmin:!0,children:v(Zx,{})})}),v(J,{path:`/system/history`,element:v($,{requireAdmin:!0,children:v(Qx,{})})}),v(J,{path:`/system/jobs`,element:v($,{requireAdmin:!0,children:v($x,{})})}),v(J,{path:`/system/calendars`,element:v($,{requireAdmin:!0,children:v(eS,{})})}),v(J,{path:`/system/templates`,element:v(yx,{})}),v(J,{path:`/system/identity`,element:v($,{requireAdmin:!0,children:v(Ux,{})})}),v(J,{path:`/system/my-access`,element:v(Vx,{})}),v(J,{path:`/system/network`,element:v($,{requireAdmin:!0,children:v(Wx,{})})}),v(J,{path:`/training/providers`,element:v($,{requireAdmin:!0,children:v(Kx,{})})}),v(J,{path:`/system/integrations`,element:v($,{requireAdmin:!0,children:v(Gx,{})})}),v(J,{path:`/system/data`,element:v($,{requireAdmin:!0,children:v(qx,{})})}),v(J,{path:`/system`,element:v(Y,{to:fg,replace:!0})}),v(J,{path:`/system/terminal/:nodeId/*`,element:v(Sx,{})}),v(J,{path:`/system/terminal`,element:v($,{requireAdmin:!0,children:v(Xx,{})})}),v(J,{path:gg,element:v(yg,{})}),pg.map(e=>v(J,{path:e.path,element:v(vg,{tab:e.tab})},e.path)),v(J,{path:`/system/users`,element:v(Y,{to:`/system/identity?tab=users`,replace:!0})}),v(J,{path:`/system/api-keys`,element:v(Y,{to:`/system/identity?tab=api-keys`,replace:!0})}),v(J,{path:`/system/authentication`,element:v(Y,{to:nb(`authentication`),replace:!0})}),v(J,{path:`/system/linked-sessions`,element:v(Y,{to:`/system/identity?tab=linked-sessions`,replace:!0})}),v(J,{path:`/system/remote-access`,element:v(Y,{to:nb(`remoteAccess`),replace:!0})}),v(J,{path:`/system/turn`,element:v(Y,{to:nb(`turn`),replace:!0})}),v(J,{path:`/system/storage`,element:v(Y,{to:`/system/data?tab=storage`,replace:!0})}),v(J,{path:`/system/backup`,element:v(Y,{to:`/system/data?tab=backup`,replace:!0})}),v(J,{path:`/library`,element:v($,{requireAdmin:!0,children:v(Cx,{})})}),v(J,{path:`/retrain`,element:v(Y,{to:`/addon/training`,replace:!0})}),v(J,{path:`/archive`,element:v($,{requireAdmin:!0,children:v(Px,{})})}),v(J,{path:`/archive/:deviceId`,element:v(xx,{})}),v(J,{path:`/recordings`,element:v(xx,{})}),v(J,{path:`/build`,element:v($,{requireAdmin:!0,children:v(Ix,{})})}),v(J,{path:Ip,element:v($,{requireAdmin:!0,children:v(Lx,{})})}),v(J,{path:Lp,element:v($,{requireAdmin:!0,children:v(Lx,{})})}),v(J,{path:`/locations`,element:v($,{requireAdmin:!0,children:v(Rx,{})})}),v(J,{path:`/automation`,element:v(ig,{to:`/build`})}),v(J,{path:`/addon/:pagePath`,element:v($,{requireAdmin:!0,children:v(Qg,{})})}),v(J,{path:`*`,element:v(Y,{to:`/devices`,replace:!0})})]})]})})})}),v(Sg,{}),v(Js,{})]})})})})})})})})})}T(),window.__dominevoUiLibrary=ma,window.__dominevoSdk=Zr,window.__dominevoTypes=ln;var cS=po(document.getElementById(`root`));Lo(window.location.pathname,bt())?fx(cS):cS.render(v(S,{children:v(sS,{})}));export{Kp as $,Pc as $t,s_ as A,Md as At,_h as B,$u as Bt,$_ as C,Gd as Ct,M_ as D,Vd as Dt,A_ as E,zd as Et,kh as F,ld as Ft,Tm as G,Fu as Gt,mh as H,Mu as Ht,Dh as I,id as It,wm as J,rd as Jt,Em as K,Au as Kt,bh as L,Hu as Lt,_g as M,bd as Mt,sg as N,dd as Nt,w_ as O,kd as Ot,Gh as P,cd as Pt,rm as Q,dl as Qt,xh as R,Vu as Rt,Q_ as S,ef as St,k_ as T,Ud as Tt,Wm as U,ed as Ut,gh as V,xu as Vt,Dm as W,zu as Wt,cm as X,hl as Xt,fm as Y,yl as Yt,sm as Z,pl as Zt,Zv as _,yf as _t,eb as a,Ys as an,zp as at,qv as b,cf as bt,nb as c,Xs as cn,Ap as ct,Hy as d,kf as dt,rc as en,Rp as et,ay as f,Of as ft,Qv as g,hf as gt,Jv as h,bf as ht,$y as i,oc as in,Bp as it,fg as j,Ad as jt,T_ as k,jd as kt,rb as l,cp as lt,ty as m,Cf as mt,Eb as n,ic as nn,Up as nt,Zy as o,Qs as on,Wp as ot,ny as p,wf as pt,Om as q,Pu as qt,tb as r,ac as rn,Fp as rt,Qy as s,Zs as sn,Pp as st,Ab as t,nc as tn,Hp as tt,ib as u,Wf as ut,Bv as v,uf as vt,N_ as w,Wd as wt,tv as x,sf as xt,Iv as y,lf as yt,Ch as z,Bu as zt};
5
+ // here the editor could re-open this block and overwrite everything below.`;function O_(e){return e.includes(E_)}function k_(e){if(!O_(e))return!1;let t=nn(e);return!(t.status===`recipe`&&t.recipe.template?.templateId===`builtin:linked-trigger`)}function A_(e){return!O_(e.code)}function j_(e){let t=e.indexOf(E_);if(t<0)return null;let n=e.indexOf(`{`,t+25);if(n<0)return null;let r=0,i=!1,a=!1;for(let o=n;o<e.length;o+=1){let s=e.charAt(o);if(i){a?a=!1:s===`\\`?a=!0:s===`"`&&(i=!1);continue}if(s===`"`){i=!0;continue}if(s===`{`)r+=1;else if(s===`}`&&(--r,r===0))return{declStart:t,literalEnd:o+1,json:e.slice(n,o+1)}}return null}function M_(e){let t=j_(e);if(t===null)return{ok:!1,reason:X.t(`helpers.recipeFromCode.noLiteral`)};let n;try{n=JSON.parse(t.json)}catch(e){let t=e instanceof Error?e.message:String(e);return{ok:!1,reason:X.t(`helpers.recipeFromCode.badJson`,{detail:t})}}let r=fn.safeParse(n);if(!r.success){let e=r.error.issues[0];return{ok:!1,reason:e===void 0?X.t(`helpers.recipeFromCode.schemaMismatch`):X.t(`helpers.recipeFromCode.schemaMismatchAt`,{path:e.path.join(`.`),message:e.message})}}return{ok:!0,recipe:r.data}}function N_(e){let t=j_(e);if(t===null)return e;let n=e.slice(t.literalEnd),r=/^\s*as\s+const/.exec(n),i=t.literalEnd+(r===null?0:r[0].length);return`${e.slice(0,t.declStart)}${D_}${e.slice(i)}`}function P_(e,t,n){return`/build?tab=${e}&${t}=${encodeURIComponent(n)}`}function F_(e){return e??[]}function I_(e){let t=[];for(let n of e.blocks??[])if(O_(n.code)){if(!k_(n.code))continue;t.push({key:`automation:${n.id}`,domain:`automation`,label:n.name,keywords:F_(n.tags),path:P_(`automations`,`block`,n.id)})}else Rt(n)===`code`&&A_(n)&&t.push({key:`script:${n.id}`,domain:`script`,label:n.name,keywords:F_(n.tags),path:P_(`scripts`,`block`,n.id)});for(let n of e.schedulers??[])t.push({key:`scheduler:${n.id}`,domain:`scheduler`,label:n.name,keywords:F_(n.tags),path:P_(`schedulers`,`scheduler`,n.id)});for(let n of e.actions??[])t.push({key:`action:${n.id}`,domain:`action`,label:n.name,keywords:F_(n.tags),path:P_(`actions`,`action`,n.id)});for(let n of e.templates??[])t.push({key:`template:${n.id}`,domain:`template`,label:n.name,subtitle:n.kind,keywords:F_(n.tags),path:T_(n.id)});for(let n of e.compositions??[])t.push({key:`customDevice:${n.block.id}`,domain:`customDevice`,label:n.block.name,keywords:F_(n.block.tags),path:Vp(n.block.id)});return t}T();var L_={device:{labelKey:`search.resultsList.devices`,icon:xe},page:{labelKey:`search.resultsList.pages`,icon:vn},integration:{labelKey:`search.resultsList.integrations`,icon:te},automation:{labelKey:`search.resultsList.automations`,icon:ht},script:{labelKey:`search.resultsList.scripts`,icon:En},scheduler:{labelKey:`search.resultsList.schedulers`,icon:de},action:{labelKey:`search.resultsList.actions`,icon:qe},template:{labelKey:`search.resultsList.templates`,icon:On},customDevice:{labelKey:`search.resultsList.customDevices`,icon:je}};function R_({groups:e,activeKey:t,query:n,totalMatched:r,truncated:i,pending:a=!1,onSelect:o,onHover:c}){let{t:l}=Z(),u=d(null);if(y(()=>{t&&(u.current?.querySelector(`[data-key="${CSS.escape(t)}"]`))?.scrollIntoView({block:`nearest`})},[t]),n.trim().length===0)return null;if(e.length===0&&a)return v(`div`,{role:`status`,className:`px-3 py-4 text-center text-[12px] text-foreground-subtle`,"data-testid":`search-pending`,children:l(`search.resultsList.searching`,`Searching…`)});if(e.length===0)return v(`div`,{className:`px-3 py-4 text-center text-[12px] text-foreground-subtle`,children:l(`search.resultsList.noResults`,{query:n})});let f=e.reduce((e,t)=>e+t.items.length,0);return s(j,{children:[v(`div`,{ref:u,role:`listbox`,className:`max-h-[60vh] overflow-y-auto py-1`,children:e.map(e=>{let n=L_[e.domain],r=n.icon;return s(`div`,{className:`px-1 py-1`,children:[s(`div`,{className:`sticky top-0 z-10 flex items-center gap-1.5 bg-surface px-2 py-1 text-[10px] font-semibold uppercase tracking-widest text-foreground-subtle/60`,children:[v(r,{className:`h-3 w-3`}),l(n.labelKey)]}),e.items.map(e=>{let r=e.icon??n.icon,i=e.key===t;return s(W,{variant:`unstyled`,type:`button`,role:`option`,"aria-selected":i,"data-key":e.key,onMouseEnter:()=>c(e),onClick:()=>o(e),className:`flex w-full items-center gap-2.5 rounded-md px-2 py-1.5 text-left text-[12px] transition-colors ${i?`bg-primary/12 text-primary`:`text-foreground hover:bg-surface-hover`}`,children:[v(r,{className:`h-3.5 w-3.5 shrink-0 ${i?`text-primary`:`text-foreground-subtle`}`}),s(`span`,{className:`flex-1 min-w-0`,children:[v(`span`,{className:`block truncate font-medium`,children:e.label}),e.subtitle&&v(`span`,{className:`block truncate text-[10px] text-foreground-subtle`,children:e.subtitle})]})]},e.key)})]},e.domain)})}),i&&v(`div`,{className:`border-t border-border px-3 py-1.5 text-center text-[10px] text-foreground-subtle`,children:l(`search.truncatedResults`,`Showing first {{shown}} of {{total}} — refine your search.`,{shown:f,total:r})})]})}T(),uo();function z_({navSections:e,addonPages:t,compact:n,onNavigated:r,floating:i=!1,request:a=null}){let{t:o}=Z(),c=_o(),l=d(null),u=d(null),p=d(null),[m,h]=x(null),[g,b]=x(``),[S,C]=x(0),[w,T]=x(!1),{data:E}=Mr({projection:`slim`}),{data:D}=Sa(void 0),O=w&&g.trim().length>0,k={enabled:O},A=nr({},k),j=Ci({},k),M=xa({},k),N=aa({},k),P=Ar({},k),F=O&&[A,j,M,N,P].some(e=>e.isLoading),ee=f(()=>{let n={detection:o(`nav.detectionSection`,`Detection`),cluster:o(`nav.clusterSection`,`Cluster`),administration:o(`system.title`,`Administration`),ungrouped:o(`nav.addonPages`,`Addon Pages`)};return[...b_(E??[],D??null),...C_(e,t,n),...x_(D??[]),...I_({blocks:A.data?.blocks,actions:j.data,schedulers:M.data,templates:N.data,compositions:P.data?.state===`loaded`?P.data.views:void 0})]},[E,D,e,t,o,A.data,j.data,M.data,N.data,P.data]),{groups:te,totalMatched:ne,truncated:re}=f(()=>g_(ee,g),[ee,g]),ie=f(()=>__(te),[te]);y(()=>{C(0)},[g,ee]),y(()=>{w&&l.current?.focus()},[w]);let oe=a?.id,se=a?.query;y(()=>{oe!==void 0&&(b(se??``),T(!0))},[oe,se]);let ce=_(()=>{T(!1),b(``),C(0)},[]),le=_(e=>{c(e.path),ce(),l.current?.blur(),r?.()},[c,ce,r]);ae(l,{scope:be}),y(()=>{if(!w)return;function e(e){if(!(e.target instanceof Node))return;let t=u.current?.contains(e.target)===!0,n=p.current?.contains(e.target)===!0;!t&&!n&&T(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[w]);let ue=w&&g.trim().length>0;y(()=>{if(!ue){h(null);return}let e=()=>{let e=l.current?.getBoundingClientRect();e&&h({left:e.left,top:e.bottom+4,width:e.width})};return e(),window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},[ue]);let de=ie[S]?.key??null,fe=o(`search.placeholder`,`Search devices, pages, automations, scripts…`),pe=s(`div`,{className:`relative`,children:[v(ft,{className:`pointer-events-none absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-foreground-subtle`}),v(U,{ref:l,type:`text`,value:g,placeholder:fe,"aria-label":fe,role:`combobox`,"aria-expanded":w&&g.trim().length>0,"aria-controls":`global-search-results`,onChange:e=>{b(e.target.value),T(!0)},onFocus:()=>T(!0),onKeyDown:e=>{if(e.key===`ArrowDown`)e.preventDefault(),ie.length>0&&C(e=>(e+1)%ie.length);else if(e.key===`ArrowUp`)e.preventDefault(),ie.length>0&&C(e=>(e-1+ie.length)%ie.length);else if(e.key===`Enter`){e.preventDefault();let t=ie[S];t&&le(t)}else e.key===`Escape`&&(e.preventDefault(),ce(),l.current?.blur())},className:`w-full rounded-md border border-border bg-surface py-1.5 pl-7 pr-6 text-[12px] text-foreground placeholder:text-foreground-subtle/70 focus:outline-none focus:ring-1 focus:ring-primary/50`}),g.length>0&&v(W,{variant:`unstyled`,type:`button`,"aria-label":o(`search.globalSearch.clearSearch`,`Clear search`),onClick:()=>{b(``),l.current?.focus()},className:`absolute right-1.5 top-1/2 -translate-y-1/2 text-foreground-subtle hover:text-foreground`,children:v(I,{className:`h-3 w-3`})}),ue&&m!==null&&fo(v(`div`,{ref:p,id:`global-search-results`,className:`fixed z-50 w-max max-w-[26rem] rounded-lg border border-border bg-surface shadow-xl`,style:{left:m.left,top:m.top,minWidth:m.width},children:v(R_,{groups:te,activeKey:de,query:g,totalMatched:ne,truncated:re,pending:F,onSelect:le,onHover:e=>{let t=ie.findIndex(t=>t.key===e.key);t>=0&&C(t)}})}),document.body)]});return i?w?v(`div`,{ref:u,className:`fixed inset-x-2 top-[calc(env(safe-area-inset-top)+0.5rem)] z-50 mx-auto max-w-[26rem]`,children:pe}):null:n?v(`div`,{ref:u,className:`px-1.5 pb-1.5`,children:w?v(`div`,{className:`fixed z-50 w-max min-w-72 max-w-[26rem]`,style:{left:`calc(env(safe-area-inset-left) + 3.5rem)`,top:`calc(env(safe-area-inset-top) + 3.5rem)`},children:pe}):v(W,{variant:`unstyled`,type:`button`,onClick:()=>T(!0),"aria-label":fe,title:fe,className:`flex w-full items-center justify-center rounded-md px-0 py-2 text-foreground-subtle hover:bg-surface-hover hover:text-foreground transition-colors`,children:v(ft,{className:`h-3.5 w-3.5 shrink-0`})})}):v(`div`,{ref:u,className:`px-2 pb-2`,children:pe})}var B_=/^(\d{1,3}\.){3}\d{1,3}$/;function V_(e){let t=e.startsWith(`[`)&&e.endsWith(`]`)?e.slice(1,-1):e;return!!(B_.test(t)||t.includes(`:`))}function H_(e,t){return!t||V_(e)?!1:e===t||e.endsWith(`.${t}`)}T();var U_=`auth-webauthn/passkey-enrollment`,W_=`dominevo_passkey_prompt_dismissed:`,G_=720*60*60*1e3;function K_(e){try{let t=localStorage.getItem(`${W_}${e}`);if(!t)return!1;let n=Number(t);return Number.isFinite(n)?Date.now()-n<G_:!1}catch{return!1}}function q_(e){try{localStorage.setItem(`${W_}${e}`,String(Date.now()))}catch{}}function J_(){let{user:e}=os(),{t}=Z(),n=G(),r=io(U_),[i,a]=x(!1),[o,c]=x(!1),l=f(()=>e?K_(e.id):!0,[e]),u=gr.auth.listLoginMethods.useQuery().data?.find(e=>e.kind===`passkey`),d=u!==void 0&&H_(window.location.hostname,u.rpId),p=e!==null&&d&&r!=null&&!l,m=C({queryKey:[`auth`,`listOwnPasskeys`],queryFn:()=>n.listOwnPasskeys(),enabled:p,staleTime:6e4}),h=_(()=>{e&&q_(e.id),a(!0),c(!1)},[e]),g=_(()=>{c(!1),m.refetch()},[m]);return!p||i||m.data===void 0||m.data.length>0?null:s(`div`,{className:`shrink-0 border-b border-primary/20 bg-primary/5`,children:[s(`div`,{className:`flex items-center gap-2.5 px-3 py-2 text-xs text-foreground`,children:[v(_n,{className:`h-4 w-4 text-primary shrink-0`}),v(`span`,{className:`flex-1 min-w-0`,children:t(`passkeyPrompt.message`,`Save a passkey for faster sign-in?`)}),v(W,{variant:`unstyled`,onClick:()=>c(e=>!e),className:`rounded bg-primary px-2.5 py-1 text-[11px] font-semibold text-primary-foreground hover:bg-primary/90`,children:t(`passkeyPrompt.enrollNow`,`Enroll now`)}),v(W,{variant:`unstyled`,onClick:h,className:`inline-flex items-center gap-1 rounded border border-border px-2 py-1 text-[11px] text-foreground-subtle hover:text-foreground hover:bg-surface-hover`,children:t(`passkeyPrompt.notNow`,`Not now`)}),v(W,{variant:`unstyled`,onClick:h,"aria-label":t(`passkeyPrompt.notNow`,`Not now`),className:`p-1 rounded text-foreground-subtle hover:text-foreground`,children:v(I,{className:`h-3.5 w-3.5`})})]}),o&&v(`div`,{className:`px-3 pb-3`,children:s(`div`,{className:`max-w-xl`,children:[v(hi,{widgetId:U_,host:`dashboard`}),v(`div`,{className:`mt-2 flex justify-end`,children:v(W,{variant:`unstyled`,onClick:g,className:`rounded border border-border px-2.5 py-1 text-[11px] text-foreground-subtle hover:text-foreground hover:bg-surface-hover`,children:t(`common.close`,`Close`)})})]})})]})}var Y_=`system-config`,X_=[`system-config`,`bootstrap-form`];function Z_(e){return typeof e==`object`&&!!e&&`sections`in e&&Array.isArray(e.sections)}function Q_(){let e=G();return C({queryKey:X_,queryFn:async()=>{let t=await e.trpcClient.addons.custom.mutate({addonId:Y_,action:`getBootstrapForm`,input:{}});if(!Z_(t))throw Error(`The hub did not return the settings form`);return t}})}function $_(){let e=G(),t=O(),n=k({mutationFn:async t=>{await e.trpcClient.addons.custom.mutate({addonId:Y_,action:`saveBootstrapForm`,input:t})},onSuccess:()=>Promise.all([t.invalidateQueries({queryKey:X_}),t.invalidateQueries({queryKey:[[`system`,`info`]]})])});return{mutateAsync:n.mutateAsync,isPending:n.isPending}}var ev=6e4;function tv(){let e=$r(void 0,{staleTime:ev});return{info:e.data?.serverName??null,isLoading:e.isLoading}}T();var nv=`dominevo_server_name_prompt_dismissed`;function rv(){try{return sessionStorage.getItem(nv)===`1`}catch{return!1}}function iv(){try{sessionStorage.setItem(nv,`1`)}catch{}}function av(e){return e.isAdmin&&e.info!==null&&e.info.isDefault&&!e.dismissed}function ov(){let{user:e}=os(),{info:t}=tv(),[n,r]=x(rv);return av({isAdmin:e?.isAdmin===!0,info:t,dismissed:n})?v(sv,{suggestion:t?.name??``,onLater:()=>{iv(),r(!0)}}):null}function sv({suggestion:e,onLater:t}){let{t:n}=Z(),r=O(),i=$_(),[a,o]=x(e),[c,l]=x(null),u=d(null);y(()=>u.current?.focus(),[]);let f=_(async()=>{let e=cn.safeParse(a);if(!e.success){l(e.error.issues[0]?.message??n(`serverName.invalid`,`Not a valid name`));return}l(null);try{await i.mutateAsync({patch:{name:e.data}}),await r.invalidateQueries({queryKey:[[`system`,`info`]]})}catch(e){l(e instanceof Error&&e.message.length>0?e.message:`Could not save`)}},[r,i,n,a]);return v(Nn,{open:!0,onOpenChange:e=>!e&&t(),children:v(Na,{children:s(`form`,{onSubmit:e=>{e.preventDefault(),i.isPending||f()},children:[s($i,{children:[v(Ti,{children:n(`serverName.title`,`Name this server`)}),v(ha,{children:n(`serverName.description`,`Pick a name for this hub. It shows in the admin UI and on the apps’ sign-in screen. You can change it later in System settings.`)})]}),v(Li,{children:v(Ma,{label:n(`serverName.label`,`Server name`),...c===null?{}:{error:c},children:v(U,{ref:u,value:a,maxLength:48,onChange:e=>o(e.target.value),state:c===null?`default`:`error`,"aria-label":n(`serverName.label`,`Server name`)})})}),s(Ta,{children:[v(W,{type:`button`,variant:`ghost`,onClick:t,disabled:i.isPending,children:n(`serverName.later`,`Later`)}),s(W,{type:`submit`,disabled:i.isPending||a.trim().length===0,children:[i.isPending&&v(H,{className:`h-4 w-4 animate-spin`}),n(`common.save`,`Save`)]})]})]})})})}var cv=4,lv=160,uv=320,dv=`env(safe-area-inset-top)`,fv=`env(safe-area-inset-bottom)`;function pv(e){let{rect:t,viewportWidth:n,viewportHeight:r}=e,i=Math.min(uv,n-16),a={position:`fixed`,left:Math.max(8,Math.min(t.left,n-8-i)),width:i,zIndex:9999};if(r-t.bottom>=t.top){let e=`max(${t.bottom+cv}px, calc(${dv} + 8px))`;return{...a,top:e,maxHeight:`max(${lv}px, calc(100dvh - ${e} - ${fv} - 8px))`}}let o=`max(${r-t.top+cv}px, calc(${fv} + 8px))`;return{...a,bottom:o,maxHeight:`max(${lv}px, calc(100dvh - ${o} - ${dv} - 8px))`}}var mv=!1;function hv(){return mv}function gv(){mv=!0}function _v(e){return!e.read&&e.severity===`critical`}function vv(e){return e.filter(_v)}function yv(e){return e!==void 0&&typeof e.href==`string`&&e.href.length>0}function bv(e){return yv(e)||e!==void 0&&e.invoke!==void 0}var xv=/^\/addon\/[^/?#]+\/oauth\//;function Sv(e){return e.navigation===void 0?xv.test(e.href):e.navigation===`server`}function Cv(e){let t=e.action;if(bv(t)&&!(t.invoke!==void 0&&(e.status===`completed`||e.status===`dismissed`)))return t}T();function wv({action:e,className:t,onActivate:n}){let r=O(),i=G(),{t:a}=Z(),[o,c]=x(!1),[l,u]=x(null);if(e.invoke!==void 0){let{addonId:d,action:f,input:p}=e.invoke;return s(`span`,{className:`inline-flex flex-col items-start gap-0.5`,children:[v(`button`,{type:`button`,className:t,disabled:o,onClick:e=>{e.preventDefault(),n?.(e),c(!0),u(null),i.trpcClient.addons.custom.mutate({addonId:d,action:f,input:p}).then(()=>r.invalidateQueries({queryKey:[[`alerts`]]})).catch(e=>u(e instanceof Error?e.message:String(e))).finally(()=>c(!1))},children:o?a(`ui.alertAction.running`,`Working…`):e.label}),l!==null&&v(`span`,{role:`alert`,className:`text-[10px] text-destructive`,children:l})]})}return yv(e)?Sv(e)?v(`a`,{href:V(e.href),className:t,onClick:t=>{t.preventDefault(),n?.(t),Wo(e.href,()=>{r.invalidateQueries({queryKey:[[`alerts`]]}),r.invalidateQueries({queryKey:[[`broker`]]}),r.invalidateQueries({queryKey:[[`recordEntries`]]})})},children:e.label}):v(vo,{to:e.href,className:t,onClick:n,children:e.label}):v(j,{})}T(),uo();var Tv={info:ut,success:Ve,warning:He,error:Ue,critical:B},Ev={info:`text-info`,success:`text-success`,warning:`text-warning`,error:`text-danger`,critical:`text-danger`},Dv={active:`border-l-info`,"in-progress":`border-l-warning`,completed:`border-l-success`,failed:`border-l-danger`,dismissed:`border-l-foreground-subtle/30`};function Ov(e){let t=Math.floor((Date.now()-e)/1e3);if(t<60)return X.t(`helpers.relativeTime.justNow`);let n=Math.floor(t/60);if(n<60)return X.t(`helpers.relativeTime.minutesAgo`,{count:n});let r=Math.floor(n/60);if(r<24)return X.t(`helpers.relativeTime.hoursAgo`,{count:r});let i=Math.floor(r/24);return X.t(`helpers.relativeTime.daysAgo`,{count:i})}function kv(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Av(e){return typeof e==`string`&&e.length>0?e:void 0}function jv(e){if(kv(e.metadata)){let t=Av(e.metadata.nodeId)??Av(e.metadata.agentId);if(t!==void 0)return t}let t=e.source;if(t!==void 0&&!(t.type!==`node`&&t.type!==`agent`))return Av(t.id)}function Mv({alert:e,onMarkRead:t,onDismiss:n}){let{t:r}=Z(),i=e.severity in Tv?e.severity:`info`,a=Cv(e),o=e.status in Dv?e.status:`active`,c=Tv[i],l=Ev[i],u=Dv[o],{nodes:d}=ra(),f=jv(e),p=f===void 0?void 0:d.find(e=>e.id===f),m=f===void 0?void 0:p?.name??f;return s(`div`,{className:`flex items-start gap-2.5 px-3 py-2.5 border-l-2 ${u} ${e.read?`opacity-60`:``} hover:bg-surface-hover transition-colors`,children:[v(c,{className:`h-3.5 w-3.5 shrink-0 mt-0.5 ${l}`}),s(`div`,{className:`flex-1 min-w-0`,children:[s(`div`,{className:`flex items-center gap-1.5`,children:[v(`span`,{className:`text-[11px] font-semibold ${e.read?`text-foreground-subtle`:`text-foreground`}`,children:e.title}),!e.read&&v(`span`,{className:`h-1.5 w-1.5 rounded-full bg-primary shrink-0`})]}),m!==void 0&&v(`div`,{className:`text-foreground-subtle text-[10px] mt-0.5 truncate`,children:m}),v(`div`,{className:`text-[10px] text-foreground-subtle mt-0.5 line-clamp-2`,children:e.message}),a!==void 0&&v(wv,{action:a,className:`inline-flex mt-1.5 items-center rounded-md bg-primary px-2 py-0.5 text-[10px] font-medium text-primary-foreground hover:bg-primary/90 transition-colors`,onActivate:e=>e.stopPropagation()}),e.status===`in-progress`&&e.progress!==void 0&&s(`div`,{className:`mt-1.5 flex items-center gap-2`,children:[v(`div`,{className:`flex-1 h-1 bg-surface-hover rounded-full overflow-hidden`,children:v(`div`,{className:`h-full bg-primary rounded-full transition-all duration-300`,style:{width:`${String(Math.min(100,Math.max(0,e.progress)))}%`}})}),s(`span`,{className:`text-[9px] text-foreground-subtle font-mono shrink-0`,children:[String(Math.round(e.progress)),`%`]})]}),v(`div`,{className:`text-[9px] text-foreground-subtle/60 mt-1`,children:Ov(e.updatedAt)})]}),s(`div`,{className:`flex items-center gap-0.5 shrink-0`,children:[!e.read&&v(W,{variant:`unstyled`,type:`button`,onClick:n=>{n.stopPropagation(),t(e.id)},className:`p-1 rounded hover:bg-surface-hover transition-colors`,title:r(`ui.alertBell.markAsRead`,`Mark as read`),children:v(_e,{className:`h-3 w-3 text-foreground-subtle`})}),e.status!==`in-progress`&&v(W,{variant:`unstyled`,type:`button`,onClick:t=>{t.stopPropagation(),n(e.id)},className:`p-1 rounded hover:bg-surface-hover transition-colors`,title:r(`ui.alertBell.dismiss`,`Dismiss`),children:v(I,{className:`h-3 w-3 text-foreground-subtle`})})]})]})}function Nv({variant:e=`icon`,compact:t=!1}={}){let{t:n}=Z(),[r,i]=x(!1),[a,o]=x(!1),c=d(null),l=d(null),u=O(),{data:f=0}=Hr(void 0,{refetchInterval:3e4}),{data:p=[],isLoading:m}=Pn({limit:50},{enabled:r}),h=a?p:p.filter(e=>!e.read),g=p.filter(e=>e.read).length,b=()=>{u.invalidateQueries({queryKey:[[`alerts`]]})},S=Fa({onSuccess:b}),C=Bi({onSuccess:b}),w=_i({onSuccess:b});$n(`alert.created`,()=>{u.invalidateQueries({queryKey:[[`alerts`]]})}),$n(`alert.updated`,()=>{u.invalidateQueries({queryKey:[[`alerts`]]})}),y(()=>{if(!r)return;let e=e=>{let t=e.target;c.current&&!c.current.contains(t)&&l.current&&!l.current.contains(t)&&i(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`touchstart`,e),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`touchstart`,e)}},[r]);let T=_(e=>{S.mutate({alertId:e})},[S]),E=_(e=>{e&&w.mutate({alertId:e})},[w]),D=_(()=>{C.mutate(void 0),i(!1)},[C]),k=h.filter(_v),A=new Set(k.map(e=>e.id)),j=h.filter(e=>e.status===`in-progress`&&!A.has(e.id)),M=h.filter(e=>e.status!==`in-progress`&&!A.has(e.id)),[N,P]=x({}),F=_(()=>{let e=l.current;e&&P(pv({rect:e.getBoundingClientRect(),viewportWidth:window.innerWidth,viewportHeight:window.innerHeight}))},[]);return y(()=>{if(!r)return;F();let e=()=>F();return window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},[r,F]),s(`div`,{children:[e===`sidebar`?s(W,{variant:`unstyled`,ref:l,type:`button`,onClick:()=>i(!r),className:`flex w-full items-center gap-2.5 rounded-md ${t?`justify-center px-0 py-2`:`px-2.5 py-1.5`} text-[12px] text-foreground-subtle hover:bg-surface-hover hover:text-foreground transition-colors`,title:t?f>0?n(`ui.alertBell.alertsUnread`,{count:f}):n(`ui.alertBell.alerts`):void 0,children:[s(`span`,{className:`relative inline-flex shrink-0`,children:[v(vt,{className:`h-3.5 w-3.5`}),t&&f>0&&v(`span`,{className:`absolute -top-1 -right-1 h-2 w-2 rounded-full bg-primary`})]}),!t&&v(`span`,{className:`flex-1 text-left`,children:n(`ui.alertBell.alerts`,`Alerts`)}),!t&&f>0&&v(`span`,{className:`flex items-center justify-center h-4 min-w-4 px-1 rounded-full bg-primary text-primary-foreground text-[9px] font-bold leading-none`,children:f>99?`99+`:String(f)})]}):s(W,{variant:`unstyled`,ref:l,type:`button`,onClick:()=>i(!r),className:`relative p-1.5 rounded-md hover:bg-surface-hover text-foreground-subtle hover:text-foreground transition-colors`,"aria-label":n(`ui.alertBell.alerts`,`Alerts`),children:[v(vt,{className:`h-4.5 w-4.5`}),f>0&&v(`span`,{className:`absolute -top-0.5 -right-0.5 flex items-center justify-center h-4 min-w-4 px-0.5 rounded-full bg-primary text-primary-foreground text-[9px] font-bold leading-none`,children:f>99?`99+`:String(f)})]}),r&&fo(s(`div`,{ref:c,style:N,className:`bg-surface border border-border rounded-lg shadow-xl flex flex-col overflow-hidden`,children:[s(`div`,{className:`flex items-center justify-between px-3 py-2 border-b border-border shrink-0`,children:[v(`span`,{className:`text-[12px] font-semibold text-foreground`,children:n(`ui.alertBell.alerts`,`Alerts`)}),s(`div`,{className:`flex items-center gap-2`,children:[g>0&&s(`label`,{className:`flex items-center gap-1 text-[10px] text-foreground-subtle cursor-pointer select-none`,children:[v(Dt,{checked:a,onChange:e=>o(e.target.checked),className:`h-3 w-3 rounded border-border accent-primary cursor-pointer`}),n(`ui.alertBell.showRead`,`Show read`)]}),f>0&&s(W,{variant:`unstyled`,type:`button`,onClick:D,className:`flex items-center gap-1 text-[10px] text-primary hover:text-primary/80 transition-colors`,children:[v(Cn,{className:`h-3 w-3`}),n(`ui.alertBell.markAllRead`,`Mark all read`)]})]})]}),s(`div`,{className:`flex-1 overflow-y-auto`,children:[m&&v(`div`,{className:`flex items-center justify-center py-8`,children:v(H,{className:`h-4 w-4 animate-spin text-foreground-subtle`})}),!m&&h.length===0&&s(`div`,{className:`flex flex-col items-center justify-center py-8 text-foreground-subtle`,children:[v(vt,{className:`h-6 w-6 mb-2 opacity-40`}),v(`span`,{className:`text-[11px]`,children:p.length>0?n(`ui.alertBell.noUnreadAlerts`,`No unread alerts`):n(`ui.alertBell.noAlerts`,`No alerts`)}),p.length>0&&!a&&v(W,{variant:`unstyled`,type:`button`,onClick:()=>o(!0),className:`text-[10px] text-primary mt-1 hover:underline`,children:n(`ui.alertBell.showRead`,{count:g})})]}),k.length>0&&s(`div`,{className:`border-b border-border`,children:[v(`div`,{className:`px-3 py-1.5 bg-danger/5`,children:v(`span`,{className:`text-[9px] font-semibold uppercase tracking-widest text-danger`,children:n(`ui.alertBell.urgent`,`Urgent`)})}),k.map(e=>v(Mv,{alert:e,onMarkRead:T,onDismiss:E},e.id))]}),j.length>0&&s(`div`,{className:`border-b border-border`,children:[v(`div`,{className:`px-3 py-1.5 bg-surface-hover/50`,children:v(`span`,{className:`text-[9px] font-semibold uppercase tracking-widest text-foreground-subtle/60`,children:n(`ui.alertBell.inProgress`,`In Progress`)})}),j.map(e=>v(Mv,{alert:e,onMarkRead:T,onDismiss:E},e.id))]}),M.map(e=>v(Mv,{alert:e,onMarkRead:T,onDismiss:E},e.id))]})]}),document.body)]})}var Pv={queued:`neutral`,running:`info`,done:`success`,failed:`danger`,cancelled:`warning`};function Fv(e){return Pv[e]}function Iv(e){return`activity.state.${e}`}function Lv(e){return e.state===`queued`||e.state===`running`}function Rv(e){let t=e.progress;if(t===null)return e.state===`running`?{kind:`indeterminate`,done:null,unit:null}:{kind:`none`};if(t.total===null||t.total<=0)return{kind:`indeterminate`,done:t.done,unit:t.unit};let n=Math.min(100,Math.max(0,t.done/t.total*100));return{kind:`determinate`,done:t.done,total:t.total,unit:t.unit,percent:n}}function zv(e,t=e=>e){return e.kind===`none`?null:e.kind===`indeterminate`?e.done===null?null:`${String(e.done)} ${t(e.unit??``,e.done)}`.trim():`${String(e.done)} / ${String(e.total)} ${t(e.unit,e.total)}`.trim()}function Bv(e){return`activity.kind.${e.kind.replaceAll(`.`,`_`)}`}var Vv={"not-found":`activity.cancelRefused.notFound`,"not-cancellable":`activity.cancelRefused.notCancellable`,terminal:`activity.cancelRefused.terminal`,"not-allowed":`activity.cancelRefused.notAllowed`,"producer-refused":`activity.cancelRefused.producerRefused`,"producer-unreachable":`activity.cancelRefused.producerUnreachable`};function Hv(e){return e===null?`activity.cancelRefused.unknown`:Vv[e]}function Uv(e){return e.cancellable&&Lv(e)}function Wv(e){return!Lv(e)}function Gv(e){return e.ownerUserId===`system`}function Kv(e){return e==null?0:e.running+(e.unseenFinished??0)}function qv(e){return[...e].sort((e,t)=>{let n=Number(Lv(t))-Number(Lv(e));return n===0?t.createdAt-e.createdAt:n})}T();function Jv({id:e,title:t,icon:n,description:r,actions:i,tone:a=`default`,notice:o=null,onDismissNotice:c,children:l}){return v(or,{headingId:`access-${e}`,title:t,icon:n,actions:i,testId:`access-${e}`,children:s(`div`,{className:`${ne} space-y-3`,children:[v(`div`,{className:ee(`text-[11px] leading-relaxed`,a===`danger`?`rounded-md border border-danger/30 bg-danger/5 px-3 py-2 text-foreground`:`text-foreground-subtle`),children:r}),o!==null&&v(Xv,{notice:o,onDismiss:c}),l]})})}var Yv={success:{icon:Ve,line:`border-success/30 text-foreground`,mark:`text-success`},danger:{icon:B,line:`border-danger/40 text-danger`,mark:`text-danger`}};function Xv({notice:e,onDismiss:t}){let{t:n}=Z(),r=Yv[e.tone],i=r.icon;return s(`div`,{role:e.tone===`danger`?`alert`:`status`,className:ee(`flex items-start gap-2 rounded-md border bg-surface px-3 py-2 text-[11px]`,r.line),children:[v(i,{className:ee(`mt-0.5 h-3.5 w-3.5 shrink-0`,r.mark),"aria-hidden":!0}),v(`span`,{className:`min-w-0 flex-1`,children:e.message}),t!==void 0&&v(pa,{type:`button`,variant:`ghost`,size:`sm`,icon:I,"aria-label":n(`access.accessSection.dismiss`,`Dismiss`),onClick:t,className:`-my-1 h-5 w-5`})]})}function Zv(){let{data:e}=Sr();return f(()=>{let t=new Map;for(let n of e??[])t.set(n.id,n.username);return t},[e])}function Qv(e,t=null){return e===null?t:{tone:`danger`,message:e}}T();function $v(e){let{t}=Z();return t(Bv(e),{defaultValue:e.kind})}function ey(e){let{t}=Z(),n=$v(e);return X.exists(e.titleKey)?t(e.titleKey,e.titleParams):n}function ty({state:e}){let{t}=Z();return v(jn,{variant:Fv(e),className:`text-[10px]`,children:t(Iv(e))})}function ny({job:e}){let t=Rv(e),{t:n}=Z(),r=zv(t,(e,t)=>n(`activity.unit.${e}`,{count:t,defaultValue:e}));return t.kind===`none`?null:s(`div`,{className:`flex items-center gap-2`,children:[v(`div`,{className:`h-1 flex-1 overflow-hidden rounded-full bg-border`,children:t.kind===`determinate`?v(`div`,{className:`h-full rounded-full bg-primary transition-all`,style:{width:`${String(t.percent)}%`},role:`progressbar`,"aria-valuenow":Math.round(t.percent),"aria-valuemin":0,"aria-valuemax":100}):v(`div`,{className:`h-full w-full animate-pulse rounded-full bg-primary/40`,role:`progressbar`})}),r!==null&&v(`span`,{className:`shrink-0 font-mono text-[10px] text-foreground-subtle`,children:r})]})}function ry({job:e}){let{t}=Z(),n=Zv();return Gv(e)?v(j,{children:t(`activity.ownerSystem`)}):v(j,{children:n.get(e.ownerUserId)??e.ownerUserId})}function iy(){let e=O();return()=>{e.invalidateQueries({queryKey:[[`jobs`]]})}}function ay({job:e}){let{t}=Z(),n=pt(),r=iy(),i=Hi({onSuccess:e=>{r(),!e.accepted&&n({title:t(`activity.cancelRefused.title`),message:t(Hv(e.reason))})}}),a=Ia({onSuccess:r}),o=G(),c=_o(),[l,u]=x(!1);return s(`div`,{className:`flex items-center justify-end gap-1.5`,children:[e.state===`done`&&s(W,{variant:`primary`,size:`xs`,disabled:l,onClick:()=>{u(!0),o.trpcClient.jobs.collect.query({jobId:e.jobId}).then(e=>{if(e===null){n({title:t(`activity.openResult`),message:t(`activity.noResult`)});return}e.navigation===`server`?Wo(e.href):c(e.href)}).catch(e=>n({title:t(`activity.openResult`),message:e instanceof Error?e.message:String(e)})).finally(()=>u(!1))},children:[l&&v(H,{className:`h-3 w-3 animate-spin`,"aria-hidden":!0}),t(`activity.openResult`)]}),Uv(e)&&s(W,{variant:`outline`,size:`xs`,disabled:i.isPending,onClick:()=>i.mutate({jobId:e.jobId}),children:[i.isPending&&v(H,{className:`h-3 w-3 animate-spin`,"aria-hidden":!0}),t(`activity.cancel`)]}),Wv(e)&&v(W,{variant:`ghost`,size:`xs`,disabled:a.isPending,onClick:()=>a.mutate({jobId:e.jobId}),"aria-label":t(`activity.dismiss`),title:t(`activity.dismiss`),children:v(I,{className:`h-3 w-3`,"aria-hidden":!0})})]})}T();var oy=15e3,sy=4e3,cy=30;function ly({job:e,showOwner:t}){let{t:n}=Z(),r=ey(e),i=$v(e),a=e.finishedAt??e.createdAt;return s(`li`,{className:`space-y-1.5 border-b border-border px-3 py-2.5 last:border-b-0`,children:[s(`div`,{className:`flex items-start gap-2`,children:[s(`div`,{className:`min-w-0 flex-1`,children:[v(`div`,{className:`truncate text-[12px] font-semibold text-foreground`,title:r,children:r}),s(`div`,{className:`truncate text-[10px] text-foreground-subtle`,children:[i!==r&&i,t&&s(j,{children:[i!==r&&` · `,v(ry,{job:e})]})]})]}),v(ty,{state:e.state})]}),v(ny,{job:e}),e.failure!==null&&v(`div`,{className:`line-clamp-2 text-[10px] text-danger`,children:e.failure.message}),s(`div`,{className:`flex items-center justify-between gap-2`,children:[v(`span`,{className:`text-[10px] text-foreground-subtle`,children:e.finishedAt===null?n(`activity.startedAgo`,{when:Ov(a)}):n(`activity.finishedAgo`,{when:Ov(a)})}),v(ay,{job:e})]})]})}function uy({isAdmin:e}){let{t}=Z(),n=ka({includeDismissed:!1,limit:cy},{refetchInterval:sy}),r=f(()=>qv(n.data??[]),[n.data]);return s(`div`,{className:`flex w-[min(24rem,calc(100vw-1rem))] max-w-full flex-col`,children:[s(`div`,{className:`flex shrink-0 items-center justify-between border-b border-border px-3 py-2`,children:[v(`span`,{className:`text-[12px] font-semibold text-foreground`,children:t(`activity.title`)}),e&&v(vo,{to:`/system/jobs`,className:`text-[10px] text-primary hover:underline`,children:t(`activity.viewAll`)})]}),s(`div`,{className:`max-h-[60vh] overflow-y-auto`,children:[n.isLoading&&s(`div`,{className:`space-y-2 p-3`,children:[v(zi,{className:`h-10 w-full`}),v(zi,{className:`h-10 w-full`})]}),n.isError&&v(`div`,{className:`p-3`,children:v(pi,{title:t(`activity.loadFailed`),message:n.error.message})}),n.data!==void 0&&r.length===0&&v(zr,{icon:We,title:t(`activity.empty`)}),r.length>0&&v(`ul`,{children:r.map(t=>v(ly,{job:t,showOwner:e},t.jobId))})]})]})}function dy({variant:e=`icon`,compact:t=!1}={}){let{t:n}=Z(),{user:r}=os(),i=r?.isAdmin===!0,[a,o]=x(!1),c=Kv(va({},{refetchInterval:oy}).data),l=c>0?n(`activity.buttonCount`,{count:c}):n(`activity.title`),u=c>99?`99+`:String(c);return s(qi,{open:a,onOpenChange:o,className:`block`,children:[e===`sidebar`?s(Va,{className:`flex w-full items-center gap-2.5 rounded-md ${t?`justify-center px-0 py-2`:`px-2.5 py-1.5`} text-[12px] text-foreground-subtle transition-colors hover:bg-surface-hover hover:text-foreground`,title:t?l:void 0,"aria-label":l,children:[s(`span`,{className:`relative inline-flex shrink-0`,children:[v(We,{className:`h-3.5 w-3.5`}),t&&c>0&&v(`span`,{className:`absolute -right-1 -top-1 h-2 w-2 rounded-full bg-primary`})]}),!t&&v(`span`,{className:`flex-1 text-left`,children:n(`activity.title`)}),!t&&c>0&&v(`span`,{className:`flex h-4 min-w-4 items-center justify-center rounded-full bg-primary px-1 text-[9px] font-bold leading-none text-primary-foreground`,children:u})]}):s(Va,{className:`relative rounded-md p-1.5 text-foreground-subtle transition-colors hover:bg-surface-hover hover:text-foreground`,"aria-label":l,children:[v(We,{className:`h-4.5 w-4.5`}),c>0&&v(`span`,{className:`absolute -right-0.5 -top-0.5 flex h-4 min-w-4 items-center justify-center rounded-full bg-primary px-0.5 text-[9px] font-bold leading-none text-primary-foreground`,children:u})]}),v(Si,{align:e===`sidebar`?`start`:`end`,className:`p-0`,children:a&&v(uy,{isAdmin:i})})]})}T(),uo();function fy({alert:e,onMarkRead:t}){let{t:n}=Z(),r=Cv(e);return s(`div`,{className:`border-b border-border last:border-b-0 px-3 py-2.5`,children:[v(`div`,{className:`text-[12px] font-semibold text-foreground`,children:e.title}),v(`div`,{className:`text-[11px] text-foreground-muted mt-0.5`,children:e.message}),s(`div`,{className:`mt-2 flex flex-wrap items-center gap-2`,children:[r!==void 0&&v(wv,{action:r,className:`inline-flex items-center justify-center rounded-md bg-primary px-2.5 py-1 text-[11px] font-medium text-primary-foreground hover:bg-primary/90 transition-colors`}),v(W,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>t(e.id),children:n(`ui.alertBell.markAsRead`,`Mark as read`)})]})]})}function py(){let{t:e}=Z(),t=O(),[n,r]=x(hv()),{data:i=[],isLoading:a}=Pn({limit:50}),o=f(()=>vv(i),[i]),c=Fa({onSuccess:_(()=>{t.invalidateQueries({queryKey:[[`alerts`]]})},[t])}),l=_(e=>{c.mutate({alertId:e})},[c]),u=_(()=>{gv(),r(!0)},[]);return a||n||o.length===0?null:fo(v(`div`,{className:`fixed inset-x-0 bottom-0 z-[10000] flex justify-center p-2 sm:p-4 pb-[max(0.5rem,env(safe-area-inset-bottom))] pointer-events-none`,"data-testid":`critical-alerts-on-load-panel`,children:s(`div`,{className:`pointer-events-auto w-full max-w-lg bg-surface border border-danger/30 rounded-lg shadow-xl flex flex-col max-h-[min(70dvh,32rem)] overflow-hidden`,role:`region`,"aria-labelledby":`critical-alerts-panel-title`,children:[s(`div`,{className:`flex items-start justify-between gap-2 px-3 py-2.5 border-b border-border shrink-0 bg-danger/5`,children:[s(`div`,{children:[v(`h2`,{id:`critical-alerts-panel-title`,className:`text-[12px] font-semibold text-foreground`,children:e(`ui.criticalAlertsPanel.title`,`Urgent alerts`)}),v(`p`,{className:`text-[10px] text-foreground-muted mt-0.5`,children:e(`ui.criticalAlertsPanel.subtitle`,`These need your attention.`)})]}),v(pa,{type:`button`,variant:`ghost`,onClick:u,"aria-label":e(`ui.criticalAlertsPanel.close`,`Close`),"data-testid":`critical-alerts-panel-close`,icon:I})]}),v(`div`,{className:`flex-1 overflow-y-auto`,children:o.map(e=>v(fy,{alert:e,onMarkRead:l},e.id))})]})}),document.body)}T();function my(){let e=Jo();return b(e.subscribe,e.getSnapshot,e.getSnapshot)}var hy=[`detection`,`cluster`,`administration`];function gy(e){return hy.includes(e)}function _y(e){let t=new Map,n=new Map,r=[];for(let i of e){let e=i.section?.trim();if(e===void 0||e.length===0){r.push(i);continue}if(gy(e)){let n=t.get(e)??[];n.push(i),t.set(e,n);continue}let a=n.get(e);a?a.pages.push(i):n.set(e,{label:i.sectionLabel?.trim()||e,pages:[i]})}return{known:t,custom:[...n.entries()].map(([e,t])=>({id:e,label:t.label,pages:t.pages})),ungrouped:r}}var vy=`dominevo:last-path`,yy=512,by=[`/login`,`/change-password`,`/access-denied`,`/logout`];function xy(e){return!e.startsWith(`/`)||e.startsWith(`//`)||e.length>yy?!1:!by.some(t=>e===t||e.startsWith(t+`/`))}function Sy(e){if(!(typeof window>`u`)&&xy(e))try{window.localStorage.setItem(vy,e)}catch{}}function Cy(){if(typeof window>`u`)return null;try{let e=window.localStorage.getItem(vy);return e===null?null:xy(e)?e:null}catch{return null}}var wy=`/devices`;function Ty(e){return e!==void 0&&xy(e)?e:Cy()??wy}function Ey(e){return e.split(`.`)[0]===`0`?`${e} beta`:e}function Dy(e){if(e===null)return null;let t=e.trim();return t.length>0?t:null}function Oy(e){let t=Dy(e.productVersion),n=Dy(e.serverVersion),r=Dy(e.fallbackVersion);return t!==null&&n!==null?{kind:`both`,productLabel:Ey(t),serverVersion:n}:t===null?n===null?r===null?{kind:`none`}:{kind:`fallback`,version:r}:{kind:`server`,serverVersion:n}:{kind:`product`,productLabel:Ey(t)}}function ky(e,t){if(!Object.hasOwn(e,t))return null;let n=Reflect.get(e,t);return typeof n==`string`?n:null}function Ay(e){return typeof e!=`object`||!e?null:{productVersion:ky(e,`productVersion`),serverVersion:ky(e,`serverVersion`)}}T();function jy(e,t){return e.kind===`both`?t(`releaseIdentity.both`,`{{product}} · server {{server}}`,{product:e.productLabel,server:e.serverVersion}):e.kind===`product`?e.productLabel:e.kind===`server`?t(`releaseIdentity.serverOnly`,`server {{version}}`,{version:e.serverVersion}):e.kind===`fallback`?t(`releaseIdentity.fallback`,`v{{version}}`,{version:e.version}):null}function My({placement:e,compact:t=!1}){let{t:n}=Z(),[r,i]=x({kind:`fallback`,version:`0.1.4`});y(()=>{let e=new AbortController;return fetch(V(`/api/release-identity`),{signal:e.signal}).then(async e=>e.ok?Ay(await e.json()):null).then(t=>{e.signal.aborted||t===null||i(Oy({productVersion:t.productVersion,serverVersion:t.serverVersion,fallbackVersion:`0.1.4`}))}).catch(t=>{e.signal.aborted||t instanceof DOMException&&t.name}),()=>e.abort()},[]);let a=jy(r,n);return a===null?null:e===`login`?v(`span`,{"data-testid":`release-identity`,children:a}):v(`div`,{"data-testid":`release-identity`,className:`pt-1 text-[10px] text-foreground-disabled select-none truncate ${t?`text-center`:`px-2`}`,title:a,children:a})}function Ny(e){return typeof e==`object`&&!!e&&typeof Reflect.get(e,`postMessage`)==`function`}function Py(e){let t=Reflect.get(e,`ReactNativeWebView`);return Ny(t)?t:null}function Fy(e=window){return{parent:e.parent===e?null:e.parent,origin:e.location.origin,native:Py(e)!==null}}function Iy(e){if(typeof e!=`string`)return e;try{return JSON.parse(e)}catch{return null}}function Ly(e){return e.startsWith(`/`)&&!e.startsWith(`//`)&&!e.startsWith(`/\\`)}function Ry(e,t){let n=t.parent!==null&&e.source===t.parent&&e.origin===t.origin,r=t.native&&e.source===null&&e.origin===``;if(!n&&!r)return null;let i=en.safeParse(Iy(e.data));return!i.success||i.data.type===`navigate`&&!Ly(i.data.path)?null:i.data}function zy(e=window){let t=Py(e);if(t!==null)return e=>t.postMessage(JSON.stringify(e));if(e.parent===e)return null;let n=e.parent,r=e.location.origin;return e=>n.postMessage(e,r)}function By(e){return`${e.pathname}${e.search}`}T();function Vy(){let e=_o(),t=By(mo()),n=d(t);n.current=t;let[r,i]=x(!1),[a,o]=x(null),s=ji()?.setMode,c=d(0),l=f(()=>zy(),[]);return y(()=>{let t=Fy(),r=n=>{let r=Ry(n,t);r!==null&&(r.type===`hello`?i(!0):r.type===`navigate`?e(r.path):r.type===`search`?(c.current+=1,o({id:c.current,query:r.query})):r.type===`theme`&&s?.(r.mode))};return window.addEventListener(`message`,r),l?.({dominevo:`app-bridge`,v:1,type:`ready`,path:n.current}),()=>window.removeEventListener(`message`,r)},[e,l,s]),y(()=>{l?.({dominevo:`app-bridge`,v:1,type:`path`,path:t,title:document.title})},[l,t]),{chromeless:r,search:a}}function Hy(e=bt()){return e===``?{kind:`frame`,src:V(`/viewer/dominevo/`)}:{kind:`unavailable-under-mount`,mount:e}}function Uy(e=window){if(Reflect.get(e,`__DOMINEVO_VIEWER_EMBED__`)===!0)return!0;try{return e.self!==e.top}catch{return!0}}T();var Wy=D(!0);function Gy(e){return e===`/addon`||e.startsWith(`/addon/`)}function Ky(e,t,n){let r=[...e.filter(e=>e!==t),t];return r.length<=n?r:r.slice(r.length-n)}function qy({maxCached:e=6}){let t=ho(),n=mo(),r=Co(),i=M(yo),a=n.pathname,o=Gy(a),c=d(new Map),l=d([]);if(o){c.current.set(a,{key:a,outlet:t,location:n,navigationType:r,routeContext:i});let o=Ky(l.current,a,e),s=new Set(o);for(let e of c.current.keys())s.has(e)||c.current.delete(e);l.current=o}return s(j,{children:[l.current.map(e=>{let t=c.current.get(e);if(t?.outlet==null)return null;let n=o&&e===a;return v(`div`,{className:n?`h-full min-h-0`:void 0,style:n?void 0:{display:`none`},hidden:!n,"aria-hidden":!n,children:v(Wy.Provider,{value:n,children:v(bo.Provider,{value:{location:t.location,navigationType:t.navigationType},children:v(yo.Provider,{value:t.routeContext,children:t.outlet})})})},e)}),!o&&t!=null?v(`div`,{className:`h-full min-h-0`,children:t},a):null]})}T();var Jy={dark:ke,light:at,system:Me};function Yy(){return v(`div`,{className:`flex h-full min-h-[50vh] items-center justify-center`,children:v(`span`,{className:`h-4 w-4 animate-spin rounded-full border-2 border-primary/30 border-t-primary`})})}function Xy(){let e=mo(),t=_o(),{user:n,logout:r}=os(),i=ji(),{t:a}=Z(),o=Ai(),c=Is(),l=eo(),{info:u}=tv();y(()=>{document.title=u===null?`Dominevo Admin`:`${u.name} \u00b7 Dominevo Admin`},[u]);let p=Yo(my()),[m,h]=x(!1);y(()=>{Sy(e.pathname+e.search)},[e.pathname,e.search]);let[_,b]=x(()=>typeof window>`u`?!1:window.localStorage.getItem(`dominevo:sidebar-collapsed`)===`1`);y(()=>{typeof window>`u`||window.localStorage.setItem(`dominevo:sidebar-collapsed`,_?`1`:`0`)},[_]);let[S]=x(()=>{if(typeof window>`u`)return new Set;try{let e=window.localStorage.getItem(`dominevo:sidebar-collapsed-groups`);if(!e)return new Set;let t=JSON.parse(e);return Array.isArray(t)?new Set(t.filter(e=>typeof e==`string`)):new Set}catch{return new Set}});y(()=>{typeof window>`u`||window.localStorage.setItem(`dominevo:sidebar-collapsed-groups`,JSON.stringify([...S]))},[S]),y(()=>{l&&window.localStorage.getItem(`dominevo:sidebar-collapsed`)===null&&b(!0)},[l]);let{data:C=[]}=co({nodeId:`hub`},{refetchInterval:3e4}),w=C.length,T=O(),E=d(Date.now()),{data:D}=Za(void 0,{staleTime:0,refetchOnMount:`always`,refetchInterval:e=>{let t=e.state.data;return t&&t.length>0||Date.now()-E.current>=3e4?!1:2e3}}),k=f(()=>D&&n?.isAdmin?Hg(D):[],[D,n?.isAdmin]),A=f(()=>_y(k),[k]),M=A.known.get(`detection`)??[],P=A.known.get(`cluster`)??[],F=A.known.get(`administration`)??[];$n(`addon.page-ready`,()=>{T.invalidateQueries({queryKey:[[`addonPages`,`listPages`]]})});let ee=()=>{r(),t(`/login`)},te=t=>!!(e.pathname===t||e.pathname.startsWith(t+`/`)),ne=[`/system/pipeline`,`/live`,`/addon/osd-manager`,`/build`].some(t=>e.pathname===t||e.pathname.startsWith(t+`/`)),ie=n?.isAdmin===!0,ae=f(()=>Uy(),[]),{chromeless:se,search:ce}=Vy(),I=f(()=>i_({t:a,isAdmin:ie,embeddedByViewer:ae}),[a,ie,ae]),le=I[0]?.items??[],ue=I[1]?.items??[],de=I[2]?.items??[],fe=I[3]?.items??[],pe=i?.mode??`system`,L={dark:a(`theme.dark`),light:a(`theme.light`),system:a(`theme.system`)},R=_&&!o,z=(e,t=`md`,n=!1)=>`flex w-full items-center gap-2.5 rounded-md ${R?`justify-center px-0 py-2`:`px-2.5 py-1.5`} ${t===`lg`?`text-[13px] font-medium`:`text-[12px]`} transition-all ${e?t===`lg`?`bg-primary/12 text-primary shadow-sm shadow-primary/5`:`bg-primary/12 text-primary`:n?`text-foreground-disabled hover:bg-surface-hover`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,me=(e,t)=>e===0?null:R?v(`div`,{className:`pt-3 mb-1 mx-2 border-t border-border/60`},`sep-${t}`):v(`div`,{className:`pt-4 pb-1.5 px-2.5`,children:v(`span`,{className:`text-[10px] font-semibold uppercase tracking-widest text-foreground-subtle/60`,children:t})},`hdr-${t}`),B=e=>{let n=te(e.path),r=o_(e.icon);return s(W,{variant:`unstyled`,onClick:()=>{t(e.path),h(!1)},className:z(n),title:R?e.label:void 0,children:[v(r,{className:`h-3.5 w-3.5 shrink-0 ${n?`text-primary`:``}`}),!R&&e.label]},`${e.addonId}::${e.id}`)},he=e=>e.requiresCapability===void 0?ge(e,!1):v(d_,{capability:e.requiresCapability,children:t=>ge(e,t)},e.path),ge=(e,n)=>{let r=e.icon,i=te(e.path),o=e.path===`/system/addons`;return s(W,{variant:`unstyled`,"data-testid":`nav-${e.path.replace(/^\//,``).replace(/\//g,`-`)}`,onClick:()=>{t(e.path),h(!1)},className:z(i,`md`,n),"aria-disabled":n||void 0,title:n?a(`nav.notInstalled`,`{{page}} — not installed`,{page:e.label}):R?e.label:void 0,children:[v(r,{className:`h-3.5 w-3.5 shrink-0 ${i?`text-primary`:``}`}),!R&&s(j,{children:[v(`span`,{className:`flex-1 text-left`,children:e.label}),o&&w>0&&v(`span`,{className:`ml-auto rounded-full bg-primary px-1.5 py-0.5 text-[9px] font-bold text-primary-foreground leading-none`,children:w})]}),R&&o&&w>0&&v(`span`,{className:`absolute mt-[-14px] ml-3 h-2 w-2 rounded-full bg-primary`})]},e.path)},_e=s(j,{children:[s(`div`,{className:`flex h-14 items-center border-b border-border ${R?`justify-center px-1`:`pl-3 pr-4 gap-2`}`,children:[!R&&v(`img`,{src:i?.resolvedMode===`light`?V(`/brand/logo-horizontal-light.svg`):V(`/brand/logo-horizontal-dark.svg`),alt:a(`layouts.appLayout.dominevoAdmin`,`Dominevo Admin`),className:`h-9 flex-1 min-w-0`}),!o&&v(W,{variant:`unstyled`,onClick:()=>b(e=>!e),className:`p-1.5 rounded-md hover:bg-surface-hover text-foreground-subtle transition-colors flex-shrink-0 ${R?``:`mr-2`}`,"aria-label":_?a(`layouts.appLayout.expandSidebar`,`Expand sidebar`):a(`layouts.appLayout.collapseSidebar`,`Collapse sidebar`),title:_?a(`layouts.appLayout.expandSidebar`,`Expand sidebar`):a(`layouts.appLayout.collapseSidebar`,`Collapse sidebar`),children:v(_?oe:re,{className:`h-4 w-4`})})]}),!R&&u!==null&&v(`div`,{"data-testid":`sidebar-server-name`,title:u.name,className:`truncate border-b border-border px-3 py-1.5 text-xs font-medium text-foreground-muted`,children:u.name}),v(`div`,{className:`border-b border-border pt-2`,children:v(z_,{navSections:I,addonPages:k,compact:R,onNavigated:()=>h(!1)})}),s(`nav`,{className:`flex-1 overflow-y-auto py-3 ${R?`px-1.5`:`px-2`} space-y-0.5`,children:[le.map(e=>he(e)),me(ue.length+M.length,a(`nav.detectionSection`,`Detection`)),ue.map(e=>he(e)),M.map(e=>B(e)),me(de.length+P.length,a(`nav.clusterSection`,`Cluster`)),de.map(e=>he(e)),P.map(e=>B(e)),me(fe.length+F.length,a(`system.title`,`Administration`)),fe.map(e=>he(e)),F.map(e=>B(e)),A.custom.map(e=>s(`div`,{className:`contents`,children:[me(e.pages.length,e.label),e.pages.map(e=>B(e))]},`custom-${e.id}`)),me(A.ungrouped.length,a(`nav.addonPages`,`Addon Pages`)),A.ungrouped.map(e=>B(e))]}),s(`div`,{className:`border-t border-border ${R?`p-1.5`:`p-2`} space-y-0.5`,children:[s(W,{variant:`unstyled`,onClick:()=>i?.toggleMode(),className:z(!1),title:R?L[pe]:void 0,children:[(()=>{let e=Jy[pe];return v(e,{className:`h-3.5 w-3.5 shrink-0`})})(),!R&&v(`span`,{children:L[pe]})]}),v(dy,{variant:`sidebar`,compact:R}),v(Nv,{variant:`sidebar`,compact:R}),s(W,{variant:`unstyled`,type:`button`,onClick:()=>t(`/system/my-access`),className:z(te(`/system/my-access`)),title:R?a(`system.myAccess`,`My access`):void 0,children:[v(N,{className:`h-3.5 w-3.5 shrink-0`}),!R&&v(`span`,{className:`truncate`,children:a(`system.myAccess`,`My access`)})]}),s(W,{variant:`unstyled`,type:`button`,onClick:()=>c.setOn(!c.on),className:z(c.on),"aria-pressed":c.on,title:R?a(`layouts.appLayout.debugLayers`,`Debug layers`):void 0,children:[v(Ot,{className:`h-3.5 w-3.5 shrink-0`}),!R&&v(`span`,{className:`truncate`,children:c.on?a(`layouts.appLayout.debugLayersOn`,`Debug layers: on`):a(`layouts.appLayout.debugLayers`,`Debug layers`)})]}),s(W,{variant:`unstyled`,onClick:ee,className:z(!1).replace(`hover:text-foreground`,`hover:text-danger`),title:R?n?.username??a(`layouts.appLayout.logout`,`Logout`):void 0,children:[v(xn,{className:`h-3.5 w-3.5 shrink-0`}),!R&&v(`span`,{className:`truncate`,children:n?.username??a(`layouts.appLayout.user`,`User`)})]}),v(My,{placement:`sidebar`,compact:R})]})]});return s(`div`,{className:`flex h-dvh flex-col overflow-hidden bg-background text-foreground pb-[env(safe-area-inset-bottom)]`,children:[v(`div`,{"aria-hidden":`true`,className:`h-[env(safe-area-inset-top)] shrink-0 bg-surface`}),s(`div`,{className:`flex min-h-0 flex-1`,children:[!se&&!o&&v(`aside`,{className:`flex flex-col border-r border-border bg-surface shrink-0 transition-[width] duration-150 ease-out ${R?`w-12`:`w-48`}`,children:_e}),!se&&o&&v(fa,{open:m,onClose:()=>h(!1),width:`w-64`,children:_e}),s(`div`,{className:`flex flex-1 flex-col min-w-0`,children:[p!==null&&v(`div`,{role:`status`,className:`pointer-events-none fixed inset-x-0 top-[env(safe-area-inset-top)] z-50 flex justify-center`,children:s(`div`,{className:`pointer-events-auto flex items-center justify-center gap-2 rounded-b-md px-3 py-2 text-[12px] font-medium shadow-lg ${p.severity===`danger`?`bg-danger text-white`:`bg-surface text-warning border border-t-0 border-warning/30`}`,children:[p.severity===`danger`?v(Be,{className:`h-3.5 w-3.5`}):v(We,{className:`h-3.5 w-3.5`}),v(`span`,{children:a(p.i18nKey,{defaultValue:p.message,...p.i18nParams})}),p.action===`sign-in`&&v(W,{variant:`unstyled`,onClick:()=>r(),className:`ml-2 rounded border border-white/40 px-2 py-0.5 text-[11px] font-semibold hover:bg-white/10`,children:a(`connection.signIn`,`Sign in`)}),p.showSpinner&&v(H,{className:`h-3.5 w-3.5 animate-spin`})]})}),se&&v(z_,{floating:!0,compact:!1,request:ce,navSections:I,addonPages:k}),v(J_,{}),v(ov,{}),v(py,{}),!se&&o&&s(`header`,{"data-debug-header":``,className:`flex items-center h-12 border-b border-border px-3 shrink-0 bg-surface`,children:[v(W,{variant:`unstyled`,onClick:()=>h(!0),className:`p-1.5 -ml-1.5 rounded-md hover:bg-surface-hover text-foreground-muted transition-colors`,"aria-label":a(`layouts.appLayout.openMenu`,`Open menu`),children:v(Ie,{className:`h-5 w-5`})}),v(`div`,{className:`flex-1 flex justify-center`,children:v(`img`,{src:i?.resolvedMode===`light`?V(`/brand/logo-horizontal-light.svg`):V(`/brand/logo-horizontal-dark.svg`),alt:a(`layouts.appLayout.dominevo`,`Dominevo`),className:`h-7`})}),v(dy,{}),v(Nv,{})]}),s(f_,{children:[v(m_,{}),v(`main`,{className:`relative flex-1 min-h-0 overscroll-contain bg-background ${ne?`overflow-hidden`:`overflow-auto`}`,children:v(Bg,{resetKey:e.pathname,children:v(g,{fallback:v(Yy,{}),children:v(qy,{})})})})]})]})]})]})}function $({children:e,requireAdmin:t}){let{t:n}=Z(),{user:r,loading:i,mustChangePassword:a}=os(),o=mo();return i?v(`div`,{className:`flex h-screen items-center justify-center bg-background text-foreground-subtle`,children:n(`layouts.protectedRoute.loading`,`Loading...`)}):r?a&&o.pathname!==`/change-password`?v(Y,{to:`/change-password`,replace:!0}):t&&!r.isAdmin?v(Y,{to:`/access-denied`,replace:!0}):v(j,{children:e}):v(Y,{to:`/login`,replace:!0,state:{from:o.pathname+o.search}})}var Zy=`integration`,Qy=`section`,$y=[Zy,Qy,`instance`,`instance-new`],eb={connectivity:{path:`/system/integrations`,tab:null},remoteAccess:{path:`/system/network`,tab:`remote-access`},mesh:{path:`/system/network`,tab:`mesh`},turn:{path:`/system/network`,tab:`turn`},authentication:{path:`/system/identity`,tab:`authentication`},access:{path:`/system/identity`,tab:`access`},logging:{path:`/system/logs`,tab:`destinations`}},tb=`activity`;function nb(e,t={}){let{path:n,tab:r}=eb[e],i=new URLSearchParams;r===null?t.kindSection!==void 0&&i.set(`tab`,t.kindSection):i.set(`tab`,r),t.integration!==void 0&&i.set(Zy,t.integration),t.section!==void 0&&i.set(Qy,t.section);let a=i.toString();return a.length>0?`${n}?${a}`:n}function rb(e){let{ids:t,requested:n,answered:r,legacyGroup:i=null,groupFirst:a={}}=e;if(n!==null&&t.includes(n))return{selectedId:n,staleId:null};let o=n!==null&&r?n:null,s=i===null?void 0:a[i];return s!==void 0&&t.includes(s)?{selectedId:s,staleId:o}:{selectedId:t[0]??null,staleId:o}}function ib(e,t,n=null,r=null){let i=new URLSearchParams(e);return i.set(Zy,t),r===null?i.delete(Qy):i.set(Qy,r),n!==null&&i.delete(n),i}function ab(e){return e===`/admin`||e===`/admin/`?`/`:e.startsWith(`/admin/`)?e.slice(6):e}var ob=`--color-surface`;function sb(e){let t=e.querySelector(`meta[name="theme-color"]`);if(t)return t;let n=e.createElement(`meta`);return n.name=`theme-color`,e.head.appendChild(n),n}function cb(e=document){let t=e.defaultView?.getComputedStyle(e.documentElement).getPropertyValue(ob).trim();if(!t)return;let n=sb(e);n.content!==t&&(n.content=t)}function lb(e=document){cb(e);let t=e.defaultView;if(!t)return()=>void 0;let n=new t.MutationObserver(()=>cb(e));return n.observe(e.documentElement,{attributes:!0,attributeFilter:[`class`]}),()=>n.disconnect()}function ub(){let{t:e}=Z(),t=_o();return s(`div`,{className:`flex flex-col items-center justify-center text-foreground py-16 px-4`,children:[v(`div`,{className:`flex h-16 w-16 items-center justify-center rounded-2xl bg-danger/10 mb-4`,children:v(Dn,{className:`h-8 w-8 text-danger`})}),v(`h1`,{className:`text-xl font-bold`,children:e(`accessDenied.accessDenied`,`Access Denied`)}),v(`p`,{className:`mt-2 text-sm text-foreground-subtle`,children:e(`accessDenied.youDonTHavePermission`,`You don't have permission to access this page.`)}),v(W,{variant:`unstyled`,onClick:()=>t(`/devices`),className:`mt-6 rounded-lg bg-primary px-5 py-2.5 text-sm font-medium text-primary-foreground shadow-md shadow-primary/20 hover:shadow-lg transition-all`,children:e(`accessDenied.goToDevices`,`Go to Devices`)})]})}function db(e){let t=new Uint8Array(e),n=``;for(let e of t)n+=String.fromCharCode(e);return btoa(n).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=/g,``)}function fb(e){let t=e.replace(/-/g,`+`).replace(/_/g,`/`),n=(4-t.length%4)%4,r=t.padEnd(t.length+n,`=`),i=atob(r),a=new ArrayBuffer(i.length),o=new Uint8Array(a);for(let e=0;e<i.length;e++)o[e]=i.charCodeAt(e);return a}function pb(){return window?.PublicKeyCredential!==void 0&&typeof window.PublicKeyCredential==`function`}function mb(e){let{id:t}=e;return{...e,id:fb(t),transports:e.transports}}function hb(e){return e===`localhost`||/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(e)}var gb=class extends Error{constructor({message:e,code:t,cause:n,name:r}){super(e,{cause:n}),this.name=r??n.name,this.code=t}},_b=new class{createNewAbortSignal(){if(this.controller){let e=Error(`Cancelling existing WebAuthn API call for new one`);e.name=`AbortError`,this.controller.abort(e)}let e=new AbortController;return this.controller=e,e.signal}cancelCeremony(){if(this.controller){let e=Error(`Manually cancelling existing WebAuthn API call`);e.name=`AbortError`,this.controller.abort(e),this.controller=void 0}}},vb=[`cross-platform`,`platform`];function yb(e){if(e&&!(vb.indexOf(e)<0))return e}function bb(){if(!pb())return new Promise(e=>e(!1));let e=window.PublicKeyCredential;return e.isConditionalMediationAvailable===void 0?new Promise(e=>e(!1)):e.isConditionalMediationAvailable()}function xb({error:e,options:t}){let{publicKey:n}=t;if(!n)throw Error(`options was missing required publicKey property`);if(e.name===`AbortError`){if(t.signal instanceof AbortSignal)return new gb({message:`Authentication ceremony was sent an abort signal`,code:`ERROR_CEREMONY_ABORTED`,cause:e})}else if(e.name===`NotAllowedError`)return new gb({message:e.message,code:`ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY`,cause:e});else if(e.name===`SecurityError`){let t=window.location.hostname;if(!hb(t))return new gb({message:`${window.location.hostname} is an invalid domain`,code:`ERROR_INVALID_DOMAIN`,cause:e});if(n.rpId!==t)return new gb({message:`The RP ID "${n.rpId}" is invalid for this domain`,code:`ERROR_INVALID_RP_ID`,cause:e})}else if(e.name===`UnknownError`)return new gb({message:`The authenticator was unable to process the specified options, or could not create a new assertion signature`,code:`ERROR_AUTHENTICATOR_GENERAL_ERROR`,cause:e});return e}async function Sb(e){let{optionsJSON:t,useBrowserAutofill:n=!1,verifyBrowserAutofillInput:r=!0}=e;if(!pb())throw Error(`WebAuthn is not supported in this browser`);let i;t.allowCredentials?.length!==0&&(i=t.allowCredentials?.map(mb));let a={...t,challenge:fb(t.challenge),allowCredentials:i},o={};if(n){if(!await bb())throw Error(`Browser does not support WebAuthn autofill`);if(document.querySelectorAll(`input[autocomplete$='webauthn']`).length<1&&r)throw Error('No <input> with "webauthn" as the only or last value in its `autocomplete` attribute was detected');o.mediation=`conditional`,a.allowCredentials=[]}o.publicKey=a,o.signal=_b.createNewAbortSignal();let s;try{s=await navigator.credentials.get(o)}catch(e){throw xb({error:e,options:o})}if(!s)throw Error(`Authentication was not completed`);let{id:c,rawId:l,response:u,type:d}=s,f;return u.userHandle&&(f=db(u.userHandle)),{id:c,rawId:db(l),response:{authenticatorData:db(u.authenticatorData),clientDataJSON:db(u.clientDataJSON),signature:db(u.signature),userHandle:f},type:d,clientExtensionResults:s.getClientExtensionResults(),authenticatorAttachment:yb(s.authenticatorAttachment)}}function Cb(e){return typeof e==`object`&&!!e}function wb(e){return Cb(e)&&typeof e.challenge==`string`}T();function Tb(e,t){return e instanceof Error&&e.message.length>0?e.message:t}function Eb(e){let{t}=Z(),n=G(),[r,i]=x(!1),[a,o]=x(``),[c,l]=x(null),[u,f]=x(null),p=d(null),m=_(e=>{p.current?.(e),p.current=null,i(!1),o(``),l(null),f(null)},[]),h=_(()=>new Promise(e=>{p.current?.(null),p.current=e,f(null),i(!0)}),[]),g=async()=>{l(`password`),f(null);try{let{reauthToken:e}=await n.reauthenticate({password:a});m(e)}catch(e){f(Tb(e,`Password is incorrect`)),l(null)}},y=async()=>{l(`passkey`),f(null);try{let{optionsJSON:e}=await n.reauthBeginPasskey();if(!wb(e))throw Error(`passkey authentication options missing challenge`);let t=await Sb({optionsJSON:e}),{reauthToken:r}=await n.reauthenticate({passkeyResponse:Object.fromEntries(Object.entries(t))});m(r)}catch(e){f(Tb(e,`Passkey verification failed`)),l(null)}};return{requestProof:h,dialog:v(Nn,{open:r,onOpenChange:e=>!e&&m(null),children:s(Na,{children:[s($i,{children:[v(Ti,{children:t(`auth.reauthDialog.confirmItSYou`,`Confirm it’s you`)}),v(ha,{children:t(`auth.reauthDialog.needsPassword`,{action:e})})]}),s(`form`,{className:`space-y-3`,onSubmit:e=>{e.preventDefault(),a.length>0&&c===null&&g()},children:[v(U,{type:`password`,autoComplete:`current-password`,placeholder:t(`auth.reauthDialog.currentPassword`,`Current password`),value:a,onChange:e=>o(e.target.value),"aria-label":t(`auth.reauthDialog.currentPassword`,`Current password`)}),u!==null&&v(`p`,{role:`alert`,className:`text-xs text-danger`,children:u}),s(Ta,{className:`flex flex-wrap gap-2`,children:[s(W,{type:`button`,variant:`outline`,disabled:c!==null,onClick:()=>void y(),children:[c===`passkey`?v(H,{className:`h-4 w-4 animate-spin`}):v(gn,{className:`h-4 w-4`}),t(`auth.reauthDialog.useAPasskey`,`Use a passkey`)]}),s(W,{type:`submit`,disabled:a.length===0||c!==null,children:[c===`password`&&v(H,{className:`h-4 w-4 animate-spin`}),t(`common.confirm`,`Confirm`)]})]})]})]})})}}T();function Db(e){return e.ip!==null&&e.approverIp!==null&&e.ip!==e.approverIp}function Ob(e,t){return e instanceof Error&&e.message.length>0?e.message:t}function kb(e){let t=e instanceof Error?e.message:``;return t.startsWith(`Sign in again first`)||t.startsWith(`Confirm it is you`)}function Ab(e,t){let n=Math.max(0,Math.round((t-e)/1e3));return n<5?{key:`justNow`,value:0}:n<60?{key:`seconds`,value:n}:{key:`minutes`,value:Math.round(n/60)}}function jb({onApproved:e,onDenied:t}){let{t:n}=Z(),r=gr.useUtils(),[i,a]=x(``),[o,c]=x(null),[l,u]=x(``),[d,f]=x(null),[p,m]=x(null),{requestProof:h,dialog:g}=Eb(n(`cliLogin.reauthAction`,`Approving a terminal sign-in`)),_=gr.auth.cliLoginApprove.useMutation(),y=gr.auth.cliLoginDeny.useMutation(),b=async e=>{e.preventDefault(),f(`lookup`),m(null);try{c(await r.auth.cliLoginDescribe.fetch({userCode:i})),u(i)}catch(e){c(null),m(Ob(e,n(`cliLogin.unknownCode`,`No pending sign-in with that code. Check the terminal.`)))}finally{f(null)}},S=async r=>{f(r),m(null);try{if(r===`deny`){await y.mutateAsync({userCode:l}),t();return}try{await _.mutateAsync({userCode:l})}catch(e){if(!kb(e))throw e;let t=await h();if(t===null)return;await _.mutateAsync({userCode:l,reauthToken:t})}e()}catch(e){m(Ob(e,n(`cliLogin.failed`,`That did not work. Try again.`)))}finally{f(null)}},C=o===null?null:Ab(o.createdAt,Date.now());return s(`div`,{className:`space-y-4`,"data-testid":`cli-login-approval`,children:[s(`div`,{className:`space-y-1`,children:[s(`h1`,{className:`flex items-center gap-2 text-sm font-semibold text-foreground`,children:[v(wn,{className:`h-4 w-4`,"aria-hidden":!0}),n(`cliLogin.title`,`Approve a terminal sign-in`)]}),v(`p`,{className:`text-xs text-foreground-subtle`,children:n(`cliLogin.intro`,`Type the code your terminal shows. Only approve a sign-in you started yourself.`)})]}),p!==null&&v(`div`,{role:`alert`,className:`rounded-md border border-danger/20 bg-danger/10 px-3 py-2 text-xs text-danger`,children:p}),o===null||C===null?s(`form`,{onSubmit:e=>void b(e),className:`space-y-3`,children:[v(U,{value:i,onChange:e=>a(e.target.value),placeholder:`ABCD-EFGH`,"aria-label":n(`cliLogin.codeLabel`,`Sign-in code`),autoComplete:`off`,autoCapitalize:`characters`,spellCheck:!1,maxLength:16,className:`text-center font-mono tracking-widest`}),s(W,{type:`submit`,variant:`primary`,className:`w-full`,disabled:i.trim().length<8||d!==null,children:[d===`lookup`&&v(H,{className:`h-4 w-4 animate-spin`,"aria-hidden":!0}),n(`cliLogin.continue`,`Continue`)]})]}):s(`div`,{className:`space-y-3`,children:[s(`dl`,{className:`space-y-1 rounded-md border border-border bg-background-elevated p-3 text-xs`,children:[s(`div`,{className:`flex justify-between gap-3`,children:[v(`dt`,{className:`text-foreground-muted`,children:n(`cliLogin.address`,`Terminal address`)}),v(`dd`,{className:`text-foreground`,"data-testid":`cli-login-ip`,children:o.ip??n(`cliLogin.unknownValue`,`Unknown`)})]}),s(`div`,{className:`flex justify-between gap-3`,children:[v(`dt`,{className:`text-foreground-muted`,children:n(`cliLogin.yourAddress`,`Your address`)}),v(`dd`,{className:`text-foreground`,"data-testid":`cli-login-approver-ip`,children:o.approverIp??n(`cliLogin.unknownValue`,`Unknown`)})]}),s(`div`,{className:`flex justify-between gap-3`,children:[v(`dt`,{className:`text-foreground-muted`,children:n(`cliLogin.program`,`Program (seen by the hub)`)}),v(`dd`,{className:`truncate text-foreground`,"data-testid":`cli-login-agent`,children:o.userAgent??n(`cliLogin.unknownValue`,`Unknown`)})]}),s(`div`,{className:`flex justify-between gap-3`,children:[v(`dt`,{className:`text-foreground-muted`,children:n(`cliLogin.client`,`Name it gave itself (unverified)`)}),v(`dd`,{className:`truncate text-foreground-muted`,"data-testid":`cli-login-client`,children:o.client??n(`cliLogin.unknownValue`,`Unknown`)})]}),s(`div`,{className:`flex justify-between gap-3`,children:[v(`dt`,{className:`text-foreground-muted`,children:n(`cliLogin.requested`,`Requested`)}),v(`dd`,{className:`text-foreground`,children:C.key===`justNow`?n(`cliLogin.ageNow`,`just now`):C.key===`seconds`?n(`cliLogin.ageSeconds`,`{{count}} s ago`,{count:C.value}):n(`cliLogin.ageMinutes`,`{{count}} min ago`,{count:C.value})})]})]}),Db(o)&&v(`div`,{role:`alert`,"data-testid":`cli-login-mismatch`,className:`rounded-md border border-warning/20 bg-warning/10 px-3 py-2 text-xs text-warning`,children:n(`cliLogin.mismatch`,`This request comes from a different address than the one you are using now. Approve it only if you started it from another machine of yours.`)}),v(`p`,{className:`text-xs text-foreground-subtle`,"data-testid":`cli-login-grant`,children:n(`cliLogin.grant`,`Approving signs this terminal in as you, with all of your rights, until the session expires or you end it under Tokens & sessions.`)}),s(`div`,{className:`flex gap-2`,children:[v(W,{type:`button`,variant:`ghost`,className:`flex-1`,disabled:d!==null,onClick:()=>void S(`deny`),children:n(`cliLogin.deny`,`Deny`)}),s(W,{type:`button`,variant:`primary`,className:`flex-1`,disabled:d!==null,onClick:()=>void S(`approve`),children:[d===`approve`&&v(H,{className:`h-4 w-4 animate-spin`,"aria-hidden":!0}),n(`cliLogin.approve`,`Approve`)]})]})]}),g]})}T();function Mb(){let{t:e}=Z(),t=ji(),n=_o(),[r,i]=x(!1);return v(`div`,{className:`flex min-h-screen items-center justify-center bg-background p-4`,children:s(`div`,{className:`w-full max-w-sm`,children:[v(`div`,{className:`mb-8 flex justify-center`,children:v(`img`,{src:t?.resolvedMode===`light`?V(`/brand/logo-horizontal-light.svg`):V(`/brand/logo-horizontal-dark.svg`),alt:e(`cliLogin.brand`,`Dominevo`),className:`h-12`})}),v(`div`,{className:`rounded-xl border border-border bg-surface p-6 shadow-xl shadow-black/10`,children:r?s(`div`,{className:`space-y-3 text-center`,"data-testid":`cli-login-denied`,children:[v(`p`,{className:`text-sm text-foreground`,children:e(`cliLogin.deniedBody`,`The sign-in was denied. The terminal stays signed out.`)}),v(W,{type:`button`,variant:`ghost`,onClick:()=>void n(`/`),children:e(`cliLogin.back`,`Back to Dominevo`)})]}):v(jb,{onApproved:()=>window.location.assign(V(tn(null,{status:`success`,action:`cli-login`}))),onDenied:()=>i(!0)})})]})})}var Nb=`auth.password-incorrect`;function Pb(e,t){return typeof e==`object`&&e?Reflect.get(e,t):void 0}function Fb(e){if(!(e instanceof Error))return{kind:`connection-lost`};let t=Pb(e,`data`);return typeof t!=`object`||!t?{kind:`connection-lost`}:Pb(Pb(t,`i18n`),`code`)===Nb?{kind:`wrong-current`}:Pb(t,`code`)===`UNAUTHORIZED`?{kind:`session-ended`}:{kind:`rejected`,message:e.message}}T();var Ib=8;function Lb(e,t){let n=Fb(e);switch(n.kind){case`wrong-current`:return t(`changePassword.errorWrongCurrent`,`The current password is incorrect.`);case`session-ended`:return t(`changePassword.errorSessionEnded`,`Your session ended before the change was confirmed. Sign in again — try the new password first.`);case`connection-lost`:return t(`changePassword.errorConnectionLost`,`The connection to the hub dropped before it confirmed the change. Sign in again — try the new password first.`);case`rejected`:return n.message}}function Rb(){let{t:e}=Z(),{user:t,mustChangePassword:n,clearMustChangePassword:r,logout:i}=os(),a=G(),o=ji(),c=_o(),[l,u]=x(``),[d,f]=x(``),[p,m]=x(``),[h,g]=x(!1),[_,y]=x(``),[b,S]=x(!1),C=n?ls:l;return v(`div`,{className:`flex min-h-screen items-center justify-center bg-background p-4`,children:s(`div`,{className:`w-full max-w-sm`,children:[v(`div`,{className:`flex justify-center mb-8`,children:v(`img`,{src:o?.resolvedMode===`light`?V(`/brand/logo-horizontal-light.svg`):V(`/brand/logo-horizontal-dark.svg`),alt:e(`changePassword.dominevoAdmin`,`Dominevo Admin`),className:`h-12`})}),s(`form`,{onSubmit:async i=>{if(i.preventDefault(),y(``),!t){y(`Not signed in`);return}if(!n&&l.length===0){y(e(`changePassword.enterCurrent`,`Enter your current password`));return}if(d.length<Ib){y(`Password must be at least ${Ib} characters`);return}if(d!==p){y(`The two passwords do not match`);return}if(d===`changeme`){y(`Choose a password different from the seed default`);return}S(!0);try{await a.changeOwnPassword({currentPassword:C,newPassword:d}),r(),c(`/devices`,{replace:!0})}catch(t){y(Lb(t,e))}finally{S(!1)}},className:`space-y-4 rounded-xl border border-border bg-surface p-6 shadow-xl shadow-black/10`,children:[s(`div`,{className:`space-y-1`,children:[v(`h1`,{className:`text-sm font-semibold text-foreground`,children:e(`changePassword.setANewPassword`,`Set a new password`)}),v(`p`,{className:`text-xs text-foreground-subtle`,children:n?e(`changePassword.youMustRotateTheSeed`,`You must rotate the seed password before continuing.`):e(`changePassword.chooseANewPasswordFor`,`Choose a new password for your account.`)})]}),_&&v(`div`,{role:`alert`,className:`rounded-md bg-danger/10 border border-danger/20 px-3 py-2 text-xs text-danger`,children:_}),!n&&s(`div`,{className:`space-y-1.5`,children:[v(`label`,{className:`text-xs font-medium text-foreground-subtle`,children:e(`changePassword.currentPassword`,`Current password`)}),v(U,{"data-testid":`change-password-current`,type:h?`text`:`password`,value:l,onChange:e=>u(e.target.value),autoComplete:`current-password`,className:`w-full rounded-lg border border-border bg-background px-3 py-2.5 text-sm text-foreground placeholder:text-foreground-disabled focus:border-primary focus:ring-1 focus:ring-primary/30 outline-none transition-all`,autoFocus:!0})]}),s(`div`,{className:`space-y-1.5`,children:[v(`label`,{className:`text-xs font-medium text-foreground-subtle`,children:e(`changePassword.newPassword`,`New password`)}),s(`div`,{className:`relative`,children:[v(U,{"data-testid":`change-password-new`,type:h?`text`:`password`,value:d,onChange:e=>f(e.target.value),autoComplete:`new-password`,className:`w-full rounded-lg border border-border bg-background px-3 py-2.5 pr-10 text-sm text-foreground placeholder:text-foreground-disabled focus:border-primary focus:ring-1 focus:ring-primary/30 outline-none transition-all`,autoFocus:n}),v(W,{variant:`unstyled`,type:`button`,onClick:()=>g(!h),className:`absolute right-2.5 top-1/2 -translate-y-1/2 text-foreground-subtle hover:text-foreground transition-colors`,tabIndex:-1,children:v(h?kt:we,{className:`h-4 w-4`})})]})]}),s(`div`,{className:`space-y-1.5`,children:[v(`label`,{className:`text-xs font-medium text-foreground-subtle`,children:e(`changePassword.confirmNewPassword`,`Confirm new password`)}),v(U,{"data-testid":`change-password-confirm`,type:h?`text`:`password`,value:p,onChange:e=>m(e.target.value),autoComplete:`new-password`,className:`w-full rounded-lg border border-border bg-background px-3 py-2.5 text-sm text-foreground placeholder:text-foreground-disabled focus:border-primary focus:ring-1 focus:ring-primary/30 outline-none transition-all`})]}),v(W,{variant:`unstyled`,"data-testid":`change-password-submit`,type:`submit`,disabled:b||!d||!p,className:`w-full rounded-lg bg-primary px-4 py-2.5 text-sm font-semibold text-primary-foreground shadow-md shadow-primary/20 hover:shadow-lg hover:shadow-primary/30 disabled:opacity-50 disabled:shadow-none transition-all`,children:b?e(`changePassword.saving`,`Saving…`):e(`changePassword.saveAndContinue`,`Save and continue`)}),n&&v(W,{variant:`unstyled`,type:`button`,onClick:()=>{i(),c(`/login`,{replace:!0})},className:`w-full text-xs text-foreground-subtle hover:text-foreground transition-colors`,children:e(`changePassword.signOutInstead`,`Sign out instead`)})]})]})})}T();async function zb(e){if(!wb(e))throw Error(`passkey authentication options missing challenge`);let t=await Sb({optionsJSON:e});return Object.fromEntries(Object.entries(t))}function Bb({method:e,challengeToken:t,onComplete:n,onSecondFactor:r,onError:i}){let[a,o]=x(!1),[c,l]=x(null),u=async()=>{l(null),o(!0);try{let e=Zo();if(t){let r=await zb((await e.loginBeginPasskey(t)).optionsJSON),i=await e.loginVerifyPasskey(t,r,{refreshable:!0});n(i.token,i);return}let a=await zb((await e.passkeyLoginBegin()).optionsJSON),o=await e.passkeyLoginFinish(a,{refreshable:!0}),s=o.secondFactors??(o.requiresTotp===!0?[`totp`]:[]);if(s.length>0){if(r)r({challengeToken:o.token,factors:s});else{let e=`Additional verification is required — sign in with your password to continue.`;l(e),i?.(e)}return}n(o.token,o)}catch(e){let n=t?`Passkey verification failed`:`Passkey sign-in failed`,r=e instanceof Error?e.message:n;l(r),i?.(r)}finally{o(!1)}};return s(`div`,{className:`space-y-2`,children:[s(W,{variant:`unstyled`,type:`button`,"data-testid":t?`login-passkey`:`login-passkey-direct`,onClick:()=>void u(),disabled:a,className:`w-full flex items-center justify-center gap-2 rounded-lg border border-border bg-surface px-4 py-2.5 text-sm font-medium text-foreground hover:bg-surface-hover disabled:opacity-50 transition-colors`,children:[a?v(H,{className:`h-4 w-4 animate-spin text-primary`}):v(_n,{className:`h-4 w-4 text-primary`}),e.label]}),c&&v(`div`,{className:`rounded-md bg-danger/10 border border-danger/20 px-3 py-2 text-xs text-danger`,children:c})]})}var Vb=()=>window.location.hostname;function Hb(e,t=Vb,n=null){return n===!1?!1:pb()&&H_(t(),e.rpId)}function Ub(e,t=Vb,n=null){let r=e.filter(e=>e.kind===`passkey`&&e.stage===`second-factor`).filter(e=>Hb(e,t,n));return{passkeyMethods:r,widgetMethods:r.length>0?[]:e.filter(e=>e.kind===`widget`&&e.stage===`second-factor`)}}function Wb(e,t){let n=e.includes(`passkey`),r=t.passkeyMethods.length>0||t.widgetMethods.length>0,i=e.includes(`totp`);return n&&!r&&!i}T();async function Gb(){if(typeof PublicKeyCredential>`u`)return null;let e=PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable;if(typeof e!=`function`)return null;try{return await e.call(PublicKeyCredential)}catch{return null}}var Kb=()=>`dominevoAgentApp`in window;function qb(){let[e,t]=x(null);return y(()=>{if(!Kb())return;let e=!0;return Gb().then(n=>{e&&t(n)}),()=>{e=!1}},[]),e}function Jb(e){let t=e.onComplete,n=e.onSecondFactor;return typeof t==`function`?{onComplete:t,onSecondFactor:typeof n==`function`?n:void 0}:null}function Yb({methods:e,widgetConfig:t,onRedirect:n}){let{t:r}=Z();qa();let i=qb(),a=e.filter(e=>e.kind!==`passkey`||Hb(e,void 0,i));return a.length===0?null:s(`div`,{className:`mt-6 space-y-3`,children:[s(`div`,{className:`flex items-center gap-3`,children:[v(`div`,{className:`h-px flex-1 bg-border`}),v(`span`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle`,children:r(`login.primaryLoginMethods.orContinueWith`,`Or continue with`)}),v(`div`,{className:`h-px flex-1 bg-border`})]}),v(`div`,{className:`space-y-2`,children:a.map(e=>{if(e.kind===`redirect`){let t=(e.icon===void 0?void 0:Xr(e.icon))??N;return s(`a`,{href:e.startUrl,onClick:t=>{n?.(e)===!0&&t.preventDefault()},className:`flex items-center justify-center gap-2 w-full rounded-lg border border-border bg-surface px-4 py-2.5 text-sm font-medium text-foreground hover:bg-surface-hover transition-colors`,children:[v(t,{className:`h-4 w-4 text-primary`}),e.label]},e.id)}if(e.kind===`passkey`){let n=Jb(t);return n?v(Bb,{method:e,onComplete:n.onComplete,onSecondFactor:n.onSecondFactor},e.id):null}return v(Xb,{method:e,config:t},e.id)})})]})}function Xb({method:e,config:t}){let{t:n}=Z(),r=Wr(e.remote,e.bundleUrl);return r===null?s(`div`,{className:`flex items-center justify-center gap-2 rounded-lg border border-border bg-background px-4 py-2.5 text-xs text-foreground-subtle`,children:[v(H,{className:`h-3.5 w-3.5 animate-spin`}),n(`common.loading`,`Loading…`)]}):r===void 0?s(`div`,{"data-testid":`login-method-load-error`,className:`flex items-center justify-center gap-2 rounded-lg border border-danger/20 bg-danger/10 px-4 py-2.5 text-xs text-danger`,children:[v(Ue,{className:`h-3.5 w-3.5 shrink-0`}),n(`login.primaryMethods.loadFailed`)]}):v(r,{instanceId:e.id,host:`dashboard`,config:t})}var Zb=4e3,Qb=/^[A-Za-z0-9._-]{1,64}$/;function $b(e){if(e.action===`cli-login`)return nb(`access`);let t=e.addonId!==void 0&&Qb.test(e.addonId)?e.addonId:null,n=e.integration!==void 0&&Qb.test(e.integration)?e.integration:null;if(t!==null&&e.brokerId!==void 0)return nb(`connectivity`,{integration:t,kindSection:`brokers`});let r=n??t;return nb(`connectivity`,r===null?{}:{integration:r})}function ex(e,t){let n=t.opener;if(n===null||n.closed||Ro(n)!==t.origin)return!1;try{return n.postMessage({type:Go,ok:e.status===`success`,...e.brokerId===void 0?{}:{brokerId:e.brokerId},...e.status===`error`?{error:e.reason??`unknown`}:{}},t.origin),!0}catch{return!1}}T();var tx=500;function nx(e){let{t}=Z();switch(e){case`access_denied`:return t(`oauthLanding.reason.access_denied`,`Access was denied, so nothing was connected.`);case`invalid_state`:return t(`oauthLanding.reason.invalid_state`,`This sign-in link expired or was already used. Start the sign-in again.`);case`invalid_request`:return t(`oauthLanding.reason.invalid_request`,`The request was not valid for this hub. Start the link again from the beginning.`);case`unknown_broker`:return t(`oauthLanding.reason.unknown_broker`,`That connection no longer exists. Add it again, then sign in.`);case`not_configured`:return t(`oauthLanding.reason.not_configured`,`The connection is missing its client ID or secret. Fill them in, save, then sign in.`);case`exchange_failed`:return t(`oauthLanding.reason.exchange_failed`,`The provider did not accept the sign-in. Check the client ID and secret, then try again.`);case`no_authorization_code`:return t(`oauthLanding.reason.no_authorization_code`,`The provider finished the sign-in without granting Dominevo access. Start the sign-in again from the beginning.`);case`no_refresh_token`:return t(`oauthLanding.reason.no_refresh_token`,`The provider returned no long-lived access. Remove Dominevo from the account’s connected apps, then sign in again.`);case`unavailable`:return t(`oauthLanding.reason.unavailable`,`The hub is still starting this integration. Wait a moment and try again.`);case`unknown`:return t(`oauthLanding.reason.unknown`,`Something went wrong. Try again in a moment.`)}}function rx({outcome:e}){let{t}=Z(),n=nx(e.reason??`unknown`);if(e.status===`error`)return s(j,{children:[v(Je,{className:`mx-auto h-8 w-8 text-danger`,"aria-hidden":!0}),v(`h1`,{"data-testid":`oauth-landing-title`,className:`text-sm font-semibold text-foreground`,children:t(`oauthLanding.errorTitle`,`Sign-in did not finish`)}),v(`p`,{"data-testid":`oauth-landing-reason`,className:`rounded-md border border-danger/20 bg-danger/10 px-3 py-2 text-xs text-danger`,children:n})]});if(e.action===`cli-login`)return s(j,{children:[v(Ve,{className:`mx-auto h-8 w-8 text-success`,"aria-hidden":!0}),v(`h1`,{"data-testid":`oauth-landing-title`,className:`text-sm font-semibold text-foreground`,children:t(`oauthLanding.cliLoginTitle`,`Terminal signed in`)}),v(`p`,{className:`text-xs text-foreground-muted`,children:t(`oauthLanding.cliLoginBody`,`Go back to your terminal: it finishes the sign-in by itself.`)})]});let r=e.action===`disconnect`;return s(j,{children:[v(Ve,{className:`mx-auto h-8 w-8 text-success`,"aria-hidden":!0}),v(`h1`,{"data-testid":`oauth-landing-title`,className:`text-sm font-semibold text-foreground`,children:r?t(`oauthLanding.signedOutTitle`,`Signed out`):t(`oauthLanding.successTitle`,`Signed in`)}),v(`p`,{className:`text-xs text-foreground-muted`,children:r?t(`oauthLanding.signedOutBody`,`The account was disconnected from this hub.`):t(`oauthLanding.successBody`,`The account is connected. Returning to Dominevo…`)})]})}function ix({outcome:e,closable:t,onContinue:n,onClose:r}){let{t:i}=Z(),a=$b(e);return y(()=>{if(e.status!==`success`)return;let t=window.setTimeout(()=>n(a),Zb);return()=>window.clearTimeout(t)},[e.status,n,a]),v(`main`,{className:`flex min-h-screen items-center justify-center bg-background p-4`,children:s(`div`,{className:`w-full max-w-sm space-y-4`,children:[v(`div`,{className:`flex justify-center`,children:s(`picture`,{children:[v(`source`,{media:`(prefers-color-scheme: dark)`,srcSet:V(`/brand/logo-horizontal-dark.svg`)}),v(`img`,{src:V(`/brand/logo-horizontal-light.svg`),alt:i(`oauthLanding.brand`,`Dominevo`),className:`h-12`})]})}),s(`div`,{className:`space-y-4 rounded-xl border border-border bg-surface p-6 text-center shadow-xl shadow-black/10`,children:[v(rx,{outcome:e}),s(`div`,{className:`flex flex-col gap-2`,children:[v(W,{type:`button`,variant:`primary`,onClick:()=>n(a),children:i(`oauthLanding.back`,`Back to Dominevo`)}),t&&v(W,{type:`button`,variant:`ghost`,onClick:r,children:i(`oauthLanding.close`,`Close this window`)})]})]})]})})}function ax(e,t){window.history.replaceState(null,``,window.location.pathname);let n=window.opener,r=ex(t,{opener:n,origin:window.location.origin}),i=()=>e.render(v(ix,{outcome:t,closable:r,onContinue:e=>window.location.replace(V(e)),onClose:()=>window.close()}));if(r&&t.status===`success`){window.close(),window.setTimeout(i,tx);return}i()}function ox(e){return un(e)}var sx=`Done — you can close this window.`,cx=500,lx=`dominevo_admin_token`;async function ux(e,t=``){try{let n=ps(new URLSearchParams(t));n!==null&&n.token===e?hs(n):localStorage.setItem(lx,e)}catch{}await fetch(V(`/api/auth/session`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({token:e})}).catch(()=>{})}function dx(){try{let e=localStorage.getItem(lx);return e!==null&&e.length>0?e:null}catch{return null}}function fx(e){let t=ox(window.location.hash);if(t!==null){ax(e,t);return}let n=No(window.location.hash);window.history.replaceState(null,``,window.location.pathname);let r=t=>e.render(v(px,{completion:n,result:t,hasOpener:window.opener!==null}));if(r(null),n===null)return;let i=zo();Vo(n,{opener:window.opener,origin:window.location.origin,channel:i,addEventListener:(e,t)=>window.addEventListener(e,t),removeEventListener:(e,t)=>window.removeEventListener(e,t),close:()=>{window.close(),window.setTimeout(()=>r({kind:`done`,message:sx}),cx)},continueAt:e=>window.location.replace(V(e)),persistSession:e=>ux(e,n.target===`login`?n.fragment:``),showResult:r,setTimeout:(e,t)=>window.setTimeout(e,t)})}function px({completion:e,result:t,hasOpener:n=!0}){let{t:r}=Z();return v(`div`,{className:`flex min-h-screen items-center justify-center bg-background p-4`,children:v(`div`,{className:`flex flex-col items-center gap-3 text-sm text-foreground-subtle`,children:e===null?v(`a`,{className:`text-primary underline`,href:V(`/login`),children:r(`ssoComplete.nothingToFinishHereGo`,`Nothing to finish here — go to sign-in`)}):t===null?s(`span`,{className:`flex items-center gap-3`,children:[v(`span`,{className:`h-4 w-4 animate-spin rounded-full border-2 border-primary/30 border-t-primary`}),r(`ssoComplete.finishingSignIn`,`Finishing sign-in…`)]}):s(j,{children:[v(`span`,{"data-testid":`sso-complete-result`,className:t.kind===`link-error`?`text-danger`:`text-foreground`,children:t.message}),v(W,{variant:`unstyled`,type:`button`,className:`rounded-md border border-border px-3 py-1.5 text-foreground hover:bg-surface-hover`,onClick:()=>window.close(),children:r(`ssoComplete.closeThisWindow`,`Close this window`)}),!n&&v(`a`,{className:`text-primary underline`,href:V(`/login`),children:r(`ssoComplete.backToSignIn`,`Back to sign-in`)})]})})})}T();function mx(e){if(typeof e!=`object`||!e)return!1;let t=Reflect.get(e,`message`),n=Reflect.get(e,`data`);return(typeof n==`object`&&n?Reflect.get(n,`code`):void 0)===`FORBIDDEN`||typeof t==`string`&&/sign in again first/i.test(t)}function hx(){let e=new URLSearchParams(window.location.search);return ss({codeChallenge:e.get(`code_challenge`),codeChallengeMethod:e.get(`code_challenge_method`),state:e.get(`state`),purpose:e.get(`purpose`)})}function gx(e){return Math.min(1e3*2**e,15e3)}function _x(){let{t:e}=Z(),{login:t,verifyTotp:n,finalizePasskeyLogin:r,user:i}=os(),{i18n:a}=Z(),o=ji(),c=_o(),l=mo(),u=new URLSearchParams(window.location.search).get(`next`);y(()=>{is(u)},[u]);let f=new URLSearchParams(window.location.search).get(`redirect`);y(()=>{fs(f)},[f]);let p=hx();y(()=>{Qo(p)},[p?.codeChallenge,p?.state,p?.purpose]);let m=l.state,h=Ty(m?.from),[g,_]=x(``),[b,S]=x(``),[C,w]=x(!1),[T,E]=x(``),[D,O]=x(!1),[k,A]=x(`credentials`),[M,N]=x(``),[P,F]=x([]),[ee,te]=x(``),[ne,re]=x(void 0),[ie,ae]=x(`sso-not-linked`),oe=gr.auth.listLoginMethods.useQuery(void 0,{retry:!0,retryDelay:gx}),se=oe.data===void 0,ce=(oe.data??[]).filter(e=>e.kind!==`device-certificate`),I=gr.auth.getServerName.useQuery().data,le=ce.filter(e=>e.stage===`primary`),ue=Ub(ce,void 0,qb());y(()=>{let e=Ho(window.location.hash);if(e!==null){if(window.history.replaceState({},``,window.location.pathname+window.location.search),e.kind===`challenge`){N(e.challengeToken),F(e.factors),te(``),A(`second-factor`);return}ae(e.code),re(e.provider)}},[]);let de=ne==null?null:ce.find(e=>e.id===ne&&`label`in e)?.label??null,fe=T||(ne===void 0?``:Fo(ie,de)),{passkeyMethods:pe,widgetMethods:L}=ue,R=d(!1),z=async()=>{if(R.current)return;R.current=!0;let e=es(f);if(e?.kind===`app-callback`){await he(e.url);return}else if(e){window.location.assign(V(e.path));return}let t=$o(u);t?window.location.assign(V(t)):c(h,{replace:!0})},[me,B]=x(null),he=async e=>{B({callbackBase:e,mintedUrl:null,failed:!1});try{let t=hx()??Xo();if(t===null)throw Error(`The app sent no PKCE challenge and state`);let{code:n}=await Zo().trpcClient.auth.createHandoffCode.mutate({purpose:t.purpose,codeChallenge:t.codeChallenge,state:t.state}),r=rs(e,n,t.state);B({callbackBase:e,mintedUrl:r,failed:!1}),window.location.assign(r)}catch(t){if(mx(t)){R.current=!1,B(null),E(`Sign in again to confirm it is you.`);return}B({callbackBase:e,mintedUrl:null,failed:!0})}},ge=i!==null,[_e,ve]=x(!1);y(()=>{!ge||!f&&!u||_e||(ve(!0),z())},[ge,f,u,_e]);let ye=async e=>{e.preventDefault(),E(``),re(void 0),O(!0);try{let e=await t(g,b);if(e.kind===`second-factor`){N(e.challengeToken),F(e.factors),A(`second-factor`);return}b===`changeme`?c(`/change-password`,{replace:!0}):await z()}catch(e){E(e instanceof Error?e.message:`Login failed`)}finally{O(!1)}},be=async e=>{e.preventDefault(),E(``),O(!0);try{await n(M,ee.trim()),await z()}catch(e){E(e instanceof Error?e.message:`TOTP verification failed`),te(``)}finally{O(!1)}},xe=async(e,t)=>{try{await r(e,t),await z()}catch(e){E(e instanceof Error?e.message:`Passkey sign-in failed`)}},Se=d(null);y(()=>()=>Se.current?.(),[]);let Ce=async e=>{if(e.target!==`login`)return;let t=ps(new URLSearchParams(e.fragment));if(t!==null){try{await r(t.token,t),await z()}catch(e){E(e instanceof Error?e.message:`Sign-in failed`)}return}let n=Ho(`#${e.fragment}`);if(n!==null){if(n.kind===`challenge`){Ee({challengeToken:n.challengeToken,factors:n.factors});return}ae(n.code),re(n.provider)}},Te=e=>{if(us(f)?.kind===`app-callback`)return!1;let t=Io(V(Po(e.startUrl)));return t===null?!1:(E(``),re(void 0),Se.current?.(),Se.current=Bo(t,{onReturn:e=>{Se.current?.(),Se.current=null,Ce(e)},onDone:e=>{if(Se.current?.(),Se.current=null,e.target!==`login`)return;let t=dx()===null?null:as();t!==null&&Ce({target:`login`,fragment:new URLSearchParams({token:t.token,...t.refreshToken===void 0?{}:{refreshToken:t.refreshToken},...t.expiresAt===void 0?{}:{expiresAt:String(t.expiresAt)}}).toString()})}}),!0)},Ee=e=>{let t=e.factors.filter(e=>e===`totp`||e===`passkey`);N(e.challengeToken),F(t),te(``),E(``),A(`second-factor`)};return me===null?v(`div`,{className:`flex min-h-screen items-center justify-center bg-background p-4`,children:s(`div`,{className:`w-full max-w-sm`,children:[v(`div`,{className:`flex justify-center mb-8`,children:v(`img`,{src:o?.resolvedMode===`light`?V(`/brand/logo-horizontal-light.svg`):V(`/brand/logo-horizontal-dark.svg`),alt:e(`login.dominevoAdmin`,`Dominevo Admin`),className:`h-12`})}),I!==void 0&&!I.isDefault&&v(`p`,{"data-testid":`login-server-name`,className:`-mt-4 mb-6 text-center text-sm text-foreground-muted`,children:v(Pc,{i18nKey:`login.signInTo`,values:{name:I.name},components:{b:v(`span`,{className:`font-semibold text-foreground`})}})}),k===`credentials`?s(`form`,{onSubmit:ye,className:`space-y-4 rounded-xl border border-border bg-surface p-6 shadow-xl shadow-black/10`,children:[fe&&v(`div`,{"data-testid":`login-error`,className:`rounded-md bg-danger/10 border border-danger/20 px-3 py-2 text-xs text-danger`,children:fe}),s(`div`,{className:`space-y-1.5`,children:[v(`label`,{className:`text-xs font-medium text-foreground-subtle`,children:e(`login.username`,`Username`)}),v(U,{"data-testid":`login-username`,type:`text`,placeholder:e(`login.username`,`Username`),value:g,onChange:e=>_(e.target.value),className:`w-full rounded-lg border border-border bg-background px-3 py-2.5 text-sm text-foreground placeholder:text-foreground-disabled focus:border-primary focus:ring-1 focus:ring-primary/30 outline-none transition-all`,autoFocus:!0})]}),s(`div`,{className:`space-y-1.5`,children:[v(`label`,{className:`text-xs font-medium text-foreground-subtle`,children:e(`login.password`,`Password`)}),s(`div`,{className:`relative`,children:[v(U,{"data-testid":`login-password`,type:C?`text`:`password`,placeholder:e(`login.password`,`Password`),value:b,onChange:e=>S(e.target.value),className:`w-full rounded-lg border border-border bg-background px-3 py-2.5 pr-10 text-sm text-foreground placeholder:text-foreground-disabled focus:border-primary focus:ring-1 focus:ring-primary/30 outline-none transition-all`}),v(W,{variant:`unstyled`,type:`button`,onClick:()=>w(!C),className:`absolute right-2.5 top-1/2 -translate-y-1/2 text-foreground-subtle hover:text-foreground transition-colors`,tabIndex:-1,children:v(C?kt:we,{className:`h-4 w-4`})})]})]}),v(W,{variant:`unstyled`,"data-testid":`login-submit`,type:`submit`,disabled:D||!g||!b,className:`w-full rounded-lg bg-primary px-4 py-2.5 text-sm font-semibold text-primary-foreground shadow-md shadow-primary/20 hover:shadow-lg hover:shadow-primary/30 disabled:opacity-50 disabled:shadow-none transition-all`,children:D?s(`span`,{className:`flex items-center justify-center gap-2`,children:[v(`span`,{className:`h-4 w-4 animate-spin rounded-full border-2 border-primary-foreground/30 border-t-primary-foreground`}),e(`login.loggingIn`,`Logging in...`)]}):e(`login.logIn`,`Log in`)})]}):s(`div`,{className:`space-y-4 rounded-xl border border-border bg-surface p-6 shadow-xl shadow-black/10`,children:[s(`div`,{className:`flex items-center gap-2 pb-1 border-b border-border`,children:[v(Oe,{className:`h-4 w-4 text-primary`}),v(`div`,{className:`text-sm font-medium text-foreground`,children:e(`login.twoFactorAuthentication`,`Two-factor authentication`)})]}),v(`p`,{className:`text-xs text-foreground-subtle`,children:g?v(j,{children:v(Pc,{i18nKey:`login.finishSigningInAs`,values:{username:g},components:{mono:v(`span`,{className:`font-mono text-foreground`})}})}):e(`login.finishSigningInAs`,`Finish signing in.`)}),T&&v(`div`,{className:`rounded-md bg-danger/10 border border-danger/20 px-3 py-2 text-xs text-danger`,children:T}),P.includes(`passkey`)&&pe.map(e=>v(Bb,{method:e,challengeToken:M,onComplete:xe},e.id)),P.includes(`passkey`)&&L.map(e=>v(Xb,{method:e,config:{challengeToken:M,onComplete:xe}},e.id)),Wb(P,ue)&&v(`div`,{className:`rounded-md border border-border bg-background px-3 py-2 text-xs text-foreground-subtle`,children:e(`login.passkeyVerificationIsnTAvailable`,`Passkey verification isn't available on this address. Open the hub via its domain URL to complete sign-in.`)}),P.includes(`passkey`)&&P.includes(`totp`)&&s(`div`,{className:`flex items-center gap-3`,children:[v(`div`,{className:`h-px flex-1 bg-border`}),v(`span`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle`,children:`or`}),v(`div`,{className:`h-px flex-1 bg-border`})]}),P.includes(`totp`)&&s(`form`,{onSubmit:be,className:`space-y-4`,children:[s(`div`,{className:`space-y-1.5`,children:[v(`label`,{className:`text-xs font-medium text-foreground-subtle`,children:e(`login.authenticationCode`,`Authentication code`)}),v(U,{"data-testid":`login-totp`,type:`text`,inputMode:`numeric`,autoComplete:`one-time-code`,placeholder:`123456`,value:ee,onChange:e=>te(e.target.value.replace(/\D/g,``).slice(0,6)),className:`w-full rounded-lg border border-border bg-background px-3 py-3 text-center text-2xl font-mono tracking-widest text-foreground placeholder:text-foreground-disabled focus:border-primary focus:ring-1 focus:ring-primary/30 outline-none transition-all`,autoFocus:!0})]}),v(W,{variant:`unstyled`,"data-testid":`login-totp-submit`,type:`submit`,disabled:D||ee.length!==6,className:`w-full rounded-lg bg-primary px-4 py-2.5 text-sm font-semibold text-primary-foreground shadow-md shadow-primary/20 hover:shadow-lg hover:shadow-primary/30 disabled:opacity-50 disabled:shadow-none transition-all`,children:D?s(`span`,{className:`flex items-center justify-center gap-2`,children:[v(`span`,{className:`h-4 w-4 animate-spin rounded-full border-2 border-primary-foreground/30 border-t-primary-foreground`}),e(`login.verifying`,`Verifying...`)]}):e(`login.verifyAndSignIn`,`Verify and sign in`)})]}),s(W,{variant:`unstyled`,type:`button`,onClick:()=>{A(`credentials`),N(``),F([]),te(``),E(``)},className:`w-full flex items-center justify-center gap-1.5 text-xs text-foreground-subtle hover:text-foreground transition-colors`,children:[v(Ze,{className:`h-3 w-3`}),e(`login.backToUsernamePassword`,`Back to username + password`)]})]}),k===`credentials`&&se&&s(`p`,{"data-testid":`login-methods-pending`,role:`status`,className:`mt-4 flex items-center justify-center gap-2 text-xs text-foreground-subtle`,children:[v(`span`,{className:`h-3 w-3 animate-spin rounded-full border-2 border-foreground-subtle/30 border-t-foreground-subtle`}),e(`login.methodsPending`,`Loading other sign-in options...`)]}),k===`credentials`&&v(Yb,{methods:le,widgetConfig:{onComplete:xe,onSecondFactor:Ee,locale:a.language},onRedirect:Te}),v(`p`,{className:`mt-6 text-center text-[10px] text-foreground-subtle/50`,children:v(My,{placement:`login`})})]})}):v(`div`,{className:`flex min-h-screen items-center justify-center bg-background p-4`,children:s(`div`,{className:`w-full max-w-sm rounded-xl border border-border bg-surface p-6 text-center space-y-4`,children:[v(`h1`,{className:`text-sm font-semibold text-foreground`,children:e(`login.returningToTheApp`,`Returning to the app…`)}),me.failed?s(j,{children:[v(`p`,{className:`text-xs text-danger`,children:e(`login.couldNotPrepareTheSign`,`Could not prepare the sign-in handoff. You are logged in — retry below.`)}),v(W,{variant:`unstyled`,onClick:()=>void he(me.callbackBase),className:`inline-flex rounded-lg bg-primary px-4 py-2 text-sm font-medium text-primary-foreground hover:bg-primary/90`,children:e(`common.retry`,`Retry`)})]}):me.mintedUrl===null?v(`p`,{className:`text-xs text-foreground-subtle`,children:e(`login.preparingAOneTimeSign`,`Preparing a one-time sign-in code…`)}):s(j,{children:[v(`p`,{className:`text-xs text-foreground-subtle`,children:e(`login.ifTheAppDoesNot`,`If the app does not open automatically, tap below (the code expires in 60s).`)}),v(`a`,{href:me.mintedUrl,className:`inline-flex rounded-lg bg-primary px-4 py-2 text-sm font-medium text-primary-foreground hover:bg-primary/90`,children:e(`login.openDominevo`,`Open Dominevo`)})]})]})})}function vx(e){let t=new URLSearchParams(e).get(w_),n=new URLSearchParams({tab:`templates`});return t!==null&&n.set(w_,t),`/build?${n.toString()}`}function yx(){let{search:e}=mo();return v(Y,{to:vx(e),replace:!0})}T();function bx(){let{pathname:e,search:t,hash:n}=mo();return v(Y,{to:`${ab(e)}${t}${n}`,replace:!0})}function xx(){let{pathname:e,search:t}=mo();return v(Y,{to:uc(e,t)??`/archive`,replace:!0})}function Sx(){let{nodeId:e=``}=go();return v(Y,{to:`/system/terminal?tab=shells&node=${encodeURIComponent(e)}`,replace:!0})}function Cx(){let{pathname:e,search:t}=mo(),n=uc(e,t);return n===null?v(Nx,{}):v(Y,{to:n,replace:!0})}function wx(){return v(Y,{to:Cy()??`/devices`,replace:!0})}var Tx=m(()=>a(()=>import(`./Devices-Dv9L-Kji.js`).then(e=>({default:e.DevicesPage})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12]),import.meta.url)),Ex=m(()=>a(()=>import(`./Integrations-ClCrv1nX.js`).then(e=>({default:e.IntegrationsPage})),__vite__mapDeps([13,1,2,3,4,5,14,6,15,7,8,9,11]),import.meta.url)),Dx=m(()=>a(()=>import(`./IntegrationDetail-CXJ4DIj2.js`).then(e=>({default:e.IntegrationDetailPage})),__vite__mapDeps([16,1,2,3,4,5,17,6,7,18,14,9,10]),import.meta.url)),Ox=m(()=>a(()=>import(`./Pipeline-D6QSFY4L.js`).then(e=>({default:e.PipelinePage})),__vite__mapDeps([19,1,2,3,4,5,14,6,20,21,22,23,7,24,18,25,26,27,28,11]),import.meta.url)),kx=m(()=>a(()=>import(`./DeviceDetail-BxkGFnI2.js`).then(e=>({default:e.DeviceDetailPage})),__vite__mapDeps([29,1,2,3,4,5,14,6,20,30,31,32,33,34,23,35,7,36,22,37,38,39,40,41,42,43,26,44,45,28,11,46,47]),import.meta.url)),Ax=m(()=>a(()=>import(`./Showroom-DSZ7_JVJ.js`).then(e=>({default:e.ShowroomPage})),__vite__mapDeps([48,1,2,3,4,5,18,14,6]),import.meta.url)),jx=m(()=>a(()=>import(`./EmbedPlayerPage-C2A2ZfFZ.js`).then(e=>({default:e.EmbedPlayerPage})),__vite__mapDeps([49,1,2,3,4,5,6]),import.meta.url)),Mx=m(()=>a(()=>import(`./EmbedDevicePage-DcLTsAsw.js`).then(e=>({default:e.EmbedDevicePage})),__vite__mapDeps([50,1,2,3,4,5,6,7,44,14,45]),import.meta.url)),Nx=m(()=>a(()=>import(`./Library-FfhywvlF.js`).then(e=>({default:e.LibraryPage})),__vite__mapDeps([51,1,2,3,4,5,14,6,20,52,22,53,7,54,55,56,46,45,57]),import.meta.url)),Px=m(()=>a(()=>import(`./Archive-ByC3bXel.js`).then(e=>({default:e.ArchivePage})),__vite__mapDeps([58,1,2,3,4,5,14,6,20,59,53,7,54,55,60,61,62,63,64,24,18,25,65,45,66,57,46]),import.meta.url)),Fx=m(()=>a(()=>import(`./Viewer-2F_bb_FE.js`).then(e=>({default:e.ViewerPage})),__vite__mapDeps([67,68,2,6]),import.meta.url)),Ix=m(()=>a(()=>import(`./Build-DfH4qlmf.js`).then(e=>({default:e.BuildPage})),__vite__mapDeps([69,1,2,3,4,5,14,6,20,33,70,7,54,36,30,22,37,38,39,40,35,41,43,18,28,71]),import.meta.url)),Lx=m(()=>a(()=>import(`./CompositionEditorPage-DOy1_xa6.js`).then(e=>({default:e.CompositionEditorPage})),__vite__mapDeps([72,1,2,3,4,5,6,7,8,36,14,20,30,22,37,38,39]),import.meta.url)),Rx=m(()=>a(()=>import(`./Locations-DKSaqyPH.js`).then(e=>({default:e.LocationsPage})),__vite__mapDeps([73,1,2,3,4,5,14,6,7,54,42,38,39]),import.meta.url)),zx=m(()=>a(()=>import(`./Addons-Dqwyi0aS.js`).then(e=>({default:e.AddonsPage})),__vite__mapDeps([74,1,2,3,4,5,20,6,7,8,75,24,18,14,25,12,45]),import.meta.url)),Bx=m(()=>a(()=>import(`./AiProfiles-SI2Iyt3F.js`).then(e=>({default:e.AiProfilesPage})),__vite__mapDeps([76,1,2,3,4,5,14,6,77,78,7,8,54,63,64,24,18,25,65,45,66,79]),import.meta.url)),Vx=m(()=>a(()=>import(`./MyAccess-Dq0fJGPb.js`).then(e=>({default:e.MyAccessPage})),__vite__mapDeps([80,1,2,3,4,5,14,6,20,81,35,7,8,54,82,44,45,66]),import.meta.url)),Hx=m(()=>a(()=>import(`./Logs-C13uuzLz.js`).then(e=>({default:e.LogsPage})),__vite__mapDeps([83,1,2,3,4,5,23,84,6,7,8,54,63,64,24,18,14,25,65,45,66]),import.meta.url)),Ux=m(()=>a(()=>import(`./Identity-BzYQSoVB.js`).then(e=>({default:e.IdentityPage})),__vite__mapDeps([85,1,2,3,4,5,14,6,20,34,86,81,35,7,8,54,63,64,24,18,25,65,45,66,82,44,87]),import.meta.url)),Wx=m(()=>a(()=>import(`./Network-BVOnr0mt.js`).then(e=>({default:e.NetworkPage})),__vite__mapDeps([88,1,2,3,4,5,14,6,20,89,7,8,54,63,64,24,18,25,65,45,66,90,91]),import.meta.url)),Gx=m(()=>a(()=>import(`./Integrations-B7lFcabS.js`).then(e=>({default:e.IntegrationsPage})),__vite__mapDeps([92,1,2,3,4,5,6,7,54,63,64,24,18,14,25,65,45,66]),import.meta.url)),Kx=m(()=>a(()=>import(`./TrainingProviders-BsfUFtDp.js`).then(e=>({default:e.TrainingProvidersPage})),__vite__mapDeps([93,1,2,3,4,5,6,7,8,63,64,24,18,14,25,65,45,66]),import.meta.url)),qx=m(()=>a(()=>import(`./Data-wkMPgPIi.js`).then(e=>({default:e.DataPage})),__vite__mapDeps([94,1,2,3,4,5,14,6,20,31,95,62,7,8,54,63,64,24,18,25,65,45,66,60,61,57,46]),import.meta.url)),Jx=m(()=>a(()=>import(`./System-C2tFswFM.js`).then(e=>({default:e.SystemPage})),__vite__mapDeps([96,1,2,3,4,5,14,6,97,7,8,54,87,18,25,45]),import.meta.url)),Yx=m(()=>a(()=>import(`./Cluster-Ul0y1bLm.js`).then(e=>({default:e.ClusterPage})),__vite__mapDeps([98,1,2,3,4,5,14,6,62,99,35,7,8,75,43,24,18,25,27,57]),import.meta.url)),Xx=m(()=>a(()=>import(`./Terminal-CD78nora.js`).then(e=>({default:e.TerminalPage})),__vite__mapDeps([100,1,2,3,4,5,20,6,7,8,63,64,24,18,14,25,65,45,66,37,43,90,101]),import.meta.url)),Zx=m(()=>a(()=>import(`./Notifications-DF8en3Zl.js`).then(e=>({default:e.NotificationsPage})),__vite__mapDeps([102,1,2,3,4,5,14,6,77,103,7,8,54,63,64,24,18,25,65,45,66,43,56,71,41,79,39,47]),import.meta.url)),Qx=m(()=>a(()=>import(`./History-Am70bV1z.js`).then(e=>({default:e.HistoryPage})),__vite__mapDeps([104,1,2,3,4,5,20,6,7,8]),import.meta.url)),$x=m(()=>a(()=>import(`./Jobs-D9dl7u2u.js`).then(e=>({default:e.JobsPage})),__vite__mapDeps([105,1,2,3,4,5,14,6,8]),import.meta.url)),eS=m(()=>a(()=>import(`./Calendars-K1Z15Ly2.js`).then(e=>({default:e.CalendarsPage})),__vite__mapDeps([106,1,2,3,4,5,14,6,7,8]),import.meta.url)),tS=new w({defaultOptions:{queries:{gcTime:0,staleTime:0,retry:!1,refetchOnWindowFocus:!1}}});no(tS);function nS({field:e,value:t,onChange:n,disabled:r}){return v(rg,{field:e,value:t,onChange:n,disabled:r})}var rS={"model-selector":nS};function iS({children:e}){let{t}=Z(),{user:n,logout:r}=os(),[i,a]=x(0),o=d(n?.username??null);y(()=>{let e=n?.username??null;e!==o.current&&(o.current=e,ms(),a(e=>e+1))},[n]);let c=f(()=>Zo(),[i]),l=_(()=>{Zo().reconnect(),a(e=>e+1),tS.invalidateQueries()},[]);Og(_(()=>ns(l),[l])),y(()=>cs(()=>{Zo().isSocketTokenStale()&&l()}),[l]);let u=_(async()=>{let e=await ts();return e&&l(),e},[l]),{bootReady:p,bootError:m}=Eg(c,n??null,r,u);return v(Cg,{children:v(fe,{system:c,children:v(gr.Provider,{client:c.trpcClient,queryClient:tS,children:s(Dr,{children:[v(Ha,{children:v(Ui,{children:v(Ra,{children:p?e:v(aS,{})})})}),p&&v(lg,{}),m!==null&&p&&s(`div`,{className:`fixed bottom-[calc(env(safe-area-inset-bottom)+1rem)] right-[calc(env(safe-area-inset-right)+1rem)] z-50 max-w-sm rounded-lg border border-warning/30 bg-warning/10 px-3 py-2 text-xs text-warning shadow-lg`,children:[t(`app.bootProbeFailed`,`Boot probe failed:`),` `,m,`. Retrying in background.`]})]})})})})}function aS(){let{t:e}=Z();return v(`div`,{className:`flex min-h-screen items-center justify-center bg-background`,children:s(`div`,{className:`flex items-center gap-3 text-sm text-foreground-subtle`,children:[v(`span`,{className:`h-4 w-4 animate-spin rounded-full border-2 border-primary/30 border-t-primary`}),e(`app.connecting`,`Connecting…`)]})})}function oS(){return v(`div`,{className:`flex min-h-screen items-center justify-center bg-background`,children:v(`span`,{className:`h-4 w-4 animate-spin rounded-full border-2 border-primary/30 border-t-primary`})})}function sS(){return y(()=>lb(),[]),v(Qa,{defaultMode:`dark`,children:v(ct,{children:v(A,{client:tS,children:v(ds,{children:v(iS,{children:v(Ye,{children:v(cg,{children:v(oi,{renderers:rS,children:s(ui,{picker:qf,children:[v(So,{basename:bt(),children:v(Zh,{children:v(g,{fallback:v(oS,{}),children:s(xo,{children:[v(J,{path:`/login`,element:v(_x,{})}),v(J,{path:`/admin/*`,element:v(bx,{})}),v(J,{path:`/admin`,element:v(bx,{})}),v(J,{path:`/change-password`,element:v($,{children:v(Rb,{})})}),v(J,{path:`/approve`,element:v($,{children:v(Mb,{})})}),v(J,{path:`/showroom`,element:v(Ax,{})}),v(J,{path:`/embed/player`,element:v(jx,{})}),v(J,{path:`/embed/device/:deviceId`,element:v($,{children:v(Mx,{})})}),s(J,{element:v($,{children:v($d,{children:v(Xy,{})})}),children:[v(J,{index:!0,element:v(wx,{})}),v(J,{path:`/access-denied`,element:v(ub,{})}),v(J,{path:`/dashboard`,element:v(Y,{to:`/devices`,replace:!0})}),v(J,{path:`/devices`,element:v(Tx,{})}),v(J,{path:`/cameras`,element:v(Y,{to:`/devices`,replace:!0})}),v(J,{path:`/integrations`,element:v(Ex,{})}),v(J,{path:`/integrations/:addonId`,element:v(Dx,{})}),v(J,{path:`/system/pipeline`,element:v(l_,{path:`/system/pipeline`,children:v(Ox,{})})}),v(J,{path:`/pipeline`,element:v(Y,{to:`/system/pipeline`,replace:!0})}),v(J,{path:`/live`,element:v(Fx,{})}),v(J,{path:`/devices/:deviceId`,element:v(kx,{})}),v(J,{path:`/system/logs`,element:v($,{requireAdmin:!0,children:v(Hx,{})})}),v(J,{path:`/system/addons`,element:v($,{requireAdmin:!0,children:v(zx,{})})}),v(J,{path:`/system/ai`,element:v($,{requireAdmin:!0,children:v(Bx,{})})}),v(J,{path:`/system/settings`,element:v($,{requireAdmin:!0,children:v(Jx,{})})}),v(J,{path:`/system/nodes`,element:v($,{requireAdmin:!0,children:v(Yx,{})})}),v(J,{path:`/system/notifications`,element:v($,{requireAdmin:!0,children:v(Zx,{})})}),v(J,{path:`/system/history`,element:v($,{requireAdmin:!0,children:v(Qx,{})})}),v(J,{path:`/system/jobs`,element:v($,{requireAdmin:!0,children:v($x,{})})}),v(J,{path:`/system/calendars`,element:v($,{requireAdmin:!0,children:v(eS,{})})}),v(J,{path:`/system/templates`,element:v(yx,{})}),v(J,{path:`/system/identity`,element:v($,{requireAdmin:!0,children:v(Ux,{})})}),v(J,{path:`/system/my-access`,element:v(Vx,{})}),v(J,{path:`/system/network`,element:v($,{requireAdmin:!0,children:v(Wx,{})})}),v(J,{path:`/training/providers`,element:v($,{requireAdmin:!0,children:v(Kx,{})})}),v(J,{path:`/system/integrations`,element:v($,{requireAdmin:!0,children:v(Gx,{})})}),v(J,{path:`/system/data`,element:v($,{requireAdmin:!0,children:v(qx,{})})}),v(J,{path:`/system`,element:v(Y,{to:fg,replace:!0})}),v(J,{path:`/system/terminal/:nodeId/*`,element:v(Sx,{})}),v(J,{path:`/system/terminal`,element:v($,{requireAdmin:!0,children:v(Xx,{})})}),v(J,{path:gg,element:v(yg,{})}),pg.map(e=>v(J,{path:e.path,element:v(vg,{tab:e.tab})},e.path)),v(J,{path:`/system/users`,element:v(Y,{to:`/system/identity?tab=users`,replace:!0})}),v(J,{path:`/system/api-keys`,element:v(Y,{to:`/system/identity?tab=api-keys`,replace:!0})}),v(J,{path:`/system/authentication`,element:v(Y,{to:nb(`authentication`),replace:!0})}),v(J,{path:`/system/linked-sessions`,element:v(Y,{to:`/system/identity?tab=linked-sessions`,replace:!0})}),v(J,{path:`/system/remote-access`,element:v(Y,{to:nb(`remoteAccess`),replace:!0})}),v(J,{path:`/system/turn`,element:v(Y,{to:nb(`turn`),replace:!0})}),v(J,{path:`/system/storage`,element:v(Y,{to:`/system/data?tab=storage`,replace:!0})}),v(J,{path:`/system/backup`,element:v(Y,{to:`/system/data?tab=backup`,replace:!0})}),v(J,{path:`/library`,element:v($,{requireAdmin:!0,children:v(Cx,{})})}),v(J,{path:`/retrain`,element:v(Y,{to:`/addon/training`,replace:!0})}),v(J,{path:`/archive`,element:v($,{requireAdmin:!0,children:v(Px,{})})}),v(J,{path:`/archive/:deviceId`,element:v(xx,{})}),v(J,{path:`/recordings`,element:v(xx,{})}),v(J,{path:`/build`,element:v($,{requireAdmin:!0,children:v(Ix,{})})}),v(J,{path:Ip,element:v($,{requireAdmin:!0,children:v(Lx,{})})}),v(J,{path:Lp,element:v($,{requireAdmin:!0,children:v(Lx,{})})}),v(J,{path:`/locations`,element:v($,{requireAdmin:!0,children:v(Rx,{})})}),v(J,{path:`/automation`,element:v(ig,{to:`/build`})}),v(J,{path:`/addon/:pagePath`,element:v($,{requireAdmin:!0,children:v(Qg,{})})}),v(J,{path:`*`,element:v(Y,{to:`/devices`,replace:!0})})]})]})})})}),v(Sg,{}),v(Js,{})]})})})})})})})})})}T(),window.__dominevoUiLibrary=ma,window.__dominevoSdk=Zr,window.__dominevoTypes=ln;var cS=po(document.getElementById(`root`));Lo(window.location.pathname,bt())?fx(cS):cS.render(v(S,{children:v(sS,{})}));export{Kp as $,Pc as $t,s_ as A,Md as At,_h as B,$u as Bt,$_ as C,Gd as Ct,M_ as D,Vd as Dt,A_ as E,zd as Et,kh as F,ld as Ft,Tm as G,Fu as Gt,mh as H,Mu as Ht,Dh as I,id as It,wm as J,rd as Jt,Em as K,Au as Kt,bh as L,Hu as Lt,_g as M,bd as Mt,sg as N,dd as Nt,w_ as O,kd as Ot,Gh as P,cd as Pt,rm as Q,dl as Qt,xh as R,Vu as Rt,Q_ as S,ef as St,k_ as T,Ud as Tt,Wm as U,ed as Ut,gh as V,xu as Vt,Dm as W,zu as Wt,cm as X,hl as Xt,fm as Y,yl as Yt,sm as Z,pl as Zt,Zv as _,yf as _t,eb as a,Ys as an,zp as at,qv as b,cf as bt,nb as c,Xs as cn,Ap as ct,Hy as d,kf as dt,rc as en,Rp as et,ay as f,Of as ft,Qv as g,hf as gt,Jv as h,bf as ht,$y as i,oc as in,Bp as it,fg as j,Ad as jt,T_ as k,jd as kt,rb as l,cp as lt,ty as m,Cf as mt,Eb as n,ic as nn,Up as nt,Zy as o,Qs as on,Wp as ot,ny as p,wf as pt,Om as q,Pu as qt,tb as r,ac as rn,Fp as rt,Qy as s,Zs as sn,Pp as st,Ab as t,nc as tn,Hp as tt,ib as u,Wf as ut,Bv as v,uf as vt,N_ as w,Wd as wt,tv as x,sf as xt,Iv as y,lf as yt,Ch as z,Bu as zt};