@camstack/addon-admin-ui 1.2.513 → 1.2.514

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 (120) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/assets/{AddonAssetIcon-BXUI3-Tf.js → AddonAssetIcon-CBiyVWSK.js} +1 -1
  3. package/dist/assets/{Addons-BbTJ2Fig.js → Addons-DsbbYUDT.js} +1 -1
  4. package/dist/assets/{AdminPage-DUSx45NB.js → AdminPage-B_wUVHLs.js} +1 -1
  5. package/dist/assets/{AdminSectionedPage-soMjTdb7.js → AdminSectionedPage-B2kIEVFJ.js} +1 -1
  6. package/dist/assets/{AiProfiles-Z0lIY6qW.js → AiProfiles-sNt-u_by.js} +1 -1
  7. package/dist/assets/{BrokerEditorDialog-61ZhKBtB.js → BrokerEditorDialog-DyIsWyfA.js} +1 -1
  8. package/dist/assets/{Build-DYS91I2j.js → Build-CsuCOGY2.js} +1 -1
  9. package/dist/assets/{Calendars-B70yeC96.js → Calendars-6W4Ardeb.js} +1 -1
  10. package/dist/assets/{Cluster-MhCZmNm6.js → Cluster-CWoYZoPu.js} +1 -1
  11. package/dist/assets/{CompositionBlockEditor-TlnzLRS-.js → CompositionBlockEditor-qEFV1AKI.js} +1 -1
  12. package/dist/assets/{CompositionEditorPage-BI-Y8v0_.js → CompositionEditorPage-CKCgT4Sc.js} +1 -1
  13. package/dist/assets/{Data-B-pDPXqV.js → Data-CKbI6H28.js} +1 -1
  14. package/dist/assets/{DeviceDetail-BejggRfL.js → DeviceDetail-CWaYy5st.js} +1 -1
  15. package/dist/assets/{DeviceDoActionFields-3YdRpdH5.js → DeviceDoActionFields-Bfl8v0Ww.js} +1 -1
  16. package/dist/assets/{Devices-D38AMunx.js → Devices-BXmHX1Iz.js} +1 -1
  17. package/dist/assets/{EmbedPlayerPage-BBZB_KmG.js → EmbedPlayerPage-C0JL6O13.js} +1 -1
  18. package/dist/assets/{HelperWizard-B_3MTQzU.js → HelperWizard-Bu6DbISr.js} +1 -1
  19. package/dist/assets/{History-v659n-q1.js → History-B2COiYTg.js} +1 -1
  20. package/dist/assets/{Identity-Dtc3gsXQ.js → Identity-Cp5m445y.js} +1 -1
  21. package/dist/assets/{IntegrationDetail-X94WkFek.js → IntegrationDetail-CsQJqy0O.js} +1 -1
  22. package/dist/assets/{IntegrationHub-CUAqtcr0.js → IntegrationHub-Cxb40a46.js} +1 -1
  23. package/dist/assets/{Integrations-C-JT0QSz.js → Integrations-CKTnFV7-.js} +1 -1
  24. package/dist/assets/{Integrations-BlD0JmVC.js → Integrations-Wb3Nvqvk.js} +1 -1
  25. package/dist/assets/{Library-BrvU57J_.js → Library-Cnom4jTv.js} +1 -1
  26. package/dist/assets/{Locations-BXbmZQwL.js → Locations-RMAhldT5.js} +1 -1
  27. package/dist/assets/{Logs-B0XBZZ8Q.js → Logs-YZGGdk7a.js} +1 -1
  28. package/dist/assets/{MaskShapeCanvas-DnEx9aLt.js → MaskShapeCanvas-CCcjwlTm.js} +1 -1
  29. package/dist/assets/{MotionZonesSettings-BMDPF6-L.js → MotionZonesSettings-15VWTACI.js} +1 -1
  30. package/dist/assets/{MyAccess-DfkZc8jj.js → MyAccess-ChjuVjHq.js} +1 -1
  31. package/dist/assets/{Network-B9UvgIh-.js → Network-ByvZRKWM.js} +1 -1
  32. package/dist/assets/{NodeAddonsSettingsPanel-D8UZOHme.js → NodeAddonsSettingsPanel-tEpUh0Q6.js} +1 -1
  33. package/dist/assets/{Notifications-2R56_ebY.js → Notifications-WK1xVjAV.js} +1 -1
  34. package/dist/assets/{Pipeline-BdjiguQv.js → Pipeline-C3zZKn-f.js} +1 -1
  35. package/dist/assets/{PrivacyMaskSettings-DXcb1Xsj.js → PrivacyMaskSettings-boU8xnXR.js} +1 -1
  36. package/dist/assets/{Recordings-BnGaDgIg.js → Recordings-DT5kHAwS.js} +1 -1
  37. package/dist/assets/{RemoteGrid-C_hwBm7-.js → RemoteGrid-HppYsb5t.js} +1 -1
  38. package/dist/assets/{ScanNetworkModal-BTQIrvGc.js → ScanNetworkModal-Dk1v70-s.js} +1 -1
  39. package/dist/assets/{SceneMonitorEditor-BeZzFwDE.js → SceneMonitorEditor-DbEDdw8n.js} +1 -1
  40. package/dist/assets/{SessionsList-C03j936p.js → SessionsList-4nVxGpqc.js} +1 -1
  41. package/dist/assets/{Showroom-hqqCXmrT.js → Showroom-Cyf_5WTf.js} +1 -1
  42. package/dist/assets/{System-C9oV_d1y.js → System-B47qVCVK.js} +1 -1
  43. package/dist/assets/{Templates-cp28J05t.js → Templates-lCo5yN4g.js} +1 -1
  44. package/dist/assets/{Terminal-C2kXj9wO.js → Terminal-RLflxok5.js} +1 -1
  45. package/dist/assets/{Viewer-zU0ym-3m.js → Viewer-BFtLOgb5.js} +1 -1
  46. package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-RW_iqTJh.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-Dd1lnVnV.js} +1 -1
  47. package/dist/assets/{addon-icons-context-Dvq70FHG.js → addon-icons-context-BqCF3aDM.js} +1 -1
  48. package/dist/assets/{archive-DEQjGSlb.js → archive-COJvuz8j.js} +1 -1
  49. package/dist/assets/{assignment-candidates-CYEy8Oew.js → assignment-candidates-GFFTkY5s.js} +1 -1
  50. package/dist/assets/{authed-media-ei7XgIJl.js → authed-media-CPH4gDSb.js} +1 -1
  51. package/dist/assets/{automation-data-E3BGzBLE.js → automation-data-D3oEGSM3.js} +1 -1
  52. package/dist/assets/{bell-off-BtOUApIg.js → bell-off-CEHvcpV8.js} +1 -1
  53. package/dist/assets/{boxes-vYLDJNRv.js → boxes-C0Z7cB0S.js} +1 -1
  54. package/dist/assets/circle-slash-BY9zkWdJ.js +1 -0
  55. package/dist/assets/client-BjsFVjEa.js +674 -0
  56. package/dist/assets/{cloud-upload-CzsF_jzI.js → cloud-upload-yzPIJtWW.js} +1 -1
  57. package/dist/assets/crop-DpfML6TR.js +1 -0
  58. package/dist/assets/{device-integration-icon-CMOElaCq.js → device-integration-icon-DC0L96qt.js} +1 -1
  59. package/dist/assets/device-picker-model-C9XdDI0R.js +1 -0
  60. package/dist/assets/{dist-ODNaReOx.js → dist-D7eSjbBx.js} +1 -1
  61. package/dist/assets/dist-DuYXDhcZ.js +674 -0
  62. package/dist/assets/{eraser-DdxDfnsw.js → eraser-CcAxRsoL.js} +1 -1
  63. package/dist/assets/{file-up-DtWjJzxE.js → file-up-gEH5fPam.js} +1 -1
  64. package/dist/assets/{hard-drive-download-BUYTmxO8.js → hard-drive-download-CwO_DU-K.js} +1 -1
  65. package/dist/assets/{hostInit-CEmOeO-p.js → hostInit-BonUhoQT.js} +1 -1
  66. package/dist/assets/{icons-BS95Q050.js → icons-l5aYjks5.js} +1 -1
  67. package/dist/assets/{index-CUQ_1-3M.js → index-C1TP1bDM.js} +3 -3
  68. package/dist/assets/{key-BHqMlU3n.js → key-03tb4am1.js} +1 -1
  69. package/dist/assets/{key-round-DEGX9D7v.js → key-round-CxRbUD09.js} +1 -1
  70. package/dist/assets/{layers-CmVPxgW7.js → layers-B_aq5GyC.js} +1 -1
  71. package/dist/assets/{linked-devices-model-9YMVfHc9.js → linked-devices-model-BDwJCC37.js} +1 -1
  72. package/dist/assets/{list-ordered-CheGo-ag.js → list-ordered-BIOnBH5V.js} +1 -1
  73. package/dist/assets/{location-owned-usage-CkEO8Lym.js → location-owned-usage-C8KAIY_m.js} +1 -1
  74. package/dist/assets/{log-in-CiEueJS1.js → log-in-DYRRiyUu.js} +1 -1
  75. package/dist/assets/{memory-stick-BR7h-gLy.js → memory-stick-BTjX5XXU.js} +1 -1
  76. package/dist/assets/{message-square-plus-pFenYopk.js → message-square-plus-CYHn2tx1.js} +1 -1
  77. package/dist/assets/{mf-entry-bootstrap-0-f252a886.js → mf-entry-bootstrap-0-55c9b237.js} +2 -2
  78. package/dist/assets/{mic-off-Cy2vjOdb.js → mic-off-BfWqJn2R.js} +1 -1
  79. package/dist/assets/{monitor-off-DSnpgX4h.js → monitor-off-Dy7WsqTN.js} +1 -1
  80. package/dist/assets/{monitor-smartphone-Bbz5EYKE.js → monitor-smartphone-Cl-w7Gs0.js} +1 -1
  81. package/dist/assets/mount-C9XdDI0R.js +1 -0
  82. package/dist/assets/{player-overlays-CeCeKlFy.js → player-overlays-DaSesfVn.js} +1 -1
  83. package/dist/assets/{recycle-CRCqoNuC.js → recycle-CC6kU24N.js} +1 -1
  84. package/dist/assets/remoteEntry-C7WJfwvN.js +1 -0
  85. package/dist/assets/{ruler-D4nA2AkO.js → ruler-C6bIqLbX.js} +1 -1
  86. package/dist/assets/{scan-eye-B6ToEyNT.js → scan-eye-BbYgoJiK.js} +1 -1
  87. package/dist/assets/{scissors-Cy9qo-01.js → scissors-oYo-ZhBm.js} +1 -1
  88. package/dist/assets/{search-x-Bc6YoEgC.js → search-x-CySi2ygd.js} +1 -1
  89. package/dist/assets/{send-C88bJpzN.js → send-FMXSDirA.js} +1 -1
  90. package/dist/assets/{settings-2-CT7EhY20.js → settings-2-WfXnibr2.js} +1 -1
  91. package/dist/assets/{shapes-D49xx3pl.js → shapes-JaoPTvAm.js} +1 -1
  92. package/dist/assets/{sigma-r_LYWpZC.js → sigma-C2um2nX9.js} +1 -1
  93. package/dist/assets/{speaker-Ki0ZHj9k.js → speaker-DVh7yO4_.js} +1 -1
  94. package/dist/assets/{src-Cq4wbXVd.js → src-DxOL9qHw.js} +3 -3
  95. package/dist/assets/{step-inspector-model-DybV6iGj.js → step-inspector-model-D4wNZnAf.js} +1 -1
  96. package/dist/assets/{table-2-BCrCvQBE.js → table-2-BzvZ1C8Y.js} +1 -1
  97. package/dist/assets/{timer-reset-BCU9mQbt.js → timer-reset-BFyZoIS7.js} +1 -1
  98. package/dist/assets/{unlink-Bdf-2hM2.js → unlink-Bf6pcFmm.js} +1 -1
  99. package/dist/assets/{usb-Dk1-9w-h.js → usb-oSHxCOV9.js} +1 -1
  100. package/dist/assets/{use-scenes-feed-kuO8vvaU.js → use-scenes-feed-DrR6sBRO.js} +1 -1
  101. package/dist/assets/{use-stationary-objects-h9zEu1aK.js → use-stationary-objects-DVmg7h4R.js} +1 -1
  102. package/dist/assets/useEventInvalidation-C9XdDI0R.js +1 -0
  103. package/dist/assets/{useNodeUrlSelection-DxKAfF2w.js → useNodeUrlSelection-CJVhV7Gy.js} +1 -1
  104. package/dist/assets/user-round-BZHQXbgV.js +1 -0
  105. package/dist/assets/{user-x-Ci81AHsS.js → user-x-aU8InWh0.js} +1 -1
  106. package/dist/assets/{variable-6lR9ETRn.js → variable-DwONvC9h.js} +1 -1
  107. package/dist/assets/{video-BSJxItXj.js → video-DOy8UceJ.js} +1 -1
  108. package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-CCXtVAMI.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-DXQ8OkGD.js} +2 -2
  109. package/dist/index.html +8 -8
  110. package/dist/server/addon.js +2 -2
  111. package/package.json +1 -1
  112. package/dist/assets/circle-slash-DG3-Ibc_.js +0 -1
  113. package/dist/assets/client-gOfL8FDq.js +0 -674
  114. package/dist/assets/crop-BYOsBPcF.js +0 -1
  115. package/dist/assets/device-picker-model-CtJOP06v.js +0 -1
  116. package/dist/assets/dist-BIFugJlu.js +0 -674
  117. package/dist/assets/mount-CtJOP06v.js +0 -1
  118. package/dist/assets/remoteEntry-DHoKCa7I.js +0 -1
  119. package/dist/assets/useEventInvalidation-CtJOP06v.js +0 -1
  120. package/dist/assets/user-round-ucYAzmFE.js +0 -1
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./Devices-D38AMunx.js","./src-Cq4wbXVd.js","./player-overlays-CeCeKlFy.js","./client-gOfL8FDq.js","./__vite-browser-external-BlMfPwfH.js","./useTranslation-BJr-n0es.js","./AdminPage-DUSx45NB.js","./device-integration-icon-CMOElaCq.js","./useEventInvalidation-CtJOP06v.js","./Integrations-C-JT0QSz.js","./i18n-CtSKEBgX.js","./table-2-BCrCvQBE.js","./ScanNetworkModal-BTQIrvGc.js","./BrokerEditorDialog-61ZhKBtB.js","./log-in-CiEueJS1.js","./mount-CtJOP06v.js","./framework-packages-B7oma9J4.js","./IntegrationDetail-X94WkFek.js","./search-x-Bc6YoEgC.js","./NodeAddonsSettingsPanel-D8UZOHme.js","./addon-icons-context-Dvq70FHG.js","./Pipeline-BdjiguQv.js","./video-BSJxItXj.js","./usb-Dk1-9w-h.js","./crop-BYOsBPcF.js","./layers-CmVPxgW7.js","./step-inspector-model-DybV6iGj.js","./board-model-uN4dojCw.js","./DeviceDetail-BejggRfL.js","./archive-DEQjGSlb.js","./scan-eye-B6ToEyNT.js","./bell-off-BtOUApIg.js","./sigma-r_LYWpZC.js","./boxes-vYLDJNRv.js","./circle-slash-DG3-Ibc_.js","./file-up-DtWjJzxE.js","./HelperWizard-B_3MTQzU.js","./assignment-candidates-CYEy8Oew.js","./device-picker-model-CtJOP06v.js","./use-stationary-objects-h9zEu1aK.js","./DeviceDoActionFields-3YdRpdH5.js","./linked-devices-model-9YMVfHc9.js","./RemoteGrid-C_hwBm7-.js","./authed-media-ei7XgIJl.js","./automation-data-E3BGzBLE.js","./Showroom-hqqCXmrT.js","./EmbedPlayerPage-BBZB_KmG.js","./Library-BrvU57J_.js","./user-x-Ci81AHsS.js","./user-round-ucYAzmFE.js","./AdminSectionedPage-soMjTdb7.js","./use-scenes-feed-kuO8vvaU.js","./Recordings-BnGaDgIg.js","./scissors-Cy9qo-01.js","./location-owned-usage-CkEO8Lym.js","./eraser-DdxDfnsw.js","./hard-drive-download-BUYTmxO8.js","./format-size-DIxKXxtj.js","./Viewer-zU0ym-3m.js","./monitor-off-DSnpgX4h.js","./Build-DYS91I2j.js","./variable-6lR9ETRn.js","./CompositionBlockEditor-TlnzLRS-.js","./CompositionEditorPage-BI-Y8v0_.js","./Locations-BXbmZQwL.js","./speaker-Ki0ZHj9k.js","./Addons-BbTJ2Fig.js","./useNodeUrlSelection-DxKAfF2w.js","./AiProfiles-Z0lIY6qW.js","./send-C88bJpzN.js","./message-square-plus-pFenYopk.js","./MyAccess-DfkZc8jj.js","./key-round-DEGX9D7v.js","./monitor-smartphone-Bbz5EYKE.js","./ruler-D4nA2AkO.js","./unlink-Bdf-2hM2.js","./SessionsList-C03j936p.js","./Logs-B0XBZZ8Q.js","./timer-reset-BCU9mQbt.js","./IntegrationHub-CUAqtcr0.js","./settings-2-CT7EhY20.js","./AddonAssetIcon-BXUI3-Tf.js","./addon-display-names-BkwMrExv.js","./Identity-Dtc3gsXQ.js","./key-BHqMlU3n.js","./Network-B9UvgIh-.js","./Integrations-BlD0JmVC.js","./recycle-CRCqoNuC.js","./Data-B-pDPXqV.js","./cloud-upload-CzsF_jzI.js","./System-C9oV_d1y.js","./Cluster-MhCZmNm6.js","./memory-stick-BR7h-gLy.js","./Terminal-C2kXj9wO.js","./Terminal-kHJ-D0s7.css","./Notifications-2R56_ebY.js","./list-ordered-CheGo-ag.js","./History-v659n-q1.js","./Calendars-B70yeC96.js","./Templates-cp28J05t.js","./shapes-D49xx3pl.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}from"./virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-CCXtVAMI.js";import{t as i}from"./vite-preload-helper-kNaey6uv.js";import{A as a,C as o,D as s,F as c,G as l,H as u,I as d,J as f,K as p,M as m,N as h,O as g,P as _,Q as v,R as y,S as b,V as x,X as S,Y as C,Z as w,a as T,d as E,et as D,i as O,j as k,k as A,m as j,o as M,u as N,x as P,z as F}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Ar as I,Dn as ee,Ei as te,En as L,Fn as ne,Gn as re,Gr as ie,Ht as ae,Kr as oe,Li as se,Mr as R,Ni as ce,Nr as le,Oi as ue,Pn as de,Pr as fe,Q as z,Qn as pe,Qt as me,Ri as he,St as ge,T as _e,Ti as ve,Ui as ye,Vr as be,Wr as xe,Yi as Se,Z as Ce,_n as we,_t as Te,an as Ee,br as De,bt as Oe,dn as ke,dt as Ae,ei as je,fr as Me,gn as Ne,gt as Pe,ht as Fe,ir as Ie,it as Le,jn as Re,ki as ze,la as Be,lr as Ve,lt as He,na as Ue,ni as We,nr as Ge,pi as Ke,pn as qe,rn as Je,rt as Ye,sa as Xe,sr as Ze,st as Qe,vi as $e,vn as et,wr as tt,xi as nt,yi as rt,yn as it,zt as at}from"./player-overlays-CeCeKlFy.js";import{A as ot,Aa as st,At as ct,Br as lt,Bt as ut,Ca as dt,Ct as ft,Dt as pt,E as mt,Ft as ht,G as gt,Hr as _t,Ht as vt,I as yt,It as bt,K as xt,L as St,Lt as Ct,M as wt,Mt as Tt,N as Et,Ot as Dt,P as Ot,Qa as kt,R as At,Rt as jt,Tt as Mt,Ut as Nt,Vr as Pt,Vt as Ft,Wt as It,a as Lt,ba as Rt,bt as zt,dt as Bt,ft as Vt,gt as Ht,ht as Ut,j as Wt,lt as Gt,mt as Kt,o as qt,or as Jt,pt as Yt,r as Xt,si as Zt,t as Qt,ut as $t,wt as en,xt as tn,yt as nn,zt as rn}from"./client-gOfL8FDq.js";import{a as an,c as on,d as sn,f as cn,g as ln,h as un,i as dn,l as fn,m as pn,n as mn,o as hn,p as gn,r as _n,s as vn,t as yn,u as bn}from"./video-BSJxItXj.js";import{$r as xn,Ad as Sn,Ar as Cn,B as wn,Bd as Tn,Ct as En,Eo as Dn,Fi as On,Gr as kn,Hd as An,Hn as jn,Id as Mn,Jd as Nn,Jl as Pn,Jo as Fn,Jr as In,K as Ln,Kl as Rn,Ks as zn,Kt as Bn,Ld as Vn,Mo as Hn,Mr as Un,Mt as Wn,Nr as Gn,Nu as Kn,Oo as qn,Pu as Jn,Qr as Yn,Rt as Xn,Sr as Zn,Td as Qn,To as $n,Ui as er,Ur as tr,Ut as nr,Vd as rr,Vr as ir,Vt as ar,Wd as or,Wr as sr,Wt as cr,Xd as lr,Xo as ur,Xr as dr,Yo as fr,Yr as pr,Zr as mr,_r as hr,aa as gr,ai as _r,br as vr,cn as yr,d as br,dn as xr,ef as Sr,ei as Cr,es as wr,fn as Tr,fr as Er,gn as Dr,gr as Or,h as kr,hr as Ar,ia as jr,jd as Mr,jr as Nr,js as Pr,ki as Fr,ko as Ir,l as Lr,ln as Rr,mn as zr,n as Br,na as Vr,ns as Hr,od as Ur,os as Wr,pr as Gr,qr as Kr,ra as qr,ri as Jr,sn as Yr,sr as Xr,ss as Zr,ta as Qr,tf as $r,ti as ei,ts as ti,un as ni,us as ri,vr as ii,vs as ai,vt as oi,wd as si,wi as ci,x as li,xr as ui,yr as di,zd as fi,zr as pi,zu as mi}from"./src-Cq4wbXVd.js";import{r as hi,t as gi}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare__react_mf_2_dom__loadShare__.js-BPba2g2p.js";import{t as _i}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare__react_mf_2_dom_mf_1_client__loadShare__.js-ZBKFTPET.js";import{n as vi,t as B}from"./i18n-CtSKEBgX.js";import{a as yi,c as bi,i as xi,l as Si,n as Ci,o as wi,s as Ti,t as V,u as Ei}from"./useTranslation-BJr-n0es.js";import"./mount-CtJOP06v.js";import{n as Di,t as Oi}from"./addon-icons-context-Dvq70FHG.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)}})(),D();var ki=/^(?:[a-z][a-z0-9+.-]*:|[\\/]{2})/i,Ai=/^[\\/]{2}/;function ji(e,t){return t+e.replace(/\\/g,`/`)}var Mi=`popstate`;function Ni(e){return typeof e==`object`&&!!e&&`pathname`in e&&`search`in e&&`hash`in e&&`state`in e&&`key`in e}function Pi(e={}){function t(e,t){let n=t.state?.masked,{pathname:r,search:i,hash:a}=n||e.location;return Li(``,{pathname:r,search:i,hash:a},t.state&&t.state.usr||null,t.state&&t.state.key||`default`,n?{pathname:e.location.pathname,search:e.location.search,hash:e.location.hash}:void 0)}function n(e,t){return typeof t==`string`?t:Ri(t)}return Bi(t,n,null,e)}function H(e,t){if(e===!1||e==null)throw Error(t)}function U(e,t){if(!e){typeof console<`u`&&console.warn(t);try{throw Error(t)}catch{}}}function Fi(){return Math.random().toString(36).substring(2,10)}function Ii(e,t){return{usr:e.state,key:e.key,idx:t,masked:e.mask?{pathname:e.pathname,search:e.search,hash:e.hash}:void 0}}function Li(e,t,n=null,r,i){return{pathname:typeof e==`string`?e:e.pathname,search:``,hash:``,...typeof t==`string`?zi(t):t,state:n,key:t&&t.key||r||Fi(),mask:i}}function Ri({pathname:e=`/`,search:t=``,hash:n=``}){return t&&t!==`?`&&(e+=t.charAt(0)===`?`?t:`?`+t),n&&n!==`#`&&(e+=n.charAt(0)===`#`?n:`#`+n),e}function zi(e){let t={};if(e){let n=e.indexOf(`#`);n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let r=e.indexOf(`?`);r>=0&&(t.search=e.substring(r),e=e.substring(0,r)),e&&(t.pathname=e)}return t}function Bi(e,t,n,r={}){let{window:i=document.defaultView,v5Compat:a=!1}=r,o=i.history,s=`POP`,c=null,l=u();l??(l=0,o.replaceState({...o.state,idx:l},``));function u(){return(o.state||{idx:null}).idx}function d(){s=`POP`;let e=u(),t=e==null?null:e-l;l=e,c&&c({action:s,location:h.location,delta:t})}function f(e,t){s=`PUSH`;let r=Ni(e)?e:Li(h.location,e,t);n&&n(r,e),l=u()+1;let d=Ii(r,l),f=h.createHref(r.mask||r);try{o.pushState(d,``,f)}catch(e){if(e instanceof DOMException&&e.name===`DataCloneError`)throw e;i.location.assign(f)}a&&c&&c({action:s,location:h.location,delta:1})}function p(e,t){s=`REPLACE`;let r=Ni(e)?e:Li(h.location,e,t);n&&n(r,e),l=u();let i=Ii(r,l),d=h.createHref(r.mask||r);o.replaceState(i,``,d),a&&c&&c({action:s,location:h.location,delta:0})}function m(e){return Vi(i,e)}let h={get action(){return s},get location(){return e(i,o)},listen(e){if(c)throw Error(`A history only accepts one active listener`);return i.addEventListener(Mi,d),c=e,()=>{i.removeEventListener(Mi,d),c=null}},createHref(e){return t(i,e)},createURL:m,encodeLocation(e){let t=m(e);return{pathname:t.pathname,search:t.search,hash:t.hash}},push:f,replace:p,go(e){return o.go(e)}};return h}function Vi(e,t,n=!1){let r=`http://localhost`;e&&(r=e.location.origin===`null`?e.location.href:e.location.origin),H(r,`No window.location.(origin|href) available to create URL`);let i=typeof t==`string`?t:Ri(t);return i=i.replace(/ $/,`%20`),!n&&Ai.test(i)&&(i=r+i),new URL(i,r)}function Hi(e,t,n=`/`){return Ui(e,t,n,!1)}function Ui(e,t,n,r,i){let a=la((typeof t==`string`?zi(t):t).pathname||`/`,n);if(a==null)return null;let o=i??Gi(e),s=null,c=ca(a);for(let e=0;s==null&&e<o.length;++e)s=ia(o[e],c,r);return s}function Wi(e,t){let{route:n,pathname:r,params:i}=e;return{id:n.id,pathname:r,params:i,data:t[n.id],loaderData:t[n.id],handle:n.handle}}function Gi(e){let t=Ki(e);return Ji(t),t}function Ki(e,t=[],n=[],r=``,i=!1){let a=(e,a,o=i,s)=>{let c={relativePath:s===void 0?e.path||``:s,caseSensitive:e.caseSensitive===!0,childrenIndex:a,route:e};if(c.relativePath.startsWith(`/`)){if(!c.relativePath.startsWith(r)&&o)return;H(c.relativePath.startsWith(r),`Absolute route path "${c.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),c.relativePath=c.relativePath.slice(r.length)}let l=W([r,c.relativePath]),u=n.concat(c);e.children&&e.children.length>0&&(H(e.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${l}".`),Ki(e.children,t,u,l,o)),!(e.path==null&&!e.index)&&t.push({path:l,score:na(l,e.index),routesMeta:u.map((e,t)=>{let[n,r]=sa(e.relativePath,e.caseSensitive,t===u.length-1);return{...e,matcher:n,compiledParams:r}})})};return e.forEach((e,t)=>{if(e.path===``||!e.path?.includes(`?`))a(e,t);else for(let n of qi(e.path))a(e,t,!0,n)}),t}function qi(e){let t=e.split(`/`);if(t.length===0)return[];let[n,...r]=t,i=n.endsWith(`?`),a=n.replace(/\?$/,``);if(r.length===0)return i?[a,``]:[a];let o=qi(r.join(`/`)),s=[];return s.push(...o.map(e=>e===``?a:[a,e].join(`/`))),i&&s.push(...o),s.map(t=>e.startsWith(`/`)&&t===``?`/`:t)}function Ji(e){e.sort((e,t)=>e.score===t.score?ra(e.routesMeta.map(e=>e.childrenIndex),t.routesMeta.map(e=>e.childrenIndex)):t.score-e.score)}var Yi=/^:[\w-]+$/,Xi=3,Zi=2,Qi=1,$i=10,ea=-2,ta=e=>e===`*`;function na(e,t){let n=e.split(`/`),r=n.length;return n.some(ta)&&(r+=ea),t&&(r+=Zi),n.filter(e=>!ta(e)).reduce((e,t)=>e+(Yi.test(t)?Xi:t===``?Qi:$i),r)}function ra(e,t){return e.length===t.length&&e.slice(0,-1).every((e,n)=>e===t[n])?e[e.length-1]-t[t.length-1]:0}function ia(e,t,n=!1){let{routesMeta:r}=e,i={},a=`/`,o=[];for(let e=0;e<r.length;++e){let s=r[e],c=e===r.length-1,l=a===`/`?t:t.slice(a.length)||`/`,u={path:s.relativePath,caseSensitive:s.caseSensitive,end:c},d=s.matcher&&s.compiledParams?oa(u,l,s.matcher,s.compiledParams):aa(u,l),f=s.route;if(!d&&c&&n&&!r[r.length-1].route.index&&(d=aa({path:s.relativePath,caseSensitive:s.caseSensitive,end:!1},l)),!d)return null;Object.assign(i,d.params),o.push({params:i,pathname:W([a,d.pathname]),pathnameBase:va(W([a,d.pathnameBase])),route:f}),d.pathnameBase!==`/`&&(a=W([a,d.pathnameBase]))}return o}function aa(e,t){typeof e==`string`&&(e={path:e,caseSensitive:!1,end:!0});let[n,r]=sa(e.path,e.caseSensitive,e.end);return oa(e,t,n,r)}function oa(e,t,n,r){let i=t.match(n);if(!i)return null;let a=i[0],o=a.replace(/(.)\/+$/,`$1`),s=i.slice(1);return{params:r.reduce((e,{paramName:t,isOptional:n},r)=>{if(t===`*`){let e=s[r]||``;o=a.slice(0,a.length-e.length).replace(/(.)\/+$/,`$1`)}let i=s[r];return n&&!i?e[t]=void 0:e[t]=(i||``).replace(/%2F/g,`/`),e},{}),pathname:a,pathnameBase:o,pattern:e}}function sa(e,t=!1,n=!0){U(e===`*`||!e.endsWith(`*`)||e.endsWith(`/*`),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,`/*`)}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,`/*`)}".`);let r=[],i=`^`+e.replace(/\/*\*?$/,``).replace(/^\/*/,`/`).replace(/[\\.*+^${}|()[\]]/g,`\\$&`).replace(/\/:([\w-]+)(\?)?/g,(e,t,n,i,a)=>{if(r.push({paramName:t,isOptional:n!=null}),n){let t=a.charAt(i+e.length);return t&&t!==`/`?`/([^\\/]*)`:`(?:/([^\\/]*))?`}return`/([^\\/]+)`}).replace(/\/([\w-]+)\?(\/|$)/g,`(/$1)?$2`);return e.endsWith(`*`)?(r.push({paramName:`*`}),i+=e===`*`||e===`/*`?`(.*)$`:`(?:\\/(.+)|\\/*)$`):n?i+=`\\/*$`:e!==``&&e!==`/`&&(i+=`(?:(?=\\/|$))`),[new RegExp(i,t?void 0:`i`),r]}function ca(e){try{return e.split(`/`).map(e=>decodeURIComponent(e).replace(/\//g,`%2F`)).join(`/`)}catch(t){return U(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}function la(e,t){if(t===`/`)return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith(`/`)?t.length-1:t.length,r=e.charAt(n);return r&&r!==`/`?null:e.slice(n)||`/`}function ua(e,t=`/`){let{pathname:n,search:r=``,hash:i=``}=typeof e==`string`?zi(e):e,a;return n?(n=ga(n),a=n.startsWith(`/`)?da(n.substring(1),`/`):da(n,t)):a=t,{pathname:a,search:ya(r),hash:ba(i)}}function da(e,t){let n=_a(t).split(`/`);return e.split(`/`).forEach(e=>{e===`..`?n.length>1&&n.pop():e!==`.`&&n.push(e)}),n.length>1?n.join(`/`):`/`}function fa(e,t,n,r){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(r)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function pa(e){return e.filter((e,t)=>t===0||e.route.path&&e.route.path.length>0)}function ma(e){let t=pa(e);return t.map((e,n)=>n===t.length-1?e.pathname:e.pathnameBase)}function ha(e,t,n,r=!1){let i;typeof e==`string`?i=zi(e):(i={...e},H(!i.pathname||!i.pathname.includes(`?`),fa(`?`,`pathname`,`search`,i)),H(!i.pathname||!i.pathname.includes(`#`),fa(`#`,`pathname`,`hash`,i)),H(!i.search||!i.search.includes(`#`),fa(`#`,`search`,`hash`,i)));let a=e===``||i.pathname===``,o=a?`/`:i.pathname,s;if(o==null)s=n;else{let e=t.length-1;if(!r&&o.startsWith(`..`)){let t=o.split(`/`);for(;t[0]===`..`;)t.shift(),--e;i.pathname=t.join(`/`)}s=e>=0?t[e]:`/`}let c=ua(i,s),l=o&&o!==`/`&&o.endsWith(`/`),u=(a||o===`.`)&&n.endsWith(`/`);return!c.pathname.endsWith(`/`)&&(l||u)&&(c.pathname+=`/`),c}var ga=e=>e.replace(/[\\/]{2,}/g,`/`),W=e=>ga(e.join(`/`)),_a=e=>e.replace(/\/+$/,``),va=e=>_a(e).replace(/^\/*/,`/`),ya=e=>!e||e===`?`?``:e.startsWith(`?`)?e:`?`+e,ba=e=>!e||e===`#`?``:e.startsWith(`#`)?e:`#`+e,xa=class{constructor(e,t,n,r=!1){this.status=e,this.statusText=t||``,this.internal=r,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}};function Sa(e){return e!=null&&typeof e.status==`number`&&typeof e.statusText==`string`&&typeof e.internal==`boolean`&&`data`in e}function Ca(e){return W(e.map(e=>e.route.path).filter(Boolean))||`/`}var wa=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function Ta(e,t){let n=e;if(typeof n!=`string`||!ki.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,i=!1;if(wa)try{let e=new URL(window.location.href),r=Ai.test(n)?new URL(ji(n,e.protocol)):new URL(n),a=la(r.pathname,t);r.origin===e.origin&&a!=null?n=a+r.search+r.hash:i=!0}catch{U(!1,`<Link to="${n}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:r,isExternal:i,to:n}}Object.getOwnPropertyNames(Object.prototype).sort().join(`\0`);var Ea=[`POST`,`PUT`,`PATCH`,`DELETE`];new Set(Ea);var Da=[`GET`,...Ea];new Set(Da);var Oa=[`about:`,`blob:`,`chrome:`,`chrome-untrusted:`,`content:`,`data:`,`devtools:`,`file:`,`filesystem:`,`javascript:`];function ka(e){try{return Oa.includes(new URL(e).protocol)}catch{return!1}}var Aa=A(null);Aa.displayName=`DataRouter`;var ja=A(null);ja.displayName=`DataRouterState`;var Ma=A(!1);function Na(){return F(Ma)}var Pa=A({isTransitioning:!1});Pa.displayName=`ViewTransition`;var Fa=A(new Map);Fa.displayName=`Fetchers`;var Ia=A(null);Ia.displayName=`Await`;var G=A(null);G.displayName=`Navigation`;var La=A(null);La.displayName=`Location`;var K=A({outlet:null,matches:[],isDataRoute:!1});K.displayName=`Route`;var Ra=A(null);Ra.displayName=`RouteError`;var za=`REACT_ROUTER_ERROR`,Ba=`REDIRECT`,Va=`ROUTE_ERROR_RESPONSE`;function Ha(e){if(e.startsWith(`${za}:${Ba}:{`))try{let t=JSON.parse(e.slice(28));if(typeof t==`object`&&t&&typeof t.status==`number`&&typeof t.statusText==`string`&&typeof t.location==`string`&&typeof t.reloadDocument==`boolean`&&typeof t.replace==`boolean`)return t}catch{}}function Ua(e){if(e.startsWith(`${za}:${Va}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t==`object`&&t&&typeof t.status==`number`&&typeof t.statusText==`string`)return new xa(t.status,t.statusText,t.data)}catch{}}function Wa(e,{relative:t}={}){H(Ga(),`useHref() may be used only in the context of a <Router> component.`);let{basename:n,navigator:r}=F(G),{hash:i,pathname:a,search:o}=$a(e,{relative:t}),s=a;return n!==`/`&&(s=a===`/`?n:W([n,a])),r.createHref({pathname:s,search:o,hash:i})}function Ga(){return F(La)!=null}function q(){return H(Ga(),`useLocation() may be used only in the context of a <Router> component.`),F(La).location}function Ka(){return F(La).navigationType}var qa=`You should call navigate() in a React.useEffect(), not when your component is first rendered.`;function Ja(e){F(G).static||l(e)}function J(){let{isDataRoute:e}=F(K);return e?yo():Ya()}function Ya(){H(Ga(),`useNavigate() may be used only in the context of a <Router> component.`);let e=F(Aa),{basename:t,navigator:n}=F(G),{matches:r}=F(K),{pathname:i}=q(),a=JSON.stringify(ma(r)),o=f(!1);return Ja(()=>{o.current=!0}),y((r,s={})=>{if(U(o.current,qa),!o.current)return;if(typeof r==`number`){n.go(r);return}let c=ha(r,JSON.parse(a),i,s.relative===`path`);e==null&&t!==`/`&&(c.pathname=c.pathname===`/`?t:W([t,c.pathname])),(s.replace?n.replace:n.push)(c,s.state,s)},[t,n,a,i,e])}var Xa=A(null);function Za(e){let t=F(K).outlet;return p(()=>t&&a(Xa.Provider,{value:e},t),[t,e])}function Qa(){let{matches:e}=F(K);return e[e.length-1]?.params??{}}function $a(e,{relative:t}={}){let{matches:n}=F(K),{pathname:r}=q(),i=JSON.stringify(ma(n));return p(()=>ha(e,JSON.parse(i),r,t===`path`),[e,i,r,t])}function eo(e,t){return to(e,t)}function to(e,t,n){H(Ga(),`useRoutes() may be used only in the context of a <Router> component.`);let{navigator:r}=F(G),{matches:i}=F(K),o=i[i.length-1],s=o?o.params:{},c=o?o.pathname:`/`,l=o?o.pathnameBase:`/`,u=o&&o.route;{let e=u&&u.path||``;xo(c,!u||e.endsWith(`*`)||e.endsWith(`*?`),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${c}" (under <Route path="${e}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./Devices-BXmHX1Iz.js","./src-DxOL9qHw.js","./player-overlays-DaSesfVn.js","./client-BjsFVjEa.js","./__vite-browser-external-BlMfPwfH.js","./useTranslation-BJr-n0es.js","./AdminPage-B_wUVHLs.js","./device-integration-icon-DC0L96qt.js","./useEventInvalidation-C9XdDI0R.js","./Integrations-CKTnFV7-.js","./i18n-CtSKEBgX.js","./table-2-BzvZ1C8Y.js","./ScanNetworkModal-Dk1v70-s.js","./BrokerEditorDialog-DyIsWyfA.js","./log-in-DYRRiyUu.js","./mount-C9XdDI0R.js","./framework-packages-B7oma9J4.js","./IntegrationDetail-CsQJqy0O.js","./search-x-CySi2ygd.js","./NodeAddonsSettingsPanel-tEpUh0Q6.js","./addon-icons-context-BqCF3aDM.js","./Pipeline-C3zZKn-f.js","./video-DOy8UceJ.js","./usb-oSHxCOV9.js","./crop-DpfML6TR.js","./layers-B_aq5GyC.js","./step-inspector-model-D4wNZnAf.js","./board-model-uN4dojCw.js","./DeviceDetail-CWaYy5st.js","./archive-COJvuz8j.js","./scan-eye-BbYgoJiK.js","./bell-off-CEHvcpV8.js","./sigma-C2um2nX9.js","./boxes-C0Z7cB0S.js","./circle-slash-BY9zkWdJ.js","./file-up-gEH5fPam.js","./HelperWizard-Bu6DbISr.js","./assignment-candidates-GFFTkY5s.js","./device-picker-model-C9XdDI0R.js","./use-stationary-objects-DVmg7h4R.js","./DeviceDoActionFields-Bfl8v0Ww.js","./linked-devices-model-BDwJCC37.js","./RemoteGrid-HppYsb5t.js","./authed-media-CPH4gDSb.js","./automation-data-D3oEGSM3.js","./Showroom-Cyf_5WTf.js","./EmbedPlayerPage-C0JL6O13.js","./Library-Cnom4jTv.js","./user-x-aU8InWh0.js","./user-round-BZHQXbgV.js","./AdminSectionedPage-B2kIEVFJ.js","./use-scenes-feed-DrR6sBRO.js","./Recordings-DT5kHAwS.js","./scissors-oYo-ZhBm.js","./location-owned-usage-C8KAIY_m.js","./eraser-CcAxRsoL.js","./hard-drive-download-CwO_DU-K.js","./format-size-DIxKXxtj.js","./Viewer-BFtLOgb5.js","./monitor-off-Dy7WsqTN.js","./Build-CsuCOGY2.js","./variable-DwONvC9h.js","./CompositionBlockEditor-qEFV1AKI.js","./CompositionEditorPage-CKCgT4Sc.js","./Locations-RMAhldT5.js","./speaker-DVh7yO4_.js","./Addons-DsbbYUDT.js","./useNodeUrlSelection-CJVhV7Gy.js","./AiProfiles-sNt-u_by.js","./send-FMXSDirA.js","./message-square-plus-CYHn2tx1.js","./MyAccess-ChjuVjHq.js","./key-round-CxRbUD09.js","./monitor-smartphone-Cl-w7Gs0.js","./ruler-C6bIqLbX.js","./unlink-Bf6pcFmm.js","./SessionsList-4nVxGpqc.js","./Logs-YZGGdk7a.js","./timer-reset-BFyZoIS7.js","./IntegrationHub-Cxb40a46.js","./settings-2-WfXnibr2.js","./AddonAssetIcon-CBiyVWSK.js","./addon-display-names-BkwMrExv.js","./Identity-Cp5m445y.js","./key-03tb4am1.js","./Network-ByvZRKWM.js","./Integrations-Wb3Nvqvk.js","./recycle-CC6kU24N.js","./Data-CKbI6H28.js","./cloud-upload-yzPIJtWW.js","./System-B47qVCVK.js","./Cluster-CWoYZoPu.js","./memory-stick-BTjX5XXU.js","./Terminal-RLflxok5.js","./Terminal-kHJ-D0s7.css","./Notifications-WK1xVjAV.js","./list-ordered-BIOnBH5V.js","./History-B2COiYTg.js","./Calendars-6W4Ardeb.js","./Templates-lCo5yN4g.js","./shapes-JaoPTvAm.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}from"./virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-DXQ8OkGD.js";import{t as i}from"./vite-preload-helper-kNaey6uv.js";import{A as a,C as o,D as s,F as c,G as l,H as u,I as d,J as f,K as p,M as m,N as h,O as g,P as _,Q as v,R as y,S as b,V as x,X as S,Y as C,Z as w,a as T,d as E,et as D,i as O,j as k,k as A,m as j,o as M,u as N,x as P,z as F}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Ar as I,Dn as ee,Ei as te,En as L,Fn as ne,Gn as re,Gr as ie,Ht as ae,Kr as oe,Li as se,Mr as R,Ni as ce,Nr as le,Oi as ue,Pn as de,Pr as fe,Q as z,Qn as pe,Qt as me,Ri as he,St as ge,T as _e,Ti as ve,Ui as ye,Vr as be,Wr as xe,Yi as Se,Z as Ce,_n as we,_t as Te,an as Ee,br as De,bt as Oe,dn as ke,dt as Ae,ei as je,fr as Me,gn as Ne,gt as Pe,ht as Fe,ir as Ie,it as Le,jn as Re,ki as ze,la as Be,lr as Ve,lt as He,na as Ue,ni as We,nr as Ge,pi as Ke,pn as qe,rn as Je,rt as Ye,sa as Xe,sr as Ze,st as Qe,vi as $e,vn as et,wr as tt,xi as nt,yi as rt,yn as it,zt as at}from"./player-overlays-DaSesfVn.js";import{A as ot,Aa as st,At as ct,Br as lt,Bt as ut,Ca as dt,Ct as ft,Dt as pt,E as mt,Ft as ht,G as gt,Hr as _t,Ht as vt,I as yt,It as bt,K as xt,L as St,Lt as Ct,M as wt,Mt as Tt,N as Et,Ot as Dt,P as Ot,Qa as kt,R as At,Rt as jt,Tt as Mt,Ut as Nt,Vr as Pt,Vt as Ft,Wt as It,a as Lt,ba as Rt,bt as zt,dt as Bt,ft as Vt,gt as Ht,ht as Ut,j as Wt,lt as Gt,mt as Kt,o as qt,or as Jt,pt as Yt,r as Xt,si as Zt,t as Qt,ut as $t,wt as en,xt as tn,yt as nn,zt as rn}from"./client-BjsFVjEa.js";import{a as an,c as on,d as sn,f as cn,g as ln,h as un,i as dn,l as fn,m as pn,n as mn,o as hn,p as gn,r as _n,s as vn,t as yn,u as bn}from"./video-DOy8UceJ.js";import{$r as xn,Ad as Sn,Ar as Cn,B as wn,Bd as Tn,Ct as En,Eo as Dn,Fi as On,Gr as kn,Hd as An,Hn as jn,Id as Mn,Jd as Nn,Jl as Pn,Jo as Fn,Jr as In,K as Ln,Kl as Rn,Ks as zn,Kt as Bn,Ld as Vn,Mo as Hn,Mr as Un,Mt as Wn,Nr as Gn,Nu as Kn,Oo as qn,Pu as Jn,Qr as Yn,Rt as Xn,Sr as Zn,Td as Qn,To as $n,Ui as er,Ur as tr,Ut as nr,Vd as rr,Vr as ir,Vt as ar,Wd as or,Wr as sr,Wt as cr,Xd as lr,Xo as ur,Xr as dr,Yo as fr,Yr as pr,Zr as mr,_r as hr,aa as gr,ai as _r,br as vr,cn as yr,d as br,dn as xr,ef as Sr,ei as Cr,es as wr,fn as Tr,fr as Er,gn as Dr,gr as Or,h as kr,hr as Ar,ia as jr,jd as Mr,jr as Nr,js as Pr,ki as Fr,ko as Ir,l as Lr,ln as Rr,mn as zr,n as Br,na as Vr,ns as Hr,od as Ur,os as Wr,pr as Gr,qr as Kr,ra as qr,ri as Jr,sn as Yr,sr as Xr,ss as Zr,ta as Qr,tf as $r,ti as ei,ts as ti,un as ni,us as ri,vr as ii,vs as ai,vt as oi,wd as si,wi as ci,x as li,xr as ui,yr as di,zd as fi,zr as pi,zu as mi}from"./src-DxOL9qHw.js";import{r as hi,t as gi}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare__react_mf_2_dom__loadShare__.js-BPba2g2p.js";import{t as _i}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare__react_mf_2_dom_mf_1_client__loadShare__.js-ZBKFTPET.js";import{n as vi,t as B}from"./i18n-CtSKEBgX.js";import{a as yi,c as bi,i as xi,l as Si,n as Ci,o as wi,s as Ti,t as V,u as Ei}from"./useTranslation-BJr-n0es.js";import"./mount-C9XdDI0R.js";import{n as Di,t as Oi}from"./addon-icons-context-BqCF3aDM.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)}})(),D();var ki=/^(?:[a-z][a-z0-9+.-]*:|[\\/]{2})/i,Ai=/^[\\/]{2}/;function ji(e,t){return t+e.replace(/\\/g,`/`)}var Mi=`popstate`;function Ni(e){return typeof e==`object`&&!!e&&`pathname`in e&&`search`in e&&`hash`in e&&`state`in e&&`key`in e}function Pi(e={}){function t(e,t){let n=t.state?.masked,{pathname:r,search:i,hash:a}=n||e.location;return Li(``,{pathname:r,search:i,hash:a},t.state&&t.state.usr||null,t.state&&t.state.key||`default`,n?{pathname:e.location.pathname,search:e.location.search,hash:e.location.hash}:void 0)}function n(e,t){return typeof t==`string`?t:Ri(t)}return Bi(t,n,null,e)}function H(e,t){if(e===!1||e==null)throw Error(t)}function U(e,t){if(!e){typeof console<`u`&&console.warn(t);try{throw Error(t)}catch{}}}function Fi(){return Math.random().toString(36).substring(2,10)}function Ii(e,t){return{usr:e.state,key:e.key,idx:t,masked:e.mask?{pathname:e.pathname,search:e.search,hash:e.hash}:void 0}}function Li(e,t,n=null,r,i){return{pathname:typeof e==`string`?e:e.pathname,search:``,hash:``,...typeof t==`string`?zi(t):t,state:n,key:t&&t.key||r||Fi(),mask:i}}function Ri({pathname:e=`/`,search:t=``,hash:n=``}){return t&&t!==`?`&&(e+=t.charAt(0)===`?`?t:`?`+t),n&&n!==`#`&&(e+=n.charAt(0)===`#`?n:`#`+n),e}function zi(e){let t={};if(e){let n=e.indexOf(`#`);n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let r=e.indexOf(`?`);r>=0&&(t.search=e.substring(r),e=e.substring(0,r)),e&&(t.pathname=e)}return t}function Bi(e,t,n,r={}){let{window:i=document.defaultView,v5Compat:a=!1}=r,o=i.history,s=`POP`,c=null,l=u();l??(l=0,o.replaceState({...o.state,idx:l},``));function u(){return(o.state||{idx:null}).idx}function d(){s=`POP`;let e=u(),t=e==null?null:e-l;l=e,c&&c({action:s,location:h.location,delta:t})}function f(e,t){s=`PUSH`;let r=Ni(e)?e:Li(h.location,e,t);n&&n(r,e),l=u()+1;let d=Ii(r,l),f=h.createHref(r.mask||r);try{o.pushState(d,``,f)}catch(e){if(e instanceof DOMException&&e.name===`DataCloneError`)throw e;i.location.assign(f)}a&&c&&c({action:s,location:h.location,delta:1})}function p(e,t){s=`REPLACE`;let r=Ni(e)?e:Li(h.location,e,t);n&&n(r,e),l=u();let i=Ii(r,l),d=h.createHref(r.mask||r);o.replaceState(i,``,d),a&&c&&c({action:s,location:h.location,delta:0})}function m(e){return Vi(i,e)}let h={get action(){return s},get location(){return e(i,o)},listen(e){if(c)throw Error(`A history only accepts one active listener`);return i.addEventListener(Mi,d),c=e,()=>{i.removeEventListener(Mi,d),c=null}},createHref(e){return t(i,e)},createURL:m,encodeLocation(e){let t=m(e);return{pathname:t.pathname,search:t.search,hash:t.hash}},push:f,replace:p,go(e){return o.go(e)}};return h}function Vi(e,t,n=!1){let r=`http://localhost`;e&&(r=e.location.origin===`null`?e.location.href:e.location.origin),H(r,`No window.location.(origin|href) available to create URL`);let i=typeof t==`string`?t:Ri(t);return i=i.replace(/ $/,`%20`),!n&&Ai.test(i)&&(i=r+i),new URL(i,r)}function Hi(e,t,n=`/`){return Ui(e,t,n,!1)}function Ui(e,t,n,r,i){let a=la((typeof t==`string`?zi(t):t).pathname||`/`,n);if(a==null)return null;let o=i??Gi(e),s=null,c=ca(a);for(let e=0;s==null&&e<o.length;++e)s=ia(o[e],c,r);return s}function Wi(e,t){let{route:n,pathname:r,params:i}=e;return{id:n.id,pathname:r,params:i,data:t[n.id],loaderData:t[n.id],handle:n.handle}}function Gi(e){let t=Ki(e);return Ji(t),t}function Ki(e,t=[],n=[],r=``,i=!1){let a=(e,a,o=i,s)=>{let c={relativePath:s===void 0?e.path||``:s,caseSensitive:e.caseSensitive===!0,childrenIndex:a,route:e};if(c.relativePath.startsWith(`/`)){if(!c.relativePath.startsWith(r)&&o)return;H(c.relativePath.startsWith(r),`Absolute route path "${c.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),c.relativePath=c.relativePath.slice(r.length)}let l=W([r,c.relativePath]),u=n.concat(c);e.children&&e.children.length>0&&(H(e.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${l}".`),Ki(e.children,t,u,l,o)),!(e.path==null&&!e.index)&&t.push({path:l,score:na(l,e.index),routesMeta:u.map((e,t)=>{let[n,r]=sa(e.relativePath,e.caseSensitive,t===u.length-1);return{...e,matcher:n,compiledParams:r}})})};return e.forEach((e,t)=>{if(e.path===``||!e.path?.includes(`?`))a(e,t);else for(let n of qi(e.path))a(e,t,!0,n)}),t}function qi(e){let t=e.split(`/`);if(t.length===0)return[];let[n,...r]=t,i=n.endsWith(`?`),a=n.replace(/\?$/,``);if(r.length===0)return i?[a,``]:[a];let o=qi(r.join(`/`)),s=[];return s.push(...o.map(e=>e===``?a:[a,e].join(`/`))),i&&s.push(...o),s.map(t=>e.startsWith(`/`)&&t===``?`/`:t)}function Ji(e){e.sort((e,t)=>e.score===t.score?ra(e.routesMeta.map(e=>e.childrenIndex),t.routesMeta.map(e=>e.childrenIndex)):t.score-e.score)}var Yi=/^:[\w-]+$/,Xi=3,Zi=2,Qi=1,$i=10,ea=-2,ta=e=>e===`*`;function na(e,t){let n=e.split(`/`),r=n.length;return n.some(ta)&&(r+=ea),t&&(r+=Zi),n.filter(e=>!ta(e)).reduce((e,t)=>e+(Yi.test(t)?Xi:t===``?Qi:$i),r)}function ra(e,t){return e.length===t.length&&e.slice(0,-1).every((e,n)=>e===t[n])?e[e.length-1]-t[t.length-1]:0}function ia(e,t,n=!1){let{routesMeta:r}=e,i={},a=`/`,o=[];for(let e=0;e<r.length;++e){let s=r[e],c=e===r.length-1,l=a===`/`?t:t.slice(a.length)||`/`,u={path:s.relativePath,caseSensitive:s.caseSensitive,end:c},d=s.matcher&&s.compiledParams?oa(u,l,s.matcher,s.compiledParams):aa(u,l),f=s.route;if(!d&&c&&n&&!r[r.length-1].route.index&&(d=aa({path:s.relativePath,caseSensitive:s.caseSensitive,end:!1},l)),!d)return null;Object.assign(i,d.params),o.push({params:i,pathname:W([a,d.pathname]),pathnameBase:va(W([a,d.pathnameBase])),route:f}),d.pathnameBase!==`/`&&(a=W([a,d.pathnameBase]))}return o}function aa(e,t){typeof e==`string`&&(e={path:e,caseSensitive:!1,end:!0});let[n,r]=sa(e.path,e.caseSensitive,e.end);return oa(e,t,n,r)}function oa(e,t,n,r){let i=t.match(n);if(!i)return null;let a=i[0],o=a.replace(/(.)\/+$/,`$1`),s=i.slice(1);return{params:r.reduce((e,{paramName:t,isOptional:n},r)=>{if(t===`*`){let e=s[r]||``;o=a.slice(0,a.length-e.length).replace(/(.)\/+$/,`$1`)}let i=s[r];return n&&!i?e[t]=void 0:e[t]=(i||``).replace(/%2F/g,`/`),e},{}),pathname:a,pathnameBase:o,pattern:e}}function sa(e,t=!1,n=!0){U(e===`*`||!e.endsWith(`*`)||e.endsWith(`/*`),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,`/*`)}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,`/*`)}".`);let r=[],i=`^`+e.replace(/\/*\*?$/,``).replace(/^\/*/,`/`).replace(/[\\.*+^${}|()[\]]/g,`\\$&`).replace(/\/:([\w-]+)(\?)?/g,(e,t,n,i,a)=>{if(r.push({paramName:t,isOptional:n!=null}),n){let t=a.charAt(i+e.length);return t&&t!==`/`?`/([^\\/]*)`:`(?:/([^\\/]*))?`}return`/([^\\/]+)`}).replace(/\/([\w-]+)\?(\/|$)/g,`(/$1)?$2`);return e.endsWith(`*`)?(r.push({paramName:`*`}),i+=e===`*`||e===`/*`?`(.*)$`:`(?:\\/(.+)|\\/*)$`):n?i+=`\\/*$`:e!==``&&e!==`/`&&(i+=`(?:(?=\\/|$))`),[new RegExp(i,t?void 0:`i`),r]}function ca(e){try{return e.split(`/`).map(e=>decodeURIComponent(e).replace(/\//g,`%2F`)).join(`/`)}catch(t){return U(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}function la(e,t){if(t===`/`)return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith(`/`)?t.length-1:t.length,r=e.charAt(n);return r&&r!==`/`?null:e.slice(n)||`/`}function ua(e,t=`/`){let{pathname:n,search:r=``,hash:i=``}=typeof e==`string`?zi(e):e,a;return n?(n=ga(n),a=n.startsWith(`/`)?da(n.substring(1),`/`):da(n,t)):a=t,{pathname:a,search:ya(r),hash:ba(i)}}function da(e,t){let n=_a(t).split(`/`);return e.split(`/`).forEach(e=>{e===`..`?n.length>1&&n.pop():e!==`.`&&n.push(e)}),n.length>1?n.join(`/`):`/`}function fa(e,t,n,r){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(r)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function pa(e){return e.filter((e,t)=>t===0||e.route.path&&e.route.path.length>0)}function ma(e){let t=pa(e);return t.map((e,n)=>n===t.length-1?e.pathname:e.pathnameBase)}function ha(e,t,n,r=!1){let i;typeof e==`string`?i=zi(e):(i={...e},H(!i.pathname||!i.pathname.includes(`?`),fa(`?`,`pathname`,`search`,i)),H(!i.pathname||!i.pathname.includes(`#`),fa(`#`,`pathname`,`hash`,i)),H(!i.search||!i.search.includes(`#`),fa(`#`,`search`,`hash`,i)));let a=e===``||i.pathname===``,o=a?`/`:i.pathname,s;if(o==null)s=n;else{let e=t.length-1;if(!r&&o.startsWith(`..`)){let t=o.split(`/`);for(;t[0]===`..`;)t.shift(),--e;i.pathname=t.join(`/`)}s=e>=0?t[e]:`/`}let c=ua(i,s),l=o&&o!==`/`&&o.endsWith(`/`),u=(a||o===`.`)&&n.endsWith(`/`);return!c.pathname.endsWith(`/`)&&(l||u)&&(c.pathname+=`/`),c}var ga=e=>e.replace(/[\\/]{2,}/g,`/`),W=e=>ga(e.join(`/`)),_a=e=>e.replace(/\/+$/,``),va=e=>_a(e).replace(/^\/*/,`/`),ya=e=>!e||e===`?`?``:e.startsWith(`?`)?e:`?`+e,ba=e=>!e||e===`#`?``:e.startsWith(`#`)?e:`#`+e,xa=class{constructor(e,t,n,r=!1){this.status=e,this.statusText=t||``,this.internal=r,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}};function Sa(e){return e!=null&&typeof e.status==`number`&&typeof e.statusText==`string`&&typeof e.internal==`boolean`&&`data`in e}function Ca(e){return W(e.map(e=>e.route.path).filter(Boolean))||`/`}var wa=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function Ta(e,t){let n=e;if(typeof n!=`string`||!ki.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,i=!1;if(wa)try{let e=new URL(window.location.href),r=Ai.test(n)?new URL(ji(n,e.protocol)):new URL(n),a=la(r.pathname,t);r.origin===e.origin&&a!=null?n=a+r.search+r.hash:i=!0}catch{U(!1,`<Link to="${n}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:r,isExternal:i,to:n}}Object.getOwnPropertyNames(Object.prototype).sort().join(`\0`);var Ea=[`POST`,`PUT`,`PATCH`,`DELETE`];new Set(Ea);var Da=[`GET`,...Ea];new Set(Da);var Oa=[`about:`,`blob:`,`chrome:`,`chrome-untrusted:`,`content:`,`data:`,`devtools:`,`file:`,`filesystem:`,`javascript:`];function ka(e){try{return Oa.includes(new URL(e).protocol)}catch{return!1}}var Aa=A(null);Aa.displayName=`DataRouter`;var ja=A(null);ja.displayName=`DataRouterState`;var Ma=A(!1);function Na(){return F(Ma)}var Pa=A({isTransitioning:!1});Pa.displayName=`ViewTransition`;var Fa=A(new Map);Fa.displayName=`Fetchers`;var Ia=A(null);Ia.displayName=`Await`;var G=A(null);G.displayName=`Navigation`;var La=A(null);La.displayName=`Location`;var K=A({outlet:null,matches:[],isDataRoute:!1});K.displayName=`Route`;var Ra=A(null);Ra.displayName=`RouteError`;var za=`REACT_ROUTER_ERROR`,Ba=`REDIRECT`,Va=`ROUTE_ERROR_RESPONSE`;function Ha(e){if(e.startsWith(`${za}:${Ba}:{`))try{let t=JSON.parse(e.slice(28));if(typeof t==`object`&&t&&typeof t.status==`number`&&typeof t.statusText==`string`&&typeof t.location==`string`&&typeof t.reloadDocument==`boolean`&&typeof t.replace==`boolean`)return t}catch{}}function Ua(e){if(e.startsWith(`${za}:${Va}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t==`object`&&t&&typeof t.status==`number`&&typeof t.statusText==`string`)return new xa(t.status,t.statusText,t.data)}catch{}}function Wa(e,{relative:t}={}){H(Ga(),`useHref() may be used only in the context of a <Router> component.`);let{basename:n,navigator:r}=F(G),{hash:i,pathname:a,search:o}=$a(e,{relative:t}),s=a;return n!==`/`&&(s=a===`/`?n:W([n,a])),r.createHref({pathname:s,search:o,hash:i})}function Ga(){return F(La)!=null}function q(){return H(Ga(),`useLocation() may be used only in the context of a <Router> component.`),F(La).location}function Ka(){return F(La).navigationType}var qa=`You should call navigate() in a React.useEffect(), not when your component is first rendered.`;function Ja(e){F(G).static||l(e)}function J(){let{isDataRoute:e}=F(K);return e?yo():Ya()}function Ya(){H(Ga(),`useNavigate() may be used only in the context of a <Router> component.`);let e=F(Aa),{basename:t,navigator:n}=F(G),{matches:r}=F(K),{pathname:i}=q(),a=JSON.stringify(ma(r)),o=f(!1);return Ja(()=>{o.current=!0}),y((r,s={})=>{if(U(o.current,qa),!o.current)return;if(typeof r==`number`){n.go(r);return}let c=ha(r,JSON.parse(a),i,s.relative===`path`);e==null&&t!==`/`&&(c.pathname=c.pathname===`/`?t:W([t,c.pathname])),(s.replace?n.replace:n.push)(c,s.state,s)},[t,n,a,i,e])}var Xa=A(null);function Za(e){let t=F(K).outlet;return p(()=>t&&a(Xa.Provider,{value:e},t),[t,e])}function Qa(){let{matches:e}=F(K);return e[e.length-1]?.params??{}}function $a(e,{relative:t}={}){let{matches:n}=F(K),{pathname:r}=q(),i=JSON.stringify(ma(n));return p(()=>ha(e,JSON.parse(i),r,t===`path`),[e,i,r,t])}function eo(e,t){return to(e,t)}function to(e,t,n){H(Ga(),`useRoutes() may be used only in the context of a <Router> component.`);let{navigator:r}=F(G),{matches:i}=F(K),o=i[i.length-1],s=o?o.params:{},c=o?o.pathname:`/`,l=o?o.pathnameBase:`/`,u=o&&o.route;{let e=u&&u.path||``;xo(c,!u||e.endsWith(`*`)||e.endsWith(`*?`),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${c}" (under <Route path="${e}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
3
3
 
4
- Please change the parent <Route path="${e}"> to <Route path="${e===`/`?`*`:`${e}/*`}">.`)}let d=q(),f;if(t){let e=typeof t==`string`?zi(t):t;H(l===`/`||e.pathname?.startsWith(l),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${l}" but pathname "${e.pathname}" was given in the \`location\` prop.`),f=e}else f=d;let p=f.pathname||`/`,m=p;if(l!==`/`){let e=l.replace(/^\//,``).split(`/`);m=`/`+p.replace(/^\//,``).split(`/`).slice(e.length).join(`/`)}let h=n&&n.state.matches.length?n.state.matches.map(e=>Object.assign(e,{route:n.manifest[e.route.id]||e.route})):Hi(e,{pathname:m});U(u||h!=null,`No routes matched location "${f.pathname}${f.search}${f.hash}" `),U(h==null||h[h.length-1].route.element!==void 0||h[h.length-1].route.Component!==void 0||h[h.length-1].route.lazy!==void 0,`Matched leaf route at location "${f.pathname}${f.search}${f.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let g=co(h&&h.map(e=>Object.assign({},e,{params:Object.assign({},s,e.params),pathname:W([l,r.encodeLocation?r.encodeLocation(e.pathname.replace(/%/g,`%25`).replace(/\?/g,`%3F`).replace(/#/g,`%23`)).pathname:e.pathname]),pathnameBase:e.pathnameBase===`/`?l:W([l,r.encodeLocation?r.encodeLocation(e.pathnameBase.replace(/%/g,`%25`).replace(/\?/g,`%3F`).replace(/#/g,`%23`)).pathname:e.pathnameBase])})),i,n);return t&&g?a(La.Provider,{value:{location:{pathname:`/`,search:``,hash:``,state:null,key:`default`,mask:void 0,...f},navigationType:`POP`}},g):g}function no(){let e=vo(),t=Sa(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,r=`rgba(200,200,200, 0.5)`,i={padding:`0.5rem`,backgroundColor:r},o={padding:`2px 4px`,backgroundColor:r},s=null;return console.error(`Error handled by React Router default ErrorBoundary:`,e),s=a(u,null,a(`p`,null,`💿 Hey developer 👋`),a(`p`,null,`You can provide a way better UX than this when your app throws errors by providing your own `,a(`code`,{style:o},`ErrorBoundary`),` or`,` `,a(`code`,{style:o},`errorElement`),` prop on your route.`)),a(u,null,a(`h2`,null,`Unexpected Application Error!`),a(`h3`,{style:{fontStyle:`italic`}},t),n?a(`pre`,{style:i},n):null,s)}var ro=a(no,null),io=class extends c{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||t.revalidation!==`idle`&&e.revalidation===`idle`?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error===void 0?t.error:e.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){this.props.onError?this.props.onError(e,t):console.error(`React Router caught the following error during render`,e)}render(){let e=this.state.error;if(this.context&&typeof e==`object`&&e&&`digest`in e&&typeof e.digest==`string`){let t=Ua(e.digest);t&&(e=t)}let t=e===void 0?this.props.children:a(K.Provider,{value:this.props.routeContext},a(Ra.Provider,{value:e,children:this.props.component}));return this.context?a(oo,{error:e},t):t}};io.contextType=Ma;var ao=new WeakMap;function oo({children:e,error:t}){let{basename:n}=F(G);if(typeof t==`object`&&t&&`digest`in t&&typeof t.digest==`string`){let e=Ha(t.digest);if(e){let r=ao.get(t);if(r)throw r;let i=Ta(e.location,n),o=i.absoluteURL||i.to;if(ka(o))throw Error(`Invalid redirect location`);if(wa&&!ao.get(t))if(i.isExternal||e.reloadDocument)window.location.href=o;else{let n=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(i.to,{replace:e.replace}));throw ao.set(t,n),n}return a(`meta`,{httpEquiv:`refresh`,content:`0;url=${o}`})}}return e}function so({routeContext:e,match:t,children:n}){let r=F(Aa);return r&&r.static&&r.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=t.route.id),a(K.Provider,{value:e},n)}function co(e,t=[],n){let r=n?.state;if(e==null){if(!r)return null;if(r.errors)e=r.matches;else if(t.length===0&&!r.initialized&&r.matches.length>0)e=r.matches;else return null}let i=e,o=r?.errors;if(o!=null){let e=i.findIndex(e=>e.route.id&&o?.[e.route.id]!==void 0);H(e>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(o).join(`,`)}`),i=i.slice(0,Math.min(i.length,e+1))}let s=!1,c=-1;if(n&&r){s=r.renderFallback;for(let e=0;e<i.length;e++){let t=i[e];if((t.route.HydrateFallback||t.route.hydrateFallbackElement)&&(c=e),t.route.id){let{loaderData:e,errors:a}=r,o=t.route.loader&&!e.hasOwnProperty(t.route.id)&&(!a||a[t.route.id]===void 0);if(t.route.lazy||o){n.isStatic&&(s=!0),i=c>=0?i.slice(0,c+1):[i[0]];break}}}}let l=n?.onError,u=r&&l?(e,t)=>{l(e,{location:r.location,params:r.matches?.[0]?.params??{},pattern:Ca(r.matches),errorInfo:t})}:void 0;return i.reduceRight((e,n,l)=>{let d,f=!1,p=null,m=null;r&&(d=o&&n.route.id?o[n.route.id]:void 0,p=n.route.errorElement||ro,s&&(c<0&&l===0?(xo(`route-fallback`,!1,"No `HydrateFallback` element provided to render during initial hydration"),f=!0,m=null):c===l&&(f=!0,m=n.route.hydrateFallbackElement||null)));let h=t.concat(i.slice(0,l+1)),g=()=>{let t;return t=d?p:f?m:n.route.Component?a(n.route.Component,null):n.route.element?n.route.element:e,a(so,{match:n,routeContext:{outlet:e,matches:h,isDataRoute:r!=null},children:t})};return r&&(n.route.ErrorBoundary||n.route.errorElement||l===0)?a(io,{location:r.location,revalidation:r.revalidation,component:p,error:d,children:g(),routeContext:{outlet:null,matches:h,isDataRoute:!0},onError:u}):g()},null)}function lo(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function uo(e){let t=F(Aa);return H(t,lo(e)),t}function fo(e){let t=F(ja);return H(t,lo(e)),t}function po(e){let t=F(K);return H(t,lo(e)),t}function mo(e){let t=po(e),n=t.matches[t.matches.length-1];return H(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function ho(){return mo(`useRouteId`)}function go(){let e=fo(`useNavigation`);return p(()=>{let{matches:t,historyAction:n,...r}=e.navigation;return r},[e.navigation])}function _o(){let{matches:e,loaderData:t}=fo(`useMatches`);return p(()=>e.map(e=>Wi(e,t)),[e,t])}function vo(){let e=F(Ra),t=fo(`useRouteError`),n=mo(`useRouteError`);return e===void 0?t.errors?.[n]:e}function yo(){let{router:e}=uo(`useNavigate`),t=mo(`useNavigate`),n=f(!1);return Ja(()=>{n.current=!0}),y(async(r,i={})=>{U(n.current,qa),n.current&&(typeof r==`number`?await e.navigate(r):await e.navigate(r,{fromRouteId:t,...i}))},[e,t])}var bo={};function xo(e,t,n){!t&&!bo[e]&&(bo[e]=!0,U(!1,n))}_(So);function So({routes:e,manifest:t,future:n,state:r,isStatic:i,onError:a}){return to(e,void 0,{manifest:t,state:r,isStatic:i,onError:a,future:n})}function Y({to:e,replace:t,state:n,relative:r}){H(Ga(),`<Navigate> may be used only in the context of a <Router> component.`);let{static:i}=F(G);U(!i,`<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.`);let{matches:a}=F(K),{pathname:o}=q(),s=J(),c=ha(e,ma(a),o,r===`path`),l=JSON.stringify(c);return x(()=>{s(JSON.parse(l),{replace:t,state:n,relative:r})},[s,l,r,t,n]),null}function X(e){H(!1,`A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.`)}function Co({basename:e=`/`,children:t=null,location:n,navigationType:r=`POP`,navigator:i,static:o=!1,useTransitions:s}){H(!Ga(),`You cannot render a <Router> inside another <Router>. You should never have more than one in your app.`);let c=e.replace(/^\/*/,`/`),l=p(()=>({basename:c,navigator:i,static:o,useTransitions:s,future:{}}),[c,i,o,s]);typeof n==`string`&&(n=zi(n));let{pathname:u=`/`,search:d=``,hash:f=``,state:m=null,key:h=`default`,mask:g}=n,_=p(()=>{let e=la(u,c);return e==null?null:{location:{pathname:e,search:d,hash:f,state:m,key:h,mask:g},navigationType:r}},[c,u,d,f,m,h,r,g]);return U(_!=null,`<Router basename="${c}"> is not able to match the URL "${u}${d}${f}" because it does not start with the basename, so the <Router> won't render anything.`),_==null?null:a(G.Provider,{value:l},a(La.Provider,{children:t,value:_}))}function wo({children:e,location:t}){return eo(To(e),t)}function To(e,t=[]){let n=[];return s.forEach(e,(e,r)=>{if(!m(e))return;let i=[...t,r];if(e.type===u){n.push.apply(n,To(e.props.children,i));return}H(e.type===X,`[${typeof e.type==`string`?e.type:e.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),H(!e.props.index||!e.props.children,`An index route cannot have child routes.`);let a={id:e.props.id||i.join(`-`),caseSensitive:e.props.caseSensitive,element:e.props.element,Component:e.props.Component,index:e.props.index,path:e.props.path,middleware:e.props.middleware,loader:e.props.loader,action:e.props.action,hydrateFallbackElement:e.props.hydrateFallbackElement,HydrateFallback:e.props.HydrateFallback,errorElement:e.props.errorElement,ErrorBoundary:e.props.ErrorBoundary,hasErrorBoundary:e.props.hasErrorBoundary===!0||e.props.ErrorBoundary!=null||e.props.errorElement!=null,shouldRevalidate:e.props.shouldRevalidate,handle:e.props.handle,lazy:e.props.lazy};e.props.children&&(a.children=To(e.props.children,i)),n.push(a)}),n}var Eo=`get`,Do=`application/x-www-form-urlencoded`;function Oo(e){return typeof HTMLElement<`u`&&e instanceof HTMLElement}function ko(e){return Oo(e)&&e.tagName.toLowerCase()===`button`}function Ao(e){return Oo(e)&&e.tagName.toLowerCase()===`form`}function jo(e){return Oo(e)&&e.tagName.toLowerCase()===`input`}function Mo(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function No(e,t){return e.button===0&&(!t||t===`_self`)&&!Mo(e)}function Po(e=``){return new URLSearchParams(typeof e==`string`||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((t,n)=>{let r=e[n];return t.concat(Array.isArray(r)?r.map(e=>[n,e]):[[n,r]])},[]))}function Fo(e,t){let n=Po(e);return t&&t.forEach((e,r)=>{n.has(r)||t.getAll(r).forEach(e=>{n.append(r,e)})}),n}var Io=null;function Lo(){if(Io===null)try{new FormData(document.createElement(`form`),0),Io=!1}catch{Io=!0}return Io}var Ro=new Set([`application/x-www-form-urlencoded`,`multipart/form-data`,`text/plain`]);function zo(e){return e!=null&&!Ro.has(e)?(U(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Do}"`),null):e}function Bo(e,t){let n,r,i,a,o;if(Ao(e)){let o=e.getAttribute(`action`);r=o?la(o,t):null,n=e.getAttribute(`method`)||Eo,i=zo(e.getAttribute(`enctype`))||Do,a=new FormData(e)}else if(ko(e)||jo(e)&&(e.type===`submit`||e.type===`image`)){let o=e.form;if(o==null)throw Error(`Cannot submit a <button> or <input type="submit"> without a <form>`);let s=e.getAttribute(`formaction`)||o.getAttribute(`action`);if(r=s?la(s,t):null,n=e.getAttribute(`formmethod`)||o.getAttribute(`method`)||Eo,i=zo(e.getAttribute(`formenctype`))||zo(o.getAttribute(`enctype`))||Do,a=new FormData(o,e),!Lo()){let{name:t,type:n,value:r}=e;if(n===`image`){let e=t?`${t}.`:``;a.append(`${e}x`,`0`),a.append(`${e}y`,`0`)}else t&&a.append(t,r)}}else if(Oo(e))throw Error(`Cannot submit element that is not <form>, <button>, or <input type="submit|image">`);else n=Eo,r=null,i=Do,o=e;return a&&i===`text/plain`&&(o=a,a=void 0),{action:r,method:n.toLowerCase(),encType:i,formData:a,body:o}}Object.getOwnPropertyNames(Object.prototype).sort().join(`\0`);var Vo={"&":`\\u0026`,">":`\\u003e`,"<":`\\u003c`,"\u2028":`\\u2028`,"\u2029":`\\u2029`},Ho=/[&><\u2028\u2029]/g;function Uo(e){return e.replace(Ho,e=>Vo[e])}function Wo(e,t){if(e===!1||e==null)throw Error(t)}function Go(e,t,n,r){let i=typeof e==`string`?new URL(e,typeof window>`u`?`server://singlefetch/`:window.location.origin):e;return n?i.pathname.endsWith(`/`)?i.pathname=`${i.pathname}_.${r}`:i.pathname=`${i.pathname}.${r}`:i.pathname===`/`?i.pathname=`_root.${r}`:t&&la(i.pathname,t)===`/`?i.pathname=`${_a(t)}/_root.${r}`:i.pathname=`${_a(i.pathname)}.${r}`,i}async function Ko(e,t){if(e.id in t)return t[e.id];try{let n=await i(()=>import(e.module),[],import.meta.url);return t[e.id]=n,n}catch(t){return console.error(`Error loading route module \`${e.module}\`, reloading page...`),console.error(t),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function qo(e){return e!=null&&typeof e.page==`string`}function Jo(e){return e==null?!1:e.href==null?e.rel===`preload`&&typeof e.imageSrcSet==`string`&&typeof e.imageSizes==`string`:typeof e.rel==`string`&&typeof e.href==`string`}async function Yo(e,t,n){return es((await Promise.all(e.map(async e=>{let r=t.routes[e.route.id];if(r){let e=await Ko(r,n);return e.links?e.links():[]}return[]}))).flat(1).filter(Jo).filter(e=>e.rel===`stylesheet`||e.rel===`preload`).map(e=>e.rel===`stylesheet`?{...e,rel:`prefetch`,as:`style`}:{...e,rel:`prefetch`}))}function Xo(e,t,n,r,i,a){let o=(e,t)=>n[t]?e.route.id!==n[t].route.id:!0,s=(e,t)=>n[t].pathname!==e.pathname||n[t].route.path?.endsWith(`*`)&&n[t].params[`*`]!==e.params[`*`];return a===`assets`?t.filter((e,t)=>o(e,t)||s(e,t)):a===`data`?t.filter((t,a)=>{let c=r.routes[t.route.id];if(!c||!c.hasLoader)return!1;if(o(t,a)||s(t,a))return!0;if(t.route.shouldRevalidate){let r=t.route.shouldRevalidate({currentUrl:new URL(i.pathname+i.search+i.hash,window.origin),currentParams:n[0]?.params||{},nextUrl:new URL(e,window.origin),nextParams:t.params,defaultShouldRevalidate:!0});if(typeof r==`boolean`)return r}return!0}):[]}function Zo(e,t,{includeHydrateFallback:n}={}){return Qo(e.map(e=>{let r=t.routes[e.route.id];if(!r)return[];let i=[r.module];return r.clientActionModule&&(i=i.concat(r.clientActionModule)),r.clientLoaderModule&&(i=i.concat(r.clientLoaderModule)),n&&r.hydrateFallbackModule&&(i=i.concat(r.hydrateFallbackModule)),r.imports&&(i=i.concat(r.imports)),i}).flat(1))}function Qo(e){return[...new Set(e)]}function $o(e){let t={},n=Object.keys(e).sort();for(let r of n)t[r]=e[r];return t}function es(e,t){let n=new Set,r=new Set(t);return e.reduce((e,i)=>{if(t&&!qo(i)&&i.as===`script`&&i.href&&r.has(i.href))return e;let a=JSON.stringify($o(i));return n.has(a)||(n.add(a),e.push({key:a,link:i})),e},[])}function ts(){let e=F(Aa);return Wo(e,`You must render this element inside a <DataRouterContext.Provider> element`),e}function ns(){let e=F(ja);return Wo(e,`You must render this element inside a <DataRouterStateContext.Provider> element`),e}var rs=A(void 0);rs.displayName=`FrameworkContext`;function is(){let e=F(rs);return Wo(e,`You must render this element inside a <HydratedRouter> element`),e}function as(e,t){let n=F(rs),[r,i]=C(!1),[a,o]=C(!1),{onFocus:s,onBlur:c,onMouseEnter:l,onMouseLeave:u,onTouchStart:d}=t,p=f(null);x(()=>{if(e===`render`&&o(!0),e===`viewport`){let e=new IntersectionObserver(e=>{e.forEach(e=>{o(e.isIntersecting)})},{threshold:.5});return p.current&&e.observe(p.current),()=>{e.disconnect()}}},[e]),x(()=>{if(r){let e=setTimeout(()=>{o(!0)},100);return()=>{clearTimeout(e)}}},[r]);let m=()=>{i(!0)},h=()=>{i(!1),o(!1)};return n?e===`intent`?[a,p,{onFocus:os(s,m),onBlur:os(c,h),onMouseEnter:os(l,m),onMouseLeave:os(u,h),onTouchStart:os(d,m)}]:[a,p,{}]:[!1,p,{}]}function os(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function ss({page:e,...t}){let n=Na(),{nonce:r}=is(),{router:i}=ts(),o=p(()=>Hi(i.routes,e,i.basename),[i.routes,e,i.basename]);return o?(t.nonce==null&&r&&(t={...t,nonce:r}),a(n?ls:us,{page:e,matches:o,...t})):null}function cs(e){let{manifest:t,routeModules:n}=is(),[r,i]=C([]);return x(()=>{let r=!1;return Yo(e,t,n).then(e=>{r||i(e)}),()=>{r=!0}},[e,t,n]),r}function ls({page:e,matches:t,...n}){let r=q(),{future:i}=is(),{basename:o}=ts();return a(u,null,p(()=>{if(e===r.pathname+r.search+r.hash)return[];let n=Go(e,o,i.v8_trailingSlashAwareDataRequests,`rsc`),a=!1,s=[];for(let e of t)typeof e.route.shouldRevalidate==`function`?a=!0:s.push(e.route.id);return a&&s.length>0&&n.searchParams.set(`_routes`,s.join(`,`)),[n.pathname+n.search]},[o,i.v8_trailingSlashAwareDataRequests,e,r,t]).map(e=>a(`link`,{key:e,rel:`prefetch`,as:`fetch`,href:e,...n})))}function us({page:e,matches:t,...n}){let r=q(),{future:i,manifest:o,routeModules:s}=is(),{basename:c}=ts(),{loaderData:l,matches:d}=ns(),f=p(()=>Xo(e,t,d,o,r,`data`),[e,t,d,o,r]),m=p(()=>Xo(e,t,d,o,r,`assets`),[e,t,d,o,r]),h=p(()=>{if(e===r.pathname+r.search+r.hash)return[];let n=new Set,a=!1;if(t.forEach(e=>{let t=o.routes[e.route.id];!t||!t.hasLoader||(!f.some(t=>t.route.id===e.route.id)&&e.route.id in l&&s[e.route.id]?.shouldRevalidate||t.hasClientLoader?a=!0:n.add(e.route.id))}),n.size===0)return[];let u=Go(e,c,i.v8_trailingSlashAwareDataRequests,`data`);return a&&n.size>0&&u.searchParams.set(`_routes`,t.filter(e=>n.has(e.route.id)).map(e=>e.route.id).join(`,`)),[u.pathname+u.search]},[c,i.v8_trailingSlashAwareDataRequests,l,r,o,f,t,e,s]),g=p(()=>Zo(m,o),[m,o]),_=cs(m);return a(u,null,h.map(e=>a(`link`,{key:e,rel:`prefetch`,as:`fetch`,href:e,...n})),g.map(e=>a(`link`,{key:e,rel:`modulepreload`,href:e,...n})),_.map(({key:e,link:t})=>a(`link`,{key:e,nonce:n.nonce,...t,crossOrigin:t.crossOrigin??n.crossOrigin})))}function ds(...e){return t=>{e.forEach(e=>{typeof e==`function`?e(t):e!=null&&(e.current=t)})}}var fs=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;try{fs&&(window.__reactRouterVersion=`7.18.0`)}catch{}function ps({basename:e,children:t,useTransitions:n,window:r}){let i=f();i.current??=Pi({window:r,v5Compat:!0});let o=i.current,[s,c]=C({action:o.action,location:o.location}),u=y(e=>{n===!1?c(e):d(()=>c(e))},[n]);return l(()=>o.listen(u),[o,u]),a(Co,{basename:e,children:t,location:s.location,navigationType:s.action,navigator:o,useTransitions:n})}function ms({basename:e,children:t,history:n,useTransitions:r}){let[i,o]=C({action:n.action,location:n.location}),s=y(e=>{r===!1?o(e):d(()=>o(e))},[r]);return l(()=>n.listen(s),[n,s]),a(Co,{basename:e,children:t,location:i.location,navigationType:i.action,navigator:n,useTransitions:r})}ms.displayName=`unstable_HistoryRouter`;var hs=k(function({onClick:e,discover:t=`render`,prefetch:n=`none`,relative:r,reloadDocument:i,replace:o,mask:s,state:c,target:l,to:d,preventScrollReset:f,viewTransition:p,defaultShouldRevalidate:m,...h},g){let{basename:_,navigator:v,useTransitions:y}=F(G),b=typeof d==`string`&&ki.test(d),x=Ta(d,_);d=x.to;let S=Wa(d,{relative:r}),C=q(),w=null;if(s){let e=ha(s,[],C.mask?C.mask.pathname:`/`,!0);_!==`/`&&(e.pathname=e.pathname===`/`?_:W([_,e.pathname])),w=v.createHref(e)}let[T,E,D]=as(n,h),O=Ss(d,{replace:o,mask:s,state:c,target:l,preventScrollReset:f,relative:r,viewTransition:p,defaultShouldRevalidate:m,useTransitions:y});function k(t){e&&e(t),t.defaultPrevented||O(t)}let A=!(x.isExternal||i),j=a(`a`,{...h,...D,href:(A?w:void 0)||x.absoluteURL||S,onClick:A?k:e,ref:ds(g,E),target:l,"data-discover":!b&&t===`render`?`true`:void 0});return T&&!b?a(u,null,j,a(ss,{page:S})):j});hs.displayName=`Link`;var gs=k(function({"aria-current":e=`page`,caseSensitive:t=!1,className:n=``,end:r=!1,style:i,to:o,viewTransition:s,children:c,...l},u){let d=$a(o,{relative:l.relative}),f=q(),p=F(ja),{navigator:m,basename:h}=F(G),g=p!=null&&Ns(d)&&s===!0,_=m.encodeLocation?m.encodeLocation(d).pathname:d.pathname,v=f.pathname,y=p&&p.navigation&&p.navigation.location?p.navigation.location.pathname:null;t||(v=v.toLowerCase(),y=y?y.toLowerCase():null,_=_.toLowerCase()),y&&h&&(y=la(y,h)||y);let b=_!==`/`&&_.endsWith(`/`)?_.length-1:_.length,x=v===_||!r&&v.startsWith(_)&&v.charAt(b)===`/`,S=y!=null&&(y===_||!r&&y.startsWith(_)&&y.charAt(_.length)===`/`),C={isActive:x,isPending:S,isTransitioning:g},w=x?e:void 0,T;T=typeof n==`function`?n(C):[n,x?`active`:null,S?`pending`:null,g?`transitioning`:null].filter(Boolean).join(` `);let E=typeof i==`function`?i(C):i;return a(hs,{...l,"aria-current":w,className:T,ref:u,style:E,to:o,viewTransition:s},typeof c==`function`?c(C):c)});gs.displayName=`NavLink`;var _s=k(({discover:e=`render`,fetcherKey:t,navigate:n,reloadDocument:r,replace:i,state:o,method:s=Eo,action:c,onSubmit:l,relative:u,preventScrollReset:f,viewTransition:p,defaultShouldRevalidate:m,...h},g)=>{let{useTransitions:_}=F(G),v=Es(),y=Ds(c,{relative:u}),b=s.toLowerCase()===`get`?`get`:`post`,x=typeof c==`string`&&ki.test(c);return a(`form`,{ref:g,method:b,action:y,onSubmit:r?l:e=>{if(l&&l(e),e.defaultPrevented)return;e.preventDefault();let r=e.nativeEvent.submitter,a=r?.getAttribute(`formmethod`)||s,c=()=>v(r||e.currentTarget,{fetcherKey:t,method:a,navigate:n,replace:i,state:o,relative:u,preventScrollReset:f,viewTransition:p,defaultShouldRevalidate:m});_&&n!==!1?d(()=>c()):c()},...h,"data-discover":!x&&e===`render`?`true`:void 0})});_s.displayName=`Form`;function vs({getKey:e,storageKey:t,...n}){let r=F(rs),{basename:i}=F(G),o=q(),s=_o();js({getKey:e,storageKey:t});let c=p(()=>{if(!r||!e)return null;let t=As(o,s,i,e);return t===o.key?null:t},[]);if(!r||r.isSpaMode)return null;let l=((e,t)=>{if(!window.history.state||!window.history.state.key){let e=Math.random().toString(32).slice(2);window.history.replaceState({key:e},``)}try{let n=JSON.parse(sessionStorage.getItem(e)||`{}`)[t||window.history.state.key];typeof n==`number`&&window.scrollTo(0,n)}catch(t){console.error(t),sessionStorage.removeItem(e)}}).toString();return n.nonce==null&&r?.nonce&&(n.nonce=r.nonce),a(`script`,{...n,suppressHydrationWarning:!0,dangerouslySetInnerHTML:{__html:`(${l})(${Uo(JSON.stringify(t||Os))}, ${Uo(JSON.stringify(c))})`}})}vs.displayName=`ScrollRestoration`;function ys(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function bs(e){let t=F(Aa);return H(t,ys(e)),t}function xs(e){let t=F(ja);return H(t,ys(e)),t}function Ss(e,{target:t,replace:n,mask:r,state:i,preventScrollReset:a,relative:o,viewTransition:s,defaultShouldRevalidate:c,useTransitions:l}={}){let u=J(),f=q(),p=$a(e,{relative:o});return y(m=>{if(No(m,t)){m.preventDefault();let t=n===void 0?Ri(f)===Ri(p):n,h=()=>u(e,{replace:t,mask:r,state:i,preventScrollReset:a,relative:o,viewTransition:s,defaultShouldRevalidate:c});l?d(()=>h()):h()}},[f,u,p,n,r,i,t,e,a,o,s,c,l])}function Cs(e){U(typeof URLSearchParams<`u`,"You cannot use the `useSearchParams` hook in a browser that does not support the URLSearchParams API. If you need to support Internet Explorer 11, we recommend you load a polyfill such as https://github.com/ungap/url-search-params.");let t=f(Po(e)),n=f(!1),r=q(),i=p(()=>Fo(r.search,n.current?null:t.current),[r.search]),a=J();return[i,y((e,t)=>{let r=Po(typeof e==`function`?e(new URLSearchParams(i)):e);n.current=!0,a(`?`+r,t)},[a,i])]}var ws=0,Ts=()=>`__${String(++ws)}__`;function Es(){let{router:e}=bs(`useSubmit`),{basename:t}=F(G),n=ho(),r=e.fetch,i=e.navigate;return y(async(e,a={})=>{let{action:o,method:s,encType:c,formData:l,body:u}=Bo(e,t);a.navigate===!1?await r(a.fetcherKey||Ts(),n,a.action||o,{defaultShouldRevalidate:a.defaultShouldRevalidate,preventScrollReset:a.preventScrollReset,formData:l,body:u,formMethod:a.method||s,formEncType:a.encType||c,flushSync:a.flushSync}):await i(a.action||o,{defaultShouldRevalidate:a.defaultShouldRevalidate,preventScrollReset:a.preventScrollReset,formData:l,body:u,formMethod:a.method||s,formEncType:a.encType||c,replace:a.replace,state:a.state,fromRouteId:n,flushSync:a.flushSync,viewTransition:a.viewTransition})},[r,i,t,n])}function Ds(e,{relative:t}={}){let{basename:n}=F(G),r=F(K);H(r,`useFormAction must be used inside a RouteContext`);let[i]=r.matches.slice(-1),a={...$a(e||`.`,{relative:t})},o=q();if(e==null){a.search=o.search;let e=new URLSearchParams(a.search),t=e.getAll(`index`);if(t.some(e=>e===``)){e.delete(`index`),t.filter(e=>e).forEach(t=>e.append(`index`,t));let n=e.toString();a.search=n?`?${n}`:``}}return(!e||e===`.`)&&i.route.index&&(a.search=a.search?a.search.replace(/^\?/,`?index&`):`?index`),n!==`/`&&(a.pathname=a.pathname===`/`?n:W([n,a.pathname])),Ri(a)}var Os=`react-router-scroll-positions`,ks={};function As(e,t,n,r){let i=null;return r&&(i=r(n===`/`?e:{...e,pathname:la(e.pathname,n)||e.pathname},t)),i??=e.key,i}function js({getKey:e,storageKey:t}={}){let{router:n}=bs(`useScrollRestoration`),{restoreScrollPosition:r,preventScrollReset:i}=xs(`useScrollRestoration`),{basename:a}=F(G),o=q(),s=_o(),c=go();x(()=>(window.history.scrollRestoration=`manual`,()=>{window.history.scrollRestoration=`auto`}),[]),Ms(y(()=>{if(c.state===`idle`){let t=As(o,s,a,e);ks[t]=window.scrollY}try{sessionStorage.setItem(t||Os,JSON.stringify(ks))}catch(e){U(!1,`Failed to save scroll positions in sessionStorage, <ScrollRestoration /> will not work properly (${e}).`)}window.history.scrollRestoration=`auto`},[c.state,e,a,o,s,t])),typeof document<`u`&&(l(()=>{try{let e=sessionStorage.getItem(t||Os);e&&(ks=JSON.parse(e))}catch{}},[t]),l(()=>{let t=n?.enableScrollRestoration(ks,()=>window.scrollY,e?(t,n)=>As(t,n,a,e):void 0);return()=>t&&t()},[n,a,e]),l(()=>{if(r!==!1){if(typeof r==`number`){window.scrollTo(0,r);return}try{if(o.hash){let e=document.getElementById(decodeURIComponent(o.hash.slice(1)));if(e){e.scrollIntoView();return}}}catch{U(!1,`"${o.hash.slice(1)}" is not a decodable element ID. The view will not scroll to it.`)}i!==!0&&window.scrollTo(0,0)}},[o,r,i]))}function Ms(e,t){let{capture:n}=t||{};x(()=>{let t=n==null?void 0:{capture:n};return window.addEventListener(`pagehide`,e,t),()=>{window.removeEventListener(`pagehide`,e,t)}},[e,n])}function Ns(e,{relative:t}={}){let n=F(Pa);H(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=bs(`useViewTransitionState`),i=$a(e,{relative:t});if(!n.isTransitioning)return!1;let a=la(n.currentLocation.pathname,r)||n.currentLocation.pathname,o=la(n.nextLocation.pathname,r)||n.nextLocation.pathname;return aa(i.pathname,o)!=null||aa(i.pathname,a)!=null}var Ps=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}}))()),Fs=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g;function Is(e){var t={type:`tag`,name:``,voidElement:!1,attrs:{},children:[]},n=e.match(/<\/?([^\s]+?)[/\s>]/);if(n&&(t.name=n[1],(Ps.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(Fs),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 Ls=/<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g,Rs=/^\s*$/,zs=Object.create(null);function Bs(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(Bs,``)+`</`+t.name+`>`;case`comment`:return e+`<!--`+t.comment+`-->`}}var Vs={parse:function(e,t){t||={},t.components||=zs;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(Ls,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=Is(s);return a<0?(r.push(m),r):((l=i[a]).children.push(m),r)}if(u&&(a++,(n=Is(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);Rs.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+Bs(``,t)},``)}};D();var Hs=(e,t)=>{if(!e)return!1;let n=e.props?.children??e.children;return t?n.length>0:!!n},Us=e=>{if(!e)return[];let t=e.props?.children??e.children;return e.props?.i18nIsDynamicList?Gs(t):t},Ws=e=>Array.isArray(e)&&e.every(m),Gs=e=>Array.isArray(e)?e:[e],Ks=(e,t)=>{let n={...t};return n.props={...t.props,...e.props},n},qs=e=>{let t={};if(!e)return t;let n=e=>{Gs(e).forEach(e=>{bi(e)||(Hs(e)?n(Us(e)):Ti(e)&&!m(e)&&Object.assign(t,e))})};return n(e),t},Js=(e,t,n,r)=>{if(!e)return``;let i=``,a=Gs(e),o=t?.transSupportBasicHtmlNodes?t.transKeepBasicHtmlNodesFor??[]:[];return a.forEach((e,a)=>{if(bi(e)){i+=`${e}`;return}if(m(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=bi(d)?d:Js(d,t,n,r);i+=`<${c}>${e}</${c}>`;return}let f=Js(d,t,n,r);i+=`<${a}>${f}</${a}>`;return}if(e===null){Si(n,`TRANS_NULL_VALUE`,`Passed in a null value as child`,{i18nKey:r});return}if(Ti(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}Si(n,`TRANS_INVALID_OBJ`,`Invalid child - Object should only have keys {{ value, format }} (format is optional).`,{i18nKey:r,child:e});return}Si(n,`TRANS_INVALID_VAR`,`Passed in a variable like {number} - pass variables for interpolation as full objects like {{number}}.`,{i18nKey:r,child:e})}),i},Ys=(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},Xs=(e,t,n,r,i,o,c)=>{if(n===``)return[];let l=i.transKeepBasicHtmlNodesFor||[],d=n&&new RegExp(l.map(e=>`<${e}`).join(`|`)).test(n);if(!e&&!t&&!d&&!c)return[n];let f=t??{},p=e=>{Gs(e).forEach(e=>{bi(e)||(Hs(e)?p(Us(e)):Ti(e)&&!m(e)&&Object.assign(f,e))})};p(e);let h=Ys(n,l,f),_=Vs.parse(`<0>${h}</0>`),v={...f,...o},y=(e,t,n)=>{let r=Us(e),i=x(r,t.children,n);return Ws(r)&&i.length===0||e.props?.i18nIsDynamicList?r:i},b=(e,t,n,r,i)=>{e.dummy?(e.children=t,n.push(g(e,{key:r},i?void 0:t))):n.push(...s.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])}),a(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])}),g(e,n,i?null:t)}))},x=(e,n,o)=>{let s=Gs(e),u=Gs(n),f={};return u.reduce((e,n,u)=>{let p=n.children?.[0]?.content&&r.services.interpolator.interpolate(n.children[0].content,v,r.language);if(n.type===`tag`){let h=s[parseInt(n.name,10)];!h&&t&&(h=t[n.name]),o.length===1&&!h&&(h=o[0][n.name]),h||={};let g={...n.attrs};c&&Object.keys(g).forEach(e=>{let t=g[e];bi(t)&&(g[e]=wi(t))});let _=Object.keys(g).length===0?h:Ks({props:g},h),S=m(_),C=S&&Hs(n,!0)&&!n.voidElement,w=d&&Ti(_)&&_.dummy&&!S,T=Ti(t)&&Object.hasOwnProperty.call(t,n.name);if(bi(_)){let t=r.services.interpolator.interpolate(_,v,r.language);e.push(t)}else if(Hs(_)||C)b(_,y(_,n,o),e,u);else if(w)b(_,x(s,n.children,o),e,u);else if(Number.isNaN(parseFloat(n.name)))if(T)b(_,y(_,n,o),e,u,n.voidElement);else if(i.transSupportBasicHtmlNodes&&l.indexOf(n.name)>-1)if(n.voidElement)e.push(a(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<s.length;e+=1){let a=s[e];if(m(a)&&a.type===n.name){if(i===t){r=a;break}i+=1}}let c=x(r?Gs(Us(r)):s,n.children,o);e.push(a(n.name,{key:`${n.name}-${u}`},c))}else if(n.voidElement)e.push(`<${n.name} />`);else{let t=x(s,n.children,o);e.push(`<${n.name}>${t}</${n.name}>`)}else if(Ti(_)&&!S){let t=n.children[0]?p:null;t&&e.push(t)}else b(_,p,e,u,n.children.length!==1||!p)}else if(n.type===`text`){let t=i.transWrapTextNodes,o=typeof i.unescape==`function`?i.unescape:yi().unescape,s=c?o(r.services.interpolator.interpolate(n.content,v,r.language)):r.services.interpolator.interpolate(n.content,v,r.language);t?e.push(a(t,{key:`${n.name}-${u}`},s)):e.push(s)}return e},[])};return Us(x([{dummy:!0,children:e||[]}],_,Gs(e||[]))[0])},Zs=(e,t,n)=>{let r=e.key||t,i=g(e,{key:r});if(!i.props||!i.props.children||n.indexOf(`${t}/>`)<0&&n.indexOf(`${t} />`)<0)return i;function o(){return a(u,null,i)}return a(o,{key:r})},Qs=(e,t)=>e.map((e,n)=>Zs(e,n,t)),$s=(e,t)=>{let n={};return Object.keys(e).forEach(r=>{Object.assign(n,{[r]:Zs(e[r],r,t)})}),n},ec=(e,t,n,r)=>e?Array.isArray(e)?Qs(e,t):Ti(e)?$s(e,t):(Ei(n,`TRANS_INVALID_COMPONENTS`,`<Trans /> "components" prop expects an object or array`,{i18nKey:r}),null):null,tc=e=>!Ti(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:o={},values:s,defaults:c,components:l,ns:u,i18n:d,t:f,shouldUnescape:p,...m}){let h=d||xi();if(!h)return Ei(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),_={...yi(),...h.options?.react},v=u||g.ns||h.options?.defaultNS;v=bi(v)?[v]:v||[`translation`];let{transDefaultProps:y}=_,b=y?.tOptions?{...y.tOptions,...o}:o,x=p??y?.shouldUnescape,S=y?.values?{...y.values,...s}:s,C=y?.components?{...y.components,...l}:l,w=Js(e,_,h,r),T=c||b?.defaultValue||w||_.transEmptyNodeValue||(typeof r==`function`?vi(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=qs(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=ec(C,j,h,r),N=M||e,P=null;tc(M)&&(P=M,N=e);let F=Xs(N,P,j,h,_,A,x),I=n??_.defaultTransParent;return I?a(I,m,F):F}D();function rc({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}=F(Ci)||{},g=u||m||xi(),_=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})}function ic(e,t){return t.map(t=>({subject:{kind:`device`,deviceId:e},key:t.key,scope:t.scope}))}function ac({deviceId:e}){let{t}=V(),{presence:n,list:r}=kr(e);return n===`absent`?null:n===`unknown`?b(Cn,{message:t(`deviceQuickDetail.historyUnknown`,`Could not tell whether this device has recorded history.`)}):n===`pending`||r.status===`pending`?b(Gn,{className:`h-24 w-full`,"aria-busy":`true`}):r.status===`error`?b(Cn,{title:t(`deviceQuickDetail.historyUnknown`,`Could not tell whether this device has recorded history.`),message:r.error}):r.data.length===0?null:o(`section`,{className:`flex flex-col gap-2`,"aria-label":t(`deviceQuickDetail.tabHistory`,`History`),children:[b(`div`,{className:`flex justify-end`,children:b(hs,{to:li(ic(e,r.data)),className:`text-xs text-primary hover:underline`,children:t(`deviceQuickDetail.openHistory`,`Open full history`)})}),b(br,{deviceId:e})]})}function oc(e,t){return e===`present`&&t.status===`ok`&&(t.data?.length??0)>0}var sc={streaming:{icon:yn,labelKey:`capabilityBadges.streaming`},detection:{icon:xe,labelKey:`capabilityBadges.detection`},recording:{icon:$e,labelKey:`capabilityBadges.recording`},audio:{icon:Ge,labelKey:`capabilityBadges.audio`},snapshot:{icon:ce,labelKey:`capabilityBadges.snapshot`},motion:{icon:Fe,labelKey:`capabilityBadges.motion`},ptz:{icon:Ne,labelKey:`capabilityBadges.ptz`},webrtc:{icon:ee,labelKey:`capabilityBadges.webrtc`},onvif:{icon:ke,labelKey:`capabilityBadges.onvif`},analytics:{icon:We,labelKey:`capabilityBadges.analytics`},"battery-operated":{icon:Se,labelKey:`capabilityBadges.battery`},"native-snapshot":{icon:ce,labelKey:`capabilityBadges.nativeSnapshot`},"pan-tilt-zoom":{icon:Ne,labelKey:`capabilityBadges.ptz`},"two-way-audio":{icon:Ge,labelKey:`capabilityBadges.twoWayAudio`},"doorbell-button":{icon:ye,labelKey:`capabilityBadges.doorbell`},rebootable:{icon:L,labelKey:`capabilityBadges.rebootable`},"vacuum-has-map":{icon:hn,labelKey:`capabilityBadges.map`},"vacuum-has-ai":{icon:Je,labelKey:`capabilityBadges.aiObstacle`},"mower-has-map":{icon:hn,labelKey:`capabilityBadges.map`},"mower-has-targeted-mowing":{icon:R,labelKey:`capabilityBadges.targetedMowing`}},cc=se;function lc({capabilities:e,showLabels:t=!1}){let{t:n}=V();return b(`div`,{className:`flex items-center gap-1 flex-wrap`,children:e.map(e=>{let r=sc[e],i=r?.icon??cc,a=r?n(r.labelKey):e;return o(`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:[b(i,{className:`h-3 w-3`}),t&&b(`span`,{children:a})]},e)})})}D();var uc={amcrest:{icon:un,color:`#3b82f6`,label:`Amcrest`},hikvision:{icon:we,color:`#a855f7`,label:`Hikvision`},reolink:{icon:ee,color:`#06b6d4`,label:`Reolink`},homeassistant:{icon:tt,color:`#22d3ee`,label:`Home Assistant`},rtsp:{icon:Oe,color:`#78716c`,label:`RTSP`},onvif:{icon:Oe,color:`#78716c`,label:`ONVIF`}},dc={sm:`h-4 w-4`,md:`h-5 w-5`,lg:`h-6 w-6`,xl:`h-16 w-16`},fc={sm:`h-7 w-7`,md:`h-8 w-8`,lg:`h-10 w-10`,xl:`h-16 w-16`};function pc(e){let t=e.toLowerCase();return t.startsWith(`provider-`)?t.slice(9):t}function mc(e){return uc[pc(e)]??{icon:un,color:`#78716c`,label:e}}function hc({type:e,size:t=`md`,showLabel:n}){let r=mc(e),i=r.icon,[a,s]=C(!1),c=Di(e);return o(`div`,{className:`flex items-center gap-2`,children:[b(`div`,{className:`flex items-center justify-center rounded-lg ${fc[t]}`,style:{backgroundColor:`${r.color}15`},children:a||!c?b(i,{className:dc[t],style:{color:r.color}}):b(`img`,{src:c,alt:r.label,className:dc[t],onError:()=>s(!0)})}),n&&b(`span`,{className:`text-xs font-medium text-foreground-subtle`,children:r.label})]})}function gc({label:e,value:t,layout:n=`inline`}){return n===`stacked`?o(`div`,{className:`min-w-0 flex flex-col gap-0.5 px-0.5`,children:[b(`span`,{className:`text-[11px] text-foreground-subtle`,children:e}),b(`div`,{className:`min-w-0 text-[11px] text-foreground`,children:t})]}):o(`div`,{className:`${_e} flex items-start gap-2 sm:gap-3`,children:[b(`span`,{className:`w-20 sm:w-28 flex-shrink-0 text-[11px] text-foreground-subtle`,children:e}),b(`div`,{className:`flex-1 min-w-0 text-[11px] text-foreground`,children:t})]})}D();function _c(e){return Hn({addonId:e,projection:`slim`})}function vc(e){return qn({deviceId:e},{enabled:Number.isFinite(e)})}var yc=3e4,bc=2e3;function xc(e){let t=f(0);return t.current===0&&(t.current=Date.now()),Dn({parentDeviceId:e},{enabled:Number.isFinite(e),staleTime:0,refetchOnMount:`always`,refetchInterval:e=>{let n=e.state.data;return n&&n.length>0||Date.now()-t.current>=yc?!1:bc}})}D();function Sc({deviceId:e}){let{t}=V(),n=M(),{data:r}=vc(e),{data:i}=xc(e),[a,s]=C(null),c=ti({onSuccess:()=>{s(null),n.invalidateQueries({queryKey:[[`deviceManager`]]})},onError:e=>{s(`Could not change primary child: ${e.message}`)}});if(r==null||String(r.type??``)!==dt.Container)return null;let l=String(r.name??``),u=(i??[]).map(e=>({id:e.id,stableId:e.stableId,type:e.type,name:nr(e,l),...e.sourceInfo?{sourceInfo:{id:e.sourceInfo.id}}:{}}));if(u.length<=1)return null;let d=Bn(u,typeof r.linkDeviceId==`number`?r.linkDeviceId:null,typeof r.primaryChildEntityId==`string`?r.primaryChildEntityId:null),f=d===null?u[0].id:d.id;return o(P,{children:[b(gc,{label:t(`shared.primaryChildRow.primaryChild`,`Primary child`),value:b(cr,{childrenList:u,selectedId:f,onSetPrimary:t=>c.mutate({deviceId:e,primaryChildEntityId:t}),disabled:c.isPending})}),a!==null&&b(`p`,{role:`alert`,className:`px-3 sm:px-4 py-1.5 text-[11px] text-danger`,children:a})]})}D();var Cc=[`manufacturer`,`model`,`hardware`,`firmware`,`serialNumber`,`uid`,`mac`,`itemNo`];function wc(e){return e.replace(/([a-z])([A-Z])/g,`$1 $2`).replace(/^./,e=>e.toUpperCase())}function Tc(e){return e==null?`—`:typeof e==`string`||typeof e==`number`||typeof e==`boolean`?String(e):JSON.stringify(e)}function Ec(){let{t:e}=V(),t=Yn(),n=xn(),{data:r}=qn({deviceId:t??0},{enabled:t!==null}),{data:i}=$n({deviceId:t??0},{enabled:t!==null}),a=r??n??null,[s,c]=C(`identity`);if(t===null||!a)return null;let l=String(a.stableId??``),u=String(a.addonId??``),d=typeof a.integrationId==`string`&&a.integrationId.length>0?a.integrationId:null,f=typeof a.parentDeviceId==`number`?a.parentDeviceId:null,p=a.features??[],m=new Set([`device-status`,`feature-probe`,`device-ops`]),h=(i?.entries??[]).filter(e=>e.kind===`native`&&!m.has(e.capName)).map(e=>e.capName),g=p.length>0?p:h,_=a.metadata??null,v=_!==null&&Object.keys(_).length>0;return o(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[o(`div`,{className:`border-b border-border px-3 sm:px-4 py-2 flex items-center justify-between gap-3`,children:[b(`h2`,{className:`text-[11px] font-semibold text-foreground uppercase tracking-wider`,children:e(`overviewAdapters.deviceInfoAdapter.deviceInfo`,`Device Info`)}),v&&o(`div`,{className:`flex items-center gap-1 rounded-md bg-surface-hover p-0.5`,children:[b(Dc,{active:s===`identity`,onClick:()=>c(`identity`),label:e(`overviewAdapters.deviceInfoAdapter.identity`,`Identity`)}),b(Dc,{active:s===`hardware`,onClick:()=>c(`hardware`),label:e(`overviewAdapters.deviceInfoAdapter.hardware`,`Hardware`)})]})]}),(!v||s===`identity`)&&o(`div`,{className:`divide-y divide-border`,children:[b(gc,{label:`ID`,value:o(`span`,{className:`font-mono text-[11px] text-foreground`,children:[`#${t}`,o(`span`,{className:`ml-1.5 text-foreground-subtle`,children:[`(`,l,`)`]})]})}),b(Sc,{deviceId:t}),d!==null&&b(gc,{label:e(`overviewAdapters.deviceInfoAdapter.integration`,`Integration`),value:b(`span`,{className:`font-mono text-[11px]`,children:d})}),f!==null&&b(gc,{label:e(`overviewAdapters.deviceInfoAdapter.parent`,`Parent`),value:b(`span`,{className:`font-mono text-[11px]`,children:`#${String(f)}`})}),b(gc,{label:e(`overviewAdapters.deviceInfoAdapter.provider`,`Provider`),value:b(hc,{type:u,size:`sm`,showLabel:!0})}),b(gc,{label:e(`overviewAdapters.deviceInfoAdapter.capabilities`,`Capabilities`),value:g.length>0?b(lc,{capabilities:g,showLabels:!0}):b(`span`,{className:`text-[11px] text-foreground-subtle`,children:e(`overviewAdapters.deviceInfoAdapter.none`,`None`)})})]}),v&&s===`hardware`&&b(Oc,{metadata:_})]})}function Dc({active:e,onClick:t,label:n}){return b(`button`,{type:`button`,onClick:t,className:`px-2 py-0.5 rounded text-[10px] font-medium transition-colors ${e?`bg-surface text-foreground shadow-sm`:`text-foreground-subtle hover:text-foreground`}`,children:n})}function Oc({metadata:e}){let{t}=V(),n=Cc.filter(t=>t in e),r=Object.keys(e).filter(e=>!Cc.includes(e)).toSorted(),i=[...n,...r];return o(`div`,{children:[b(`div`,{className:`px-3 sm:px-4 py-1.5 text-[10px] text-foreground-subtle border-b border-border bg-surface-subtle/40`,children:t(`overviewAdapters.deviceInfoAdapter.autoPopulatedByTheDriver`,`Auto-populated by the driver on every connect. Read-only.`)}),b(`div`,{className:`divide-y divide-border`,children:i.map(t=>b(gc,{label:wc(t),value:b(`span`,{className:`font-mono text-[11px] text-foreground break-all`,children:Tc(e[t])})},t))})]})}function kc(e,t){return e.icon===t.icon&&e.label===t.label&&e.unit===t.unit&&e.precision===t.precision&&e.hidden===t.hidden}function Ac(e){return{icon:e?.icon??``,label:e?.label??``,unit:e?.unit??``,precision:e?.precision===void 0?``:String(e.precision),hidden:e?.hidden===!0}}function jc(e){if(e.trim()===``)return;let t=Number.parseInt(e,10);return Number.isFinite(t)?t:void 0}function Mc(e,t){let n=jc(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 Nc(e){let t=Ac(e.display);return{name:e.name,location:e.location,role:e.role,display:t,baseName:e.name,baseLocation:e.location,baseRole:e.role,baseDisplay:t,persistedDisplay:e.display}}function Pc(e,t){if(e===null)return Nc(t);let n=Ac(t.display),r=e.name===t.name&&e.location===t.location&&e.role===t.role&&kc(e.display,n);return!Fc(e)||r?Nc(t):e}function Fc(e){return e===null?!1:e.name!==e.baseName||e.location!==e.baseLocation||e.role!==e.baseRole||!kc(e.display,e.baseDisplay)}function Ic(e){return e.name.trim().length===0?`name`:null}function Lc(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},...kc(e.display,e.baseDisplay)?{}:{display:Mc(e.display,e.persistedDisplay)}}}function Rc(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(`; `)}}D();var zc=A(null);function Bc(){return F(zc)}function Vc({deviceId:e,seed:t,showOpenFull:n=!1,onClose:r,children:i}){let[a,o]=C(null),[s,c]=C([]),l=f(new Map);if(t!==null){let e=Pc(a,t);(a===null||e.name!==a.name||e.location!==a.location||e.role!==a.role||!kc(e.display,a.display)||e.baseName!==a.baseName||e.baseLocation!==a.baseLocation||e.baseRole!==a.baseRole||!kc(e.baseDisplay,a.baseDisplay)||e.persistedDisplay!==a.persistedDisplay)&&o(e)}let u=y(e=>(l.current.set(e.id,{save:e.save,discard:e.discard}),c(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:()=>l.current.get(e.id)?.save()??Promise.resolve(),discard:()=>{l.current.get(e.id)?.discard()}}]}),()=>{l.current.delete(e.id),c(t=>t.filter(t=>t.id!==e.id))}),[]),d=p(()=>({identity:a,setIdentityName:e=>{o(t=>t===null?t:{...t,name:e})},setIdentityLocation:e=>{o(t=>t===null?t:{...t,location:e})},setIdentityRole:e=>{o(t=>t===null?t:{...t,role:e})},setIdentityDisplay:e=>{o(t=>t===null?t:{...t,display:{...t.display,...e}})},register:u}),[a,u]);return b(zc.Provider,{value:d,children:b(Hc,{deviceId:e,identity:a,contributions:s,onIdentitySaved:e=>o(e),showOpenFull:n,onClose:r,children:i})})}function Hc({deviceId:e,identity:t,contributions:n,onIdentitySaved:r,showOpenFull:i,onClose:a,children:s}){return o(P,{children:[s,b(Wc,{deviceId:e,identity:t,contributions:n,onIdentitySaved:r,showOpenFull:i,onClose:a})]})}function Uc(e){return e instanceof Error?e.message:String(e)}function Wc({deviceId:e,identity:t,contributions:n,onIdentitySaved:r,showOpenFull:i,onClose:a}){let{t:s}=V(),c=J(),l=Qe(),u=M(),[d,f]=C(null),[p,m]=C(!1),h=wr(),g=ur(),_=Hr(),v=fr(),y=Rc([{dirty:Fc(t),saving:p,error:d},...n]),x=()=>{u.invalidateQueries({queryKey:[[`deviceManager`]]})};return!y.dirty&&!y.saving&&y.error===null&&!i?null:o(`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:[y.error!==null&&b(`p`,{className:`text-xs text-danger`,children:y.error}),o(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[i?b(Cr,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>{(async()=>{y.dirty&&!await l({title:s(`deviceQuickDetail.leaveTitle`,`Discard unsaved changes?`),message:s(`deviceQuickDetail.leaveMessage`,`Unsaved edits on this device will be discarded.`),confirmLabel:s(`deviceQuickDetail.discard`,`Discard`),variant:`warning`})||(c(`/devices/${String(e)}?tab=customize`),a?.())})()},children:s(`deviceQuickDetail.openFull`,`Open full detail`)}):b(`span`,{}),o(`div`,{className:`flex items-center gap-2`,children:[b(Cr,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>{t!==null&&r({...t,name:t.baseName,location:t.baseLocation,role:t.baseRole,display:t.baseDisplay});for(let e of n)e.discard();f(null)},disabled:!y.dirty||y.saving,children:s(`deviceQuickDetail.discard`,`Discard`)}),b(Cr,{type:`button`,size:`sm`,onClick:()=>{if(t!==null&&Fc(t)&&Ic(t)===`name`){f(s(`deviceQuickDetail.nameRequired`,`Name is required`));return}f(null),m(!0),(async()=>{try{let i=t===null?{}:Lc(t);if(t!==null&&i.name!==void 0&&await h.mutateAsync({deviceId:e,name:i.name}),t!==null&&i.location!==void 0&&await g.mutateAsync({deviceId:e,location:i.location}),t!==null&&i.role!==void 0&&await _.mutateAsync({deviceId:e,role:i.role}),t!==null&&i.display!==void 0&&await v.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,persistedDisplay:i.display===void 0?t.persistedDisplay:i.display??void 0})}for(let e of n)e.dirty&&await e.save();x()}catch(e){f(Uc(e))}finally{m(!1)}})()},disabled:!y.dirty||y.saving,children:y.saving?s(`deviceQuickDetail.saving`,`Saving…`):s(`deviceQuickDetail.save`,`Save`)})]})]})]})}function Gc(e){return e.hubReachable?e.authOk===!1?{kind:`auth-expired`}:{kind:`cluster-degraded`,offlineAgents:e.offlineAgents,offlineAgentIds:e.offlineAgentIds}:{kind:`hub-unreachable`}}function Kc(e){switch(e.kind){case`connected`:return null;case`reconnecting`:return{severity:`warning`,message:B.t(`connection.reconnecting`),i18nKey:`connection.reconnecting`,showSpinner:!0};case`cluster-degraded`:{let t=e.offlineAgentIds??[];return t.length>0?{severity:`warning`,message:B.t(`connection.degradedNodes`,{nodes:t.join(`, `),count:t.length}),i18nKey:`connection.degradedNodes`,i18nParams:{nodes:t.join(`, `),count:t.length},showSpinner:!0}:e.offlineAgents!==null&&e.offlineAgents>0?{severity:`warning`,message:B.t(`connection.degradedCount`,{count:e.offlineAgents}),i18nKey:`connection.degradedCount`,i18nParams:{count:e.offlineAgents},showSpinner:!0}:{severity:`warning`,message:B.t(`connection.degraded`),i18nKey:`connection.degraded`,showSpinner:!0}}case`hub-unreachable`:return{severity:`danger`,message:B.t(`connection.disconnected`),i18nKey:`connection.disconnected`,showSpinner:!0};case`auth-expired`:return{severity:`danger`,message:B.t(`connection.sessionExpired`),i18nKey:`connection.sessionExpired`,showSpinner:!1,action:`sign-in`}}}var qc=4e3,Jc=5e3;function Yc(e){if(typeof e!=`object`||!e)return{offline:null,offlineIds:null,ok:null};let t={...e},n=typeof t.ok==`boolean`?t.ok:null,r=t.agents;if(typeof r!=`object`||!r)return{offline:null,offlineIds:null,ok:n};let i={...r},a=i.offline,o=typeof a==`number`?a:null,s=i.offlineIds;return{offline:o,offlineIds:Array.isArray(s)?s.filter(e=>typeof e==`string`):null,ok:n}}async function Xc(e,t,n,r){let i=new AbortController,a=setTimeout(()=>i.abort(),n);try{return await e(t,{method:`GET`,signal:i.signal,credentials:`omit`,...r===void 0?{}:{headers:r}})}finally{clearTimeout(a)}}async function Zc(e){let t=e.fetchFn??fetch,n=e.timeoutMs??qc,r=e.origin.replace(/\/+$/,``),i;try{i=await Xc(t,`${r}/health`,n)}catch{return{hubReachable:!1,authOk:`unknown`,offlineAgents:null,offlineAgentIds:null}}if(!i.ok)return{hubReachable:!1,authOk:`unknown`,offlineAgents:null,offlineAgentIds:null};let a=null,o=e.getToken();if(o!==null&&o!==``)try{let e=await Xc(t,`${r}/health/details`,n,{Authorization:`Bearer ${o}`});e.ok&&(a=await e.json())}catch{}let s;try{s=Yc(a??await i.json())}catch{s={offline:null,offlineIds:null,ok:null}}if(s.ok===!1)return{hubReachable:!1,authOk:`unknown`,offlineAgents:null,offlineAgentIds:null};let c=e.getToken(),l=`unknown`;if(c!==null&&c!==``)try{let e=await Xc(t,`${r}/trpc/auth.me`,n,{Authorization:`Bearer ${c}`});e.status===401||e.status===403?l=!1:e.ok&&(l=!0)}catch{l=`unknown`}return{hubReachable:!0,authOk:l,offlineAgents:s.offline,offlineAgentIds:s.offlineIds}}var Qc={kind:`connected`},$c={kind:`reconnecting`};function el(e){let t=e.probeIntervalMs??Jc,n=new Set,r=Qc,i=0,a=!1,o=null;function s(e){if(r!==e){r=e;for(let e of n)e()}}function c(){a=!1,o!==null&&(clearTimeout(o),o=null)}function l(){let n=i;e.probe().then(e=>{n!==i||!a||(s(Gc(e)),o=setTimeout(l,t))},()=>{n!==i||!a||(s({kind:`hub-unreachable`}),o=setTimeout(l,t))})}function u(e){if(i+=1,e===`connected`){c(),s(Qc);return}if(e===`connecting`){c(),s($c);return}(r.kind===`connected`||r.kind===`reconnecting`)&&s($c),o!==null&&(clearTimeout(o),o=null),a=!0,l()}return{getSnapshot:()=>r,subscribe:e=>(n.add(e),()=>{n.delete(e)}),onSdkConnectionState:u,dispose:()=>{i+=1,c(),n.clear()}}}var tl=null;function nl(){return tl===null&&(tl=el({probe:()=>Zc({origin:Ce(),getToken:()=>localStorage.getItem(`camstack_admin_token`)})})),tl}function rl(e){nl().onSdkConnectionState(e)}function il(e){return e===`connected`}function al(e){j.setOnline(il(e))}var ol=null,sl=0;function Z(){if(!ol){let e=sl;ol=xr({serverUrl:Ce(),token:localStorage.getItem(`camstack_admin_token`)??void 0,getLanguage:()=>B.language,refreshCredential:async e=>{e===`rejected`?await wl().refreshNow():await wl().ensureFresh()},onConnectionChange:t=>{e===sl&&(rl(t),al(t))}})}return ol}function cl(){let e=ol;ol=null,sl+=1,e?.close()}var ll=`camstack_admin_token`,ul=`camstack_admin_refresh`,dl=`camstack_admin_token_expires`;function fl(e){try{let t=localStorage.getItem(e);return t!==null&&t.length>0?t:null}catch{return null}}function pl(e,t){try{t===null?localStorage.removeItem(e):localStorage.setItem(e,t)}catch{}}function ml(){let e=fl(ll);if(e===null)return null;let t=fl(ul),n=Number(fl(dl));return{token:e,...t===null?{}:{refreshToken:t},...Number.isFinite(n)&&n>0?{expiresAt:n}:{}}}function hl(e){pl(ll,e.token),pl(ul,e.refreshToken??null),pl(dl,e.expiresAt===void 0?null:String(e.expiresAt))}function gl(){pl(ll,null),pl(ul,null),pl(dl,null)}function _l(e){let t=e.get(`token`);if(t===null||t.length===0)return null;let n=e.get(`refreshToken`),r=Number(e.get(`expiresAt`));return{token:t,...n!==null&&n.length>0?{refreshToken:n}:{},...Number.isFinite(r)&&r>0?{expiresAt:r}:{}}}async function vl(e){await fetch(z(`/api/auth/session`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({token:e})}).catch(()=>{})}var yl=new Set;function bl(e){return yl.add(e),()=>yl.delete(e)}var xl=new Set;function Sl(e){return xl.add(e),()=>xl.delete(e)}var Cl=null;function wl(){return Cl===null&&(Cl=new Tr({refresh:async e=>{let t=ml();if(t?.refreshToken!==void 0&&t.refreshToken!==e&&(t.expiresAt??0)>Date.now()+6e4)return t;let n=await Z().refreshSession(e);return{token:n.token,refreshToken:n.refreshToken,expiresAt:n.expiresAt}},onTokens:e=>{hl(e),Z().setToken(e.token),vl(e.token);for(let e of xl)e()},onExpired:()=>{gl();for(let e of yl)e()}})),Cl}function Tl(e){hl(e),wl().adopt(e)}async function El(e){try{await wl().ensureFresh()}catch(e){console.warn(`[admin-session] pre-reconnect refresh failed; reconnecting anyway`,e)}e()}async function Dl(){return await wl().refreshNow()!==null}var Ol=512;function kl(e){if(!e||e.length>Ol)return null;let t=Rt(e);return t===null?!e.startsWith(`/`)||e.startsWith(`//`)||e.includes(`\\`)||e.includes(`://`)||e.includes(`..`)||e===`/login`||e.startsWith(`/login?`)||e.startsWith(`/login/`)?null:{kind:`path`,path:e}:{kind:`app-callback`,url:t}}var Al=/^[A-Za-z0-9_-]{43,128}$/,jl=/^[A-Za-z0-9._~-]{1,256}$/;function Ml(e){let{codeChallenge:t,state:n}=e;return!t||!Al.test(t)||(e.codeChallengeMethod??`S256`)!==`S256`||!n||!jl.test(n)?null:{codeChallenge:t,state:n,purpose:e.purpose===`step-up`?`step-up`:`new-session`}}var Nl=`camstack:login-app-handoff`;function Pl(e){if(!e)return null;try{let t=JSON.parse(e);if(typeof t!=`object`||!t)return null;let n=e=>{let n=Reflect.get(t,e);return typeof n==`string`?n:null};return Ml({codeChallenge:n(`codeChallenge`),state:n(`state`),purpose:n(`purpose`)})}catch{return null}}function Fl(e,t=Date.now()){e!==null&&ql(Nl,JSON.stringify(e),Pl,t)}function Il(e=Date.now()){return Jl(Nl,Pl,e)}function Ll(e,t,n){return`${e}?${`code=${encodeURIComponent(t)}`}${n===void 0?``:`&state=${encodeURIComponent(n)}`}`}function Rl(e,t=Date.now()){return Zl(t)??kl(e)}var zl=2048;function Bl(e){return!e||e.length>zl||!e.startsWith(`/`)||e.startsWith(`//`)||e.includes(`\\`)||e.includes(`://`)||e.includes(`..`)||e===`/login`||e.startsWith(`/login?`)||e.startsWith(`/login/`)?null:e}function Vl(e,t=Date.now()){ql(Gl,e,Bl,t)}function Hl(e=Date.now()){return Jl(Gl,Bl,e)}function Ul(e,t=Date.now()){return Hl(t)??Bl(e)}var Wl=`camstack:login-redirect`,Gl=`camstack:login-next`,Kl=10*6e4;function ql(e,t,n,r){let i=Yl();if(!i||!n(t))return;let a={raw:t??``,at:r};try{i.setItem(e,JSON.stringify(a))}catch{}}function Jl(e,t,n){let r=Yl();if(!r)return null;let i=null;try{i=r.getItem(e),r.removeItem(e)}catch{return null}if(!i)return null;try{let e=JSON.parse(i);if(typeof e!=`object`||!e)return null;let r=Reflect.get(e,`at`),a=Reflect.get(e,`raw`);return typeof r!=`number`||typeof a!=`string`||n-r>Kl?null:t(a)}catch{return null}}function Yl(){if(typeof window>`u`)return null;try{return window.sessionStorage}catch{return null}}function Xl(e,t=Date.now()){ql(Wl,e,kl,t)}function Zl(e=Date.now()){return Jl(Wl,kl,e)}var Ql=`changeme`;function $l(e){try{let t=e.split(`.`);if(t.length<2||!t[1])return null;let n=JSON.parse(atob(t[1]));return{id:String(n.userId??``),username:String(n.username??`unknown`),isAdmin:!!n.isAdmin,exp:Number(n.exp??0),scopes:eu(n.scopes)}}catch{return null}}function eu(e){return Lt(qt(e))}function tu(e){let t=$l(e);return t?t.exp*1e3<Date.now():!0}D();var nu=Ql;function ru(e){return{token:e.token,...e.refreshToken===void 0?{}:{refreshToken:e.refreshToken},...e.expiresAt===void 0?{}:{expiresAt:e.expiresAt}}}async function iu(e,t){if(await vl(e),t.kind===`path`){window.location.replace(z(t.path));return}try{cl();let e=Il();if(e===null)throw Error(`The app sent no PKCE challenge and state`);let{code:n}=await Z().trpcClient.auth.createHandoffCode.mutate({purpose:e.purpose,codeChallenge:e.codeChallenge,state:e.state});window.location.replace(Ll(t.url,n,e.state))}catch{window.location.replace(z(`/`))}}async function au(e,t){await vl(e),window.location.replace(z(t))}var ou=A(null);function su({children:e}){let[t,n]=C(null),[r,i]=C(!0),[a,o]=C(!1);x(()=>{if(typeof window<`u`&&window.location.hash.startsWith(`#token=`)){let e=new URLSearchParams(window.location.hash.slice(1)),t=_l(e),n=t?.token??null;if(t!==null&&n!==null){Tl(t);let r=Zl();if(r){iu(n,r);return}let i=Hl()??Bl(e.get(`next`));if(i){au(n,i);return}window.history.replaceState({},``,z(`/`))}}s()},[]);let s=async()=>{let e=ml();if(e===null){i(!1);return}let t=e.token;if(e.refreshToken!==void 0){let n=wl();n.adopt(e),await n.ensureFresh();let r=ml();if(r===null){console.warn(`[auth] session restore: signed out — the hub refused the refresh token`),cl(),i(!1);return}t=r.token}if(tu(t)){console.warn(`[auth] session restore: signed out — access token expired and no refresh recovered it`),gl(),cl(),i(!1);return}let r=$l(t);if(!r){console.warn(`[auth] session restore: signed out — the stored access token is unreadable`),gl(),cl(),i(!1);return}vl(t);let a=Z();a.trpcClient.system.info.query().then(()=>n(r)).catch(async e=>{let t=e?.data?.code;if(t===`UNAUTHORIZED`||t===`FORBIDDEN`){if(await Dl()){a.reconnect();try{await Z().trpcClient.system.info.query();let e=ml();n(e&&$l(e.token)||r);return}catch{}}console.warn(`[auth] session restore: logout, probe UNAUTHORIZED and refresh did not recover it`),wl().stop(),gl(),cl()}else n(r)}).finally(()=>i(!1))};x(()=>bl(()=>{cl(),n(null),o(!1)}),[]);let c=y(async(e,t)=>{let r=await Z().login(e,t,{refreshable:!0}),i=r.secondFactors??(r.requiresTotp===!0?[`totp`]:[]);if(i.length>0)return{kind:`second-factor`,challengeToken:r.token,factors:i};let a=r.token;return Tl(ru(r)),await vl(a),cl(),n($l(a)),o(t===nu),{kind:`ok`}},[]),l=y(async(e,t)=>{let r=await Z().loginVerifyTotp(e,t,{refreshable:!0}),i=r.token;Tl(ru(r)),await vl(i),cl(),n($l(i)),o(!1)},[]),u=y(async(e,t)=>{Tl({token:e,...t}),await vl(e),cl(),n($l(e)),o(!1)},[]),d=y(()=>{Z().logout().catch(()=>{}),wl().stop(),gl(),fetch(z(`/api/auth/session`),{method:`DELETE`}).catch(()=>{}),cl(),n(null),o(!1)},[]),f=y(()=>{o(!1)},[]);return b(ou.Provider,{value:{user:t,loading:r,mustChangePassword:a,login:c,verifyTotp:l,finalizePasskeyLogin:u,logout:d,clearMustChangePassword:f},children:e})}function cu(){let e=F(ou);if(!e)throw Error(`useAuth must be used within AuthProvider`);return e}D();function lu(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 uu({schema:e,serverValues:t,onImmediateSave:n,onDeferredSave:r}){let[i,a]=C({}),[o,s]=C({}),[c,l]=C(!1),u=f(null),d=e?.sections??[],m=Object.keys(i).length>0,h=p(()=>({...t,...o,...i}),[t,o,i]);x(()=>{if(m||Object.keys(o).length>0){l(!0);return}u.current&&clearTimeout(u.current),u.current=setTimeout(()=>l(!1),500)},[m,o]),x(()=>()=>{u.current&&clearTimeout(u.current)},[]);let g=y(()=>{l(!0),u.current&&clearTimeout(u.current),u.current=setTimeout(()=>l(!1),2e3)},[]),_=y(e=>{g();let r={},o={},s={...t,...i};for(let[t,n]of Object.entries(e))s[t]!==n&&(lu(d,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,d,n]),v=y(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]),b=y(e=>{a(t=>{let n={...t};for(let t of e)delete n[t];return n})},[]),S=y(()=>{a({})},[]);return{values:h,pendingKeys:Object.keys(i),hasPendingEdits:m,editingPaused:c,handleChange:_,handleSave:v,handleDiscard:b,resetAll:S}}function Q(e){return t=>Object.prototype.hasOwnProperty.call(e,t)}var du=Q({devices:!0}),fu=Q({classes:!0,classesExclude:!0,labelEquals:!0,identities:!0,identitiesExclude:!0,eventTypeTokens:!0,sensorKinds:!0}),pu=Q({minConfidence:!0,minImportance:!0,minLabelConfidence:!0}),mu=Q({minDwellSeconds:!0}),hu=Q({source:!0}),gu=Q({crossing:!0}),_u=Q({packagePhase:!0}),vu=Q({sensorTransition:!0}),yu=Q({plates:!0}),bu=Q({occupancy:!0}),xu=Q({audio:!0}),Su=Q({systemEvent:!0}),Cu=Q({deviceState:!0}),wu=Q({scene:!0});function Tu(e,t){let n=e[t];return Array.isArray(n)?n:[]}function Eu(e,t){let n=e[t];return typeof n==`number`?n:void 0}D();function Du(e,t){let n=Ae().trpcClient,r=O({queries:e.map(e=>({queryKey:[[`nc-pickers`,`zones`],{deviceId:e}],staleTime:3e4,queryFn:async()=>({deviceId:e,zones:(await n.zones.listZones.query({deviceId:e})).map(e=>({id:e.id,name:e.name}))})}))});return p(()=>{let e=[],n=new Set;for(let i of r){if(!i.data)continue;let r=t.find(e=>e.id===i.data.deviceId)?.name;for(let t of i.data.zones)n.has(t.id)||(n.add(t.id),e.push({value:t.id,label:t.name,...r===void 0?{}:{hint:r}}))}return{options:e,loading:r.some(e=>e.isLoading),failed:r.some(e=>e.isError)}},[r,t])}function Ou(e){let t=Ae().trpcClient,n=O({queries:e.map(e=>({queryKey:[[`nc-pickers`,`event-kinds`],{deviceId:e}],staleTime:6e4,queryFn:async()=>(await t.pipelineAnalytics.listEventKinds.query({deviceId:e})).map(e=>({kind:e.kind,label:e.label}))}))});return p(()=>{let e=new Map;for(let t of n)for(let n of t.data??[])e.has(n.kind)||e.set(n.kind,n.label);let t=[...e.entries()].map(([e,t])=>({value:e,label:t}));return t.sort((e,t)=>e.label.localeCompare(t.label)),{options:t,loading:n.some(e=>e.isLoading)}},[n])}function ku(){let e=ai();return p(()=>({options:(e.data??[]).map(e=>({value:e.id,label:e.name})),loading:e.isLoading,failed:e.isError===!0}),[e.data,e.isLoading,e.isError])}function Au(){let e=Rn({limit:200}),t=Pn();return p(()=>{let n=new Set;for(let e of t.data??[])e.name.trim().length>0&&n.add(e.name);let r=new Set;for(let t of e.data??[])t.text.trim().length>0&&r.add(t.text);return[...[...n].sort(),...[...r].sort()]},[e.data,t.data])}function ju({options:e,value:t,onChange:n,loading:r,emptyHint:i,placeholder:a,noFreeText:s=!1}){let{t:c}=V(),[l,u]=C(``),d=p(()=>new Set(e.map(e=>e.value)),[e]),f=p(()=>new Set(t),[t]),m=t.filter(e=>!d.has(e)),h=e=>{n(f.has(e)?t.filter(t=>t!==e):[...t,e])},g=()=>{let e=l.trim();e.length===0||t.includes(e)||(n([...t,e]),u(``))};return o(`div`,{className:`mt-1 space-y-1.5`,children:[m.length>0&&b(`div`,{className:`flex flex-wrap gap-1`,children:m.map(e=>o(`button`,{type:`button`,onClick:()=>n(t.filter(t=>t!==e)),className:`inline-flex items-center gap-1 rounded border border-border px-1.5 py-0.5 text-[10px] text-foreground hover:bg-surface-hover`,title:c(`system.notificationRulePickers.customValueClickToRemove`,`Custom value — click to remove`),children:[e,` ×`]},e))}),e.length>0?b(`div`,{className:`max-h-40 overflow-y-auto rounded-md border border-border divide-y divide-border`,children:e.map(e=>o(`label`,{className:`flex items-center gap-2.5 px-3 py-1.5 text-xs text-foreground cursor-pointer hover:bg-surface-hover`,children:[b(`input`,{type:`checkbox`,checked:f.has(e.value),onChange:()=>h(e.value),className:`accent-primary`}),b(`span`,{className:`flex-1 truncate`,children:e.label}),e.hint!==void 0&&b(`span`,{className:`text-[10px] text-foreground-subtle`,children:e.hint})]},e.value))}):b(`p`,{className:`text-[10px] text-foreground-subtle`,children:r===!0?c(`common.loading`,`Loading…`):i}),!s&&b(`input`,{value:l,onChange:e=>u(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),g())},placeholder:a,className:`w-full rounded-md border border-border bg-background px-2 py-1 text-xs text-foreground placeholder:text-foreground-subtle`})]})}var Mu=[{value:`immediate`,get label(){return B.t(`helpers.ruleFormParsers.immediate`)},get hint(){return B.t(`helpers.ruleFormParsers.immediateHint`)}},{value:`track-end`,get label(){return B.t(`helpers.ruleFormParsers.trackEnd`)},get hint(){return B.t(`helpers.ruleFormParsers.trackEndHint`)}},{value:`device-event`,get label(){return B.t(`helpers.ruleFormParsers.deviceEvent`)},get hint(){return B.t(`helpers.ruleFormParsers.deviceEventHint`)}},{value:`package-event`,get label(){return B.t(`helpers.ruleFormParsers.packageEvent`)},get hint(){return B.t(`helpers.ruleFormParsers.packageEventHint`)}},{value:`system-event`,get label(){return B.t(`helpers.ruleFormParsers.systemEvent`)},get hint(){return B.t(`helpers.ruleFormParsers.systemEventHint`)}}],Nu=`Immediate, grouped`,Pu=Mu.flatMap(e=>e.value===`immediate`?[e,{value:`immediate-grouped`,get label(){return B.t(`notificationRules.grouping.choice`)},get hint(){return B.t(`helpers.ruleFormParsers.groupedHint`)}}]:[e]);function Fu(e){return e.groupingSec!==void 0&&nn(e)?`immediate-grouped`:e.delivery}function Iu(e){let t=(e.delivery===`immediate`||e.delivery===`track-end`)&&nn({delivery:`immediate`,conditions:e.conditions});return Pu.filter(e=>e.value!==`immediate-grouped`||t)}function Lu(e){return Pu.find(t=>t.value===e)?.value}function Ru(e,t=Nu){return Fu(e)===`immediate-grouped`?`${t} · ${String(e.groupingSec)} s`:Bu(e.delivery)}function zu(e){if(e.trim().length===0)return;let t=Number(e);return Number.isFinite(t)&&t>=0?Math.trunc(t):void 0}function Bu(e){return Mu.find(t=>t.value===e)?.label??e}function Vu(e){return Mu.some(t=>t.value===e)}var Hu=[{key:`all`,get label(){return B.t(`helpers.ruleFormParsers.sec_all_label`)},get blurb(){return B.t(`helpers.ruleFormParsers.sec_all_blurb`)},get newRuleLabel(){return B.t(`helpers.ruleFormParsers.sec_all_new`)},get emptyHint(){return B.t(`helpers.ruleFormParsers.sec_all_empty`)},creatable:!0},{key:`detection`,get label(){return B.t(`helpers.ruleFormParsers.sec_detection_label`)},get blurb(){return B.t(`helpers.ruleFormParsers.sec_detection_blurb`)},get newRuleLabel(){return B.t(`helpers.ruleFormParsers.sec_detection_new`)},get emptyHint(){return B.t(`helpers.ruleFormParsers.sec_detection_empty`)},creatable:!0},{key:`sensor`,get label(){return B.t(`helpers.ruleFormParsers.sec_sensor_label`)},get blurb(){return B.t(`helpers.ruleFormParsers.sec_sensor_blurb`)},get newRuleLabel(){return B.t(`helpers.ruleFormParsers.sec_sensor_new`)},get emptyHint(){return B.t(`helpers.ruleFormParsers.sec_sensor_empty`)},creatable:!0},{key:`audio`,get label(){return B.t(`helpers.ruleFormParsers.sec_audio_label`)},get blurb(){return B.t(`helpers.ruleFormParsers.sec_audio_blurb`)},get newRuleLabel(){return B.t(`helpers.ruleFormParsers.sec_audio_new`)},get emptyHint(){return B.t(`helpers.ruleFormParsers.sec_audio_empty`)},creatable:!0},{key:`occupancy`,get label(){return B.t(`helpers.ruleFormParsers.sec_occupancy_label`)},get blurb(){return B.t(`helpers.ruleFormParsers.sec_occupancy_blurb`)},get newRuleLabel(){return B.t(`helpers.ruleFormParsers.sec_occupancy_new`)},get emptyHint(){return B.t(`helpers.ruleFormParsers.sec_occupancy_empty`)},creatable:!0},{key:`device-events`,get label(){return B.t(`helpers.ruleFormParsers.sec_deviceEvents_label`)},get blurb(){return B.t(`helpers.ruleFormParsers.sec_deviceEvents_blurb`)},get newRuleLabel(){return B.t(`helpers.ruleFormParsers.sec_deviceEvents_new`)},get emptyHint(){return B.t(`helpers.ruleFormParsers.sec_deviceEvents_empty`)},creatable:!0},{key:`system`,get label(){return B.t(`helpers.ruleFormParsers.sec_system_label`)},get blurb(){return B.t(`helpers.ruleFormParsers.sec_system_blurb`)},get newRuleLabel(){return B.t(`helpers.ruleFormParsers.sec_system_new`)},get emptyHint(){return B.t(`helpers.ruleFormParsers.sec_system_empty`)},creatable:!0},{key:`alarm`,get label(){return B.t(`helpers.ruleFormParsers.sec_alarm_label`)},get blurb(){return B.t(`helpers.ruleFormParsers.sec_alarm_blurb`)},get newRuleLabel(){return B.t(`helpers.ruleFormParsers.sec_alarm_new`)},get emptyHint(){return B.t(`helpers.ruleFormParsers.sec_alarm_empty`)},creatable:!0},{key:`mixed`,get label(){return B.t(`helpers.ruleFormParsers.sec_mixed_label`)},get blurb(){return B.t(`helpers.ruleFormParsers.sec_mixed_blurb`)},get newRuleLabel(){return B.t(`helpers.ruleFormParsers.sec_mixed_new`)},get emptyHint(){return B.t(`helpers.ruleFormParsers.sec_mixed_empty`)},creatable:!1}];function Uu(e){return tn(zt(e)).editable}function Wu(e){return Ht(Gu(e))}function Gu(e){switch(e){case`device-events`:case`system`:case`alarm`:case`mixed`:return e;default:return}}var Ku=new Map([[0,`helpers.ruleFormParsers.cdNone`],[60,`helpers.ruleFormParsers.cd1m`],[3600,`helpers.ruleFormParsers.cd1h`]]),qu=86400;function Ju(e){let t=Ku.get(e);return t===void 0?e%3600==0?B.t(`helpers.ruleFormParsers.cdHours`,{count:e/3600}):e%60==0?B.t(`helpers.ruleFormParsers.cdMinutes`,{count:e/60}):B.t(`helpers.ruleFormParsers.cdSeconds`,{count:e}):B.t(t)}function Yu(e){if(e.trim().length===0)return;let t=Number(e);return Number.isFinite(t)&&t>=0?Math.trunc(t):void 0}var Xu=[{value:`rule-device`,get label(){return B.t(`helpers.ruleFormParsers.scopeDevice`)}},{value:`rule`,get label(){return B.t(`helpers.ruleFormParsers.scopeRule`)}}];function Zu(e){return Xu.find(t=>t.value===e)?.value}var Qu=[{value:`per-class`,get label(){return B.t(`helpers.ruleFormParsers.granPerClass`)}},{value:`shared`,get label(){return B.t(`helpers.ruleFormParsers.granShared`)}}];function $u(e){return Qu.find(t=>t.value===e)?.value}var ed=[{value:`scene-boxes`,get label(){return B.t(`helpers.ruleFormParsers.imageSceneBoxes`)},get description(){return B.t(`helpers.ruleFormParsers.imageSceneBoxesDesc`)}},{value:`crop`,get label(){return B.t(`helpers.ruleFormParsers.imageCrop`)},get description(){return B.t(`helpers.ruleFormParsers.imageCropDesc`)}},{value:`clean`,get label(){return B.t(`helpers.ruleFormParsers.imageClean`)},get description(){return B.t(`helpers.ruleFormParsers.imageCleanDesc`)}},{value:`none`,get label(){return B.t(`helpers.ruleFormParsers.imageNone`)},get description(){return B.t(`helpers.ruleFormParsers.imageNoneDesc`)}}];function td(e){return ed.find(t=>t.value===e)?.value}var nd=[{value:``,get label(){return B.t(`helpers.ruleFormParsers.linkedDefault`)}},{value:`mosaic`,get label(){return B.t(`helpers.ruleFormParsers.linkedMosaic`)}},{value:`each`,get label(){return B.t(`helpers.ruleFormParsers.linkedEach`)}}];function rd(e){let t=nd.find(t=>t.value===e)?.value;return t===``?void 0:t}var id=[{value:``,get label(){return B.t(`helpers.ruleFormParsers.profileLowest`)}},{value:`low`,get label(){return B.t(`helpers.ruleFormParsers.profileLow`)}},{value:`mid`,get label(){return B.t(`helpers.ruleFormParsers.profileMid`)}},{value:`high`,get label(){return B.t(`helpers.ruleFormParsers.profileHigh`)}}];function ad(e){let t=id.find(t=>t.value===e)?.value;return t===``?void 0:t}var od=[{value:`any`,get label(){return B.t(`helpers.ruleFormParsers.srcAny`)}},{value:`pipeline`,get label(){return B.t(`helpers.ruleFormParsers.srcPipeline`)}},{value:`onboard`,get label(){return B.t(`helpers.ruleFormParsers.srcOnboard`)}},{value:`sensor`,get label(){return B.t(`helpers.ruleFormParsers.srcSensor`)}}],sd=[{value:`delivered`,get label(){return B.t(`helpers.ruleFormParsers.phaseDelivered`)}},{value:`picked-up`,get label(){return B.t(`helpers.ruleFormParsers.phasePickedUp`)}},{value:`both`,get label(){return B.t(`helpers.ruleFormParsers.phaseBoth`)}}],cd=[{value:``,get label(){return B.t(`helpers.ruleFormParsers.stBoth`)}},{value:`raised`,get label(){return B.t(`helpers.ruleFormParsers.stRaised`)}},{value:`cleared`,get label(){return B.t(`helpers.ruleFormParsers.stCleared`)}}];function ld(e){return e===`raised`||e===`cleared`?e:void 0}function ud(e,t){return e===`sensorTransition`?xt(t.sensorKinds):!0}var dd=[{value:`enter`,get label(){return B.t(`helpers.ruleFormParsers.crossEnter`)}},{value:`exit`,get label(){return B.t(`helpers.ruleFormParsers.crossExit`)}},{value:`any`,get label(){return B.t(`helpers.ruleFormParsers.crossAny`)}}],fd=`enter`;function pd(e){return e===`exit`||e===`any`?e:void 0}var md=[{value:1,get label(){return B.t(`helpers.ruleFormParsers.prioMin`)}},{value:2,get label(){return B.t(`helpers.ruleFormParsers.prioLow`)}},{value:3,get label(){return B.t(`helpers.ruleFormParsers.prioDefault`)}},{value:4,get label(){return B.t(`helpers.ruleFormParsers.prioHigh`)}},{value:5,get label(){return B.t(`helpers.ruleFormParsers.prioMax`)}}];function hd(e,t){return e.options&&e.options.length>0?e.options:t}var gd=[{value:``,get label(){return B.t(`helpers.ruleFormParsers.speedDefault`)}},{value:`1`,get label(){return B.t(`helpers.ruleFormParsers.speedReal`)}},{value:`2`,label:`2×`},{value:`3`,label:`3×`},{value:`4`,label:`4×`},{value:`6`,label:`6×`},{value:`8`,label:`8×`}];function _d(e){if(e===``)return;let t=Number(e);return Number.isFinite(t)&&t>=1&&t<=8?t:void 0}var vd=`notificationRules.systemEventKinds.`,yd=`notificationRules.systemEventGroups.`,bd=`notificationRules.systemEventHints.`;function xd(e){return!_t.some(t=>t===e)}function Sd(e){let t=`${vd}${e}`;return B.exists(t)?B.t(t):e}function Cd(){return Dt.map(e=>({id:e.id,family:e.family,label:B.t(`${yd}${e.id}`,e.label),hint:B.t(`${bd}${e.id}`),kinds:e.kinds.filter(xd).map(e=>({value:e,label:Sd(e)}))}))}function wd(e){return Cd().filter(t=>t.family===e)}function Td(e){let t=ft(e).conditions.systemEvent;return t===void 0?{kinds:(wd(e)[0]?.kinds??[]).map(e=>e.value)}:{...t,kinds:[...t.kinds]}}function Ed(){return Cd().flatMap(e=>e.kinds)}function Dd(e){return{devices:ct(e,`deviceIds`),deviceTypes:ct(e,`deviceTypes`),nodes:ct(e,`nodeIds`),packages:ct(e,`packageNames`),consumableThreshold:ct(e,`consumableLowPercent`)}}function Od(e,t){let n=pt[e],r=Dd(t);return{devices:n.includes(`deviceIds`)&&r.devices,excludeDevices:n.includes(`excludeDeviceIds`)&&r.devices,deviceTypes:n.includes(`deviceTypes`)&&r.deviceTypes,nodes:n.includes(`nodeIds`)&&r.nodes,packages:n.includes(`packageNames`)&&r.packages,consumableThreshold:n.includes(`consumableLowPercent`)&&r.consumableThreshold}}var kd=Object.values(dt).map(e=>({value:e,label:Ad(e)})).toSorted((e,t)=>e.label.localeCompare(t.label));function Ad(e){let t=e.replaceAll(`-`,` `);return t.charAt(0).toUpperCase()+t.slice(1)}function jd(e,t){let n=[],r=new Set;for(let i of e.kinds){let e=At(i.value);if(e===void 0){n.push({key:i.value,label:i.label,kinds:[i.value],clears:[i.value]});continue}r.has(e.id)||(r.add(e.id),n.push({key:`class:${e.id}`,label:t?e.snapshotLabel:e.label,kinds:t?[...e.bad]:St(e),clears:St(e),classId:e.id,...t&&e.snapshotSection===null?{noSnapshot:!0}:{}}))}return n}function Md(e,t){return t.clears.some(t=>e.includes(t))}function Nd(e,t,n){if(!wd(n).some(e=>e.kinds.some(e=>t.kinds.includes(e.value))))return e;let r=e?.kinds??[];if(Md(r,t)){let i=r.filter(e=>!t.clears.includes(e));return i.length===0?e:Ld(e,i,n)}return Ld(e,Ed().filter(e=>t.kinds.includes(e.value)||r.includes(e.value)).map(e=>e.value),n)}function Pd(e,t){return t===void 0?void 0:Ld(t,t.kinds,e)}function Fd(e,t){let n=e?.kinds??[];if(n.length===0)return;let r=Id(t,`deviceIds`,e?.deviceIds),i=Id(t,`excludeDeviceIds`,e?.excludeDeviceIds),a=Id(t,`deviceTypes`,e?.deviceTypes),o=Id(t,`nodeIds`,e?.nodeIds),s=Id(t,`packageNames`,e?.packageNames),c=Object.prototype.hasOwnProperty.call(t,`consumableLowPercent`)?t.consumableLowPercent:e?.consumableLowPercent;return{kinds:[...n],...r===void 0?{}:{deviceIds:[...r]},...i===void 0?{}:{excludeDeviceIds:[...i]},...a===void 0?{}:{deviceTypes:[...a]},...o===void 0?{}:{nodeIds:[...o]},...s===void 0?{}:{packageNames:[...s]},...c===void 0?{}:{consumableLowPercent:c}}}function Id(e,t,n){let r=Object.prototype.hasOwnProperty.call(e,t)?e[t]:n;return r!==void 0&&r.length===0?void 0:r}function Ld(e,t,n){let r=Od(n,t),i=r.devices?e?.deviceIds:void 0,a=r.excludeDevices?e?.excludeDeviceIds:void 0,o=r.deviceTypes?e?.deviceTypes:void 0,s=r.nodes?e?.nodeIds:void 0,c=r.packages?e?.packageNames:void 0,l=r.consumableThreshold?e?.consumableLowPercent:void 0;return{kinds:[...t],...i&&i.length>0?{deviceIds:[...i]}:{},...a&&a.length>0?{excludeDeviceIds:[...a]}:{},...o&&o.length>0?{deviceTypes:[...o]}:{},...s&&s.length>0?{nodeIds:[...s]}:{},...c&&c.length>0?{packageNames:[...c]}:{},...l===void 0?{}:{consumableLowPercent:l}}}var Rd=95;function zd(e){let t=e.trim();if(t===``)return{kind:`clear`};let n=Number(t);return Number.isInteger(n)&&n>=1&&n<=Rd?{kind:`set`,value:n}:{kind:`invalid`}}function Bd(e,t=2){if(e===void 0||e.length===0)return B.t(`helpers.notificationSystemEvents.noneSelected`);let n=e.slice(0,t).map(Sd).join(`, `),r=e.length-Math.min(t,e.length);return r>0?`${n} +${r}`:n}function Vd(e){if(e===void 0)return`—`;let t=[],n=e.deviceIds?.length??0,r=e.deviceTypes?.length??0,i=e.nodeIds?.length??0,a=e.packageNames?.length??0,o=e.excludeDeviceIds?.length??0;r>0&&t.push(e.deviceTypes?.map(Ad).join(`, `)??``),n>0&&t.push(`${n} device${n===1?``:`s`}`),i>0&&t.push(`${i} node${i===1?``:`s`}`),a>0&&t.push(`${a} package${a===1?``:`s`}`);let s=o>0?`except ${o} device${o===1?``:`s`}`:null,c=e.consumableLowPercent===void 0?[]:[`consumables at ${e.consumableLowPercent}%`];return t.length===0?[s===null?`Everything`:`Everything ${s}`,...c].join(` · `):[...t,...s===null?[]:[s],...c].join(` · `)}function Hd(e){return e===void 0||(e.deviceTypes?.length??0)===0?!1:e.kinds.some(e=>lt.includes(e))}var Ud=[`all`,`only`,`except`];function Wd(e,t){return(e??[]).length>0?`only`:(t??[]).length>0?`except`:`all`}function Gd(e,t){let n=[...e??[]],r=[...t??[]];return{mode:Wd(n,r),include:n,exclude:r,legacyBoth:n.length>0&&r.length>0}}function Kd(e,t){return{...e,mode:t}}function qd(e){switch(e.mode){case`only`:return e.include;case`except`:return e.exclude;case`all`:return[]}}function Jd(e,t){switch(e.mode){case`only`:return{...e,include:[...t]};case`except`:return{...e,exclude:[...t]};case`all`:return e}}function Yd(e){return e.mode===`only`&&e.legacyBoth?e.exclude:[]}function Xd(e){return{...e,exclude:[],legacyBoth:!1}}function Zd(e){switch(e.mode){case`all`:return{};case`except`:return e.exclude.length>0?{exclude:[...e.exclude]}:{};case`only`:{let t=Yd(e);return{...e.include.length>0?{include:[...e.include]}:{},...t.length>0?{exclude:[...t]}:{}}}}}function Qd(e){let t=Zd(e),n=t.include??[],r=t.exclude??[];return[...e.include.filter(e=>!n.includes(e)),...e.exclude.filter(e=>!r.includes(e))]}var $d=[`onActivation`,`onDeactivation`,`onTrigger`,`onTriggerOff`],ef={onActivation:{get title(){return B.t(`helpers.notificationRuleActions.onActivationTitle`)},get hint(){return B.t(`helpers.notificationRuleActions.onActivationHint`)}},onDeactivation:{get title(){return B.t(`helpers.notificationRuleActions.onDeactivationTitle`)},get hint(){return B.t(`helpers.notificationRuleActions.onDeactivationHint`)}},onTrigger:{get title(){return B.t(`helpers.notificationRuleActions.onTriggerTitle`)},get hint(){return B.t(`helpers.notificationRuleActions.onTriggerHint`)}},onTriggerOff:{get title(){return B.t(`helpers.notificationRuleActions.onTriggerOffTitle`)},get hint(){return B.t(`helpers.notificationRuleActions.onTriggerOffHint`)}}},tf={onActivation:[],onDeactivation:[],onTrigger:[],onTriggerOff:[],buttons:[]};function nf(e){return e===void 0?tf:{onActivation:[...e.onActivation??[]],onDeactivation:[...e.onDeactivation??[]],onTrigger:[...e.onTrigger??[]],onTriggerOff:[...e.onTriggerOff??[]],buttons:[...e.buttons??[]]}}function rf(e){let t=e.buttons.filter(e=>e.id.trim()!==``&&e.label.trim()!==``&&e.sequenceId.trim()!==``),n={onActivation:e.onActivation,onDeactivation:e.onDeactivation,onTrigger:e.onTrigger,onTriggerOff:e.onTriggerOff};if(!(!$d.some(e=>n[e].length>0)&&t.length===0))return{...n.onActivation.length>0?{onActivation:[...n.onActivation]}:{},...n.onDeactivation.length>0?{onDeactivation:[...n.onDeactivation]}:{},...n.onTrigger.length>0?{onTrigger:[...n.onTrigger]}:{},...n.onTriggerOff.length>0?{onTriggerOff:[...n.onTriggerOff]}:{},...t.length>0?{buttons:t}:{}}}function af(e,t){let n=[];for(let r of $d){let i=e[r];i.length>4&&n.push({kind:`too-many`,message:B.t(`helpers.notificationRuleActions.tooMany`,{title:ef[r].title})});for(let e of i)e.kind===`sequence`&&!t.has(e.sequenceId)&&n.push({kind:`unknown-sequence`,message:B.t(`helpers.notificationRuleActions.hookUnknownSeq`,{title:ef[r].title})})}let r=new Set;for(let i of e.buttons){let e=i.id.trim();e!==``&&(r.has(e)&&n.push({kind:`duplicate-button`,message:B.t(`helpers.notificationRuleActions.dupButton`,{id:e})}),r.add(e),t.has(i.sequenceId.trim())||n.push({kind:`unknown-sequence`,message:B.t(`helpers.notificationRuleActions.buttonUnknownSeq`,{label:i.label||e})}))}return n}function of(e,t){return{id:`action-${String(e+1)}`,label:B.t(`helpers.notificationRuleActions.newButtonLabel`),sequenceId:t}}function sf(){return{kind:`do`,action:{kind:`cap`,deviceId:0,cap:``,method:``}}}function cf(e){return{kind:`sequence`,sequenceId:e}}function lf(){return{kind:`wait`,seconds:5}}var uf=[{value:`acknowledge`,get label(){return B.t(`helpers.notificationRuleActions.icon_acknowledge`)}},{value:`dismiss`,get label(){return B.t(`helpers.notificationRuleActions.icon_dismiss`)}},{value:`silence`,get label(){return B.t(`helpers.notificationRuleActions.icon_silence`)}},{value:`snooze`,get label(){return B.t(`helpers.notificationRuleActions.icon_snooze`)}},{value:`view`,get label(){return B.t(`helpers.notificationRuleActions.icon_view`)}},{value:`play`,get label(){return B.t(`helpers.notificationRuleActions.icon_play`)}},{value:`camera`,get label(){return B.t(`helpers.notificationRuleActions.icon_camera`)}},{value:`open`,get label(){return B.t(`helpers.notificationRuleActions.icon_open`)}},{value:`close`,get label(){return B.t(`helpers.notificationRuleActions.icon_close`)}},{value:`unlock`,get label(){return B.t(`helpers.notificationRuleActions.icon_unlock`)}},{value:`lock`,get label(){return B.t(`helpers.notificationRuleActions.icon_lock`)}},{value:`disarm`,get label(){return B.t(`helpers.notificationRuleActions.icon_disarm`)}},{value:`arm`,get label(){return B.t(`helpers.notificationRuleActions.icon_arm`)}},{value:`arm-home`,get label(){return B.t(`helpers.notificationRuleActions.icon_arm_home`)}},{value:`arm-away`,get label(){return B.t(`helpers.notificationRuleActions.icon_arm_away`)}},{value:`arm-night`,get label(){return B.t(`helpers.notificationRuleActions.icon_arm_night`)}},{value:`light`,get label(){return B.t(`helpers.notificationRuleActions.icon_light`)}},{value:`alert`,get label(){return B.t(`helpers.notificationRuleActions.icon_alert`)}}],df=[10,30,60],ff=[5,10,15,30,60,120,240,480];function pf(e){return e>=60&&e%60==0?B.t(`helpers.ruleFormState.snoozeHours`,{count:e/60}):B.t(`helpers.ruleFormState.snoozeMin`,{count:e})}var mf=new Set([`alarm-arm-refused`,`alarm-check-failed`,`alarm-arming`,`alarm-armed`,`alarm-pending`,`alarm-triggered`,`alarm-rearmed`,`alarm-sensor-bypass`,`alarm-disarmed`]),hf=`alarm-panel`;function gf(e,t){for(let t of e.systemEvent?.kinds??[])if(mf.has(t))return!0;for(let e of t)if(e.kind===`cap`&&e.cap===hf)return!0;return!1}function _f(e,t){let n=new Map(t.map(e=>[e.id,e])),r=[];for(let t of[`onActivation`,`onDeactivation`,`onTrigger`,`onTriggerOff`])for(let i of e[t])if(i.kind===`do`)r.push(i.action);else{let e=n.get(i.sequenceId);e!==void 0&&r.push(...e.actions)}for(let t of e.buttons){let e=n.get(t.sequenceId);e!==void 0&&r.push(...e.actions)}return r}function vf(e){let{devices:t,devicesExclude:n,classes:r,classesExclude:i,...a}=e;return{conditions:a,deviceScope:Gd(t,n),classScope:Gd(r,i)}}function yf(e){let t=Zd(e.deviceScope),n=Zd(e.classScope);return{...e.conditions,...t.include===void 0?{}:{devices:[...t.include]},...t.exclude===void 0?{}:{devicesExclude:[...t.exclude]},...n.include===void 0?{}:{classes:[...n.include]},...n.exclude===void 0?{}:{classesExclude:[...n.exclude]}}}function bf(e){return e.deviceScope.mode===`only`?e.deviceScope.include:[]}function xf(e,t,n){let r=zt(n);return e.some(e=>e.id===t&&Yt(e,n.delivery,r))}function Sf(e=`immediate`,t={}){return{name:``,enabled:!0,delivery:e,targetIds:[],targetUsers:[],targetParams:{},priority:3,mediaImage:Gt({},zt({delivery:e,conditions:t})),mediaShowTriggerZone:!1,mediaShowSubjectPath:!1,mediaGif:!1,mediaClip:!1,mediaProfile:void 0,mediaClipSpeed:void 0,mediaLinkedCameras:void 0,templateTitle:``,templateBody:``,...vf(t),schedule:void 0,systemEventDelivery:void 0,snoozeAllowGlobal:!1,groupingSec:void 0,snoozeOptions:void 0,askVerdict:void 0,actions:tf,cooldownSec:30,cooldownScope:`rule-device`,cooldownGranularity:void 0}}function Cf(e){let t={};for(let n of e.targets)n.params&&Object.keys(n.params).length>0&&(t[n.targetId]=n.params);return{name:e.name,enabled:e.enabled,delivery:e.delivery,targetIds:e.targets.map(e=>e.targetId),targetUsers:e.targetUsers??[],targetParams:t,priority:e.priority,mediaImage:Gt(e.media,zt(e)),mediaShowTriggerZone:e.media.showTriggerZone===!0,mediaShowSubjectPath:e.media.showSubjectPath===!0,mediaGif:e.media.gif===!0,mediaClip:e.media.clip===!0,mediaProfile:e.media.profile,mediaClipSpeed:e.media.clipSpeed,mediaLinkedCameras:e.media.linkedCameras,templateTitle:e.template?.title??``,templateBody:e.template?.body??``,...vf(e.conditions),schedule:e.schedule,systemEventDelivery:e.systemEventDelivery,snoozeAllowGlobal:e.snoozeAllowGlobal===!0,groupingSec:e.groupingSec,snoozeOptions:e.snoozeOptions,askVerdict:e.askVerdict,actions:nf(e.actions),cooldownSec:e.throttle.cooldownSec,cooldownScope:e.throttle.scope,cooldownGranularity:e.throttle.granularity}}function wf(e,t){let n=[];if(Mf(e)){let r=e.groupingSec;r!==void 0&&(!Number.isInteger(r)||r<5||r>60)&&n.push(`The grouping window is a whole number of seconds between 5 and 60.`);let i=t?.confirm;i?.enabled===!0&&i.expect!==void 0&&!Nf(i.expect)&&n.push(`This rule’s AI confirm expects more than one subject, but a grouped message judges one picture per subject, so it would never send. Remove the confirm expectation (viewer or API), or choose Immediate.`)}if(jt(e.conditions.audio)&&n.push(`This sound rule names neither a sound nor a level threshold, so it can never fire — every sample would count as a hit and the engine refuses it rather than notifying on silence. Pick at least one sound, or add a level.`),(!Number.isInteger(e.cooldownSec)||e.cooldownSec<0||e.cooldownSec>86400)&&n.push(`The cooldown is a whole number of seconds between 0 and ${String(qu)} (24 hours). 0 means every match is delivered.`),Df(e))for(let t of Ot({delivery:e.delivery,conditions:e.conditions,...e.systemEventDelivery===void 0?{}:{systemEventDelivery:e.systemEventDelivery},...rf(e.actions)===void 0?{}:{actions:rf(e.actions)}}))n.push(ot(t));return n}function Tf(e){let t=e.systemEventDelivery;if(t===void 0)return{};if(!Ut(e.delivery))return t.mode===`summary`?{systemEventDelivery:{mode:`instant`}}:{};if(t.mode===`summary`&&Et(t.schedule)===null){let e=wt(t.schedule);if(e!==null&&e.times.length>0)return{systemEventDelivery:{...t,schedule:Wt(e.times,t.schedule.timezone)}}}return{systemEventDelivery:t}}function Ef(e){if(!Df(e))return null;if(!yt(e.templateBody))return B.t(`helpers.ruleFormState.summaryWarnNone`,{token:`{{summaryText}}`});let t=e.templateBody;return(e.systemEventDelivery?.mode===`summary`?e.systemEventDelivery.split:void 0)===`section`&&t.trim().length>0&&!/\{\{\s*summaryText\s*\}\}/.test(t)?B.t(`helpers.ruleFormState.summaryWarnSplit`,{token:`{{summaryText}}`}):null}function Df(e){return Ut(e.delivery)&&e.systemEventDelivery?.mode===`summary`}function Of(e,t,n=new Set){return wf(e,t).length===0&&Vu(e.delivery)&&(!Ut(e.delivery)||Lf(e)>0)&&zt(e)!==`mixed`&&e.name.trim().length>0&&(e.targetIds.length>0||e.targetUsers.length>0)&&af(e.actions,n).length===0}function kf(e,t){let n=Ff(e.conditions,t);return Ut(t)&&(n.systemEvent?.kinds.length??0)===0?{...e,delivery:t,conditions:{...n,systemEvent:Td(`device-events`)}}:{...e,delivery:t,conditions:n}}function Af(e,t){return t===`immediate-grouped`?{...kf(e,`immediate`),groupingSec:e.groupingSec??20}:{...kf(e,t),groupingSec:void 0}}function jf(e){return e.delivery===`immediate`||e.delivery===`track-end`}function Mf(e){return e.groupingSec!==void 0&&nn(e)}function Nf(e){switch(e.op){case`>`:return 1>e.count;case`<=`:return 1<=e.count;case`<`:return 1<e.count;case`==`:return e.count===1;default:return 1>=e.count}}var Pf=new Set([`immediate`,`track-end`,`package-event`]);function Ff(e,t){if(e.source!==`pipeline`||Pf.has(t))return e;let{source:n,...r}=e;return r}function If(e,t){return Mt(e.conditions.systemEvent)===t?e:{...e,conditions:{...e.conditions,systemEvent:Td(t)}}}function Lf(e){return e.conditions.systemEvent?.kinds.length??0}function Rf(e,t){return e.appliesTo.includes(t)}var zf={source:`any`};function Bf(e,t){if(t==null)return!0;if(Array.isArray(t))return t.length===0;if(typeof t==`string`)return t.length===0||zf[e]===t;if(typeof t==`number`)return!Number.isFinite(t);if(typeof t==`object`){if(`ids`in t){let e=t.ids;return!Array.isArray(e)||e.length===0}if(`values`in t){let e=t.values;return!Array.isArray(e)||e.length===0}return!1}return!1}var Vf=Pt.filter(e=>e.id===`audio`);function Hf(e){if(e.length===0)return e;let t=new Set(e.map(e=>e.id)),n=Vf.filter(e=>!t.has(e.id));return n.length===0?e:[...e,...n]}function Uf(e,t,n,r=zt({delivery:t,conditions:e})){let i=n.length===0?null:new Set(n.filter(e=>e.id!==`schedule`&&Yt(e,t,r)).map(e=>e.id)),a={};for(let[t,n]of Object.entries(e))i!==null&&!i.has(t)||ud(t,e)&&(Bf(t,n)||(a[t]=n));return a}function Wf(e,t){if(e===void 0)return{};let n=Pd(e,t.systemEvent);return n===void 0?{}:{systemEvent:n}}function Gf(e){return e!==void 0&&e.windows.length>0}function Kf(e){let t={...e.clipPreRollSec===void 0?{}:{clipPreRollSec:e.clipPreRollSec},...e.clipPostRollSec===void 0?{}:{clipPostRollSec:e.clipPostRollSec}};return Object.keys(t).length>0?t:void 0}function qf(e){let t=Kf(e.media);return{...e.confirm===void 0?{}:{confirm:e.confirm},...t===void 0?{}:{media:t}}}function Jf(e,t,n=[]){let r=e.templateTitle.trim(),i=e.templateBody.trim(),a=r.length>0||i.length>0?{...r.length>0?{title:r}:{},...i.length>0?{body:i}:{}}:void 0,o=rf(e.actions),s=zt(e),c=tn(s),l=en(s),u=n.length===0?!0:n.some(t=>t.id===`schedule`&&Rf(t,e.delivery)),d=!Df(e)&&u&&Gf(e.schedule)?e.schedule:void 0,f=n.length===0?!0:n.some(t=>t.id===`devices`&&Rf(t,e.delivery)),p=n.length===0?!0:n.some(t=>t.id===`devicesExclude`&&Rf(t,e.delivery)),{devices:m,devicesExclude:h,...g}=yf(e),_=Uf(g,e.delivery,n,s);return{name:e.name.trim(),enabled:e.enabled,delivery:e.delivery,conditions:{..._,...f&&m!==void 0?{devices:m}:{},...p&&h!==void 0?{devicesExclude:h}:{},...Wf(l,e.conditions)},...d?{schedule:d}:{},...Tf(e),targets:e.targetIds.map(t=>{let n=e.targetParams[t];return n&&Object.keys(n).length>0?{targetId:t,params:n}:{targetId:t}}),...e.targetUsers.length>0?{targetUsers:[...e.targetUsers]}:{},media:c.carriesMedia?{image:e.mediaImage,...e.mediaShowTriggerZone&&e.mediaImage!==`crop`&&e.mediaImage!==`none`&&$t(_).length>0?{showTriggerZone:!0}:{},...e.mediaShowSubjectPath&&e.mediaImage!==`none`&&Bt(s)?{showSubjectPath:!0}:{},...e.mediaGif?{gif:!0}:{},...e.mediaClip?{clip:!0}:{},...e.mediaProfile===void 0?{}:{profile:e.mediaProfile},...e.mediaClipSpeed===void 0?{}:{clipSpeed:e.mediaClipSpeed},...s===`sensor`&&e.mediaImage!==`none`&&e.mediaLinkedCameras!==void 0?{linkedCameras:e.mediaLinkedCameras}:{},...(e.mediaGif||e.mediaClip)&&t?.media?.clipPreRollSec!==void 0?{clipPreRollSec:t.media.clipPreRollSec}:{},...(e.mediaGif||e.mediaClip)&&t?.media?.clipPostRollSec!==void 0?{clipPostRollSec:t.media.clipPostRollSec}:{}}:{image:`none`},throttle:{cooldownSec:e.cooldownSec,scope:e.cooldownScope,...e.cooldownGranularity===void 0?{}:{granularity:e.cooldownGranularity}},priority:e.priority,...a?{template:a}:{},...e.snoozeAllowGlobal?{snoozeAllowGlobal:!0}:{},...Mf(e)?{groupingSec:e.groupingSec}:{},...e.snoozeOptions===void 0?{}:{snoozeOptions:[...e.snoozeOptions]},...e.askVerdict!==void 0&&jf(e)?{askVerdict:e.askVerdict}:{},...t?.confirm===void 0?{}:{confirm:t.confirm},...o===void 0?{}:{actions:o}}}function Yf(e,t){let n=Jf(e,void 0,t);return[`template`,`schedule`,`targetUsers`,`snoozeOptions`,`snoozeAllowGlobal`,`groupingSec`,`actions`].filter(e=>n[e]===void 0)}var Xf=[{key:`rule`,get label(){return B.t(`helpers.ruleFormTabs.tab_rule`)},fields:[`name`,`enabled`,`delivery`,`groupingSec`,`targetIds`,`targetUsers`,`targetParams`]},{key:`devices`,get label(){return B.t(`helpers.ruleFormTabs.tab_devices`)},fields:[`deviceScope`]},{key:`conditions`,get label(){return B.t(`helpers.ruleFormTabs.tab_conditions`)},fields:[`conditions`,`classScope`,`schedule`,`systemEventDelivery`]},{key:`notification`,get label(){return B.t(`helpers.ruleFormTabs.tab_notification`)},fields:[`priority`,`mediaImage`,`mediaShowTriggerZone`,`mediaShowSubjectPath`,`mediaGif`,`mediaClip`,`mediaProfile`,`mediaClipSpeed`,`mediaLinkedCameras`,`templateTitle`,`templateBody`]},{key:`actions`,get label(){return B.t(`helpers.ruleFormTabs.tab_actions`)},fields:[`actions`]},{key:`advanced`,get label(){return B.t(`helpers.ruleFormTabs.tab_advanced`)},fields:[`snoozeAllowGlobal`,`snoozeOptions`,`askVerdict`,`cooldownSec`,`cooldownScope`,`cooldownGranularity`]}];function Zf(e,t={}){let n=zt({delivery:e,conditions:t}),r=tn(n),i=Xf.map(e=>e.key===`conditions`?{...e,label:r.label}:e);return Ht(n)?i.filter(e=>e.key!==`devices`):i}function Qf(e){if(e.audio!==void 0)return B.t(`helpers.ruleFormTabs.condSound`);if(e.occupancy!==void 0)return B.t(`helpers.ruleFormTabs.condOccupancy`)}function $f(e){let t=zt(e),n=Kt(yf(e),t);return t===`sensor`&&e.conditions.sensorTransition!==void 0&&!ud(`sensorTransition`,e.conditions)?[...n,{conditionId:`sensorTransition`,reason:gt}]:n}var ep=`rule`;function tp(e){return Xf.find(t=>t.key===e)?.key}function np(e){return e?.toLowerCase().startsWith(`it`)===!0?`it`:`en`}function rp(){let{i18n:e}=V(),t=np(e.language);return e=>mt(e,t)}D();var ip=`block text-[11px] font-medium text-foreground`,ap=`text-[10px] text-foreground-subtle mt-0.5`;function op({cameras:e,fleet:t,value:n,onChange:r,emptyMeansAll:i=!1,savedHadDevices:a=!1}){return b(wn,{devices:e,listState:t.state,fleet:t,value:n,onChange:r,emptyMeansAll:i,savedHadDevices:a})}function sp({value:e,placeholder:t,onChange:n}){let{t:r}=V(),[i,a]=C(``),s=()=>{let t=i.trim();if(t.length===0||e.includes(t)){a(``);return}n([...e,t]),a(``)},c=t=>n(e.filter(e=>e!==t));return o(`div`,{className:`mt-1 space-y-1.5`,children:[e.length>0&&b(`div`,{className:`flex flex-wrap gap-1`,children:e.map(e=>o(`span`,{className:`inline-flex items-center gap-1 rounded bg-surface-hover px-1.5 py-0.5 text-[11px] text-foreground`,children:[e,b(`button`,{type:`button`,onClick:()=>c(e),"aria-label":r(`system.notificationConditionWidgets.remove`,`remove {{v}}`,{v:e}),className:`text-foreground-subtle hover:text-danger`,children:b(Pe,{className:`h-3 w-3`})})]},e))}),b(Sn,{value:i,placeholder:t,onChange:e=>a(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),s())},onBlur:s})]})}function cp({picker:e,value:t,onChange:n}){let{t:r}=V(),i=p(()=>Tt(e),[e]),a=p(()=>new Set(t),[t]),s=t.filter(e=>!i.has(e)),c=e=>{n(a.has(e)?t.filter(t=>t!==e):[...t,e])};return o(`div`,{className:`space-y-2`,children:[s.length>0&&b(`div`,{className:`flex flex-wrap gap-1`,children:s.map(e=>o(`button`,{type:`button`,onClick:()=>n(t.filter(t=>t!==e)),className:`inline-flex items-center gap-1 rounded border border-border px-1.5 py-0.5 text-[10px] text-foreground hover:bg-surface-hover`,title:r(`system.notificationConditionWidgets.customValueClickToRemove`,`Custom value — click to remove`),children:[e,` ×`]},e))}),e.groups.map(e=>o(`div`,{children:[b(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-muted mb-1`,children:e.fallbackLabel}),b(`div`,{className:`flex flex-wrap gap-1`,children:e.options.map(e=>{let t=a.has(e.value);return b(`button`,{type:`button`,"aria-pressed":t,onClick:()=>c(e.value),className:t?`rounded border border-primary bg-primary/15 px-1.5 py-0.5 text-[10px] text-foreground`:`rounded border border-border px-1.5 py-0.5 text-[10px] text-foreground hover:bg-surface-hover`,children:e.label},e.value)})})]},e.key))]})}function lp({value:e,min:t,max:n,step:r,onChange:i}){let{t:a}=V();return o(`div`,{className:`mt-1 flex items-center gap-2`,children:[b(Sn,{type:`number`,value:e??``,min:t,max:n,step:r,className:`max-w-[8rem]`,onChange:e=>{let t=e.target.value;if(t===``){i(void 0);return}let n=Number(t);i(Number.isFinite(n)?n:void 0)}}),e!==void 0&&n!==void 0&&b(`input`,{type:`range`,min:t,max:n,step:r,value:e,onChange:e=>i(Number(e.target.value)),className:`flex-1 accent-primary`,"aria-label":a(`common.valueWord`)})]})}function up({value:e,onChange:t,options:n}){let{t:r}=V(),i=dp(n??[]),a=i.length>0?i:dd;return o(`div`,{className:`mt-1 space-y-1`,children:[b(Qn,{value:e??`enter`,options:a.map(e=>({value:e.value,label:r(`notificationRules.crossing.${e.value}`,e.label)})),onChange:e=>t(pd(e.target.value))}),b(`p`,{className:ap,children:r(`notificationRules.crossing.hint`,`Which way the subject crosses the zone.`)})]})}function dp(e){let t=[];for(let n of e){let e=n.value===``||n.value===`enter`?fd:pd(n.value);e===void 0||t.some(t=>t.value===e)||t.push({value:e,label:n.label})}return t}function fp({deviceIds:e,cameras:t,value:n,onChange:r}){let{options:i,loading:a}=Du(e,t);return b(ju,{options:i,value:n,onChange:r,loading:a,noFreeText:!0,emptyHint:e.length===0?`Select cameras first — a rule can only use zones those cameras actually have.`:`The selected cameras have no zones. Draw one in the camera’s zone editor first.`,placeholder:``})}function pp({deviceIds:e,value:t,onChange:n}){let{t:r}=V(),{options:i,loading:a}=Ou(e);return b(ju,{options:i,value:t,onChange:n,loading:a,emptyHint:e.length===0?`Select cameras above to pick their event kinds — or type a token.`:`No event kinds reported for the selected cameras — type a token.`,placeholder:r(`system.notificationConditionWidgets.eventToken`,`Event token…`)})}var mp=[{value:`became-occupied`,labelKey:`system.notificationConditionWidgets.opBecameOccupied`},{value:`became-free`,labelKey:`system.notificationConditionWidgets.opBecameFree`},{value:`>=`,labelKey:`system.notificationConditionWidgets.opCountAtLeast`},{value:`<=`,labelKey:`system.notificationConditionWidgets.opCountAtMost`}];function hp(e,t){let n=e.map(e=>({value:e.value,label:e.label}));return t===void 0||t===``||n.some(e=>e.value===t)?n:[...n,{value:t,label:B.t(`system.notificationConditionWidgets.subTypeNeverCountsAlways`,`{{stored}} — sub-type, never counts (always 0)`,{stored:t})}]}function gp({deviceIds:e,cameras:t,classOptions:n,value:r,onChange:i}){let{t:a}=V(),{options:s,loading:c}=Du(e,t),l=r??Vt,u=e=>i({...l,...e}),d=l.op===`became-occupied`||l.op===`became-free`,f=hp(n,l.className);return o(`div`,{className:`mt-1 space-y-1.5`,children:[o(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[b(`div`,{className:`min-w-[10rem]`,children:b(Qn,{value:l.zoneId??``,options:[{value:``,label:c?a(`system.notificationConditionWidgets.loadingZones`,`Loading zones…`):a(`system.notificationConditionWidgets.wholeFrame`,`— whole frame —`)},...s.map(e=>({value:e.value,label:e.label}))],onChange:e=>u({zoneId:e.target.value===``?void 0:e.target.value})})}),b(`div`,{className:`min-w-[9rem]`,children:b(Qn,{value:l.className??``,options:[{value:``,label:a(`system.notificationConditionWidgets.anyClass`,`— any class —`)},...f],onChange:e=>u({className:e.target.value===``?void 0:e.target.value})})}),b(`div`,{className:`min-w-[9rem]`,children:b(Qn,{value:l.op,options:mp.map(e=>({value:e.value,label:a(e.labelKey)})),onChange:e=>{let t=mp.find(t=>t.value===e.target.value);t&&u({op:t.value})}})})]}),o(`div`,{className:`flex flex-wrap items-center gap-3 text-xs text-foreground-subtle`,children:[o(`label`,{className:`flex items-center gap-1`,children:[d?a(`system.notificationConditionWidgets.threshold`,`Threshold`):a(`system.notificationConditionWidgets.count`,`Count`),b(Sn,{type:`number`,min:0,className:`w-16`,value:String(l.count),onChange:e=>u({count:Math.max(0,Number(e.target.value)||0)})})]}),o(`label`,{className:`flex items-center gap-1`,children:[a(`system.notificationConditionWidgets.holdFor`,`Hold for`),b(Sn,{type:`number`,min:0,max:3600,className:`w-16`,value:String(l.sustainSeconds),onChange:e=>u({sustainSeconds:Math.min(3600,Math.max(0,Number(e.target.value)||0))})}),`s`]}),r===void 0?null:b(`button`,{type:`button`,onClick:()=>i(void 0),className:`underline hover:text-foreground`,children:a(`system.notificationConditionWidgets.clear`,`Clear`)})]}),e.length===0&&b(`p`,{className:`text-[11px] text-warning`,children:a(`system.notificationConditionWidgets.noCameraPickedOnThe`,`No camera picked on the Devices tab: this watches EVERY camera's occupancy, and no zone can be offered until you choose one — a zone id belongs to a camera.`)}),b(`p`,{className:`text-[11px] text-foreground-subtle`,children:a(`system.notificationConditionWidgets.countsConfirmedTrackedObjectsFrom`,`Counts confirmed tracked objects from zone analytics. The change must hold for the sustain window before it fires; with no snapshot for the camera or zone the rule never fires.`)})]})}var _p=[{value:`label`,labelKey:`system.notificationConditionWidgets.audioModeLabel`,Icon:et},{value:`level`,labelKey:`system.notificationConditionWidgets.audioModeLevel`,Icon:Xe}];function vp({taxonomy:e,value:t,onChange:n}){let{t:r}=V(),i=Ft(t),a=e=>n(Nt(t,e)),{choices:s,unknownLabels:c}=rn(e,i.labels),l=ut(t)??`label`;return o(`div`,{className:`mt-1 space-y-2`,children:[o(`div`,{className:`flex flex-wrap items-center gap-1`,children:[_p.map(e=>b(`button`,{type:`button`,"aria-pressed":l===e.value,onClick:()=>a({mode:e.value}),className:`rounded border px-2 py-0.5 text-[11px] ${l===e.value?`border-primary bg-primary/15 text-foreground`:`border-border text-foreground-subtle hover:bg-surface-hover`}`,children:o(`span`,{className:`inline-flex items-center gap-1`,children:[b(e.Icon,{className:`h-3 w-3`}),r(e.labelKey)]})},e.value)),t===void 0?null:b(`button`,{type:`button`,onClick:()=>n(void 0),className:`ml-1 text-xs text-foreground-subtle underline hover:text-foreground`,children:r(`system.notificationConditionWidgets.clear`,`Clear`)})]}),l===`label`?o(P,{children:[b(`div`,{className:`flex flex-wrap gap-1`,children:s.map(e=>{let t=vt(i.labels,e.value),n=e.unknown?`border-dashed border-warning text-warning`:t?`border-primary bg-primary/15 text-foreground`:`border-border text-foreground hover:bg-surface-hover`;return b(`button`,{type:`button`,"aria-pressed":t,title:e.unknown?r(`system.notificationConditionWidgets.storedByTheRuleNot`,`Stored by the rule — not offered by this hub`):void 0,onClick:()=>a({labels:It(i.labels,e.value)}),className:`rounded border px-1.5 py-0.5 text-[10px] ${n}`,children:o(`span`,{className:`inline-flex items-center gap-1`,children:[b(_r,{iconId:e.iconId,size:12}),e.label]})},e.value)})}),c.length>0&&o(`p`,{className:`text-[10px] text-warning`,children:[r(`system.notificationConditionWidgets.keptFromTheRuleUnknown`,`Kept from the rule, unknown to this hub:`),` `,c.join(`, `)]}),o(`div`,{className:`flex flex-wrap items-center gap-3 text-xs text-foreground-subtle`,children:[o(`label`,{className:`flex items-center gap-1`,children:[r(`system.notificationConditionWidgets.confirmAfter`,`Confirm after`),b(Sn,{type:`number`,min:1,max:20,step:1,className:`w-16`,value:String(i.confirmHits??2),onChange:e=>a({confirmHits:Number(e.target.value)})}),r(`system.notificationConditionWidgets.frames`)]}),o(`label`,{className:`flex items-center gap-1`,children:[r(`system.notificationConditionWidgets.within`),b(Sn,{type:`number`,min:1,max:60,step:1,className:`w-16`,value:String(i.confirmWindowSec??5),onChange:e=>a({confirmWindowSec:Number(e.target.value)})}),`s`]})]}),b(`p`,{className:`text-[11px] text-foreground-subtle`,children:r(`system.notificationConditionWidgets.audioConfirmHint`,{hits:2,window:5})})]}):o(P,{children:[b(`div`,{className:`flex flex-wrap items-center gap-3 text-xs text-foreground-subtle`,children:o(`label`,{className:`flex items-center gap-1`,children:[r(`system.notificationConditionWidgets.louderThan`,`Louder than`),b(Sn,{type:`number`,min:ht,max:0,step:3,className:`w-20`,value:String(i.dbThreshold??bt),onChange:e=>a({dbThreshold:Number(e.target.value)})}),`dBFS`]})}),o(`div`,{className:`flex flex-wrap items-center gap-3 text-xs text-foreground-subtle`,children:[o(`label`,{className:`flex items-center gap-1`,children:[r(`system.notificationConditionWidgets.hits`,`Hits`),b(Sn,{type:`number`,min:1,max:100,step:5,className:`w-16`,value:String(i.hitPercent),onChange:e=>a({hitPercent:Number(e.target.value)})}),r(`system.notificationConditionWidgets.hitsPercentDefault`,{value:Ct.hitPercent})]}),o(`label`,{className:`flex items-center gap-1`,children:[r(`system.notificationConditionWidgets.over`),b(Sn,{type:`number`,min:1,max:300,step:5,className:`w-16`,value:String(i.samplingSeconds),onChange:e=>a({samplingSeconds:Number(e.target.value)})}),r(`system.notificationConditionWidgets.secondsDefault`,{value:Ct.samplingSeconds})]})]}),b(`p`,{className:`text-[11px] text-foreground-subtle`,children:r(`system.notificationConditionWidgets.dbfsHint`,{min:ht})})]}),jt(t)?b(`p`,{className:`text-[11px] text-warning`,children:r(`system.notificationConditionWidgets.withNeitherASoundNor`,`With neither a sound nor a level threshold this can never match — every sample would be a hit, so the engine refuses it rather than notifying on silence.`)}):null]})}function yp({value:e,onChange:t}){let{t:n}=V(),r=e?.values??[],i=e?.maxDistance??1,a=e=>t(e.length>0?{values:e,maxDistance:i}:void 0),s=e=>t(r.length>0?{values:r,maxDistance:e}:void 0),c=Au().filter(e=>!r.includes(e));return o(`div`,{className:`mt-1 space-y-1.5`,children:[b(sp,{value:r,placeholder:n(`system.notificationConditionWidgets.plateText`,`Plate text…`),onChange:a}),c.length>0&&o(`div`,{className:`flex flex-wrap items-center gap-1`,children:[b(`span`,{className:`text-[10px] text-foreground-subtle`,children:n(`system.notificationConditionWidgets.seen`,`Seen:`)}),c.slice(0,12).map(e=>b(`button`,{type:`button`,onClick:()=>a([...r,e]),className:`rounded border border-border px-1.5 py-0.5 text-[10px] text-foreground-subtle hover:bg-surface-hover hover:text-foreground`,children:e},e))]}),o(`label`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[n(`system.notificationConditionWidgets.maxDistance`,`Max distance`),b(Sn,{type:`number`,min:0,max:3,step:1,value:i,className:`max-w-[5rem]`,onChange:e=>{let t=Number(e.target.value);s(Number.isFinite(t)?Math.max(0,Math.min(3,t)):1)}})]})]})}function bp({gateable:e,value:t,onChange:n}){let{t:r}=V(),i=rp(),a=e.find(e=>e.id===t?.deviceId),s=new Set(t?.states??[]),c=e=>{let t=Number(e);if(!Number.isFinite(t)||t===0)return n(void 0);n({deviceId:t,states:[]})},l=e=>{if(t===void 0)return;let r=new Set(s);r.has(e)?r.delete(e):r.add(e),n(r.size===0?void 0:{deviceId:t.deviceId,states:[...r]})};return o(`div`,{className:`mt-1 space-y-2`,children:[b(Qn,{value:t===void 0?``:String(t.deviceId),options:[{value:``,label:r(`system.notificationConditionWidgets.noDeviceGate`,`— no device gate —`)},...e.map(e=>({value:String(e.id),label:e.name}))],onChange:e=>c(e.target.value)}),a!==void 0&&b(`div`,{className:`flex flex-wrap gap-1.5`,children:a.states.map(e=>b(`button`,{type:`button`,onClick:()=>l(e),className:s.has(e)?`rounded-md border border-primary bg-primary/10 px-2 py-0.5 text-[11px] text-primary`:`rounded-md border border-border px-2 py-0.5 text-[11px] text-foreground-subtle`,children:i(e)},e))}),a!==void 0&&a.states.length===0&&b(`p`,{className:`text-[10px] text-foreground-subtle mt-0.5`,children:r(`system.notificationConditionWidgets.thisDeviceReportsNoState`,`This device reports no state the gate can read, so it cannot arm a rule.`)}),t!==void 0&&b(`p`,{className:`text-[10px] text-foreground-subtle mt-0.5`,children:r(`system.notificationConditionWidgets.theRuleIsSilentWhile`,`The rule is silent while the device is in any other state — including when its state cannot be read at all.`)})]})}function xp(e,t){let n=t(e.verdict);return e.latched?`${n} · ${t(`latched`)}`:n}function Sp({scenes:e,value:t,onChange:n}){let{t:r}=V(),i=rp(),a=e.find(e=>e.sceneId===t?.sceneId),s=r=>{if(r===``)return n(void 0);let i=e.find(e=>e.sceneId===r);if(i===void 0)return n(void 0);n({sceneId:r,deviceId:i.deviceId,requiredState:t?.requiredState??`diverged`,...t?.latched===void 0?{}:{latched:t.latched}})},c=e=>{t!==void 0&&n({...t,requiredState:e===`matched`?`matched`:`diverged`})},l=e=>{if(t!==void 0){if(e===``){let{latched:e,...r}=t;return n(r)}n({...t,latched:e===`latched`})}};return e.length===0?b(`p`,{className:ap,children:r(`notificationRules.scene.none`,`No scenes yet — create one on the Scenes page.`)}):o(`div`,{className:`mt-1 space-y-2`,children:[b(Qn,{value:t?.sceneId??``,options:[{value:``,label:r(`notificationRules.scene.noGate`,`— no scene gate —`)},...e.map(e=>({value:e.sceneId,label:`${e.cameraName} · ${e.label} — ${xp(e,i)}`}))],onChange:e=>s(e.target.value)}),t!==void 0&&o(`div`,{className:`flex flex-wrap items-center gap-2`,children:[o(`label`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[r(`notificationRules.scene.onlyWhile`,`Only while it is`),b(Qn,{value:t.requiredState,options:[{value:`diverged`,label:i(`diverged`)},{value:`matched`,label:i(`matched`)}],onChange:e=>c(e.target.value)})]}),o(`label`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[r(`notificationRules.scene.read`,`Read`),b(Qn,{value:t.latched===void 0?``:t.latched?`latched`:`live`,options:[{value:``,label:a===void 0?r(`notificationRules.scene.readOwn`,`The scene's own setting`):`${r(`notificationRules.scene.readOwn`,`The scene's own setting`)} (${i(a.emit)})`},{value:`latched`,label:i(`latched`)},{value:`live`,label:i(`live`)}],onChange:e=>l(e.target.value)})]})]}),a!==void 0&&o(`p`,{className:`text-[10px] text-foreground-subtle mt-0.5`,children:[r(`notificationRules.scene.rightNow`,`Right now:`),` `,xp(a,i)]}),t!==void 0&&a===void 0&&b(`p`,{className:`text-[10px] text-foreground-subtle mt-0.5`,children:r(`notificationRules.scene.missing`,`This scene no longer exists — pick another or remove the gate.`)})]})}var Cp={days:[0,1,2,3,4,5,6],minute:480},wp=[{value:1,get label(){return B.t(`helpers.notificationSystemEventDelivery.wd_mon`)}},{value:2,get label(){return B.t(`helpers.notificationSystemEventDelivery.wd_tue`)}},{value:3,get label(){return B.t(`helpers.notificationSystemEventDelivery.wd_wed`)}},{value:4,get label(){return B.t(`helpers.notificationSystemEventDelivery.wd_thu`)}},{value:5,get label(){return B.t(`helpers.notificationSystemEventDelivery.wd_fri`)}},{value:6,get label(){return B.t(`helpers.notificationSystemEventDelivery.wd_sat`)}},{value:0,get label(){return B.t(`helpers.notificationSystemEventDelivery.wd_sun`)}}];function Tp(e){let t=Math.floor(e/60),n=e%60;return`${String(t).padStart(2,`0`)}:${String(n).padStart(2,`0`)}`}function Ep(e){let[t,n]=e.split(`:`),r=Number(t)*60+Number(n);return Number.isFinite(r)?Math.max(0,Math.min(1439,r)):0}function Dp(e){if(typeof e!=`object`||!e||!(`data`in e))return;let t=e.data;if(!(typeof t!=`object`||!t||!(`code`in t)))return typeof t.code==`string`?t.code:void 0}function Op(e){let t=Object.entries(e).map(([e,t])=>`${e} ${String(t)}`);return t.length>0?B.t(`helpers.notificationSystemEventDelivery.dropped`,{parts:t.join(`, `)}):null}function kp(e,t,n,r=`rule`){if(e===`error`)return Dp(n)===`NOT_FOUND`?{lines:[`This hub does not serve summary rules yet — update @camstack/server first. A rule saved now would be stored without its summary, and stay instant.`]}:{lines:[`The preview could not be read: ${n instanceof Error?n.message:String(n)}`]};if(e!==`success`||t===void 0)return null;let i=[];if(r===`section`&&t.split===void 0&&i.push(`This hub does not send per-category summaries yet — update @camstack/server first. Until then it sends one message.`),t.empty)i.push(`Nothing to report right now — no notification would be sent.`);else if(t.split===`section`&&t.rows!==void 0){let e=t.rows.length;i.push(`${String(e)} notification${e===1?``:`s`} would be sent now, one per category:`);for(let e of t.rows)i.push(`${e.title}\n${e.text}`)}else i.push(`${String(t.count)} item(s) would be sent now:\n${t.text}`);let a=Op(t.dropped);return a!==null&&i.push(a),t.excludedGroups.includes(`backups-exports`)&&i.push(`Backups and exports are completed jobs, not a state — they are not in a summary.`),{lines:i}}function Ap(e,t){return{...e,schedule:t}}function jp(e,t){let{split:n,...r}=e;return t===`section`?{...r,split:t}:r}function Mp(e){return Tp(e)}function Np(e){return Ep(e)}function Pp(){return{days:[1,2,3,4,5],startMinute:540,endMinute:1080}}function Fp(e){return{days:[...Cp.days],minute:e}}var Ip=`Always active — add a window to restrict when the rule fires.`;function Lp({value:e,onChange:t,mode:n=`windows`,defaultMinute:r=Cp.minute,emptyHint:i}){return n===`times`?b(zp,{value:e,onChange:t,defaultMinute:r}):b(Rp,{value:e,onChange:t,emptyHint:i??Ip})}function Rp({value:e,onChange:t,emptyHint:n}){let{t:r}=V(),i=e?.windows??[],a=e?.invert??!1,s=(n,r)=>{if(n.length===0){t(void 0);return}t({windows:n,...r?{invert:!0}:{},...e?.timezone?{timezone:e.timezone}:{}})},c=()=>s([...i,Pp()],a),l=e=>s(i.filter((t,n)=>n!==e),a),u=(e,t)=>s(i.map((n,r)=>r===e?t:n),a);return o(`div`,{className:`mt-1 space-y-2`,"data-testid":`schedule-field-windows`,children:[i.length===0?b(`p`,{className:ap,children:n}):i.map((e,t)=>b(Bp,{window:e,onChange:e=>u(t,e),onRemove:()=>l(t)},t)),o(`div`,{className:`flex items-center gap-3`,children:[o(`button`,{type:`button`,onClick:c,className:`flex items-center gap-1 rounded-md bg-surface-hover px-2 py-1 text-[11px] text-foreground-subtle hover:text-foreground`,children:[b(ne,{className:`h-3 w-3`}),` `,r(`system.notificationScheduleField.addWindow`)]}),i.length>0&&o(`label`,{className:`flex items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[b(`input`,{type:`checkbox`,checked:a,onChange:e=>s([...i],e.target.checked),className:`accent-primary`}),r(`system.notificationScheduleField.activeOutsideTheWindows`,`Active outside the windows`)]})]})]})}function zp({value:e,onChange:t,defaultMinute:n}){let{t:r}=V(),i=e?.timezone,a=e===void 0?{times:[],approximated:!1}:wt(e);if(a===null)return o(`div`,{className:`mt-1 space-y-2`,"data-testid":`schedule-field-times-fallback`,children:[b(`p`,{className:ap,children:r(`system.notificationScheduleField.invertedScheduleShownAsBands`,`Inverted schedule — shown as bands. Clear the invert flag (or the windows) to author punctual times.`)}),b(Rp,{value:e,onChange:t,emptyHint:Ip})]});let s=a.times,c=e=>{if(e.length===0){t(void 0);return}t(Wt(e,i))};return o(`div`,{className:`mt-1 space-y-2`,"data-testid":`schedule-field-times`,children:[a.approximated&&b(`p`,{className:`text-[10px] text-foreground-subtle mt-0.5`,"data-testid":`schedule-field-times-approximated`,children:r(`system.notificationScheduleField.shownAsSendAtTimes`,`Shown as send-at times from each window's end (when the summary fires). Edit or save to store them as punctual one-minute windows.`)}),s.length===0?b(`p`,{className:ap,children:r(`system.notificationScheduleField.noTimesYetAddOne`,`No times yet — add one to send on those days at that clock time.`)}):s.map((e,t)=>b(Vp,{time:e,index:t,onChange:e=>c(s.map((n,r)=>r===t?e:n)),onRemove:s.length>1?()=>c(s.filter((e,n)=>n!==t)):void 0},t)),o(`button`,{type:`button`,onClick:()=>c([...s,Fp(n)]),className:`flex items-center gap-1 rounded-md bg-surface-hover px-2 py-1 text-[11px] text-foreground-subtle hover:text-foreground`,"data-testid":`schedule-field-add-time`,children:[b(ne,{className:`h-3 w-3`}),` `,r(`system.notificationScheduleField.addTime`)]})]})}function Bp({window:e,onChange:t,onRemove:n}){let{t:r}=V();return o(`div`,{className:`space-y-1.5 rounded-md border border-border p-2`,children:[o(`div`,{className:`flex items-center gap-2 text-xs`,children:[b(`input`,{type:`time`,value:Mp(e.startMinute),onChange:n=>t({...e,startMinute:Np(n.target.value)}),className:`rounded-md border border-border bg-background px-1 py-0.5`}),b(`span`,{className:`text-foreground-subtle`,children:`→`}),b(`input`,{type:`time`,value:Mp(e.endMinute),onChange:n=>t({...e,endMinute:Np(n.target.value)}),className:`rounded-md border border-border bg-background px-1 py-0.5`}),b(`span`,{className:`flex-1`}),b(`button`,{type:`button`,onClick:n,"aria-label":r(`system.notificationScheduleField.removeWindow`,`Remove window`),className:`text-foreground-subtle hover:text-danger`,children:b(ae,{className:`h-3.5 w-3.5`})})]}),b(Hp,{days:e.days,onToggle:n=>{let r=e.days.includes(n)?e.days.filter(e=>e!==n):[...e.days,n];r.length!==0&&t({...e,days:r})}})]})}function Vp({time:e,index:t,onChange:n,onRemove:r}){let{t:i}=V();return o(`div`,{className:`space-y-1.5 rounded-md border border-border p-2`,children:[o(`div`,{className:`flex items-center gap-2 text-xs`,children:[b(`span`,{className:`text-foreground-subtle`,children:i(`system.notificationScheduleField.at`,`At`)}),b(`input`,{type:`time`,value:Tp(e.minute),onChange:t=>n({...e,minute:Ep(t.target.value)}),className:`rounded-md border border-border bg-background px-1 py-0.5`,"data-testid":`schedule-field-time-${String(t)}`}),b(`span`,{className:`flex-1`}),r!==void 0&&b(`button`,{type:`button`,onClick:r,"aria-label":i(`system.notificationScheduleField.removeTime`,`Remove time`),className:`text-foreground-subtle hover:text-danger`,children:b(ae,{className:`h-3.5 w-3.5`})})]}),b(Hp,{days:e.days,onToggle:t=>{let r=e.days.includes(t)?e.days.filter(e=>e!==t):[...e.days,t];r.length!==0&&n({...e,days:r})}})]})}function Hp({days:e,onToggle:t}){return b(`div`,{className:`flex flex-wrap gap-1`,children:wp.map(n=>b(`button`,{type:`button`,onClick:()=>t(n.value),className:`rounded px-1.5 py-0.5 text-[10px] ${e.includes(n.value)?`bg-primary text-primary-foreground`:`bg-surface-hover text-foreground-subtle`}`,children:n.label},n.value))})}function Up(e){return e>=8}D();function Wp(e){if(typeof e!=`object`||!e)return;let t=Reflect.get(e,`windows`);if(!(!Array.isArray(t)||t.length===0))return e}function Gp(e){return e.type===`multiselect`}function Kp(e){let t=e.suggestions;return t===void 0||t.length===0?[]:t.map(e=>({value:e,label:e}))}function qp(e){return e.map(e=>({value:e.value,label:e.label,...e.description===void 0?{}:{description:e.description},...e.iconId===void 0?{}:{iconId:e.iconId}}))}function Jp(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function Yp({field:e,values:t,onChange:n,onChangeMany:r,disabled:i,translationFn:a,onTestField:s,externalProbe:c,allFields:l,onAction:u}){let{t:d}=V();if(e.type===`tags`){if(!Gr(e,t,l))return null;let r=e.creatable!==!1;return b(Jr,{mode:`multi`,options:Kp(e),value:Jp(t[e.key]),onChange:t=>n(e.key,t),disabled:i===!0||e.disabled===!0,creatable:r,...e.createLabel===void 0?{}:{createLabel:e.createLabel},...e.maxTags===void 0?{}:{maxItems:e.maxTags},label:Zp(e.label,a),description:e.description===void 0?void 0:Zp(e.description,a),placeholder:e.placeholder??d(`formBuilder.formBuilder.searchOrAdd`,`Search or add…`),testId:`config-tags-${e.key}`})}if(e.type===`schedule`){if(!Gr(e,t,l))return null;let r=Zp(e.label,a),i=e.description===void 0?void 0:Zp(e.description,a),s=e.mode===`times`?`times`:`windows`;return o(`div`,{className:`space-y-1`,"data-testid":`config-schedule-${e.key}`,children:[r!==void 0&&b(`label`,{className:`block text-[11px] font-medium text-foreground-subtle`,children:r}),i!==void 0&&b(`p`,{className:`text-[10px] text-foreground-subtle`,children:i}),b(Lp,{mode:s,value:Wp(t[e.key]),onChange:t=>n(e.key,t)})]})}return Gp(e)&&(Up(e.options.length)||e.creatable===!0)?Gr(e,t,l)?b(Jr,{mode:`multi`,options:qp(e.options),value:Jp(t[e.key]),onChange:t=>n(e.key,t),disabled:i===!0||e.disabled===!0,creatable:e.creatable===!0,...e.createLabel===void 0?{}:{createLabel:e.createLabel},...e.maxItems===void 0?{}:{maxItems:e.maxItems},label:Zp(e.label,a),description:e.description===void 0?void 0:Zp(e.description,a),placeholder:e.placeholder??d(`formBuilder.formBuilder.searchToAdd`,`Search to add…`),testId:`config-multiselect-${e.key}`,listboxId:`msel-${e.key}`}):null:b(Er,{field:e,values:t,onChange:n,onChangeMany:r,disabled:i,translationFn:a,onTestField:s,externalProbe:c,allFields:l,onAction:u})}function Xp(e){return/^[a-zA-Z0-9_]+(\.[a-zA-Z0-9_]+)+$/.test(e)}function Zp(e,t){if(e!==void 0)return t&&Xp(e)?t(e):e}function Qp({section:e,values:t,onChange:n,onChangeMany:r,disabled:i,translationFn:a,onTestField:s,probeResults:c,onAction:l}){let[u,d]=C(e.defaultCollapsed??!1),f=e.style===`accordion`;if(e.fields.reduce((n,r)=>n+ +!!Gr(r,t,e.fields),0)===0)return null;let p=e.fields,m=e.columns??2,h=m===1?`grid-cols-1`:m===3?`grid-cols-1 @[480px]:grid-cols-2 @[880px]:grid-cols-3`:m===4?`grid-cols-1 @[480px]:grid-cols-2 @[1140px]:grid-cols-4`:`grid-cols-1 @[480px]:grid-cols-2`,g=e.fields.length===1&&e.fields[0]?.type===`widget`?e.fields[0]:void 0,_=g!==void 0||!e.title&&!e.description;return o(`div`,{className:`@container rounded-lg border border-border bg-surface p-3`,style:{containerType:`inline-size`},"data-settings-section":e.id,children:[!_&&o(`div`,{className:[`flex items-center justify-between mb-2`,f?`cursor-pointer`:``].join(` `),onClick:f?()=>d(e=>!e):void 0,children:[o(`div`,{children:[e.title&&b(`h3`,{className:`text-[11px] font-semibold text-foreground-subtle uppercase tracking-wider`,children:Zp(e.title,a)}),e.description&&b(`p`,{className:`text-[10px] text-foreground-subtle mt-0.5`,children:Zp(e.description,a)})]}),f&&b(`span`,{className:`text-foreground-subtle text-xs ml-2`,children:u?`▸`:`▾`})]}),!(u&&!_)&&(g===void 0?b(P,{children:b(`div`,{className:`grid ${h} gap-x-3 gap-y-2.5`,children:p.map(o=>b(Yp,{field:o,values:t,onChange:n,onChangeMany:r,disabled:i,translationFn:a,onTestField:s,externalProbe:c?.[o.key],allFields:e.fields,onAction:l},o.key))})}):b(Er,{field:g,values:t,onChange:n,onChangeMany:r,disabled:i,translationFn:a,onTestField:s,externalProbe:c?.[g.key],allFields:e.fields,onAction:l},g.key))]})}function $p({schema:e,values:t,onChange:n,disabled:r,translationFn:i,onTestField:a,probeResults:o,onClearProbe:s,onAction:c,visibilityContext:l}){let u=l?{...l,...t}:t,d=(e,r)=>{n({...t,[e]:r}),s?.(e)},f=e=>{n({...t,...e});for(let t of Object.keys(e))s?.(t)};return b(`div`,{className:`space-y-4`,children:e.sections.map((e,t)=>b(Qp,{section:e,values:u,onChange:d,onChangeMany:f,disabled:r,translationFn:i,onTestField:a,probeResults:o,onAction:c},`${e.id}-${t}`))})}function em({pendingCount:e,onSave:t,onDiscard:n,saving:r=!1,saveLabel:i=`Save`,discardLabel:a=`Discard`}){let{t:s}=V();return e<=0?null:o(`div`,{className:`sticky bottom-0 -mb-3 flex items-center justify-between gap-3 rounded-lg border border-primary/40 bg-primary/5 px-3 py-2 shadow-sm z-10`,children:[b(`span`,{className:`text-xs text-foreground`,children:s(`formBuilder.saveBar.unsavedChanges`,{count:e})}),o(`div`,{className:`flex items-center gap-2`,children:[b(`button`,{type:`button`,onClick:n,disabled:r,className:`inline-flex items-center rounded-md border border-border px-2.5 py-1 text-xs text-foreground-subtle hover:bg-surface-hover disabled:opacity-50`,children:a}),b(`button`,{type:`button`,onClick:t,disabled:r,className:`inline-flex items-center rounded-md bg-primary px-3 py-1 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,children:r?s(`formBuilder.formSaveBar.saving`,`Saving…`):i})]})]})}function tm({tabs:e,activeId:t,onChange:n,countByTab:r,pendingByTab:i}){return e.length===0?null:b(`div`,{className:`flex flex-wrap items-center gap-1 border-b border-border shrink-0`,children:e.map(e=>{let a=e.id===t,s=r?.get(e.id)??0,c=i?.get(e.id)??0;return o(`button`,{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,s>0&&o(`span`,{className:`ml-1.5 text-[10px] opacity-60`,children:[`(`,s,`)`]}),c>0&&b(`span`,{className:`ml-1.5 inline-flex h-1.5 w-1.5 rounded-full bg-primary`})]},e.id)})})}D();function nm({schema:e,values:t,pendingKeys:n,onChange:r,onAction:i,onSave:a,onDiscard:s,disabled:c,activeSubTab:l,onSubTabChange:u,flattenTabs:d=!1,visibilityContext:m,hideSaveBar:h=!1}){let g=e.tabs??[],_=p(()=>{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]),v=new Set(g.map(e=>e.id)),y=[...g,...[..._.keys()].filter(e=>!v.has(e)).map(e=>({id:e,label:e,icon:`wrench`,order:100}))],x=y[0]?.id??`general`,[S,w]=C(x),T=u!==void 0,E=new Set(y.map(e=>e.id)),D=f(new Set);for(let e of E)D.current.add(e);let O=D.current,k=(e=>e&&(E.has(e)||O.has(e))?e:x)(T?l:S),A=e=>{T?u(e):w(e)},j=_.get(k)??[],M={sections:j.length<=1?j.length===1?[{...j[0],title:``}]:j:j.every(e=>!e.title)?[{...j[0],title:``,fields:j.flatMap(e=>e.fields)}]:j},N=h?null:b(em,{pendingCount:n.length,onSave:()=>a(n),onDiscard:()=>s(n),saving:c});if(d||y.length<=1)return o(`div`,{className:`flex flex-col gap-3`,children:[b($p,{schema:e,values:t,onChange:r,onAction:i,disabled:c,visibilityContext:m}),N]});let P=new Map,F=new Map;for(let[e,t]of _){P.set(e,t.length);let r=new Set,i=e=>{for(let t of e)if(`key`in t&&typeof t.key==`string`&&r.add(t.key),t.type===`group`)i(t.fields);else if(t.type===`sub-tabs`)for(let e of t.tabs)i(e.fields)};for(let e of t)i(e.fields);let a=n.filter(e=>r.has(e)).length;a>0&&F.set(e,a)}return o(`div`,{className:`flex flex-col gap-3`,children:[b(tm,{tabs:y.map(e=>({id:e.id,label:e.label})),activeId:k,onChange:A,countByTab:P,pendingByTab:F}),b(oi,{tabKey:k,children:b($p,{schema:M,values:t,onChange:r,onAction:i,disabled:c,visibilityContext:m})}),N]})}var rm=`device-export`,im=`export`,am=`Export`;function om(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(om):e.type===`sub-tabs`?e.tabs.some(e=>e.fields.some(om)):e.writerCapName===rm}function sm(e){return e.tab===`export`?!0:e.fields.some(om)}var cm=`host/extensions-panel`;function lm(e){return e.type===`widget`?e.widgetId===cm:e.type===`group`?e.fields.some(lm):e.type===`sub-tabs`?e.tabs.some(e=>e.fields.some(lm)):!1}function um(e){return e.fields.some(lm)}function dm(e,t){return!t&&e!==void 0&&Zt.includes(e)}function fm(e){return e.location!==`top-tab`&&e.location!==`hero`&&!sm(e)&&!um(e)}function pm(e,t,n,r){return!r||dm(t,n)?!0:(e??[]).some(fm)}function mm(e,t){for(let n of e){if(n.type===`group`){mm(n.fields,t);continue}if(n.type===`sub-tabs`){for(let e of n.tabs)mm(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 hm(e){let t={};for(let n of e)mm(n.fields,t);return t}D();function gm(e,t){return t&&t===`admin`?e:!0}function _m(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?sm(e)&&sm(t)?e.id.localeCompare(t.id):(e.order??0)-(t.order??0):n.localeCompare(r)})};return e.tabs?{...t,tabs:e.tabs}:t}function vm(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 ym(e){return e.key}function bm(e){if(!vm(e))return e.value}function xm(e){return vm(e)?null:e}function Sm(e,t){for(let n of e)if(t(n),n.type===`group`)Sm(n.fields,t);else if(n.type===`sub-tabs`)for(let e of n.tabs)Sm(e.fields,t)}function Cm(e){if(!e)return{};let t={};for(let n of e.sections)Sm(n.fields,e=>{let n=ym(e);n!==null&&(t[n]=bm(e))});return t}function wm(e,t){if(!e)return null;let n=null;for(let r of e.sections)if(Sm(r.fields,e=>{if(n!==null||ym(e)!==t)return;let r=xm(e);r&&r.writerCapName&&r.writerAddonId&&(n={capName:r.writerCapName,addonId:r.writerAddonId})}),n!==null)break;return n}function Tm(e){return{...e,fields:e.fields.map(Em)}}function Em(e){return e.type===`separator`||e.type===`info`||e.type===`button`||e.type===`object-array`?e:{...e,readonlyField:!0}}function Dm(e,t){return e&&{...e,sections:e.sections.map(e=>({...e,fields:e.fields.map(e=>{let n=xm(e);return n?gm(t,n.minRole)?e:Em(e):e})}))}}function Om({deviceId:e,sectionFilter:t,activeSubTab:n,onSubTabChange:r,flattenSubTabs:i,subTabGrouping:a}){let{t:s}=V(),c=M(),{user:l}=cu(),u=l?.isAdmin===!0,d=f(!1),{data:m,isLoading:h}=Ir({deviceId:e},{refetchInterval:()=>d.current?!1:2500,enabled:Number.isFinite(e)}),{data:g}=qn({deviceId:e},{enabled:Number.isFinite(e)}),_=m?.settings??null,v=m?.live??null,S=p(()=>{if(!_&&!v)return null;let e=_?.sections??[],n=(v?.sections??[]).map(Tm),r=[...e,...n],i=t?r.filter(t):r.filter(fm);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=[..._?.tabs??[],...(v?.tabs??[]).filter(e=>!(_?.tabs??[]).some(t=>t.id===e.id))].filter(e=>o.has(e.id));return s.length>0?{tabs:s,sections:i}:{sections:i}},[_,v,t,a]),C=p(()=>hm([..._?.sections??[],...v?.sections??[]]),[_,v]),w=p(()=>_m(S),[S]),T=p(()=>Dm(w,u),[w,u]),E=p(()=>Cm(T),[T]),D=Jn(),O=Kn(),k=Wr(),A=Fn(),j=Zr({onSuccess:()=>{c.invalidateQueries({queryKey:[[`deviceManager`,`getDeviceAggregate`]]})}}),N={isPending:j.isPending,mutate:t=>{j.mutate({deviceId:e,changes:[...t]})}},P=uu({schema:T,serverValues:E,onImmediateSave:y(e=>{let t=Object.entries(e).map(([e,t])=>{let n=wm(T,e);return n?{writerCapName:n.capName,writerAddonId:n.addonId,key:e,value:t}:null}).filter(e=>e!==null);t.length>0&&N.mutate(t)},[T,N]),onDeferredSave:y(async t=>{let n=Object.entries(t).map(([e,t])=>{let n=wm(T,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 j.mutateAsync({deviceId:e,changes:n});if(t.failures.length>0)throw Error(t.failures.map(e=>e.error).join(`; `))}finally{await c.invalidateQueries({queryKey:[[`deviceManager`,`getDeviceAggregate`]]})}},[T,j,e,c])}),{values:F,pendingKeys:I,handleChange:ee,handleSave:te,handleDiscard:L}=P;d.current=P.editingPaused;let ne=Bc(),re=f(te),ie=f(L);re.current=te,ie.current=L;let ae=ne?.register,oe=j.isError?j.error instanceof Error?j.error.message:String(j.error):null,se=I.join(`\0`);if(x(()=>{if(ae===void 0)return;let e=se===``?[]:se.split(`\0`);return ae({id:`export`,dirty:e.length>0,saving:j.isPending,error:oe,save:()=>(re.current(e),Promise.resolve()),discard:()=>ie.current(e)})},[ae,se,j.isPending,oe]),h)return o(`div`,{className:`flex items-center justify-center py-12 text-foreground-subtle`,children:[b(Me,{className:`h-4 w-4 animate-spin mr-2`}),b(`span`,{className:`text-xs`,children:s(`device.deviceAggregateSection.loadingDeviceAggregate`,`Loading device aggregate…`)})]});if(!T||T.sections.length===0)return b(`div`,{className:`text-xs text-foreground-subtle italic py-4 text-center`,children:s(`device.deviceAggregateSection.noAggregateContributionsForThis`,`No aggregate contributions for this device.`)});async function R(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=kt(e,r);await D.mutateAsync({brokerId:i}),c.invalidateQueries({queryKey:[[`deviceManager`,`getDeviceAggregate`]]});return}if(t===`test-probe`){if(!g)return{status:`error`,error:s(`device.deviceAggregateSection.metadataNotLoaded`)};try{return await k.mutateAsync({addonId:g.addonId,type:g.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=kt(e,t),i=await O.mutateAsync({brokerId:r});return c.invalidateQueries({queryKey:[[`deviceManager`,`getDeviceAggregate`]]}),i}if(t===`device-custom-action`){let t=await A.mutateAsync({deviceId:e,action:n,input:r});return c.invalidateQueries({queryKey:[[`deviceManager`,`getDeviceAggregate`]]}),t}throw Error(`[device-aggregate] unknown action "${t}"`)}return b(nm,{schema:T,values:F,pendingKeys:I,onChange:ee,onAction:R,onSave:te,onDiscard:L,hideSaveBar:ne!==null,disabled:N.isPending,activeSubTab:n,onSubTabChange:r,flattenTabs:i,visibilityContext:C})}D();function km({deviceId:e,onClose:t}){let{t:n}=V(),[r,i]=C(`info`),{data:a}=qn({deviceId:e},{enabled:e>0}),s=kr(e),c=oc(s.presence,s.list),l=r===`history`&&!c?`info`:r,u=typeof a?.name==`string`?a.name:``,d=ir(e,`full`,u.length>0?u:`#${String(e)}`),f=typeof a?.location==`string`?a.location:``,p=[[`info`,n(`deviceQuickDetail.tabInfo`,{defaultValue:`Device info`})],[`export`,n(`deviceQuickDetail.tabExport`,{defaultValue:`Export`})],...c?[[`history`,n(`deviceQuickDetail.tabHistory`,{defaultValue:`History`})]]:[]];return b(Or,{open:!0,onOpenChange:e=>!e&&t(),children:b(ii,{width:`lg`,scroll:`body`,children:o(Vc,{deviceId:e,seed:a==null?null:{name:u,location:f,role:typeof a.role==`string`?a.role:null,display:a.display},showOpenFull:!0,onClose:t,children:[b(ui,{children:b(Zn,{children:d})}),b(`div`,{className:`mt-3 flex items-center gap-1 rounded-md bg-surface-hover p-0.5 w-fit`,children:p.map(([e,t])=>b(`button`,{type:`button`,onClick:()=>i(e),className:`px-2.5 py-1 rounded text-[11px] font-medium transition-colors ${l===e?`bg-surface text-foreground shadow-sm`:`text-foreground-subtle hover:text-foreground`}`,children:t},e))}),b(hr,{className:`mt-3`,children:o(mr,{deviceId:e,device:a??void 0,children:[b(`div`,{className:l===`info`?void 0:`hidden`,children:b(Ec,{})}),b(`div`,{className:l===`export`?void 0:`hidden`,children:b(Om,{deviceId:e,sectionFilter:sm})}),c?b(`div`,{className:l===`history`?void 0:`hidden`,children:b(ac,{deviceId:e})}):null]})})]})})})}function Am({children:e}){let[t,n]=C(null),r=y(e=>n(e),[]),i=y(()=>n(null),[]);return o(Xn,{open:r,children:[e,t===null?null:b(km,{deviceId:t,onClose:i})]})}D();function jm({tabs:e,active:t,onChange:n}){return b(`div`,{className:`flex rounded-lg border border-border bg-surface p-0.5 gap-0.5`,children:e.map(e=>b(`button`,{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 Mm(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 Nm(e){return`${e.inputSize.width}x${e.inputSize.height}`}function Pm(e){return e.formats?Object.keys(e.formats).filter(t=>e.formats[t]!==void 0):[]}function Fm({entry:e,selected:t,onSelect:n,disabled:r}){let{t:i}=V(),a=Mm(e),s=Nm(e),c=Pm(e);return o(`button`,{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:[b(`div`,{className:`flex items-start justify-between gap-2`,children:o(`div`,{className:`flex-1 min-w-0`,children:[o(`div`,{className:`flex items-center gap-2`,children:[b(`span`,{className:`text-xs font-semibold text-foreground truncate`,children:e.name}),t&&b(ue,{className:`h-3.5 w-3.5 text-primary shrink-0`})]}),b(`p`,{className:`text-[10px] text-foreground-subtle mt-0.5 line-clamp-2`,children:e.description})]})}),o(`div`,{className:`flex items-center gap-3 mt-2 flex-wrap`,children:[o(`span`,{className:`inline-flex items-center gap-1 text-[10px] text-foreground-subtle`,children:[b(We,{className:`h-3 w-3`}),s]}),a&&b(`span`,{className:`text-[10px] text-foreground-subtle`,children:a}),c.length>0&&b(`div`,{className:`flex gap-1`,children:c.map(e=>b(`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&&b(`span`,{className:`text-[10px] text-foreground-subtle`,children:i(`common.labels`,{count:e.labels.length})})]})]})}function Im({field:e,value:t,onChange:n,disabled:r}){let{t:i}=V(),a=e.catalog??[],s=a.length>0,c=st(a).length>0,l=e.allowCustomPath!==!1||e.allowCustom===!0,u=[...s?[{id:`catalog`,label:i(`formBuilder.modelSelector.models`,`Models ({{length}})`,{length:a.length})}]:[],...l?[{id:`custom`,label:i(`formBuilder.modelSelector.customPath`,`Custom Path`)}]:[]],[d,f]=C(s?`catalog`:`custom`),p=t==null?``:String(t);return o(`div`,{className:`space-y-3`,children:[u.length>1&&b(jm,{tabs:u,active:d,onChange:f}),d===`catalog`&&s&&c&&b(Xr,{catalog:a,value:p,onChange:e=>n(e),disabled:r||e.disabled}),d===`catalog`&&s&&!c&&b(`div`,{className:`space-y-1.5 max-h-[320px] overflow-y-auto pr-1`,children:a.filter(e=>e.legacy!==!0).map(t=>b(Fm,{entry:t,selected:p===t.id,onSelect:()=>n(t.id),disabled:r||e.disabled},t.id))}),d===`catalog`&&!s&&o(`div`,{className:`rounded-md border border-info/30 bg-info/5 px-3 py-2 flex items-start gap-2`,children:[b(De,{className:`h-3.5 w-3.5 text-info shrink-0 mt-0.5`}),b(`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&&o(`div`,{className:`space-y-2`,children:[b(`input`,{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&&o(`p`,{className:`text-[10px] text-foreground-subtle`,children:[i(`formBuilder.modelSelector.acceptedFormats`,`Accepted formats:`),` `,e.acceptFormats.join(`, `)]})]}),(e.compatibilityNote||e.conversionGuideUrl)&&o(`div`,{className:`flex items-start justify-between gap-3 pt-1`,children:[e.compatibilityNote&&o(`p`,{className:`flex items-start gap-1 text-[10px] text-foreground-subtle`,children:[b(De,{className:`h-3 w-3 mt-0.5 shrink-0`}),e.compatibilityNote]}),e.conversionGuideUrl&&o(`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`),b(oe,{className:`h-3 w-3`})]})]})]})}function Lm({to:e}){let{search:t}=q();return b(Y,{to:`${e}${t}`,replace:!0})}D();function Rm(){return B.t(`helpers.keychainRevealHost.forbidden`)}function zm(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 Bm(e){let t=zm(e);if(t===`FORBIDDEN`||t===`UNAUTHORIZED`)return Rm();let n=e instanceof Error?e.message:String(e);return n.length>0?B.t(`helpers.keychainRevealHost.failedWith`,{message:n}):B.t(`helpers.keychainRevealHost.failed`)}function Vm({children:e}){let t=zn();return b(si,{reveal:y(async e=>{try{return(await t.mutateAsync({ref:e})).value}catch(e){throw Error(Bm(e))}},[t]),children:e})}D();function Hm(){let e=Ae(),t=M(),[n,r]=C(()=>e.isConnected()?`connected`:`disconnected`),i=f(!1),[a,o]=C(0),[s,c]=C([]);x(()=>e.subscribeConnectionEvents(e=>{r(t=>(t!==`connected`&&e===`connected`&&i.current&&o(e=>e+1),e!==`connected`&&(i.current=!0),e))}),[e]),x(()=>{a!==0&&t.invalidateQueries({queryKey:[[`addons`,`getLastRestart`]]})},[a,t]);let{data:l}=On(void 0,{enabled:n===`connected`&&a>0,staleTime:0,refetchOnMount:!1,refetchOnWindowFocus:!1}),u=f(null);return x(()=>{if(l==null||l.requestedAt===u.current)return;u.current=l.requestedAt;let e=Wm(l);c(t=>[...t,e]);let t=window.setTimeout(()=>{c(t=>t.filter(t=>t.id!==e.id))},6e3);return()=>window.clearTimeout(t)},[l]),b(P,{children:s.length>0&&b(Um,{toasts:s})})}function Um({toasts:e}){return b(`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=>o(`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 backdrop-blur-sm`,children:[b(rt,{className:`w-4 h-4 shrink-0 mt-0.5 text-green-400`}),o(`div`,{children:[b(`div`,{className:`text-[11px] font-semibold text-foreground`,children:e.title}),b(`div`,{className:`text-[10px] text-foreground-subtle mt-0.5`,children:e.message})]})]},e.id))})}function Wm(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:B.t(`system.reconnectOverlay.frameworkUpdated`,`Framework updated`),message:B.t(`system.reconnectOverlay.isNow`,`{{packageName}} is now {{fromTo}}.`,{packageName:e.packageName,fromTo:n})}}return{id:t,title:B.t(`system.reconnectOverlay.serverRestarted`,`Server restarted`),message:e.requestedBy===void 0?B.t(`system.reconnectOverlay.manualRestartCompleted`,`Manual restart completed.`):B.t(`system.reconnectOverlay.manualRestartByCompleted`,`Manual restart by {{requestedBy}} completed.`,{requestedBy:e.requestedBy})}}var Gm=`/system/settings`,Km=[{path:`/system/secrets`,tab:`secrets`},{path:`/system/capabilities`,tab:`capabilities`}];function qm(e,t=``){let n=new URLSearchParams(t);return n.delete(`tab`),n.set(`tab`,e),`${Gm}?${n.toString()}`}function Jm({tab:e}){let{search:t,hash:n}=q();return b(Y,{to:`${qm(e,t)}${n}`,replace:!0})}D();var Ym={info:{bg:`bg-info/10`,border:`border-info/30`,icon:De},warning:{bg:`bg-warning/10`,border:`border-warning/30`,icon:at},critical:{bg:`bg-danger/10`,border:`border-danger/30`,icon:nt}};function Xm({toast:e,onDismiss:t}){let n=Ym[e.severity]??Ym.info,r=n.icon;return x(()=>{let n=e.duration??5e3;if(n<=0)return;let r=setTimeout(()=>t(e.id),n);return()=>clearTimeout(r)},[e.id,e.duration,t]),o(`div`,{className:`flex items-start gap-3 px-4 py-3 rounded-lg border ${n.border} ${n.bg} shadow-lg backdrop-blur-sm animate-in slide-in-from-right-5 fade-in duration-200`,children:[b(r,{className:`h-4 w-4 shrink-0 mt-0.5 text-foreground-subtle`}),o(`div`,{className:`flex-1 min-w-0`,children:[b(`div`,{className:`text-xs font-semibold text-foreground`,children:e.title}),b(`div`,{className:`text-[11px] text-foreground-subtle mt-0.5`,children:e.message})]}),b(`button`,{type:`button`,onClick:()=>t(e.id),className:`shrink-0 p-0.5 rounded hover:bg-surface-hover transition-colors`,children:b(Pe,{className:`h-3.5 w-3.5 text-foreground-subtle`})})]})}function Zm(){let[e,t]=C([]),n=y(e=>{t(t=>t.filter(t=>t.id!==e))},[]);return Ur(void 0,{onData:e=>{let n=e,r=`toast-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;t(e=>[...e,{...n,id:r,timestamp:Date.now()}])}}),e.length===0?null:b(`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=>b(`div`,{className:`pointer-events-auto`,children:b(Xm,{toast:e,onDismiss:n})},e.id))})}function Qm(e){return(t,n,r)=>e(t,{...typeof n==`string`?{defaultValue:n}:{defaultValue_one:n.one,defaultValue_other:n.other},...r})}var $m=(e,t,n)=>Qm(B.t.bind(B))(e,t,n);D();function eh({children:e}){let{t}=V();return b(Be,{t:p(()=>Qm(t),[t]),children:e})}D();function th(e){if(typeof e!=`object`||!e)return;let{data:t}=e;return t?.code}function nh(e,t){let n=th(e);return n===`UNAUTHORIZED`||n===`FORBIDDEN`?!0:/UNAUTHORIZED|FORBIDDEN/.test(t)}function rh(e,t,n,r){let[i,a]=C(!1),[o,s]=C(null);return x(()=>{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(nh(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}}D();var ih=3e4;function ah(e){let t=f(e);t.current=e,x(()=>{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>=ih&&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)}},[])}D();function oh(){let{t:e}=V();return o(`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:[b(Gn,{className:`h-7 w-48`}),b(Gn,{className:`h-5 w-72 max-w-full`}),b(Gn,{className:`h-40`})]})}function sh({message:e}){let{t}=V();return b(`div`,{className:`p-2 sm:p-4`,"data-testid":`addon-page-error`,children:b(Cn,{title:t(`layouts.addonPageLoader.failedTitle`,`This page could not be shown`),message:e})})}var ch=class extends c{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:b(sh,{message:this.state.error.message})}};function lh({resetKey:e,children:t}){return b(ch,{resetKey:e,children:t})}function uh({pageKey:e,children:t}){return b(ch,{resetKey:e,children:b(v,{fallback:b(oh,{}),children:t})})}D();function dh(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}var fh=2e4;function ph(e,t){let[n,r]=C(!1);return x(()=>{if(!e){r(!1);return}let n=setTimeout(()=>r(!0),t);return()=>clearTimeout(n)},[e,t]),n}var mh=new Map,hh=new Map,gh=new Set;function _h(e){return!e||typeof e!=`object`?!1:typeof e.default==`function`}async function vh(e,t){let i=mh.get(e);if(i)return i;let a=hh.get(e);if(a)return a;gh.has(e)||(dr(),r([{name:e,entry:z(t),type:`module`}],{force:!1}),gh.add(e));let o=n(`${e}/page`).then(n=>{if(!_h(n))throw Error(`Addon page remote ${e} (${t}) does not expose a default React component on './page'`);return mh.set(e,n.default),hh.delete(e),n.default}).catch(t=>{throw hh.delete(e),t});return hh.set(e,o),o}function yh(){let{t:e}=V(),{pagePath:t}=Qa(),n=J(),r=Ae(),{data:i,isError:a,error:o}=ci(void 0),s=p(()=>i?dh(i):void 0,[i]),c=s?.find(e=>e.path===`/addon/${t}`),l=c?.remoteName,u=c?.bundleUrl,[d,f]=C(null),[m,h]=C(null);x(()=>{if(!l||!u)return;h(null);let e=mh.get(l);if(e){f(()=>e);return}f(null);let t=!1;return vh(l,u).then(e=>{t||f(()=>e)}).catch(e=>{t||h(e instanceof Error?e.message:String(e))}),()=>{t=!0}},[l,u]);let g=ph(!s&&!a,fh),_=ph(c!==void 0&&!d&&!m,fh);return s?c?m?b(sh,{message:m}):d?b(uh,{pageKey:c.remoteName,children:b(d,{trpc:r.trpcClient,theme:{isDark:document.documentElement.classList.contains(`dark`)},navigate:e=>{n(e.startsWith(`/`)?e:`/${e}`)}})}):_?b(sh,{message:e(`layouts.addonPageLoader.remoteStalled`,`The page did not load. Its addon may be starting or unreachable.`)}):b(oh,{}):b(`div`,{className:`flex items-center justify-center h-full text-foreground-subtle`,children:e(`layouts.addonPageLoader.addonPageNotFound`,`Addon page not found`)}):a?b(sh,{message:o?.message??e(`layouts.addonPageLoader.listFailed`,`The page list could not be loaded.`)}):g?b(sh,{message:e(`layouts.addonPageLoader.listStalled`,`The hub did not send the page list. Try again in a moment.`)}):b(oh,{})}var bh={"/system/pipeline":`pipeline-orchestrator`,"/system/history":`device-history`,"/system/ai":`llm`};function xh(e,t){return e.filter(e=>!e.adminOnly||t).map(e=>{let t=bh[e.path];return t===void 0?e:{...e,requiresCapability:t}})}function Sh({t:e,isAdmin:t}){let n=xh([{label:e(`nav.devices`,`Devices`),icon:ce,path:`/devices`},{label:e(`nav.integrations`),icon:de,path:`/integrations`},{label:e(`nav.build`,`Build-your-self`),icon:I,path:`/build`,adminOnly:!0},{label:e(`nav.locations`,`Locations`),icon:Ze,path:`/locations`,adminOnly:!0},{label:e(`nav.viewer`,`Viewer`),icon:an,path:`/live`}],t),r=xh([{label:e(`nav.library`,`Library`),icon:on,path:`/library`,adminOnly:!0,keywords:[`People`,`Vehicles`,`Events`,`Scenes`,`plates`,`faces`,`detection-intelligence`]},{label:e(`nav.recordings`,`Recordings`),icon:be,path:`/recordings`,adminOnly:!0}],t),i=xh([{label:e(`nav.nodes`,`Nodes`),icon:re,path:`/system/nodes`,adminOnly:!0},{label:e(`nav.history`,`History`),icon:ze,path:`/system/history`,adminOnly:!0,keywords:[`charts`,`graphs`,`energy`,`temperature`,`metrics`,`trends`]},{label:e(`nav.pipeline`,`Pipeline`),icon:sn,path:`/system/pipeline`},{label:e(`system.addons`),icon:Re,path:`/system/addons`,adminOnly:!0},{label:e(`system.ai`,`AI`),icon:Je,path:`/system/ai`,adminOnly:!0}],t),a=xh([{label:e(`system.identity`,`Identity & Access`),icon:Ve,path:`/system/identity`,adminOnly:!0},{label:e(`system.network`,`Network`),icon:bn,path:`/system/network`,adminOnly:!0},{label:e(`system.integrations`,`Connectivity`),icon:de,path:`/system/integrations`,adminOnly:!0},{label:e(`system.data`,`Data`),icon:je,path:`/system/data`,adminOnly:!0},{label:e(`system.notifications`,`Notifications`),icon:ye,path:`/system/notifications`,adminOnly:!0},{label:e(`system.calendars`,`Calendars`),icon:ln,path:`/system/calendars`,adminOnly:!0},{label:e(`system.templates`,`Templates`),icon:fn,path:`/system/templates`,adminOnly:!0},{label:e(`system.systemNav`,`System`),icon:Ne,path:Gm,adminOnly:!0},{label:e(`system.logs`,`Logs`),icon:it,path:`/system/logs`,adminOnly:!0},{label:e(`system.terminal`,`Terminal`),icon:mn,path:`/system/terminal`,adminOnly:!0}],t);return[{key:`top`,label:null,items:n},{key:`detection`,label:e(`nav.detectionSection`,`Detection`),items:r},{key:`cluster`,label:e(`nav.clusterSection`,`Cluster`),items:i},{key:`administration`,label:e(`system.title`,`Administration`),items:a}]}var Ch={gauge:fe,puzzle:Re,bot:he,cpu:We,terminal:mn,box:se,boxes:se,monitor:an,wrench:Te,activity:Xe,plug:de,"graduation-cap":le};function wh(e){return Ch[e]??Re}function Th(e,t){for(let n of Sh(t))for(let t of n.items)if(t.path===e)return{icon:t.icon,title:t.label,path:t.path};return null}var Eh=`/system/addons`;function Dh({path:e,children:t}){let n=bh[e];return n===void 0?b(P,{children:t}):b(Oh,{path:e,capability:n,children:t})}function Oh({path:e,capability:t,children:n}){let{t:r}=V(),i=J(),a=Un(t);if(a===`present`)return b(P,{children:n});if(a===`pending`)return o(`div`,{className:`flex flex-col gap-4 p-2 sm:p-4`,"data-testid":`page-presence-pending`,children:[b(Gn,{className:`h-7 w-48`}),b(Gn,{className:`h-40`})]});if(a===`unknown`)return b(`div`,{className:`p-2 sm:p-4`,"data-testid":`page-presence-unknown`,children:b(Cn,{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 s=Th(e,{t:r,isAdmin:!0});return b(`div`,{className:`p-2 sm:p-4`,"data-testid":`page-not-installed`,children:b(Nr,{icon:s?.icon??Re,title:r(`pageRequires.absentTitle`,`{{page}} is not installed`,{page:s?.title??e}),description:r(`pageRequires.absentDescription`,`The addon that provides this page is not installed. Install it from System → Addons.`),action:b(Cr,{variant:`primary`,onClick:()=>i(Eh),children:r(`pageRequires.openAddons`,`Open Addons`)})})})}function kh({capability:e,children:t}){return b(P,{children:t(Un(e)===`absent`)})}function Ah({children:e}){return b(zr,{value:jh(ri({})),children:e})}function jh(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 Mh(){let e=Dr(),{t}=V();return e.status===`unknown`?b(`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 CamStack preset.`,{reason:e.reason})}):null}hi();var Nh=/\p{Mn}/gu;function Ph(e){return e.normalize(`NFD`).replace(Nh,``).toLowerCase().trim()}var Fh=[`device`,`page`,`integration`],Ih=0,Lh=1,Rh=2,zh=3,Bh=4,Vh=5,Hh=6,Uh=7;function Wh(e,t,n,r){return n.includes(r)?Ih:e===r?Lh:e.startsWith(r)?Rh:e.split(/\s+/).some(e=>e.startsWith(r))?zh:e.includes(r)?Bh:t.some(e=>e.includes(r))?Vh:null}function Gh(e,t){let n=0;for(let r=0;r<e.length&&n<t.length;r++)e[r]===t[n]&&n++;return n===t.length}function Kh(e){return e<4?0:e<=7?1:e<=12?2:3}function qh(e,t,n){if(e===t)return 0;if(n<=0||Math.abs(e.length-t.length)>n)return null;let r=t.length,i=Array(r+1).fill(0),a=Array.from({length:r+1},(e,t)=>t),o=Array(r+1).fill(0);for(let s=1;s<=e.length;s++){o[0]=s;let c=s,l=e[s-1];for(let n=1;n<=r;n++){let r=t[n-1],u=l===r?0:1,d=Math.min((a[n]??1/0)+1,o[n-1]+1,(a[n-1]??1/0)+u);s>1&&n>1&&l===t[n-2]&&e[s-2]===r&&(d=Math.min(d,(i[n-2]??1/0)+1)),o[n]=d,d<c&&(c=d)}if(c>n)return null;let u=i;i=a,a=o,o=u}let s=a[r]??1/0;return s<=n?s:null}function Jh(e,t){if(Gh(e,t))return Hh;let n=Kh(t.length);if(n>0){for(let r of e.split(/\s+/))if(qh(r,t,n)!==null)return Uh}return null}function Yh(e,t,n=200){let r=Ph(t);if(r.length===0)return{groups:[],totalMatched:0,truncated:!1};let i=new Map;for(let t of e){let e=Ph(t.label),n=Wh(e,(t.keywords??[]).map(Ph),(t.identifiers??[]).map(Ph),r)??Jh(e,r);if(n===null)continue;let a=i.get(t.domain)??[];a.push({item:t,rank:n}),i.set(t.domain,a)}let a=0;for(let e of i.values())a+=e.length;let o=n,s=[];for(let e of Fh){let t=i.get(e);if(!t||t.length===0||o<=0)continue;t.sort((e,t)=>e.rank-t.rank||e.item.label.localeCompare(t.item.label));let n=t.slice(0,o).map(e=>e.item);o-=n.length,s.push({domain:e,items:n})}return{groups:s,totalMatched:a,truncated:a>n}}function Xh(e){return e.flatMap(e=>e.items)}var Zh=`instance`;function Qh(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 $h(e,t){let n=`/integrations/${encodeURIComponent(e)}`;return t===void 0||t.length===0?n:`${n}?${Zh}=${encodeURIComponent(t)}`}var eg=` · `;function tg(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(eg)}function ng(e,t=null){let n=Ln(e),r=tr(B.language.startsWith(`it`)?`it`:`en`),i=kn(e),a=Wn(t);return e.map(e=>{let t=String(e.id),o=pi(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(eg).includes(c)),u=a(e),d=u.kind===`resolved`?u.integration.name:``;return{key:`device:${t}`,domain:`device`,label:s,subtitle:tg(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:Nn(e.type).icon}})}function rg(e){return e.map(e=>({key:`integration:${e.id}`,domain:`integration`,label:e.name||e.addonId,subtitle:e.enabled?e.addonId:B.t(`helpers.searchItems.disabled`,{addonId:e.addonId}),keywords:[e.addonId,e.processState],path:$h(e.addonId,e.id)}))}function ig(e,t,n){let r=e.section?.trim();return r?t[r]??e.sectionLabel?.trim()??r:n}function ag(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:ig(e,i,n.ungrouped),keywords:[e.addonId],path:e.path,icon:wh(e.icon)}));return[...r,...a]}D();var og={device:{labelKey:`search.resultsList.devices`,icon:ce},page:{labelKey:`search.resultsList.pages`,icon:gn},integration:{labelKey:`search.resultsList.integrations`,icon:de}};function sg({groups:e,activeKey:t,query:n,totalMatched:r,truncated:i,onSelect:a,onHover:s}){let{t:c}=V(),l=f(null);if(x(()=>{t&&(l.current?.querySelector(`[data-key="${CSS.escape(t)}"]`))?.scrollIntoView({block:`nearest`})},[t]),n.trim().length===0)return null;if(e.length===0)return b(`div`,{className:`px-3 py-4 text-center text-[12px] text-foreground-subtle`,children:c(`search.resultsList.noResults`,{query:n})});let u=e.reduce((e,t)=>e+t.items.length,0);return o(P,{children:[b(`div`,{ref:l,role:`listbox`,className:`max-h-[60vh] overflow-y-auto py-1`,children:e.map(e=>{let n=og[e.domain],r=n.icon;return o(`div`,{className:`px-1 py-1`,children:[o(`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:[b(r,{className:`h-3 w-3`}),c(n.labelKey)]}),e.items.map(e=>{let r=e.icon??n.icon,i=e.key===t;return o(`button`,{type:`button`,role:`option`,"aria-selected":i,"data-key":e.key,onMouseEnter:()=>s(e),onClick:()=>a(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:[b(r,{className:`h-3.5 w-3.5 shrink-0 ${i?`text-primary`:`text-foreground-subtle`}`}),o(`span`,{className:`flex-1 min-w-0`,children:[b(`span`,{className:`block truncate font-medium`,children:e.label}),e.subtitle&&b(`span`,{className:`block truncate text-[10px] text-foreground-subtle`,children:e.subtitle})]})]},e.key)})]},e.domain)})}),i&&b(`div`,{className:`border-t border-border px-3 py-1.5 text-center text-[10px] text-foreground-subtle`,children:c(`search.truncatedResults`,`Showing first {{shown}} of {{total}} — refine your search.`,{shown:u,total:r})})]})}D();function cg({navSections:e,addonPages:t,compact:n,onNavigated:r}){let{t:i}=V(),a=J(),s=f(null),c=f(null),l=f(null),[u,d]=C(null),[m,h]=C(``),[g,_]=C(0),[v,S]=C(!1),{data:w}=Hn({projection:`slim`}),{data:T}=Pr(void 0),E=p(()=>{let n={detection:i(`nav.detectionSection`,`Detection`),cluster:i(`nav.clusterSection`,`Cluster`),administration:i(`system.title`,`Administration`),ungrouped:i(`nav.addonPages`,`Addon Pages`)};return[...ng(w??[],T??null),...ag(e,t,n),...rg(T??[])]},[w,T,e,t,i]),{groups:D,totalMatched:O,truncated:k}=p(()=>Yh(E,m),[E,m]),A=p(()=>Xh(D),[D]);x(()=>{_(0)},[m,E]),x(()=>{v&&s.current?.focus()},[v]);let j=y(()=>{S(!1),h(``),_(0)},[]),M=y(e=>{a(e.path),j(),s.current?.blur(),r?.()},[a,j,r]);fi(s,{scope:Tn}),x(()=>{if(!v)return;function e(e){if(!(e.target instanceof Node))return;let t=c.current?.contains(e.target)===!0,n=l.current?.contains(e.target)===!0;!t&&!n&&S(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[v]);let N=v&&m.trim().length>0;x(()=>{if(!N){d(null);return}let e=()=>{let e=s.current?.getBoundingClientRect();e&&d({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)}},[N]);let P=A[g]?.key??null,F=i(`search.placeholder`,`Search devices, pages, integrations…`),I=o(`div`,{className:`relative`,children:[b(et,{className:`pointer-events-none absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-foreground-subtle`}),b(`input`,{ref:s,type:`text`,value:m,placeholder:F,"aria-label":F,role:`combobox`,"aria-expanded":v&&m.trim().length>0,"aria-controls":`global-search-results`,onChange:e=>{h(e.target.value),S(!0)},onFocus:()=>S(!0),onKeyDown:e=>{if(e.key===`ArrowDown`)e.preventDefault(),A.length>0&&_(e=>(e+1)%A.length);else if(e.key===`ArrowUp`)e.preventDefault(),A.length>0&&_(e=>(e-1+A.length)%A.length);else if(e.key===`Enter`){e.preventDefault();let t=A[g];t&&M(t)}else e.key===`Escape`&&(e.preventDefault(),j(),s.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`}),m.length>0&&b(`button`,{type:`button`,"aria-label":i(`search.globalSearch.clearSearch`,`Clear search`),onClick:()=>{h(``),s.current?.focus()},className:`absolute right-1.5 top-1/2 -translate-y-1/2 text-foreground-subtle hover:text-foreground`,children:b(Pe,{className:`h-3 w-3`})}),N&&u!==null&&gi(b(`div`,{ref:l,id:`global-search-results`,className:`fixed z-50 w-max max-w-[26rem] rounded-lg border border-border bg-surface shadow-xl`,style:{left:u.left,top:u.top,minWidth:u.width},children:b(sg,{groups:D,activeKey:P,query:m,totalMatched:O,truncated:k,onSelect:M,onHover:e=>{let t=A.findIndex(t=>t.key===e.key);t>=0&&_(t)}})}),document.body)]});return n?b(`div`,{ref:c,className:`px-1.5 pb-1.5`,children:v?b(`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:I}):b(`button`,{type:`button`,onClick:()=>S(!0),"aria-label":F,title:F,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:b(et,{className:`h-3.5 w-3.5 shrink-0`})})}):b(`div`,{ref:c,className:`px-2 pb-2`,children:I})}var lg=/^(\d{1,3}\.){3}\d{1,3}$/;function ug(e){let t=e.startsWith(`[`)&&e.endsWith(`]`)?e.slice(1,-1):e;return!!(lg.test(t)||t.includes(`:`))}function dg(e,t){return!t||ug(e)?!1:e===t||e.endsWith(`.${t}`)}D();var fg=`auth-webauthn/passkey-enrollment`,pg=`camstack_passkey_prompt_dismissed:`,mg=720*60*60*1e3;function hg(e){try{let t=localStorage.getItem(`${pg}${e}`);if(!t)return!1;let n=Number(t);return Number.isFinite(n)?Date.now()-n<mg:!1}catch{return!1}}function gg(e){try{localStorage.setItem(`${pg}${e}`,String(Date.now()))}catch{}}function _g(){let{user:e}=cu(),{t}=V(),n=Ae(),r=pr(fg),[i,a]=C(!1),[s,c]=C(!1),l=p(()=>e?hg(e.id):!0,[e]),u=$r.auth.listLoginMethods.useQuery().data?.find(e=>e.kind===`passkey`),d=u!==void 0&&dg(window.location.hostname,u.rpId),f=e!==null&&d&&r!=null&&!l,m=T({queryKey:[`auth`,`listOwnPasskeys`],queryFn:()=>n.listOwnPasskeys(),enabled:f,staleTime:6e4}),h=y(()=>{e&&gg(e.id),a(!0),c(!1)},[e]),g=y(()=>{c(!1),m.refetch()},[m]);return!f||i||m.data===void 0||m.data.length>0?null:o(`div`,{className:`shrink-0 border-b border-primary/20 bg-primary/5`,children:[o(`div`,{className:`flex items-center gap-2.5 px-3 py-2 text-xs text-foreground`,children:[b(cn,{className:`h-4 w-4 text-primary shrink-0`}),b(`span`,{className:`flex-1 min-w-0`,children:t(`passkeyPrompt.message`,`Save a passkey for faster sign-in?`)}),b(`button`,{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`)}),b(`button`,{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`)}),b(`button`,{onClick:h,"aria-label":t(`passkeyPrompt.notNow`,`Not now`),className:`p-1 rounded text-foreground-subtle hover:text-foreground`,children:b(Pe,{className:`h-3.5 w-3.5`})})]}),s&&b(`div`,{className:`px-3 pb-3`,children:o(`div`,{className:`max-w-xl`,children:[b(Ar,{widgetId:fg,host:`dashboard`}),b(`div`,{className:`mt-2 flex justify-end`,children:b(`button`,{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 vg=6e4;function yg(){let e=mi(void 0,{staleTime:vg});return{info:e.data?.serverName??null,isLoading:e.isLoading}}D();var bg=`system-config`,xg=`hub`,Sg=`camstack_server_name_prompt_dismissed`;function Cg(){try{return sessionStorage.getItem(Sg)===`1`}catch{return!1}}function wg(){try{sessionStorage.setItem(Sg,`1`)}catch{}}function Tg(e){return e.isAdmin&&e.info!==null&&e.info.isDefault&&!e.dismissed}function Eg(){let{user:e}=cu(),{info:t}=yg(),[n,r]=C(Cg);return Tg({isAdmin:e?.isAdmin===!0,info:t,dismissed:n})?b(Dg,{suggestion:t?.name??``,onLater:()=>{wg(),r(!0)}}):null}function Dg({suggestion:e,onLater:t}){let{t:n}=V(),r=M(),i=Fr(),[a,s]=C(e),[c,l]=C(null),u=f(null);x(()=>u.current?.focus(),[]);let d=y(async()=>{let e=Jt.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({addonId:bg,nodeId:xg,patch:{name:e.data}}),await r.invalidateQueries({queryKey:[[`system`,`info`]]}),await r.invalidateQueries({queryKey:[[`addonSettings`]]})}catch(e){l(e instanceof Error&&e.message.length>0?e.message:`Could not save`)}},[r,i,n,a]);return b(Or,{open:!0,onOpenChange:e=>!e&&t(),children:b(ii,{children:o(`form`,{onSubmit:e=>{e.preventDefault(),i.isPending||d()},children:[o(ui,{children:[b(Zn,{children:n(`serverName.title`,`Name this server`)}),b(di,{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.`)})]}),b(hr,{children:b(En,{label:n(`serverName.label`,`Server name`),...c===null?{}:{error:c},children:b(Sn,{ref:u,value:a,maxLength:48,onChange:e=>s(e.target.value),state:c===null?`default`:`error`,"aria-label":n(`serverName.label`,`Server name`)})})}),o(vr,{children:[b(Cr,{type:`button`,variant:`ghost`,onClick:t,disabled:i.isPending,children:n(`serverName.later`,`Later`)}),o(Cr,{type:`submit`,disabled:i.isPending||a.trim().length===0,children:[i.isPending&&b(Me,{className:`h-4 w-4 animate-spin`}),n(`common.save`,`Save`)]})]})]})})})}var Og=4,kg=160,Ag=320,jg=`env(safe-area-inset-top)`,Mg=`env(safe-area-inset-bottom)`;function Ng(e){let{rect:t,viewportWidth:n,viewportHeight:r}=e,i=Math.min(Ag,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+Og}px, calc(${jg} + 8px))`;return{...a,top:e,maxHeight:`max(${kg}px, calc(100dvh - ${e} - ${Mg} - 8px))`}}let o=`max(${r-t.top+Og}px, calc(${Mg} + 8px))`;return{...a,bottom:o,maxHeight:`max(${kg}px, calc(100dvh - ${o} - ${jg} - 8px))`}}function Pg(e){return e===`totp`||e===`passkey`}function Fg(e){if(!e.startsWith(`#`))return null;let t=new URLSearchParams(e.slice(1)),n=t.get(`challenge`);if(n!==null){if(n.length===0)return null;let e=(t.get(`factors`)??``).split(`,`).filter(Pg);return e.length===0?null:{kind:`challenge`,challengeToken:n,factors:e}}let r=t.get(`error`);return r===`sso-not-linked`||r===`sso-state`?{kind:`error`,code:r,provider:t.get(`provider`)}:null}function Ig(e,t){switch(e){case`sso-not-linked`:return B.t(`helpers.ssoReturn.notLinked`,{provider:t??B.t(`helpers.ssoReturn.signInFallback`)});case`sso-state`:return B.t(`helpers.ssoReturn.state`)}}var Lg={expired:`helpers.ssoReturn.link.expired`,provider:`helpers.ssoReturn.link.provider`,session:`helpers.ssoReturn.link.session`,conflict:`helpers.ssoReturn.link.conflict`,state:`helpers.ssoReturn.link.state`};function Rg(e){let t=new URLSearchParams(e),n=t.get(`linked`);if(n!==null&&n.length>0)return{kind:`linked`,provider:n};let r=t.get(`linkError`);return r===null?null:{kind:`error`,message:B.t(Lg[r]??`helpers.ssoReturn.link.failed`)}}var zg=`camstack:sso-return`,Bg=`camstack:sso-ack`,Vg=`/sso-complete`,Hg=1500,Ug=520,Wg=680;function Gg(e){if(!e.startsWith(`#`))return null;let t=new URLSearchParams(e.slice(1)),n=t.get(`return`);t.delete(`return`);let r=t.toString();return n===`login`?r.length>0?{target:n,fragment:r}:null:n===`profile`&&r.length>0?{target:n,query:r}:null}function Kg(e){return e.target===`login`?`/login#${e.fragment}`:`/system/my-access?${e.query}`}function qg(e){let t=new URL(e,`http://placeholder.invalid`);return t.searchParams.set(`popup`,`1`),/^[a-z][a-z0-9+.-]*:/i.test(e)?t.toString():`${t.pathname}${t.search}${t.hash}`}function Jg(e=window){let t=Math.max(0,Math.round(e.screenX+(e.outerWidth-Ug)/2)),n=Math.max(0,Math.round(e.screenY+(e.outerHeight-Wg)/2));return[`popup=yes`,`width=${Ug}`,`height=${Wg}`,`left=${t}`,`top=${n}`,`toolbar=no`,`menubar=no`,`location=no`,`status=no`,`resizable=yes`,`scrollbars=yes`].join(`,`)}function Yg(e){try{return window.open(e??`about:blank`,`camstack-sso`,Jg())??null}catch{return null}}function Xg(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.target===`login`?typeof t.fragment==`string`:t.target===`profile`?typeof t.query==`string`:!1}function Zg(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.type===`camstack:sso-return`&&Xg(t.completion)}function Qg(e,t,n){return t===null||e.source!==t||e.origin!==n?null:Zg(e.data)?e.data.completion:null}var $g=`camstack-sso`,e_=`camstack:sso-done`;function t_(e,t){return e.target===`profile`?{target:`profile`,query:e.query}:t?{target:`login`}:null}function n_(e){if(typeof e!=`object`||!e)return null;let t=e;if(t.type!==`camstack:sso-done`)return null;let n=Object.keys(t).sort().join(`,`);return t.target===`login`&&n===`target,type`?{target:`login`}:t.target===`profile`&&typeof t.query==`string`&&n===`query,target,type`?{target:`profile`,query:t.query}:null}function r_(e){return typeof e==`object`&&!!e&&e.type===`camstack:sso-done-ack`}function i_(e){try{let t=e.location.origin;return typeof t==`string`?t:null}catch{return null}}function a_(){if(typeof BroadcastChannel>`u`)return null;try{let e=new BroadcastChannel($g);return{post:t=>e.postMessage(t),subscribe:t=>{let n=e=>t(e.data);return e.addEventListener(`message`,n),()=>e.removeEventListener(`message`,n)},close:()=>e.close()}}catch{return null}}var o_=500;function s_(e,t,n=window,r={}){let i=n.location.origin,a=r.channel===void 0?a_():null,o=r.channel===void 0?a:r.channel,s=r.setInterval??((e,t)=>window.setInterval(e,t)),c=r.clearInterval??(e=>window.clearInterval(e)),l=!1,u=!1,d=r=>{let a=Qg(r,e,i);a===null||l||(l=!0,n.removeEventListener(`message`,d),e.postMessage({type:Bg},i),t.onReturn(a))};n.addEventListener(`message`,d);let f=o?.subscribe(e=>{let n=n_(e);n===null||l||(l=!0,o.post({type:`camstack:sso-done-ack`}),t.onDone?.(n))})??null,p=s(()=>{u||!e.closed||(u=!0,c(p),t.onClosed?.())},o_);return()=>{n.removeEventListener(`message`,d),f?.(),a?.close(),c(p)}}function c_(e,t,n){if(t===null||e.source!==t||e.origin!==n)return!1;let r=e.data;return typeof r==`object`&&!!r&&r.type===`camstack:sso-ack`}function l_(e,t){return new Promise(n=>{let r=!1,i=t(()=>{r||(r=!0,i(),n(!0))});e.setTimeout(()=>{r||(r=!0,i(),n(!1))},Hg)})}function u_(e,t,n){let r=l_(n,e=>{let r=r=>{c_(r,t,n.origin)&&e()};return n.addEventListener(`message`,r),()=>n.removeEventListener(`message`,r)});try{let r={type:zg,completion:e};t.postMessage(r,n.origin)}catch{}return r}function d_(e,t,n){let r=l_(n,e=>t.subscribe(t=>{r_(t)&&e()}));return t.post({type:e_,...e}),r}async function f_(e,t){let n=t.opener!==null&&!t.opener.closed?t.opener:null;if(n!==null&&i_(n)===t.origin&&await u_(e,n,t)){t.close();return}let r=e.target===`login`?new URLSearchParams(e.fragment).get(`token`):null,i=r!==null&&r.length>0,a=t_(e,i);if(a!==null&&t.channel!==null&&(r!==null&&i&&await t.persistSession(r),await d_(a,t.channel,t))){t.close();return}if(n!==null&&e.target===`profile`){let n=Rg(`?${e.query}`);if(n?.kind===`error`){t.showResult({kind:`link-error`,message:n.message});return}t.close();return}t.continueAt(Kg(e))}function p_(e,t){return(t.length>0&&e.startsWith(t)?e.slice(t.length):e).replace(/\/+$/,``)===Vg}var m_=`camstack:broker-oauth`;function h_(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.type===`camstack:broker-oauth`&&typeof t.ok==`boolean`}function g_(e,t){return e.split(`{{brokerId}}`).join(encodeURIComponent(t))}function __(e,t,n=window){let r=n.location.origin,i=!1,a=e=>{i||(i=!0,n.removeEventListener(`message`,o),window.clearInterval(s),t(e))},o=t=>{t.origin!==r||t.source!==e||h_(t.data)&&a({ok:t.data.ok,...t.data.brokerId===void 0?{}:{brokerId:t.data.brokerId},...t.data.error===void 0?{}:{error:t.data.error}})};n.addEventListener(`message`,o);let s=window.setInterval(()=>{e.closed&&a({ok:!0})},500);return()=>{i=!0,n.removeEventListener(`message`,o),window.clearInterval(s)}}var v_={open:e=>Yg(e),assign:e=>window.location.assign(e),watch:(e,t)=>__(e,t)};function y_(e,t,n=v_){let r=z(qg(e)),i=n.open(r);if(i===null){n.assign(r);return}n.watch(i,e=>{t?.(e)})}function b_(e,t,n){y_(g_(e,t),n)}var x_=!1;function S_(){return x_}function C_(){x_=!0}function w_(e){return!e.read&&e.severity===`critical`}function T_(e){return e.filter(w_)}function E_(e){return e!==void 0&&typeof e.href==`string`&&e.href.length>0}function D_(e){return E_(e)||e!==void 0&&e.invoke!==void 0}var O_=/^\/addon\/[^/?#]+\/oauth\//;function k_(e){return e.navigation===void 0?O_.test(e.href):e.navigation===`server`}function A_(e){let t=e.action;if(D_(t)&&!(t.invoke!==void 0&&(e.status===`completed`||e.status===`dismissed`)))return t}D();function j_({action:e,className:t,onActivate:n}){let r=M(),i=Ae(),{t:a}=V(),[s,c]=C(!1),[l,u]=C(null);if(e.invoke!==void 0){let{addonId:d,action:f,input:p}=e.invoke;return o(`span`,{className:`inline-flex flex-col items-start gap-0.5`,children:[b(`button`,{type:`button`,className:t,disabled:s,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:s?a(`ui.alertAction.running`,`Working…`):e.label}),l!==null&&b(`span`,{role:`alert`,className:`text-[10px] text-destructive`,children:l})]})}return E_(e)?k_(e)?b(`a`,{href:z(e.href),className:t,onClick:t=>{t.preventDefault(),n?.(t),y_(e.href,()=>{r.invalidateQueries({queryKey:[[`alerts`]]}),r.invalidateQueries({queryKey:[[`broker`]]}),r.invalidateQueries({queryKey:[[`recordEntries`]]})})},children:e.label}):b(hs,{to:e.href,className:t,onClick:n,children:e.label}):b(P,{})}D(),hi();var M_={info:De,success:rt,warning:at,error:nt,critical:dn},N_={info:`text-info`,success:`text-success`,warning:`text-warning`,error:`text-danger`,critical:`text-danger`},P_={active:`border-l-info`,"in-progress":`border-l-warning`,completed:`border-l-success`,failed:`border-l-danger`,dismissed:`border-l-foreground-subtle/30`};function F_(e){let t=Math.floor((Date.now()-e)/1e3);if(t<60)return B.t(`helpers.relativeTime.justNow`);let n=Math.floor(t/60);if(n<60)return B.t(`helpers.relativeTime.minutesAgo`,{count:n});let r=Math.floor(n/60);if(r<24)return B.t(`helpers.relativeTime.hoursAgo`,{count:r});let i=Math.floor(r/24);return B.t(`helpers.relativeTime.daysAgo`,{count:i})}function I_(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function L_(e){return typeof e==`string`&&e.length>0?e:void 0}function R_(e){if(I_(e.metadata)){let t=L_(e.metadata.nodeId)??L_(e.metadata.agentId);if(t!==void 0)return t}let t=e.source;if(t!==void 0&&!(t.type!==`node`&&t.type!==`agent`))return L_(t.id)}function z_({alert:e,onMarkRead:t,onDismiss:n}){let{t:r}=V(),i=e.severity in M_?e.severity:`info`,a=A_(e),s=e.status in P_?e.status:`active`,c=M_[i],l=N_[i],u=P_[s],{nodes:d}=lr(),f=R_(e),p=f===void 0?void 0:d.find(e=>e.id===f),m=f===void 0?void 0:p?.name??f;return o(`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:[b(c,{className:`h-3.5 w-3.5 shrink-0 mt-0.5 ${l}`}),o(`div`,{className:`flex-1 min-w-0`,children:[o(`div`,{className:`flex items-center gap-1.5`,children:[b(`span`,{className:`text-[11px] font-semibold ${e.read?`text-foreground-subtle`:`text-foreground`}`,children:e.title}),!e.read&&b(`span`,{className:`h-1.5 w-1.5 rounded-full bg-primary shrink-0`})]}),m!==void 0&&b(`div`,{className:`text-foreground-subtle text-[10px] mt-0.5 truncate`,children:m}),b(`div`,{className:`text-[10px] text-foreground-subtle mt-0.5 line-clamp-2`,children:e.message}),a!==void 0&&b(j_,{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&&o(`div`,{className:`mt-1.5 flex items-center gap-2`,children:[b(`div`,{className:`flex-1 h-1 bg-surface-hover rounded-full overflow-hidden`,children:b(`div`,{className:`h-full bg-primary rounded-full transition-all duration-300`,style:{width:`${String(Math.min(100,Math.max(0,e.progress)))}%`}})}),o(`span`,{className:`text-[9px] text-foreground-subtle font-mono shrink-0`,children:[String(Math.round(e.progress)),`%`]})]}),b(`div`,{className:`text-[9px] text-foreground-subtle/60 mt-1`,children:F_(e.updatedAt)})]}),o(`div`,{className:`flex items-center gap-0.5 shrink-0`,children:[!e.read&&b(`button`,{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:b(ue,{className:`h-3 w-3 text-foreground-subtle`})}),e.status!==`in-progress`&&b(`button`,{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:b(Pe,{className:`h-3 w-3 text-foreground-subtle`})})]})]})}function B_({variant:e=`icon`,compact:t=!1}={}){let{t:n}=V(),[r,i]=C(!1),[a,s]=C(!1),c=f(null),l=f(null),u=M(),{data:d=0}=Vr(void 0,{refetchInterval:3e4}),{data:p=[],isLoading:m}=qr({limit:50},{enabled:r}),h=a?p:p.filter(e=>!e.read),g=p.filter(e=>e.read).length,_=()=>{u.invalidateQueries({queryKey:[[`alerts`]]})},v=gr({onSuccess:_}),S=jr({onSuccess:_}),w=Qr({onSuccess:_});Sr(`alert.created`,()=>{u.invalidateQueries({queryKey:[[`alerts`]]})}),Sr(`alert.updated`,()=>{u.invalidateQueries({queryKey:[[`alerts`]]})}),x(()=>{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=y(e=>{v.mutate({alertId:e})},[v]),E=y(e=>{e&&w.mutate({alertId:e})},[w]),D=y(()=>{S.mutate(void 0),i(!1)},[S]),O=h.filter(w_),k=new Set(O.map(e=>e.id)),A=h.filter(e=>e.status===`in-progress`&&!k.has(e.id)),j=h.filter(e=>e.status!==`in-progress`&&!k.has(e.id)),[N,P]=C({}),F=y(()=>{let e=l.current;e&&P(Ng({rect:e.getBoundingClientRect(),viewportWidth:window.innerWidth,viewportHeight:window.innerHeight}))},[]);return x(()=>{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]),o(`div`,{children:[e===`sidebar`?o(`button`,{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?d>0?n(`ui.alertBell.alertsUnread`,{count:d}):n(`ui.alertBell.alerts`):void 0,children:[o(`span`,{className:`relative inline-flex shrink-0`,children:[b(it,{className:`h-3.5 w-3.5`}),t&&d>0&&b(`span`,{className:`absolute -top-1 -right-1 h-2 w-2 rounded-full bg-primary`})]}),!t&&b(`span`,{className:`flex-1 text-left`,children:n(`ui.alertBell.alerts`,`Alerts`)}),!t&&d>0&&b(`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:d>99?`99+`:String(d)})]}):o(`button`,{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:[b(it,{className:`h-4.5 w-4.5`}),d>0&&b(`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:d>99?`99+`:String(d)})]}),r&&gi(o(`div`,{ref:c,style:N,className:`bg-surface border border-border rounded-lg shadow-xl flex flex-col overflow-hidden`,children:[o(`div`,{className:`flex items-center justify-between px-3 py-2 border-b border-border shrink-0`,children:[b(`span`,{className:`text-[12px] font-semibold text-foreground`,children:n(`ui.alertBell.alerts`,`Alerts`)}),o(`div`,{className:`flex items-center gap-2`,children:[g>0&&o(`label`,{className:`flex items-center gap-1 text-[10px] text-foreground-subtle cursor-pointer select-none`,children:[b(`input`,{type:`checkbox`,checked:a,onChange:e=>s(e.target.checked),className:`h-3 w-3 rounded border-border accent-primary cursor-pointer`}),n(`ui.alertBell.showRead`,`Show read`)]}),d>0&&o(`button`,{type:`button`,onClick:D,className:`flex items-center gap-1 text-[10px] text-primary hover:text-primary/80 transition-colors`,children:[b(pn,{className:`h-3 w-3`}),n(`ui.alertBell.markAllRead`,`Mark all read`)]})]})]}),o(`div`,{className:`flex-1 overflow-y-auto`,children:[m&&b(`div`,{className:`flex items-center justify-center py-8`,children:b(Me,{className:`h-4 w-4 animate-spin text-foreground-subtle`})}),!m&&h.length===0&&o(`div`,{className:`flex flex-col items-center justify-center py-8 text-foreground-subtle`,children:[b(it,{className:`h-6 w-6 mb-2 opacity-40`}),b(`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&&b(`button`,{type:`button`,onClick:()=>s(!0),className:`text-[10px] text-primary mt-1 hover:underline`,children:n(`ui.alertBell.showRead`,{count:g})})]}),O.length>0&&o(`div`,{className:`border-b border-border`,children:[b(`div`,{className:`px-3 py-1.5 bg-danger/5`,children:b(`span`,{className:`text-[9px] font-semibold uppercase tracking-widest text-danger`,children:n(`ui.alertBell.urgent`,`Urgent`)})}),O.map(e=>b(z_,{alert:e,onMarkRead:T,onDismiss:E},e.id))]}),A.length>0&&o(`div`,{className:`border-b border-border`,children:[b(`div`,{className:`px-3 py-1.5 bg-surface-hover/50`,children:b(`span`,{className:`text-[9px] font-semibold uppercase tracking-widest text-foreground-subtle/60`,children:n(`ui.alertBell.inProgress`,`In Progress`)})}),A.map(e=>b(z_,{alert:e,onMarkRead:T,onDismiss:E},e.id))]}),j.map(e=>b(z_,{alert:e,onMarkRead:T,onDismiss:E},e.id))]})]}),document.body)]})}D(),hi();function V_({alert:e,onMarkRead:t}){let{t:n}=V(),r=A_(e);return o(`div`,{className:`border-b border-border last:border-b-0 px-3 py-2.5`,children:[b(`div`,{className:`text-[12px] font-semibold text-foreground`,children:e.title}),b(`div`,{className:`text-[11px] text-foreground-muted mt-0.5`,children:e.message}),o(`div`,{className:`mt-2 flex flex-wrap items-center gap-2`,children:[r!==void 0&&b(j_,{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`}),b(Cr,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>t(e.id),children:n(`ui.alertBell.markAsRead`,`Mark as read`)})]})]})}function H_(){let{t:e}=V(),t=M(),[n,r]=C(S_()),{data:i=[],isLoading:a}=qr({limit:50}),s=p(()=>T_(i),[i]),c=gr({onSuccess:y(()=>{t.invalidateQueries({queryKey:[[`alerts`]]})},[t])}),l=y(e=>{c.mutate({alertId:e})},[c]),u=y(()=>{C_(),r(!0)},[]);return a||n||s.length===0?null:gi(b(`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:o(`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:[o(`div`,{className:`flex items-start justify-between gap-2 px-3 py-2.5 border-b border-border shrink-0 bg-danger/5`,children:[o(`div`,{children:[b(`h2`,{id:`critical-alerts-panel-title`,className:`text-[12px] font-semibold text-foreground`,children:e(`ui.criticalAlertsPanel.title`,`Urgent alerts`)}),b(`p`,{className:`text-[10px] text-foreground-muted mt-0.5`,children:e(`ui.criticalAlertsPanel.subtitle`,`These need your attention.`)})]}),b(Mr,{type:`button`,variant:`ghost`,onClick:u,"aria-label":e(`ui.criticalAlertsPanel.close`,`Close`),"data-testid":`critical-alerts-panel-close`,icon:Pe})]}),b(`div`,{className:`flex-1 overflow-y-auto`,children:s.map(e=>b(V_,{alert:e,onMarkRead:l},e.id))})]})}),document.body)}D();function U_(){let e=nl();return S(e.subscribe,e.getSnapshot,e.getSnapshot)}var W_=[`detection`,`cluster`,`administration`];function G_(e){return W_.includes(e)}function K_(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(G_(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 q_=`camstack:last-path`,J_=512,Y_=[`/login`,`/change-password`,`/access-denied`,`/logout`];function X_(e){return!e.startsWith(`/`)||e.startsWith(`//`)||e.length>J_?!1:!Y_.some(t=>e===t||e.startsWith(t+`/`))}function Z_(e){if(!(typeof window>`u`)&&X_(e))try{window.localStorage.setItem(q_,e)}catch{}}function Q_(){if(typeof window>`u`)return null;try{let e=window.localStorage.getItem(q_);return e===null?null:X_(e)?e:null}catch{return null}}var $_=`/devices`;function ev(e){return e!==void 0&&X_(e)?e:Q_()??$_}function tv(e){return e.split(`.`)[0]===`0`?`${e} beta`:e}function nv(e){if(e===null)return null;let t=e.trim();return t.length>0?t:null}function rv(e){let t=nv(e.productVersion),n=nv(e.serverVersion),r=nv(e.fallbackVersion);return t!==null&&n!==null?{kind:`both`,productLabel:tv(t),serverVersion:n}:t===null?n===null?r===null?{kind:`none`}:{kind:`fallback`,version:r}:{kind:`server`,serverVersion:n}:{kind:`product`,productLabel:tv(t)}}function iv(e,t){if(!Object.hasOwn(e,t))return null;let n=Reflect.get(e,t);return typeof n==`string`?n:null}function av(e){return typeof e!=`object`||!e?null:{productVersion:iv(e,`productVersion`),serverVersion:iv(e,`serverVersion`)}}D();function ov(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 sv({placement:e,compact:t=!1}){let{t:n}=V(),[r,i]=C({kind:`fallback`,version:`1.2.513`});x(()=>{let e=new AbortController;return fetch(z(`/api/release-identity`),{signal:e.signal}).then(async e=>e.ok?av(await e.json()):null).then(t=>{e.signal.aborted||t===null||i(rv({productVersion:t.productVersion,serverVersion:t.serverVersion,fallbackVersion:`1.2.513`}))}).catch(t=>{e.signal.aborted||t instanceof DOMException&&t.name}),()=>e.abort()},[]);let a=ov(r,n);return a===null?null:e===`login`?b(`span`,{"data-testid":`release-identity`,children:a}):b(`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})}D();var cv=A(!0);function lv(e){return e===`/addon`||e.startsWith(`/addon/`)}function uv(e,t,n){let r=[...e.filter(e=>e!==t),t];return r.length<=n?r:r.slice(r.length-n)}function dv({maxCached:e=6}){let t=Za(),n=q(),r=Ka(),i=F(K),a=n.pathname,s=lv(a),c=f(new Map),l=f([]);if(s){c.current.set(a,{key:a,outlet:t,location:n,navigationType:r,routeContext:i});let o=uv(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 o(P,{children:[l.current.map(e=>{let t=c.current.get(e);if(t?.outlet==null)return null;let n=s&&e===a;return b(`div`,{className:n?`h-full min-h-0`:void 0,style:n?void 0:{display:`none`},hidden:!n,"aria-hidden":!n,children:b(cv.Provider,{value:n,children:b(La.Provider,{value:{location:t.location,navigationType:t.navigationType},children:b(K.Provider,{value:t.routeContext,children:t.outlet})})})},e)}),!s&&t!=null?b(`div`,{className:`h-full min-h-0`,children:t},a):null]})}D();var fv={dark:pe,light:me,system:an};function pv(){return b(`div`,{className:`flex h-full min-h-[50vh] items-center justify-center`,children:b(`span`,{className:`h-4 w-4 animate-spin rounded-full border-2 border-primary/30 border-t-primary`})})}function mv(){let e=q(),t=J(),{user:n,logout:r}=cu(),i=yr(),{t:a}=V(),s=Vn(),c=Mn(),{info:l}=yg();x(()=>{document.title=l===null?`CamStack Admin`:`${l.name} \u00b7 CamStack Admin`},[l]);let u=Kc(U_()),[d,m]=C(!1);x(()=>{Z_(e.pathname+e.search)},[e.pathname,e.search]);let[h,g]=C(()=>typeof window>`u`?!1:window.localStorage.getItem(`camstack:sidebar-collapsed`)===`1`);x(()=>{typeof window>`u`||window.localStorage.setItem(`camstack:sidebar-collapsed`,h?`1`:`0`)},[h]);let[_]=C(()=>{if(typeof window>`u`)return new Set;try{let e=window.localStorage.getItem(`camstack: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}});x(()=>{typeof window>`u`||window.localStorage.setItem(`camstack:sidebar-collapsed-groups`,JSON.stringify([..._]))},[_]),x(()=>{c&&window.localStorage.getItem(`camstack:sidebar-collapsed`)===null&&g(!0)},[c]);let{data:y=[]}=er({nodeId:`hub`},{refetchInterval:3e4}),S=y.length,w=M(),T=f(Date.now()),{data:E}=ci(void 0,{staleTime:0,refetchOnMount:`always`,refetchInterval:e=>{let t=e.state.data;return t&&t.length>0||Date.now()-T.current>=3e4?!1:2e3}}),D=p(()=>E&&n?.isAdmin?dh(E):[],[E,n?.isAdmin]),O=p(()=>K_(D),[D]),k=O.known.get(`detection`)??[],A=O.known.get(`cluster`)??[],j=O.known.get(`administration`)??[];Sr(`addon.page-ready`,()=>{w.invalidateQueries({queryKey:[[`addonPages`,`listPages`]]})});let N=()=>{r(),t(`/login`)},F=t=>!!(e.pathname===t||e.pathname.startsWith(t+`/`)),I=[`/system/pipeline`,`/live`,`/addon/osd-manager`,`/build`].some(t=>e.pathname===t||e.pathname.startsWith(t+`/`)),ee=n?.isAdmin===!0,L=p(()=>Sh({t:a,isAdmin:ee}),[a,ee]),ne=L[0]?.items??[],re=L[1]?.items??[],ie=L[2]?.items??[],ae=L[3]?.items??[],oe=i?.mode??`system`,se={dark:a(`theme.dark`),light:a(`theme.light`),system:a(`theme.system`)},R=h&&!s,ce=(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`}`,le=(e,t)=>e===0?null:R?b(`div`,{className:`pt-3 mb-1 mx-2 border-t border-border/60`},`sep-${t}`):b(`div`,{className:`pt-4 pb-1.5 px-2.5`,children:b(`span`,{className:`text-[10px] font-semibold uppercase tracking-widest text-foreground-subtle/60`,children:t})},`hdr-${t}`),ue=e=>{let n=F(e.path),r=wh(e.icon);return o(`button`,{onClick:()=>{t(e.path),m(!1)},className:ce(n),title:R?e.label:void 0,children:[b(r,{className:`h-3.5 w-3.5 shrink-0 ${n?`text-primary`:``}`}),!R&&e.label]},`${e.addonId}::${e.id}`)},de=e=>e.requiresCapability===void 0?fe(e,!1):b(kh,{capability:e.requiresCapability,children:t=>fe(e,t)},e.path),fe=(e,n)=>{let r=e.icon,i=F(e.path),s=e.path===`/system/addons`;return o(`button`,{"data-testid":`nav-${e.path.replace(/^\//,``).replace(/\//g,`-`)}`,onClick:()=>{t(e.path),m(!1)},className:ce(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:[b(r,{className:`h-3.5 w-3.5 shrink-0 ${i?`text-primary`:``}`}),!R&&o(P,{children:[b(`span`,{className:`flex-1 text-left`,children:e.label}),s&&S>0&&b(`span`,{className:`ml-auto rounded-full bg-primary px-1.5 py-0.5 text-[9px] font-bold text-primary-foreground leading-none`,children:S})]}),R&&s&&S>0&&b(`span`,{className:`absolute mt-[-14px] ml-3 h-2 w-2 rounded-full bg-primary`})]},e.path)},pe=o(P,{children:[o(`div`,{className:`flex h-14 items-center border-b border-border ${R?`justify-center px-1`:`pl-3 pr-4 gap-2`}`,children:[!R&&b(`img`,{src:i?.resolvedMode===`light`?z(`/brand/logo-horizontal-light.svg`):z(`/brand/logo-horizontal-dark.svg`),alt:a(`layouts.appLayout.camstackAdmin`,`CamStack Admin`),className:`h-9 flex-1 min-w-0`}),!s&&b(`button`,{onClick:()=>g(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":h?a(`layouts.appLayout.expandSidebar`,`Expand sidebar`):a(`layouts.appLayout.collapseSidebar`,`Collapse sidebar`),title:h?a(`layouts.appLayout.expandSidebar`,`Expand sidebar`):a(`layouts.appLayout.collapseSidebar`,`Collapse sidebar`),children:b(h?ve:te,{className:`h-4 w-4`})})]}),!R&&l!==null&&b(`div`,{"data-testid":`sidebar-server-name`,title:l.name,className:`truncate border-b border-border px-3 py-1.5 text-xs font-medium text-foreground-muted`,children:l.name}),b(`div`,{className:`border-b border-border pt-2`,children:b(cg,{navSections:L,addonPages:D,compact:R,onNavigated:()=>m(!1)})}),o(`nav`,{className:`flex-1 overflow-y-auto py-3 ${R?`px-1.5`:`px-2`} space-y-0.5`,children:[ne.map(e=>de(e)),le(re.length+k.length,a(`nav.detectionSection`,`Detection`)),re.map(e=>de(e)),k.map(e=>ue(e)),le(ie.length+A.length,a(`nav.clusterSection`,`Cluster`)),ie.map(e=>de(e)),A.map(e=>ue(e)),le(ae.length+j.length,a(`system.title`,`Administration`)),ae.map(e=>de(e)),j.map(e=>ue(e)),O.custom.map(e=>o(`div`,{className:`contents`,children:[le(e.pages.length,e.label),e.pages.map(e=>ue(e))]},`custom-${e.id}`)),le(O.ungrouped.length,a(`nav.addonPages`,`Addon Pages`)),O.ungrouped.map(e=>ue(e))]}),o(`div`,{className:`border-t border-border ${R?`p-1.5`:`p-2`} space-y-0.5`,children:[o(`button`,{onClick:()=>i?.toggleMode(),className:ce(!1),title:R?se[oe]:void 0,children:[(()=>{let e=fv[oe];return b(e,{className:`h-3.5 w-3.5 shrink-0`})})(),!R&&b(`span`,{children:se[oe]})]}),b(B_,{variant:`sidebar`,compact:R}),o(`button`,{type:`button`,onClick:()=>t(`/system/my-access`),className:ce(F(`/system/my-access`)),title:R?a(`system.myAccess`,`My access`):void 0,children:[b(qe,{className:`h-3.5 w-3.5 shrink-0`}),!R&&b(`span`,{className:`truncate`,children:a(`system.myAccess`,`My access`)})]}),o(`button`,{onClick:N,className:ce(!1).replace(`hover:text-foreground`,`hover:text-danger`),title:R?n?.username??a(`layouts.appLayout.logout`,`Logout`):void 0,children:[b(vn,{className:`h-3.5 w-3.5 shrink-0`}),!R&&b(`span`,{className:`truncate`,children:n?.username??a(`layouts.appLayout.user`,`User`)})]}),b(sv,{placement:`sidebar`,compact:R})]})]});return o(`div`,{className:`flex h-dvh overflow-hidden bg-background text-foreground pt-[env(safe-area-inset-top)] pb-[env(safe-area-inset-bottom)]`,children:[!s&&b(`aside`,{className:`flex flex-col border-r border-border bg-surface/80 backdrop-blur-sm shrink-0 transition-[width] duration-150 ease-out ${R?`w-12`:`w-48`}`,children:pe}),s&&b(jn,{open:d,onClose:()=>m(!1),width:`w-64`,children:pe}),o(`div`,{className:`flex flex-1 flex-col min-w-0`,children:[u!==null&&o(`div`,{className:`flex items-center justify-center gap-2 px-3 py-2 text-[12px] font-medium shrink-0 ${u.severity===`danger`?`bg-danger/90 text-white`:`bg-warning/15 text-warning border-b border-warning/30`}`,children:[u.severity===`danger`?b(ge,{className:`h-3.5 w-3.5`}):b(Xe,{className:`h-3.5 w-3.5`}),b(`span`,{children:a(u.i18nKey,{defaultValue:u.message,...u.i18nParams})}),u.action===`sign-in`&&b(`button`,{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`)}),u.showSpinner&&b(Me,{className:`h-3.5 w-3.5 animate-spin`})]}),b(_g,{}),b(Eg,{}),b(H_,{}),s&&o(`header`,{className:`flex items-center h-12 border-b border-border px-3 shrink-0 bg-surface/80 backdrop-blur-sm`,children:[b(`button`,{onClick:()=>m(!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:b(Ie,{className:`h-5 w-5`})}),b(`div`,{className:`flex-1 flex justify-center`,children:b(`img`,{src:i?.resolvedMode===`light`?z(`/brand/logo-horizontal-light.svg`):z(`/brand/logo-horizontal-dark.svg`),alt:a(`layouts.appLayout.camstack`,`CamStack`),className:`h-7`})}),b(B_,{})]}),o(Ah,{children:[b(Mh,{}),b(`main`,{className:`relative flex-1 min-h-0 overscroll-contain bg-background ${I?`overflow-hidden`:`overflow-auto`}`,children:b(lh,{resetKey:e.pathname,children:b(v,{fallback:b(pv,{}),children:b(dv,{})})})})]})]})]})}function $({children:e,requireAdmin:t}){let{t:n}=V(),{user:r,loading:i,mustChangePassword:a}=cu(),o=q();return i?b(`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`?b(Y,{to:`/change-password`,replace:!0}):t&&!r.isAdmin?b(Y,{to:`/access-denied`,replace:!0}):b(P,{children:e}):b(Y,{to:`/login`,replace:!0,state:{from:o.pathname+o.search}})}var hv=`customize`,gv=`/build/compositions/new`,_v=`/build/compositions/:blockId`,vv=`/build?tab=custom-device`;function yv(e){return`/devices/${e}`}function bv(e){return`/devices/${e}?tab=${hv}`}var xv=`integration`,Sv=`section`,Cv=[xv,Sv],wv={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`}},Tv=`settings`,Ev=`activity`;function Dv(e,t={}){let{path:n,tab:r}=wv[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(xv,t.integration),t.section!==void 0&&i.set(Sv,t.section);let a=i.toString();return a.length>0?`${n}?${a}`:n}function Ov(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 kv(e,t,n=null,r=null){let i=new URLSearchParams(e);return i.set(xv,t),r===null?i.delete(Sv):i.set(Sv,r),n!==null&&i.delete(n),i}function Av(e){return e===`/admin`||e===`/admin/`?`/`:e.startsWith(`/admin/`)?e.slice(6):e}function jv(){let{t:e}=V(),t=J();return o(`div`,{className:`flex flex-col items-center justify-center text-foreground py-16 px-4`,children:[b(`div`,{className:`flex h-16 w-16 items-center justify-center rounded-2xl bg-danger/10 mb-4`,children:b(_n,{className:`h-8 w-8 text-danger`})}),b(`h1`,{className:`text-xl font-bold`,children:e(`accessDenied.accessDenied`,`Access Denied`)}),b(`p`,{className:`mt-2 text-sm text-foreground-subtle`,children:e(`accessDenied.youDonTHavePermission`,`You don't have permission to access this page.`)}),b(`button`,{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`)})]})}var Mv=`auth.password-incorrect`;function Nv(e,t){return typeof e==`object`&&e?Reflect.get(e,t):void 0}function Pv(e){if(!(e instanceof Error))return{kind:`connection-lost`};let t=Nv(e,`data`);return typeof t!=`object`||!t?{kind:`connection-lost`}:Nv(Nv(t,`i18n`),`code`)===Mv?{kind:`wrong-current`}:Nv(t,`code`)===`UNAUTHORIZED`?{kind:`session-ended`}:{kind:`rejected`,message:e.message}}D();var Fv=8;function Iv(e,t){let n=Pv(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 Lv(){let{t:e}=V(),{user:t,mustChangePassword:n,clearMustChangePassword:r,logout:i}=cu(),a=Ae(),s=yr(),c=J(),[l,u]=C(``),[d,f]=C(``),[p,m]=C(``),[h,g]=C(!1),[_,v]=C(``),[y,x]=C(!1),S=n?Ql:l;return b(`div`,{className:`flex min-h-screen items-center justify-center bg-background p-4`,children:o(`div`,{className:`w-full max-w-sm`,children:[b(`div`,{className:`flex justify-center mb-8`,children:b(`img`,{src:s?.resolvedMode===`light`?z(`/brand/logo-horizontal-light.svg`):z(`/brand/logo-horizontal-dark.svg`),alt:e(`changePassword.camstackAdmin`,`CamStack Admin`),className:`h-12`})}),o(`form`,{onSubmit:async i=>{if(i.preventDefault(),v(``),!t){v(`Not signed in`);return}if(!n&&l.length===0){v(e(`changePassword.enterCurrent`,`Enter your current password`));return}if(d.length<Fv){v(`Password must be at least ${Fv} characters`);return}if(d!==p){v(`The two passwords do not match`);return}if(d===`changeme`){v(`Choose a password different from the seed default`);return}x(!0);try{await a.changeOwnPassword({currentPassword:S,newPassword:d}),r(),c(`/devices`,{replace:!0})}catch(t){v(Iv(t,e))}finally{x(!1)}},className:`space-y-4 rounded-xl border border-border bg-surface p-6 shadow-xl shadow-black/10`,children:[o(`div`,{className:`space-y-1`,children:[b(`h1`,{className:`text-sm font-semibold text-foreground`,children:e(`changePassword.setANewPassword`,`Set a new password`)}),b(`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.`)})]}),_&&b(`div`,{role:`alert`,className:`rounded-md bg-danger/10 border border-danger/20 px-3 py-2 text-xs text-danger`,children:_}),!n&&o(`div`,{className:`space-y-1.5`,children:[b(`label`,{className:`text-xs font-medium text-foreground-subtle`,children:e(`changePassword.currentPassword`,`Current password`)}),b(`input`,{"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})]}),o(`div`,{className:`space-y-1.5`,children:[b(`label`,{className:`text-xs font-medium text-foreground-subtle`,children:e(`changePassword.newPassword`,`New password`)}),o(`div`,{className:`relative`,children:[b(`input`,{"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}),b(`button`,{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:b(h?ie:xe,{className:`h-4 w-4`})})]})]}),o(`div`,{className:`space-y-1.5`,children:[b(`label`,{className:`text-xs font-medium text-foreground-subtle`,children:e(`changePassword.confirmNewPassword`,`Confirm new password`)}),b(`input`,{"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`})]}),b(`button`,{"data-testid":`change-password-submit`,type:`submit`,disabled:y||!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:y?e(`changePassword.saving`,`Saving…`):e(`changePassword.saveAndContinue`,`Save and continue`)}),n&&b(`button`,{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`)})]})]})})}function Rv(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 zv(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 Bv(){return window?.PublicKeyCredential!==void 0&&typeof window.PublicKeyCredential==`function`}function Vv(e){let{id:t}=e;return{...e,id:zv(t),transports:e.transports}}function Hv(e){return e===`localhost`||/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(e)}var Uv=class extends Error{constructor({message:e,code:t,cause:n,name:r}){super(e,{cause:n}),this.name=r??n.name,this.code=t}},Wv=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}}},Gv=[`cross-platform`,`platform`];function Kv(e){if(e&&!(Gv.indexOf(e)<0))return e}function qv(){if(!Bv())return new Promise(e=>e(!1));let e=window.PublicKeyCredential;return e.isConditionalMediationAvailable===void 0?new Promise(e=>e(!1)):e.isConditionalMediationAvailable()}function Jv({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 Uv({message:`Authentication ceremony was sent an abort signal`,code:`ERROR_CEREMONY_ABORTED`,cause:e})}else if(e.name===`NotAllowedError`)return new Uv({message:e.message,code:`ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY`,cause:e});else if(e.name===`SecurityError`){let t=window.location.hostname;if(!Hv(t))return new Uv({message:`${window.location.hostname} is an invalid domain`,code:`ERROR_INVALID_DOMAIN`,cause:e});if(n.rpId!==t)return new Uv({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 Uv({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 Yv(e){let{optionsJSON:t,useBrowserAutofill:n=!1,verifyBrowserAutofillInput:r=!0}=e;if(!Bv())throw Error(`WebAuthn is not supported in this browser`);let i;t.allowCredentials?.length!==0&&(i=t.allowCredentials?.map(Vv));let a={...t,challenge:zv(t.challenge),allowCredentials:i},o={};if(n){if(!await qv())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=Wv.createNewAbortSignal();let s;try{s=await navigator.credentials.get(o)}catch(e){throw Jv({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=Rv(u.userHandle)),{id:c,rawId:Rv(l),response:{authenticatorData:Rv(u.authenticatorData),clientDataJSON:Rv(u.clientDataJSON),signature:Rv(u.signature),userHandle:f},type:d,clientExtensionResults:s.getClientExtensionResults(),authenticatorAttachment:Kv(s.authenticatorAttachment)}}function Xv(e){return typeof e==`object`&&!!e}function Zv(e){return Xv(e)&&typeof e.challenge==`string`}D();async function Qv(e){if(!Zv(e))throw Error(`passkey authentication options missing challenge`);let t=await Yv({optionsJSON:e});return Object.fromEntries(Object.entries(t))}function $v({method:e,challengeToken:t,onComplete:n,onSecondFactor:r,onError:i}){let[a,s]=C(!1),[c,l]=C(null),u=async()=>{l(null),s(!0);try{let e=Z();if(t){let r=await Qv((await e.loginBeginPasskey(t)).optionsJSON),i=await e.loginVerifyPasskey(t,r,{refreshable:!0});n(i.token,i);return}let a=await Qv((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{s(!1)}};return o(`div`,{className:`space-y-2`,children:[o(`button`,{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?b(Me,{className:`h-4 w-4 animate-spin text-primary`}):b(cn,{className:`h-4 w-4 text-primary`}),e.label]}),c&&b(`div`,{className:`rounded-md bg-danger/10 border border-danger/20 px-3 py-2 text-xs text-danger`,children:c})]})}var ey=()=>window.location.hostname;function ty(e,t=ey){return Bv()&&dg(t(),e.rpId)}function ny(e,t=ey){let n=e.filter(e=>e.kind===`passkey`&&e.stage===`second-factor`).filter(e=>ty(e,t));return{passkeyMethods:n,widgetMethods:n.length>0?[]:e.filter(e=>e.kind===`widget`&&e.stage===`second-factor`)}}function ry(e,t){let n=e.includes(`passkey`),r=t.passkeyMethods.length>0||t.widgetMethods.length>0,i=e.includes(`totp`);return n&&!r&&!i}function iy(e){let t=e.onComplete,n=e.onSecondFactor;return typeof t==`function`?{onComplete:t,onSecondFactor:typeof n==`function`?n:void 0}:null}function ay({methods:e,widgetConfig:t,onRedirect:n}){let{t:r}=V();or();let i=e.filter(e=>e.kind!==`passkey`||ty(e));return i.length===0?null:o(`div`,{className:`mt-6 space-y-3`,children:[o(`div`,{className:`flex items-center gap-3`,children:[b(`div`,{className:`h-px flex-1 bg-border`}),b(`span`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle`,children:r(`login.primaryLoginMethods.orContinueWith`,`Or continue with`)}),b(`div`,{className:`h-px flex-1 bg-border`})]}),b(`div`,{className:`space-y-2`,children:i.map(e=>{if(e.kind===`redirect`){let t=(e.icon===void 0?void 0:An(e.icon))??qe;return o(`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:[b(t,{className:`h-4 w-4 text-primary`}),e.label]},e.id)}if(e.kind===`passkey`){let n=iy(t);return n?b($v,{method:e,onComplete:n.onComplete,onSecondFactor:n.onSecondFactor},e.id):null}return b(oy,{method:e,config:t},e.id)})})]})}function oy({method:e,config:t}){let{t:n}=V(),r=In(e.remote,e.bundleUrl);return r===null?o(`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:[b(Me,{className:`h-3.5 w-3.5 animate-spin`}),n(`common.loading`,`Loading…`)]}):r===void 0?o(`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:[b(nt,{className:`h-3.5 w-3.5 shrink-0`}),n(`login.primaryMethods.loadFailed`)]}):b(r,{instanceId:e.id,host:`dashboard`,config:t})}var sy=4e3,cy=/^[A-Za-z0-9._-]{1,64}$/;function ly(e){let t=e.addonId!==void 0&&cy.test(e.addonId)?e.addonId:null,n=e.integration!==void 0&&cy.test(e.integration)?e.integration:null;if(t!==null&&e.brokerId!==void 0)return Dv(`connectivity`,{integration:t,kindSection:`brokers`});let r=n??t;return Dv(`connectivity`,r===null?{}:{integration:r})}function uy(e,t){let n=t.opener;if(n===null||n.closed||i_(n)!==t.origin)return!1;try{return n.postMessage({type:m_,ok:e.status===`success`,...e.brokerId===void 0?{}:{brokerId:e.brokerId},...e.status===`error`?{error:e.reason??`unknown`}:{}},t.origin),!0}catch{return!1}}D();var dy=500;function fy(e){let{t}=V();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_refresh_token`:return t(`oauthLanding.reason.no_refresh_token`,`The provider returned no long-lived access. Remove CamStack 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 py({outcome:e}){let{t}=V(),n=fy(e.reason??`unknown`);if(e.status===`error`)return o(P,{children:[b(Ke,{className:`mx-auto h-8 w-8 text-danger`,"aria-hidden":!0}),b(`h1`,{"data-testid":`oauth-landing-title`,className:`text-sm font-semibold text-foreground`,children:t(`oauthLanding.errorTitle`,`Sign-in did not finish`)}),b(`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})]});let r=e.action===`disconnect`;return o(P,{children:[b(rt,{className:`mx-auto h-8 w-8 text-success`,"aria-hidden":!0}),b(`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`)}),b(`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 CamStack…`)})]})}function my({outcome:e,closable:t,onContinue:n,onClose:r}){let{t:i}=V(),a=ly(e);return x(()=>{if(e.status!==`success`)return;let t=window.setTimeout(()=>n(a),sy);return()=>window.clearTimeout(t)},[e.status,n,a]),b(`main`,{className:`flex min-h-screen items-center justify-center bg-background p-4`,children:o(`div`,{className:`w-full max-w-sm space-y-4`,children:[b(`div`,{className:`flex justify-center`,children:o(`picture`,{children:[b(`source`,{media:`(prefers-color-scheme: dark)`,srcSet:z(`/brand/logo-horizontal-dark.svg`)}),b(`img`,{src:z(`/brand/logo-horizontal-light.svg`),alt:i(`oauthLanding.brand`,`CamStack`),className:`h-12`})]})}),o(`div`,{className:`space-y-4 rounded-xl border border-border bg-surface p-6 text-center shadow-xl shadow-black/10`,children:[b(py,{outcome:e}),o(`div`,{className:`flex flex-col gap-2`,children:[b(Cr,{type:`button`,variant:`primary`,onClick:()=>n(a),children:i(`oauthLanding.back`,`Back to CamStack`)}),t&&b(Cr,{type:`button`,variant:`ghost`,onClick:r,children:i(`oauthLanding.close`,`Close this window`)})]})]})]})})}function hy(e,t){window.history.replaceState(null,``,window.location.pathname);let n=window.opener,r=uy(t,{opener:n,origin:window.location.origin}),i=()=>e.render(b(my,{outcome:t,closable:r,onContinue:e=>window.location.replace(z(e)),onClose:()=>window.close()}));if(r&&t.status===`success`){window.close(),window.setTimeout(i,dy);return}i()}function gy(e){return Xt(e)}var _y=`Done — you can close this window.`,vy=500,yy=`camstack_admin_token`;async function by(e,t=``){try{let n=_l(new URLSearchParams(t));n!==null&&n.token===e?hl(n):localStorage.setItem(yy,e)}catch{}await fetch(z(`/api/auth/session`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({token:e})}).catch(()=>{})}function xy(){try{let e=localStorage.getItem(yy);return e!==null&&e.length>0?e:null}catch{return null}}function Sy(e){let t=gy(window.location.hash);if(t!==null){hy(e,t);return}let n=Gg(window.location.hash);window.history.replaceState(null,``,window.location.pathname);let r=t=>e.render(b(Cy,{completion:n,result:t}));if(r(null),n===null)return;let i=a_();f_(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:_y}),vy)},continueAt:e=>window.location.replace(z(e)),persistSession:e=>by(e,n.target===`login`?n.fragment:``),showResult:r,setTimeout:(e,t)=>window.setTimeout(e,t)})}function Cy({completion:e,result:t}){let{t:n}=V();return b(`div`,{className:`flex min-h-screen items-center justify-center bg-background p-4`,children:b(`div`,{className:`flex flex-col items-center gap-3 text-sm text-foreground-subtle`,children:e===null?b(`a`,{className:`text-primary underline`,href:z(`/login`),children:n(`ssoComplete.nothingToFinishHereGo`,`Nothing to finish here — go to sign-in`)}):t===null?o(`span`,{className:`flex items-center gap-3`,children:[b(`span`,{className:`h-4 w-4 animate-spin rounded-full border-2 border-primary/30 border-t-primary`}),n(`ssoComplete.finishingSignIn`,`Finishing sign-in…`)]}):o(P,{children:[b(`span`,{"data-testid":`sso-complete-result`,className:t.kind===`link-error`?`text-danger`:`text-foreground`,children:t.message}),b(`button`,{type:`button`,className:`rounded-md border border-border px-3 py-1.5 text-foreground hover:bg-surface-hover`,onClick:()=>window.close(),children:n(`ssoComplete.closeThisWindow`,`Close this window`)})]})})})}D();function wy(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 Ty(){let e=new URLSearchParams(window.location.search);return Ml({codeChallenge:e.get(`code_challenge`),codeChallengeMethod:e.get(`code_challenge_method`),state:e.get(`state`),purpose:e.get(`purpose`)})}function Ey(e){return Math.min(1e3*2**e,15e3)}function Dy(){let{t:e}=V(),{login:t,verifyTotp:n,finalizePasskeyLogin:r,user:i}=cu(),{i18n:a}=V(),s=yr(),c=J(),l=q(),u=new URLSearchParams(window.location.search).get(`next`);x(()=>{Vl(u)},[u]);let d=new URLSearchParams(window.location.search).get(`redirect`);x(()=>{Xl(d)},[d]);let p=Ty();x(()=>{Fl(p)},[p?.codeChallenge,p?.state,p?.purpose]);let m=l.state,h=ev(m?.from),[g,_]=C(``),[v,y]=C(``),[S,w]=C(!1),[T,E]=C(``),[D,O]=C(!1),[k,A]=C(`credentials`),[j,M]=C(``),[N,F]=C([]),[I,ee]=C(``),[te,L]=C(void 0),[ne,re]=C(`sso-not-linked`),ae=$r.auth.listLoginMethods.useQuery(void 0,{retry:!0,retryDelay:Ey}),oe=ae.data===void 0,se=(ae.data??[]).filter(e=>e.kind!==`device-certificate`),R=$r.auth.getServerName.useQuery().data,ce=se.filter(e=>e.stage===`primary`),le=ny(se);x(()=>{let e=Fg(window.location.hash);if(e!==null){if(window.history.replaceState({},``,window.location.pathname+window.location.search),e.kind===`challenge`){M(e.challengeToken),F(e.factors),ee(``),A(`second-factor`);return}re(e.code),L(e.provider)}},[]);let ue=te==null?null:se.find(e=>e.id===te&&`label`in e)?.label??null,de=T||(te===void 0?``:Ig(ne,ue)),{passkeyMethods:fe,widgetMethods:pe}=le,me=f(!1),he=async()=>{if(me.current)return;me.current=!0;let e=Rl(d);if(e?.kind===`app-callback`){await ve(e.url);return}else if(e){window.location.assign(z(e.path));return}let t=Ul(u);t?window.location.assign(z(t)):c(h,{replace:!0})},[ge,_e]=C(null),ve=async e=>{_e({callbackBase:e,mintedUrl:null,failed:!1});try{let t=Ty()??Il();if(t===null)throw Error(`The app sent no PKCE challenge and state`);let{code:n}=await Z().trpcClient.auth.createHandoffCode.mutate({purpose:t.purpose,codeChallenge:t.codeChallenge,state:t.state}),r=Ll(e,n,t.state);_e({callbackBase:e,mintedUrl:r,failed:!1}),window.location.assign(r)}catch(t){if(wy(t)){me.current=!1,_e(null),E(`Sign in again to confirm it is you.`);return}_e({callbackBase:e,mintedUrl:null,failed:!0})}},ye=i!==null,[be,Se]=C(!1);x(()=>{!ye||!d&&!u||be||(Se(!0),he())},[ye,d,u,be]);let Ce=async e=>{e.preventDefault(),E(``),L(void 0),O(!0);try{let e=await t(g,v);if(e.kind===`second-factor`){M(e.challengeToken),F(e.factors),A(`second-factor`);return}v===`changeme`?c(`/change-password`,{replace:!0}):await he()}catch(e){E(e instanceof Error?e.message:`Login failed`)}finally{O(!1)}},we=async e=>{e.preventDefault(),E(``),O(!0);try{await n(j,I.trim()),await he()}catch(e){E(e instanceof Error?e.message:`TOTP verification failed`),ee(``)}finally{O(!1)}},Te=async(e,t)=>{try{await r(e,t),await he()}catch(e){E(e instanceof Error?e.message:`Passkey sign-in failed`)}},De=f(null);x(()=>()=>De.current?.(),[]);let Oe=async e=>{if(e.target!==`login`)return;let t=_l(new URLSearchParams(e.fragment));if(t!==null){try{await r(t.token,t),await he()}catch(e){E(e instanceof Error?e.message:`Sign-in failed`)}return}let n=Fg(`#${e.fragment}`);if(n!==null){if(n.kind===`challenge`){Ae({challengeToken:n.challengeToken,factors:n.factors});return}re(n.code),L(n.provider)}},ke=e=>{if(kl(d)?.kind===`app-callback`)return!1;let t=Yg(z(qg(e.startUrl)));return t===null?!1:(E(``),L(void 0),De.current?.(),De.current=s_(t,{onReturn:e=>{De.current?.(),De.current=null,Oe(e)},onDone:e=>{if(De.current?.(),De.current=null,e.target!==`login`)return;let t=xy()===null?null:ml();t!==null&&Oe({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)},Ae=e=>{let t=e.factors.filter(e=>e===`totp`||e===`passkey`);M(e.challengeToken),F(t),ee(``),E(``),A(`second-factor`)};return ge===null?b(`div`,{className:`flex min-h-screen items-center justify-center bg-background p-4`,children:o(`div`,{className:`w-full max-w-sm`,children:[b(`div`,{className:`flex justify-center mb-8`,children:b(`img`,{src:s?.resolvedMode===`light`?z(`/brand/logo-horizontal-light.svg`):z(`/brand/logo-horizontal-dark.svg`),alt:e(`login.camstackAdmin`,`CamStack Admin`),className:`h-12`})}),R!==void 0&&!R.isDefault&&b(`p`,{"data-testid":`login-server-name`,className:`-mt-4 mb-6 text-center text-sm text-foreground-muted`,children:b(rc,{i18nKey:`login.signInTo`,values:{name:R.name},components:{b:b(`span`,{className:`font-semibold text-foreground`})}})}),k===`credentials`?o(`form`,{onSubmit:Ce,className:`space-y-4 rounded-xl border border-border bg-surface p-6 shadow-xl shadow-black/10`,children:[de&&b(`div`,{"data-testid":`login-error`,className:`rounded-md bg-danger/10 border border-danger/20 px-3 py-2 text-xs text-danger`,children:de}),o(`div`,{className:`space-y-1.5`,children:[b(`label`,{className:`text-xs font-medium text-foreground-subtle`,children:e(`login.username`,`Username`)}),b(`input`,{"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})]}),o(`div`,{className:`space-y-1.5`,children:[b(`label`,{className:`text-xs font-medium text-foreground-subtle`,children:e(`login.password`,`Password`)}),o(`div`,{className:`relative`,children:[b(`input`,{"data-testid":`login-password`,type:S?`text`:`password`,placeholder:e(`login.password`,`Password`),value:v,onChange:e=>y(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`}),b(`button`,{type:`button`,onClick:()=>w(!S),className:`absolute right-2.5 top-1/2 -translate-y-1/2 text-foreground-subtle hover:text-foreground transition-colors`,tabIndex:-1,children:b(S?ie:xe,{className:`h-4 w-4`})})]})]}),b(`button`,{"data-testid":`login-submit`,type:`submit`,disabled:D||!g||!v,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?o(`span`,{className:`flex items-center justify-center gap-2`,children:[b(`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`)})]}):o(`div`,{className:`space-y-4 rounded-xl border border-border bg-surface p-6 shadow-xl shadow-black/10`,children:[o(`div`,{className:`flex items-center gap-2 pb-1 border-b border-border`,children:[b(Ee,{className:`h-4 w-4 text-primary`}),b(`div`,{className:`text-sm font-medium text-foreground`,children:e(`login.twoFactorAuthentication`,`Two-factor authentication`)})]}),b(`p`,{className:`text-xs text-foreground-subtle`,children:g?b(P,{children:b(rc,{i18nKey:`login.finishSigningInAs`,values:{username:g},components:{mono:b(`span`,{className:`font-mono text-foreground`})}})}):e(`login.finishSigningInAs`,`Finish signing in.`)}),T&&b(`div`,{className:`rounded-md bg-danger/10 border border-danger/20 px-3 py-2 text-xs text-danger`,children:T}),N.includes(`passkey`)&&fe.map(e=>b($v,{method:e,challengeToken:j,onComplete:Te},e.id)),N.includes(`passkey`)&&pe.map(e=>b(oy,{method:e,config:{challengeToken:j,onComplete:Te}},e.id)),ry(N,le)&&b(`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.`)}),N.includes(`passkey`)&&N.includes(`totp`)&&o(`div`,{className:`flex items-center gap-3`,children:[b(`div`,{className:`h-px flex-1 bg-border`}),b(`span`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle`,children:`or`}),b(`div`,{className:`h-px flex-1 bg-border`})]}),N.includes(`totp`)&&o(`form`,{onSubmit:we,className:`space-y-4`,children:[o(`div`,{className:`space-y-1.5`,children:[b(`label`,{className:`text-xs font-medium text-foreground-subtle`,children:e(`login.authenticationCode`,`Authentication code`)}),b(`input`,{"data-testid":`login-totp`,type:`text`,inputMode:`numeric`,autoComplete:`one-time-code`,placeholder:`123456`,value:I,onChange:e=>ee(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})]}),b(`button`,{"data-testid":`login-totp-submit`,type:`submit`,disabled:D||I.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?o(`span`,{className:`flex items-center justify-center gap-2`,children:[b(`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`)})]}),o(`button`,{type:`button`,onClick:()=>{A(`credentials`),M(``),F([]),ee(``),E(``)},className:`w-full flex items-center justify-center gap-1.5 text-xs text-foreground-subtle hover:text-foreground transition-colors`,children:[b(Ue,{className:`h-3 w-3`}),e(`login.backToUsernamePassword`,`Back to username + password`)]})]}),k===`credentials`&&oe&&o(`p`,{"data-testid":`login-methods-pending`,role:`status`,className:`mt-4 flex items-center justify-center gap-2 text-xs text-foreground-subtle`,children:[b(`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`&&b(ay,{methods:ce,widgetConfig:{onComplete:Te,onSecondFactor:Ae,locale:a.language},onRedirect:ke}),b(`p`,{className:`mt-6 text-center text-[10px] text-foreground-subtle/50`,children:b(sv,{placement:`login`})})]})}):b(`div`,{className:`flex min-h-screen items-center justify-center bg-background p-4`,children:o(`div`,{className:`w-full max-w-sm rounded-xl border border-border bg-surface p-6 text-center space-y-4`,children:[b(`h1`,{className:`text-sm font-semibold text-foreground`,children:e(`login.returningToTheApp`,`Returning to the app…`)}),ge.failed?o(P,{children:[b(`p`,{className:`text-xs text-danger`,children:e(`login.couldNotPrepareTheSign`,`Could not prepare the sign-in handoff. You are logged in — retry below.`)}),b(`button`,{onClick:()=>void ve(ge.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`)})]}):ge.mintedUrl===null?b(`p`,{className:`text-xs text-foreground-subtle`,children:e(`login.preparingAOneTimeSign`,`Preparing a one-time sign-in code…`)}):o(P,{children:[b(`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).`)}),b(`a`,{href:ge.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.openCamstack`,`Open CamStack`)})]})]})})}D();function Oy(){let{pathname:e,search:t,hash:n}=q();return b(Y,{to:`${Av(e)}${t}${n}`,replace:!0})}function ky(){return b(Y,{to:Q_()??`/devices`,replace:!0})}var Ay=h(()=>i(()=>import(`./Devices-D38AMunx.js`).then(e=>({default:e.DevicesPage})),__vite__mapDeps([0,1,2,3,4,5,6,7,8]),import.meta.url)),jy=h(()=>i(()=>import(`./Integrations-C-JT0QSz.js`).then(e=>({default:e.IntegrationsPage})),__vite__mapDeps([9,1,2,3,4,10,5,11,6,12,13,14,15,7,8,16]),import.meta.url)),My=h(()=>i(()=>import(`./IntegrationDetail-X94WkFek.js`).then(e=>({default:e.IntegrationDetailPage})),__vite__mapDeps([17,1,2,3,4,18,5,12,13,10,14,15,19,7,20]),import.meta.url)),Ny=h(()=>i(()=>import(`./Pipeline-BdjiguQv.js`).then(e=>({default:e.PipelinePage})),__vite__mapDeps([21,1,2,3,4,10,5,22,23,24,25,19,26,27,8]),import.meta.url)),Py=h(()=>i(()=>import(`./DeviceDetail-BejggRfL.js`).then(e=>({default:e.DeviceDetailPage})),__vite__mapDeps([28,1,2,3,4,10,5,29,30,31,32,33,22,34,35,25,36,37,38,39,40,41,26,42,8,43,15,44]),import.meta.url)),Fy=h(()=>i(()=>import(`./Showroom-hqqCXmrT.js`).then(e=>({default:e.ShowroomPage})),__vite__mapDeps([45,1,2,3,4]),import.meta.url)),Iy=h(()=>i(()=>import(`./EmbedPlayerPage-BBZB_KmG.js`).then(e=>({default:e.EmbedPlayerPage})),__vite__mapDeps([46,1,2,3,4,5]),import.meta.url)),Ly=h(()=>i(()=>import(`./Library-BrvU57J_.js`).then(e=>({default:e.LibraryPage})),__vite__mapDeps([47,1,2,3,4,10,5,48,22,24,49,50,39,51,43,15]),import.meta.url)),Ry=h(()=>i(()=>import(`./Recordings-BnGaDgIg.js`).then(e=>({default:e.RecordingsPage})),__vite__mapDeps([52,1,2,3,4,10,5,53,50,54,29,55,56,57,43,15]),import.meta.url)),zy=h(()=>i(()=>import(`./Viewer-zU0ym-3m.js`).then(e=>({default:e.ViewerPage})),__vite__mapDeps([58,2,3,4,59,5,15,1]),import.meta.url)),By=h(()=>i(()=>import(`./Build-DYS91I2j.js`).then(e=>({default:e.BuildPage})),__vite__mapDeps([60,1,2,3,4,10,5,33,61,22,50,62,36,32,37,38,40,44]),import.meta.url)),Vy=h(()=>i(()=>import(`./CompositionEditorPage-BI-Y8v0_.js`).then(e=>({default:e.CompositionEditorPage})),__vite__mapDeps([63,1,2,3,4,33,5,6,62,36,10,32,37,38]),import.meta.url)),Hy=h(()=>i(()=>import(`./Locations-BXbmZQwL.js`).then(e=>({default:e.LocationsPage})),__vite__mapDeps([64,1,2,3,4,10,5,33,65,49,50,41,37,38]),import.meta.url)),Uy=h(()=>i(()=>import(`./Addons-BbTJ2Fig.js`).then(e=>({default:e.AddonsPage})),__vite__mapDeps([66,1,2,3,4,22,5,6,19,67,16,15]),import.meta.url)),Wy=h(()=>i(()=>import(`./AiProfiles-Z0lIY6qW.js`).then(e=>({default:e.AiProfilesPage})),__vite__mapDeps([68,1,2,3,4,10,5,69,70,6,50,15]),import.meta.url)),Gy=h(()=>i(()=>import(`./MyAccess-DfkZc8jj.js`).then(e=>({default:e.MyAccessPage})),__vite__mapDeps([71,1,2,3,4,10,5,22,72,73,74,75,6,50,76,15]),import.meta.url)),Ky=h(()=>i(()=>import(`./Logs-B0XBZZ8Q.js`).then(e=>({default:e.LogsPage})),__vite__mapDeps([77,1,2,3,4,78,25,5,6,50,79,80,19,81,20,15,82]),import.meta.url)),qy=h(()=>i(()=>import(`./Identity-Dtc3gsXQ.js`).then(e=>({default:e.IdentityPage})),__vite__mapDeps([83,1,2,3,4,10,5,84,22,35,72,73,75,6,50,79,80,19,81,20,15,76,82]),import.meta.url)),Jy=h(()=>i(()=>import(`./Network-B9UvgIh-.js`).then(e=>({default:e.NetworkPage})),__vite__mapDeps([85,1,2,3,4,10,5,33,22,14,6,50,79,80,19,81,20,15,82]),import.meta.url)),Yy=h(()=>i(()=>import(`./Integrations-BlD0JmVC.js`).then(e=>({default:e.IntegrationsPage})),__vite__mapDeps([86,1,2,3,4,10,5,22,14,73,87,50,79,80,6,19,81,20,15,13]),import.meta.url)),Xy=h(()=>i(()=>import(`./Data-B-pDPXqV.js`).then(e=>({default:e.DataPage})),__vite__mapDeps([88,1,2,3,4,10,5,89,34,56,6,50,54,29,55,57,43,15]),import.meta.url)),Zy=h(()=>i(()=>import(`./System-C9oV_d1y.js`).then(e=>({default:e.SystemPage})),__vite__mapDeps([90,1,2,3,4,10,5,22,72,6,50,19,81,20,15]),import.meta.url)),Qy=h(()=>i(()=>import(`./Cluster-MhCZmNm6.js`).then(e=>({default:e.ClusterPage})),__vite__mapDeps([91,1,2,3,4,10,5,56,92,75,6,19,27,67,57]),import.meta.url)),$y=h(()=>i(()=>import(`./Terminal-C2kXj9wO.js`).then(e=>({default:e.TerminalPage})),__vite__mapDeps([93,1,2,3,4,22,5,6,19,94]),import.meta.url)),eb=h(()=>i(()=>import(`./Notifications-2R56_ebY.js`).then(e=>({default:e.NotificationsPage})),__vite__mapDeps([95,1,2,3,4,10,5,31,22,69,96,6,50,40,51,15,38]),import.meta.url)),tb=h(()=>i(()=>import(`./History-v659n-q1.js`).then(e=>({default:e.HistoryPage})),__vite__mapDeps([97,1,2,3,4,5,6]),import.meta.url)),nb=h(()=>i(()=>import(`./Calendars-B70yeC96.js`).then(e=>({default:e.CalendarsPage})),__vite__mapDeps([98,1,2,3,4,10,5,22,6]),import.meta.url)),rb=h(()=>i(()=>import(`./Templates-cp28J05t.js`).then(e=>({default:e.TemplatesPage})),__vite__mapDeps([99,1,2,3,4,22,100,5,6,42]),import.meta.url)),ib=new E({defaultOptions:{queries:{gcTime:0,staleTime:0,retry:!1,refetchOnWindowFocus:!1}}});Yr(ib);function ab({field:e,value:t,onChange:n,disabled:r}){return b(Im,{field:e,value:t,onChange:n,disabled:r})}var ob={"model-selector":ab};function sb({children:e}){let{t}=V(),{user:n,logout:r}=cu(),[i,a]=C(0),s=f(n?.username??null);x(()=>{let e=n?.username??null;e!==s.current&&(s.current=e,cl(),a(e=>e+1))},[n]);let c=p(()=>Z(),[i]),l=y(()=>{Z().reconnect(),a(e=>e+1),ib.invalidateQueries()},[]);ah(y(()=>El(l),[l])),x(()=>Sl(()=>{Z().isSocketTokenStale()&&l()}),[l]);let u=y(async()=>{let e=await Dl();return e&&l(),e},[l]),{bootReady:d,bootError:m}=rh(c,n??null,r,u);return b(eh,{children:b(He,{system:c,children:b($r.Provider,{client:c.trpcClient,queryClient:ib,children:o(Kr,{children:[b(ar,{children:b(Lr,{children:b(sr,{children:d?e:b(cb,{})})})}),d&&b(Hm,{}),m!==null&&d&&o(`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 cb(){let{t:e}=V();return b(`div`,{className:`flex min-h-screen items-center justify-center bg-background`,children:o(`div`,{className:`flex items-center gap-3 text-sm text-foreground-subtle`,children:[b(`span`,{className:`h-4 w-4 animate-spin rounded-full border-2 border-primary/30 border-t-primary`}),e(`app.connecting`,`Connecting…`)]})})}function lb(){return b(`div`,{className:`flex min-h-screen items-center justify-center bg-background`,children:b(`span`,{className:`h-4 w-4 animate-spin rounded-full border-2 border-primary/30 border-t-primary`})})}function ub(){return b(Rr,{defaultMode:`dark`,children:b(rr,{children:b(N,{client:ib,children:b(su,{children:b(sb,{children:b(Le,{children:b(Vm,{children:o(ei,{renderers:ob,children:[b(ps,{basename:Ye(),children:b(Am,{children:b(v,{fallback:b(lb,{}),children:o(wo,{children:[b(X,{path:`/login`,element:b(Dy,{})}),b(X,{path:`/admin/*`,element:b(Oy,{})}),b(X,{path:`/admin`,element:b(Oy,{})}),b(X,{path:`/change-password`,element:b($,{children:b(Lv,{})})}),b(X,{path:`/showroom`,element:b(Fy,{})}),b(X,{path:`/embed/player`,element:b(Iy,{})}),o(X,{element:b($,{children:b(Oi,{children:b(mv,{})})}),children:[b(X,{index:!0,element:b(ky,{})}),b(X,{path:`/access-denied`,element:b(jv,{})}),b(X,{path:`/dashboard`,element:b(Y,{to:`/devices`,replace:!0})}),b(X,{path:`/devices`,element:b(Ay,{})}),b(X,{path:`/cameras`,element:b(Y,{to:`/devices`,replace:!0})}),b(X,{path:`/integrations`,element:b(jy,{})}),b(X,{path:`/integrations/:addonId`,element:b(My,{})}),b(X,{path:`/system/pipeline`,element:b(Dh,{path:`/system/pipeline`,children:b(Ny,{})})}),b(X,{path:`/pipeline`,element:b(Y,{to:`/system/pipeline`,replace:!0})}),b(X,{path:`/live`,element:b(zy,{})}),b(X,{path:`/devices/:deviceId`,element:b(Py,{})}),b(X,{path:`/system/logs`,element:b($,{requireAdmin:!0,children:b(Ky,{})})}),b(X,{path:`/system/addons`,element:b($,{requireAdmin:!0,children:b(Uy,{})})}),b(X,{path:`/system/ai`,element:b($,{requireAdmin:!0,children:b(Wy,{})})}),b(X,{path:`/system/settings`,element:b($,{requireAdmin:!0,children:b(Zy,{})})}),b(X,{path:`/system/nodes`,element:b($,{requireAdmin:!0,children:b(Qy,{})})}),b(X,{path:`/system/notifications`,element:b($,{requireAdmin:!0,children:b(eb,{})})}),b(X,{path:`/system/history`,element:b($,{requireAdmin:!0,children:b(tb,{})})}),b(X,{path:`/system/calendars`,element:b($,{requireAdmin:!0,children:b(nb,{})})}),b(X,{path:`/system/templates`,element:b($,{requireAdmin:!0,children:b(rb,{})})}),b(X,{path:`/system/identity`,element:b($,{requireAdmin:!0,children:b(qy,{})})}),b(X,{path:`/system/my-access`,element:b(Gy,{})}),b(X,{path:`/system/network`,element:b($,{requireAdmin:!0,children:b(Jy,{})})}),b(X,{path:`/system/integrations`,element:b($,{requireAdmin:!0,children:b(Yy,{})})}),b(X,{path:`/system/data`,element:b($,{requireAdmin:!0,children:b(Xy,{})})}),b(X,{path:`/system`,element:b(Y,{to:Gm,replace:!0})}),b(X,{path:`/system/terminal`,element:b($,{requireAdmin:!0,children:b($y,{})})}),Km.map(e=>b(X,{path:e.path,element:b(Jm,{tab:e.tab})},e.path)),b(X,{path:`/system/users`,element:b(Y,{to:`/system/identity?tab=users`,replace:!0})}),b(X,{path:`/system/api-keys`,element:b(Y,{to:`/system/identity?tab=api-keys`,replace:!0})}),b(X,{path:`/system/authentication`,element:b(Y,{to:Dv(`authentication`),replace:!0})}),b(X,{path:`/system/linked-sessions`,element:b(Y,{to:`/system/identity?tab=linked-sessions`,replace:!0})}),b(X,{path:`/system/remote-access`,element:b(Y,{to:Dv(`remoteAccess`),replace:!0})}),b(X,{path:`/system/turn`,element:b(Y,{to:Dv(`turn`),replace:!0})}),b(X,{path:`/system/storage`,element:b(Y,{to:`/system/data?tab=storage`,replace:!0})}),b(X,{path:`/system/backup`,element:b(Y,{to:`/system/data?tab=backup`,replace:!0})}),b(X,{path:`/library`,element:b($,{requireAdmin:!0,children:b(Ly,{})})}),b(X,{path:`/retrain`,element:b(Y,{to:`/addon/training`,replace:!0})}),b(X,{path:`/recordings`,element:b($,{requireAdmin:!0,children:b(Ry,{})})}),b(X,{path:`/build`,element:b($,{requireAdmin:!0,children:b(By,{})})}),b(X,{path:gv,element:b($,{requireAdmin:!0,children:b(Vy,{})})}),b(X,{path:_v,element:b($,{requireAdmin:!0,children:b(Vy,{})})}),b(X,{path:`/locations`,element:b($,{requireAdmin:!0,children:b(Hy,{})})}),b(X,{path:`/automation`,element:b(Lm,{to:`/build`})}),b(X,{path:`/addon/:pagePath`,element:b($,{requireAdmin:!0,children:b(yh,{})})}),b(X,{path:`*`,element:b(Y,{to:`/devices`,replace:!0})})]})]})})})}),b(Zm,{})]})})})})})})})})}D(),window.__camstackUiLibrary=Br,window.__camstackSdk=ni,window.__camstackTypes=Qt;var db=_i(document.getElementById(`root`));p_(window.location.pathname,Ye())?Sy(db):db.render(b(w,{children:b(ub,{})}));export{Sp as $,Su as $n,Od as $t,pm as A,Zu as An,ef as At,kp as B,xu as Bn,Qd as Bt,$h as C,Vu as Cn,xf as Ct,Gm as D,_d as Dn,jf as Dt,$m as E,ad as En,Ef as Et,tm as F,ld as Fn,lf as Ft,op as G,mu as Gn,Kd as Gt,jp as H,du as Hn,Yd as Ht,em as I,Ru as In,af as It,ap as J,yu as Jn,Hd as Jt,bp as K,bu as Kn,Rd as Kt,$p as L,ju as Ln,Ud as Lt,im as M,zu as Mn,of as Mt,am as N,rd as Nn,sf as Nt,Bm as O,Yu as On,uf as Ot,sm as P,td as Pn,cf as Pt,yp as Q,fu as Qn,Vd as Qt,Lp as R,ku as Rn,Zd as Rt,Zh as S,hd as Sn,wf as St,Th as T,Wu as Tn,pf as Tt,vp as U,Cu as Un,qd as Ut,Ap as V,gu as Vn,Gd as Vt,up as W,pu as Wn,Jd as Wt,lp as X,vu as Xn,Fd as Xt,ip as Y,wu as Yn,zd as Yt,gp as Z,hu as Zn,Bd as Zt,Yg as _,od as _n,J as _r,bf as _t,wv as a,id as an,Bc as ar,$f as at,Rg as b,Fu as bn,gf as bt,Tv as c,qu as cn,xc as cr,Yf as ct,kv as d,ed as dn,hc as dr,Hf as dt,jd as en,Eu as er,sp as et,vv as f,nd as fn,lc as fr,df as ft,b_ as g,cd as gn,q as gr,Sf as gt,yv as h,Hu as hn,Y as hr,If as ht,Cv as i,Nd as in,Vc as ir,Qf as it,dm as j,Lu as jn,rf as jt,Om as k,$u as kn,$d as kt,Dv as l,Xu as ln,_c as lr,Jf as lt,bv as m,md as mn,hs as mr,Af as mt,Yv as n,Sd as nn,uu as nr,fp as nt,xv as o,gd as on,Ec as or,tp as ot,hv as p,sd as pn,rc as pr,ff as pt,pp as q,_u as qn,kd as qt,Ev as r,Md as rn,cu as rr,ep as rt,Sv as s,Qu as sn,vc as sr,Zf as st,Zv as t,wd as tn,Tu as tr,cp as tt,Ov as u,Nu as un,gc as ur,qf as ut,s_ as v,ud as vn,Qa as vr,_f as vt,Qh as w,Uu as wn,Cf as wt,yg as x,Iu as xn,Df as xt,qg as y,Ju as yn,Cs as yr,Of as yt,Cp as z,Du as zn,Xd as zt};
4
+ Please change the parent <Route path="${e}"> to <Route path="${e===`/`?`*`:`${e}/*`}">.`)}let d=q(),f;if(t){let e=typeof t==`string`?zi(t):t;H(l===`/`||e.pathname?.startsWith(l),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${l}" but pathname "${e.pathname}" was given in the \`location\` prop.`),f=e}else f=d;let p=f.pathname||`/`,m=p;if(l!==`/`){let e=l.replace(/^\//,``).split(`/`);m=`/`+p.replace(/^\//,``).split(`/`).slice(e.length).join(`/`)}let h=n&&n.state.matches.length?n.state.matches.map(e=>Object.assign(e,{route:n.manifest[e.route.id]||e.route})):Hi(e,{pathname:m});U(u||h!=null,`No routes matched location "${f.pathname}${f.search}${f.hash}" `),U(h==null||h[h.length-1].route.element!==void 0||h[h.length-1].route.Component!==void 0||h[h.length-1].route.lazy!==void 0,`Matched leaf route at location "${f.pathname}${f.search}${f.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let g=co(h&&h.map(e=>Object.assign({},e,{params:Object.assign({},s,e.params),pathname:W([l,r.encodeLocation?r.encodeLocation(e.pathname.replace(/%/g,`%25`).replace(/\?/g,`%3F`).replace(/#/g,`%23`)).pathname:e.pathname]),pathnameBase:e.pathnameBase===`/`?l:W([l,r.encodeLocation?r.encodeLocation(e.pathnameBase.replace(/%/g,`%25`).replace(/\?/g,`%3F`).replace(/#/g,`%23`)).pathname:e.pathnameBase])})),i,n);return t&&g?a(La.Provider,{value:{location:{pathname:`/`,search:``,hash:``,state:null,key:`default`,mask:void 0,...f},navigationType:`POP`}},g):g}function no(){let e=vo(),t=Sa(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,r=`rgba(200,200,200, 0.5)`,i={padding:`0.5rem`,backgroundColor:r},o={padding:`2px 4px`,backgroundColor:r},s=null;return console.error(`Error handled by React Router default ErrorBoundary:`,e),s=a(u,null,a(`p`,null,`💿 Hey developer 👋`),a(`p`,null,`You can provide a way better UX than this when your app throws errors by providing your own `,a(`code`,{style:o},`ErrorBoundary`),` or`,` `,a(`code`,{style:o},`errorElement`),` prop on your route.`)),a(u,null,a(`h2`,null,`Unexpected Application Error!`),a(`h3`,{style:{fontStyle:`italic`}},t),n?a(`pre`,{style:i},n):null,s)}var ro=a(no,null),io=class extends c{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||t.revalidation!==`idle`&&e.revalidation===`idle`?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error===void 0?t.error:e.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){this.props.onError?this.props.onError(e,t):console.error(`React Router caught the following error during render`,e)}render(){let e=this.state.error;if(this.context&&typeof e==`object`&&e&&`digest`in e&&typeof e.digest==`string`){let t=Ua(e.digest);t&&(e=t)}let t=e===void 0?this.props.children:a(K.Provider,{value:this.props.routeContext},a(Ra.Provider,{value:e,children:this.props.component}));return this.context?a(oo,{error:e},t):t}};io.contextType=Ma;var ao=new WeakMap;function oo({children:e,error:t}){let{basename:n}=F(G);if(typeof t==`object`&&t&&`digest`in t&&typeof t.digest==`string`){let e=Ha(t.digest);if(e){let r=ao.get(t);if(r)throw r;let i=Ta(e.location,n),o=i.absoluteURL||i.to;if(ka(o))throw Error(`Invalid redirect location`);if(wa&&!ao.get(t))if(i.isExternal||e.reloadDocument)window.location.href=o;else{let n=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(i.to,{replace:e.replace}));throw ao.set(t,n),n}return a(`meta`,{httpEquiv:`refresh`,content:`0;url=${o}`})}}return e}function so({routeContext:e,match:t,children:n}){let r=F(Aa);return r&&r.static&&r.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=t.route.id),a(K.Provider,{value:e},n)}function co(e,t=[],n){let r=n?.state;if(e==null){if(!r)return null;if(r.errors)e=r.matches;else if(t.length===0&&!r.initialized&&r.matches.length>0)e=r.matches;else return null}let i=e,o=r?.errors;if(o!=null){let e=i.findIndex(e=>e.route.id&&o?.[e.route.id]!==void 0);H(e>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(o).join(`,`)}`),i=i.slice(0,Math.min(i.length,e+1))}let s=!1,c=-1;if(n&&r){s=r.renderFallback;for(let e=0;e<i.length;e++){let t=i[e];if((t.route.HydrateFallback||t.route.hydrateFallbackElement)&&(c=e),t.route.id){let{loaderData:e,errors:a}=r,o=t.route.loader&&!e.hasOwnProperty(t.route.id)&&(!a||a[t.route.id]===void 0);if(t.route.lazy||o){n.isStatic&&(s=!0),i=c>=0?i.slice(0,c+1):[i[0]];break}}}}let l=n?.onError,u=r&&l?(e,t)=>{l(e,{location:r.location,params:r.matches?.[0]?.params??{},pattern:Ca(r.matches),errorInfo:t})}:void 0;return i.reduceRight((e,n,l)=>{let d,f=!1,p=null,m=null;r&&(d=o&&n.route.id?o[n.route.id]:void 0,p=n.route.errorElement||ro,s&&(c<0&&l===0?(xo(`route-fallback`,!1,"No `HydrateFallback` element provided to render during initial hydration"),f=!0,m=null):c===l&&(f=!0,m=n.route.hydrateFallbackElement||null)));let h=t.concat(i.slice(0,l+1)),g=()=>{let t;return t=d?p:f?m:n.route.Component?a(n.route.Component,null):n.route.element?n.route.element:e,a(so,{match:n,routeContext:{outlet:e,matches:h,isDataRoute:r!=null},children:t})};return r&&(n.route.ErrorBoundary||n.route.errorElement||l===0)?a(io,{location:r.location,revalidation:r.revalidation,component:p,error:d,children:g(),routeContext:{outlet:null,matches:h,isDataRoute:!0},onError:u}):g()},null)}function lo(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function uo(e){let t=F(Aa);return H(t,lo(e)),t}function fo(e){let t=F(ja);return H(t,lo(e)),t}function po(e){let t=F(K);return H(t,lo(e)),t}function mo(e){let t=po(e),n=t.matches[t.matches.length-1];return H(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function ho(){return mo(`useRouteId`)}function go(){let e=fo(`useNavigation`);return p(()=>{let{matches:t,historyAction:n,...r}=e.navigation;return r},[e.navigation])}function _o(){let{matches:e,loaderData:t}=fo(`useMatches`);return p(()=>e.map(e=>Wi(e,t)),[e,t])}function vo(){let e=F(Ra),t=fo(`useRouteError`),n=mo(`useRouteError`);return e===void 0?t.errors?.[n]:e}function yo(){let{router:e}=uo(`useNavigate`),t=mo(`useNavigate`),n=f(!1);return Ja(()=>{n.current=!0}),y(async(r,i={})=>{U(n.current,qa),n.current&&(typeof r==`number`?await e.navigate(r):await e.navigate(r,{fromRouteId:t,...i}))},[e,t])}var bo={};function xo(e,t,n){!t&&!bo[e]&&(bo[e]=!0,U(!1,n))}_(So);function So({routes:e,manifest:t,future:n,state:r,isStatic:i,onError:a}){return to(e,void 0,{manifest:t,state:r,isStatic:i,onError:a,future:n})}function Y({to:e,replace:t,state:n,relative:r}){H(Ga(),`<Navigate> may be used only in the context of a <Router> component.`);let{static:i}=F(G);U(!i,`<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.`);let{matches:a}=F(K),{pathname:o}=q(),s=J(),c=ha(e,ma(a),o,r===`path`),l=JSON.stringify(c);return x(()=>{s(JSON.parse(l),{replace:t,state:n,relative:r})},[s,l,r,t,n]),null}function X(e){H(!1,`A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.`)}function Co({basename:e=`/`,children:t=null,location:n,navigationType:r=`POP`,navigator:i,static:o=!1,useTransitions:s}){H(!Ga(),`You cannot render a <Router> inside another <Router>. You should never have more than one in your app.`);let c=e.replace(/^\/*/,`/`),l=p(()=>({basename:c,navigator:i,static:o,useTransitions:s,future:{}}),[c,i,o,s]);typeof n==`string`&&(n=zi(n));let{pathname:u=`/`,search:d=``,hash:f=``,state:m=null,key:h=`default`,mask:g}=n,_=p(()=>{let e=la(u,c);return e==null?null:{location:{pathname:e,search:d,hash:f,state:m,key:h,mask:g},navigationType:r}},[c,u,d,f,m,h,r,g]);return U(_!=null,`<Router basename="${c}"> is not able to match the URL "${u}${d}${f}" because it does not start with the basename, so the <Router> won't render anything.`),_==null?null:a(G.Provider,{value:l},a(La.Provider,{children:t,value:_}))}function wo({children:e,location:t}){return eo(To(e),t)}function To(e,t=[]){let n=[];return s.forEach(e,(e,r)=>{if(!m(e))return;let i=[...t,r];if(e.type===u){n.push.apply(n,To(e.props.children,i));return}H(e.type===X,`[${typeof e.type==`string`?e.type:e.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),H(!e.props.index||!e.props.children,`An index route cannot have child routes.`);let a={id:e.props.id||i.join(`-`),caseSensitive:e.props.caseSensitive,element:e.props.element,Component:e.props.Component,index:e.props.index,path:e.props.path,middleware:e.props.middleware,loader:e.props.loader,action:e.props.action,hydrateFallbackElement:e.props.hydrateFallbackElement,HydrateFallback:e.props.HydrateFallback,errorElement:e.props.errorElement,ErrorBoundary:e.props.ErrorBoundary,hasErrorBoundary:e.props.hasErrorBoundary===!0||e.props.ErrorBoundary!=null||e.props.errorElement!=null,shouldRevalidate:e.props.shouldRevalidate,handle:e.props.handle,lazy:e.props.lazy};e.props.children&&(a.children=To(e.props.children,i)),n.push(a)}),n}var Eo=`get`,Do=`application/x-www-form-urlencoded`;function Oo(e){return typeof HTMLElement<`u`&&e instanceof HTMLElement}function ko(e){return Oo(e)&&e.tagName.toLowerCase()===`button`}function Ao(e){return Oo(e)&&e.tagName.toLowerCase()===`form`}function jo(e){return Oo(e)&&e.tagName.toLowerCase()===`input`}function Mo(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function No(e,t){return e.button===0&&(!t||t===`_self`)&&!Mo(e)}function Po(e=``){return new URLSearchParams(typeof e==`string`||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((t,n)=>{let r=e[n];return t.concat(Array.isArray(r)?r.map(e=>[n,e]):[[n,r]])},[]))}function Fo(e,t){let n=Po(e);return t&&t.forEach((e,r)=>{n.has(r)||t.getAll(r).forEach(e=>{n.append(r,e)})}),n}var Io=null;function Lo(){if(Io===null)try{new FormData(document.createElement(`form`),0),Io=!1}catch{Io=!0}return Io}var Ro=new Set([`application/x-www-form-urlencoded`,`multipart/form-data`,`text/plain`]);function zo(e){return e!=null&&!Ro.has(e)?(U(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Do}"`),null):e}function Bo(e,t){let n,r,i,a,o;if(Ao(e)){let o=e.getAttribute(`action`);r=o?la(o,t):null,n=e.getAttribute(`method`)||Eo,i=zo(e.getAttribute(`enctype`))||Do,a=new FormData(e)}else if(ko(e)||jo(e)&&(e.type===`submit`||e.type===`image`)){let o=e.form;if(o==null)throw Error(`Cannot submit a <button> or <input type="submit"> without a <form>`);let s=e.getAttribute(`formaction`)||o.getAttribute(`action`);if(r=s?la(s,t):null,n=e.getAttribute(`formmethod`)||o.getAttribute(`method`)||Eo,i=zo(e.getAttribute(`formenctype`))||zo(o.getAttribute(`enctype`))||Do,a=new FormData(o,e),!Lo()){let{name:t,type:n,value:r}=e;if(n===`image`){let e=t?`${t}.`:``;a.append(`${e}x`,`0`),a.append(`${e}y`,`0`)}else t&&a.append(t,r)}}else if(Oo(e))throw Error(`Cannot submit element that is not <form>, <button>, or <input type="submit|image">`);else n=Eo,r=null,i=Do,o=e;return a&&i===`text/plain`&&(o=a,a=void 0),{action:r,method:n.toLowerCase(),encType:i,formData:a,body:o}}Object.getOwnPropertyNames(Object.prototype).sort().join(`\0`);var Vo={"&":`\\u0026`,">":`\\u003e`,"<":`\\u003c`,"\u2028":`\\u2028`,"\u2029":`\\u2029`},Ho=/[&><\u2028\u2029]/g;function Uo(e){return e.replace(Ho,e=>Vo[e])}function Wo(e,t){if(e===!1||e==null)throw Error(t)}function Go(e,t,n,r){let i=typeof e==`string`?new URL(e,typeof window>`u`?`server://singlefetch/`:window.location.origin):e;return n?i.pathname.endsWith(`/`)?i.pathname=`${i.pathname}_.${r}`:i.pathname=`${i.pathname}.${r}`:i.pathname===`/`?i.pathname=`_root.${r}`:t&&la(i.pathname,t)===`/`?i.pathname=`${_a(t)}/_root.${r}`:i.pathname=`${_a(i.pathname)}.${r}`,i}async function Ko(e,t){if(e.id in t)return t[e.id];try{let n=await i(()=>import(e.module),[],import.meta.url);return t[e.id]=n,n}catch(t){return console.error(`Error loading route module \`${e.module}\`, reloading page...`),console.error(t),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function qo(e){return e!=null&&typeof e.page==`string`}function Jo(e){return e==null?!1:e.href==null?e.rel===`preload`&&typeof e.imageSrcSet==`string`&&typeof e.imageSizes==`string`:typeof e.rel==`string`&&typeof e.href==`string`}async function Yo(e,t,n){return es((await Promise.all(e.map(async e=>{let r=t.routes[e.route.id];if(r){let e=await Ko(r,n);return e.links?e.links():[]}return[]}))).flat(1).filter(Jo).filter(e=>e.rel===`stylesheet`||e.rel===`preload`).map(e=>e.rel===`stylesheet`?{...e,rel:`prefetch`,as:`style`}:{...e,rel:`prefetch`}))}function Xo(e,t,n,r,i,a){let o=(e,t)=>n[t]?e.route.id!==n[t].route.id:!0,s=(e,t)=>n[t].pathname!==e.pathname||n[t].route.path?.endsWith(`*`)&&n[t].params[`*`]!==e.params[`*`];return a===`assets`?t.filter((e,t)=>o(e,t)||s(e,t)):a===`data`?t.filter((t,a)=>{let c=r.routes[t.route.id];if(!c||!c.hasLoader)return!1;if(o(t,a)||s(t,a))return!0;if(t.route.shouldRevalidate){let r=t.route.shouldRevalidate({currentUrl:new URL(i.pathname+i.search+i.hash,window.origin),currentParams:n[0]?.params||{},nextUrl:new URL(e,window.origin),nextParams:t.params,defaultShouldRevalidate:!0});if(typeof r==`boolean`)return r}return!0}):[]}function Zo(e,t,{includeHydrateFallback:n}={}){return Qo(e.map(e=>{let r=t.routes[e.route.id];if(!r)return[];let i=[r.module];return r.clientActionModule&&(i=i.concat(r.clientActionModule)),r.clientLoaderModule&&(i=i.concat(r.clientLoaderModule)),n&&r.hydrateFallbackModule&&(i=i.concat(r.hydrateFallbackModule)),r.imports&&(i=i.concat(r.imports)),i}).flat(1))}function Qo(e){return[...new Set(e)]}function $o(e){let t={},n=Object.keys(e).sort();for(let r of n)t[r]=e[r];return t}function es(e,t){let n=new Set,r=new Set(t);return e.reduce((e,i)=>{if(t&&!qo(i)&&i.as===`script`&&i.href&&r.has(i.href))return e;let a=JSON.stringify($o(i));return n.has(a)||(n.add(a),e.push({key:a,link:i})),e},[])}function ts(){let e=F(Aa);return Wo(e,`You must render this element inside a <DataRouterContext.Provider> element`),e}function ns(){let e=F(ja);return Wo(e,`You must render this element inside a <DataRouterStateContext.Provider> element`),e}var rs=A(void 0);rs.displayName=`FrameworkContext`;function is(){let e=F(rs);return Wo(e,`You must render this element inside a <HydratedRouter> element`),e}function as(e,t){let n=F(rs),[r,i]=C(!1),[a,o]=C(!1),{onFocus:s,onBlur:c,onMouseEnter:l,onMouseLeave:u,onTouchStart:d}=t,p=f(null);x(()=>{if(e===`render`&&o(!0),e===`viewport`){let e=new IntersectionObserver(e=>{e.forEach(e=>{o(e.isIntersecting)})},{threshold:.5});return p.current&&e.observe(p.current),()=>{e.disconnect()}}},[e]),x(()=>{if(r){let e=setTimeout(()=>{o(!0)},100);return()=>{clearTimeout(e)}}},[r]);let m=()=>{i(!0)},h=()=>{i(!1),o(!1)};return n?e===`intent`?[a,p,{onFocus:os(s,m),onBlur:os(c,h),onMouseEnter:os(l,m),onMouseLeave:os(u,h),onTouchStart:os(d,m)}]:[a,p,{}]:[!1,p,{}]}function os(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function ss({page:e,...t}){let n=Na(),{nonce:r}=is(),{router:i}=ts(),o=p(()=>Hi(i.routes,e,i.basename),[i.routes,e,i.basename]);return o?(t.nonce==null&&r&&(t={...t,nonce:r}),a(n?ls:us,{page:e,matches:o,...t})):null}function cs(e){let{manifest:t,routeModules:n}=is(),[r,i]=C([]);return x(()=>{let r=!1;return Yo(e,t,n).then(e=>{r||i(e)}),()=>{r=!0}},[e,t,n]),r}function ls({page:e,matches:t,...n}){let r=q(),{future:i}=is(),{basename:o}=ts();return a(u,null,p(()=>{if(e===r.pathname+r.search+r.hash)return[];let n=Go(e,o,i.v8_trailingSlashAwareDataRequests,`rsc`),a=!1,s=[];for(let e of t)typeof e.route.shouldRevalidate==`function`?a=!0:s.push(e.route.id);return a&&s.length>0&&n.searchParams.set(`_routes`,s.join(`,`)),[n.pathname+n.search]},[o,i.v8_trailingSlashAwareDataRequests,e,r,t]).map(e=>a(`link`,{key:e,rel:`prefetch`,as:`fetch`,href:e,...n})))}function us({page:e,matches:t,...n}){let r=q(),{future:i,manifest:o,routeModules:s}=is(),{basename:c}=ts(),{loaderData:l,matches:d}=ns(),f=p(()=>Xo(e,t,d,o,r,`data`),[e,t,d,o,r]),m=p(()=>Xo(e,t,d,o,r,`assets`),[e,t,d,o,r]),h=p(()=>{if(e===r.pathname+r.search+r.hash)return[];let n=new Set,a=!1;if(t.forEach(e=>{let t=o.routes[e.route.id];!t||!t.hasLoader||(!f.some(t=>t.route.id===e.route.id)&&e.route.id in l&&s[e.route.id]?.shouldRevalidate||t.hasClientLoader?a=!0:n.add(e.route.id))}),n.size===0)return[];let u=Go(e,c,i.v8_trailingSlashAwareDataRequests,`data`);return a&&n.size>0&&u.searchParams.set(`_routes`,t.filter(e=>n.has(e.route.id)).map(e=>e.route.id).join(`,`)),[u.pathname+u.search]},[c,i.v8_trailingSlashAwareDataRequests,l,r,o,f,t,e,s]),g=p(()=>Zo(m,o),[m,o]),_=cs(m);return a(u,null,h.map(e=>a(`link`,{key:e,rel:`prefetch`,as:`fetch`,href:e,...n})),g.map(e=>a(`link`,{key:e,rel:`modulepreload`,href:e,...n})),_.map(({key:e,link:t})=>a(`link`,{key:e,nonce:n.nonce,...t,crossOrigin:t.crossOrigin??n.crossOrigin})))}function ds(...e){return t=>{e.forEach(e=>{typeof e==`function`?e(t):e!=null&&(e.current=t)})}}var fs=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;try{fs&&(window.__reactRouterVersion=`7.18.0`)}catch{}function ps({basename:e,children:t,useTransitions:n,window:r}){let i=f();i.current??=Pi({window:r,v5Compat:!0});let o=i.current,[s,c]=C({action:o.action,location:o.location}),u=y(e=>{n===!1?c(e):d(()=>c(e))},[n]);return l(()=>o.listen(u),[o,u]),a(Co,{basename:e,children:t,location:s.location,navigationType:s.action,navigator:o,useTransitions:n})}function ms({basename:e,children:t,history:n,useTransitions:r}){let[i,o]=C({action:n.action,location:n.location}),s=y(e=>{r===!1?o(e):d(()=>o(e))},[r]);return l(()=>n.listen(s),[n,s]),a(Co,{basename:e,children:t,location:i.location,navigationType:i.action,navigator:n,useTransitions:r})}ms.displayName=`unstable_HistoryRouter`;var hs=k(function({onClick:e,discover:t=`render`,prefetch:n=`none`,relative:r,reloadDocument:i,replace:o,mask:s,state:c,target:l,to:d,preventScrollReset:f,viewTransition:p,defaultShouldRevalidate:m,...h},g){let{basename:_,navigator:v,useTransitions:y}=F(G),b=typeof d==`string`&&ki.test(d),x=Ta(d,_);d=x.to;let S=Wa(d,{relative:r}),C=q(),w=null;if(s){let e=ha(s,[],C.mask?C.mask.pathname:`/`,!0);_!==`/`&&(e.pathname=e.pathname===`/`?_:W([_,e.pathname])),w=v.createHref(e)}let[T,E,D]=as(n,h),O=Ss(d,{replace:o,mask:s,state:c,target:l,preventScrollReset:f,relative:r,viewTransition:p,defaultShouldRevalidate:m,useTransitions:y});function k(t){e&&e(t),t.defaultPrevented||O(t)}let A=!(x.isExternal||i),j=a(`a`,{...h,...D,href:(A?w:void 0)||x.absoluteURL||S,onClick:A?k:e,ref:ds(g,E),target:l,"data-discover":!b&&t===`render`?`true`:void 0});return T&&!b?a(u,null,j,a(ss,{page:S})):j});hs.displayName=`Link`;var gs=k(function({"aria-current":e=`page`,caseSensitive:t=!1,className:n=``,end:r=!1,style:i,to:o,viewTransition:s,children:c,...l},u){let d=$a(o,{relative:l.relative}),f=q(),p=F(ja),{navigator:m,basename:h}=F(G),g=p!=null&&Ns(d)&&s===!0,_=m.encodeLocation?m.encodeLocation(d).pathname:d.pathname,v=f.pathname,y=p&&p.navigation&&p.navigation.location?p.navigation.location.pathname:null;t||(v=v.toLowerCase(),y=y?y.toLowerCase():null,_=_.toLowerCase()),y&&h&&(y=la(y,h)||y);let b=_!==`/`&&_.endsWith(`/`)?_.length-1:_.length,x=v===_||!r&&v.startsWith(_)&&v.charAt(b)===`/`,S=y!=null&&(y===_||!r&&y.startsWith(_)&&y.charAt(_.length)===`/`),C={isActive:x,isPending:S,isTransitioning:g},w=x?e:void 0,T;T=typeof n==`function`?n(C):[n,x?`active`:null,S?`pending`:null,g?`transitioning`:null].filter(Boolean).join(` `);let E=typeof i==`function`?i(C):i;return a(hs,{...l,"aria-current":w,className:T,ref:u,style:E,to:o,viewTransition:s},typeof c==`function`?c(C):c)});gs.displayName=`NavLink`;var _s=k(({discover:e=`render`,fetcherKey:t,navigate:n,reloadDocument:r,replace:i,state:o,method:s=Eo,action:c,onSubmit:l,relative:u,preventScrollReset:f,viewTransition:p,defaultShouldRevalidate:m,...h},g)=>{let{useTransitions:_}=F(G),v=Es(),y=Ds(c,{relative:u}),b=s.toLowerCase()===`get`?`get`:`post`,x=typeof c==`string`&&ki.test(c);return a(`form`,{ref:g,method:b,action:y,onSubmit:r?l:e=>{if(l&&l(e),e.defaultPrevented)return;e.preventDefault();let r=e.nativeEvent.submitter,a=r?.getAttribute(`formmethod`)||s,c=()=>v(r||e.currentTarget,{fetcherKey:t,method:a,navigate:n,replace:i,state:o,relative:u,preventScrollReset:f,viewTransition:p,defaultShouldRevalidate:m});_&&n!==!1?d(()=>c()):c()},...h,"data-discover":!x&&e===`render`?`true`:void 0})});_s.displayName=`Form`;function vs({getKey:e,storageKey:t,...n}){let r=F(rs),{basename:i}=F(G),o=q(),s=_o();js({getKey:e,storageKey:t});let c=p(()=>{if(!r||!e)return null;let t=As(o,s,i,e);return t===o.key?null:t},[]);if(!r||r.isSpaMode)return null;let l=((e,t)=>{if(!window.history.state||!window.history.state.key){let e=Math.random().toString(32).slice(2);window.history.replaceState({key:e},``)}try{let n=JSON.parse(sessionStorage.getItem(e)||`{}`)[t||window.history.state.key];typeof n==`number`&&window.scrollTo(0,n)}catch(t){console.error(t),sessionStorage.removeItem(e)}}).toString();return n.nonce==null&&r?.nonce&&(n.nonce=r.nonce),a(`script`,{...n,suppressHydrationWarning:!0,dangerouslySetInnerHTML:{__html:`(${l})(${Uo(JSON.stringify(t||Os))}, ${Uo(JSON.stringify(c))})`}})}vs.displayName=`ScrollRestoration`;function ys(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function bs(e){let t=F(Aa);return H(t,ys(e)),t}function xs(e){let t=F(ja);return H(t,ys(e)),t}function Ss(e,{target:t,replace:n,mask:r,state:i,preventScrollReset:a,relative:o,viewTransition:s,defaultShouldRevalidate:c,useTransitions:l}={}){let u=J(),f=q(),p=$a(e,{relative:o});return y(m=>{if(No(m,t)){m.preventDefault();let t=n===void 0?Ri(f)===Ri(p):n,h=()=>u(e,{replace:t,mask:r,state:i,preventScrollReset:a,relative:o,viewTransition:s,defaultShouldRevalidate:c});l?d(()=>h()):h()}},[f,u,p,n,r,i,t,e,a,o,s,c,l])}function Cs(e){U(typeof URLSearchParams<`u`,"You cannot use the `useSearchParams` hook in a browser that does not support the URLSearchParams API. If you need to support Internet Explorer 11, we recommend you load a polyfill such as https://github.com/ungap/url-search-params.");let t=f(Po(e)),n=f(!1),r=q(),i=p(()=>Fo(r.search,n.current?null:t.current),[r.search]),a=J();return[i,y((e,t)=>{let r=Po(typeof e==`function`?e(new URLSearchParams(i)):e);n.current=!0,a(`?`+r,t)},[a,i])]}var ws=0,Ts=()=>`__${String(++ws)}__`;function Es(){let{router:e}=bs(`useSubmit`),{basename:t}=F(G),n=ho(),r=e.fetch,i=e.navigate;return y(async(e,a={})=>{let{action:o,method:s,encType:c,formData:l,body:u}=Bo(e,t);a.navigate===!1?await r(a.fetcherKey||Ts(),n,a.action||o,{defaultShouldRevalidate:a.defaultShouldRevalidate,preventScrollReset:a.preventScrollReset,formData:l,body:u,formMethod:a.method||s,formEncType:a.encType||c,flushSync:a.flushSync}):await i(a.action||o,{defaultShouldRevalidate:a.defaultShouldRevalidate,preventScrollReset:a.preventScrollReset,formData:l,body:u,formMethod:a.method||s,formEncType:a.encType||c,replace:a.replace,state:a.state,fromRouteId:n,flushSync:a.flushSync,viewTransition:a.viewTransition})},[r,i,t,n])}function Ds(e,{relative:t}={}){let{basename:n}=F(G),r=F(K);H(r,`useFormAction must be used inside a RouteContext`);let[i]=r.matches.slice(-1),a={...$a(e||`.`,{relative:t})},o=q();if(e==null){a.search=o.search;let e=new URLSearchParams(a.search),t=e.getAll(`index`);if(t.some(e=>e===``)){e.delete(`index`),t.filter(e=>e).forEach(t=>e.append(`index`,t));let n=e.toString();a.search=n?`?${n}`:``}}return(!e||e===`.`)&&i.route.index&&(a.search=a.search?a.search.replace(/^\?/,`?index&`):`?index`),n!==`/`&&(a.pathname=a.pathname===`/`?n:W([n,a.pathname])),Ri(a)}var Os=`react-router-scroll-positions`,ks={};function As(e,t,n,r){let i=null;return r&&(i=r(n===`/`?e:{...e,pathname:la(e.pathname,n)||e.pathname},t)),i??=e.key,i}function js({getKey:e,storageKey:t}={}){let{router:n}=bs(`useScrollRestoration`),{restoreScrollPosition:r,preventScrollReset:i}=xs(`useScrollRestoration`),{basename:a}=F(G),o=q(),s=_o(),c=go();x(()=>(window.history.scrollRestoration=`manual`,()=>{window.history.scrollRestoration=`auto`}),[]),Ms(y(()=>{if(c.state===`idle`){let t=As(o,s,a,e);ks[t]=window.scrollY}try{sessionStorage.setItem(t||Os,JSON.stringify(ks))}catch(e){U(!1,`Failed to save scroll positions in sessionStorage, <ScrollRestoration /> will not work properly (${e}).`)}window.history.scrollRestoration=`auto`},[c.state,e,a,o,s,t])),typeof document<`u`&&(l(()=>{try{let e=sessionStorage.getItem(t||Os);e&&(ks=JSON.parse(e))}catch{}},[t]),l(()=>{let t=n?.enableScrollRestoration(ks,()=>window.scrollY,e?(t,n)=>As(t,n,a,e):void 0);return()=>t&&t()},[n,a,e]),l(()=>{if(r!==!1){if(typeof r==`number`){window.scrollTo(0,r);return}try{if(o.hash){let e=document.getElementById(decodeURIComponent(o.hash.slice(1)));if(e){e.scrollIntoView();return}}}catch{U(!1,`"${o.hash.slice(1)}" is not a decodable element ID. The view will not scroll to it.`)}i!==!0&&window.scrollTo(0,0)}},[o,r,i]))}function Ms(e,t){let{capture:n}=t||{};x(()=>{let t=n==null?void 0:{capture:n};return window.addEventListener(`pagehide`,e,t),()=>{window.removeEventListener(`pagehide`,e,t)}},[e,n])}function Ns(e,{relative:t}={}){let n=F(Pa);H(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=bs(`useViewTransitionState`),i=$a(e,{relative:t});if(!n.isTransitioning)return!1;let a=la(n.currentLocation.pathname,r)||n.currentLocation.pathname,o=la(n.nextLocation.pathname,r)||n.nextLocation.pathname;return aa(i.pathname,o)!=null||aa(i.pathname,a)!=null}var Ps=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}}))()),Fs=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g;function Is(e){var t={type:`tag`,name:``,voidElement:!1,attrs:{},children:[]},n=e.match(/<\/?([^\s]+?)[/\s>]/);if(n&&(t.name=n[1],(Ps.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(Fs),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 Ls=/<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g,Rs=/^\s*$/,zs=Object.create(null);function Bs(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(Bs,``)+`</`+t.name+`>`;case`comment`:return e+`<!--`+t.comment+`-->`}}var Vs={parse:function(e,t){t||={},t.components||=zs;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(Ls,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=Is(s);return a<0?(r.push(m),r):((l=i[a]).children.push(m),r)}if(u&&(a++,(n=Is(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);Rs.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+Bs(``,t)},``)}};D();var Hs=(e,t)=>{if(!e)return!1;let n=e.props?.children??e.children;return t?n.length>0:!!n},Us=e=>{if(!e)return[];let t=e.props?.children??e.children;return e.props?.i18nIsDynamicList?Gs(t):t},Ws=e=>Array.isArray(e)&&e.every(m),Gs=e=>Array.isArray(e)?e:[e],Ks=(e,t)=>{let n={...t};return n.props={...t.props,...e.props},n},qs=e=>{let t={};if(!e)return t;let n=e=>{Gs(e).forEach(e=>{bi(e)||(Hs(e)?n(Us(e)):Ti(e)&&!m(e)&&Object.assign(t,e))})};return n(e),t},Js=(e,t,n,r)=>{if(!e)return``;let i=``,a=Gs(e),o=t?.transSupportBasicHtmlNodes?t.transKeepBasicHtmlNodesFor??[]:[];return a.forEach((e,a)=>{if(bi(e)){i+=`${e}`;return}if(m(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=bi(d)?d:Js(d,t,n,r);i+=`<${c}>${e}</${c}>`;return}let f=Js(d,t,n,r);i+=`<${a}>${f}</${a}>`;return}if(e===null){Si(n,`TRANS_NULL_VALUE`,`Passed in a null value as child`,{i18nKey:r});return}if(Ti(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}Si(n,`TRANS_INVALID_OBJ`,`Invalid child - Object should only have keys {{ value, format }} (format is optional).`,{i18nKey:r,child:e});return}Si(n,`TRANS_INVALID_VAR`,`Passed in a variable like {number} - pass variables for interpolation as full objects like {{number}}.`,{i18nKey:r,child:e})}),i},Ys=(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},Xs=(e,t,n,r,i,o,c)=>{if(n===``)return[];let l=i.transKeepBasicHtmlNodesFor||[],d=n&&new RegExp(l.map(e=>`<${e}`).join(`|`)).test(n);if(!e&&!t&&!d&&!c)return[n];let f=t??{},p=e=>{Gs(e).forEach(e=>{bi(e)||(Hs(e)?p(Us(e)):Ti(e)&&!m(e)&&Object.assign(f,e))})};p(e);let h=Ys(n,l,f),_=Vs.parse(`<0>${h}</0>`),v={...f,...o},y=(e,t,n)=>{let r=Us(e),i=x(r,t.children,n);return Ws(r)&&i.length===0||e.props?.i18nIsDynamicList?r:i},b=(e,t,n,r,i)=>{e.dummy?(e.children=t,n.push(g(e,{key:r},i?void 0:t))):n.push(...s.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])}),a(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])}),g(e,n,i?null:t)}))},x=(e,n,o)=>{let s=Gs(e),u=Gs(n),f={};return u.reduce((e,n,u)=>{let p=n.children?.[0]?.content&&r.services.interpolator.interpolate(n.children[0].content,v,r.language);if(n.type===`tag`){let h=s[parseInt(n.name,10)];!h&&t&&(h=t[n.name]),o.length===1&&!h&&(h=o[0][n.name]),h||={};let g={...n.attrs};c&&Object.keys(g).forEach(e=>{let t=g[e];bi(t)&&(g[e]=wi(t))});let _=Object.keys(g).length===0?h:Ks({props:g},h),S=m(_),C=S&&Hs(n,!0)&&!n.voidElement,w=d&&Ti(_)&&_.dummy&&!S,T=Ti(t)&&Object.hasOwnProperty.call(t,n.name);if(bi(_)){let t=r.services.interpolator.interpolate(_,v,r.language);e.push(t)}else if(Hs(_)||C)b(_,y(_,n,o),e,u);else if(w)b(_,x(s,n.children,o),e,u);else if(Number.isNaN(parseFloat(n.name)))if(T)b(_,y(_,n,o),e,u,n.voidElement);else if(i.transSupportBasicHtmlNodes&&l.indexOf(n.name)>-1)if(n.voidElement)e.push(a(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<s.length;e+=1){let a=s[e];if(m(a)&&a.type===n.name){if(i===t){r=a;break}i+=1}}let c=x(r?Gs(Us(r)):s,n.children,o);e.push(a(n.name,{key:`${n.name}-${u}`},c))}else if(n.voidElement)e.push(`<${n.name} />`);else{let t=x(s,n.children,o);e.push(`<${n.name}>${t}</${n.name}>`)}else if(Ti(_)&&!S){let t=n.children[0]?p:null;t&&e.push(t)}else b(_,p,e,u,n.children.length!==1||!p)}else if(n.type===`text`){let t=i.transWrapTextNodes,o=typeof i.unescape==`function`?i.unescape:yi().unescape,s=c?o(r.services.interpolator.interpolate(n.content,v,r.language)):r.services.interpolator.interpolate(n.content,v,r.language);t?e.push(a(t,{key:`${n.name}-${u}`},s)):e.push(s)}return e},[])};return Us(x([{dummy:!0,children:e||[]}],_,Gs(e||[]))[0])},Zs=(e,t,n)=>{let r=e.key||t,i=g(e,{key:r});if(!i.props||!i.props.children||n.indexOf(`${t}/>`)<0&&n.indexOf(`${t} />`)<0)return i;function o(){return a(u,null,i)}return a(o,{key:r})},Qs=(e,t)=>e.map((e,n)=>Zs(e,n,t)),$s=(e,t)=>{let n={};return Object.keys(e).forEach(r=>{Object.assign(n,{[r]:Zs(e[r],r,t)})}),n},ec=(e,t,n,r)=>e?Array.isArray(e)?Qs(e,t):Ti(e)?$s(e,t):(Ei(n,`TRANS_INVALID_COMPONENTS`,`<Trans /> "components" prop expects an object or array`,{i18nKey:r}),null):null,tc=e=>!Ti(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:o={},values:s,defaults:c,components:l,ns:u,i18n:d,t:f,shouldUnescape:p,...m}){let h=d||xi();if(!h)return Ei(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),_={...yi(),...h.options?.react},v=u||g.ns||h.options?.defaultNS;v=bi(v)?[v]:v||[`translation`];let{transDefaultProps:y}=_,b=y?.tOptions?{...y.tOptions,...o}:o,x=p??y?.shouldUnescape,S=y?.values?{...y.values,...s}:s,C=y?.components?{...y.components,...l}:l,w=Js(e,_,h,r),T=c||b?.defaultValue||w||_.transEmptyNodeValue||(typeof r==`function`?vi(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=qs(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=ec(C,j,h,r),N=M||e,P=null;tc(M)&&(P=M,N=e);let F=Xs(N,P,j,h,_,A,x),I=n??_.defaultTransParent;return I?a(I,m,F):F}D();function rc({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}=F(Ci)||{},g=u||m||xi(),_=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})}function ic(e,t){return t.map(t=>({subject:{kind:`device`,deviceId:e},key:t.key,scope:t.scope}))}function ac({deviceId:e}){let{t}=V(),{presence:n,list:r}=kr(e);return n===`absent`?null:n===`unknown`?b(Cn,{message:t(`deviceQuickDetail.historyUnknown`,`Could not tell whether this device has recorded history.`)}):n===`pending`||r.status===`pending`?b(Gn,{className:`h-24 w-full`,"aria-busy":`true`}):r.status===`error`?b(Cn,{title:t(`deviceQuickDetail.historyUnknown`,`Could not tell whether this device has recorded history.`),message:r.error}):r.data.length===0?null:o(`section`,{className:`flex flex-col gap-2`,"aria-label":t(`deviceQuickDetail.tabHistory`,`History`),children:[b(`div`,{className:`flex justify-end`,children:b(hs,{to:li(ic(e,r.data)),className:`text-xs text-primary hover:underline`,children:t(`deviceQuickDetail.openHistory`,`Open full history`)})}),b(br,{deviceId:e})]})}function oc(e,t){return e===`present`&&t.status===`ok`&&(t.data?.length??0)>0}var sc={streaming:{icon:yn,labelKey:`capabilityBadges.streaming`},detection:{icon:xe,labelKey:`capabilityBadges.detection`},recording:{icon:$e,labelKey:`capabilityBadges.recording`},audio:{icon:Ge,labelKey:`capabilityBadges.audio`},snapshot:{icon:ce,labelKey:`capabilityBadges.snapshot`},motion:{icon:Fe,labelKey:`capabilityBadges.motion`},ptz:{icon:Ne,labelKey:`capabilityBadges.ptz`},webrtc:{icon:ee,labelKey:`capabilityBadges.webrtc`},onvif:{icon:ke,labelKey:`capabilityBadges.onvif`},analytics:{icon:We,labelKey:`capabilityBadges.analytics`},"battery-operated":{icon:Se,labelKey:`capabilityBadges.battery`},"native-snapshot":{icon:ce,labelKey:`capabilityBadges.nativeSnapshot`},"pan-tilt-zoom":{icon:Ne,labelKey:`capabilityBadges.ptz`},"two-way-audio":{icon:Ge,labelKey:`capabilityBadges.twoWayAudio`},"doorbell-button":{icon:ye,labelKey:`capabilityBadges.doorbell`},rebootable:{icon:L,labelKey:`capabilityBadges.rebootable`},"vacuum-has-map":{icon:hn,labelKey:`capabilityBadges.map`},"vacuum-has-ai":{icon:Je,labelKey:`capabilityBadges.aiObstacle`},"mower-has-map":{icon:hn,labelKey:`capabilityBadges.map`},"mower-has-targeted-mowing":{icon:R,labelKey:`capabilityBadges.targetedMowing`}},cc=se;function lc({capabilities:e,showLabels:t=!1}){let{t:n}=V();return b(`div`,{className:`flex items-center gap-1 flex-wrap`,children:e.map(e=>{let r=sc[e],i=r?.icon??cc,a=r?n(r.labelKey):e;return o(`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:[b(i,{className:`h-3 w-3`}),t&&b(`span`,{children:a})]},e)})})}D();var uc={amcrest:{icon:un,color:`#3b82f6`,label:`Amcrest`},hikvision:{icon:we,color:`#a855f7`,label:`Hikvision`},reolink:{icon:ee,color:`#06b6d4`,label:`Reolink`},homeassistant:{icon:tt,color:`#22d3ee`,label:`Home Assistant`},rtsp:{icon:Oe,color:`#78716c`,label:`RTSP`},onvif:{icon:Oe,color:`#78716c`,label:`ONVIF`}},dc={sm:`h-4 w-4`,md:`h-5 w-5`,lg:`h-6 w-6`,xl:`h-16 w-16`},fc={sm:`h-7 w-7`,md:`h-8 w-8`,lg:`h-10 w-10`,xl:`h-16 w-16`};function pc(e){let t=e.toLowerCase();return t.startsWith(`provider-`)?t.slice(9):t}function mc(e){return uc[pc(e)]??{icon:un,color:`#78716c`,label:e}}function hc({type:e,size:t=`md`,showLabel:n}){let r=mc(e),i=r.icon,[a,s]=C(!1),c=Di(e);return o(`div`,{className:`flex items-center gap-2`,children:[b(`div`,{className:`flex items-center justify-center rounded-lg ${fc[t]}`,style:{backgroundColor:`${r.color}15`},children:a||!c?b(i,{className:dc[t],style:{color:r.color}}):b(`img`,{src:c,alt:r.label,className:dc[t],onError:()=>s(!0)})}),n&&b(`span`,{className:`text-xs font-medium text-foreground-subtle`,children:r.label})]})}function gc({label:e,value:t,layout:n=`inline`}){return n===`stacked`?o(`div`,{className:`min-w-0 flex flex-col gap-0.5 px-0.5`,children:[b(`span`,{className:`text-[11px] text-foreground-subtle`,children:e}),b(`div`,{className:`min-w-0 text-[11px] text-foreground`,children:t})]}):o(`div`,{className:`${_e} flex items-start gap-2 sm:gap-3`,children:[b(`span`,{className:`w-20 sm:w-28 flex-shrink-0 text-[11px] text-foreground-subtle`,children:e}),b(`div`,{className:`flex-1 min-w-0 text-[11px] text-foreground`,children:t})]})}D();function _c(e){return Hn({addonId:e,projection:`slim`})}function vc(e){return qn({deviceId:e},{enabled:Number.isFinite(e)})}var yc=3e4,bc=2e3;function xc(e){let t=f(0);return t.current===0&&(t.current=Date.now()),Dn({parentDeviceId:e},{enabled:Number.isFinite(e),staleTime:0,refetchOnMount:`always`,refetchInterval:e=>{let n=e.state.data;return n&&n.length>0||Date.now()-t.current>=yc?!1:bc}})}D();function Sc({deviceId:e}){let{t}=V(),n=M(),{data:r}=vc(e),{data:i}=xc(e),[a,s]=C(null),c=ti({onSuccess:()=>{s(null),n.invalidateQueries({queryKey:[[`deviceManager`]]})},onError:e=>{s(`Could not change primary child: ${e.message}`)}});if(r==null||String(r.type??``)!==dt.Container)return null;let l=String(r.name??``),u=(i??[]).map(e=>({id:e.id,stableId:e.stableId,type:e.type,name:nr(e,l),...e.sourceInfo?{sourceInfo:{id:e.sourceInfo.id}}:{}}));if(u.length<=1)return null;let d=Bn(u,typeof r.linkDeviceId==`number`?r.linkDeviceId:null,typeof r.primaryChildEntityId==`string`?r.primaryChildEntityId:null),f=d===null?u[0].id:d.id;return o(P,{children:[b(gc,{label:t(`shared.primaryChildRow.primaryChild`,`Primary child`),value:b(cr,{childrenList:u,selectedId:f,onSetPrimary:t=>c.mutate({deviceId:e,primaryChildEntityId:t}),disabled:c.isPending})}),a!==null&&b(`p`,{role:`alert`,className:`px-3 sm:px-4 py-1.5 text-[11px] text-danger`,children:a})]})}D();var Cc=[`manufacturer`,`model`,`hardware`,`firmware`,`serialNumber`,`uid`,`mac`,`itemNo`];function wc(e){return e.replace(/([a-z])([A-Z])/g,`$1 $2`).replace(/^./,e=>e.toUpperCase())}function Tc(e){return e==null?`—`:typeof e==`string`||typeof e==`number`||typeof e==`boolean`?String(e):JSON.stringify(e)}function Ec(){let{t:e}=V(),t=Yn(),n=xn(),{data:r}=qn({deviceId:t??0},{enabled:t!==null}),{data:i}=$n({deviceId:t??0},{enabled:t!==null}),a=r??n??null,[s,c]=C(`identity`);if(t===null||!a)return null;let l=String(a.stableId??``),u=String(a.addonId??``),d=typeof a.integrationId==`string`&&a.integrationId.length>0?a.integrationId:null,f=typeof a.parentDeviceId==`number`?a.parentDeviceId:null,p=a.features??[],m=new Set([`device-status`,`feature-probe`,`device-ops`]),h=(i?.entries??[]).filter(e=>e.kind===`native`&&!m.has(e.capName)).map(e=>e.capName),g=p.length>0?p:h,_=a.metadata??null,v=_!==null&&Object.keys(_).length>0;return o(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[o(`div`,{className:`border-b border-border px-3 sm:px-4 py-2 flex items-center justify-between gap-3`,children:[b(`h2`,{className:`text-[11px] font-semibold text-foreground uppercase tracking-wider`,children:e(`overviewAdapters.deviceInfoAdapter.deviceInfo`,`Device Info`)}),v&&o(`div`,{className:`flex items-center gap-1 rounded-md bg-surface-hover p-0.5`,children:[b(Dc,{active:s===`identity`,onClick:()=>c(`identity`),label:e(`overviewAdapters.deviceInfoAdapter.identity`,`Identity`)}),b(Dc,{active:s===`hardware`,onClick:()=>c(`hardware`),label:e(`overviewAdapters.deviceInfoAdapter.hardware`,`Hardware`)})]})]}),(!v||s===`identity`)&&o(`div`,{className:`divide-y divide-border`,children:[b(gc,{label:`ID`,value:o(`span`,{className:`font-mono text-[11px] text-foreground`,children:[`#${t}`,o(`span`,{className:`ml-1.5 text-foreground-subtle`,children:[`(`,l,`)`]})]})}),b(Sc,{deviceId:t}),d!==null&&b(gc,{label:e(`overviewAdapters.deviceInfoAdapter.integration`,`Integration`),value:b(`span`,{className:`font-mono text-[11px]`,children:d})}),f!==null&&b(gc,{label:e(`overviewAdapters.deviceInfoAdapter.parent`,`Parent`),value:b(`span`,{className:`font-mono text-[11px]`,children:`#${String(f)}`})}),b(gc,{label:e(`overviewAdapters.deviceInfoAdapter.provider`,`Provider`),value:b(hc,{type:u,size:`sm`,showLabel:!0})}),b(gc,{label:e(`overviewAdapters.deviceInfoAdapter.capabilities`,`Capabilities`),value:g.length>0?b(lc,{capabilities:g,showLabels:!0}):b(`span`,{className:`text-[11px] text-foreground-subtle`,children:e(`overviewAdapters.deviceInfoAdapter.none`,`None`)})})]}),v&&s===`hardware`&&b(Oc,{metadata:_})]})}function Dc({active:e,onClick:t,label:n}){return b(`button`,{type:`button`,onClick:t,className:`px-2 py-0.5 rounded text-[10px] font-medium transition-colors ${e?`bg-surface text-foreground shadow-sm`:`text-foreground-subtle hover:text-foreground`}`,children:n})}function Oc({metadata:e}){let{t}=V(),n=Cc.filter(t=>t in e),r=Object.keys(e).filter(e=>!Cc.includes(e)).toSorted(),i=[...n,...r];return o(`div`,{children:[b(`div`,{className:`px-3 sm:px-4 py-1.5 text-[10px] text-foreground-subtle border-b border-border bg-surface-subtle/40`,children:t(`overviewAdapters.deviceInfoAdapter.autoPopulatedByTheDriver`,`Auto-populated by the driver on every connect. Read-only.`)}),b(`div`,{className:`divide-y divide-border`,children:i.map(t=>b(gc,{label:wc(t),value:b(`span`,{className:`font-mono text-[11px] text-foreground break-all`,children:Tc(e[t])})},t))})]})}function kc(e,t){return e.icon===t.icon&&e.label===t.label&&e.unit===t.unit&&e.precision===t.precision&&e.hidden===t.hidden}function Ac(e){return{icon:e?.icon??``,label:e?.label??``,unit:e?.unit??``,precision:e?.precision===void 0?``:String(e.precision),hidden:e?.hidden===!0}}function jc(e){if(e.trim()===``)return;let t=Number.parseInt(e,10);return Number.isFinite(t)?t:void 0}function Mc(e,t){let n=jc(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 Nc(e){let t=Ac(e.display);return{name:e.name,location:e.location,role:e.role,display:t,baseName:e.name,baseLocation:e.location,baseRole:e.role,baseDisplay:t,persistedDisplay:e.display}}function Pc(e,t){if(e===null)return Nc(t);let n=Ac(t.display),r=e.name===t.name&&e.location===t.location&&e.role===t.role&&kc(e.display,n);return!Fc(e)||r?Nc(t):e}function Fc(e){return e===null?!1:e.name!==e.baseName||e.location!==e.baseLocation||e.role!==e.baseRole||!kc(e.display,e.baseDisplay)}function Ic(e){return e.name.trim().length===0?`name`:null}function Lc(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},...kc(e.display,e.baseDisplay)?{}:{display:Mc(e.display,e.persistedDisplay)}}}function Rc(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(`; `)}}D();var zc=A(null);function Bc(){return F(zc)}function Vc({deviceId:e,seed:t,showOpenFull:n=!1,onClose:r,children:i}){let[a,o]=C(null),[s,c]=C([]),l=f(new Map);if(t!==null){let e=Pc(a,t);(a===null||e.name!==a.name||e.location!==a.location||e.role!==a.role||!kc(e.display,a.display)||e.baseName!==a.baseName||e.baseLocation!==a.baseLocation||e.baseRole!==a.baseRole||!kc(e.baseDisplay,a.baseDisplay)||e.persistedDisplay!==a.persistedDisplay)&&o(e)}let u=y(e=>(l.current.set(e.id,{save:e.save,discard:e.discard}),c(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:()=>l.current.get(e.id)?.save()??Promise.resolve(),discard:()=>{l.current.get(e.id)?.discard()}}]}),()=>{l.current.delete(e.id),c(t=>t.filter(t=>t.id!==e.id))}),[]),d=p(()=>({identity:a,setIdentityName:e=>{o(t=>t===null?t:{...t,name:e})},setIdentityLocation:e=>{o(t=>t===null?t:{...t,location:e})},setIdentityRole:e=>{o(t=>t===null?t:{...t,role:e})},setIdentityDisplay:e=>{o(t=>t===null?t:{...t,display:{...t.display,...e}})},register:u}),[a,u]);return b(zc.Provider,{value:d,children:b(Hc,{deviceId:e,identity:a,contributions:s,onIdentitySaved:e=>o(e),showOpenFull:n,onClose:r,children:i})})}function Hc({deviceId:e,identity:t,contributions:n,onIdentitySaved:r,showOpenFull:i,onClose:a,children:s}){return o(P,{children:[s,b(Wc,{deviceId:e,identity:t,contributions:n,onIdentitySaved:r,showOpenFull:i,onClose:a})]})}function Uc(e){return e instanceof Error?e.message:String(e)}function Wc({deviceId:e,identity:t,contributions:n,onIdentitySaved:r,showOpenFull:i,onClose:a}){let{t:s}=V(),c=J(),l=Qe(),u=M(),[d,f]=C(null),[p,m]=C(!1),h=wr(),g=ur(),_=Hr(),v=fr(),y=Rc([{dirty:Fc(t),saving:p,error:d},...n]),x=()=>{u.invalidateQueries({queryKey:[[`deviceManager`]]})};return!y.dirty&&!y.saving&&y.error===null&&!i?null:o(`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:[y.error!==null&&b(`p`,{className:`text-xs text-danger`,children:y.error}),o(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[i?b(Cr,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>{(async()=>{y.dirty&&!await l({title:s(`deviceQuickDetail.leaveTitle`,`Discard unsaved changes?`),message:s(`deviceQuickDetail.leaveMessage`,`Unsaved edits on this device will be discarded.`),confirmLabel:s(`deviceQuickDetail.discard`,`Discard`),variant:`warning`})||(c(`/devices/${String(e)}?tab=customize`),a?.())})()},children:s(`deviceQuickDetail.openFull`,`Open full detail`)}):b(`span`,{}),o(`div`,{className:`flex items-center gap-2`,children:[b(Cr,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>{t!==null&&r({...t,name:t.baseName,location:t.baseLocation,role:t.baseRole,display:t.baseDisplay});for(let e of n)e.discard();f(null)},disabled:!y.dirty||y.saving,children:s(`deviceQuickDetail.discard`,`Discard`)}),b(Cr,{type:`button`,size:`sm`,onClick:()=>{if(t!==null&&Fc(t)&&Ic(t)===`name`){f(s(`deviceQuickDetail.nameRequired`,`Name is required`));return}f(null),m(!0),(async()=>{try{let i=t===null?{}:Lc(t);if(t!==null&&i.name!==void 0&&await h.mutateAsync({deviceId:e,name:i.name}),t!==null&&i.location!==void 0&&await g.mutateAsync({deviceId:e,location:i.location}),t!==null&&i.role!==void 0&&await _.mutateAsync({deviceId:e,role:i.role}),t!==null&&i.display!==void 0&&await v.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,persistedDisplay:i.display===void 0?t.persistedDisplay:i.display??void 0})}for(let e of n)e.dirty&&await e.save();x()}catch(e){f(Uc(e))}finally{m(!1)}})()},disabled:!y.dirty||y.saving,children:y.saving?s(`deviceQuickDetail.saving`,`Saving…`):s(`deviceQuickDetail.save`,`Save`)})]})]})]})}function Gc(e){return e.hubReachable?e.authOk===!1?{kind:`auth-expired`}:{kind:`cluster-degraded`,offlineAgents:e.offlineAgents,offlineAgentIds:e.offlineAgentIds}:{kind:`hub-unreachable`}}function Kc(e){switch(e.kind){case`connected`:return null;case`reconnecting`:return{severity:`warning`,message:B.t(`connection.reconnecting`),i18nKey:`connection.reconnecting`,showSpinner:!0};case`cluster-degraded`:{let t=e.offlineAgentIds??[];return t.length>0?{severity:`warning`,message:B.t(`connection.degradedNodes`,{nodes:t.join(`, `),count:t.length}),i18nKey:`connection.degradedNodes`,i18nParams:{nodes:t.join(`, `),count:t.length},showSpinner:!0}:e.offlineAgents!==null&&e.offlineAgents>0?{severity:`warning`,message:B.t(`connection.degradedCount`,{count:e.offlineAgents}),i18nKey:`connection.degradedCount`,i18nParams:{count:e.offlineAgents},showSpinner:!0}:{severity:`warning`,message:B.t(`connection.degraded`),i18nKey:`connection.degraded`,showSpinner:!0}}case`hub-unreachable`:return{severity:`danger`,message:B.t(`connection.disconnected`),i18nKey:`connection.disconnected`,showSpinner:!0};case`auth-expired`:return{severity:`danger`,message:B.t(`connection.sessionExpired`),i18nKey:`connection.sessionExpired`,showSpinner:!1,action:`sign-in`}}}var qc=4e3,Jc=5e3;function Yc(e){if(typeof e!=`object`||!e)return{offline:null,offlineIds:null,ok:null};let t={...e},n=typeof t.ok==`boolean`?t.ok:null,r=t.agents;if(typeof r!=`object`||!r)return{offline:null,offlineIds:null,ok:n};let i={...r},a=i.offline,o=typeof a==`number`?a:null,s=i.offlineIds;return{offline:o,offlineIds:Array.isArray(s)?s.filter(e=>typeof e==`string`):null,ok:n}}async function Xc(e,t,n,r){let i=new AbortController,a=setTimeout(()=>i.abort(),n);try{return await e(t,{method:`GET`,signal:i.signal,credentials:`omit`,...r===void 0?{}:{headers:r}})}finally{clearTimeout(a)}}async function Zc(e){let t=e.fetchFn??fetch,n=e.timeoutMs??qc,r=e.origin.replace(/\/+$/,``),i;try{i=await Xc(t,`${r}/health`,n)}catch{return{hubReachable:!1,authOk:`unknown`,offlineAgents:null,offlineAgentIds:null}}if(!i.ok)return{hubReachable:!1,authOk:`unknown`,offlineAgents:null,offlineAgentIds:null};let a=null,o=e.getToken();if(o!==null&&o!==``)try{let e=await Xc(t,`${r}/health/details`,n,{Authorization:`Bearer ${o}`});e.ok&&(a=await e.json())}catch{}let s;try{s=Yc(a??await i.json())}catch{s={offline:null,offlineIds:null,ok:null}}if(s.ok===!1)return{hubReachable:!1,authOk:`unknown`,offlineAgents:null,offlineAgentIds:null};let c=e.getToken(),l=`unknown`;if(c!==null&&c!==``)try{let e=await Xc(t,`${r}/trpc/auth.me`,n,{Authorization:`Bearer ${c}`});e.status===401||e.status===403?l=!1:e.ok&&(l=!0)}catch{l=`unknown`}return{hubReachable:!0,authOk:l,offlineAgents:s.offline,offlineAgentIds:s.offlineIds}}var Qc={kind:`connected`},$c={kind:`reconnecting`};function el(e){let t=e.probeIntervalMs??Jc,n=new Set,r=Qc,i=0,a=!1,o=null;function s(e){if(r!==e){r=e;for(let e of n)e()}}function c(){a=!1,o!==null&&(clearTimeout(o),o=null)}function l(){let n=i;e.probe().then(e=>{n!==i||!a||(s(Gc(e)),o=setTimeout(l,t))},()=>{n!==i||!a||(s({kind:`hub-unreachable`}),o=setTimeout(l,t))})}function u(e){if(i+=1,e===`connected`){c(),s(Qc);return}if(e===`connecting`){c(),s($c);return}(r.kind===`connected`||r.kind===`reconnecting`)&&s($c),o!==null&&(clearTimeout(o),o=null),a=!0,l()}return{getSnapshot:()=>r,subscribe:e=>(n.add(e),()=>{n.delete(e)}),onSdkConnectionState:u,dispose:()=>{i+=1,c(),n.clear()}}}var tl=null;function nl(){return tl===null&&(tl=el({probe:()=>Zc({origin:Ce(),getToken:()=>localStorage.getItem(`camstack_admin_token`)})})),tl}function rl(e){nl().onSdkConnectionState(e)}function il(e){return e===`connected`}function al(e){j.setOnline(il(e))}var ol=null,sl=0;function Z(){if(!ol){let e=sl;ol=xr({serverUrl:Ce(),token:localStorage.getItem(`camstack_admin_token`)??void 0,getLanguage:()=>B.language,refreshCredential:async e=>{e===`rejected`?await wl().refreshNow():await wl().ensureFresh()},onConnectionChange:t=>{e===sl&&(rl(t),al(t))}})}return ol}function cl(){let e=ol;ol=null,sl+=1,e?.close()}var ll=`camstack_admin_token`,ul=`camstack_admin_refresh`,dl=`camstack_admin_token_expires`;function fl(e){try{let t=localStorage.getItem(e);return t!==null&&t.length>0?t:null}catch{return null}}function pl(e,t){try{t===null?localStorage.removeItem(e):localStorage.setItem(e,t)}catch{}}function ml(){let e=fl(ll);if(e===null)return null;let t=fl(ul),n=Number(fl(dl));return{token:e,...t===null?{}:{refreshToken:t},...Number.isFinite(n)&&n>0?{expiresAt:n}:{}}}function hl(e){pl(ll,e.token),pl(ul,e.refreshToken??null),pl(dl,e.expiresAt===void 0?null:String(e.expiresAt))}function gl(){pl(ll,null),pl(ul,null),pl(dl,null)}function _l(e){let t=e.get(`token`);if(t===null||t.length===0)return null;let n=e.get(`refreshToken`),r=Number(e.get(`expiresAt`));return{token:t,...n!==null&&n.length>0?{refreshToken:n}:{},...Number.isFinite(r)&&r>0?{expiresAt:r}:{}}}async function vl(e){await fetch(z(`/api/auth/session`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({token:e})}).catch(()=>{})}var yl=new Set;function bl(e){return yl.add(e),()=>yl.delete(e)}var xl=new Set;function Sl(e){return xl.add(e),()=>xl.delete(e)}var Cl=null;function wl(){return Cl===null&&(Cl=new Tr({refresh:async e=>{let t=ml();if(t?.refreshToken!==void 0&&t.refreshToken!==e&&(t.expiresAt??0)>Date.now()+6e4)return t;let n=await Z().refreshSession(e);return{token:n.token,refreshToken:n.refreshToken,expiresAt:n.expiresAt}},onTokens:e=>{hl(e),Z().setToken(e.token),vl(e.token);for(let e of xl)e()},onExpired:()=>{gl();for(let e of yl)e()}})),Cl}function Tl(e){hl(e),wl().adopt(e)}async function El(e){try{await wl().ensureFresh()}catch(e){console.warn(`[admin-session] pre-reconnect refresh failed; reconnecting anyway`,e)}e()}async function Dl(){return await wl().refreshNow()!==null}var Ol=512;function kl(e){if(!e||e.length>Ol)return null;let t=Rt(e);return t===null?!e.startsWith(`/`)||e.startsWith(`//`)||e.includes(`\\`)||e.includes(`://`)||e.includes(`..`)||e===`/login`||e.startsWith(`/login?`)||e.startsWith(`/login/`)?null:{kind:`path`,path:e}:{kind:`app-callback`,url:t}}var Al=/^[A-Za-z0-9_-]{43,128}$/,jl=/^[A-Za-z0-9._~-]{1,256}$/;function Ml(e){let{codeChallenge:t,state:n}=e;return!t||!Al.test(t)||(e.codeChallengeMethod??`S256`)!==`S256`||!n||!jl.test(n)?null:{codeChallenge:t,state:n,purpose:e.purpose===`step-up`?`step-up`:`new-session`}}var Nl=`camstack:login-app-handoff`;function Pl(e){if(!e)return null;try{let t=JSON.parse(e);if(typeof t!=`object`||!t)return null;let n=e=>{let n=Reflect.get(t,e);return typeof n==`string`?n:null};return Ml({codeChallenge:n(`codeChallenge`),state:n(`state`),purpose:n(`purpose`)})}catch{return null}}function Fl(e,t=Date.now()){e!==null&&ql(Nl,JSON.stringify(e),Pl,t)}function Il(e=Date.now()){return Jl(Nl,Pl,e)}function Ll(e,t,n){return`${e}?${`code=${encodeURIComponent(t)}`}${n===void 0?``:`&state=${encodeURIComponent(n)}`}`}function Rl(e,t=Date.now()){return Zl(t)??kl(e)}var zl=2048;function Bl(e){return!e||e.length>zl||!e.startsWith(`/`)||e.startsWith(`//`)||e.includes(`\\`)||e.includes(`://`)||e.includes(`..`)||e===`/login`||e.startsWith(`/login?`)||e.startsWith(`/login/`)?null:e}function Vl(e,t=Date.now()){ql(Gl,e,Bl,t)}function Hl(e=Date.now()){return Jl(Gl,Bl,e)}function Ul(e,t=Date.now()){return Hl(t)??Bl(e)}var Wl=`camstack:login-redirect`,Gl=`camstack:login-next`,Kl=10*6e4;function ql(e,t,n,r){let i=Yl();if(!i||!n(t))return;let a={raw:t??``,at:r};try{i.setItem(e,JSON.stringify(a))}catch{}}function Jl(e,t,n){let r=Yl();if(!r)return null;let i=null;try{i=r.getItem(e),r.removeItem(e)}catch{return null}if(!i)return null;try{let e=JSON.parse(i);if(typeof e!=`object`||!e)return null;let r=Reflect.get(e,`at`),a=Reflect.get(e,`raw`);return typeof r!=`number`||typeof a!=`string`||n-r>Kl?null:t(a)}catch{return null}}function Yl(){if(typeof window>`u`)return null;try{return window.sessionStorage}catch{return null}}function Xl(e,t=Date.now()){ql(Wl,e,kl,t)}function Zl(e=Date.now()){return Jl(Wl,kl,e)}var Ql=`changeme`;function $l(e){try{let t=e.split(`.`);if(t.length<2||!t[1])return null;let n=JSON.parse(atob(t[1]));return{id:String(n.userId??``),username:String(n.username??`unknown`),isAdmin:!!n.isAdmin,exp:Number(n.exp??0),scopes:eu(n.scopes)}}catch{return null}}function eu(e){return Lt(qt(e))}function tu(e){let t=$l(e);return t?t.exp*1e3<Date.now():!0}D();var nu=Ql;function ru(e){return{token:e.token,...e.refreshToken===void 0?{}:{refreshToken:e.refreshToken},...e.expiresAt===void 0?{}:{expiresAt:e.expiresAt}}}async function iu(e,t){if(await vl(e),t.kind===`path`){window.location.replace(z(t.path));return}try{cl();let e=Il();if(e===null)throw Error(`The app sent no PKCE challenge and state`);let{code:n}=await Z().trpcClient.auth.createHandoffCode.mutate({purpose:e.purpose,codeChallenge:e.codeChallenge,state:e.state});window.location.replace(Ll(t.url,n,e.state))}catch{window.location.replace(z(`/`))}}async function au(e,t){await vl(e),window.location.replace(z(t))}var ou=A(null);function su({children:e}){let[t,n]=C(null),[r,i]=C(!0),[a,o]=C(!1);x(()=>{if(typeof window<`u`&&window.location.hash.startsWith(`#token=`)){let e=new URLSearchParams(window.location.hash.slice(1)),t=_l(e),n=t?.token??null;if(t!==null&&n!==null){Tl(t);let r=Zl();if(r){iu(n,r);return}let i=Hl()??Bl(e.get(`next`));if(i){au(n,i);return}window.history.replaceState({},``,z(`/`))}}s()},[]);let s=async()=>{let e=ml();if(e===null){i(!1);return}let t=e.token;if(e.refreshToken!==void 0){let n=wl();n.adopt(e),await n.ensureFresh();let r=ml();if(r===null){console.warn(`[auth] session restore: signed out — the hub refused the refresh token`),cl(),i(!1);return}t=r.token}if(tu(t)){console.warn(`[auth] session restore: signed out — access token expired and no refresh recovered it`),gl(),cl(),i(!1);return}let r=$l(t);if(!r){console.warn(`[auth] session restore: signed out — the stored access token is unreadable`),gl(),cl(),i(!1);return}vl(t);let a=Z();a.trpcClient.system.info.query().then(()=>n(r)).catch(async e=>{let t=e?.data?.code;if(t===`UNAUTHORIZED`||t===`FORBIDDEN`){if(await Dl()){a.reconnect();try{await Z().trpcClient.system.info.query();let e=ml();n(e&&$l(e.token)||r);return}catch{}}console.warn(`[auth] session restore: logout, probe UNAUTHORIZED and refresh did not recover it`),wl().stop(),gl(),cl()}else n(r)}).finally(()=>i(!1))};x(()=>bl(()=>{cl(),n(null),o(!1)}),[]);let c=y(async(e,t)=>{let r=await Z().login(e,t,{refreshable:!0}),i=r.secondFactors??(r.requiresTotp===!0?[`totp`]:[]);if(i.length>0)return{kind:`second-factor`,challengeToken:r.token,factors:i};let a=r.token;return Tl(ru(r)),await vl(a),cl(),n($l(a)),o(t===nu),{kind:`ok`}},[]),l=y(async(e,t)=>{let r=await Z().loginVerifyTotp(e,t,{refreshable:!0}),i=r.token;Tl(ru(r)),await vl(i),cl(),n($l(i)),o(!1)},[]),u=y(async(e,t)=>{Tl({token:e,...t}),await vl(e),cl(),n($l(e)),o(!1)},[]),d=y(()=>{Z().logout().catch(()=>{}),wl().stop(),gl(),fetch(z(`/api/auth/session`),{method:`DELETE`}).catch(()=>{}),cl(),n(null),o(!1)},[]),f=y(()=>{o(!1)},[]);return b(ou.Provider,{value:{user:t,loading:r,mustChangePassword:a,login:c,verifyTotp:l,finalizePasskeyLogin:u,logout:d,clearMustChangePassword:f},children:e})}function cu(){let e=F(ou);if(!e)throw Error(`useAuth must be used within AuthProvider`);return e}D();function lu(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 uu({schema:e,serverValues:t,onImmediateSave:n,onDeferredSave:r}){let[i,a]=C({}),[o,s]=C({}),[c,l]=C(!1),u=f(null),d=e?.sections??[],m=Object.keys(i).length>0,h=p(()=>({...t,...o,...i}),[t,o,i]);x(()=>{if(m||Object.keys(o).length>0){l(!0);return}u.current&&clearTimeout(u.current),u.current=setTimeout(()=>l(!1),500)},[m,o]),x(()=>()=>{u.current&&clearTimeout(u.current)},[]);let g=y(()=>{l(!0),u.current&&clearTimeout(u.current),u.current=setTimeout(()=>l(!1),2e3)},[]),_=y(e=>{g();let r={},o={},s={...t,...i};for(let[t,n]of Object.entries(e))s[t]!==n&&(lu(d,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,d,n]),v=y(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]),b=y(e=>{a(t=>{let n={...t};for(let t of e)delete n[t];return n})},[]),S=y(()=>{a({})},[]);return{values:h,pendingKeys:Object.keys(i),hasPendingEdits:m,editingPaused:c,handleChange:_,handleSave:v,handleDiscard:b,resetAll:S}}function Q(e){return t=>Object.prototype.hasOwnProperty.call(e,t)}var du=Q({devices:!0}),fu=Q({classes:!0,classesExclude:!0,labelEquals:!0,identities:!0,identitiesExclude:!0,eventTypeTokens:!0,sensorKinds:!0}),pu=Q({minConfidence:!0,minImportance:!0,minLabelConfidence:!0}),mu=Q({minDwellSeconds:!0}),hu=Q({source:!0}),gu=Q({crossing:!0}),_u=Q({packagePhase:!0}),vu=Q({sensorTransition:!0}),yu=Q({plates:!0}),bu=Q({occupancy:!0}),xu=Q({audio:!0}),Su=Q({systemEvent:!0}),Cu=Q({deviceState:!0}),wu=Q({scene:!0});function Tu(e,t){let n=e[t];return Array.isArray(n)?n:[]}function Eu(e,t){let n=e[t];return typeof n==`number`?n:void 0}D();function Du(e,t){let n=Ae().trpcClient,r=O({queries:e.map(e=>({queryKey:[[`nc-pickers`,`zones`],{deviceId:e}],staleTime:3e4,queryFn:async()=>({deviceId:e,zones:(await n.zones.listZones.query({deviceId:e})).map(e=>({id:e.id,name:e.name}))})}))});return p(()=>{let e=[],n=new Set;for(let i of r){if(!i.data)continue;let r=t.find(e=>e.id===i.data.deviceId)?.name;for(let t of i.data.zones)n.has(t.id)||(n.add(t.id),e.push({value:t.id,label:t.name,...r===void 0?{}:{hint:r}}))}return{options:e,loading:r.some(e=>e.isLoading),failed:r.some(e=>e.isError)}},[r,t])}function Ou(e){let t=Ae().trpcClient,n=O({queries:e.map(e=>({queryKey:[[`nc-pickers`,`event-kinds`],{deviceId:e}],staleTime:6e4,queryFn:async()=>(await t.pipelineAnalytics.listEventKinds.query({deviceId:e})).map(e=>({kind:e.kind,label:e.label}))}))});return p(()=>{let e=new Map;for(let t of n)for(let n of t.data??[])e.has(n.kind)||e.set(n.kind,n.label);let t=[...e.entries()].map(([e,t])=>({value:e,label:t}));return t.sort((e,t)=>e.label.localeCompare(t.label)),{options:t,loading:n.some(e=>e.isLoading)}},[n])}function ku(){let e=ai();return p(()=>({options:(e.data??[]).map(e=>({value:e.id,label:e.name})),loading:e.isLoading,failed:e.isError===!0}),[e.data,e.isLoading,e.isError])}function Au(){let e=Rn({limit:200}),t=Pn();return p(()=>{let n=new Set;for(let e of t.data??[])e.name.trim().length>0&&n.add(e.name);let r=new Set;for(let t of e.data??[])t.text.trim().length>0&&r.add(t.text);return[...[...n].sort(),...[...r].sort()]},[e.data,t.data])}function ju({options:e,value:t,onChange:n,loading:r,emptyHint:i,placeholder:a,noFreeText:s=!1}){let{t:c}=V(),[l,u]=C(``),d=p(()=>new Set(e.map(e=>e.value)),[e]),f=p(()=>new Set(t),[t]),m=t.filter(e=>!d.has(e)),h=e=>{n(f.has(e)?t.filter(t=>t!==e):[...t,e])},g=()=>{let e=l.trim();e.length===0||t.includes(e)||(n([...t,e]),u(``))};return o(`div`,{className:`mt-1 space-y-1.5`,children:[m.length>0&&b(`div`,{className:`flex flex-wrap gap-1`,children:m.map(e=>o(`button`,{type:`button`,onClick:()=>n(t.filter(t=>t!==e)),className:`inline-flex items-center gap-1 rounded border border-border px-1.5 py-0.5 text-[10px] text-foreground hover:bg-surface-hover`,title:c(`system.notificationRulePickers.customValueClickToRemove`,`Custom value — click to remove`),children:[e,` ×`]},e))}),e.length>0?b(`div`,{className:`max-h-40 overflow-y-auto rounded-md border border-border divide-y divide-border`,children:e.map(e=>o(`label`,{className:`flex items-center gap-2.5 px-3 py-1.5 text-xs text-foreground cursor-pointer hover:bg-surface-hover`,children:[b(`input`,{type:`checkbox`,checked:f.has(e.value),onChange:()=>h(e.value),className:`accent-primary`}),b(`span`,{className:`flex-1 truncate`,children:e.label}),e.hint!==void 0&&b(`span`,{className:`text-[10px] text-foreground-subtle`,children:e.hint})]},e.value))}):b(`p`,{className:`text-[10px] text-foreground-subtle`,children:r===!0?c(`common.loading`,`Loading…`):i}),!s&&b(`input`,{value:l,onChange:e=>u(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),g())},placeholder:a,className:`w-full rounded-md border border-border bg-background px-2 py-1 text-xs text-foreground placeholder:text-foreground-subtle`})]})}var Mu=[{value:`immediate`,get label(){return B.t(`helpers.ruleFormParsers.immediate`)},get hint(){return B.t(`helpers.ruleFormParsers.immediateHint`)}},{value:`track-end`,get label(){return B.t(`helpers.ruleFormParsers.trackEnd`)},get hint(){return B.t(`helpers.ruleFormParsers.trackEndHint`)}},{value:`device-event`,get label(){return B.t(`helpers.ruleFormParsers.deviceEvent`)},get hint(){return B.t(`helpers.ruleFormParsers.deviceEventHint`)}},{value:`package-event`,get label(){return B.t(`helpers.ruleFormParsers.packageEvent`)},get hint(){return B.t(`helpers.ruleFormParsers.packageEventHint`)}},{value:`system-event`,get label(){return B.t(`helpers.ruleFormParsers.systemEvent`)},get hint(){return B.t(`helpers.ruleFormParsers.systemEventHint`)}}],Nu=`Immediate, grouped`,Pu=Mu.flatMap(e=>e.value===`immediate`?[e,{value:`immediate-grouped`,get label(){return B.t(`notificationRules.grouping.choice`)},get hint(){return B.t(`helpers.ruleFormParsers.groupedHint`)}}]:[e]);function Fu(e){return e.groupingSec!==void 0&&nn(e)?`immediate-grouped`:e.delivery}function Iu(e){let t=(e.delivery===`immediate`||e.delivery===`track-end`)&&nn({delivery:`immediate`,conditions:e.conditions});return Pu.filter(e=>e.value!==`immediate-grouped`||t)}function Lu(e){return Pu.find(t=>t.value===e)?.value}function Ru(e,t=Nu){return Fu(e)===`immediate-grouped`?`${t} · ${String(e.groupingSec)} s`:Bu(e.delivery)}function zu(e){if(e.trim().length===0)return;let t=Number(e);return Number.isFinite(t)&&t>=0?Math.trunc(t):void 0}function Bu(e){return Mu.find(t=>t.value===e)?.label??e}function Vu(e){return Mu.some(t=>t.value===e)}var Hu=[{key:`all`,get label(){return B.t(`helpers.ruleFormParsers.sec_all_label`)},get blurb(){return B.t(`helpers.ruleFormParsers.sec_all_blurb`)},get newRuleLabel(){return B.t(`helpers.ruleFormParsers.sec_all_new`)},get emptyHint(){return B.t(`helpers.ruleFormParsers.sec_all_empty`)},creatable:!0},{key:`detection`,get label(){return B.t(`helpers.ruleFormParsers.sec_detection_label`)},get blurb(){return B.t(`helpers.ruleFormParsers.sec_detection_blurb`)},get newRuleLabel(){return B.t(`helpers.ruleFormParsers.sec_detection_new`)},get emptyHint(){return B.t(`helpers.ruleFormParsers.sec_detection_empty`)},creatable:!0},{key:`sensor`,get label(){return B.t(`helpers.ruleFormParsers.sec_sensor_label`)},get blurb(){return B.t(`helpers.ruleFormParsers.sec_sensor_blurb`)},get newRuleLabel(){return B.t(`helpers.ruleFormParsers.sec_sensor_new`)},get emptyHint(){return B.t(`helpers.ruleFormParsers.sec_sensor_empty`)},creatable:!0},{key:`audio`,get label(){return B.t(`helpers.ruleFormParsers.sec_audio_label`)},get blurb(){return B.t(`helpers.ruleFormParsers.sec_audio_blurb`)},get newRuleLabel(){return B.t(`helpers.ruleFormParsers.sec_audio_new`)},get emptyHint(){return B.t(`helpers.ruleFormParsers.sec_audio_empty`)},creatable:!0},{key:`occupancy`,get label(){return B.t(`helpers.ruleFormParsers.sec_occupancy_label`)},get blurb(){return B.t(`helpers.ruleFormParsers.sec_occupancy_blurb`)},get newRuleLabel(){return B.t(`helpers.ruleFormParsers.sec_occupancy_new`)},get emptyHint(){return B.t(`helpers.ruleFormParsers.sec_occupancy_empty`)},creatable:!0},{key:`device-events`,get label(){return B.t(`helpers.ruleFormParsers.sec_deviceEvents_label`)},get blurb(){return B.t(`helpers.ruleFormParsers.sec_deviceEvents_blurb`)},get newRuleLabel(){return B.t(`helpers.ruleFormParsers.sec_deviceEvents_new`)},get emptyHint(){return B.t(`helpers.ruleFormParsers.sec_deviceEvents_empty`)},creatable:!0},{key:`system`,get label(){return B.t(`helpers.ruleFormParsers.sec_system_label`)},get blurb(){return B.t(`helpers.ruleFormParsers.sec_system_blurb`)},get newRuleLabel(){return B.t(`helpers.ruleFormParsers.sec_system_new`)},get emptyHint(){return B.t(`helpers.ruleFormParsers.sec_system_empty`)},creatable:!0},{key:`alarm`,get label(){return B.t(`helpers.ruleFormParsers.sec_alarm_label`)},get blurb(){return B.t(`helpers.ruleFormParsers.sec_alarm_blurb`)},get newRuleLabel(){return B.t(`helpers.ruleFormParsers.sec_alarm_new`)},get emptyHint(){return B.t(`helpers.ruleFormParsers.sec_alarm_empty`)},creatable:!0},{key:`mixed`,get label(){return B.t(`helpers.ruleFormParsers.sec_mixed_label`)},get blurb(){return B.t(`helpers.ruleFormParsers.sec_mixed_blurb`)},get newRuleLabel(){return B.t(`helpers.ruleFormParsers.sec_mixed_new`)},get emptyHint(){return B.t(`helpers.ruleFormParsers.sec_mixed_empty`)},creatable:!1}];function Uu(e){return tn(zt(e)).editable}function Wu(e){return Ht(Gu(e))}function Gu(e){switch(e){case`device-events`:case`system`:case`alarm`:case`mixed`:return e;default:return}}var Ku=new Map([[0,`helpers.ruleFormParsers.cdNone`],[60,`helpers.ruleFormParsers.cd1m`],[3600,`helpers.ruleFormParsers.cd1h`]]),qu=86400;function Ju(e){let t=Ku.get(e);return t===void 0?e%3600==0?B.t(`helpers.ruleFormParsers.cdHours`,{count:e/3600}):e%60==0?B.t(`helpers.ruleFormParsers.cdMinutes`,{count:e/60}):B.t(`helpers.ruleFormParsers.cdSeconds`,{count:e}):B.t(t)}function Yu(e){if(e.trim().length===0)return;let t=Number(e);return Number.isFinite(t)&&t>=0?Math.trunc(t):void 0}var Xu=[{value:`rule-device`,get label(){return B.t(`helpers.ruleFormParsers.scopeDevice`)}},{value:`rule`,get label(){return B.t(`helpers.ruleFormParsers.scopeRule`)}}];function Zu(e){return Xu.find(t=>t.value===e)?.value}var Qu=[{value:`per-class`,get label(){return B.t(`helpers.ruleFormParsers.granPerClass`)}},{value:`shared`,get label(){return B.t(`helpers.ruleFormParsers.granShared`)}}];function $u(e){return Qu.find(t=>t.value===e)?.value}var ed=[{value:`scene-boxes`,get label(){return B.t(`helpers.ruleFormParsers.imageSceneBoxes`)},get description(){return B.t(`helpers.ruleFormParsers.imageSceneBoxesDesc`)}},{value:`crop`,get label(){return B.t(`helpers.ruleFormParsers.imageCrop`)},get description(){return B.t(`helpers.ruleFormParsers.imageCropDesc`)}},{value:`clean`,get label(){return B.t(`helpers.ruleFormParsers.imageClean`)},get description(){return B.t(`helpers.ruleFormParsers.imageCleanDesc`)}},{value:`none`,get label(){return B.t(`helpers.ruleFormParsers.imageNone`)},get description(){return B.t(`helpers.ruleFormParsers.imageNoneDesc`)}}];function td(e){return ed.find(t=>t.value===e)?.value}var nd=[{value:``,get label(){return B.t(`helpers.ruleFormParsers.linkedDefault`)}},{value:`mosaic`,get label(){return B.t(`helpers.ruleFormParsers.linkedMosaic`)}},{value:`each`,get label(){return B.t(`helpers.ruleFormParsers.linkedEach`)}}];function rd(e){let t=nd.find(t=>t.value===e)?.value;return t===``?void 0:t}var id=[{value:``,get label(){return B.t(`helpers.ruleFormParsers.profileLowest`)}},{value:`low`,get label(){return B.t(`helpers.ruleFormParsers.profileLow`)}},{value:`mid`,get label(){return B.t(`helpers.ruleFormParsers.profileMid`)}},{value:`high`,get label(){return B.t(`helpers.ruleFormParsers.profileHigh`)}}];function ad(e){let t=id.find(t=>t.value===e)?.value;return t===``?void 0:t}var od=[{value:`any`,get label(){return B.t(`helpers.ruleFormParsers.srcAny`)}},{value:`pipeline`,get label(){return B.t(`helpers.ruleFormParsers.srcPipeline`)}},{value:`onboard`,get label(){return B.t(`helpers.ruleFormParsers.srcOnboard`)}},{value:`sensor`,get label(){return B.t(`helpers.ruleFormParsers.srcSensor`)}}],sd=[{value:`delivered`,get label(){return B.t(`helpers.ruleFormParsers.phaseDelivered`)}},{value:`picked-up`,get label(){return B.t(`helpers.ruleFormParsers.phasePickedUp`)}},{value:`both`,get label(){return B.t(`helpers.ruleFormParsers.phaseBoth`)}}],cd=[{value:``,get label(){return B.t(`helpers.ruleFormParsers.stBoth`)}},{value:`raised`,get label(){return B.t(`helpers.ruleFormParsers.stRaised`)}},{value:`cleared`,get label(){return B.t(`helpers.ruleFormParsers.stCleared`)}}];function ld(e){return e===`raised`||e===`cleared`?e:void 0}function ud(e,t){return e===`sensorTransition`?xt(t.sensorKinds):!0}var dd=[{value:`enter`,get label(){return B.t(`helpers.ruleFormParsers.crossEnter`)}},{value:`exit`,get label(){return B.t(`helpers.ruleFormParsers.crossExit`)}},{value:`any`,get label(){return B.t(`helpers.ruleFormParsers.crossAny`)}}],fd=`enter`;function pd(e){return e===`exit`||e===`any`?e:void 0}var md=[{value:1,get label(){return B.t(`helpers.ruleFormParsers.prioMin`)}},{value:2,get label(){return B.t(`helpers.ruleFormParsers.prioLow`)}},{value:3,get label(){return B.t(`helpers.ruleFormParsers.prioDefault`)}},{value:4,get label(){return B.t(`helpers.ruleFormParsers.prioHigh`)}},{value:5,get label(){return B.t(`helpers.ruleFormParsers.prioMax`)}}];function hd(e,t){return e.options&&e.options.length>0?e.options:t}var gd=[{value:``,get label(){return B.t(`helpers.ruleFormParsers.speedDefault`)}},{value:`1`,get label(){return B.t(`helpers.ruleFormParsers.speedReal`)}},{value:`2`,label:`2×`},{value:`3`,label:`3×`},{value:`4`,label:`4×`},{value:`6`,label:`6×`},{value:`8`,label:`8×`}];function _d(e){if(e===``)return;let t=Number(e);return Number.isFinite(t)&&t>=1&&t<=8?t:void 0}var vd=`notificationRules.systemEventKinds.`,yd=`notificationRules.systemEventGroups.`,bd=`notificationRules.systemEventHints.`;function xd(e){return!_t.some(t=>t===e)}function Sd(e){let t=`${vd}${e}`;return B.exists(t)?B.t(t):e}function Cd(){return Dt.map(e=>({id:e.id,family:e.family,label:B.t(`${yd}${e.id}`,e.label),hint:B.t(`${bd}${e.id}`),kinds:e.kinds.filter(xd).map(e=>({value:e,label:Sd(e)}))}))}function wd(e){return Cd().filter(t=>t.family===e)}function Td(e){let t=ft(e).conditions.systemEvent;return t===void 0?{kinds:(wd(e)[0]?.kinds??[]).map(e=>e.value)}:{...t,kinds:[...t.kinds]}}function Ed(){return Cd().flatMap(e=>e.kinds)}function Dd(e){return{devices:ct(e,`deviceIds`),deviceTypes:ct(e,`deviceTypes`),nodes:ct(e,`nodeIds`),packages:ct(e,`packageNames`),consumableThreshold:ct(e,`consumableLowPercent`)}}function Od(e,t){let n=pt[e],r=Dd(t);return{devices:n.includes(`deviceIds`)&&r.devices,excludeDevices:n.includes(`excludeDeviceIds`)&&r.devices,deviceTypes:n.includes(`deviceTypes`)&&r.deviceTypes,nodes:n.includes(`nodeIds`)&&r.nodes,packages:n.includes(`packageNames`)&&r.packages,consumableThreshold:n.includes(`consumableLowPercent`)&&r.consumableThreshold}}var kd=Object.values(dt).map(e=>({value:e,label:Ad(e)})).toSorted((e,t)=>e.label.localeCompare(t.label));function Ad(e){let t=e.replaceAll(`-`,` `);return t.charAt(0).toUpperCase()+t.slice(1)}function jd(e,t){let n=[],r=new Set;for(let i of e.kinds){let e=At(i.value);if(e===void 0){n.push({key:i.value,label:i.label,kinds:[i.value],clears:[i.value]});continue}r.has(e.id)||(r.add(e.id),n.push({key:`class:${e.id}`,label:t?e.snapshotLabel:e.label,kinds:t?[...e.bad]:St(e),clears:St(e),classId:e.id,...t&&e.snapshotSection===null?{noSnapshot:!0}:{}}))}return n}function Md(e,t){return t.clears.some(t=>e.includes(t))}function Nd(e,t,n){if(!wd(n).some(e=>e.kinds.some(e=>t.kinds.includes(e.value))))return e;let r=e?.kinds??[];if(Md(r,t)){let i=r.filter(e=>!t.clears.includes(e));return i.length===0?e:Ld(e,i,n)}return Ld(e,Ed().filter(e=>t.kinds.includes(e.value)||r.includes(e.value)).map(e=>e.value),n)}function Pd(e,t){return t===void 0?void 0:Ld(t,t.kinds,e)}function Fd(e,t){let n=e?.kinds??[];if(n.length===0)return;let r=Id(t,`deviceIds`,e?.deviceIds),i=Id(t,`excludeDeviceIds`,e?.excludeDeviceIds),a=Id(t,`deviceTypes`,e?.deviceTypes),o=Id(t,`nodeIds`,e?.nodeIds),s=Id(t,`packageNames`,e?.packageNames),c=Object.prototype.hasOwnProperty.call(t,`consumableLowPercent`)?t.consumableLowPercent:e?.consumableLowPercent;return{kinds:[...n],...r===void 0?{}:{deviceIds:[...r]},...i===void 0?{}:{excludeDeviceIds:[...i]},...a===void 0?{}:{deviceTypes:[...a]},...o===void 0?{}:{nodeIds:[...o]},...s===void 0?{}:{packageNames:[...s]},...c===void 0?{}:{consumableLowPercent:c}}}function Id(e,t,n){let r=Object.prototype.hasOwnProperty.call(e,t)?e[t]:n;return r!==void 0&&r.length===0?void 0:r}function Ld(e,t,n){let r=Od(n,t),i=r.devices?e?.deviceIds:void 0,a=r.excludeDevices?e?.excludeDeviceIds:void 0,o=r.deviceTypes?e?.deviceTypes:void 0,s=r.nodes?e?.nodeIds:void 0,c=r.packages?e?.packageNames:void 0,l=r.consumableThreshold?e?.consumableLowPercent:void 0;return{kinds:[...t],...i&&i.length>0?{deviceIds:[...i]}:{},...a&&a.length>0?{excludeDeviceIds:[...a]}:{},...o&&o.length>0?{deviceTypes:[...o]}:{},...s&&s.length>0?{nodeIds:[...s]}:{},...c&&c.length>0?{packageNames:[...c]}:{},...l===void 0?{}:{consumableLowPercent:l}}}var Rd=95;function zd(e){let t=e.trim();if(t===``)return{kind:`clear`};let n=Number(t);return Number.isInteger(n)&&n>=1&&n<=Rd?{kind:`set`,value:n}:{kind:`invalid`}}function Bd(e,t=2){if(e===void 0||e.length===0)return B.t(`helpers.notificationSystemEvents.noneSelected`);let n=e.slice(0,t).map(Sd).join(`, `),r=e.length-Math.min(t,e.length);return r>0?`${n} +${r}`:n}function Vd(e){if(e===void 0)return`—`;let t=[],n=e.deviceIds?.length??0,r=e.deviceTypes?.length??0,i=e.nodeIds?.length??0,a=e.packageNames?.length??0,o=e.excludeDeviceIds?.length??0;r>0&&t.push(e.deviceTypes?.map(Ad).join(`, `)??``),n>0&&t.push(`${n} device${n===1?``:`s`}`),i>0&&t.push(`${i} node${i===1?``:`s`}`),a>0&&t.push(`${a} package${a===1?``:`s`}`);let s=o>0?`except ${o} device${o===1?``:`s`}`:null,c=e.consumableLowPercent===void 0?[]:[`consumables at ${e.consumableLowPercent}%`];return t.length===0?[s===null?`Everything`:`Everything ${s}`,...c].join(` · `):[...t,...s===null?[]:[s],...c].join(` · `)}function Hd(e){return e===void 0||(e.deviceTypes?.length??0)===0?!1:e.kinds.some(e=>lt.includes(e))}var Ud=[`all`,`only`,`except`];function Wd(e,t){return(e??[]).length>0?`only`:(t??[]).length>0?`except`:`all`}function Gd(e,t){let n=[...e??[]],r=[...t??[]];return{mode:Wd(n,r),include:n,exclude:r,legacyBoth:n.length>0&&r.length>0}}function Kd(e,t){return{...e,mode:t}}function qd(e){switch(e.mode){case`only`:return e.include;case`except`:return e.exclude;case`all`:return[]}}function Jd(e,t){switch(e.mode){case`only`:return{...e,include:[...t]};case`except`:return{...e,exclude:[...t]};case`all`:return e}}function Yd(e){return e.mode===`only`&&e.legacyBoth?e.exclude:[]}function Xd(e){return{...e,exclude:[],legacyBoth:!1}}function Zd(e){switch(e.mode){case`all`:return{};case`except`:return e.exclude.length>0?{exclude:[...e.exclude]}:{};case`only`:{let t=Yd(e);return{...e.include.length>0?{include:[...e.include]}:{},...t.length>0?{exclude:[...t]}:{}}}}}function Qd(e){let t=Zd(e),n=t.include??[],r=t.exclude??[];return[...e.include.filter(e=>!n.includes(e)),...e.exclude.filter(e=>!r.includes(e))]}var $d=[`onActivation`,`onDeactivation`,`onTrigger`,`onTriggerOff`],ef={onActivation:{get title(){return B.t(`helpers.notificationRuleActions.onActivationTitle`)},get hint(){return B.t(`helpers.notificationRuleActions.onActivationHint`)}},onDeactivation:{get title(){return B.t(`helpers.notificationRuleActions.onDeactivationTitle`)},get hint(){return B.t(`helpers.notificationRuleActions.onDeactivationHint`)}},onTrigger:{get title(){return B.t(`helpers.notificationRuleActions.onTriggerTitle`)},get hint(){return B.t(`helpers.notificationRuleActions.onTriggerHint`)}},onTriggerOff:{get title(){return B.t(`helpers.notificationRuleActions.onTriggerOffTitle`)},get hint(){return B.t(`helpers.notificationRuleActions.onTriggerOffHint`)}}},tf={onActivation:[],onDeactivation:[],onTrigger:[],onTriggerOff:[],buttons:[]};function nf(e){return e===void 0?tf:{onActivation:[...e.onActivation??[]],onDeactivation:[...e.onDeactivation??[]],onTrigger:[...e.onTrigger??[]],onTriggerOff:[...e.onTriggerOff??[]],buttons:[...e.buttons??[]]}}function rf(e){let t=e.buttons.filter(e=>e.id.trim()!==``&&e.label.trim()!==``&&e.sequenceId.trim()!==``),n={onActivation:e.onActivation,onDeactivation:e.onDeactivation,onTrigger:e.onTrigger,onTriggerOff:e.onTriggerOff};if(!(!$d.some(e=>n[e].length>0)&&t.length===0))return{...n.onActivation.length>0?{onActivation:[...n.onActivation]}:{},...n.onDeactivation.length>0?{onDeactivation:[...n.onDeactivation]}:{},...n.onTrigger.length>0?{onTrigger:[...n.onTrigger]}:{},...n.onTriggerOff.length>0?{onTriggerOff:[...n.onTriggerOff]}:{},...t.length>0?{buttons:t}:{}}}function af(e,t){let n=[];for(let r of $d){let i=e[r];i.length>4&&n.push({kind:`too-many`,message:B.t(`helpers.notificationRuleActions.tooMany`,{title:ef[r].title})});for(let e of i)e.kind===`sequence`&&!t.has(e.sequenceId)&&n.push({kind:`unknown-sequence`,message:B.t(`helpers.notificationRuleActions.hookUnknownSeq`,{title:ef[r].title})})}let r=new Set;for(let i of e.buttons){let e=i.id.trim();e!==``&&(r.has(e)&&n.push({kind:`duplicate-button`,message:B.t(`helpers.notificationRuleActions.dupButton`,{id:e})}),r.add(e),t.has(i.sequenceId.trim())||n.push({kind:`unknown-sequence`,message:B.t(`helpers.notificationRuleActions.buttonUnknownSeq`,{label:i.label||e})}))}return n}function of(e,t){return{id:`action-${String(e+1)}`,label:B.t(`helpers.notificationRuleActions.newButtonLabel`),sequenceId:t}}function sf(){return{kind:`do`,action:{kind:`cap`,deviceId:0,cap:``,method:``}}}function cf(e){return{kind:`sequence`,sequenceId:e}}function lf(){return{kind:`wait`,seconds:5}}var uf=[{value:`acknowledge`,get label(){return B.t(`helpers.notificationRuleActions.icon_acknowledge`)}},{value:`dismiss`,get label(){return B.t(`helpers.notificationRuleActions.icon_dismiss`)}},{value:`silence`,get label(){return B.t(`helpers.notificationRuleActions.icon_silence`)}},{value:`snooze`,get label(){return B.t(`helpers.notificationRuleActions.icon_snooze`)}},{value:`view`,get label(){return B.t(`helpers.notificationRuleActions.icon_view`)}},{value:`play`,get label(){return B.t(`helpers.notificationRuleActions.icon_play`)}},{value:`camera`,get label(){return B.t(`helpers.notificationRuleActions.icon_camera`)}},{value:`open`,get label(){return B.t(`helpers.notificationRuleActions.icon_open`)}},{value:`close`,get label(){return B.t(`helpers.notificationRuleActions.icon_close`)}},{value:`unlock`,get label(){return B.t(`helpers.notificationRuleActions.icon_unlock`)}},{value:`lock`,get label(){return B.t(`helpers.notificationRuleActions.icon_lock`)}},{value:`disarm`,get label(){return B.t(`helpers.notificationRuleActions.icon_disarm`)}},{value:`arm`,get label(){return B.t(`helpers.notificationRuleActions.icon_arm`)}},{value:`arm-home`,get label(){return B.t(`helpers.notificationRuleActions.icon_arm_home`)}},{value:`arm-away`,get label(){return B.t(`helpers.notificationRuleActions.icon_arm_away`)}},{value:`arm-night`,get label(){return B.t(`helpers.notificationRuleActions.icon_arm_night`)}},{value:`light`,get label(){return B.t(`helpers.notificationRuleActions.icon_light`)}},{value:`alert`,get label(){return B.t(`helpers.notificationRuleActions.icon_alert`)}}],df=[10,30,60],ff=[5,10,15,30,60,120,240,480];function pf(e){return e>=60&&e%60==0?B.t(`helpers.ruleFormState.snoozeHours`,{count:e/60}):B.t(`helpers.ruleFormState.snoozeMin`,{count:e})}var mf=new Set([`alarm-arm-refused`,`alarm-check-failed`,`alarm-arming`,`alarm-armed`,`alarm-pending`,`alarm-triggered`,`alarm-rearmed`,`alarm-sensor-bypass`,`alarm-disarmed`]),hf=`alarm-panel`;function gf(e,t){for(let t of e.systemEvent?.kinds??[])if(mf.has(t))return!0;for(let e of t)if(e.kind===`cap`&&e.cap===hf)return!0;return!1}function _f(e,t){let n=new Map(t.map(e=>[e.id,e])),r=[];for(let t of[`onActivation`,`onDeactivation`,`onTrigger`,`onTriggerOff`])for(let i of e[t])if(i.kind===`do`)r.push(i.action);else{let e=n.get(i.sequenceId);e!==void 0&&r.push(...e.actions)}for(let t of e.buttons){let e=n.get(t.sequenceId);e!==void 0&&r.push(...e.actions)}return r}function vf(e){let{devices:t,devicesExclude:n,classes:r,classesExclude:i,...a}=e;return{conditions:a,deviceScope:Gd(t,n),classScope:Gd(r,i)}}function yf(e){let t=Zd(e.deviceScope),n=Zd(e.classScope);return{...e.conditions,...t.include===void 0?{}:{devices:[...t.include]},...t.exclude===void 0?{}:{devicesExclude:[...t.exclude]},...n.include===void 0?{}:{classes:[...n.include]},...n.exclude===void 0?{}:{classesExclude:[...n.exclude]}}}function bf(e){return e.deviceScope.mode===`only`?e.deviceScope.include:[]}function xf(e,t,n){let r=zt(n);return e.some(e=>e.id===t&&Yt(e,n.delivery,r))}function Sf(e=`immediate`,t={}){return{name:``,enabled:!0,delivery:e,targetIds:[],targetUsers:[],targetParams:{},priority:3,mediaImage:Gt({},zt({delivery:e,conditions:t})),mediaShowTriggerZone:!1,mediaShowSubjectPath:!1,mediaGif:!1,mediaClip:!1,mediaProfile:void 0,mediaClipSpeed:void 0,mediaLinkedCameras:void 0,templateTitle:``,templateBody:``,...vf(t),schedule:void 0,systemEventDelivery:void 0,snoozeAllowGlobal:!1,groupingSec:void 0,snoozeOptions:void 0,askVerdict:void 0,actions:tf,cooldownSec:30,cooldownScope:`rule-device`,cooldownGranularity:void 0}}function Cf(e){let t={};for(let n of e.targets)n.params&&Object.keys(n.params).length>0&&(t[n.targetId]=n.params);return{name:e.name,enabled:e.enabled,delivery:e.delivery,targetIds:e.targets.map(e=>e.targetId),targetUsers:e.targetUsers??[],targetParams:t,priority:e.priority,mediaImage:Gt(e.media,zt(e)),mediaShowTriggerZone:e.media.showTriggerZone===!0,mediaShowSubjectPath:e.media.showSubjectPath===!0,mediaGif:e.media.gif===!0,mediaClip:e.media.clip===!0,mediaProfile:e.media.profile,mediaClipSpeed:e.media.clipSpeed,mediaLinkedCameras:e.media.linkedCameras,templateTitle:e.template?.title??``,templateBody:e.template?.body??``,...vf(e.conditions),schedule:e.schedule,systemEventDelivery:e.systemEventDelivery,snoozeAllowGlobal:e.snoozeAllowGlobal===!0,groupingSec:e.groupingSec,snoozeOptions:e.snoozeOptions,askVerdict:e.askVerdict,actions:nf(e.actions),cooldownSec:e.throttle.cooldownSec,cooldownScope:e.throttle.scope,cooldownGranularity:e.throttle.granularity}}function wf(e,t){let n=[];if(Mf(e)){let r=e.groupingSec;r!==void 0&&(!Number.isInteger(r)||r<5||r>60)&&n.push(`The grouping window is a whole number of seconds between 5 and 60.`);let i=t?.confirm;i?.enabled===!0&&i.expect!==void 0&&!Nf(i.expect)&&n.push(`This rule’s AI confirm expects more than one subject, but a grouped message judges one picture per subject, so it would never send. Remove the confirm expectation (viewer or API), or choose Immediate.`)}if(jt(e.conditions.audio)&&n.push(`This sound rule names neither a sound nor a level threshold, so it can never fire — every sample would count as a hit and the engine refuses it rather than notifying on silence. Pick at least one sound, or add a level.`),(!Number.isInteger(e.cooldownSec)||e.cooldownSec<0||e.cooldownSec>86400)&&n.push(`The cooldown is a whole number of seconds between 0 and ${String(qu)} (24 hours). 0 means every match is delivered.`),Df(e))for(let t of Ot({delivery:e.delivery,conditions:e.conditions,...e.systemEventDelivery===void 0?{}:{systemEventDelivery:e.systemEventDelivery},...rf(e.actions)===void 0?{}:{actions:rf(e.actions)}}))n.push(ot(t));return n}function Tf(e){let t=e.systemEventDelivery;if(t===void 0)return{};if(!Ut(e.delivery))return t.mode===`summary`?{systemEventDelivery:{mode:`instant`}}:{};if(t.mode===`summary`&&Et(t.schedule)===null){let e=wt(t.schedule);if(e!==null&&e.times.length>0)return{systemEventDelivery:{...t,schedule:Wt(e.times,t.schedule.timezone)}}}return{systemEventDelivery:t}}function Ef(e){if(!Df(e))return null;if(!yt(e.templateBody))return B.t(`helpers.ruleFormState.summaryWarnNone`,{token:`{{summaryText}}`});let t=e.templateBody;return(e.systemEventDelivery?.mode===`summary`?e.systemEventDelivery.split:void 0)===`section`&&t.trim().length>0&&!/\{\{\s*summaryText\s*\}\}/.test(t)?B.t(`helpers.ruleFormState.summaryWarnSplit`,{token:`{{summaryText}}`}):null}function Df(e){return Ut(e.delivery)&&e.systemEventDelivery?.mode===`summary`}function Of(e,t,n=new Set){return wf(e,t).length===0&&Vu(e.delivery)&&(!Ut(e.delivery)||Lf(e)>0)&&zt(e)!==`mixed`&&e.name.trim().length>0&&(e.targetIds.length>0||e.targetUsers.length>0)&&af(e.actions,n).length===0}function kf(e,t){let n=Ff(e.conditions,t);return Ut(t)&&(n.systemEvent?.kinds.length??0)===0?{...e,delivery:t,conditions:{...n,systemEvent:Td(`device-events`)}}:{...e,delivery:t,conditions:n}}function Af(e,t){return t===`immediate-grouped`?{...kf(e,`immediate`),groupingSec:e.groupingSec??20}:{...kf(e,t),groupingSec:void 0}}function jf(e){return e.delivery===`immediate`||e.delivery===`track-end`}function Mf(e){return e.groupingSec!==void 0&&nn(e)}function Nf(e){switch(e.op){case`>`:return 1>e.count;case`<=`:return 1<=e.count;case`<`:return 1<e.count;case`==`:return e.count===1;default:return 1>=e.count}}var Pf=new Set([`immediate`,`track-end`,`package-event`]);function Ff(e,t){if(e.source!==`pipeline`||Pf.has(t))return e;let{source:n,...r}=e;return r}function If(e,t){return Mt(e.conditions.systemEvent)===t?e:{...e,conditions:{...e.conditions,systemEvent:Td(t)}}}function Lf(e){return e.conditions.systemEvent?.kinds.length??0}function Rf(e,t){return e.appliesTo.includes(t)}var zf={source:`any`};function Bf(e,t){if(t==null)return!0;if(Array.isArray(t))return t.length===0;if(typeof t==`string`)return t.length===0||zf[e]===t;if(typeof t==`number`)return!Number.isFinite(t);if(typeof t==`object`){if(`ids`in t){let e=t.ids;return!Array.isArray(e)||e.length===0}if(`values`in t){let e=t.values;return!Array.isArray(e)||e.length===0}return!1}return!1}var Vf=Pt.filter(e=>e.id===`audio`);function Hf(e){if(e.length===0)return e;let t=new Set(e.map(e=>e.id)),n=Vf.filter(e=>!t.has(e.id));return n.length===0?e:[...e,...n]}function Uf(e,t,n,r=zt({delivery:t,conditions:e})){let i=n.length===0?null:new Set(n.filter(e=>e.id!==`schedule`&&Yt(e,t,r)).map(e=>e.id)),a={};for(let[t,n]of Object.entries(e))i!==null&&!i.has(t)||ud(t,e)&&(Bf(t,n)||(a[t]=n));return a}function Wf(e,t){if(e===void 0)return{};let n=Pd(e,t.systemEvent);return n===void 0?{}:{systemEvent:n}}function Gf(e){return e!==void 0&&e.windows.length>0}function Kf(e){let t={...e.clipPreRollSec===void 0?{}:{clipPreRollSec:e.clipPreRollSec},...e.clipPostRollSec===void 0?{}:{clipPostRollSec:e.clipPostRollSec}};return Object.keys(t).length>0?t:void 0}function qf(e){let t=Kf(e.media);return{...e.confirm===void 0?{}:{confirm:e.confirm},...t===void 0?{}:{media:t}}}function Jf(e,t,n=[]){let r=e.templateTitle.trim(),i=e.templateBody.trim(),a=r.length>0||i.length>0?{...r.length>0?{title:r}:{},...i.length>0?{body:i}:{}}:void 0,o=rf(e.actions),s=zt(e),c=tn(s),l=en(s),u=n.length===0?!0:n.some(t=>t.id===`schedule`&&Rf(t,e.delivery)),d=!Df(e)&&u&&Gf(e.schedule)?e.schedule:void 0,f=n.length===0?!0:n.some(t=>t.id===`devices`&&Rf(t,e.delivery)),p=n.length===0?!0:n.some(t=>t.id===`devicesExclude`&&Rf(t,e.delivery)),{devices:m,devicesExclude:h,...g}=yf(e),_=Uf(g,e.delivery,n,s);return{name:e.name.trim(),enabled:e.enabled,delivery:e.delivery,conditions:{..._,...f&&m!==void 0?{devices:m}:{},...p&&h!==void 0?{devicesExclude:h}:{},...Wf(l,e.conditions)},...d?{schedule:d}:{},...Tf(e),targets:e.targetIds.map(t=>{let n=e.targetParams[t];return n&&Object.keys(n).length>0?{targetId:t,params:n}:{targetId:t}}),...e.targetUsers.length>0?{targetUsers:[...e.targetUsers]}:{},media:c.carriesMedia?{image:e.mediaImage,...e.mediaShowTriggerZone&&e.mediaImage!==`crop`&&e.mediaImage!==`none`&&$t(_).length>0?{showTriggerZone:!0}:{},...e.mediaShowSubjectPath&&e.mediaImage!==`none`&&Bt(s)?{showSubjectPath:!0}:{},...e.mediaGif?{gif:!0}:{},...e.mediaClip?{clip:!0}:{},...e.mediaProfile===void 0?{}:{profile:e.mediaProfile},...e.mediaClipSpeed===void 0?{}:{clipSpeed:e.mediaClipSpeed},...s===`sensor`&&e.mediaImage!==`none`&&e.mediaLinkedCameras!==void 0?{linkedCameras:e.mediaLinkedCameras}:{},...(e.mediaGif||e.mediaClip)&&t?.media?.clipPreRollSec!==void 0?{clipPreRollSec:t.media.clipPreRollSec}:{},...(e.mediaGif||e.mediaClip)&&t?.media?.clipPostRollSec!==void 0?{clipPostRollSec:t.media.clipPostRollSec}:{}}:{image:`none`},throttle:{cooldownSec:e.cooldownSec,scope:e.cooldownScope,...e.cooldownGranularity===void 0?{}:{granularity:e.cooldownGranularity}},priority:e.priority,...a?{template:a}:{},...e.snoozeAllowGlobal?{snoozeAllowGlobal:!0}:{},...Mf(e)?{groupingSec:e.groupingSec}:{},...e.snoozeOptions===void 0?{}:{snoozeOptions:[...e.snoozeOptions]},...e.askVerdict!==void 0&&jf(e)?{askVerdict:e.askVerdict}:{},...t?.confirm===void 0?{}:{confirm:t.confirm},...o===void 0?{}:{actions:o}}}function Yf(e,t){let n=Jf(e,void 0,t);return[`template`,`schedule`,`targetUsers`,`snoozeOptions`,`snoozeAllowGlobal`,`groupingSec`,`actions`].filter(e=>n[e]===void 0)}var Xf=[{key:`rule`,get label(){return B.t(`helpers.ruleFormTabs.tab_rule`)},fields:[`name`,`enabled`,`delivery`,`groupingSec`,`targetIds`,`targetUsers`,`targetParams`]},{key:`devices`,get label(){return B.t(`helpers.ruleFormTabs.tab_devices`)},fields:[`deviceScope`]},{key:`conditions`,get label(){return B.t(`helpers.ruleFormTabs.tab_conditions`)},fields:[`conditions`,`classScope`,`schedule`,`systemEventDelivery`]},{key:`notification`,get label(){return B.t(`helpers.ruleFormTabs.tab_notification`)},fields:[`priority`,`mediaImage`,`mediaShowTriggerZone`,`mediaShowSubjectPath`,`mediaGif`,`mediaClip`,`mediaProfile`,`mediaClipSpeed`,`mediaLinkedCameras`,`templateTitle`,`templateBody`]},{key:`actions`,get label(){return B.t(`helpers.ruleFormTabs.tab_actions`)},fields:[`actions`]},{key:`advanced`,get label(){return B.t(`helpers.ruleFormTabs.tab_advanced`)},fields:[`snoozeAllowGlobal`,`snoozeOptions`,`askVerdict`,`cooldownSec`,`cooldownScope`,`cooldownGranularity`]}];function Zf(e,t={}){let n=zt({delivery:e,conditions:t}),r=tn(n),i=Xf.map(e=>e.key===`conditions`?{...e,label:r.label}:e);return Ht(n)?i.filter(e=>e.key!==`devices`):i}function Qf(e){if(e.audio!==void 0)return B.t(`helpers.ruleFormTabs.condSound`);if(e.occupancy!==void 0)return B.t(`helpers.ruleFormTabs.condOccupancy`)}function $f(e){let t=zt(e),n=Kt(yf(e),t);return t===`sensor`&&e.conditions.sensorTransition!==void 0&&!ud(`sensorTransition`,e.conditions)?[...n,{conditionId:`sensorTransition`,reason:gt}]:n}var ep=`rule`;function tp(e){return Xf.find(t=>t.key===e)?.key}function np(e){return e?.toLowerCase().startsWith(`it`)===!0?`it`:`en`}function rp(){let{i18n:e}=V(),t=np(e.language);return e=>mt(e,t)}D();var ip=`block text-[11px] font-medium text-foreground`,ap=`text-[10px] text-foreground-subtle mt-0.5`;function op({cameras:e,fleet:t,value:n,onChange:r,emptyMeansAll:i=!1,savedHadDevices:a=!1}){return b(wn,{devices:e,listState:t.state,fleet:t,value:n,onChange:r,emptyMeansAll:i,savedHadDevices:a})}function sp({value:e,placeholder:t,onChange:n}){let{t:r}=V(),[i,a]=C(``),s=()=>{let t=i.trim();if(t.length===0||e.includes(t)){a(``);return}n([...e,t]),a(``)},c=t=>n(e.filter(e=>e!==t));return o(`div`,{className:`mt-1 space-y-1.5`,children:[e.length>0&&b(`div`,{className:`flex flex-wrap gap-1`,children:e.map(e=>o(`span`,{className:`inline-flex items-center gap-1 rounded bg-surface-hover px-1.5 py-0.5 text-[11px] text-foreground`,children:[e,b(`button`,{type:`button`,onClick:()=>c(e),"aria-label":r(`system.notificationConditionWidgets.remove`,`remove {{v}}`,{v:e}),className:`text-foreground-subtle hover:text-danger`,children:b(Pe,{className:`h-3 w-3`})})]},e))}),b(Sn,{value:i,placeholder:t,onChange:e=>a(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),s())},onBlur:s})]})}function cp({picker:e,value:t,onChange:n}){let{t:r}=V(),i=p(()=>Tt(e),[e]),a=p(()=>new Set(t),[t]),s=t.filter(e=>!i.has(e)),c=e=>{n(a.has(e)?t.filter(t=>t!==e):[...t,e])};return o(`div`,{className:`space-y-2`,children:[s.length>0&&b(`div`,{className:`flex flex-wrap gap-1`,children:s.map(e=>o(`button`,{type:`button`,onClick:()=>n(t.filter(t=>t!==e)),className:`inline-flex items-center gap-1 rounded border border-border px-1.5 py-0.5 text-[10px] text-foreground hover:bg-surface-hover`,title:r(`system.notificationConditionWidgets.customValueClickToRemove`,`Custom value — click to remove`),children:[e,` ×`]},e))}),e.groups.map(e=>o(`div`,{children:[b(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-muted mb-1`,children:e.fallbackLabel}),b(`div`,{className:`flex flex-wrap gap-1`,children:e.options.map(e=>{let t=a.has(e.value);return b(`button`,{type:`button`,"aria-pressed":t,onClick:()=>c(e.value),className:t?`rounded border border-primary bg-primary/15 px-1.5 py-0.5 text-[10px] text-foreground`:`rounded border border-border px-1.5 py-0.5 text-[10px] text-foreground hover:bg-surface-hover`,children:e.label},e.value)})})]},e.key))]})}function lp({value:e,min:t,max:n,step:r,onChange:i}){let{t:a}=V();return o(`div`,{className:`mt-1 flex items-center gap-2`,children:[b(Sn,{type:`number`,value:e??``,min:t,max:n,step:r,className:`max-w-[8rem]`,onChange:e=>{let t=e.target.value;if(t===``){i(void 0);return}let n=Number(t);i(Number.isFinite(n)?n:void 0)}}),e!==void 0&&n!==void 0&&b(`input`,{type:`range`,min:t,max:n,step:r,value:e,onChange:e=>i(Number(e.target.value)),className:`flex-1 accent-primary`,"aria-label":a(`common.valueWord`)})]})}function up({value:e,onChange:t,options:n}){let{t:r}=V(),i=dp(n??[]),a=i.length>0?i:dd;return o(`div`,{className:`mt-1 space-y-1`,children:[b(Qn,{value:e??`enter`,options:a.map(e=>({value:e.value,label:r(`notificationRules.crossing.${e.value}`,e.label)})),onChange:e=>t(pd(e.target.value))}),b(`p`,{className:ap,children:r(`notificationRules.crossing.hint`,`Which way the subject crosses the zone.`)})]})}function dp(e){let t=[];for(let n of e){let e=n.value===``||n.value===`enter`?fd:pd(n.value);e===void 0||t.some(t=>t.value===e)||t.push({value:e,label:n.label})}return t}function fp({deviceIds:e,cameras:t,value:n,onChange:r}){let{options:i,loading:a}=Du(e,t);return b(ju,{options:i,value:n,onChange:r,loading:a,noFreeText:!0,emptyHint:e.length===0?`Select cameras first — a rule can only use zones those cameras actually have.`:`The selected cameras have no zones. Draw one in the camera’s zone editor first.`,placeholder:``})}function pp({deviceIds:e,value:t,onChange:n}){let{t:r}=V(),{options:i,loading:a}=Ou(e);return b(ju,{options:i,value:t,onChange:n,loading:a,emptyHint:e.length===0?`Select cameras above to pick their event kinds — or type a token.`:`No event kinds reported for the selected cameras — type a token.`,placeholder:r(`system.notificationConditionWidgets.eventToken`,`Event token…`)})}var mp=[{value:`became-occupied`,labelKey:`system.notificationConditionWidgets.opBecameOccupied`},{value:`became-free`,labelKey:`system.notificationConditionWidgets.opBecameFree`},{value:`>=`,labelKey:`system.notificationConditionWidgets.opCountAtLeast`},{value:`<=`,labelKey:`system.notificationConditionWidgets.opCountAtMost`}];function hp(e,t){let n=e.map(e=>({value:e.value,label:e.label}));return t===void 0||t===``||n.some(e=>e.value===t)?n:[...n,{value:t,label:B.t(`system.notificationConditionWidgets.subTypeNeverCountsAlways`,`{{stored}} — sub-type, never counts (always 0)`,{stored:t})}]}function gp({deviceIds:e,cameras:t,classOptions:n,value:r,onChange:i}){let{t:a}=V(),{options:s,loading:c}=Du(e,t),l=r??Vt,u=e=>i({...l,...e}),d=l.op===`became-occupied`||l.op===`became-free`,f=hp(n,l.className);return o(`div`,{className:`mt-1 space-y-1.5`,children:[o(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[b(`div`,{className:`min-w-[10rem]`,children:b(Qn,{value:l.zoneId??``,options:[{value:``,label:c?a(`system.notificationConditionWidgets.loadingZones`,`Loading zones…`):a(`system.notificationConditionWidgets.wholeFrame`,`— whole frame —`)},...s.map(e=>({value:e.value,label:e.label}))],onChange:e=>u({zoneId:e.target.value===``?void 0:e.target.value})})}),b(`div`,{className:`min-w-[9rem]`,children:b(Qn,{value:l.className??``,options:[{value:``,label:a(`system.notificationConditionWidgets.anyClass`,`— any class —`)},...f],onChange:e=>u({className:e.target.value===``?void 0:e.target.value})})}),b(`div`,{className:`min-w-[9rem]`,children:b(Qn,{value:l.op,options:mp.map(e=>({value:e.value,label:a(e.labelKey)})),onChange:e=>{let t=mp.find(t=>t.value===e.target.value);t&&u({op:t.value})}})})]}),o(`div`,{className:`flex flex-wrap items-center gap-3 text-xs text-foreground-subtle`,children:[o(`label`,{className:`flex items-center gap-1`,children:[d?a(`system.notificationConditionWidgets.threshold`,`Threshold`):a(`system.notificationConditionWidgets.count`,`Count`),b(Sn,{type:`number`,min:0,className:`w-16`,value:String(l.count),onChange:e=>u({count:Math.max(0,Number(e.target.value)||0)})})]}),o(`label`,{className:`flex items-center gap-1`,children:[a(`system.notificationConditionWidgets.holdFor`,`Hold for`),b(Sn,{type:`number`,min:0,max:3600,className:`w-16`,value:String(l.sustainSeconds),onChange:e=>u({sustainSeconds:Math.min(3600,Math.max(0,Number(e.target.value)||0))})}),`s`]}),r===void 0?null:b(`button`,{type:`button`,onClick:()=>i(void 0),className:`underline hover:text-foreground`,children:a(`system.notificationConditionWidgets.clear`,`Clear`)})]}),e.length===0&&b(`p`,{className:`text-[11px] text-warning`,children:a(`system.notificationConditionWidgets.noCameraPickedOnThe`,`No camera picked on the Devices tab: this watches EVERY camera's occupancy, and no zone can be offered until you choose one — a zone id belongs to a camera.`)}),b(`p`,{className:`text-[11px] text-foreground-subtle`,children:a(`system.notificationConditionWidgets.countsConfirmedTrackedObjectsFrom`,`Counts confirmed tracked objects from zone analytics. The change must hold for the sustain window before it fires; with no snapshot for the camera or zone the rule never fires.`)})]})}var _p=[{value:`label`,labelKey:`system.notificationConditionWidgets.audioModeLabel`,Icon:et},{value:`level`,labelKey:`system.notificationConditionWidgets.audioModeLevel`,Icon:Xe}];function vp({taxonomy:e,value:t,onChange:n}){let{t:r}=V(),i=Ft(t),a=e=>n(Nt(t,e)),{choices:s,unknownLabels:c}=rn(e,i.labels),l=ut(t)??`label`;return o(`div`,{className:`mt-1 space-y-2`,children:[o(`div`,{className:`flex flex-wrap items-center gap-1`,children:[_p.map(e=>b(`button`,{type:`button`,"aria-pressed":l===e.value,onClick:()=>a({mode:e.value}),className:`rounded border px-2 py-0.5 text-[11px] ${l===e.value?`border-primary bg-primary/15 text-foreground`:`border-border text-foreground-subtle hover:bg-surface-hover`}`,children:o(`span`,{className:`inline-flex items-center gap-1`,children:[b(e.Icon,{className:`h-3 w-3`}),r(e.labelKey)]})},e.value)),t===void 0?null:b(`button`,{type:`button`,onClick:()=>n(void 0),className:`ml-1 text-xs text-foreground-subtle underline hover:text-foreground`,children:r(`system.notificationConditionWidgets.clear`,`Clear`)})]}),l===`label`?o(P,{children:[b(`div`,{className:`flex flex-wrap gap-1`,children:s.map(e=>{let t=vt(i.labels,e.value),n=e.unknown?`border-dashed border-warning text-warning`:t?`border-primary bg-primary/15 text-foreground`:`border-border text-foreground hover:bg-surface-hover`;return b(`button`,{type:`button`,"aria-pressed":t,title:e.unknown?r(`system.notificationConditionWidgets.storedByTheRuleNot`,`Stored by the rule — not offered by this hub`):void 0,onClick:()=>a({labels:It(i.labels,e.value)}),className:`rounded border px-1.5 py-0.5 text-[10px] ${n}`,children:o(`span`,{className:`inline-flex items-center gap-1`,children:[b(_r,{iconId:e.iconId,size:12}),e.label]})},e.value)})}),c.length>0&&o(`p`,{className:`text-[10px] text-warning`,children:[r(`system.notificationConditionWidgets.keptFromTheRuleUnknown`,`Kept from the rule, unknown to this hub:`),` `,c.join(`, `)]}),o(`div`,{className:`flex flex-wrap items-center gap-3 text-xs text-foreground-subtle`,children:[o(`label`,{className:`flex items-center gap-1`,children:[r(`system.notificationConditionWidgets.confirmAfter`,`Confirm after`),b(Sn,{type:`number`,min:1,max:20,step:1,className:`w-16`,value:String(i.confirmHits??2),onChange:e=>a({confirmHits:Number(e.target.value)})}),r(`system.notificationConditionWidgets.frames`)]}),o(`label`,{className:`flex items-center gap-1`,children:[r(`system.notificationConditionWidgets.within`),b(Sn,{type:`number`,min:1,max:60,step:1,className:`w-16`,value:String(i.confirmWindowSec??5),onChange:e=>a({confirmWindowSec:Number(e.target.value)})}),`s`]})]}),b(`p`,{className:`text-[11px] text-foreground-subtle`,children:r(`system.notificationConditionWidgets.audioConfirmHint`,{hits:2,window:5})})]}):o(P,{children:[b(`div`,{className:`flex flex-wrap items-center gap-3 text-xs text-foreground-subtle`,children:o(`label`,{className:`flex items-center gap-1`,children:[r(`system.notificationConditionWidgets.louderThan`,`Louder than`),b(Sn,{type:`number`,min:ht,max:0,step:3,className:`w-20`,value:String(i.dbThreshold??bt),onChange:e=>a({dbThreshold:Number(e.target.value)})}),`dBFS`]})}),o(`div`,{className:`flex flex-wrap items-center gap-3 text-xs text-foreground-subtle`,children:[o(`label`,{className:`flex items-center gap-1`,children:[r(`system.notificationConditionWidgets.hits`,`Hits`),b(Sn,{type:`number`,min:1,max:100,step:5,className:`w-16`,value:String(i.hitPercent),onChange:e=>a({hitPercent:Number(e.target.value)})}),r(`system.notificationConditionWidgets.hitsPercentDefault`,{value:Ct.hitPercent})]}),o(`label`,{className:`flex items-center gap-1`,children:[r(`system.notificationConditionWidgets.over`),b(Sn,{type:`number`,min:1,max:300,step:5,className:`w-16`,value:String(i.samplingSeconds),onChange:e=>a({samplingSeconds:Number(e.target.value)})}),r(`system.notificationConditionWidgets.secondsDefault`,{value:Ct.samplingSeconds})]})]}),b(`p`,{className:`text-[11px] text-foreground-subtle`,children:r(`system.notificationConditionWidgets.dbfsHint`,{min:ht})})]}),jt(t)?b(`p`,{className:`text-[11px] text-warning`,children:r(`system.notificationConditionWidgets.withNeitherASoundNor`,`With neither a sound nor a level threshold this can never match — every sample would be a hit, so the engine refuses it rather than notifying on silence.`)}):null]})}function yp({value:e,onChange:t}){let{t:n}=V(),r=e?.values??[],i=e?.maxDistance??1,a=e=>t(e.length>0?{values:e,maxDistance:i}:void 0),s=e=>t(r.length>0?{values:r,maxDistance:e}:void 0),c=Au().filter(e=>!r.includes(e));return o(`div`,{className:`mt-1 space-y-1.5`,children:[b(sp,{value:r,placeholder:n(`system.notificationConditionWidgets.plateText`,`Plate text…`),onChange:a}),c.length>0&&o(`div`,{className:`flex flex-wrap items-center gap-1`,children:[b(`span`,{className:`text-[10px] text-foreground-subtle`,children:n(`system.notificationConditionWidgets.seen`,`Seen:`)}),c.slice(0,12).map(e=>b(`button`,{type:`button`,onClick:()=>a([...r,e]),className:`rounded border border-border px-1.5 py-0.5 text-[10px] text-foreground-subtle hover:bg-surface-hover hover:text-foreground`,children:e},e))]}),o(`label`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[n(`system.notificationConditionWidgets.maxDistance`,`Max distance`),b(Sn,{type:`number`,min:0,max:3,step:1,value:i,className:`max-w-[5rem]`,onChange:e=>{let t=Number(e.target.value);s(Number.isFinite(t)?Math.max(0,Math.min(3,t)):1)}})]})]})}function bp({gateable:e,value:t,onChange:n}){let{t:r}=V(),i=rp(),a=e.find(e=>e.id===t?.deviceId),s=new Set(t?.states??[]),c=e=>{let t=Number(e);if(!Number.isFinite(t)||t===0)return n(void 0);n({deviceId:t,states:[]})},l=e=>{if(t===void 0)return;let r=new Set(s);r.has(e)?r.delete(e):r.add(e),n(r.size===0?void 0:{deviceId:t.deviceId,states:[...r]})};return o(`div`,{className:`mt-1 space-y-2`,children:[b(Qn,{value:t===void 0?``:String(t.deviceId),options:[{value:``,label:r(`system.notificationConditionWidgets.noDeviceGate`,`— no device gate —`)},...e.map(e=>({value:String(e.id),label:e.name}))],onChange:e=>c(e.target.value)}),a!==void 0&&b(`div`,{className:`flex flex-wrap gap-1.5`,children:a.states.map(e=>b(`button`,{type:`button`,onClick:()=>l(e),className:s.has(e)?`rounded-md border border-primary bg-primary/10 px-2 py-0.5 text-[11px] text-primary`:`rounded-md border border-border px-2 py-0.5 text-[11px] text-foreground-subtle`,children:i(e)},e))}),a!==void 0&&a.states.length===0&&b(`p`,{className:`text-[10px] text-foreground-subtle mt-0.5`,children:r(`system.notificationConditionWidgets.thisDeviceReportsNoState`,`This device reports no state the gate can read, so it cannot arm a rule.`)}),t!==void 0&&b(`p`,{className:`text-[10px] text-foreground-subtle mt-0.5`,children:r(`system.notificationConditionWidgets.theRuleIsSilentWhile`,`The rule is silent while the device is in any other state — including when its state cannot be read at all.`)})]})}function xp(e,t){let n=t(e.verdict);return e.latched?`${n} · ${t(`latched`)}`:n}function Sp({scenes:e,value:t,onChange:n}){let{t:r}=V(),i=rp(),a=e.find(e=>e.sceneId===t?.sceneId),s=r=>{if(r===``)return n(void 0);let i=e.find(e=>e.sceneId===r);if(i===void 0)return n(void 0);n({sceneId:r,deviceId:i.deviceId,requiredState:t?.requiredState??`diverged`,...t?.latched===void 0?{}:{latched:t.latched}})},c=e=>{t!==void 0&&n({...t,requiredState:e===`matched`?`matched`:`diverged`})},l=e=>{if(t!==void 0){if(e===``){let{latched:e,...r}=t;return n(r)}n({...t,latched:e===`latched`})}};return e.length===0?b(`p`,{className:ap,children:r(`notificationRules.scene.none`,`No scenes yet — create one on the Scenes page.`)}):o(`div`,{className:`mt-1 space-y-2`,children:[b(Qn,{value:t?.sceneId??``,options:[{value:``,label:r(`notificationRules.scene.noGate`,`— no scene gate —`)},...e.map(e=>({value:e.sceneId,label:`${e.cameraName} · ${e.label} — ${xp(e,i)}`}))],onChange:e=>s(e.target.value)}),t!==void 0&&o(`div`,{className:`flex flex-wrap items-center gap-2`,children:[o(`label`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[r(`notificationRules.scene.onlyWhile`,`Only while it is`),b(Qn,{value:t.requiredState,options:[{value:`diverged`,label:i(`diverged`)},{value:`matched`,label:i(`matched`)}],onChange:e=>c(e.target.value)})]}),o(`label`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[r(`notificationRules.scene.read`,`Read`),b(Qn,{value:t.latched===void 0?``:t.latched?`latched`:`live`,options:[{value:``,label:a===void 0?r(`notificationRules.scene.readOwn`,`The scene's own setting`):`${r(`notificationRules.scene.readOwn`,`The scene's own setting`)} (${i(a.emit)})`},{value:`latched`,label:i(`latched`)},{value:`live`,label:i(`live`)}],onChange:e=>l(e.target.value)})]})]}),a!==void 0&&o(`p`,{className:`text-[10px] text-foreground-subtle mt-0.5`,children:[r(`notificationRules.scene.rightNow`,`Right now:`),` `,xp(a,i)]}),t!==void 0&&a===void 0&&b(`p`,{className:`text-[10px] text-foreground-subtle mt-0.5`,children:r(`notificationRules.scene.missing`,`This scene no longer exists — pick another or remove the gate.`)})]})}var Cp={days:[0,1,2,3,4,5,6],minute:480},wp=[{value:1,get label(){return B.t(`helpers.notificationSystemEventDelivery.wd_mon`)}},{value:2,get label(){return B.t(`helpers.notificationSystemEventDelivery.wd_tue`)}},{value:3,get label(){return B.t(`helpers.notificationSystemEventDelivery.wd_wed`)}},{value:4,get label(){return B.t(`helpers.notificationSystemEventDelivery.wd_thu`)}},{value:5,get label(){return B.t(`helpers.notificationSystemEventDelivery.wd_fri`)}},{value:6,get label(){return B.t(`helpers.notificationSystemEventDelivery.wd_sat`)}},{value:0,get label(){return B.t(`helpers.notificationSystemEventDelivery.wd_sun`)}}];function Tp(e){let t=Math.floor(e/60),n=e%60;return`${String(t).padStart(2,`0`)}:${String(n).padStart(2,`0`)}`}function Ep(e){let[t,n]=e.split(`:`),r=Number(t)*60+Number(n);return Number.isFinite(r)?Math.max(0,Math.min(1439,r)):0}function Dp(e){if(typeof e!=`object`||!e||!(`data`in e))return;let t=e.data;if(!(typeof t!=`object`||!t||!(`code`in t)))return typeof t.code==`string`?t.code:void 0}function Op(e){let t=Object.entries(e).map(([e,t])=>`${e} ${String(t)}`);return t.length>0?B.t(`helpers.notificationSystemEventDelivery.dropped`,{parts:t.join(`, `)}):null}function kp(e,t,n,r=`rule`){if(e===`error`)return Dp(n)===`NOT_FOUND`?{lines:[`This hub does not serve summary rules yet — update @camstack/server first. A rule saved now would be stored without its summary, and stay instant.`]}:{lines:[`The preview could not be read: ${n instanceof Error?n.message:String(n)}`]};if(e!==`success`||t===void 0)return null;let i=[];if(r===`section`&&t.split===void 0&&i.push(`This hub does not send per-category summaries yet — update @camstack/server first. Until then it sends one message.`),t.empty)i.push(`Nothing to report right now — no notification would be sent.`);else if(t.split===`section`&&t.rows!==void 0){let e=t.rows.length;i.push(`${String(e)} notification${e===1?``:`s`} would be sent now, one per category:`);for(let e of t.rows)i.push(`${e.title}\n${e.text}`)}else i.push(`${String(t.count)} item(s) would be sent now:\n${t.text}`);let a=Op(t.dropped);return a!==null&&i.push(a),t.excludedGroups.includes(`backups-exports`)&&i.push(`Backups and exports are completed jobs, not a state — they are not in a summary.`),{lines:i}}function Ap(e,t){return{...e,schedule:t}}function jp(e,t){let{split:n,...r}=e;return t===`section`?{...r,split:t}:r}function Mp(e){return Tp(e)}function Np(e){return Ep(e)}function Pp(){return{days:[1,2,3,4,5],startMinute:540,endMinute:1080}}function Fp(e){return{days:[...Cp.days],minute:e}}var Ip=`Always active — add a window to restrict when the rule fires.`;function Lp({value:e,onChange:t,mode:n=`windows`,defaultMinute:r=Cp.minute,emptyHint:i}){return n===`times`?b(zp,{value:e,onChange:t,defaultMinute:r}):b(Rp,{value:e,onChange:t,emptyHint:i??Ip})}function Rp({value:e,onChange:t,emptyHint:n}){let{t:r}=V(),i=e?.windows??[],a=e?.invert??!1,s=(n,r)=>{if(n.length===0){t(void 0);return}t({windows:n,...r?{invert:!0}:{},...e?.timezone?{timezone:e.timezone}:{}})},c=()=>s([...i,Pp()],a),l=e=>s(i.filter((t,n)=>n!==e),a),u=(e,t)=>s(i.map((n,r)=>r===e?t:n),a);return o(`div`,{className:`mt-1 space-y-2`,"data-testid":`schedule-field-windows`,children:[i.length===0?b(`p`,{className:ap,children:n}):i.map((e,t)=>b(Bp,{window:e,onChange:e=>u(t,e),onRemove:()=>l(t)},t)),o(`div`,{className:`flex items-center gap-3`,children:[o(`button`,{type:`button`,onClick:c,className:`flex items-center gap-1 rounded-md bg-surface-hover px-2 py-1 text-[11px] text-foreground-subtle hover:text-foreground`,children:[b(ne,{className:`h-3 w-3`}),` `,r(`system.notificationScheduleField.addWindow`)]}),i.length>0&&o(`label`,{className:`flex items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[b(`input`,{type:`checkbox`,checked:a,onChange:e=>s([...i],e.target.checked),className:`accent-primary`}),r(`system.notificationScheduleField.activeOutsideTheWindows`,`Active outside the windows`)]})]})]})}function zp({value:e,onChange:t,defaultMinute:n}){let{t:r}=V(),i=e?.timezone,a=e===void 0?{times:[],approximated:!1}:wt(e);if(a===null)return o(`div`,{className:`mt-1 space-y-2`,"data-testid":`schedule-field-times-fallback`,children:[b(`p`,{className:ap,children:r(`system.notificationScheduleField.invertedScheduleShownAsBands`,`Inverted schedule — shown as bands. Clear the invert flag (or the windows) to author punctual times.`)}),b(Rp,{value:e,onChange:t,emptyHint:Ip})]});let s=a.times,c=e=>{if(e.length===0){t(void 0);return}t(Wt(e,i))};return o(`div`,{className:`mt-1 space-y-2`,"data-testid":`schedule-field-times`,children:[a.approximated&&b(`p`,{className:`text-[10px] text-foreground-subtle mt-0.5`,"data-testid":`schedule-field-times-approximated`,children:r(`system.notificationScheduleField.shownAsSendAtTimes`,`Shown as send-at times from each window's end (when the summary fires). Edit or save to store them as punctual one-minute windows.`)}),s.length===0?b(`p`,{className:ap,children:r(`system.notificationScheduleField.noTimesYetAddOne`,`No times yet — add one to send on those days at that clock time.`)}):s.map((e,t)=>b(Vp,{time:e,index:t,onChange:e=>c(s.map((n,r)=>r===t?e:n)),onRemove:s.length>1?()=>c(s.filter((e,n)=>n!==t)):void 0},t)),o(`button`,{type:`button`,onClick:()=>c([...s,Fp(n)]),className:`flex items-center gap-1 rounded-md bg-surface-hover px-2 py-1 text-[11px] text-foreground-subtle hover:text-foreground`,"data-testid":`schedule-field-add-time`,children:[b(ne,{className:`h-3 w-3`}),` `,r(`system.notificationScheduleField.addTime`)]})]})}function Bp({window:e,onChange:t,onRemove:n}){let{t:r}=V();return o(`div`,{className:`space-y-1.5 rounded-md border border-border p-2`,children:[o(`div`,{className:`flex items-center gap-2 text-xs`,children:[b(`input`,{type:`time`,value:Mp(e.startMinute),onChange:n=>t({...e,startMinute:Np(n.target.value)}),className:`rounded-md border border-border bg-background px-1 py-0.5`}),b(`span`,{className:`text-foreground-subtle`,children:`→`}),b(`input`,{type:`time`,value:Mp(e.endMinute),onChange:n=>t({...e,endMinute:Np(n.target.value)}),className:`rounded-md border border-border bg-background px-1 py-0.5`}),b(`span`,{className:`flex-1`}),b(`button`,{type:`button`,onClick:n,"aria-label":r(`system.notificationScheduleField.removeWindow`,`Remove window`),className:`text-foreground-subtle hover:text-danger`,children:b(ae,{className:`h-3.5 w-3.5`})})]}),b(Hp,{days:e.days,onToggle:n=>{let r=e.days.includes(n)?e.days.filter(e=>e!==n):[...e.days,n];r.length!==0&&t({...e,days:r})}})]})}function Vp({time:e,index:t,onChange:n,onRemove:r}){let{t:i}=V();return o(`div`,{className:`space-y-1.5 rounded-md border border-border p-2`,children:[o(`div`,{className:`flex items-center gap-2 text-xs`,children:[b(`span`,{className:`text-foreground-subtle`,children:i(`system.notificationScheduleField.at`,`At`)}),b(`input`,{type:`time`,value:Tp(e.minute),onChange:t=>n({...e,minute:Ep(t.target.value)}),className:`rounded-md border border-border bg-background px-1 py-0.5`,"data-testid":`schedule-field-time-${String(t)}`}),b(`span`,{className:`flex-1`}),r!==void 0&&b(`button`,{type:`button`,onClick:r,"aria-label":i(`system.notificationScheduleField.removeTime`,`Remove time`),className:`text-foreground-subtle hover:text-danger`,children:b(ae,{className:`h-3.5 w-3.5`})})]}),b(Hp,{days:e.days,onToggle:t=>{let r=e.days.includes(t)?e.days.filter(e=>e!==t):[...e.days,t];r.length!==0&&n({...e,days:r})}})]})}function Hp({days:e,onToggle:t}){return b(`div`,{className:`flex flex-wrap gap-1`,children:wp.map(n=>b(`button`,{type:`button`,onClick:()=>t(n.value),className:`rounded px-1.5 py-0.5 text-[10px] ${e.includes(n.value)?`bg-primary text-primary-foreground`:`bg-surface-hover text-foreground-subtle`}`,children:n.label},n.value))})}function Up(e){return e>=8}D();function Wp(e){if(typeof e!=`object`||!e)return;let t=Reflect.get(e,`windows`);if(!(!Array.isArray(t)||t.length===0))return e}function Gp(e){return e.type===`multiselect`}function Kp(e){let t=e.suggestions;return t===void 0||t.length===0?[]:t.map(e=>({value:e,label:e}))}function qp(e){return e.map(e=>({value:e.value,label:e.label,...e.description===void 0?{}:{description:e.description},...e.iconId===void 0?{}:{iconId:e.iconId}}))}function Jp(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function Yp({field:e,values:t,onChange:n,onChangeMany:r,disabled:i,translationFn:a,onTestField:s,externalProbe:c,allFields:l,onAction:u}){let{t:d}=V();if(e.type===`tags`){if(!Gr(e,t,l))return null;let r=e.creatable!==!1;return b(Jr,{mode:`multi`,options:Kp(e),value:Jp(t[e.key]),onChange:t=>n(e.key,t),disabled:i===!0||e.disabled===!0,creatable:r,...e.createLabel===void 0?{}:{createLabel:e.createLabel},...e.maxTags===void 0?{}:{maxItems:e.maxTags},label:Zp(e.label,a),description:e.description===void 0?void 0:Zp(e.description,a),placeholder:e.placeholder??d(`formBuilder.formBuilder.searchOrAdd`,`Search or add…`),testId:`config-tags-${e.key}`})}if(e.type===`schedule`){if(!Gr(e,t,l))return null;let r=Zp(e.label,a),i=e.description===void 0?void 0:Zp(e.description,a),s=e.mode===`times`?`times`:`windows`;return o(`div`,{className:`space-y-1`,"data-testid":`config-schedule-${e.key}`,children:[r!==void 0&&b(`label`,{className:`block text-[11px] font-medium text-foreground-subtle`,children:r}),i!==void 0&&b(`p`,{className:`text-[10px] text-foreground-subtle`,children:i}),b(Lp,{mode:s,value:Wp(t[e.key]),onChange:t=>n(e.key,t)})]})}return Gp(e)&&(Up(e.options.length)||e.creatable===!0)?Gr(e,t,l)?b(Jr,{mode:`multi`,options:qp(e.options),value:Jp(t[e.key]),onChange:t=>n(e.key,t),disabled:i===!0||e.disabled===!0,creatable:e.creatable===!0,...e.createLabel===void 0?{}:{createLabel:e.createLabel},...e.maxItems===void 0?{}:{maxItems:e.maxItems},label:Zp(e.label,a),description:e.description===void 0?void 0:Zp(e.description,a),placeholder:e.placeholder??d(`formBuilder.formBuilder.searchToAdd`,`Search to add…`),testId:`config-multiselect-${e.key}`,listboxId:`msel-${e.key}`}):null:b(Er,{field:e,values:t,onChange:n,onChangeMany:r,disabled:i,translationFn:a,onTestField:s,externalProbe:c,allFields:l,onAction:u})}function Xp(e){return/^[a-zA-Z0-9_]+(\.[a-zA-Z0-9_]+)+$/.test(e)}function Zp(e,t){if(e!==void 0)return t&&Xp(e)?t(e):e}function Qp({section:e,values:t,onChange:n,onChangeMany:r,disabled:i,translationFn:a,onTestField:s,probeResults:c,onAction:l}){let[u,d]=C(e.defaultCollapsed??!1),f=e.style===`accordion`;if(e.fields.reduce((n,r)=>n+ +!!Gr(r,t,e.fields),0)===0)return null;let p=e.fields,m=e.columns??2,h=m===1?`grid-cols-1`:m===3?`grid-cols-1 @[480px]:grid-cols-2 @[880px]:grid-cols-3`:m===4?`grid-cols-1 @[480px]:grid-cols-2 @[1140px]:grid-cols-4`:`grid-cols-1 @[480px]:grid-cols-2`,g=e.fields.length===1&&e.fields[0]?.type===`widget`?e.fields[0]:void 0,_=g!==void 0||!e.title&&!e.description;return o(`div`,{className:`@container rounded-lg border border-border bg-surface p-3`,style:{containerType:`inline-size`},"data-settings-section":e.id,children:[!_&&o(`div`,{className:[`flex items-center justify-between mb-2`,f?`cursor-pointer`:``].join(` `),onClick:f?()=>d(e=>!e):void 0,children:[o(`div`,{children:[e.title&&b(`h3`,{className:`text-[11px] font-semibold text-foreground-subtle uppercase tracking-wider`,children:Zp(e.title,a)}),e.description&&b(`p`,{className:`text-[10px] text-foreground-subtle mt-0.5`,children:Zp(e.description,a)})]}),f&&b(`span`,{className:`text-foreground-subtle text-xs ml-2`,children:u?`▸`:`▾`})]}),!(u&&!_)&&(g===void 0?b(P,{children:b(`div`,{className:`grid ${h} gap-x-3 gap-y-2.5`,children:p.map(o=>b(Yp,{field:o,values:t,onChange:n,onChangeMany:r,disabled:i,translationFn:a,onTestField:s,externalProbe:c?.[o.key],allFields:e.fields,onAction:l},o.key))})}):b(Er,{field:g,values:t,onChange:n,onChangeMany:r,disabled:i,translationFn:a,onTestField:s,externalProbe:c?.[g.key],allFields:e.fields,onAction:l},g.key))]})}function $p({schema:e,values:t,onChange:n,disabled:r,translationFn:i,onTestField:a,probeResults:o,onClearProbe:s,onAction:c,visibilityContext:l}){let u=l?{...l,...t}:t,d=(e,r)=>{n({...t,[e]:r}),s?.(e)},f=e=>{n({...t,...e});for(let t of Object.keys(e))s?.(t)};return b(`div`,{className:`space-y-4`,children:e.sections.map((e,t)=>b(Qp,{section:e,values:u,onChange:d,onChangeMany:f,disabled:r,translationFn:i,onTestField:a,probeResults:o,onAction:c},`${e.id}-${t}`))})}function em({pendingCount:e,onSave:t,onDiscard:n,saving:r=!1,saveLabel:i=`Save`,discardLabel:a=`Discard`}){let{t:s}=V();return e<=0?null:o(`div`,{className:`sticky bottom-0 -mb-3 flex items-center justify-between gap-3 rounded-lg border border-primary/40 bg-primary/5 px-3 py-2 shadow-sm z-10`,children:[b(`span`,{className:`text-xs text-foreground`,children:s(`formBuilder.saveBar.unsavedChanges`,{count:e})}),o(`div`,{className:`flex items-center gap-2`,children:[b(`button`,{type:`button`,onClick:n,disabled:r,className:`inline-flex items-center rounded-md border border-border px-2.5 py-1 text-xs text-foreground-subtle hover:bg-surface-hover disabled:opacity-50`,children:a}),b(`button`,{type:`button`,onClick:t,disabled:r,className:`inline-flex items-center rounded-md bg-primary px-3 py-1 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,children:r?s(`formBuilder.formSaveBar.saving`,`Saving…`):i})]})]})}function tm({tabs:e,activeId:t,onChange:n,countByTab:r,pendingByTab:i}){return e.length===0?null:b(`div`,{className:`flex flex-wrap items-center gap-1 border-b border-border shrink-0`,children:e.map(e=>{let a=e.id===t,s=r?.get(e.id)??0,c=i?.get(e.id)??0;return o(`button`,{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,s>0&&o(`span`,{className:`ml-1.5 text-[10px] opacity-60`,children:[`(`,s,`)`]}),c>0&&b(`span`,{className:`ml-1.5 inline-flex h-1.5 w-1.5 rounded-full bg-primary`})]},e.id)})})}D();function nm({schema:e,values:t,pendingKeys:n,onChange:r,onAction:i,onSave:a,onDiscard:s,disabled:c,activeSubTab:l,onSubTabChange:u,flattenTabs:d=!1,visibilityContext:m,hideSaveBar:h=!1}){let g=e.tabs??[],_=p(()=>{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]),v=new Set(g.map(e=>e.id)),y=[...g,...[..._.keys()].filter(e=>!v.has(e)).map(e=>({id:e,label:e,icon:`wrench`,order:100}))],x=y[0]?.id??`general`,[S,w]=C(x),T=u!==void 0,E=new Set(y.map(e=>e.id)),D=f(new Set);for(let e of E)D.current.add(e);let O=D.current,k=(e=>e&&(E.has(e)||O.has(e))?e:x)(T?l:S),A=e=>{T?u(e):w(e)},j=_.get(k)??[],M={sections:j.length<=1?j.length===1?[{...j[0],title:``}]:j:j.every(e=>!e.title)?[{...j[0],title:``,fields:j.flatMap(e=>e.fields)}]:j},N=h?null:b(em,{pendingCount:n.length,onSave:()=>a(n),onDiscard:()=>s(n),saving:c});if(d||y.length<=1)return o(`div`,{className:`flex flex-col gap-3`,children:[b($p,{schema:e,values:t,onChange:r,onAction:i,disabled:c,visibilityContext:m}),N]});let P=new Map,F=new Map;for(let[e,t]of _){P.set(e,t.length);let r=new Set,i=e=>{for(let t of e)if(`key`in t&&typeof t.key==`string`&&r.add(t.key),t.type===`group`)i(t.fields);else if(t.type===`sub-tabs`)for(let e of t.tabs)i(e.fields)};for(let e of t)i(e.fields);let a=n.filter(e=>r.has(e)).length;a>0&&F.set(e,a)}return o(`div`,{className:`flex flex-col gap-3`,children:[b(tm,{tabs:y.map(e=>({id:e.id,label:e.label})),activeId:k,onChange:A,countByTab:P,pendingByTab:F}),b(oi,{tabKey:k,children:b($p,{schema:M,values:t,onChange:r,onAction:i,disabled:c,visibilityContext:m})}),N]})}var rm=`device-export`,im=`export`,am=`Export`;function om(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(om):e.type===`sub-tabs`?e.tabs.some(e=>e.fields.some(om)):e.writerCapName===rm}function sm(e){return e.tab===`export`?!0:e.fields.some(om)}var cm=`host/extensions-panel`;function lm(e){return e.type===`widget`?e.widgetId===cm:e.type===`group`?e.fields.some(lm):e.type===`sub-tabs`?e.tabs.some(e=>e.fields.some(lm)):!1}function um(e){return e.fields.some(lm)}function dm(e,t){return!t&&e!==void 0&&Zt.includes(e)}function fm(e){return e.location!==`top-tab`&&e.location!==`hero`&&!sm(e)&&!um(e)}function pm(e,t,n,r){return!r||dm(t,n)?!0:(e??[]).some(fm)}function mm(e,t){for(let n of e){if(n.type===`group`){mm(n.fields,t);continue}if(n.type===`sub-tabs`){for(let e of n.tabs)mm(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 hm(e){let t={};for(let n of e)mm(n.fields,t);return t}D();function gm(e,t){return t&&t===`admin`?e:!0}function _m(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?sm(e)&&sm(t)?e.id.localeCompare(t.id):(e.order??0)-(t.order??0):n.localeCompare(r)})};return e.tabs?{...t,tabs:e.tabs}:t}function vm(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 ym(e){return e.key}function bm(e){if(!vm(e))return e.value}function xm(e){return vm(e)?null:e}function Sm(e,t){for(let n of e)if(t(n),n.type===`group`)Sm(n.fields,t);else if(n.type===`sub-tabs`)for(let e of n.tabs)Sm(e.fields,t)}function Cm(e){if(!e)return{};let t={};for(let n of e.sections)Sm(n.fields,e=>{let n=ym(e);n!==null&&(t[n]=bm(e))});return t}function wm(e,t){if(!e)return null;let n=null;for(let r of e.sections)if(Sm(r.fields,e=>{if(n!==null||ym(e)!==t)return;let r=xm(e);r&&r.writerCapName&&r.writerAddonId&&(n={capName:r.writerCapName,addonId:r.writerAddonId})}),n!==null)break;return n}function Tm(e){return{...e,fields:e.fields.map(Em)}}function Em(e){return e.type===`separator`||e.type===`info`||e.type===`button`||e.type===`object-array`?e:{...e,readonlyField:!0}}function Dm(e,t){return e&&{...e,sections:e.sections.map(e=>({...e,fields:e.fields.map(e=>{let n=xm(e);return n?gm(t,n.minRole)?e:Em(e):e})}))}}function Om({deviceId:e,sectionFilter:t,activeSubTab:n,onSubTabChange:r,flattenSubTabs:i,subTabGrouping:a}){let{t:s}=V(),c=M(),{user:l}=cu(),u=l?.isAdmin===!0,d=f(!1),{data:m,isLoading:h}=Ir({deviceId:e},{refetchInterval:()=>d.current?!1:2500,enabled:Number.isFinite(e)}),{data:g}=qn({deviceId:e},{enabled:Number.isFinite(e)}),_=m?.settings??null,v=m?.live??null,S=p(()=>{if(!_&&!v)return null;let e=_?.sections??[],n=(v?.sections??[]).map(Tm),r=[...e,...n],i=t?r.filter(t):r.filter(fm);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=[..._?.tabs??[],...(v?.tabs??[]).filter(e=>!(_?.tabs??[]).some(t=>t.id===e.id))].filter(e=>o.has(e.id));return s.length>0?{tabs:s,sections:i}:{sections:i}},[_,v,t,a]),C=p(()=>hm([..._?.sections??[],...v?.sections??[]]),[_,v]),w=p(()=>_m(S),[S]),T=p(()=>Dm(w,u),[w,u]),E=p(()=>Cm(T),[T]),D=Jn(),O=Kn(),k=Wr(),A=Fn(),j=Zr({onSuccess:()=>{c.invalidateQueries({queryKey:[[`deviceManager`,`getDeviceAggregate`]]})}}),N={isPending:j.isPending,mutate:t=>{j.mutate({deviceId:e,changes:[...t]})}},P=uu({schema:T,serverValues:E,onImmediateSave:y(e=>{let t=Object.entries(e).map(([e,t])=>{let n=wm(T,e);return n?{writerCapName:n.capName,writerAddonId:n.addonId,key:e,value:t}:null}).filter(e=>e!==null);t.length>0&&N.mutate(t)},[T,N]),onDeferredSave:y(async t=>{let n=Object.entries(t).map(([e,t])=>{let n=wm(T,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 j.mutateAsync({deviceId:e,changes:n});if(t.failures.length>0)throw Error(t.failures.map(e=>e.error).join(`; `))}finally{await c.invalidateQueries({queryKey:[[`deviceManager`,`getDeviceAggregate`]]})}},[T,j,e,c])}),{values:F,pendingKeys:I,handleChange:ee,handleSave:te,handleDiscard:L}=P;d.current=P.editingPaused;let ne=Bc(),re=f(te),ie=f(L);re.current=te,ie.current=L;let ae=ne?.register,oe=j.isError?j.error instanceof Error?j.error.message:String(j.error):null,se=I.join(`\0`);if(x(()=>{if(ae===void 0)return;let e=se===``?[]:se.split(`\0`);return ae({id:`export`,dirty:e.length>0,saving:j.isPending,error:oe,save:()=>(re.current(e),Promise.resolve()),discard:()=>ie.current(e)})},[ae,se,j.isPending,oe]),h)return o(`div`,{className:`flex items-center justify-center py-12 text-foreground-subtle`,children:[b(Me,{className:`h-4 w-4 animate-spin mr-2`}),b(`span`,{className:`text-xs`,children:s(`device.deviceAggregateSection.loadingDeviceAggregate`,`Loading device aggregate…`)})]});if(!T||T.sections.length===0)return b(`div`,{className:`text-xs text-foreground-subtle italic py-4 text-center`,children:s(`device.deviceAggregateSection.noAggregateContributionsForThis`,`No aggregate contributions for this device.`)});async function R(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=kt(e,r);await D.mutateAsync({brokerId:i}),c.invalidateQueries({queryKey:[[`deviceManager`,`getDeviceAggregate`]]});return}if(t===`test-probe`){if(!g)return{status:`error`,error:s(`device.deviceAggregateSection.metadataNotLoaded`)};try{return await k.mutateAsync({addonId:g.addonId,type:g.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=kt(e,t),i=await O.mutateAsync({brokerId:r});return c.invalidateQueries({queryKey:[[`deviceManager`,`getDeviceAggregate`]]}),i}if(t===`device-custom-action`){let t=await A.mutateAsync({deviceId:e,action:n,input:r});return c.invalidateQueries({queryKey:[[`deviceManager`,`getDeviceAggregate`]]}),t}throw Error(`[device-aggregate] unknown action "${t}"`)}return b(nm,{schema:T,values:F,pendingKeys:I,onChange:ee,onAction:R,onSave:te,onDiscard:L,hideSaveBar:ne!==null,disabled:N.isPending,activeSubTab:n,onSubTabChange:r,flattenTabs:i,visibilityContext:C})}D();function km({deviceId:e,onClose:t}){let{t:n}=V(),[r,i]=C(`info`),{data:a}=qn({deviceId:e},{enabled:e>0}),s=kr(e),c=oc(s.presence,s.list),l=r===`history`&&!c?`info`:r,u=typeof a?.name==`string`?a.name:``,d=ir(e,`full`,u.length>0?u:`#${String(e)}`),f=typeof a?.location==`string`?a.location:``,p=[[`info`,n(`deviceQuickDetail.tabInfo`,{defaultValue:`Device info`})],[`export`,n(`deviceQuickDetail.tabExport`,{defaultValue:`Export`})],...c?[[`history`,n(`deviceQuickDetail.tabHistory`,{defaultValue:`History`})]]:[]];return b(Or,{open:!0,onOpenChange:e=>!e&&t(),children:b(ii,{width:`lg`,scroll:`body`,children:o(Vc,{deviceId:e,seed:a==null?null:{name:u,location:f,role:typeof a.role==`string`?a.role:null,display:a.display},showOpenFull:!0,onClose:t,children:[b(ui,{children:b(Zn,{children:d})}),b(`div`,{className:`mt-3 flex items-center gap-1 rounded-md bg-surface-hover p-0.5 w-fit`,children:p.map(([e,t])=>b(`button`,{type:`button`,onClick:()=>i(e),className:`px-2.5 py-1 rounded text-[11px] font-medium transition-colors ${l===e?`bg-surface text-foreground shadow-sm`:`text-foreground-subtle hover:text-foreground`}`,children:t},e))}),b(hr,{className:`mt-3`,children:o(mr,{deviceId:e,device:a??void 0,children:[b(`div`,{className:l===`info`?void 0:`hidden`,children:b(Ec,{})}),b(`div`,{className:l===`export`?void 0:`hidden`,children:b(Om,{deviceId:e,sectionFilter:sm})}),c?b(`div`,{className:l===`history`?void 0:`hidden`,children:b(ac,{deviceId:e})}):null]})})]})})})}function Am({children:e}){let[t,n]=C(null),r=y(e=>n(e),[]),i=y(()=>n(null),[]);return o(Xn,{open:r,children:[e,t===null?null:b(km,{deviceId:t,onClose:i})]})}D();function jm({tabs:e,active:t,onChange:n}){return b(`div`,{className:`flex rounded-lg border border-border bg-surface p-0.5 gap-0.5`,children:e.map(e=>b(`button`,{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 Mm(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 Nm(e){return`${e.inputSize.width}x${e.inputSize.height}`}function Pm(e){return e.formats?Object.keys(e.formats).filter(t=>e.formats[t]!==void 0):[]}function Fm({entry:e,selected:t,onSelect:n,disabled:r}){let{t:i}=V(),a=Mm(e),s=Nm(e),c=Pm(e);return o(`button`,{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:[b(`div`,{className:`flex items-start justify-between gap-2`,children:o(`div`,{className:`flex-1 min-w-0`,children:[o(`div`,{className:`flex items-center gap-2`,children:[b(`span`,{className:`text-xs font-semibold text-foreground truncate`,children:e.name}),t&&b(ue,{className:`h-3.5 w-3.5 text-primary shrink-0`})]}),b(`p`,{className:`text-[10px] text-foreground-subtle mt-0.5 line-clamp-2`,children:e.description})]})}),o(`div`,{className:`flex items-center gap-3 mt-2 flex-wrap`,children:[o(`span`,{className:`inline-flex items-center gap-1 text-[10px] text-foreground-subtle`,children:[b(We,{className:`h-3 w-3`}),s]}),a&&b(`span`,{className:`text-[10px] text-foreground-subtle`,children:a}),c.length>0&&b(`div`,{className:`flex gap-1`,children:c.map(e=>b(`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&&b(`span`,{className:`text-[10px] text-foreground-subtle`,children:i(`common.labels`,{count:e.labels.length})})]})]})}function Im({field:e,value:t,onChange:n,disabled:r}){let{t:i}=V(),a=e.catalog??[],s=a.length>0,c=st(a).length>0,l=e.allowCustomPath!==!1||e.allowCustom===!0,u=[...s?[{id:`catalog`,label:i(`formBuilder.modelSelector.models`,`Models ({{length}})`,{length:a.length})}]:[],...l?[{id:`custom`,label:i(`formBuilder.modelSelector.customPath`,`Custom Path`)}]:[]],[d,f]=C(s?`catalog`:`custom`),p=t==null?``:String(t);return o(`div`,{className:`space-y-3`,children:[u.length>1&&b(jm,{tabs:u,active:d,onChange:f}),d===`catalog`&&s&&c&&b(Xr,{catalog:a,value:p,onChange:e=>n(e),disabled:r||e.disabled}),d===`catalog`&&s&&!c&&b(`div`,{className:`space-y-1.5 max-h-[320px] overflow-y-auto pr-1`,children:a.filter(e=>e.legacy!==!0).map(t=>b(Fm,{entry:t,selected:p===t.id,onSelect:()=>n(t.id),disabled:r||e.disabled},t.id))}),d===`catalog`&&!s&&o(`div`,{className:`rounded-md border border-info/30 bg-info/5 px-3 py-2 flex items-start gap-2`,children:[b(De,{className:`h-3.5 w-3.5 text-info shrink-0 mt-0.5`}),b(`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&&o(`div`,{className:`space-y-2`,children:[b(`input`,{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&&o(`p`,{className:`text-[10px] text-foreground-subtle`,children:[i(`formBuilder.modelSelector.acceptedFormats`,`Accepted formats:`),` `,e.acceptFormats.join(`, `)]})]}),(e.compatibilityNote||e.conversionGuideUrl)&&o(`div`,{className:`flex items-start justify-between gap-3 pt-1`,children:[e.compatibilityNote&&o(`p`,{className:`flex items-start gap-1 text-[10px] text-foreground-subtle`,children:[b(De,{className:`h-3 w-3 mt-0.5 shrink-0`}),e.compatibilityNote]}),e.conversionGuideUrl&&o(`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`),b(oe,{className:`h-3 w-3`})]})]})]})}function Lm({to:e}){let{search:t}=q();return b(Y,{to:`${e}${t}`,replace:!0})}D();function Rm(){return B.t(`helpers.keychainRevealHost.forbidden`)}function zm(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 Bm(e){let t=zm(e);if(t===`FORBIDDEN`||t===`UNAUTHORIZED`)return Rm();let n=e instanceof Error?e.message:String(e);return n.length>0?B.t(`helpers.keychainRevealHost.failedWith`,{message:n}):B.t(`helpers.keychainRevealHost.failed`)}function Vm({children:e}){let t=zn();return b(si,{reveal:y(async e=>{try{return(await t.mutateAsync({ref:e})).value}catch(e){throw Error(Bm(e))}},[t]),children:e})}D();function Hm(){let e=Ae(),t=M(),[n,r]=C(()=>e.isConnected()?`connected`:`disconnected`),i=f(!1),[a,o]=C(0),[s,c]=C([]);x(()=>e.subscribeConnectionEvents(e=>{r(t=>(t!==`connected`&&e===`connected`&&i.current&&o(e=>e+1),e!==`connected`&&(i.current=!0),e))}),[e]),x(()=>{a!==0&&t.invalidateQueries({queryKey:[[`addons`,`getLastRestart`]]})},[a,t]);let{data:l}=On(void 0,{enabled:n===`connected`&&a>0,staleTime:0,refetchOnMount:!1,refetchOnWindowFocus:!1}),u=f(null);return x(()=>{if(l==null||l.requestedAt===u.current)return;u.current=l.requestedAt;let e=Wm(l);c(t=>[...t,e]);let t=window.setTimeout(()=>{c(t=>t.filter(t=>t.id!==e.id))},6e3);return()=>window.clearTimeout(t)},[l]),b(P,{children:s.length>0&&b(Um,{toasts:s})})}function Um({toasts:e}){return b(`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=>o(`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 backdrop-blur-sm`,children:[b(rt,{className:`w-4 h-4 shrink-0 mt-0.5 text-green-400`}),o(`div`,{children:[b(`div`,{className:`text-[11px] font-semibold text-foreground`,children:e.title}),b(`div`,{className:`text-[10px] text-foreground-subtle mt-0.5`,children:e.message})]})]},e.id))})}function Wm(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:B.t(`system.reconnectOverlay.frameworkUpdated`,`Framework updated`),message:B.t(`system.reconnectOverlay.isNow`,`{{packageName}} is now {{fromTo}}.`,{packageName:e.packageName,fromTo:n})}}return{id:t,title:B.t(`system.reconnectOverlay.serverRestarted`,`Server restarted`),message:e.requestedBy===void 0?B.t(`system.reconnectOverlay.manualRestartCompleted`,`Manual restart completed.`):B.t(`system.reconnectOverlay.manualRestartByCompleted`,`Manual restart by {{requestedBy}} completed.`,{requestedBy:e.requestedBy})}}var Gm=`/system/settings`,Km=[{path:`/system/secrets`,tab:`secrets`},{path:`/system/capabilities`,tab:`capabilities`}];function qm(e,t=``){let n=new URLSearchParams(t);return n.delete(`tab`),n.set(`tab`,e),`${Gm}?${n.toString()}`}function Jm({tab:e}){let{search:t,hash:n}=q();return b(Y,{to:`${qm(e,t)}${n}`,replace:!0})}D();var Ym={info:{bg:`bg-info/10`,border:`border-info/30`,icon:De},warning:{bg:`bg-warning/10`,border:`border-warning/30`,icon:at},critical:{bg:`bg-danger/10`,border:`border-danger/30`,icon:nt}};function Xm({toast:e,onDismiss:t}){let n=Ym[e.severity]??Ym.info,r=n.icon;return x(()=>{let n=e.duration??5e3;if(n<=0)return;let r=setTimeout(()=>t(e.id),n);return()=>clearTimeout(r)},[e.id,e.duration,t]),o(`div`,{className:`flex items-start gap-3 px-4 py-3 rounded-lg border ${n.border} ${n.bg} shadow-lg backdrop-blur-sm animate-in slide-in-from-right-5 fade-in duration-200`,children:[b(r,{className:`h-4 w-4 shrink-0 mt-0.5 text-foreground-subtle`}),o(`div`,{className:`flex-1 min-w-0`,children:[b(`div`,{className:`text-xs font-semibold text-foreground`,children:e.title}),b(`div`,{className:`text-[11px] text-foreground-subtle mt-0.5`,children:e.message})]}),b(`button`,{type:`button`,onClick:()=>t(e.id),className:`shrink-0 p-0.5 rounded hover:bg-surface-hover transition-colors`,children:b(Pe,{className:`h-3.5 w-3.5 text-foreground-subtle`})})]})}function Zm(){let[e,t]=C([]),n=y(e=>{t(t=>t.filter(t=>t.id!==e))},[]);return Ur(void 0,{onData:e=>{let n=e,r=`toast-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;t(e=>[...e,{...n,id:r,timestamp:Date.now()}])}}),e.length===0?null:b(`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=>b(`div`,{className:`pointer-events-auto`,children:b(Xm,{toast:e,onDismiss:n})},e.id))})}function Qm(e){return(t,n,r)=>e(t,{...typeof n==`string`?{defaultValue:n}:{defaultValue_one:n.one,defaultValue_other:n.other},...r})}var $m=(e,t,n)=>Qm(B.t.bind(B))(e,t,n);D();function eh({children:e}){let{t}=V();return b(Be,{t:p(()=>Qm(t),[t]),children:e})}D();function th(e){if(typeof e!=`object`||!e)return;let{data:t}=e;return t?.code}function nh(e,t){let n=th(e);return n===`UNAUTHORIZED`||n===`FORBIDDEN`?!0:/UNAUTHORIZED|FORBIDDEN/.test(t)}function rh(e,t,n,r){let[i,a]=C(!1),[o,s]=C(null);return x(()=>{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(nh(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}}D();var ih=3e4;function ah(e){let t=f(e);t.current=e,x(()=>{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>=ih&&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)}},[])}D();function oh(){let{t:e}=V();return o(`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:[b(Gn,{className:`h-7 w-48`}),b(Gn,{className:`h-5 w-72 max-w-full`}),b(Gn,{className:`h-40`})]})}function sh({message:e}){let{t}=V();return b(`div`,{className:`p-2 sm:p-4`,"data-testid":`addon-page-error`,children:b(Cn,{title:t(`layouts.addonPageLoader.failedTitle`,`This page could not be shown`),message:e})})}var ch=class extends c{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:b(sh,{message:this.state.error.message})}};function lh({resetKey:e,children:t}){return b(ch,{resetKey:e,children:t})}function uh({pageKey:e,children:t}){return b(ch,{resetKey:e,children:b(v,{fallback:b(oh,{}),children:t})})}D();function dh(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}var fh=2e4;function ph(e,t){let[n,r]=C(!1);return x(()=>{if(!e){r(!1);return}let n=setTimeout(()=>r(!0),t);return()=>clearTimeout(n)},[e,t]),n}var mh=new Map,hh=new Map,gh=new Set;function _h(e){return!e||typeof e!=`object`?!1:typeof e.default==`function`}async function vh(e,t){let i=mh.get(e);if(i)return i;let a=hh.get(e);if(a)return a;gh.has(e)||(dr(),r([{name:e,entry:z(t),type:`module`}],{force:!1}),gh.add(e));let o=n(`${e}/page`).then(n=>{if(!_h(n))throw Error(`Addon page remote ${e} (${t}) does not expose a default React component on './page'`);return mh.set(e,n.default),hh.delete(e),n.default}).catch(t=>{throw hh.delete(e),t});return hh.set(e,o),o}function yh(){let{t:e}=V(),{pagePath:t}=Qa(),n=J(),r=Ae(),{data:i,isError:a,error:o}=ci(void 0),s=p(()=>i?dh(i):void 0,[i]),c=s?.find(e=>e.path===`/addon/${t}`),l=c?.remoteName,u=c?.bundleUrl,[d,f]=C(null),[m,h]=C(null);x(()=>{if(!l||!u)return;h(null);let e=mh.get(l);if(e){f(()=>e);return}f(null);let t=!1;return vh(l,u).then(e=>{t||f(()=>e)}).catch(e=>{t||h(e instanceof Error?e.message:String(e))}),()=>{t=!0}},[l,u]);let g=ph(!s&&!a,fh),_=ph(c!==void 0&&!d&&!m,fh);return s?c?m?b(sh,{message:m}):d?b(uh,{pageKey:c.remoteName,children:b(d,{trpc:r.trpcClient,theme:{isDark:document.documentElement.classList.contains(`dark`)},navigate:e=>{n(e.startsWith(`/`)?e:`/${e}`)}})}):_?b(sh,{message:e(`layouts.addonPageLoader.remoteStalled`,`The page did not load. Its addon may be starting or unreachable.`)}):b(oh,{}):b(`div`,{className:`flex items-center justify-center h-full text-foreground-subtle`,children:e(`layouts.addonPageLoader.addonPageNotFound`,`Addon page not found`)}):a?b(sh,{message:o?.message??e(`layouts.addonPageLoader.listFailed`,`The page list could not be loaded.`)}):g?b(sh,{message:e(`layouts.addonPageLoader.listStalled`,`The hub did not send the page list. Try again in a moment.`)}):b(oh,{})}var bh={"/system/pipeline":`pipeline-orchestrator`,"/system/history":`device-history`,"/system/ai":`llm`};function xh(e,t){return e.filter(e=>!e.adminOnly||t).map(e=>{let t=bh[e.path];return t===void 0?e:{...e,requiresCapability:t}})}function Sh({t:e,isAdmin:t}){let n=xh([{label:e(`nav.devices`,`Devices`),icon:ce,path:`/devices`},{label:e(`nav.integrations`),icon:de,path:`/integrations`},{label:e(`nav.build`,`Build-your-self`),icon:I,path:`/build`,adminOnly:!0},{label:e(`nav.locations`,`Locations`),icon:Ze,path:`/locations`,adminOnly:!0},{label:e(`nav.viewer`,`Viewer`),icon:an,path:`/live`}],t),r=xh([{label:e(`nav.library`,`Library`),icon:on,path:`/library`,adminOnly:!0,keywords:[`People`,`Vehicles`,`Events`,`Scenes`,`plates`,`faces`,`detection-intelligence`]},{label:e(`nav.recordings`,`Recordings`),icon:be,path:`/recordings`,adminOnly:!0}],t),i=xh([{label:e(`nav.nodes`,`Nodes`),icon:re,path:`/system/nodes`,adminOnly:!0},{label:e(`nav.history`,`History`),icon:ze,path:`/system/history`,adminOnly:!0,keywords:[`charts`,`graphs`,`energy`,`temperature`,`metrics`,`trends`]},{label:e(`nav.pipeline`,`Pipeline`),icon:sn,path:`/system/pipeline`},{label:e(`system.addons`),icon:Re,path:`/system/addons`,adminOnly:!0},{label:e(`system.ai`,`AI`),icon:Je,path:`/system/ai`,adminOnly:!0}],t),a=xh([{label:e(`system.identity`,`Identity & Access`),icon:Ve,path:`/system/identity`,adminOnly:!0},{label:e(`system.network`,`Network`),icon:bn,path:`/system/network`,adminOnly:!0},{label:e(`system.integrations`,`Connectivity`),icon:de,path:`/system/integrations`,adminOnly:!0},{label:e(`system.data`,`Data`),icon:je,path:`/system/data`,adminOnly:!0},{label:e(`system.notifications`,`Notifications`),icon:ye,path:`/system/notifications`,adminOnly:!0},{label:e(`system.calendars`,`Calendars`),icon:ln,path:`/system/calendars`,adminOnly:!0},{label:e(`system.templates`,`Templates`),icon:fn,path:`/system/templates`,adminOnly:!0},{label:e(`system.systemNav`,`System`),icon:Ne,path:Gm,adminOnly:!0},{label:e(`system.logs`,`Logs`),icon:it,path:`/system/logs`,adminOnly:!0},{label:e(`system.terminal`,`Terminal`),icon:mn,path:`/system/terminal`,adminOnly:!0}],t);return[{key:`top`,label:null,items:n},{key:`detection`,label:e(`nav.detectionSection`,`Detection`),items:r},{key:`cluster`,label:e(`nav.clusterSection`,`Cluster`),items:i},{key:`administration`,label:e(`system.title`,`Administration`),items:a}]}var Ch={gauge:fe,puzzle:Re,bot:he,cpu:We,terminal:mn,box:se,boxes:se,monitor:an,wrench:Te,activity:Xe,plug:de,"graduation-cap":le};function wh(e){return Ch[e]??Re}function Th(e,t){for(let n of Sh(t))for(let t of n.items)if(t.path===e)return{icon:t.icon,title:t.label,path:t.path};return null}var Eh=`/system/addons`;function Dh({path:e,children:t}){let n=bh[e];return n===void 0?b(P,{children:t}):b(Oh,{path:e,capability:n,children:t})}function Oh({path:e,capability:t,children:n}){let{t:r}=V(),i=J(),a=Un(t);if(a===`present`)return b(P,{children:n});if(a===`pending`)return o(`div`,{className:`flex flex-col gap-4 p-2 sm:p-4`,"data-testid":`page-presence-pending`,children:[b(Gn,{className:`h-7 w-48`}),b(Gn,{className:`h-40`})]});if(a===`unknown`)return b(`div`,{className:`p-2 sm:p-4`,"data-testid":`page-presence-unknown`,children:b(Cn,{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 s=Th(e,{t:r,isAdmin:!0});return b(`div`,{className:`p-2 sm:p-4`,"data-testid":`page-not-installed`,children:b(Nr,{icon:s?.icon??Re,title:r(`pageRequires.absentTitle`,`{{page}} is not installed`,{page:s?.title??e}),description:r(`pageRequires.absentDescription`,`The addon that provides this page is not installed. Install it from System → Addons.`),action:b(Cr,{variant:`primary`,onClick:()=>i(Eh),children:r(`pageRequires.openAddons`,`Open Addons`)})})})}function kh({capability:e,children:t}){return b(P,{children:t(Un(e)===`absent`)})}function Ah({children:e}){return b(zr,{value:jh(ri({})),children:e})}function jh(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 Mh(){let e=Dr(),{t}=V();return e.status===`unknown`?b(`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 CamStack preset.`,{reason:e.reason})}):null}hi();var Nh=/\p{Mn}/gu;function Ph(e){return e.normalize(`NFD`).replace(Nh,``).toLowerCase().trim()}var Fh=[`device`,`page`,`integration`],Ih=0,Lh=1,Rh=2,zh=3,Bh=4,Vh=5,Hh=6,Uh=7;function Wh(e,t,n,r){return n.includes(r)?Ih:e===r?Lh:e.startsWith(r)?Rh:e.split(/\s+/).some(e=>e.startsWith(r))?zh:e.includes(r)?Bh:t.some(e=>e.includes(r))?Vh:null}function Gh(e,t){let n=0;for(let r=0;r<e.length&&n<t.length;r++)e[r]===t[n]&&n++;return n===t.length}function Kh(e){return e<4?0:e<=7?1:e<=12?2:3}function qh(e,t,n){if(e===t)return 0;if(n<=0||Math.abs(e.length-t.length)>n)return null;let r=t.length,i=Array(r+1).fill(0),a=Array.from({length:r+1},(e,t)=>t),o=Array(r+1).fill(0);for(let s=1;s<=e.length;s++){o[0]=s;let c=s,l=e[s-1];for(let n=1;n<=r;n++){let r=t[n-1],u=l===r?0:1,d=Math.min((a[n]??1/0)+1,o[n-1]+1,(a[n-1]??1/0)+u);s>1&&n>1&&l===t[n-2]&&e[s-2]===r&&(d=Math.min(d,(i[n-2]??1/0)+1)),o[n]=d,d<c&&(c=d)}if(c>n)return null;let u=i;i=a,a=o,o=u}let s=a[r]??1/0;return s<=n?s:null}function Jh(e,t){if(Gh(e,t))return Hh;let n=Kh(t.length);if(n>0){for(let r of e.split(/\s+/))if(qh(r,t,n)!==null)return Uh}return null}function Yh(e,t,n=200){let r=Ph(t);if(r.length===0)return{groups:[],totalMatched:0,truncated:!1};let i=new Map;for(let t of e){let e=Ph(t.label),n=Wh(e,(t.keywords??[]).map(Ph),(t.identifiers??[]).map(Ph),r)??Jh(e,r);if(n===null)continue;let a=i.get(t.domain)??[];a.push({item:t,rank:n}),i.set(t.domain,a)}let a=0;for(let e of i.values())a+=e.length;let o=n,s=[];for(let e of Fh){let t=i.get(e);if(!t||t.length===0||o<=0)continue;t.sort((e,t)=>e.rank-t.rank||e.item.label.localeCompare(t.item.label));let n=t.slice(0,o).map(e=>e.item);o-=n.length,s.push({domain:e,items:n})}return{groups:s,totalMatched:a,truncated:a>n}}function Xh(e){return e.flatMap(e=>e.items)}var Zh=`instance`;function Qh(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 $h(e,t){let n=`/integrations/${encodeURIComponent(e)}`;return t===void 0||t.length===0?n:`${n}?${Zh}=${encodeURIComponent(t)}`}var eg=` · `;function tg(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(eg)}function ng(e,t=null){let n=Ln(e),r=tr(B.language.startsWith(`it`)?`it`:`en`),i=kn(e),a=Wn(t);return e.map(e=>{let t=String(e.id),o=pi(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(eg).includes(c)),u=a(e),d=u.kind===`resolved`?u.integration.name:``;return{key:`device:${t}`,domain:`device`,label:s,subtitle:tg(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:Nn(e.type).icon}})}function rg(e){return e.map(e=>({key:`integration:${e.id}`,domain:`integration`,label:e.name||e.addonId,subtitle:e.enabled?e.addonId:B.t(`helpers.searchItems.disabled`,{addonId:e.addonId}),keywords:[e.addonId,e.processState],path:$h(e.addonId,e.id)}))}function ig(e,t,n){let r=e.section?.trim();return r?t[r]??e.sectionLabel?.trim()??r:n}function ag(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:ig(e,i,n.ungrouped),keywords:[e.addonId],path:e.path,icon:wh(e.icon)}));return[...r,...a]}D();var og={device:{labelKey:`search.resultsList.devices`,icon:ce},page:{labelKey:`search.resultsList.pages`,icon:gn},integration:{labelKey:`search.resultsList.integrations`,icon:de}};function sg({groups:e,activeKey:t,query:n,totalMatched:r,truncated:i,onSelect:a,onHover:s}){let{t:c}=V(),l=f(null);if(x(()=>{t&&(l.current?.querySelector(`[data-key="${CSS.escape(t)}"]`))?.scrollIntoView({block:`nearest`})},[t]),n.trim().length===0)return null;if(e.length===0)return b(`div`,{className:`px-3 py-4 text-center text-[12px] text-foreground-subtle`,children:c(`search.resultsList.noResults`,{query:n})});let u=e.reduce((e,t)=>e+t.items.length,0);return o(P,{children:[b(`div`,{ref:l,role:`listbox`,className:`max-h-[60vh] overflow-y-auto py-1`,children:e.map(e=>{let n=og[e.domain],r=n.icon;return o(`div`,{className:`px-1 py-1`,children:[o(`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:[b(r,{className:`h-3 w-3`}),c(n.labelKey)]}),e.items.map(e=>{let r=e.icon??n.icon,i=e.key===t;return o(`button`,{type:`button`,role:`option`,"aria-selected":i,"data-key":e.key,onMouseEnter:()=>s(e),onClick:()=>a(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:[b(r,{className:`h-3.5 w-3.5 shrink-0 ${i?`text-primary`:`text-foreground-subtle`}`}),o(`span`,{className:`flex-1 min-w-0`,children:[b(`span`,{className:`block truncate font-medium`,children:e.label}),e.subtitle&&b(`span`,{className:`block truncate text-[10px] text-foreground-subtle`,children:e.subtitle})]})]},e.key)})]},e.domain)})}),i&&b(`div`,{className:`border-t border-border px-3 py-1.5 text-center text-[10px] text-foreground-subtle`,children:c(`search.truncatedResults`,`Showing first {{shown}} of {{total}} — refine your search.`,{shown:u,total:r})})]})}D();function cg({navSections:e,addonPages:t,compact:n,onNavigated:r}){let{t:i}=V(),a=J(),s=f(null),c=f(null),l=f(null),[u,d]=C(null),[m,h]=C(``),[g,_]=C(0),[v,S]=C(!1),{data:w}=Hn({projection:`slim`}),{data:T}=Pr(void 0),E=p(()=>{let n={detection:i(`nav.detectionSection`,`Detection`),cluster:i(`nav.clusterSection`,`Cluster`),administration:i(`system.title`,`Administration`),ungrouped:i(`nav.addonPages`,`Addon Pages`)};return[...ng(w??[],T??null),...ag(e,t,n),...rg(T??[])]},[w,T,e,t,i]),{groups:D,totalMatched:O,truncated:k}=p(()=>Yh(E,m),[E,m]),A=p(()=>Xh(D),[D]);x(()=>{_(0)},[m,E]),x(()=>{v&&s.current?.focus()},[v]);let j=y(()=>{S(!1),h(``),_(0)},[]),M=y(e=>{a(e.path),j(),s.current?.blur(),r?.()},[a,j,r]);fi(s,{scope:Tn}),x(()=>{if(!v)return;function e(e){if(!(e.target instanceof Node))return;let t=c.current?.contains(e.target)===!0,n=l.current?.contains(e.target)===!0;!t&&!n&&S(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[v]);let N=v&&m.trim().length>0;x(()=>{if(!N){d(null);return}let e=()=>{let e=s.current?.getBoundingClientRect();e&&d({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)}},[N]);let P=A[g]?.key??null,F=i(`search.placeholder`,`Search devices, pages, integrations…`),I=o(`div`,{className:`relative`,children:[b(et,{className:`pointer-events-none absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-foreground-subtle`}),b(`input`,{ref:s,type:`text`,value:m,placeholder:F,"aria-label":F,role:`combobox`,"aria-expanded":v&&m.trim().length>0,"aria-controls":`global-search-results`,onChange:e=>{h(e.target.value),S(!0)},onFocus:()=>S(!0),onKeyDown:e=>{if(e.key===`ArrowDown`)e.preventDefault(),A.length>0&&_(e=>(e+1)%A.length);else if(e.key===`ArrowUp`)e.preventDefault(),A.length>0&&_(e=>(e-1+A.length)%A.length);else if(e.key===`Enter`){e.preventDefault();let t=A[g];t&&M(t)}else e.key===`Escape`&&(e.preventDefault(),j(),s.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`}),m.length>0&&b(`button`,{type:`button`,"aria-label":i(`search.globalSearch.clearSearch`,`Clear search`),onClick:()=>{h(``),s.current?.focus()},className:`absolute right-1.5 top-1/2 -translate-y-1/2 text-foreground-subtle hover:text-foreground`,children:b(Pe,{className:`h-3 w-3`})}),N&&u!==null&&gi(b(`div`,{ref:l,id:`global-search-results`,className:`fixed z-50 w-max max-w-[26rem] rounded-lg border border-border bg-surface shadow-xl`,style:{left:u.left,top:u.top,minWidth:u.width},children:b(sg,{groups:D,activeKey:P,query:m,totalMatched:O,truncated:k,onSelect:M,onHover:e=>{let t=A.findIndex(t=>t.key===e.key);t>=0&&_(t)}})}),document.body)]});return n?b(`div`,{ref:c,className:`px-1.5 pb-1.5`,children:v?b(`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:I}):b(`button`,{type:`button`,onClick:()=>S(!0),"aria-label":F,title:F,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:b(et,{className:`h-3.5 w-3.5 shrink-0`})})}):b(`div`,{ref:c,className:`px-2 pb-2`,children:I})}var lg=/^(\d{1,3}\.){3}\d{1,3}$/;function ug(e){let t=e.startsWith(`[`)&&e.endsWith(`]`)?e.slice(1,-1):e;return!!(lg.test(t)||t.includes(`:`))}function dg(e,t){return!t||ug(e)?!1:e===t||e.endsWith(`.${t}`)}D();var fg=`auth-webauthn/passkey-enrollment`,pg=`camstack_passkey_prompt_dismissed:`,mg=720*60*60*1e3;function hg(e){try{let t=localStorage.getItem(`${pg}${e}`);if(!t)return!1;let n=Number(t);return Number.isFinite(n)?Date.now()-n<mg:!1}catch{return!1}}function gg(e){try{localStorage.setItem(`${pg}${e}`,String(Date.now()))}catch{}}function _g(){let{user:e}=cu(),{t}=V(),n=Ae(),r=pr(fg),[i,a]=C(!1),[s,c]=C(!1),l=p(()=>e?hg(e.id):!0,[e]),u=$r.auth.listLoginMethods.useQuery().data?.find(e=>e.kind===`passkey`),d=u!==void 0&&dg(window.location.hostname,u.rpId),f=e!==null&&d&&r!=null&&!l,m=T({queryKey:[`auth`,`listOwnPasskeys`],queryFn:()=>n.listOwnPasskeys(),enabled:f,staleTime:6e4}),h=y(()=>{e&&gg(e.id),a(!0),c(!1)},[e]),g=y(()=>{c(!1),m.refetch()},[m]);return!f||i||m.data===void 0||m.data.length>0?null:o(`div`,{className:`shrink-0 border-b border-primary/20 bg-primary/5`,children:[o(`div`,{className:`flex items-center gap-2.5 px-3 py-2 text-xs text-foreground`,children:[b(cn,{className:`h-4 w-4 text-primary shrink-0`}),b(`span`,{className:`flex-1 min-w-0`,children:t(`passkeyPrompt.message`,`Save a passkey for faster sign-in?`)}),b(`button`,{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`)}),b(`button`,{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`)}),b(`button`,{onClick:h,"aria-label":t(`passkeyPrompt.notNow`,`Not now`),className:`p-1 rounded text-foreground-subtle hover:text-foreground`,children:b(Pe,{className:`h-3.5 w-3.5`})})]}),s&&b(`div`,{className:`px-3 pb-3`,children:o(`div`,{className:`max-w-xl`,children:[b(Ar,{widgetId:fg,host:`dashboard`}),b(`div`,{className:`mt-2 flex justify-end`,children:b(`button`,{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 vg=6e4;function yg(){let e=mi(void 0,{staleTime:vg});return{info:e.data?.serverName??null,isLoading:e.isLoading}}D();var bg=`system-config`,xg=`hub`,Sg=`camstack_server_name_prompt_dismissed`;function Cg(){try{return sessionStorage.getItem(Sg)===`1`}catch{return!1}}function wg(){try{sessionStorage.setItem(Sg,`1`)}catch{}}function Tg(e){return e.isAdmin&&e.info!==null&&e.info.isDefault&&!e.dismissed}function Eg(){let{user:e}=cu(),{info:t}=yg(),[n,r]=C(Cg);return Tg({isAdmin:e?.isAdmin===!0,info:t,dismissed:n})?b(Dg,{suggestion:t?.name??``,onLater:()=>{wg(),r(!0)}}):null}function Dg({suggestion:e,onLater:t}){let{t:n}=V(),r=M(),i=Fr(),[a,s]=C(e),[c,l]=C(null),u=f(null);x(()=>u.current?.focus(),[]);let d=y(async()=>{let e=Jt.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({addonId:bg,nodeId:xg,patch:{name:e.data}}),await r.invalidateQueries({queryKey:[[`system`,`info`]]}),await r.invalidateQueries({queryKey:[[`addonSettings`]]})}catch(e){l(e instanceof Error&&e.message.length>0?e.message:`Could not save`)}},[r,i,n,a]);return b(Or,{open:!0,onOpenChange:e=>!e&&t(),children:b(ii,{children:o(`form`,{onSubmit:e=>{e.preventDefault(),i.isPending||d()},children:[o(ui,{children:[b(Zn,{children:n(`serverName.title`,`Name this server`)}),b(di,{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.`)})]}),b(hr,{children:b(En,{label:n(`serverName.label`,`Server name`),...c===null?{}:{error:c},children:b(Sn,{ref:u,value:a,maxLength:48,onChange:e=>s(e.target.value),state:c===null?`default`:`error`,"aria-label":n(`serverName.label`,`Server name`)})})}),o(vr,{children:[b(Cr,{type:`button`,variant:`ghost`,onClick:t,disabled:i.isPending,children:n(`serverName.later`,`Later`)}),o(Cr,{type:`submit`,disabled:i.isPending||a.trim().length===0,children:[i.isPending&&b(Me,{className:`h-4 w-4 animate-spin`}),n(`common.save`,`Save`)]})]})]})})})}var Og=4,kg=160,Ag=320,jg=`env(safe-area-inset-top)`,Mg=`env(safe-area-inset-bottom)`;function Ng(e){let{rect:t,viewportWidth:n,viewportHeight:r}=e,i=Math.min(Ag,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+Og}px, calc(${jg} + 8px))`;return{...a,top:e,maxHeight:`max(${kg}px, calc(100dvh - ${e} - ${Mg} - 8px))`}}let o=`max(${r-t.top+Og}px, calc(${Mg} + 8px))`;return{...a,bottom:o,maxHeight:`max(${kg}px, calc(100dvh - ${o} - ${jg} - 8px))`}}function Pg(e){return e===`totp`||e===`passkey`}function Fg(e){if(!e.startsWith(`#`))return null;let t=new URLSearchParams(e.slice(1)),n=t.get(`challenge`);if(n!==null){if(n.length===0)return null;let e=(t.get(`factors`)??``).split(`,`).filter(Pg);return e.length===0?null:{kind:`challenge`,challengeToken:n,factors:e}}let r=t.get(`error`);return r===`sso-not-linked`||r===`sso-state`?{kind:`error`,code:r,provider:t.get(`provider`)}:null}function Ig(e,t){switch(e){case`sso-not-linked`:return B.t(`helpers.ssoReturn.notLinked`,{provider:t??B.t(`helpers.ssoReturn.signInFallback`)});case`sso-state`:return B.t(`helpers.ssoReturn.state`)}}var Lg={expired:`helpers.ssoReturn.link.expired`,provider:`helpers.ssoReturn.link.provider`,session:`helpers.ssoReturn.link.session`,conflict:`helpers.ssoReturn.link.conflict`,state:`helpers.ssoReturn.link.state`};function Rg(e){let t=new URLSearchParams(e),n=t.get(`linked`);if(n!==null&&n.length>0)return{kind:`linked`,provider:n};let r=t.get(`linkError`);return r===null?null:{kind:`error`,message:B.t(Lg[r]??`helpers.ssoReturn.link.failed`)}}var zg=`camstack:sso-return`,Bg=`camstack:sso-ack`,Vg=`/sso-complete`,Hg=1500,Ug=520,Wg=680;function Gg(e){if(!e.startsWith(`#`))return null;let t=new URLSearchParams(e.slice(1)),n=t.get(`return`);t.delete(`return`);let r=t.toString();return n===`login`?r.length>0?{target:n,fragment:r}:null:n===`profile`&&r.length>0?{target:n,query:r}:null}function Kg(e){return e.target===`login`?`/login#${e.fragment}`:`/system/my-access?${e.query}`}function qg(e){let t=new URL(e,`http://placeholder.invalid`);return t.searchParams.set(`popup`,`1`),/^[a-z][a-z0-9+.-]*:/i.test(e)?t.toString():`${t.pathname}${t.search}${t.hash}`}function Jg(e=window){let t=Math.max(0,Math.round(e.screenX+(e.outerWidth-Ug)/2)),n=Math.max(0,Math.round(e.screenY+(e.outerHeight-Wg)/2));return[`popup=yes`,`width=${Ug}`,`height=${Wg}`,`left=${t}`,`top=${n}`,`toolbar=no`,`menubar=no`,`location=no`,`status=no`,`resizable=yes`,`scrollbars=yes`].join(`,`)}function Yg(e){try{return window.open(e??`about:blank`,`camstack-sso`,Jg())??null}catch{return null}}function Xg(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.target===`login`?typeof t.fragment==`string`:t.target===`profile`?typeof t.query==`string`:!1}function Zg(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.type===`camstack:sso-return`&&Xg(t.completion)}function Qg(e,t,n){return t===null||e.source!==t||e.origin!==n?null:Zg(e.data)?e.data.completion:null}var $g=`camstack-sso`,e_=`camstack:sso-done`;function t_(e,t){return e.target===`profile`?{target:`profile`,query:e.query}:t?{target:`login`}:null}function n_(e){if(typeof e!=`object`||!e)return null;let t=e;if(t.type!==`camstack:sso-done`)return null;let n=Object.keys(t).sort().join(`,`);return t.target===`login`&&n===`target,type`?{target:`login`}:t.target===`profile`&&typeof t.query==`string`&&n===`query,target,type`?{target:`profile`,query:t.query}:null}function r_(e){return typeof e==`object`&&!!e&&e.type===`camstack:sso-done-ack`}function i_(e){try{let t=e.location.origin;return typeof t==`string`?t:null}catch{return null}}function a_(){if(typeof BroadcastChannel>`u`)return null;try{let e=new BroadcastChannel($g);return{post:t=>e.postMessage(t),subscribe:t=>{let n=e=>t(e.data);return e.addEventListener(`message`,n),()=>e.removeEventListener(`message`,n)},close:()=>e.close()}}catch{return null}}var o_=500;function s_(e,t,n=window,r={}){let i=n.location.origin,a=r.channel===void 0?a_():null,o=r.channel===void 0?a:r.channel,s=r.setInterval??((e,t)=>window.setInterval(e,t)),c=r.clearInterval??(e=>window.clearInterval(e)),l=!1,u=!1,d=r=>{let a=Qg(r,e,i);a===null||l||(l=!0,n.removeEventListener(`message`,d),e.postMessage({type:Bg},i),t.onReturn(a))};n.addEventListener(`message`,d);let f=o?.subscribe(e=>{let n=n_(e);n===null||l||(l=!0,o.post({type:`camstack:sso-done-ack`}),t.onDone?.(n))})??null,p=s(()=>{u||!e.closed||(u=!0,c(p),t.onClosed?.())},o_);return()=>{n.removeEventListener(`message`,d),f?.(),a?.close(),c(p)}}function c_(e,t,n){if(t===null||e.source!==t||e.origin!==n)return!1;let r=e.data;return typeof r==`object`&&!!r&&r.type===`camstack:sso-ack`}function l_(e,t){return new Promise(n=>{let r=!1,i=t(()=>{r||(r=!0,i(),n(!0))});e.setTimeout(()=>{r||(r=!0,i(),n(!1))},Hg)})}function u_(e,t,n){let r=l_(n,e=>{let r=r=>{c_(r,t,n.origin)&&e()};return n.addEventListener(`message`,r),()=>n.removeEventListener(`message`,r)});try{let r={type:zg,completion:e};t.postMessage(r,n.origin)}catch{}return r}function d_(e,t,n){let r=l_(n,e=>t.subscribe(t=>{r_(t)&&e()}));return t.post({type:e_,...e}),r}async function f_(e,t){let n=t.opener!==null&&!t.opener.closed?t.opener:null;if(n!==null&&i_(n)===t.origin&&await u_(e,n,t)){t.close();return}let r=e.target===`login`?new URLSearchParams(e.fragment).get(`token`):null,i=r!==null&&r.length>0,a=t_(e,i);if(a!==null&&t.channel!==null&&(r!==null&&i&&await t.persistSession(r),await d_(a,t.channel,t))){t.close();return}if(n!==null&&e.target===`profile`){let n=Rg(`?${e.query}`);if(n?.kind===`error`){t.showResult({kind:`link-error`,message:n.message});return}t.close();return}t.continueAt(Kg(e))}function p_(e,t){return(t.length>0&&e.startsWith(t)?e.slice(t.length):e).replace(/\/+$/,``)===Vg}var m_=`camstack:broker-oauth`;function h_(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.type===`camstack:broker-oauth`&&typeof t.ok==`boolean`}function g_(e,t){return e.split(`{{brokerId}}`).join(encodeURIComponent(t))}function __(e,t,n=window){let r=n.location.origin,i=!1,a=e=>{i||(i=!0,n.removeEventListener(`message`,o),window.clearInterval(s),t(e))},o=t=>{t.origin!==r||t.source!==e||h_(t.data)&&a({ok:t.data.ok,...t.data.brokerId===void 0?{}:{brokerId:t.data.brokerId},...t.data.error===void 0?{}:{error:t.data.error}})};n.addEventListener(`message`,o);let s=window.setInterval(()=>{e.closed&&a({ok:!0})},500);return()=>{i=!0,n.removeEventListener(`message`,o),window.clearInterval(s)}}var v_={open:e=>Yg(e),assign:e=>window.location.assign(e),watch:(e,t)=>__(e,t)};function y_(e,t,n=v_){let r=z(qg(e)),i=n.open(r);if(i===null){n.assign(r);return}n.watch(i,e=>{t?.(e)})}function b_(e,t,n){y_(g_(e,t),n)}var x_=!1;function S_(){return x_}function C_(){x_=!0}function w_(e){return!e.read&&e.severity===`critical`}function T_(e){return e.filter(w_)}function E_(e){return e!==void 0&&typeof e.href==`string`&&e.href.length>0}function D_(e){return E_(e)||e!==void 0&&e.invoke!==void 0}var O_=/^\/addon\/[^/?#]+\/oauth\//;function k_(e){return e.navigation===void 0?O_.test(e.href):e.navigation===`server`}function A_(e){let t=e.action;if(D_(t)&&!(t.invoke!==void 0&&(e.status===`completed`||e.status===`dismissed`)))return t}D();function j_({action:e,className:t,onActivate:n}){let r=M(),i=Ae(),{t:a}=V(),[s,c]=C(!1),[l,u]=C(null);if(e.invoke!==void 0){let{addonId:d,action:f,input:p}=e.invoke;return o(`span`,{className:`inline-flex flex-col items-start gap-0.5`,children:[b(`button`,{type:`button`,className:t,disabled:s,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:s?a(`ui.alertAction.running`,`Working…`):e.label}),l!==null&&b(`span`,{role:`alert`,className:`text-[10px] text-destructive`,children:l})]})}return E_(e)?k_(e)?b(`a`,{href:z(e.href),className:t,onClick:t=>{t.preventDefault(),n?.(t),y_(e.href,()=>{r.invalidateQueries({queryKey:[[`alerts`]]}),r.invalidateQueries({queryKey:[[`broker`]]}),r.invalidateQueries({queryKey:[[`recordEntries`]]})})},children:e.label}):b(hs,{to:e.href,className:t,onClick:n,children:e.label}):b(P,{})}D(),hi();var M_={info:De,success:rt,warning:at,error:nt,critical:dn},N_={info:`text-info`,success:`text-success`,warning:`text-warning`,error:`text-danger`,critical:`text-danger`},P_={active:`border-l-info`,"in-progress":`border-l-warning`,completed:`border-l-success`,failed:`border-l-danger`,dismissed:`border-l-foreground-subtle/30`};function F_(e){let t=Math.floor((Date.now()-e)/1e3);if(t<60)return B.t(`helpers.relativeTime.justNow`);let n=Math.floor(t/60);if(n<60)return B.t(`helpers.relativeTime.minutesAgo`,{count:n});let r=Math.floor(n/60);if(r<24)return B.t(`helpers.relativeTime.hoursAgo`,{count:r});let i=Math.floor(r/24);return B.t(`helpers.relativeTime.daysAgo`,{count:i})}function I_(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function L_(e){return typeof e==`string`&&e.length>0?e:void 0}function R_(e){if(I_(e.metadata)){let t=L_(e.metadata.nodeId)??L_(e.metadata.agentId);if(t!==void 0)return t}let t=e.source;if(t!==void 0&&!(t.type!==`node`&&t.type!==`agent`))return L_(t.id)}function z_({alert:e,onMarkRead:t,onDismiss:n}){let{t:r}=V(),i=e.severity in M_?e.severity:`info`,a=A_(e),s=e.status in P_?e.status:`active`,c=M_[i],l=N_[i],u=P_[s],{nodes:d}=lr(),f=R_(e),p=f===void 0?void 0:d.find(e=>e.id===f),m=f===void 0?void 0:p?.name??f;return o(`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:[b(c,{className:`h-3.5 w-3.5 shrink-0 mt-0.5 ${l}`}),o(`div`,{className:`flex-1 min-w-0`,children:[o(`div`,{className:`flex items-center gap-1.5`,children:[b(`span`,{className:`text-[11px] font-semibold ${e.read?`text-foreground-subtle`:`text-foreground`}`,children:e.title}),!e.read&&b(`span`,{className:`h-1.5 w-1.5 rounded-full bg-primary shrink-0`})]}),m!==void 0&&b(`div`,{className:`text-foreground-subtle text-[10px] mt-0.5 truncate`,children:m}),b(`div`,{className:`text-[10px] text-foreground-subtle mt-0.5 line-clamp-2`,children:e.message}),a!==void 0&&b(j_,{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&&o(`div`,{className:`mt-1.5 flex items-center gap-2`,children:[b(`div`,{className:`flex-1 h-1 bg-surface-hover rounded-full overflow-hidden`,children:b(`div`,{className:`h-full bg-primary rounded-full transition-all duration-300`,style:{width:`${String(Math.min(100,Math.max(0,e.progress)))}%`}})}),o(`span`,{className:`text-[9px] text-foreground-subtle font-mono shrink-0`,children:[String(Math.round(e.progress)),`%`]})]}),b(`div`,{className:`text-[9px] text-foreground-subtle/60 mt-1`,children:F_(e.updatedAt)})]}),o(`div`,{className:`flex items-center gap-0.5 shrink-0`,children:[!e.read&&b(`button`,{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:b(ue,{className:`h-3 w-3 text-foreground-subtle`})}),e.status!==`in-progress`&&b(`button`,{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:b(Pe,{className:`h-3 w-3 text-foreground-subtle`})})]})]})}function B_({variant:e=`icon`,compact:t=!1}={}){let{t:n}=V(),[r,i]=C(!1),[a,s]=C(!1),c=f(null),l=f(null),u=M(),{data:d=0}=Vr(void 0,{refetchInterval:3e4}),{data:p=[],isLoading:m}=qr({limit:50},{enabled:r}),h=a?p:p.filter(e=>!e.read),g=p.filter(e=>e.read).length,_=()=>{u.invalidateQueries({queryKey:[[`alerts`]]})},v=gr({onSuccess:_}),S=jr({onSuccess:_}),w=Qr({onSuccess:_});Sr(`alert.created`,()=>{u.invalidateQueries({queryKey:[[`alerts`]]})}),Sr(`alert.updated`,()=>{u.invalidateQueries({queryKey:[[`alerts`]]})}),x(()=>{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=y(e=>{v.mutate({alertId:e})},[v]),E=y(e=>{e&&w.mutate({alertId:e})},[w]),D=y(()=>{S.mutate(void 0),i(!1)},[S]),O=h.filter(w_),k=new Set(O.map(e=>e.id)),A=h.filter(e=>e.status===`in-progress`&&!k.has(e.id)),j=h.filter(e=>e.status!==`in-progress`&&!k.has(e.id)),[N,P]=C({}),F=y(()=>{let e=l.current;e&&P(Ng({rect:e.getBoundingClientRect(),viewportWidth:window.innerWidth,viewportHeight:window.innerHeight}))},[]);return x(()=>{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]),o(`div`,{children:[e===`sidebar`?o(`button`,{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?d>0?n(`ui.alertBell.alertsUnread`,{count:d}):n(`ui.alertBell.alerts`):void 0,children:[o(`span`,{className:`relative inline-flex shrink-0`,children:[b(it,{className:`h-3.5 w-3.5`}),t&&d>0&&b(`span`,{className:`absolute -top-1 -right-1 h-2 w-2 rounded-full bg-primary`})]}),!t&&b(`span`,{className:`flex-1 text-left`,children:n(`ui.alertBell.alerts`,`Alerts`)}),!t&&d>0&&b(`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:d>99?`99+`:String(d)})]}):o(`button`,{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:[b(it,{className:`h-4.5 w-4.5`}),d>0&&b(`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:d>99?`99+`:String(d)})]}),r&&gi(o(`div`,{ref:c,style:N,className:`bg-surface border border-border rounded-lg shadow-xl flex flex-col overflow-hidden`,children:[o(`div`,{className:`flex items-center justify-between px-3 py-2 border-b border-border shrink-0`,children:[b(`span`,{className:`text-[12px] font-semibold text-foreground`,children:n(`ui.alertBell.alerts`,`Alerts`)}),o(`div`,{className:`flex items-center gap-2`,children:[g>0&&o(`label`,{className:`flex items-center gap-1 text-[10px] text-foreground-subtle cursor-pointer select-none`,children:[b(`input`,{type:`checkbox`,checked:a,onChange:e=>s(e.target.checked),className:`h-3 w-3 rounded border-border accent-primary cursor-pointer`}),n(`ui.alertBell.showRead`,`Show read`)]}),d>0&&o(`button`,{type:`button`,onClick:D,className:`flex items-center gap-1 text-[10px] text-primary hover:text-primary/80 transition-colors`,children:[b(pn,{className:`h-3 w-3`}),n(`ui.alertBell.markAllRead`,`Mark all read`)]})]})]}),o(`div`,{className:`flex-1 overflow-y-auto`,children:[m&&b(`div`,{className:`flex items-center justify-center py-8`,children:b(Me,{className:`h-4 w-4 animate-spin text-foreground-subtle`})}),!m&&h.length===0&&o(`div`,{className:`flex flex-col items-center justify-center py-8 text-foreground-subtle`,children:[b(it,{className:`h-6 w-6 mb-2 opacity-40`}),b(`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&&b(`button`,{type:`button`,onClick:()=>s(!0),className:`text-[10px] text-primary mt-1 hover:underline`,children:n(`ui.alertBell.showRead`,{count:g})})]}),O.length>0&&o(`div`,{className:`border-b border-border`,children:[b(`div`,{className:`px-3 py-1.5 bg-danger/5`,children:b(`span`,{className:`text-[9px] font-semibold uppercase tracking-widest text-danger`,children:n(`ui.alertBell.urgent`,`Urgent`)})}),O.map(e=>b(z_,{alert:e,onMarkRead:T,onDismiss:E},e.id))]}),A.length>0&&o(`div`,{className:`border-b border-border`,children:[b(`div`,{className:`px-3 py-1.5 bg-surface-hover/50`,children:b(`span`,{className:`text-[9px] font-semibold uppercase tracking-widest text-foreground-subtle/60`,children:n(`ui.alertBell.inProgress`,`In Progress`)})}),A.map(e=>b(z_,{alert:e,onMarkRead:T,onDismiss:E},e.id))]}),j.map(e=>b(z_,{alert:e,onMarkRead:T,onDismiss:E},e.id))]})]}),document.body)]})}D(),hi();function V_({alert:e,onMarkRead:t}){let{t:n}=V(),r=A_(e);return o(`div`,{className:`border-b border-border last:border-b-0 px-3 py-2.5`,children:[b(`div`,{className:`text-[12px] font-semibold text-foreground`,children:e.title}),b(`div`,{className:`text-[11px] text-foreground-muted mt-0.5`,children:e.message}),o(`div`,{className:`mt-2 flex flex-wrap items-center gap-2`,children:[r!==void 0&&b(j_,{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`}),b(Cr,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>t(e.id),children:n(`ui.alertBell.markAsRead`,`Mark as read`)})]})]})}function H_(){let{t:e}=V(),t=M(),[n,r]=C(S_()),{data:i=[],isLoading:a}=qr({limit:50}),s=p(()=>T_(i),[i]),c=gr({onSuccess:y(()=>{t.invalidateQueries({queryKey:[[`alerts`]]})},[t])}),l=y(e=>{c.mutate({alertId:e})},[c]),u=y(()=>{C_(),r(!0)},[]);return a||n||s.length===0?null:gi(b(`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:o(`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:[o(`div`,{className:`flex items-start justify-between gap-2 px-3 py-2.5 border-b border-border shrink-0 bg-danger/5`,children:[o(`div`,{children:[b(`h2`,{id:`critical-alerts-panel-title`,className:`text-[12px] font-semibold text-foreground`,children:e(`ui.criticalAlertsPanel.title`,`Urgent alerts`)}),b(`p`,{className:`text-[10px] text-foreground-muted mt-0.5`,children:e(`ui.criticalAlertsPanel.subtitle`,`These need your attention.`)})]}),b(Mr,{type:`button`,variant:`ghost`,onClick:u,"aria-label":e(`ui.criticalAlertsPanel.close`,`Close`),"data-testid":`critical-alerts-panel-close`,icon:Pe})]}),b(`div`,{className:`flex-1 overflow-y-auto`,children:s.map(e=>b(V_,{alert:e,onMarkRead:l},e.id))})]})}),document.body)}D();function U_(){let e=nl();return S(e.subscribe,e.getSnapshot,e.getSnapshot)}var W_=[`detection`,`cluster`,`administration`];function G_(e){return W_.includes(e)}function K_(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(G_(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 q_=`camstack:last-path`,J_=512,Y_=[`/login`,`/change-password`,`/access-denied`,`/logout`];function X_(e){return!e.startsWith(`/`)||e.startsWith(`//`)||e.length>J_?!1:!Y_.some(t=>e===t||e.startsWith(t+`/`))}function Z_(e){if(!(typeof window>`u`)&&X_(e))try{window.localStorage.setItem(q_,e)}catch{}}function Q_(){if(typeof window>`u`)return null;try{let e=window.localStorage.getItem(q_);return e===null?null:X_(e)?e:null}catch{return null}}var $_=`/devices`;function ev(e){return e!==void 0&&X_(e)?e:Q_()??$_}function tv(e){return e.split(`.`)[0]===`0`?`${e} beta`:e}function nv(e){if(e===null)return null;let t=e.trim();return t.length>0?t:null}function rv(e){let t=nv(e.productVersion),n=nv(e.serverVersion),r=nv(e.fallbackVersion);return t!==null&&n!==null?{kind:`both`,productLabel:tv(t),serverVersion:n}:t===null?n===null?r===null?{kind:`none`}:{kind:`fallback`,version:r}:{kind:`server`,serverVersion:n}:{kind:`product`,productLabel:tv(t)}}function iv(e,t){if(!Object.hasOwn(e,t))return null;let n=Reflect.get(e,t);return typeof n==`string`?n:null}function av(e){return typeof e!=`object`||!e?null:{productVersion:iv(e,`productVersion`),serverVersion:iv(e,`serverVersion`)}}D();function ov(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 sv({placement:e,compact:t=!1}){let{t:n}=V(),[r,i]=C({kind:`fallback`,version:`1.2.514`});x(()=>{let e=new AbortController;return fetch(z(`/api/release-identity`),{signal:e.signal}).then(async e=>e.ok?av(await e.json()):null).then(t=>{e.signal.aborted||t===null||i(rv({productVersion:t.productVersion,serverVersion:t.serverVersion,fallbackVersion:`1.2.514`}))}).catch(t=>{e.signal.aborted||t instanceof DOMException&&t.name}),()=>e.abort()},[]);let a=ov(r,n);return a===null?null:e===`login`?b(`span`,{"data-testid":`release-identity`,children:a}):b(`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})}D();var cv=A(!0);function lv(e){return e===`/addon`||e.startsWith(`/addon/`)}function uv(e,t,n){let r=[...e.filter(e=>e!==t),t];return r.length<=n?r:r.slice(r.length-n)}function dv({maxCached:e=6}){let t=Za(),n=q(),r=Ka(),i=F(K),a=n.pathname,s=lv(a),c=f(new Map),l=f([]);if(s){c.current.set(a,{key:a,outlet:t,location:n,navigationType:r,routeContext:i});let o=uv(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 o(P,{children:[l.current.map(e=>{let t=c.current.get(e);if(t?.outlet==null)return null;let n=s&&e===a;return b(`div`,{className:n?`h-full min-h-0`:void 0,style:n?void 0:{display:`none`},hidden:!n,"aria-hidden":!n,children:b(cv.Provider,{value:n,children:b(La.Provider,{value:{location:t.location,navigationType:t.navigationType},children:b(K.Provider,{value:t.routeContext,children:t.outlet})})})},e)}),!s&&t!=null?b(`div`,{className:`h-full min-h-0`,children:t},a):null]})}D();var fv={dark:pe,light:me,system:an};function pv(){return b(`div`,{className:`flex h-full min-h-[50vh] items-center justify-center`,children:b(`span`,{className:`h-4 w-4 animate-spin rounded-full border-2 border-primary/30 border-t-primary`})})}function mv(){let e=q(),t=J(),{user:n,logout:r}=cu(),i=yr(),{t:a}=V(),s=Vn(),c=Mn(),{info:l}=yg();x(()=>{document.title=l===null?`CamStack Admin`:`${l.name} \u00b7 CamStack Admin`},[l]);let u=Kc(U_()),[d,m]=C(!1);x(()=>{Z_(e.pathname+e.search)},[e.pathname,e.search]);let[h,g]=C(()=>typeof window>`u`?!1:window.localStorage.getItem(`camstack:sidebar-collapsed`)===`1`);x(()=>{typeof window>`u`||window.localStorage.setItem(`camstack:sidebar-collapsed`,h?`1`:`0`)},[h]);let[_]=C(()=>{if(typeof window>`u`)return new Set;try{let e=window.localStorage.getItem(`camstack: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}});x(()=>{typeof window>`u`||window.localStorage.setItem(`camstack:sidebar-collapsed-groups`,JSON.stringify([..._]))},[_]),x(()=>{c&&window.localStorage.getItem(`camstack:sidebar-collapsed`)===null&&g(!0)},[c]);let{data:y=[]}=er({nodeId:`hub`},{refetchInterval:3e4}),S=y.length,w=M(),T=f(Date.now()),{data:E}=ci(void 0,{staleTime:0,refetchOnMount:`always`,refetchInterval:e=>{let t=e.state.data;return t&&t.length>0||Date.now()-T.current>=3e4?!1:2e3}}),D=p(()=>E&&n?.isAdmin?dh(E):[],[E,n?.isAdmin]),O=p(()=>K_(D),[D]),k=O.known.get(`detection`)??[],A=O.known.get(`cluster`)??[],j=O.known.get(`administration`)??[];Sr(`addon.page-ready`,()=>{w.invalidateQueries({queryKey:[[`addonPages`,`listPages`]]})});let N=()=>{r(),t(`/login`)},F=t=>!!(e.pathname===t||e.pathname.startsWith(t+`/`)),I=[`/system/pipeline`,`/live`,`/addon/osd-manager`,`/build`].some(t=>e.pathname===t||e.pathname.startsWith(t+`/`)),ee=n?.isAdmin===!0,L=p(()=>Sh({t:a,isAdmin:ee}),[a,ee]),ne=L[0]?.items??[],re=L[1]?.items??[],ie=L[2]?.items??[],ae=L[3]?.items??[],oe=i?.mode??`system`,se={dark:a(`theme.dark`),light:a(`theme.light`),system:a(`theme.system`)},R=h&&!s,ce=(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`}`,le=(e,t)=>e===0?null:R?b(`div`,{className:`pt-3 mb-1 mx-2 border-t border-border/60`},`sep-${t}`):b(`div`,{className:`pt-4 pb-1.5 px-2.5`,children:b(`span`,{className:`text-[10px] font-semibold uppercase tracking-widest text-foreground-subtle/60`,children:t})},`hdr-${t}`),ue=e=>{let n=F(e.path),r=wh(e.icon);return o(`button`,{onClick:()=>{t(e.path),m(!1)},className:ce(n),title:R?e.label:void 0,children:[b(r,{className:`h-3.5 w-3.5 shrink-0 ${n?`text-primary`:``}`}),!R&&e.label]},`${e.addonId}::${e.id}`)},de=e=>e.requiresCapability===void 0?fe(e,!1):b(kh,{capability:e.requiresCapability,children:t=>fe(e,t)},e.path),fe=(e,n)=>{let r=e.icon,i=F(e.path),s=e.path===`/system/addons`;return o(`button`,{"data-testid":`nav-${e.path.replace(/^\//,``).replace(/\//g,`-`)}`,onClick:()=>{t(e.path),m(!1)},className:ce(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:[b(r,{className:`h-3.5 w-3.5 shrink-0 ${i?`text-primary`:``}`}),!R&&o(P,{children:[b(`span`,{className:`flex-1 text-left`,children:e.label}),s&&S>0&&b(`span`,{className:`ml-auto rounded-full bg-primary px-1.5 py-0.5 text-[9px] font-bold text-primary-foreground leading-none`,children:S})]}),R&&s&&S>0&&b(`span`,{className:`absolute mt-[-14px] ml-3 h-2 w-2 rounded-full bg-primary`})]},e.path)},pe=o(P,{children:[o(`div`,{className:`flex h-14 items-center border-b border-border ${R?`justify-center px-1`:`pl-3 pr-4 gap-2`}`,children:[!R&&b(`img`,{src:i?.resolvedMode===`light`?z(`/brand/logo-horizontal-light.svg`):z(`/brand/logo-horizontal-dark.svg`),alt:a(`layouts.appLayout.camstackAdmin`,`CamStack Admin`),className:`h-9 flex-1 min-w-0`}),!s&&b(`button`,{onClick:()=>g(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":h?a(`layouts.appLayout.expandSidebar`,`Expand sidebar`):a(`layouts.appLayout.collapseSidebar`,`Collapse sidebar`),title:h?a(`layouts.appLayout.expandSidebar`,`Expand sidebar`):a(`layouts.appLayout.collapseSidebar`,`Collapse sidebar`),children:b(h?ve:te,{className:`h-4 w-4`})})]}),!R&&l!==null&&b(`div`,{"data-testid":`sidebar-server-name`,title:l.name,className:`truncate border-b border-border px-3 py-1.5 text-xs font-medium text-foreground-muted`,children:l.name}),b(`div`,{className:`border-b border-border pt-2`,children:b(cg,{navSections:L,addonPages:D,compact:R,onNavigated:()=>m(!1)})}),o(`nav`,{className:`flex-1 overflow-y-auto py-3 ${R?`px-1.5`:`px-2`} space-y-0.5`,children:[ne.map(e=>de(e)),le(re.length+k.length,a(`nav.detectionSection`,`Detection`)),re.map(e=>de(e)),k.map(e=>ue(e)),le(ie.length+A.length,a(`nav.clusterSection`,`Cluster`)),ie.map(e=>de(e)),A.map(e=>ue(e)),le(ae.length+j.length,a(`system.title`,`Administration`)),ae.map(e=>de(e)),j.map(e=>ue(e)),O.custom.map(e=>o(`div`,{className:`contents`,children:[le(e.pages.length,e.label),e.pages.map(e=>ue(e))]},`custom-${e.id}`)),le(O.ungrouped.length,a(`nav.addonPages`,`Addon Pages`)),O.ungrouped.map(e=>ue(e))]}),o(`div`,{className:`border-t border-border ${R?`p-1.5`:`p-2`} space-y-0.5`,children:[o(`button`,{onClick:()=>i?.toggleMode(),className:ce(!1),title:R?se[oe]:void 0,children:[(()=>{let e=fv[oe];return b(e,{className:`h-3.5 w-3.5 shrink-0`})})(),!R&&b(`span`,{children:se[oe]})]}),b(B_,{variant:`sidebar`,compact:R}),o(`button`,{type:`button`,onClick:()=>t(`/system/my-access`),className:ce(F(`/system/my-access`)),title:R?a(`system.myAccess`,`My access`):void 0,children:[b(qe,{className:`h-3.5 w-3.5 shrink-0`}),!R&&b(`span`,{className:`truncate`,children:a(`system.myAccess`,`My access`)})]}),o(`button`,{onClick:N,className:ce(!1).replace(`hover:text-foreground`,`hover:text-danger`),title:R?n?.username??a(`layouts.appLayout.logout`,`Logout`):void 0,children:[b(vn,{className:`h-3.5 w-3.5 shrink-0`}),!R&&b(`span`,{className:`truncate`,children:n?.username??a(`layouts.appLayout.user`,`User`)})]}),b(sv,{placement:`sidebar`,compact:R})]})]});return o(`div`,{className:`flex h-dvh overflow-hidden bg-background text-foreground pt-[env(safe-area-inset-top)] pb-[env(safe-area-inset-bottom)]`,children:[!s&&b(`aside`,{className:`flex flex-col border-r border-border bg-surface/80 backdrop-blur-sm shrink-0 transition-[width] duration-150 ease-out ${R?`w-12`:`w-48`}`,children:pe}),s&&b(jn,{open:d,onClose:()=>m(!1),width:`w-64`,children:pe}),o(`div`,{className:`flex flex-1 flex-col min-w-0`,children:[u!==null&&o(`div`,{className:`flex items-center justify-center gap-2 px-3 py-2 text-[12px] font-medium shrink-0 ${u.severity===`danger`?`bg-danger/90 text-white`:`bg-warning/15 text-warning border-b border-warning/30`}`,children:[u.severity===`danger`?b(ge,{className:`h-3.5 w-3.5`}):b(Xe,{className:`h-3.5 w-3.5`}),b(`span`,{children:a(u.i18nKey,{defaultValue:u.message,...u.i18nParams})}),u.action===`sign-in`&&b(`button`,{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`)}),u.showSpinner&&b(Me,{className:`h-3.5 w-3.5 animate-spin`})]}),b(_g,{}),b(Eg,{}),b(H_,{}),s&&o(`header`,{className:`flex items-center h-12 border-b border-border px-3 shrink-0 bg-surface/80 backdrop-blur-sm`,children:[b(`button`,{onClick:()=>m(!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:b(Ie,{className:`h-5 w-5`})}),b(`div`,{className:`flex-1 flex justify-center`,children:b(`img`,{src:i?.resolvedMode===`light`?z(`/brand/logo-horizontal-light.svg`):z(`/brand/logo-horizontal-dark.svg`),alt:a(`layouts.appLayout.camstack`,`CamStack`),className:`h-7`})}),b(B_,{})]}),o(Ah,{children:[b(Mh,{}),b(`main`,{className:`relative flex-1 min-h-0 overscroll-contain bg-background ${I?`overflow-hidden`:`overflow-auto`}`,children:b(lh,{resetKey:e.pathname,children:b(v,{fallback:b(pv,{}),children:b(dv,{})})})})]})]})]})}function $({children:e,requireAdmin:t}){let{t:n}=V(),{user:r,loading:i,mustChangePassword:a}=cu(),o=q();return i?b(`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`?b(Y,{to:`/change-password`,replace:!0}):t&&!r.isAdmin?b(Y,{to:`/access-denied`,replace:!0}):b(P,{children:e}):b(Y,{to:`/login`,replace:!0,state:{from:o.pathname+o.search}})}var hv=`customize`,gv=`/build/compositions/new`,_v=`/build/compositions/:blockId`,vv=`/build?tab=custom-device`;function yv(e){return`/devices/${e}`}function bv(e){return`/devices/${e}?tab=${hv}`}var xv=`integration`,Sv=`section`,Cv=[xv,Sv],wv={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`}},Tv=`settings`,Ev=`activity`;function Dv(e,t={}){let{path:n,tab:r}=wv[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(xv,t.integration),t.section!==void 0&&i.set(Sv,t.section);let a=i.toString();return a.length>0?`${n}?${a}`:n}function Ov(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 kv(e,t,n=null,r=null){let i=new URLSearchParams(e);return i.set(xv,t),r===null?i.delete(Sv):i.set(Sv,r),n!==null&&i.delete(n),i}function Av(e){return e===`/admin`||e===`/admin/`?`/`:e.startsWith(`/admin/`)?e.slice(6):e}function jv(){let{t:e}=V(),t=J();return o(`div`,{className:`flex flex-col items-center justify-center text-foreground py-16 px-4`,children:[b(`div`,{className:`flex h-16 w-16 items-center justify-center rounded-2xl bg-danger/10 mb-4`,children:b(_n,{className:`h-8 w-8 text-danger`})}),b(`h1`,{className:`text-xl font-bold`,children:e(`accessDenied.accessDenied`,`Access Denied`)}),b(`p`,{className:`mt-2 text-sm text-foreground-subtle`,children:e(`accessDenied.youDonTHavePermission`,`You don't have permission to access this page.`)}),b(`button`,{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`)})]})}var Mv=`auth.password-incorrect`;function Nv(e,t){return typeof e==`object`&&e?Reflect.get(e,t):void 0}function Pv(e){if(!(e instanceof Error))return{kind:`connection-lost`};let t=Nv(e,`data`);return typeof t!=`object`||!t?{kind:`connection-lost`}:Nv(Nv(t,`i18n`),`code`)===Mv?{kind:`wrong-current`}:Nv(t,`code`)===`UNAUTHORIZED`?{kind:`session-ended`}:{kind:`rejected`,message:e.message}}D();var Fv=8;function Iv(e,t){let n=Pv(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 Lv(){let{t:e}=V(),{user:t,mustChangePassword:n,clearMustChangePassword:r,logout:i}=cu(),a=Ae(),s=yr(),c=J(),[l,u]=C(``),[d,f]=C(``),[p,m]=C(``),[h,g]=C(!1),[_,v]=C(``),[y,x]=C(!1),S=n?Ql:l;return b(`div`,{className:`flex min-h-screen items-center justify-center bg-background p-4`,children:o(`div`,{className:`w-full max-w-sm`,children:[b(`div`,{className:`flex justify-center mb-8`,children:b(`img`,{src:s?.resolvedMode===`light`?z(`/brand/logo-horizontal-light.svg`):z(`/brand/logo-horizontal-dark.svg`),alt:e(`changePassword.camstackAdmin`,`CamStack Admin`),className:`h-12`})}),o(`form`,{onSubmit:async i=>{if(i.preventDefault(),v(``),!t){v(`Not signed in`);return}if(!n&&l.length===0){v(e(`changePassword.enterCurrent`,`Enter your current password`));return}if(d.length<Fv){v(`Password must be at least ${Fv} characters`);return}if(d!==p){v(`The two passwords do not match`);return}if(d===`changeme`){v(`Choose a password different from the seed default`);return}x(!0);try{await a.changeOwnPassword({currentPassword:S,newPassword:d}),r(),c(`/devices`,{replace:!0})}catch(t){v(Iv(t,e))}finally{x(!1)}},className:`space-y-4 rounded-xl border border-border bg-surface p-6 shadow-xl shadow-black/10`,children:[o(`div`,{className:`space-y-1`,children:[b(`h1`,{className:`text-sm font-semibold text-foreground`,children:e(`changePassword.setANewPassword`,`Set a new password`)}),b(`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.`)})]}),_&&b(`div`,{role:`alert`,className:`rounded-md bg-danger/10 border border-danger/20 px-3 py-2 text-xs text-danger`,children:_}),!n&&o(`div`,{className:`space-y-1.5`,children:[b(`label`,{className:`text-xs font-medium text-foreground-subtle`,children:e(`changePassword.currentPassword`,`Current password`)}),b(`input`,{"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})]}),o(`div`,{className:`space-y-1.5`,children:[b(`label`,{className:`text-xs font-medium text-foreground-subtle`,children:e(`changePassword.newPassword`,`New password`)}),o(`div`,{className:`relative`,children:[b(`input`,{"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}),b(`button`,{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:b(h?ie:xe,{className:`h-4 w-4`})})]})]}),o(`div`,{className:`space-y-1.5`,children:[b(`label`,{className:`text-xs font-medium text-foreground-subtle`,children:e(`changePassword.confirmNewPassword`,`Confirm new password`)}),b(`input`,{"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`})]}),b(`button`,{"data-testid":`change-password-submit`,type:`submit`,disabled:y||!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:y?e(`changePassword.saving`,`Saving…`):e(`changePassword.saveAndContinue`,`Save and continue`)}),n&&b(`button`,{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`)})]})]})})}function Rv(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 zv(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 Bv(){return window?.PublicKeyCredential!==void 0&&typeof window.PublicKeyCredential==`function`}function Vv(e){let{id:t}=e;return{...e,id:zv(t),transports:e.transports}}function Hv(e){return e===`localhost`||/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(e)}var Uv=class extends Error{constructor({message:e,code:t,cause:n,name:r}){super(e,{cause:n}),this.name=r??n.name,this.code=t}},Wv=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}}},Gv=[`cross-platform`,`platform`];function Kv(e){if(e&&!(Gv.indexOf(e)<0))return e}function qv(){if(!Bv())return new Promise(e=>e(!1));let e=window.PublicKeyCredential;return e.isConditionalMediationAvailable===void 0?new Promise(e=>e(!1)):e.isConditionalMediationAvailable()}function Jv({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 Uv({message:`Authentication ceremony was sent an abort signal`,code:`ERROR_CEREMONY_ABORTED`,cause:e})}else if(e.name===`NotAllowedError`)return new Uv({message:e.message,code:`ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY`,cause:e});else if(e.name===`SecurityError`){let t=window.location.hostname;if(!Hv(t))return new Uv({message:`${window.location.hostname} is an invalid domain`,code:`ERROR_INVALID_DOMAIN`,cause:e});if(n.rpId!==t)return new Uv({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 Uv({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 Yv(e){let{optionsJSON:t,useBrowserAutofill:n=!1,verifyBrowserAutofillInput:r=!0}=e;if(!Bv())throw Error(`WebAuthn is not supported in this browser`);let i;t.allowCredentials?.length!==0&&(i=t.allowCredentials?.map(Vv));let a={...t,challenge:zv(t.challenge),allowCredentials:i},o={};if(n){if(!await qv())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=Wv.createNewAbortSignal();let s;try{s=await navigator.credentials.get(o)}catch(e){throw Jv({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=Rv(u.userHandle)),{id:c,rawId:Rv(l),response:{authenticatorData:Rv(u.authenticatorData),clientDataJSON:Rv(u.clientDataJSON),signature:Rv(u.signature),userHandle:f},type:d,clientExtensionResults:s.getClientExtensionResults(),authenticatorAttachment:Kv(s.authenticatorAttachment)}}function Xv(e){return typeof e==`object`&&!!e}function Zv(e){return Xv(e)&&typeof e.challenge==`string`}D();async function Qv(e){if(!Zv(e))throw Error(`passkey authentication options missing challenge`);let t=await Yv({optionsJSON:e});return Object.fromEntries(Object.entries(t))}function $v({method:e,challengeToken:t,onComplete:n,onSecondFactor:r,onError:i}){let[a,s]=C(!1),[c,l]=C(null),u=async()=>{l(null),s(!0);try{let e=Z();if(t){let r=await Qv((await e.loginBeginPasskey(t)).optionsJSON),i=await e.loginVerifyPasskey(t,r,{refreshable:!0});n(i.token,i);return}let a=await Qv((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{s(!1)}};return o(`div`,{className:`space-y-2`,children:[o(`button`,{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?b(Me,{className:`h-4 w-4 animate-spin text-primary`}):b(cn,{className:`h-4 w-4 text-primary`}),e.label]}),c&&b(`div`,{className:`rounded-md bg-danger/10 border border-danger/20 px-3 py-2 text-xs text-danger`,children:c})]})}var ey=()=>window.location.hostname;function ty(e,t=ey){return Bv()&&dg(t(),e.rpId)}function ny(e,t=ey){let n=e.filter(e=>e.kind===`passkey`&&e.stage===`second-factor`).filter(e=>ty(e,t));return{passkeyMethods:n,widgetMethods:n.length>0?[]:e.filter(e=>e.kind===`widget`&&e.stage===`second-factor`)}}function ry(e,t){let n=e.includes(`passkey`),r=t.passkeyMethods.length>0||t.widgetMethods.length>0,i=e.includes(`totp`);return n&&!r&&!i}function iy(e){let t=e.onComplete,n=e.onSecondFactor;return typeof t==`function`?{onComplete:t,onSecondFactor:typeof n==`function`?n:void 0}:null}function ay({methods:e,widgetConfig:t,onRedirect:n}){let{t:r}=V();or();let i=e.filter(e=>e.kind!==`passkey`||ty(e));return i.length===0?null:o(`div`,{className:`mt-6 space-y-3`,children:[o(`div`,{className:`flex items-center gap-3`,children:[b(`div`,{className:`h-px flex-1 bg-border`}),b(`span`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle`,children:r(`login.primaryLoginMethods.orContinueWith`,`Or continue with`)}),b(`div`,{className:`h-px flex-1 bg-border`})]}),b(`div`,{className:`space-y-2`,children:i.map(e=>{if(e.kind===`redirect`){let t=(e.icon===void 0?void 0:An(e.icon))??qe;return o(`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:[b(t,{className:`h-4 w-4 text-primary`}),e.label]},e.id)}if(e.kind===`passkey`){let n=iy(t);return n?b($v,{method:e,onComplete:n.onComplete,onSecondFactor:n.onSecondFactor},e.id):null}return b(oy,{method:e,config:t},e.id)})})]})}function oy({method:e,config:t}){let{t:n}=V(),r=In(e.remote,e.bundleUrl);return r===null?o(`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:[b(Me,{className:`h-3.5 w-3.5 animate-spin`}),n(`common.loading`,`Loading…`)]}):r===void 0?o(`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:[b(nt,{className:`h-3.5 w-3.5 shrink-0`}),n(`login.primaryMethods.loadFailed`)]}):b(r,{instanceId:e.id,host:`dashboard`,config:t})}var sy=4e3,cy=/^[A-Za-z0-9._-]{1,64}$/;function ly(e){let t=e.addonId!==void 0&&cy.test(e.addonId)?e.addonId:null,n=e.integration!==void 0&&cy.test(e.integration)?e.integration:null;if(t!==null&&e.brokerId!==void 0)return Dv(`connectivity`,{integration:t,kindSection:`brokers`});let r=n??t;return Dv(`connectivity`,r===null?{}:{integration:r})}function uy(e,t){let n=t.opener;if(n===null||n.closed||i_(n)!==t.origin)return!1;try{return n.postMessage({type:m_,ok:e.status===`success`,...e.brokerId===void 0?{}:{brokerId:e.brokerId},...e.status===`error`?{error:e.reason??`unknown`}:{}},t.origin),!0}catch{return!1}}D();var dy=500;function fy(e){let{t}=V();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_refresh_token`:return t(`oauthLanding.reason.no_refresh_token`,`The provider returned no long-lived access. Remove CamStack 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 py({outcome:e}){let{t}=V(),n=fy(e.reason??`unknown`);if(e.status===`error`)return o(P,{children:[b(Ke,{className:`mx-auto h-8 w-8 text-danger`,"aria-hidden":!0}),b(`h1`,{"data-testid":`oauth-landing-title`,className:`text-sm font-semibold text-foreground`,children:t(`oauthLanding.errorTitle`,`Sign-in did not finish`)}),b(`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})]});let r=e.action===`disconnect`;return o(P,{children:[b(rt,{className:`mx-auto h-8 w-8 text-success`,"aria-hidden":!0}),b(`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`)}),b(`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 CamStack…`)})]})}function my({outcome:e,closable:t,onContinue:n,onClose:r}){let{t:i}=V(),a=ly(e);return x(()=>{if(e.status!==`success`)return;let t=window.setTimeout(()=>n(a),sy);return()=>window.clearTimeout(t)},[e.status,n,a]),b(`main`,{className:`flex min-h-screen items-center justify-center bg-background p-4`,children:o(`div`,{className:`w-full max-w-sm space-y-4`,children:[b(`div`,{className:`flex justify-center`,children:o(`picture`,{children:[b(`source`,{media:`(prefers-color-scheme: dark)`,srcSet:z(`/brand/logo-horizontal-dark.svg`)}),b(`img`,{src:z(`/brand/logo-horizontal-light.svg`),alt:i(`oauthLanding.brand`,`CamStack`),className:`h-12`})]})}),o(`div`,{className:`space-y-4 rounded-xl border border-border bg-surface p-6 text-center shadow-xl shadow-black/10`,children:[b(py,{outcome:e}),o(`div`,{className:`flex flex-col gap-2`,children:[b(Cr,{type:`button`,variant:`primary`,onClick:()=>n(a),children:i(`oauthLanding.back`,`Back to CamStack`)}),t&&b(Cr,{type:`button`,variant:`ghost`,onClick:r,children:i(`oauthLanding.close`,`Close this window`)})]})]})]})})}function hy(e,t){window.history.replaceState(null,``,window.location.pathname);let n=window.opener,r=uy(t,{opener:n,origin:window.location.origin}),i=()=>e.render(b(my,{outcome:t,closable:r,onContinue:e=>window.location.replace(z(e)),onClose:()=>window.close()}));if(r&&t.status===`success`){window.close(),window.setTimeout(i,dy);return}i()}function gy(e){return Xt(e)}var _y=`Done — you can close this window.`,vy=500,yy=`camstack_admin_token`;async function by(e,t=``){try{let n=_l(new URLSearchParams(t));n!==null&&n.token===e?hl(n):localStorage.setItem(yy,e)}catch{}await fetch(z(`/api/auth/session`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({token:e})}).catch(()=>{})}function xy(){try{let e=localStorage.getItem(yy);return e!==null&&e.length>0?e:null}catch{return null}}function Sy(e){let t=gy(window.location.hash);if(t!==null){hy(e,t);return}let n=Gg(window.location.hash);window.history.replaceState(null,``,window.location.pathname);let r=t=>e.render(b(Cy,{completion:n,result:t}));if(r(null),n===null)return;let i=a_();f_(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:_y}),vy)},continueAt:e=>window.location.replace(z(e)),persistSession:e=>by(e,n.target===`login`?n.fragment:``),showResult:r,setTimeout:(e,t)=>window.setTimeout(e,t)})}function Cy({completion:e,result:t}){let{t:n}=V();return b(`div`,{className:`flex min-h-screen items-center justify-center bg-background p-4`,children:b(`div`,{className:`flex flex-col items-center gap-3 text-sm text-foreground-subtle`,children:e===null?b(`a`,{className:`text-primary underline`,href:z(`/login`),children:n(`ssoComplete.nothingToFinishHereGo`,`Nothing to finish here — go to sign-in`)}):t===null?o(`span`,{className:`flex items-center gap-3`,children:[b(`span`,{className:`h-4 w-4 animate-spin rounded-full border-2 border-primary/30 border-t-primary`}),n(`ssoComplete.finishingSignIn`,`Finishing sign-in…`)]}):o(P,{children:[b(`span`,{"data-testid":`sso-complete-result`,className:t.kind===`link-error`?`text-danger`:`text-foreground`,children:t.message}),b(`button`,{type:`button`,className:`rounded-md border border-border px-3 py-1.5 text-foreground hover:bg-surface-hover`,onClick:()=>window.close(),children:n(`ssoComplete.closeThisWindow`,`Close this window`)})]})})})}D();function wy(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 Ty(){let e=new URLSearchParams(window.location.search);return Ml({codeChallenge:e.get(`code_challenge`),codeChallengeMethod:e.get(`code_challenge_method`),state:e.get(`state`),purpose:e.get(`purpose`)})}function Ey(e){return Math.min(1e3*2**e,15e3)}function Dy(){let{t:e}=V(),{login:t,verifyTotp:n,finalizePasskeyLogin:r,user:i}=cu(),{i18n:a}=V(),s=yr(),c=J(),l=q(),u=new URLSearchParams(window.location.search).get(`next`);x(()=>{Vl(u)},[u]);let d=new URLSearchParams(window.location.search).get(`redirect`);x(()=>{Xl(d)},[d]);let p=Ty();x(()=>{Fl(p)},[p?.codeChallenge,p?.state,p?.purpose]);let m=l.state,h=ev(m?.from),[g,_]=C(``),[v,y]=C(``),[S,w]=C(!1),[T,E]=C(``),[D,O]=C(!1),[k,A]=C(`credentials`),[j,M]=C(``),[N,F]=C([]),[I,ee]=C(``),[te,L]=C(void 0),[ne,re]=C(`sso-not-linked`),ae=$r.auth.listLoginMethods.useQuery(void 0,{retry:!0,retryDelay:Ey}),oe=ae.data===void 0,se=(ae.data??[]).filter(e=>e.kind!==`device-certificate`),R=$r.auth.getServerName.useQuery().data,ce=se.filter(e=>e.stage===`primary`),le=ny(se);x(()=>{let e=Fg(window.location.hash);if(e!==null){if(window.history.replaceState({},``,window.location.pathname+window.location.search),e.kind===`challenge`){M(e.challengeToken),F(e.factors),ee(``),A(`second-factor`);return}re(e.code),L(e.provider)}},[]);let ue=te==null?null:se.find(e=>e.id===te&&`label`in e)?.label??null,de=T||(te===void 0?``:Ig(ne,ue)),{passkeyMethods:fe,widgetMethods:pe}=le,me=f(!1),he=async()=>{if(me.current)return;me.current=!0;let e=Rl(d);if(e?.kind===`app-callback`){await ve(e.url);return}else if(e){window.location.assign(z(e.path));return}let t=Ul(u);t?window.location.assign(z(t)):c(h,{replace:!0})},[ge,_e]=C(null),ve=async e=>{_e({callbackBase:e,mintedUrl:null,failed:!1});try{let t=Ty()??Il();if(t===null)throw Error(`The app sent no PKCE challenge and state`);let{code:n}=await Z().trpcClient.auth.createHandoffCode.mutate({purpose:t.purpose,codeChallenge:t.codeChallenge,state:t.state}),r=Ll(e,n,t.state);_e({callbackBase:e,mintedUrl:r,failed:!1}),window.location.assign(r)}catch(t){if(wy(t)){me.current=!1,_e(null),E(`Sign in again to confirm it is you.`);return}_e({callbackBase:e,mintedUrl:null,failed:!0})}},ye=i!==null,[be,Se]=C(!1);x(()=>{!ye||!d&&!u||be||(Se(!0),he())},[ye,d,u,be]);let Ce=async e=>{e.preventDefault(),E(``),L(void 0),O(!0);try{let e=await t(g,v);if(e.kind===`second-factor`){M(e.challengeToken),F(e.factors),A(`second-factor`);return}v===`changeme`?c(`/change-password`,{replace:!0}):await he()}catch(e){E(e instanceof Error?e.message:`Login failed`)}finally{O(!1)}},we=async e=>{e.preventDefault(),E(``),O(!0);try{await n(j,I.trim()),await he()}catch(e){E(e instanceof Error?e.message:`TOTP verification failed`),ee(``)}finally{O(!1)}},Te=async(e,t)=>{try{await r(e,t),await he()}catch(e){E(e instanceof Error?e.message:`Passkey sign-in failed`)}},De=f(null);x(()=>()=>De.current?.(),[]);let Oe=async e=>{if(e.target!==`login`)return;let t=_l(new URLSearchParams(e.fragment));if(t!==null){try{await r(t.token,t),await he()}catch(e){E(e instanceof Error?e.message:`Sign-in failed`)}return}let n=Fg(`#${e.fragment}`);if(n!==null){if(n.kind===`challenge`){Ae({challengeToken:n.challengeToken,factors:n.factors});return}re(n.code),L(n.provider)}},ke=e=>{if(kl(d)?.kind===`app-callback`)return!1;let t=Yg(z(qg(e.startUrl)));return t===null?!1:(E(``),L(void 0),De.current?.(),De.current=s_(t,{onReturn:e=>{De.current?.(),De.current=null,Oe(e)},onDone:e=>{if(De.current?.(),De.current=null,e.target!==`login`)return;let t=xy()===null?null:ml();t!==null&&Oe({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)},Ae=e=>{let t=e.factors.filter(e=>e===`totp`||e===`passkey`);M(e.challengeToken),F(t),ee(``),E(``),A(`second-factor`)};return ge===null?b(`div`,{className:`flex min-h-screen items-center justify-center bg-background p-4`,children:o(`div`,{className:`w-full max-w-sm`,children:[b(`div`,{className:`flex justify-center mb-8`,children:b(`img`,{src:s?.resolvedMode===`light`?z(`/brand/logo-horizontal-light.svg`):z(`/brand/logo-horizontal-dark.svg`),alt:e(`login.camstackAdmin`,`CamStack Admin`),className:`h-12`})}),R!==void 0&&!R.isDefault&&b(`p`,{"data-testid":`login-server-name`,className:`-mt-4 mb-6 text-center text-sm text-foreground-muted`,children:b(rc,{i18nKey:`login.signInTo`,values:{name:R.name},components:{b:b(`span`,{className:`font-semibold text-foreground`})}})}),k===`credentials`?o(`form`,{onSubmit:Ce,className:`space-y-4 rounded-xl border border-border bg-surface p-6 shadow-xl shadow-black/10`,children:[de&&b(`div`,{"data-testid":`login-error`,className:`rounded-md bg-danger/10 border border-danger/20 px-3 py-2 text-xs text-danger`,children:de}),o(`div`,{className:`space-y-1.5`,children:[b(`label`,{className:`text-xs font-medium text-foreground-subtle`,children:e(`login.username`,`Username`)}),b(`input`,{"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})]}),o(`div`,{className:`space-y-1.5`,children:[b(`label`,{className:`text-xs font-medium text-foreground-subtle`,children:e(`login.password`,`Password`)}),o(`div`,{className:`relative`,children:[b(`input`,{"data-testid":`login-password`,type:S?`text`:`password`,placeholder:e(`login.password`,`Password`),value:v,onChange:e=>y(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`}),b(`button`,{type:`button`,onClick:()=>w(!S),className:`absolute right-2.5 top-1/2 -translate-y-1/2 text-foreground-subtle hover:text-foreground transition-colors`,tabIndex:-1,children:b(S?ie:xe,{className:`h-4 w-4`})})]})]}),b(`button`,{"data-testid":`login-submit`,type:`submit`,disabled:D||!g||!v,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?o(`span`,{className:`flex items-center justify-center gap-2`,children:[b(`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`)})]}):o(`div`,{className:`space-y-4 rounded-xl border border-border bg-surface p-6 shadow-xl shadow-black/10`,children:[o(`div`,{className:`flex items-center gap-2 pb-1 border-b border-border`,children:[b(Ee,{className:`h-4 w-4 text-primary`}),b(`div`,{className:`text-sm font-medium text-foreground`,children:e(`login.twoFactorAuthentication`,`Two-factor authentication`)})]}),b(`p`,{className:`text-xs text-foreground-subtle`,children:g?b(P,{children:b(rc,{i18nKey:`login.finishSigningInAs`,values:{username:g},components:{mono:b(`span`,{className:`font-mono text-foreground`})}})}):e(`login.finishSigningInAs`,`Finish signing in.`)}),T&&b(`div`,{className:`rounded-md bg-danger/10 border border-danger/20 px-3 py-2 text-xs text-danger`,children:T}),N.includes(`passkey`)&&fe.map(e=>b($v,{method:e,challengeToken:j,onComplete:Te},e.id)),N.includes(`passkey`)&&pe.map(e=>b(oy,{method:e,config:{challengeToken:j,onComplete:Te}},e.id)),ry(N,le)&&b(`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.`)}),N.includes(`passkey`)&&N.includes(`totp`)&&o(`div`,{className:`flex items-center gap-3`,children:[b(`div`,{className:`h-px flex-1 bg-border`}),b(`span`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle`,children:`or`}),b(`div`,{className:`h-px flex-1 bg-border`})]}),N.includes(`totp`)&&o(`form`,{onSubmit:we,className:`space-y-4`,children:[o(`div`,{className:`space-y-1.5`,children:[b(`label`,{className:`text-xs font-medium text-foreground-subtle`,children:e(`login.authenticationCode`,`Authentication code`)}),b(`input`,{"data-testid":`login-totp`,type:`text`,inputMode:`numeric`,autoComplete:`one-time-code`,placeholder:`123456`,value:I,onChange:e=>ee(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})]}),b(`button`,{"data-testid":`login-totp-submit`,type:`submit`,disabled:D||I.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?o(`span`,{className:`flex items-center justify-center gap-2`,children:[b(`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`)})]}),o(`button`,{type:`button`,onClick:()=>{A(`credentials`),M(``),F([]),ee(``),E(``)},className:`w-full flex items-center justify-center gap-1.5 text-xs text-foreground-subtle hover:text-foreground transition-colors`,children:[b(Ue,{className:`h-3 w-3`}),e(`login.backToUsernamePassword`,`Back to username + password`)]})]}),k===`credentials`&&oe&&o(`p`,{"data-testid":`login-methods-pending`,role:`status`,className:`mt-4 flex items-center justify-center gap-2 text-xs text-foreground-subtle`,children:[b(`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`&&b(ay,{methods:ce,widgetConfig:{onComplete:Te,onSecondFactor:Ae,locale:a.language},onRedirect:ke}),b(`p`,{className:`mt-6 text-center text-[10px] text-foreground-subtle/50`,children:b(sv,{placement:`login`})})]})}):b(`div`,{className:`flex min-h-screen items-center justify-center bg-background p-4`,children:o(`div`,{className:`w-full max-w-sm rounded-xl border border-border bg-surface p-6 text-center space-y-4`,children:[b(`h1`,{className:`text-sm font-semibold text-foreground`,children:e(`login.returningToTheApp`,`Returning to the app…`)}),ge.failed?o(P,{children:[b(`p`,{className:`text-xs text-danger`,children:e(`login.couldNotPrepareTheSign`,`Could not prepare the sign-in handoff. You are logged in — retry below.`)}),b(`button`,{onClick:()=>void ve(ge.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`)})]}):ge.mintedUrl===null?b(`p`,{className:`text-xs text-foreground-subtle`,children:e(`login.preparingAOneTimeSign`,`Preparing a one-time sign-in code…`)}):o(P,{children:[b(`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).`)}),b(`a`,{href:ge.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.openCamstack`,`Open CamStack`)})]})]})})}D();function Oy(){let{pathname:e,search:t,hash:n}=q();return b(Y,{to:`${Av(e)}${t}${n}`,replace:!0})}function ky(){return b(Y,{to:Q_()??`/devices`,replace:!0})}var Ay=h(()=>i(()=>import(`./Devices-BXmHX1Iz.js`).then(e=>({default:e.DevicesPage})),__vite__mapDeps([0,1,2,3,4,5,6,7,8]),import.meta.url)),jy=h(()=>i(()=>import(`./Integrations-CKTnFV7-.js`).then(e=>({default:e.IntegrationsPage})),__vite__mapDeps([9,1,2,3,4,10,5,11,6,12,13,14,15,7,8,16]),import.meta.url)),My=h(()=>i(()=>import(`./IntegrationDetail-CsQJqy0O.js`).then(e=>({default:e.IntegrationDetailPage})),__vite__mapDeps([17,1,2,3,4,18,5,12,13,10,14,15,19,7,20]),import.meta.url)),Ny=h(()=>i(()=>import(`./Pipeline-C3zZKn-f.js`).then(e=>({default:e.PipelinePage})),__vite__mapDeps([21,1,2,3,4,10,5,22,23,24,25,19,26,27,8]),import.meta.url)),Py=h(()=>i(()=>import(`./DeviceDetail-CWaYy5st.js`).then(e=>({default:e.DeviceDetailPage})),__vite__mapDeps([28,1,2,3,4,10,5,29,30,31,32,33,22,34,35,25,36,37,38,39,40,41,26,42,8,43,15,44]),import.meta.url)),Fy=h(()=>i(()=>import(`./Showroom-Cyf_5WTf.js`).then(e=>({default:e.ShowroomPage})),__vite__mapDeps([45,1,2,3,4]),import.meta.url)),Iy=h(()=>i(()=>import(`./EmbedPlayerPage-C0JL6O13.js`).then(e=>({default:e.EmbedPlayerPage})),__vite__mapDeps([46,1,2,3,4,5]),import.meta.url)),Ly=h(()=>i(()=>import(`./Library-Cnom4jTv.js`).then(e=>({default:e.LibraryPage})),__vite__mapDeps([47,1,2,3,4,10,5,48,22,24,49,50,39,51,43,15]),import.meta.url)),Ry=h(()=>i(()=>import(`./Recordings-DT5kHAwS.js`).then(e=>({default:e.RecordingsPage})),__vite__mapDeps([52,1,2,3,4,10,5,53,50,54,29,55,56,57,43,15]),import.meta.url)),zy=h(()=>i(()=>import(`./Viewer-BFtLOgb5.js`).then(e=>({default:e.ViewerPage})),__vite__mapDeps([58,2,3,4,59,5,15,1]),import.meta.url)),By=h(()=>i(()=>import(`./Build-CsuCOGY2.js`).then(e=>({default:e.BuildPage})),__vite__mapDeps([60,1,2,3,4,10,5,33,61,22,50,62,36,32,37,38,40,44]),import.meta.url)),Vy=h(()=>i(()=>import(`./CompositionEditorPage-CKCgT4Sc.js`).then(e=>({default:e.CompositionEditorPage})),__vite__mapDeps([63,1,2,3,4,33,5,6,62,36,10,32,37,38]),import.meta.url)),Hy=h(()=>i(()=>import(`./Locations-RMAhldT5.js`).then(e=>({default:e.LocationsPage})),__vite__mapDeps([64,1,2,3,4,10,5,33,65,49,50,41,37,38]),import.meta.url)),Uy=h(()=>i(()=>import(`./Addons-DsbbYUDT.js`).then(e=>({default:e.AddonsPage})),__vite__mapDeps([66,1,2,3,4,22,5,6,19,67,16,15]),import.meta.url)),Wy=h(()=>i(()=>import(`./AiProfiles-sNt-u_by.js`).then(e=>({default:e.AiProfilesPage})),__vite__mapDeps([68,1,2,3,4,10,5,69,70,6,50,15]),import.meta.url)),Gy=h(()=>i(()=>import(`./MyAccess-ChjuVjHq.js`).then(e=>({default:e.MyAccessPage})),__vite__mapDeps([71,1,2,3,4,10,5,22,72,73,74,75,6,50,76,15]),import.meta.url)),Ky=h(()=>i(()=>import(`./Logs-YZGGdk7a.js`).then(e=>({default:e.LogsPage})),__vite__mapDeps([77,1,2,3,4,78,25,5,6,50,79,80,19,81,20,15,82]),import.meta.url)),qy=h(()=>i(()=>import(`./Identity-Cp5m445y.js`).then(e=>({default:e.IdentityPage})),__vite__mapDeps([83,1,2,3,4,10,5,84,22,35,72,73,75,6,50,79,80,19,81,20,15,76,82]),import.meta.url)),Jy=h(()=>i(()=>import(`./Network-ByvZRKWM.js`).then(e=>({default:e.NetworkPage})),__vite__mapDeps([85,1,2,3,4,10,5,33,22,14,6,50,79,80,19,81,20,15,82]),import.meta.url)),Yy=h(()=>i(()=>import(`./Integrations-Wb3Nvqvk.js`).then(e=>({default:e.IntegrationsPage})),__vite__mapDeps([86,1,2,3,4,10,5,22,14,73,87,50,79,80,6,19,81,20,15,13]),import.meta.url)),Xy=h(()=>i(()=>import(`./Data-CKbI6H28.js`).then(e=>({default:e.DataPage})),__vite__mapDeps([88,1,2,3,4,10,5,89,34,56,6,50,54,29,55,57,43,15]),import.meta.url)),Zy=h(()=>i(()=>import(`./System-B47qVCVK.js`).then(e=>({default:e.SystemPage})),__vite__mapDeps([90,1,2,3,4,10,5,22,72,6,50,19,81,20,15]),import.meta.url)),Qy=h(()=>i(()=>import(`./Cluster-CWoYZoPu.js`).then(e=>({default:e.ClusterPage})),__vite__mapDeps([91,1,2,3,4,10,5,56,92,75,6,19,27,67,57]),import.meta.url)),$y=h(()=>i(()=>import(`./Terminal-RLflxok5.js`).then(e=>({default:e.TerminalPage})),__vite__mapDeps([93,1,2,3,4,22,5,6,19,94]),import.meta.url)),eb=h(()=>i(()=>import(`./Notifications-WK1xVjAV.js`).then(e=>({default:e.NotificationsPage})),__vite__mapDeps([95,1,2,3,4,10,5,31,22,69,96,6,50,40,51,15,38]),import.meta.url)),tb=h(()=>i(()=>import(`./History-B2COiYTg.js`).then(e=>({default:e.HistoryPage})),__vite__mapDeps([97,1,2,3,4,5,6]),import.meta.url)),nb=h(()=>i(()=>import(`./Calendars-6W4Ardeb.js`).then(e=>({default:e.CalendarsPage})),__vite__mapDeps([98,1,2,3,4,10,5,22,6]),import.meta.url)),rb=h(()=>i(()=>import(`./Templates-lCo5yN4g.js`).then(e=>({default:e.TemplatesPage})),__vite__mapDeps([99,1,2,3,4,22,100,5,6,42]),import.meta.url)),ib=new E({defaultOptions:{queries:{gcTime:0,staleTime:0,retry:!1,refetchOnWindowFocus:!1}}});Yr(ib);function ab({field:e,value:t,onChange:n,disabled:r}){return b(Im,{field:e,value:t,onChange:n,disabled:r})}var ob={"model-selector":ab};function sb({children:e}){let{t}=V(),{user:n,logout:r}=cu(),[i,a]=C(0),s=f(n?.username??null);x(()=>{let e=n?.username??null;e!==s.current&&(s.current=e,cl(),a(e=>e+1))},[n]);let c=p(()=>Z(),[i]),l=y(()=>{Z().reconnect(),a(e=>e+1),ib.invalidateQueries()},[]);ah(y(()=>El(l),[l])),x(()=>Sl(()=>{Z().isSocketTokenStale()&&l()}),[l]);let u=y(async()=>{let e=await Dl();return e&&l(),e},[l]),{bootReady:d,bootError:m}=rh(c,n??null,r,u);return b(eh,{children:b(He,{system:c,children:b($r.Provider,{client:c.trpcClient,queryClient:ib,children:o(Kr,{children:[b(ar,{children:b(Lr,{children:b(sr,{children:d?e:b(cb,{})})})}),d&&b(Hm,{}),m!==null&&d&&o(`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 cb(){let{t:e}=V();return b(`div`,{className:`flex min-h-screen items-center justify-center bg-background`,children:o(`div`,{className:`flex items-center gap-3 text-sm text-foreground-subtle`,children:[b(`span`,{className:`h-4 w-4 animate-spin rounded-full border-2 border-primary/30 border-t-primary`}),e(`app.connecting`,`Connecting…`)]})})}function lb(){return b(`div`,{className:`flex min-h-screen items-center justify-center bg-background`,children:b(`span`,{className:`h-4 w-4 animate-spin rounded-full border-2 border-primary/30 border-t-primary`})})}function ub(){return b(Rr,{defaultMode:`dark`,children:b(rr,{children:b(N,{client:ib,children:b(su,{children:b(sb,{children:b(Le,{children:b(Vm,{children:o(ei,{renderers:ob,children:[b(ps,{basename:Ye(),children:b(Am,{children:b(v,{fallback:b(lb,{}),children:o(wo,{children:[b(X,{path:`/login`,element:b(Dy,{})}),b(X,{path:`/admin/*`,element:b(Oy,{})}),b(X,{path:`/admin`,element:b(Oy,{})}),b(X,{path:`/change-password`,element:b($,{children:b(Lv,{})})}),b(X,{path:`/showroom`,element:b(Fy,{})}),b(X,{path:`/embed/player`,element:b(Iy,{})}),o(X,{element:b($,{children:b(Oi,{children:b(mv,{})})}),children:[b(X,{index:!0,element:b(ky,{})}),b(X,{path:`/access-denied`,element:b(jv,{})}),b(X,{path:`/dashboard`,element:b(Y,{to:`/devices`,replace:!0})}),b(X,{path:`/devices`,element:b(Ay,{})}),b(X,{path:`/cameras`,element:b(Y,{to:`/devices`,replace:!0})}),b(X,{path:`/integrations`,element:b(jy,{})}),b(X,{path:`/integrations/:addonId`,element:b(My,{})}),b(X,{path:`/system/pipeline`,element:b(Dh,{path:`/system/pipeline`,children:b(Ny,{})})}),b(X,{path:`/pipeline`,element:b(Y,{to:`/system/pipeline`,replace:!0})}),b(X,{path:`/live`,element:b(zy,{})}),b(X,{path:`/devices/:deviceId`,element:b(Py,{})}),b(X,{path:`/system/logs`,element:b($,{requireAdmin:!0,children:b(Ky,{})})}),b(X,{path:`/system/addons`,element:b($,{requireAdmin:!0,children:b(Uy,{})})}),b(X,{path:`/system/ai`,element:b($,{requireAdmin:!0,children:b(Wy,{})})}),b(X,{path:`/system/settings`,element:b($,{requireAdmin:!0,children:b(Zy,{})})}),b(X,{path:`/system/nodes`,element:b($,{requireAdmin:!0,children:b(Qy,{})})}),b(X,{path:`/system/notifications`,element:b($,{requireAdmin:!0,children:b(eb,{})})}),b(X,{path:`/system/history`,element:b($,{requireAdmin:!0,children:b(tb,{})})}),b(X,{path:`/system/calendars`,element:b($,{requireAdmin:!0,children:b(nb,{})})}),b(X,{path:`/system/templates`,element:b($,{requireAdmin:!0,children:b(rb,{})})}),b(X,{path:`/system/identity`,element:b($,{requireAdmin:!0,children:b(qy,{})})}),b(X,{path:`/system/my-access`,element:b(Gy,{})}),b(X,{path:`/system/network`,element:b($,{requireAdmin:!0,children:b(Jy,{})})}),b(X,{path:`/system/integrations`,element:b($,{requireAdmin:!0,children:b(Yy,{})})}),b(X,{path:`/system/data`,element:b($,{requireAdmin:!0,children:b(Xy,{})})}),b(X,{path:`/system`,element:b(Y,{to:Gm,replace:!0})}),b(X,{path:`/system/terminal`,element:b($,{requireAdmin:!0,children:b($y,{})})}),Km.map(e=>b(X,{path:e.path,element:b(Jm,{tab:e.tab})},e.path)),b(X,{path:`/system/users`,element:b(Y,{to:`/system/identity?tab=users`,replace:!0})}),b(X,{path:`/system/api-keys`,element:b(Y,{to:`/system/identity?tab=api-keys`,replace:!0})}),b(X,{path:`/system/authentication`,element:b(Y,{to:Dv(`authentication`),replace:!0})}),b(X,{path:`/system/linked-sessions`,element:b(Y,{to:`/system/identity?tab=linked-sessions`,replace:!0})}),b(X,{path:`/system/remote-access`,element:b(Y,{to:Dv(`remoteAccess`),replace:!0})}),b(X,{path:`/system/turn`,element:b(Y,{to:Dv(`turn`),replace:!0})}),b(X,{path:`/system/storage`,element:b(Y,{to:`/system/data?tab=storage`,replace:!0})}),b(X,{path:`/system/backup`,element:b(Y,{to:`/system/data?tab=backup`,replace:!0})}),b(X,{path:`/library`,element:b($,{requireAdmin:!0,children:b(Ly,{})})}),b(X,{path:`/retrain`,element:b(Y,{to:`/addon/training`,replace:!0})}),b(X,{path:`/recordings`,element:b($,{requireAdmin:!0,children:b(Ry,{})})}),b(X,{path:`/build`,element:b($,{requireAdmin:!0,children:b(By,{})})}),b(X,{path:gv,element:b($,{requireAdmin:!0,children:b(Vy,{})})}),b(X,{path:_v,element:b($,{requireAdmin:!0,children:b(Vy,{})})}),b(X,{path:`/locations`,element:b($,{requireAdmin:!0,children:b(Hy,{})})}),b(X,{path:`/automation`,element:b(Lm,{to:`/build`})}),b(X,{path:`/addon/:pagePath`,element:b($,{requireAdmin:!0,children:b(yh,{})})}),b(X,{path:`*`,element:b(Y,{to:`/devices`,replace:!0})})]})]})})})}),b(Zm,{})]})})})})})})})})}D(),window.__camstackUiLibrary=Br,window.__camstackSdk=ni,window.__camstackTypes=Qt;var db=_i(document.getElementById(`root`));p_(window.location.pathname,Ye())?Sy(db):db.render(b(w,{children:b(ub,{})}));export{Sp as $,Su as $n,Od as $t,pm as A,Zu as An,ef as At,kp as B,xu as Bn,Qd as Bt,$h as C,Vu as Cn,xf as Ct,Gm as D,_d as Dn,jf as Dt,$m as E,ad as En,Ef as Et,tm as F,ld as Fn,lf as Ft,op as G,mu as Gn,Kd as Gt,jp as H,du as Hn,Yd as Ht,em as I,Ru as In,af as It,ap as J,yu as Jn,Hd as Jt,bp as K,bu as Kn,Rd as Kt,$p as L,ju as Ln,Ud as Lt,im as M,zu as Mn,of as Mt,am as N,rd as Nn,sf as Nt,Bm as O,Yu as On,uf as Ot,sm as P,td as Pn,cf as Pt,yp as Q,fu as Qn,Vd as Qt,Lp as R,ku as Rn,Zd as Rt,Zh as S,hd as Sn,wf as St,Th as T,Wu as Tn,pf as Tt,vp as U,Cu as Un,qd as Ut,Ap as V,gu as Vn,Gd as Vt,up as W,pu as Wn,Jd as Wt,lp as X,vu as Xn,Fd as Xt,ip as Y,wu as Yn,zd as Yt,gp as Z,hu as Zn,Bd as Zt,Yg as _,od as _n,J as _r,bf as _t,wv as a,id as an,Bc as ar,$f as at,Rg as b,Fu as bn,gf as bt,Tv as c,qu as cn,xc as cr,Yf as ct,kv as d,ed as dn,hc as dr,Hf as dt,jd as en,Eu as er,sp as et,vv as f,nd as fn,lc as fr,df as ft,b_ as g,cd as gn,q as gr,Sf as gt,yv as h,Hu as hn,Y as hr,If as ht,Cv as i,Nd as in,Vc as ir,Qf as it,dm as j,Lu as jn,rf as jt,Om as k,$u as kn,$d as kt,Dv as l,Xu as ln,_c as lr,Jf as lt,bv as m,md as mn,hs as mr,Af as mt,Yv as n,Sd as nn,uu as nr,fp as nt,xv as o,gd as on,Ec as or,tp as ot,hv as p,sd as pn,rc as pr,ff as pt,pp as q,_u as qn,kd as qt,Ev as r,Md as rn,cu as rr,ep as rt,Sv as s,Qu as sn,vc as sr,Zf as st,Zv as t,wd as tn,Tu as tr,cp as tt,Ov as u,Nu as un,gc as ur,qf as ut,s_ as v,ud as vn,Qa as vr,_f as vt,Qh as w,Uu as wn,Cf as wt,yg as x,Iu as xn,Df as xt,qg as y,Ju as yn,Cs as yr,Of as yt,Cp as z,Du as zn,Xd as zt};