@xenon-device-management/xenon 2.12.0 → 2.13.0

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 (140) hide show
  1. package/lib/package.json +2 -2
  2. package/lib/public/assets/{AnnotationOverlay-Crkn72_3.js → AnnotationOverlay-CzbFYtPI.js} +1 -1
  3. package/lib/public/assets/{ApiKeyGate-BThVlj_j.js → ApiKeyGate-CA5KFHHJ.js} +1 -1
  4. package/lib/public/assets/{BugReportButton-Dwa0GnBh.js → BugReportButton-D-DSGg8C.js} +1 -1
  5. package/lib/public/assets/{DeviceMosaicView-Ccc-pOls.js → DeviceMosaicView-paDEFU4B.js} +1 -1
  6. package/lib/public/assets/{EmptyState-BeuTrlN_.js → EmptyState-BE_5f8Vw.js} +1 -1
  7. package/lib/public/assets/{FieldGroup-DBIaNxl1.js → FieldGroup-DqMf7Rf3.js} +1 -1
  8. package/lib/public/assets/{FilterMenu-BgSAS6iT.js → FilterMenu-BQY75Su3.js} +1 -1
  9. package/lib/public/assets/{Menu-GCbP6gYN.js → Menu-BiW3os9u.js} +1 -1
  10. package/lib/public/assets/{Modal-ByESeBRC.js → Modal-DfawTxih.js} +1 -1
  11. package/lib/public/assets/{RecordingPage-Bwyf3WMl.js → RecordingPage-BvemyRiy.js} +1 -1
  12. package/lib/public/assets/{RecordingsPage-7kM1rB3i.js → RecordingsPage-CXfw7wpd.js} +1 -1
  13. package/lib/public/assets/{SegmentedControl-B8tTU8kD.js → SegmentedControl-B7m9kpom.js} +1 -1
  14. package/lib/public/assets/{SettingCard-Clg_Ijbc.js → SettingCard-Cw6lDD0l.js} +1 -1
  15. package/lib/public/assets/{Table-CIaR0QWV.js → Table-DlEuFgv-.js} +1 -1
  16. package/lib/public/assets/{activity-Bengh9SD.js → activity-CnLvNwae.js} +1 -1
  17. package/lib/public/assets/{ai-settings-G9SymiPH.js → ai-settings-D7Te8o-a.js} +1 -1
  18. package/lib/public/assets/{api-keys-CrGlbfn-.js → api-keys-DphSVzBr.js} +1 -1
  19. package/lib/public/assets/{apps-DIbcGVlU.js → apps-vUfu15lX.js} +1 -1
  20. package/lib/public/assets/{arrow-left-BtJIXXMY.js → arrow-left-CLQWAiCY.js} +1 -1
  21. package/lib/public/assets/{arrow-right-zm-NagQh.js → arrow-right-K6A5e_Ee.js} +1 -1
  22. package/lib/public/assets/{arrow-up-right-DdU8YEYp.js → arrow-up-right-DUA_lq6f.js} +1 -1
  23. package/lib/public/assets/{auth-shell-CHmBFmOz.js → auth-shell-BYRHcZd6.js} +2 -2
  24. package/lib/public/assets/{builds-page-JkzWKRpU.js → builds-page-C0fTvIG8.js} +1 -1
  25. package/lib/public/assets/{button-CqhPBGRj.js → button-BxnHCCsX.js} +1 -1
  26. package/lib/public/assets/{calendar-C7eYYJTo.js → calendar-CqVsn28A.js} +1 -1
  27. package/lib/public/assets/{check-DpbIM4E0.js → check-R6V3bot0.js} +1 -1
  28. package/lib/public/assets/{chevron-right-Dl4X1PRz.js → chevron-right-BA2Fntu-.js} +1 -1
  29. package/lib/public/assets/{circle-check-Du3sjbfV.js → circle-check-D4EzyGzs.js} +1 -1
  30. package/lib/public/assets/{circle-x-BSSqhpXi.js → circle-x-Cf6AF2B2.js} +1 -1
  31. package/lib/public/assets/{clock-DMT60v1C.js → clock-EZfet0sS.js} +1 -1
  32. package/lib/public/assets/{copy-BKNyOehd.js → copy-Bc6P8v9V.js} +1 -1
  33. package/lib/public/assets/{device-explorer-CoPR8DW3.js → device-explorer-BFXpRq6d.js} +1 -1
  34. package/lib/public/assets/{download-BM6Xn22t.js → download-Bd8OGLzi.js} +1 -1
  35. package/lib/public/assets/{forgot-password-B8WqMqBT.js → forgot-password-CoE7Ugtx.js} +1 -1
  36. package/lib/public/assets/{index-DauQh6ie.js → index-BiL0Enl_.js} +1 -1
  37. package/lib/public/assets/{index-ClrpAMAT.js → index-CHOr4JCs.js} +2 -2
  38. package/lib/public/assets/{input-CyKdLnEx.js → input-CJ8z3IO5.js} +1 -1
  39. package/lib/public/assets/{line-chart-EIBXwYGo.js → line-chart-CPK0ObjV.js} +1 -1
  40. package/lib/public/assets/{list-checks-fWsgD9bI.js → list-checks-mXGHUVbB.js} +1 -1
  41. package/lib/public/assets/{lock-CVCe56TH.js → lock-BSXM1xvq.js} +1 -1
  42. package/lib/public/assets/{login-BJ8a7yVD.js → login-Ct2iW066.js} +1 -1
  43. package/lib/public/assets/{maintenance-settings-DcRmTLS6.js → maintenance-settings-DaOs00P6.js} +1 -1
  44. package/lib/public/assets/{monitor-Bw1YQZnL.js → monitor-D8WQK8md.js} +1 -1
  45. package/lib/public/assets/{mouse-pointer-2-C01jbqkO.js → mouse-pointer-2-Cw2tWzDX.js} +1 -1
  46. package/lib/public/assets/{network-CBGUjJDJ.js → network-Ba_uFxWo.js} +1 -1
  47. package/lib/public/assets/{overview-Cxe8aQ7C.js → overview-CxrZ7_6k.js} +1 -1
  48. package/lib/public/assets/{page-header-B92DKLiq.js → page-header-Cm1XL49f.js} +1 -1
  49. package/lib/public/assets/{play-Ck0L-0_m.js → play-C0CuKLXj.js} +1 -1
  50. package/lib/public/assets/{plus-Dq3tCy2N.js → plus-CIIvR_6Z.js} +1 -1
  51. package/lib/public/assets/{profile-page--dkDiKbr.js → profile-page-BZ_e-Bgw.js} +1 -1
  52. package/lib/public/assets/{recording-group-store-5BYIFFN9.js → recording-group-store-BWeeNs2_.js} +1 -1
  53. package/lib/public/assets/{reset-password-KYWlfjia.js → reset-password-lfNz8Rm1.js} +1 -1
  54. package/lib/public/assets/{runbook-page-mnsxgS1d.js → runbook-page-Cnec3VSx.js} +1 -1
  55. package/lib/public/assets/{select-BBOIZTYm.js → select-CZuCnold.js} +1 -1
  56. package/lib/public/assets/{selector-detail-redirect-CcI2j_Su.js → selector-detail-redirect-BG3pxFLw.js} +1 -1
  57. package/lib/public/assets/{selector-health-page-BdJb_x5L.js → selector-health-page-DsyL58tb.js} +1 -1
  58. package/lib/public/assets/{session-detail-page-BjLaJy8z.js → session-detail-page-ZZyGM413.js} +1 -1
  59. package/lib/public/assets/{settings-B6cpMhsx.js → settings-DGZ7B_AR.js} +1 -1
  60. package/lib/public/assets/{stat-tile-BU9e4s36.js → stat-tile-DFhv8JoI.js} +1 -1
  61. package/lib/public/assets/{tablet-hgbEwrWq.js → tablet-68J5f6zh.js} +1 -1
  62. package/lib/public/assets/{teams-uiiG4hZM.js → teams-eHSyEpbD.js} +1 -1
  63. package/lib/public/assets/{trash-2-NK_Iazmg.js → trash-2-CcSsv4fS.js} +1 -1
  64. package/lib/public/assets/{upload-BUX8TNFi.js → upload-BYf26K71.js} +1 -1
  65. package/lib/public/assets/{use-builds-data-DZszmFyl.js → use-builds-data-CHW-MhaP.js} +1 -1
  66. package/lib/public/assets/{use-password-reset-mode-BK4B9kRC.js → use-password-reset-mode-DozShXkk.js} +1 -1
  67. package/lib/public/assets/{users-BU4XBbMT.js → users-BpYnpOl2.js} +1 -1
  68. package/lib/public/assets/{users-BDh1xjad.js → users-CcSQRoK9.js} +1 -1
  69. package/lib/public/assets/{video-off-BOjNwT4R.js → video-off-dFKgps73.js} +1 -1
  70. package/lib/public/assets/{webhook-settings-BMzyUcx5.js → webhook-settings-DD1XjiOD.js} +1 -1
  71. package/lib/public/assets/{zap-DTWwVMUg.js → zap-COC2tZaH.js} +1 -1
  72. package/lib/public/index.html +1 -1
  73. package/lib/src/app/apiErrors.js +118 -0
  74. package/lib/src/app/index.js +6 -1
  75. package/lib/src/app/openapi/control.yaml +3129 -0
  76. package/lib/src/app/openapi/grid.yaml +2295 -0
  77. package/lib/src/app/openapi/identity.yaml +2168 -0
  78. package/lib/src/app/openapi/platform.yaml +2885 -0
  79. package/lib/src/app/openapi/sessions.yaml +3784 -0
  80. package/lib/src/app/routers/bug-report.js +4 -1
  81. package/lib/src/app/routers/config.js +6 -107
  82. package/lib/src/app/routers/control.js +117 -59
  83. package/lib/src/app/routers/dashboard.js +13 -7
  84. package/lib/src/app/routers/grid.js +54 -14
  85. package/lib/src/app/routers/profile.js +27 -13
  86. package/lib/src/app/routers/recordings.js +11 -5
  87. package/lib/src/app/routers/reservation.js +63 -15
  88. package/lib/src/app/routers/users.js +4 -0
  89. package/lib/src/app/routers/webhook.js +17 -8
  90. package/lib/src/app/swagger.js +259 -177
  91. package/lib/src/data-service/device-service.js +4 -1
  92. package/lib/src/data-service/deviceFieldOwners.js +1 -0
  93. package/lib/src/device-managers/AndroidDeviceManager.js +5 -2
  94. package/lib/src/device-managers/ios/WDAClient.js +32 -32
  95. package/lib/src/generated/client/edge.js +4 -3
  96. package/lib/src/generated/client/index-browser.js +1 -0
  97. package/lib/src/generated/client/index.d.ts +38 -0
  98. package/lib/src/generated/client/index.js +4 -3
  99. package/lib/src/generated/client/package.json +1 -1
  100. package/lib/src/generated/client/schema.prisma +2 -0
  101. package/lib/src/generated/client/wasm.js +1 -0
  102. package/lib/src/middleware/csrfMiddleware.js +13 -5
  103. package/lib/src/middleware/rateLimitMiddleware.js +19 -5
  104. package/lib/src/middleware/roleGuard.js +20 -0
  105. package/lib/src/services/AIService.js +13 -3
  106. package/lib/src/services/NotificationService.js +28 -28
  107. package/lib/src/services/bug-report/BugReportService.js +8 -2
  108. package/lib/src/services/lease/LeaseService.js +71 -20
  109. package/lib/src/services/omni-vision/OmniVisionService.js +14 -5
  110. package/lib/src/services/recording/RecordingOrchestrator.js +16 -2
  111. package/lib/test/helpers/expressRoutes.js +41 -0
  112. package/lib/test/integration/team-visibility-control.spec.js +2 -2
  113. package/lib/test/unit/access-scopes.spec.js +227 -0
  114. package/lib/test/unit/api-error-handling.spec.js +179 -0
  115. package/lib/test/unit/bug-report/route.spec.js +29 -0
  116. package/lib/test/unit/bug-report/service.spec.js +30 -0
  117. package/lib/test/unit/control-honest-answers.spec.js +134 -0
  118. package/lib/test/unit/device-allocation-routes.spec.js +232 -0
  119. package/lib/test/unit/healing-state-endpoints.spec.js +8 -5
  120. package/lib/test/unit/install-repository-app-team.spec.js +4 -1
  121. package/lib/test/unit/lease/LeaseService.spec.js +5 -4
  122. package/lib/test/unit/lease/lease-device-match.spec.js +161 -0
  123. package/lib/test/unit/lease/lease-session-ownership.spec.js +10 -9
  124. package/lib/test/unit/omni-vision-failures.spec.js +81 -0
  125. package/lib/test/unit/openapi-coverage.spec.js +114 -0
  126. package/lib/test/unit/profile-router.test.js +42 -0
  127. package/lib/test/unit/rateLimitMiddleware.test.js +49 -0
  128. package/lib/test/unit/recording-orchestrator.spec.js +80 -0
  129. package/lib/test/unit/recordings-library-routes.spec.js +37 -0
  130. package/lib/test/unit/reservation-team-visibility.spec.js +4 -3
  131. package/lib/test/unit/reset-link.test.js +2 -1
  132. package/lib/test/unit/stream-ticket-identity.spec.js +1 -1
  133. package/lib/test/unit/users-router.test.js +14 -1
  134. package/lib/test/unit/wda-client-failures.spec.js +90 -0
  135. package/lib/test/unit/webhook-delivery.spec.js +142 -0
  136. package/lib/tsconfig.tsbuildinfo +1 -1
  137. package/package.json +2 -2
  138. package/prisma/migrations/20261004120000_reservation_holder/migration.sql +2 -0
  139. package/prisma/schema.prisma +2 -0
  140. package/lib/src/app/swagger-docs.js +0 -1701
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/overview-Cxe8aQ7C.js","assets/labels-C21SA4JG.js","assets/arrow-right-zm-NagQh.js","assets/tablet-hgbEwrWq.js","assets/monitor-Bw1YQZnL.js","assets/activity-Bengh9SD.js","assets/page-header-B92DKLiq.js","assets/page-header-TkpFo69t.css","assets/device-explorer-CoPR8DW3.js","assets/BugReportButton-Dwa0GnBh.js","assets/BugReportButton-CPBjfiv4.css","assets/recording-group-store-5BYIFFN9.js","assets/button-CqhPBGRj.js","assets/utils-CDN07tui.js","assets/button-yDi2prIR.css","assets/select-BBOIZTYm.js","assets/select-_gbV-uJG.css","assets/Menu-GCbP6gYN.js","assets/index-DauQh6ie.js","assets/check-DpbIM4E0.js","assets/Menu-BJJGF7ek.css","assets/Modal-ByESeBRC.js","assets/Modal-CkhpaXeX.css","assets/FieldGroup-DBIaNxl1.js","assets/FieldGroup-trY-2qmW.css","assets/clock-DMT60v1C.js","assets/plus-Dq3tCy2N.js","assets/copy-BKNyOehd.js","assets/SegmentedControl-B8tTU8kD.js","assets/SegmentedControl-lDNf6HQr.css","assets/Table-CIaR0QWV.js","assets/Table-BIjXN_-_.css","assets/list-checks-fWsgD9bI.js","assets/chevron-right-Dl4X1PRz.js","assets/mouse-pointer-2-C01jbqkO.js","assets/zap-DTWwVMUg.js","assets/circle-check-Du3sjbfV.js","assets/circle-x-BSSqhpXi.js","assets/EmptyState-BeuTrlN_.js","assets/EmptyState-BSDHFxd1.css","assets/input-CyKdLnEx.js","assets/input-B5edaXfx.css","assets/play-Ck0L-0_m.js","assets/download-BM6Xn22t.js","assets/upload-BUX8TNFi.js","assets/arrow-left-BtJIXXMY.js","assets/AnnotationOverlay-Crkn72_3.js","assets/trash-2-NK_Iazmg.js","assets/lock-CVCe56TH.js","assets/FilterMenu-BgSAS6iT.js","assets/FilterMenu-D1i9jhjZ.css","assets/device-explorer-CHv1miyr.css","assets/builds-page-JkzWKRpU.js","assets/use-builds-data-DZszmFyl.js","assets/time-D-gjmE1o.js","assets/stat-tile-BU9e4s36.js","assets/session-detail-page-BjLaJy8z.js","assets/arrow-up-right-DdU8YEYp.js","assets/line-chart-EIBXwYGo.js","assets/line-chart-Bzzc3bMl.css","assets/video-off-BOjNwT4R.js","assets/network-CBGUjJDJ.js","assets/runbook-page-mnsxgS1d.js","assets/runbook-page-BFqSC-Ta.css","assets/apps-DIbcGVlU.js","assets/apps-BQKfuN3J.css","assets/webhook-settings-BMzyUcx5.js","assets/webhook-settings-CAfLaykw.css","assets/settings-Dep_3kbA.css","assets/settings-B6cpMhsx.js","assets/SettingCard-Clg_Ijbc.js","assets/SettingCard-CiKM8yKg.css","assets/calendar-C7eYYJTo.js","assets/ai-settings-G9SymiPH.js","assets/maintenance-settings-DcRmTLS6.js","assets/api-keys-CrGlbfn-.js","assets/teams-uiiG4hZM.js","assets/users-BU4XBbMT.js","assets/selector-health-page-BdJb_x5L.js","assets/view-state-83Z1gFME.js","assets/selector-detail-redirect-CcI2j_Su.js","assets/DeviceMosaicView-Ccc-pOls.js","assets/recordings-BWe1ydXm.js","assets/profile-page--dkDiKbr.js","assets/users-BDh1xjad.js","assets/RecordingsPage-7kM1rB3i.js","assets/recordings-n-GTW3aT.js","assets/recordings-B2Am-bZy.css","assets/RecordingPage-Bwyf3WMl.js","assets/login-BJ8a7yVD.js","assets/use-password-reset-mode-BK4B9kRC.js","assets/auth-shell-CHmBFmOz.js","assets/forgot-password-B8WqMqBT.js","assets/reset-password-KYWlfjia.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/overview-CxrZ7_6k.js","assets/labels-C21SA4JG.js","assets/arrow-right-K6A5e_Ee.js","assets/tablet-68J5f6zh.js","assets/monitor-D8WQK8md.js","assets/activity-CnLvNwae.js","assets/page-header-Cm1XL49f.js","assets/page-header-TkpFo69t.css","assets/device-explorer-BFXpRq6d.js","assets/BugReportButton-D-DSGg8C.js","assets/BugReportButton-CPBjfiv4.css","assets/recording-group-store-BWeeNs2_.js","assets/button-BxnHCCsX.js","assets/utils-CDN07tui.js","assets/button-yDi2prIR.css","assets/select-CZuCnold.js","assets/select-_gbV-uJG.css","assets/Menu-BiW3os9u.js","assets/index-BiL0Enl_.js","assets/check-R6V3bot0.js","assets/Menu-BJJGF7ek.css","assets/Modal-DfawTxih.js","assets/Modal-CkhpaXeX.css","assets/FieldGroup-DqMf7Rf3.js","assets/FieldGroup-trY-2qmW.css","assets/clock-EZfet0sS.js","assets/plus-CIIvR_6Z.js","assets/copy-Bc6P8v9V.js","assets/SegmentedControl-B7m9kpom.js","assets/SegmentedControl-lDNf6HQr.css","assets/Table-DlEuFgv-.js","assets/Table-BIjXN_-_.css","assets/list-checks-mXGHUVbB.js","assets/chevron-right-BA2Fntu-.js","assets/mouse-pointer-2-Cw2tWzDX.js","assets/zap-COC2tZaH.js","assets/circle-check-D4EzyGzs.js","assets/circle-x-Cf6AF2B2.js","assets/EmptyState-BE_5f8Vw.js","assets/EmptyState-BSDHFxd1.css","assets/input-CJ8z3IO5.js","assets/input-B5edaXfx.css","assets/play-C0CuKLXj.js","assets/download-Bd8OGLzi.js","assets/upload-BYf26K71.js","assets/arrow-left-CLQWAiCY.js","assets/AnnotationOverlay-CzbFYtPI.js","assets/trash-2-CcSsv4fS.js","assets/lock-BSXM1xvq.js","assets/FilterMenu-BQY75Su3.js","assets/FilterMenu-D1i9jhjZ.css","assets/device-explorer-CHv1miyr.css","assets/builds-page-C0fTvIG8.js","assets/use-builds-data-CHW-MhaP.js","assets/time-D-gjmE1o.js","assets/stat-tile-DFhv8JoI.js","assets/session-detail-page-ZZyGM413.js","assets/arrow-up-right-DUA_lq6f.js","assets/line-chart-CPK0ObjV.js","assets/line-chart-Bzzc3bMl.css","assets/video-off-dFKgps73.js","assets/network-Ba_uFxWo.js","assets/runbook-page-Cnec3VSx.js","assets/runbook-page-BFqSC-Ta.css","assets/apps-vUfu15lX.js","assets/apps-BQKfuN3J.css","assets/webhook-settings-DD1XjiOD.js","assets/webhook-settings-CAfLaykw.css","assets/settings-Dep_3kbA.css","assets/settings-DGZ7B_AR.js","assets/SettingCard-Cw6lDD0l.js","assets/SettingCard-CiKM8yKg.css","assets/calendar-CqVsn28A.js","assets/ai-settings-D7Te8o-a.js","assets/maintenance-settings-DaOs00P6.js","assets/api-keys-DphSVzBr.js","assets/teams-eHSyEpbD.js","assets/users-BpYnpOl2.js","assets/selector-health-page-DsyL58tb.js","assets/view-state-83Z1gFME.js","assets/selector-detail-redirect-BG3pxFLw.js","assets/DeviceMosaicView-paDEFU4B.js","assets/recordings-BWe1ydXm.js","assets/profile-page-BZ_e-Bgw.js","assets/users-CcSQRoK9.js","assets/RecordingsPage-CXfw7wpd.js","assets/recordings-n-GTW3aT.js","assets/recordings-B2Am-bZy.css","assets/RecordingPage-BvemyRiy.js","assets/login-Ct2iW066.js","assets/use-password-reset-mode-DozShXkk.js","assets/auth-shell-BYRHcZd6.js","assets/forgot-password-CoE7Ugtx.js","assets/reset-password-lfNz8Rm1.js"])))=>i.map(i=>d[i]);
2
2
  function id(e,t){for(var n=0;n<t.length;n++){const r=t[n];if(typeof r!="string"&&!Array.isArray(r)){for(const i in r)if(i!=="default"&&!(i in e)){const o=Object.getOwnPropertyDescriptor(r,i);o&&Object.defineProperty(e,i,o.get?o:{enumerable:!0,get:()=>r[i]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const o of i)if(o.type==="childList")for(const s of o.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&r(s)}).observe(document,{childList:!0,subtree:!0});function n(i){const o={};return i.integrity&&(o.integrity=i.integrity),i.referrerPolicy&&(o.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?o.credentials="include":i.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function r(i){if(i.ep)return;i.ep=!0;const o=n(i);fetch(i.href,o)}})();function _u(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Su={exports:{}},yr={};/*
3
3
  object-assign
4
4
  (c) Sindre Sorhus
@@ -216,4 +216,4 @@ Add a <Suspense fallback=...> component higher in the tree to provide a loading
216
216
  *
217
217
  * This source code is licensed under the ISC license.
218
218
  * See the LICENSE file in the root directory of this source tree.
219
- */const wy=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],ky=B("x",wy),Bi={"X-Appium-Is-Sensitive":"true"},gt="/xenon/api/auth";class ru extends Error{constructor(t,n,r=null){super(t),this.status=n,this.retryAfterSec=r,this.name="LoginError"}}async function Lv(e,t){let n;try{n=await fetch(`${gt}/login`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json",...Bi},body:JSON.stringify({email:e,password:t})})}catch(r){throw new ru(r.message||"Network error",0)}if(!n.ok){const r=await n.json().catch(()=>({})),i=Number(n.headers.get("Retry-After"));throw new ru(r.error||`Login failed (${n.status})`,n.status,Number.isFinite(i)&&i>0?i:null)}}async function jv(){try{const e=await fetch(`${gt}/options`,{credentials:"include"});return e.ok?{passwordReset:(await e.json()).passwordReset==="email"?"email":"admin"}:{passwordReset:"admin"}}catch{return{passwordReset:"admin"}}}async function xy(){await fetch(`${gt}/logout`,{method:"POST",credentials:"include"})}async function Ey(){const e=await fetch(`${gt}/me`,{credentials:"include"});if(e.status===401)return null;if(!e.ok)throw new Error(`Failed to fetch /me (${e.status})`);return e.json()}async function Av(e,t){const n=await fetch(`${gt}/change-password`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json",...Bi},body:JSON.stringify({oldPassword:e,newPassword:t})});if(!n.ok){const r=await n.json().catch(()=>({}));throw new Error(r.error||`Change password failed (${n.status})`)}}async function Iv(e){const t=await fetch(`${gt}/forgot-password`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:e})});if(!t.ok&&t.status!==204)throw t.status===429?new Error("Too many attempts — try again later."):new Error(`Request failed (${t.status})`)}async function Dv(e){return(await fetch(`${gt}/reset-password/check`,{method:"POST",headers:{"Content-Type":"application/json",...Bi},body:JSON.stringify({token:e})})).ok}async function Mv(e,t){const n=await fetch(`${gt}/reset-password`,{method:"POST",headers:{"Content-Type":"application/json",...Bi},body:JSON.stringify({token:e,newPassword:t})});if(!n.ok&&n.status!==204){const r=await n.json().catch(()=>({}));throw new Error(r.error||`Reset failed (${n.status})`)}}const Af="xenon-screenshots",He="captures",ps="udid";function If(e,t){return t.takenAt-e.takenAt||t.n-e.n}function iu(){const e=new Map;return{persistent:!1,async list(t){return Array.from(e.values()).filter(n=>n.udid===t).sort(If)},async put(t){e.set(t.id,t)},async delete(t){t.forEach(n=>e.delete(n))},async clear(t){Array.from(e.values()).filter(n=>n.udid===t).forEach(n=>e.delete(n.id))}}}function ou(e){return new Promise((t,n)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>n(e.error)})}function su(e){return new Promise((t,n)=>{e.oncomplete=()=>t(),e.onerror=()=>n(e.error),e.onabort=()=>n(e.error??new Error("transaction aborted"))})}function _y(e){return new Promise((t,n)=>{const r=e.open(Af,1);r.onupgradeneeded=()=>{r.result.createObjectStore(He,{keyPath:"id"}).createIndex(ps,"udid")},r.onsuccess=()=>{const i=r.result;i.onversionchange=()=>i.close(),t(i)},r.onerror=()=>n(r.error),r.onblocked=()=>n(new Error("blocked"))})}function Sy(e){const t=async n=>{const r=e.transaction(He,"readwrite");n(r.objectStore(He)),await su(r)};return{persistent:!0,async list(n){const r=e.transaction(He,"readonly");return(await ou(r.objectStore(He).index(ps).getAll(n))).sort(If)},put:n=>t(r=>r.put(n)),delete:n=>t(r=>n.forEach(i=>r.delete(i))),async clear(n){const r=e.transaction(He,"readwrite"),i=r.objectStore(He).index(ps);(await ou(i.getAllKeys(n))).forEach(s=>r.objectStore(He).delete(s)),await su(r)}}}function Df(){try{return typeof indexedDB>"u"?void 0:indexedDB}catch{return}}async function Cy(e=Df()){if(!e)return iu();try{return Sy(await _y(e))}catch{return iu()}}let Gr=null;function $v(){return Gr||(Gr=Cy()),Gr}async function Ty(e=Df(),t=1e3){if(Gr=null,!e)return;const n=new Promise(r=>{try{const i=e.deleteDatabase(Af);i.onsuccess=()=>r(),i.onerror=()=>r(),i.onblocked=()=>r()}catch{r()}});await Promise.race([n,new Promise(r=>setTimeout(r,t))])}const xl="xenon.hadSession";function Ry(){try{localStorage.setItem(xl,"1")}catch{}}function Py(){try{localStorage.removeItem(xl)}catch{}}function Ny(){try{return localStorage.getItem(xl)==="1"}catch{return!1}}const Mf=y.createContext(null);function Oy({children:e}){const[t,n]=y.useState(!0),[r,i]=y.useState(null);async function o(){try{const l=await Ey();l&&Ry(),i(l)}finally{n(!1)}}async function s(){Py(),await Promise.all([xy(),Ty()]),i(null),window.location.href="/xenon/login"}return y.useEffect(()=>{o()},[]),p.jsx(Mf.Provider,{value:{loading:t,me:r,refresh:o,signOut:s},children:e})}function El(){const e=y.useContext(Mf);if(!e)throw new Error("useAuth must be used inside AuthProvider");return e}const De=Object.create(null);De.open="0";De.close="1";De.ping="2";De.pong="3";De.message="4";De.upgrade="5";De.noop="6";const Yr=Object.create(null);Object.keys(De).forEach(e=>{Yr[De[e]]=e});const hs={type:"error",data:"parser error"},$f=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",Uf=typeof ArrayBuffer=="function",Bf=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,_l=({type:e,data:t},n,r)=>$f&&t instanceof Blob?n?r(t):lu(t,r):Uf&&(t instanceof ArrayBuffer||Bf(t))?n?r(t):lu(new Blob([t]),r):r(De[e]+(t||"")),lu=(e,t)=>{const n=new FileReader;return n.onload=function(){const r=n.result.split(",")[1];t("b"+(r||""))},n.readAsDataURL(e)};function au(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}let vo;function Ly(e,t){if($f&&e.data instanceof Blob)return e.data.arrayBuffer().then(au).then(t);if(Uf&&(e.data instanceof ArrayBuffer||Bf(e.data)))return t(au(e.data));_l(e,!1,n=>{vo||(vo=new TextEncoder),t(vo.encode(n))})}const uu="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Bn=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let e=0;e<uu.length;e++)Bn[uu.charCodeAt(e)]=e;const jy=e=>{let t=e.length*.75,n=e.length,r,i=0,o,s,l,a;e[e.length-1]==="="&&(t--,e[e.length-2]==="="&&t--);const u=new ArrayBuffer(t),m=new Uint8Array(u);for(r=0;r<n;r+=4)o=Bn[e.charCodeAt(r)],s=Bn[e.charCodeAt(r+1)],l=Bn[e.charCodeAt(r+2)],a=Bn[e.charCodeAt(r+3)],m[i++]=o<<2|s>>4,m[i++]=(s&15)<<4|l>>2,m[i++]=(l&3)<<6|a&63;return u},Ay=typeof ArrayBuffer=="function",Sl=(e,t)=>{if(typeof e!="string")return{type:"message",data:zf(e,t)};const n=e.charAt(0);return n==="b"?{type:"message",data:Iy(e.substring(1),t)}:Yr[n]?e.length>1?{type:Yr[n],data:e.substring(1)}:{type:Yr[n]}:hs},Iy=(e,t)=>{if(Ay){const n=jy(e);return zf(n,t)}else return{base64:!0,data:e}},zf=(e,t)=>{switch(t){case"blob":return e instanceof Blob?e:new Blob([e]);case"arraybuffer":default:return e instanceof ArrayBuffer?e:e.buffer}},bf="",Dy=(e,t)=>{const n=e.length,r=new Array(n);let i=0;e.forEach((o,s)=>{_l(o,!1,l=>{r[s]=l,++i===n&&t(r.join(bf))})})},My=(e,t)=>{const n=e.split(bf),r=[];for(let i=0;i<n.length;i++){const o=Sl(n[i],t);if(r.push(o),o.type==="error")break}return r};function $y(){return new TransformStream({transform(e,t){Ly(e,n=>{const r=n.length;let i;if(r<126)i=new Uint8Array(1),new DataView(i.buffer).setUint8(0,r);else if(r<65536){i=new Uint8Array(3);const o=new DataView(i.buffer);o.setUint8(0,126),o.setUint16(1,r)}else{i=new Uint8Array(9);const o=new DataView(i.buffer);o.setUint8(0,127),o.setBigUint64(1,BigInt(r))}e.data&&typeof e.data!="string"&&(i[0]|=128),t.enqueue(i),t.enqueue(n)})}})}let wo;function Mr(e){return e.reduce((t,n)=>t+n.length,0)}function $r(e,t){if(e[0].length===t)return e.shift();const n=new Uint8Array(t);let r=0;for(let i=0;i<t;i++)n[i]=e[0][r++],r===e[0].length&&(e.shift(),r=0);return e.length&&r<e[0].length&&(e[0]=e[0].slice(r)),n}function Uy(e,t){wo||(wo=new TextDecoder);const n=[];let r=0,i=-1,o=!1;return new TransformStream({transform(s,l){for(n.push(s);;){if(r===0){if(Mr(n)<1)break;const a=$r(n,1);o=(a[0]&128)===128,i=a[0]&127,i<126?r=3:i===126?r=1:r=2}else if(r===1){if(Mr(n)<2)break;const a=$r(n,2);i=new DataView(a.buffer,a.byteOffset,a.length).getUint16(0),r=3}else if(r===2){if(Mr(n)<8)break;const a=$r(n,8),u=new DataView(a.buffer,a.byteOffset,a.length),m=u.getUint32(0);if(m>Math.pow(2,21)-1){l.enqueue(hs);break}i=m*Math.pow(2,32)+u.getUint32(4),r=3}else{if(Mr(n)<i)break;const a=$r(n,i);l.enqueue(Sl(o?a:wo.decode(a),t)),r=0}if(i===0||i>e){l.enqueue(hs);break}}}})}const Ff=4;function G(e){if(e)return By(e)}function By(e){for(var t in G.prototype)e[t]=G.prototype[t];return e}G.prototype.on=G.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this};G.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this};G.prototype.off=G.prototype.removeListener=G.prototype.removeAllListeners=G.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var n=this._callbacks["$"+e];if(!n)return this;if(arguments.length==1)return delete this._callbacks["$"+e],this;for(var r,i=0;i<n.length;i++)if(r=n[i],r===t||r.fn===t){n.splice(i,1);break}return n.length===0&&delete this._callbacks["$"+e],this};G.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),n=this._callbacks["$"+e],r=1;r<arguments.length;r++)t[r-1]=arguments[r];if(n){n=n.slice(0);for(var r=0,i=n.length;r<i;++r)n[r].apply(this,t)}return this};G.prototype.emitReserved=G.prototype.emit;G.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]};G.prototype.hasListeners=function(e){return!!this.listeners(e).length};const zi=typeof Promise=="function"&&typeof Promise.resolve=="function"?t=>Promise.resolve().then(t):(t,n)=>n(t,0),ve=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),zy="arraybuffer";function Vf(e,...t){return t.reduce((n,r)=>(e.hasOwnProperty(r)&&(n[r]=e[r]),n),{})}const by=ve.setTimeout,Fy=ve.clearTimeout;function bi(e,t){t.useNativeTimers?(e.setTimeoutFn=by.bind(ve),e.clearTimeoutFn=Fy.bind(ve)):(e.setTimeoutFn=ve.setTimeout.bind(ve),e.clearTimeoutFn=ve.clearTimeout.bind(ve))}const Vy=1.33;function qy(e){return typeof e=="string"?Wy(e):Math.ceil((e.byteLength||e.size)*Vy)}function Wy(e){let t=0,n=0;for(let r=0,i=e.length;r<i;r++)t=e.charCodeAt(r),t<128?n+=1:t<2048?n+=2:t<55296||t>=57344?n+=3:(r++,n+=4);return n}function qf(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function Hy(e){let t="";for(let n in e)e.hasOwnProperty(n)&&(t.length&&(t+="&"),t+=encodeURIComponent(n)+"="+encodeURIComponent(e[n]));return t}function Ky(e){let t={},n=e.split("&");for(let r=0,i=n.length;r<i;r++){let o=n[r].split("=");t[decodeURIComponent(o[0])]=decodeURIComponent(o[1])}return t}class Qy extends Error{constructor(t,n,r){super(t),this.description=n,this.context=r,this.type="TransportError"}}class Cl extends G{constructor(t){super(),this.writable=!1,bi(this,t),this.opts=t,this.query=t.query,this.socket=t.socket,this.supportsBinary=!t.forceBase64}onError(t,n,r){return super.emitReserved("error",new Qy(t,n,r)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(t){this.readyState==="open"&&this.write(t)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(t){const n=Sl(t,this.socket.binaryType);this.onPacket(n)}onPacket(t){super.emitReserved("packet",t)}onClose(t){this.readyState="closed",super.emitReserved("close",t)}pause(t){}createUri(t,n={}){return t+"://"+this._hostname()+this._port()+this.opts.path+this._query(n)}_hostname(){const t=this.opts.hostname;return t.indexOf(":")===-1?t:"["+t+"]"}_port(){return this.opts.port&&(this.opts.secure&&Number(this.opts.port)!==443||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(t){const n=Hy(t);return n.length?"?"+n:""}}class Gy extends Cl{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(t){this.readyState="pausing";const n=()=>{this.readyState="paused",t()};if(this._polling||!this.writable){let r=0;this._polling&&(r++,this.once("pollComplete",function(){--r||n()})),this.writable||(r++,this.once("drain",function(){--r||n()}))}else n()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(t){const n=r=>{if(this.readyState==="opening"&&r.type==="open"&&this.onOpen(),r.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(r)};My(t,this.socket.binaryType).forEach(n),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){const t=()=>{this.write([{type:"close"}])};this.readyState==="open"?t():this.once("open",t)}write(t){this.writable=!1,Dy(t,n=>{this.doWrite(n,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const t=this.opts.secure?"https":"http",n=this.query||{};return this.opts.timestampRequests!==!1&&(n[this.opts.timestampParam]=qf()),!this.supportsBinary&&!n.sid&&(n.b64=1),this.createUri(t,n)}}let Wf=!1;try{Wf=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const Yy=Wf;function Xy(){}class Jy extends Gy{constructor(t){if(super(t),typeof location<"u"){const n=location.protocol==="https:";let r=location.port;r||(r=n?"443":"80"),this.xd=typeof location<"u"&&t.hostname!==location.hostname||r!==t.port}}doWrite(t,n){const r=this.request({method:"POST",data:t});r.on("success",n),r.on("error",(i,o)=>{this.onError("xhr post error",i,o)})}doPoll(){const t=this.request();t.on("data",this.onData.bind(this)),t.on("error",(n,r)=>{this.onError("xhr poll error",n,r)}),this.pollXhr=t}}class Ie extends G{constructor(t,n,r){super(),this.createRequest=t,bi(this,r),this._opts=r,this._method=r.method||"GET",this._uri=n,this._data=r.data!==void 0?r.data:null,this._create()}_create(){var t;const n=Vf(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");n.xdomain=!!this._opts.xd;const r=this._xhr=this.createRequest(n);try{r.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){r.setDisableHeaderCheck&&r.setDisableHeaderCheck(!0);for(let i in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(i)&&r.setRequestHeader(i,this._opts.extraHeaders[i])}}catch{}if(this._method==="POST")try{r.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{r.setRequestHeader("Accept","*/*")}catch{}(t=this._opts.cookieJar)===null||t===void 0||t.addCookies(r),"withCredentials"in r&&(r.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(r.timeout=this._opts.requestTimeout),r.onreadystatechange=()=>{var i;r.readyState===3&&((i=this._opts.cookieJar)===null||i===void 0||i.parseCookies(r.getResponseHeader("set-cookie"))),r.readyState===4&&(r.status===200||r.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof r.status=="number"?r.status:0)},0))},r.send(this._data)}catch(i){this.setTimeoutFn(()=>{this._onError(i)},0);return}typeof document<"u"&&(this._index=Ie.requestsCount++,Ie.requests[this._index]=this)}_onError(t){this.emitReserved("error",t,this._xhr),this._cleanup(!0)}_cleanup(t){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=Xy,t)try{this._xhr.abort()}catch{}typeof document<"u"&&delete Ie.requests[this._index],this._xhr=null}}_onLoad(){const t=this._xhr.responseText;t!==null&&(this.emitReserved("data",t),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}}Ie.requestsCount=0;Ie.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",cu);else if(typeof addEventListener=="function"){const e="onpagehide"in ve?"pagehide":"unload";addEventListener(e,cu,!1)}}function cu(){for(let e in Ie.requests)Ie.requests.hasOwnProperty(e)&&Ie.requests[e].abort()}const Zy=function(){const e=Hf({xdomain:!1});return e&&e.responseType!==null}();class eg extends Jy{constructor(t){super(t);const n=t&&t.forceBase64;this.supportsBinary=Zy&&!n}request(t={}){return Object.assign(t,{xd:this.xd},this.opts),new Ie(Hf,this.uri(),t)}}function Hf(e){const t=e.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!t||Yy))return new XMLHttpRequest}catch{}if(!t)try{return new ve[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const Kf=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class tg extends Cl{get name(){return"websocket"}doOpen(){const t=this.uri(),n=this.opts.protocols,r=Kf?{}:Vf(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(r.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(t,n,r)}catch(i){return this.emitReserved("error",i)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=t=>this.onClose({description:"websocket connection closed",context:t}),this.ws.onmessage=t=>this.onData(t.data),this.ws.onerror=t=>this.onError("websocket error",t)}write(t){this.writable=!1;for(let n=0;n<t.length;n++){const r=t[n],i=n===t.length-1;_l(r,this.supportsBinary,o=>{try{this.doWrite(r,o)}catch{}i&&zi(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const t=this.opts.secure?"wss":"ws",n=this.query||{};return this.opts.timestampRequests&&(n[this.opts.timestampParam]=qf()),this.supportsBinary||(n.b64=1),this.createUri(t,n)}}const ko=ve.WebSocket||ve.MozWebSocket;class ng extends tg{createSocket(t,n,r){return Kf?new ko(t,n,r):n?new ko(t,n):new ko(t)}doWrite(t,n){this.ws.send(n)}}class rg extends Cl{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(t){return this.emitReserved("error",t)}this._transport.closed.then(()=>{this.onClose()}).catch(t=>{this.onError("webtransport error",t)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(t=>{const n=Uy(Number.MAX_SAFE_INTEGER,this.socket.binaryType),r=t.readable.pipeThrough(n).getReader(),i=$y();i.readable.pipeTo(t.writable),this._writer=i.writable.getWriter();const o=()=>{r.read().then(({done:l,value:a})=>{l||(this.onPacket(a),o())}).catch(l=>{})};o();const s={type:"open"};this.query.sid&&(s.data=`{"sid":"${this.query.sid}"}`),this._writer.write(s).then(()=>this.onOpen())})})}write(t){this.writable=!1;for(let n=0;n<t.length;n++){const r=t[n],i=n===t.length-1;this._writer.write(r).then(()=>{i&&zi(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var t;(t=this._transport)===null||t===void 0||t.close()}}const ig={websocket:ng,webtransport:rg,polling:eg},og=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,sg=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function ms(e){if(e.length>8e3)throw"URI too long";const t=e,n=e.indexOf("["),r=e.indexOf("]");n!=-1&&r!=-1&&(e=e.substring(0,n)+e.substring(n,r).replace(/:/g,";")+e.substring(r,e.length));let i=og.exec(e||""),o={},s=14;for(;s--;)o[sg[s]]=i[s]||"";return n!=-1&&r!=-1&&(o.source=t,o.host=o.host.substring(1,o.host.length-1).replace(/;/g,":"),o.authority=o.authority.replace("[","").replace("]","").replace(/;/g,":"),o.ipv6uri=!0),o.pathNames=lg(o,o.path),o.queryKey=ag(o,o.query),o}function lg(e,t){const n=/\/{2,9}/g,r=t.replace(n,"/").split("/");return(t.slice(0,1)=="/"||t.length===0)&&r.splice(0,1),t.slice(-1)=="/"&&r.splice(r.length-1,1),r}function ag(e,t){const n={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(r,i,o){i&&(n[i]=o)}),n}const ys=typeof addEventListener=="function"&&typeof removeEventListener=="function",Xr=[];ys&&addEventListener("offline",()=>{Xr.forEach(e=>e())},!1);class at extends G{constructor(t,n){if(super(),this.binaryType=zy,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,t&&typeof t=="object"&&(n=t,t=null),t){const r=ms(t);n.hostname=r.host,n.secure=r.protocol==="https"||r.protocol==="wss",n.port=r.port,r.query&&(n.query=r.query)}else n.host&&(n.hostname=ms(n.host).host);bi(this,n),this.secure=n.secure!=null?n.secure:typeof location<"u"&&location.protocol==="https:",n.hostname&&!n.port&&(n.port=this.secure?"443":"80"),this.hostname=n.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=n.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},n.transports.forEach(r=>{const i=r.prototype.name;this.transports.push(i),this._transportsByName[i]=r}),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},n),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=Ky(this.opts.query)),ys&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},Xr.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(t){const n=Object.assign({},this.opts.query);n.EIO=Ff,n.transport=t,this.id&&(n.sid=this.id);const r=Object.assign({},this.opts,{query:n,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[t]);return new this._transportsByName[t](r)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const t=this.opts.rememberUpgrade&&at.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const n=this.createTransport(t);n.open(),this.setTransport(n)}setTransport(t){this.transport&&this.transport.removeAllListeners(),this.transport=t,t.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",n=>this._onClose("transport close",n))}onOpen(){this.readyState="open",at.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(t){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",t),this.emitReserved("heartbeat"),t.type){case"open":this.onHandshake(JSON.parse(t.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":const n=new Error("server error");n.code=t.data,this._onError(n);break;case"message":this.emitReserved("data",t.data),this.emitReserved("message",t.data);break}}onHandshake(t){this.emitReserved("handshake",t),this.id=t.sid,this.transport.query.sid=t.sid,this._pingInterval=t.pingInterval,this._pingTimeout=t.pingTimeout,this._maxPayload=t.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const t=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+t,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},t),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const t=this._getWritablePackets();this.transport.send(t),this._prevBufferLen=t.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let n=1;for(let r=0;r<this.writeBuffer.length;r++){const i=this.writeBuffer[r].data;if(i&&(n+=qy(i)),r>0&&n>this._maxPayload)return this.writeBuffer.slice(0,r);n+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const t=Date.now()>this._pingTimeoutTime;return t&&(this._pingTimeoutTime=0,zi(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),t}write(t,n,r){return this._sendPacket("message",t,n,r),this}send(t,n,r){return this._sendPacket("message",t,n,r),this}_sendPacket(t,n,r,i){if(typeof n=="function"&&(i=n,n=void 0),typeof r=="function"&&(i=r,r=null),this.readyState==="closing"||this.readyState==="closed")return;r=r||{},r.compress=r.compress!==!1;const o={type:t,data:n,options:r};this.emitReserved("packetCreate",o),this.writeBuffer.push(o),i&&this.once("flush",i),this.flush()}close(){const t=()=>{this._onClose("forced close"),this.transport.close()},n=()=>{this.off("upgrade",n),this.off("upgradeError",n),t()},r=()=>{this.once("upgrade",n),this.once("upgradeError",n)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?r():t()}):this.upgrading?r():t()),this}_onError(t){if(at.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",t),this._onClose("transport error",t)}_onClose(t,n){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing"){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),ys&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const r=Xr.indexOf(this._offlineEventListener);r!==-1&&Xr.splice(r,1)}this.readyState="closed",this.id=null,this.emitReserved("close",t,n),this.writeBuffer=[],this._prevBufferLen=0}}}at.protocol=Ff;class ug extends at{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let t=0;t<this._upgrades.length;t++)this._probe(this._upgrades[t])}_probe(t){let n=this.createTransport(t),r=!1;at.priorWebsocketSuccess=!1;const i=()=>{r||(n.send([{type:"ping",data:"probe"}]),n.once("packet",v=>{if(!r)if(v.type==="pong"&&v.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",n),!n)return;at.priorWebsocketSuccess=n.name==="websocket",this.transport.pause(()=>{r||this.readyState!=="closed"&&(m(),this.setTransport(n),n.send([{type:"upgrade"}]),this.emitReserved("upgrade",n),n=null,this.upgrading=!1,this.flush())})}else{const h=new Error("probe error");h.transport=n.name,this.emitReserved("upgradeError",h)}}))};function o(){r||(r=!0,m(),n.close(),n=null)}const s=v=>{const h=new Error("probe error: "+v);h.transport=n.name,o(),this.emitReserved("upgradeError",h)};function l(){s("transport closed")}function a(){s("socket closed")}function u(v){n&&v.name!==n.name&&o()}const m=()=>{n.removeListener("open",i),n.removeListener("error",s),n.removeListener("close",l),this.off("close",a),this.off("upgrading",u)};n.once("open",i),n.once("error",s),n.once("close",l),this.once("close",a),this.once("upgrading",u),this._upgrades.indexOf("webtransport")!==-1&&t!=="webtransport"?this.setTimeoutFn(()=>{r||n.open()},200):n.open()}onHandshake(t){this._upgrades=this._filterUpgrades(t.upgrades),super.onHandshake(t)}_filterUpgrades(t){const n=[];for(let r=0;r<t.length;r++)~this.transports.indexOf(t[r])&&n.push(t[r]);return n}}let cg=class extends ug{constructor(t,n={}){const r=typeof t=="object"?t:n;(!r.transports||r.transports&&typeof r.transports[0]=="string")&&(r.transports=(r.transports||["polling","websocket","webtransport"]).map(i=>ig[i]).filter(i=>!!i)),super(t,r)}};function fg(e,t="",n){let r=e;n=n||typeof location<"u"&&location,e==null&&(e=n.protocol+"//"+n.host),typeof e=="string"&&(e.charAt(0)==="/"&&(e.charAt(1)==="/"?e=n.protocol+e:e=n.host+e),/^(https?|wss?):\/\//.test(e)||(typeof n<"u"?e=n.protocol+"//"+e:e="https://"+e),r=ms(e)),r.port||(/^(http|ws)$/.test(r.protocol)?r.port="80":/^(http|ws)s$/.test(r.protocol)&&(r.port="443")),r.path=r.path||"/";const o=r.host.indexOf(":")!==-1?"["+r.host+"]":r.host;return r.id=r.protocol+"://"+o+":"+r.port+t,r.href=r.protocol+"://"+o+(n&&n.port===r.port?"":":"+r.port),r}const dg=typeof ArrayBuffer=="function",pg=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,Qf=Object.prototype.toString,hg=typeof Blob=="function"||typeof Blob<"u"&&Qf.call(Blob)==="[object BlobConstructor]",mg=typeof File=="function"||typeof File<"u"&&Qf.call(File)==="[object FileConstructor]";function Tl(e){return dg&&(e instanceof ArrayBuffer||pg(e))||hg&&e instanceof Blob||mg&&e instanceof File}function Jr(e,t){if(!e||typeof e!="object")return!1;if(Array.isArray(e)){for(let n=0,r=e.length;n<r;n++)if(Jr(e[n]))return!0;return!1}if(Tl(e))return!0;if(e.toJSON&&typeof e.toJSON=="function"&&arguments.length===1)return Jr(e.toJSON(),!0);for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&Jr(e[n]))return!0;return!1}function yg(e){const t=[],n=e.data,r=e;return r.data=gs(n,t),r.attachments=t.length,{packet:r,buffers:t}}function gs(e,t){if(!e)return e;if(Tl(e)){const n={_placeholder:!0,num:t.length};return t.push(e),n}else if(Array.isArray(e)){const n=new Array(e.length);for(let r=0;r<e.length;r++)n[r]=gs(e[r],t);return n}else if(typeof e=="object"&&!(e instanceof Date)){const n={};for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=gs(e[r],t));return n}return e}function gg(e,t){return e.data=vs(e.data,t),delete e.attachments,e}function vs(e,t){if(!e)return e;if(e&&e._placeholder===!0){if(typeof e.num=="number"&&e.num>=0&&e.num<t.length)return t[e.num];throw new Error("illegal attachments")}else if(Array.isArray(e))for(let n=0;n<e.length;n++)e[n]=vs(e[n],t);else if(typeof e=="object")for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(e[n]=vs(e[n],t));return e}const vg=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];var D;(function(e){e[e.CONNECT=0]="CONNECT",e[e.DISCONNECT=1]="DISCONNECT",e[e.EVENT=2]="EVENT",e[e.ACK=3]="ACK",e[e.CONNECT_ERROR=4]="CONNECT_ERROR",e[e.BINARY_EVENT=5]="BINARY_EVENT",e[e.BINARY_ACK=6]="BINARY_ACK"})(D||(D={}));class wg{constructor(t){this.replacer=t}encode(t){return(t.type===D.EVENT||t.type===D.ACK)&&Jr(t)?this.encodeAsBinary({type:t.type===D.EVENT?D.BINARY_EVENT:D.BINARY_ACK,nsp:t.nsp,data:t.data,id:t.id}):[this.encodeAsString(t)]}encodeAsString(t){let n=""+t.type;return(t.type===D.BINARY_EVENT||t.type===D.BINARY_ACK)&&(n+=t.attachments+"-"),t.nsp&&t.nsp!=="/"&&(n+=t.nsp+","),t.id!=null&&(n+=t.id),t.data!=null&&(n+=JSON.stringify(t.data,this.replacer)),n}encodeAsBinary(t){const n=yg(t),r=this.encodeAsString(n.packet),i=n.buffers;return i.unshift(r),i}}class Rl extends G{constructor(t){super(),this.reviver=t}add(t){let n;if(typeof t=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");n=this.decodeString(t);const r=n.type===D.BINARY_EVENT;r||n.type===D.BINARY_ACK?(n.type=r?D.EVENT:D.ACK,this.reconstructor=new kg(n),n.attachments===0&&super.emitReserved("decoded",n)):super.emitReserved("decoded",n)}else if(Tl(t)||t.base64)if(this.reconstructor)n=this.reconstructor.takeBinaryData(t),n&&(this.reconstructor=null,super.emitReserved("decoded",n));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+t)}decodeString(t){let n=0;const r={type:Number(t.charAt(0))};if(D[r.type]===void 0)throw new Error("unknown packet type "+r.type);if(r.type===D.BINARY_EVENT||r.type===D.BINARY_ACK){const o=n+1;for(;t.charAt(++n)!=="-"&&n!=t.length;);const s=t.substring(o,n);if(s!=Number(s)||t.charAt(n)!=="-")throw new Error("Illegal attachments");r.attachments=Number(s)}if(t.charAt(n+1)==="/"){const o=n+1;for(;++n&&!(t.charAt(n)===","||n===t.length););r.nsp=t.substring(o,n)}else r.nsp="/";const i=t.charAt(n+1);if(i!==""&&Number(i)==i){const o=n+1;for(;++n;){const s=t.charAt(n);if(s==null||Number(s)!=s){--n;break}if(n===t.length)break}r.id=Number(t.substring(o,n+1))}if(t.charAt(++n)){const o=this.tryParse(t.substr(n));if(Rl.isPayloadValid(r.type,o))r.data=o;else throw new Error("invalid payload")}return r}tryParse(t){try{return JSON.parse(t,this.reviver)}catch{return!1}}static isPayloadValid(t,n){switch(t){case D.CONNECT:return fu(n);case D.DISCONNECT:return n===void 0;case D.CONNECT_ERROR:return typeof n=="string"||fu(n);case D.EVENT:case D.BINARY_EVENT:return Array.isArray(n)&&(typeof n[0]=="number"||typeof n[0]=="string"&&vg.indexOf(n[0])===-1);case D.ACK:case D.BINARY_ACK:return Array.isArray(n)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class kg{constructor(t){this.packet=t,this.buffers=[],this.reconPack=t}takeBinaryData(t){if(this.buffers.push(t),this.buffers.length===this.reconPack.attachments){const n=gg(this.reconPack,this.buffers);return this.finishedReconstruction(),n}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}function fu(e){return Object.prototype.toString.call(e)==="[object Object]"}const xg=Object.freeze(Object.defineProperty({__proto__:null,Decoder:Rl,Encoder:wg,get PacketType(){return D}},Symbol.toStringTag,{value:"Module"}));function Re(e,t,n){return e.on(t,n),function(){e.off(t,n)}}const Eg=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class Gf extends G{constructor(t,n,r){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=t,this.nsp=n,r&&r.auth&&(this.auth=r.auth),this._opts=Object.assign({},r),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const t=this.io;this.subs=[Re(t,"open",this.onopen.bind(this)),Re(t,"packet",this.onpacket.bind(this)),Re(t,"error",this.onerror.bind(this)),Re(t,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...t){return t.unshift("message"),this.emit.apply(this,t),this}emit(t,...n){var r,i,o;if(Eg.hasOwnProperty(t))throw new Error('"'+t.toString()+'" is a reserved event name');if(n.unshift(t),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(n),this;const s={type:D.EVENT,data:n};if(s.options={},s.options.compress=this.flags.compress!==!1,typeof n[n.length-1]=="function"){const m=this.ids++,v=n.pop();this._registerAckCallback(m,v),s.id=m}const l=(i=(r=this.io.engine)===null||r===void 0?void 0:r.transport)===null||i===void 0?void 0:i.writable,a=this.connected&&!(!((o=this.io.engine)===null||o===void 0)&&o._hasPingExpired());return this.flags.volatile&&!l||(a?(this.notifyOutgoingListeners(s),this.packet(s)):this.sendBuffer.push(s)),this.flags={},this}_registerAckCallback(t,n){var r;const i=(r=this.flags.timeout)!==null&&r!==void 0?r:this._opts.ackTimeout;if(i===void 0){this.acks[t]=n;return}const o=this.io.setTimeoutFn(()=>{delete this.acks[t];for(let l=0;l<this.sendBuffer.length;l++)this.sendBuffer[l].id===t&&this.sendBuffer.splice(l,1);n.call(this,new Error("operation has timed out"))},i),s=(...l)=>{this.io.clearTimeoutFn(o),n.apply(this,l)};s.withError=!0,this.acks[t]=s}emitWithAck(t,...n){return new Promise((r,i)=>{const o=(s,l)=>s?i(s):r(l);o.withError=!0,n.push(o),this.emit(t,...n)})}_addToQueue(t){let n;typeof t[t.length-1]=="function"&&(n=t.pop());const r={id:this._queueSeq++,tryCount:0,pending:!1,args:t,flags:Object.assign({fromQueue:!0},this.flags)};t.push((i,...o)=>(this._queue[0],i!==null?r.tryCount>this._opts.retries&&(this._queue.shift(),n&&n(i)):(this._queue.shift(),n&&n(null,...o)),r.pending=!1,this._drainQueue())),this._queue.push(r),this._drainQueue()}_drainQueue(t=!1){if(!this.connected||this._queue.length===0)return;const n=this._queue[0];n.pending&&!t||(n.pending=!0,n.tryCount++,this.flags=n.flags,this.emit.apply(this,n.args))}packet(t){t.nsp=this.nsp,this.io._packet(t)}onopen(){typeof this.auth=="function"?this.auth(t=>{this._sendConnectPacket(t)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(t){this.packet({type:D.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},t):t})}onerror(t){this.connected||this.emitReserved("connect_error",t)}onclose(t,n){this.connected=!1,delete this.id,this.emitReserved("disconnect",t,n),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(t=>{if(!this.sendBuffer.some(r=>String(r.id)===t)){const r=this.acks[t];delete this.acks[t],r.withError&&r.call(this,new Error("socket has been disconnected"))}})}onpacket(t){if(t.nsp===this.nsp)switch(t.type){case D.CONNECT:t.data&&t.data.sid?this.onconnect(t.data.sid,t.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case D.EVENT:case D.BINARY_EVENT:this.onevent(t);break;case D.ACK:case D.BINARY_ACK:this.onack(t);break;case D.DISCONNECT:this.ondisconnect();break;case D.CONNECT_ERROR:this.destroy();const r=new Error(t.data.message);r.data=t.data.data,this.emitReserved("connect_error",r);break}}onevent(t){const n=t.data||[];t.id!=null&&n.push(this.ack(t.id)),this.connected?this.emitEvent(n):this.receiveBuffer.push(Object.freeze(n))}emitEvent(t){if(this._anyListeners&&this._anyListeners.length){const n=this._anyListeners.slice();for(const r of n)r.apply(this,t)}super.emit.apply(this,t),this._pid&&t.length&&typeof t[t.length-1]=="string"&&(this._lastOffset=t[t.length-1])}ack(t){const n=this;let r=!1;return function(...i){r||(r=!0,n.packet({type:D.ACK,id:t,data:i}))}}onack(t){const n=this.acks[t.id];typeof n=="function"&&(delete this.acks[t.id],n.withError&&t.data.unshift(null),n.apply(this,t.data))}onconnect(t,n){this.id=t,this.recovered=n&&this._pid===n,this._pid=n,this.connected=!0,this.emitBuffered(),this._drainQueue(!0),this.emitReserved("connect")}emitBuffered(){this.receiveBuffer.forEach(t=>this.emitEvent(t)),this.receiveBuffer=[],this.sendBuffer.forEach(t=>{this.notifyOutgoingListeners(t),this.packet(t)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(t=>t()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:D.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(t){return this.flags.compress=t,this}get volatile(){return this.flags.volatile=!0,this}timeout(t){return this.flags.timeout=t,this}onAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(t),this}prependAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(t),this}offAny(t){if(!this._anyListeners)return this;if(t){const n=this._anyListeners;for(let r=0;r<n.length;r++)if(t===n[r])return n.splice(r,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(t){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(t),this}prependAnyOutgoing(t){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(t),this}offAnyOutgoing(t){if(!this._anyOutgoingListeners)return this;if(t){const n=this._anyOutgoingListeners;for(let r=0;r<n.length;r++)if(t===n[r])return n.splice(r,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(t){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const n=this._anyOutgoingListeners.slice();for(const r of n)r.apply(this,t.data)}}}function gn(e){e=e||{},this.ms=e.min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}gn.prototype.duration=function(){var e=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),n=Math.floor(t*this.jitter*e);e=Math.floor(t*10)&1?e+n:e-n}return Math.min(e,this.max)|0};gn.prototype.reset=function(){this.attempts=0};gn.prototype.setMin=function(e){this.ms=e};gn.prototype.setMax=function(e){this.max=e};gn.prototype.setJitter=function(e){this.jitter=e};class ws extends G{constructor(t,n){var r;super(),this.nsps={},this.subs=[],t&&typeof t=="object"&&(n=t,t=void 0),n=n||{},n.path=n.path||"/socket.io",this.opts=n,bi(this,n),this.reconnection(n.reconnection!==!1),this.reconnectionAttempts(n.reconnectionAttempts||1/0),this.reconnectionDelay(n.reconnectionDelay||1e3),this.reconnectionDelayMax(n.reconnectionDelayMax||5e3),this.randomizationFactor((r=n.randomizationFactor)!==null&&r!==void 0?r:.5),this.backoff=new gn({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(n.timeout==null?2e4:n.timeout),this._readyState="closed",this.uri=t;const i=n.parser||xg;this.encoder=new i.Encoder,this.decoder=new i.Decoder,this._autoConnect=n.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(t){return arguments.length?(this._reconnection=!!t,t||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(t){return t===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=t,this)}reconnectionDelay(t){var n;return t===void 0?this._reconnectionDelay:(this._reconnectionDelay=t,(n=this.backoff)===null||n===void 0||n.setMin(t),this)}randomizationFactor(t){var n;return t===void 0?this._randomizationFactor:(this._randomizationFactor=t,(n=this.backoff)===null||n===void 0||n.setJitter(t),this)}reconnectionDelayMax(t){var n;return t===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=t,(n=this.backoff)===null||n===void 0||n.setMax(t),this)}timeout(t){return arguments.length?(this._timeout=t,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(t){if(~this._readyState.indexOf("open"))return this;this.engine=new cg(this.uri,this.opts);const n=this.engine,r=this;this._readyState="opening",this.skipReconnect=!1;const i=Re(n,"open",function(){r.onopen(),t&&t()}),o=l=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",l),t?t(l):this.maybeReconnectOnOpen()},s=Re(n,"error",o);if(this._timeout!==!1){const l=this._timeout,a=this.setTimeoutFn(()=>{i(),o(new Error("timeout")),n.close()},l);this.opts.autoUnref&&a.unref(),this.subs.push(()=>{this.clearTimeoutFn(a)})}return this.subs.push(i),this.subs.push(s),this}connect(t){return this.open(t)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const t=this.engine;this.subs.push(Re(t,"ping",this.onping.bind(this)),Re(t,"data",this.ondata.bind(this)),Re(t,"error",this.onerror.bind(this)),Re(t,"close",this.onclose.bind(this)),Re(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(t){try{this.decoder.add(t)}catch(n){this.onclose("parse error",n)}}ondecoded(t){zi(()=>{this.emitReserved("packet",t)},this.setTimeoutFn)}onerror(t){this.emitReserved("error",t)}socket(t,n){let r=this.nsps[t];return r?this._autoConnect&&!r.active&&r.connect():(r=new Gf(this,t,n),this.nsps[t]=r),r}_destroy(t){const n=Object.keys(this.nsps);for(const r of n)if(this.nsps[r].active)return;this._close()}_packet(t){const n=this.encoder.encode(t);for(let r=0;r<n.length;r++)this.engine.write(n[r],t.options)}cleanup(){this.subs.forEach(t=>t()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(t,n){var r;this.cleanup(),(r=this.engine)===null||r===void 0||r.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",t,n),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const t=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const n=this.backoff.duration();this._reconnecting=!0;const r=this.setTimeoutFn(()=>{t.skipReconnect||(this.emitReserved("reconnect_attempt",t.backoff.attempts),!t.skipReconnect&&t.open(i=>{i?(t._reconnecting=!1,t.reconnect(),this.emitReserved("reconnect_error",i)):t.onreconnect()}))},n);this.opts.autoUnref&&r.unref(),this.subs.push(()=>{this.clearTimeoutFn(r)})}}onreconnect(){const t=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",t)}}const jn={};function Zr(e,t){typeof e=="object"&&(t=e,e=void 0),t=t||{};const n=fg(e,t.path||"/socket.io"),r=n.source,i=n.id,o=n.path,s=jn[i]&&o in jn[i].nsps,l=t.forceNew||t["force new connection"]||t.multiplex===!1||s;let a;return l?a=new ws(r,t):(jn[i]||(jn[i]=new ws(r,t)),a=jn[i]),n.query&&!t.query&&(t.query=n.queryKey),a.socket(n.path,t)}Object.assign(Zr,{Manager:ws,Socket:Gf,io:Zr,connect:Zr});let xo=null;const zn=new Map;function _g(e,t){const n=zn.get(e);n&&Array.from(n).forEach(r=>r(t))}function Sg(){if(xo)return xo;const e=Zr(window.location.origin,{path:"/socket.io",reconnection:!0,withCredentials:!0});return e.on("connect",()=>{console.log("[Socket] Connected to Hub"),e.emit("register_dashboard")}),e.on("disconnect",()=>{console.log("[Socket] Disconnected from Hub")}),e.onAny((t,n)=>_g(t,n)),xo=e,e}function Cg(e,t){let n=zn.get(e);return n||(n=new Set,zn.set(e,n)),n.add(t),()=>{const r=zn.get(e);r&&(r.delete(t),r.size===0&&zn.delete(e))}}const Tg=()=>{const[e]=y.useState(Sg),[t,n]=y.useState(e.connected);y.useEffect(()=>{const i=()=>n(!0),o=()=>n(!1);return e.on("connect",i),e.on("disconnect",o),n(e.connected),()=>{e.off("connect",i),e.off("disconnect",o)}},[e]);const r=y.useCallback((i,o)=>Cg(i,o),[]);return{socket:e,isConnected:t,on:r}},Rg=6e4;function Pg(e,t,n,r=!0){if(e)return{tone:"live",label:"Live",title:"Connected to the Xenon server. Updates stream in as they happen."};const i=t??n;if(n-i<Rg)return r?{tone:"reconnecting",label:"Reconnecting…",title:"Lost the connection to the Xenon server. Retrying automatically."}:{tone:"reconnecting",label:"Connecting…",title:"Connecting to the Xenon server."};const o=new Date(i).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});return{tone:"down",label:`Disconnected · since ${o}`,title:`No connection to the Xenon server since ${o}. What's on screen may be out of date.`}}function Ng(){const{isConnected:e}=Tg(),[t,n]=y.useState(null),[r,i]=y.useState(()=>Date.now()),[o,s]=y.useState(e);return y.useEffect(()=>{n(e?null:Date.now()),e&&s(!0)},[e]),y.useEffect(()=>{if(e)return;const l=window.setInterval(()=>i(Date.now()),5e3);return()=>window.clearInterval(l)},[e]),Pg(e,t,r,o)}const Yf="xenon.theme",du="dark",Xf="(prefers-color-scheme: light)";function Og(){try{const e=localStorage.getItem(Yf);return e==="light"||e==="system"||e==="dark"?e:du}catch{return du}}function Jf(e,t){return e==="system"?t?"light":"dark":e}function Lg(){return typeof window.matchMedia=="function"&&window.matchMedia(Xf).matches}function Zf(e){document.documentElement.setAttribute("data-theme",e)}function jg(e){try{localStorage.setItem(Yf,e)}catch{}Zf(Jf(e,Lg()))}function Ag(){const[e,t]=y.useState(Og);return y.useEffect(()=>{var o;if(e!=="system"||typeof window.matchMedia!="function")return;const r=window.matchMedia(Xf),i=()=>Zf(Jf("system",r.matches));return(o=r.addEventListener)==null||o.call(r,"change",i),()=>{var s;return(s=r.removeEventListener)==null?void 0:s.call(r,"change",i)}},[e]),[e,r=>{jg(r),t(r)}]}function Ig({className:e,alt:t="Xenon"}){const n="/xenon/";return p.jsxs(p.Fragment,{children:[p.jsx("img",{src:`${n}logo.svg`,alt:t,className:`logo-for-dark ${e??""}`}),p.jsx("img",{src:`${n}logo-light.svg`,alt:t,className:`logo-for-light ${e??""}`})]})}const Dg=[{value:"dark",label:"Dark"},{value:"light",label:"Light"},{value:"system",label:"System"}],Mg=()=>{const e=yn(),{me:t,signOut:n}=El(),r=Ng(),[i,o]=Ag(),[s,l]=y.useState(!1),a=y.useRef(null),u=((t==null?void 0:t.name)??"A").split(" ").map(h=>h[0]).slice(0,2).join("").toUpperCase(),m=(t==null?void 0:t.role)==="SUPER_ADMIN"?"Super admin":(t==null?void 0:t.role)==="ADMIN"?"Admin":"Member";y.useEffect(()=>{const h=E=>{a.current&&!a.current.contains(E.target)&&l(!1)};return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[]);const v=()=>window.dispatchEvent(new CustomEvent("xenon.open-command-palette"));return p.jsx("header",{className:"fixed top-0 left-14 right-0 z-20 h-14 border-b border-[var(--border)] bg-[var(--bg)]/80 backdrop-blur-md",children:p.jsxs("div",{className:"flex items-center h-full px-4 gap-4",children:[p.jsx("button",{type:"button",onClick:()=>e("/overview"),className:"flex items-center gap-3 min-w-0 cursor-pointer","aria-label":"Xenon home",children:p.jsx("div",{className:"flex items-center gap-2",children:p.jsx(Ig,{alt:"Xenon Logo",className:"h-8 w-auto object-contain"})})}),p.jsx("div",{className:"flex-1 max-w-xl mx-auto",children:p.jsxs("button",{type:"button",onClick:v,className:"relative w-full h-9 flex items-center text-left","aria-label":"Open command palette",children:[p.jsx("div",{className:"w-full h-9 pl-9 pr-14 rounded-md bg-[var(--surface)] border border-[var(--border)] text-sm text-[var(--text-dim)] hover:border-[var(--border-strong)] hover:text-[var(--text)] transition-colors flex items-center",children:"Search devices, sessions, settings…"}),p.jsx(jf,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-[var(--text-dim)]"}),p.jsx("kbd",{className:"absolute right-3 top-1/2 -translate-y-1/2 font-mono text-[10px] text-[var(--text-dim)] border border-[var(--border)] rounded px-1.5 py-0.5",children:"⌘K"})]})}),p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsxs("div",{role:"status",title:r.title,className:`flex items-center gap-1.5 px-2.5 py-1 rounded-full border ${r.tone==="live"?"bg-[var(--color-success)]/10 border-[var(--color-success)]/20 text-[var(--color-success)]":r.tone==="reconnecting"?"bg-[var(--amber)]/10 border-[var(--amber)]/25 text-[var(--amber)]":"bg-[var(--red)]/10 border-[var(--red)]/25 text-[var(--red)]"}`,children:[p.jsx("span",{className:`h-1.5 w-1.5 rounded-full bg-current ${r.tone==="live"?"pulse-dot":""}`,"aria-hidden":"true"}),p.jsx("span",{className:"text-[11px] font-medium",children:r.label})]}),p.jsxs("div",{className:"relative",ref:a,children:[p.jsxs("button",{type:"button",className:"flex items-center gap-2 h-9 pl-1.5 pr-2.5 rounded-md border border-[var(--border)] hover:border-[var(--border-strong)] hover:bg-[var(--surface)] transition-colors",onClick:()=>l(h=>!h),"aria-haspopup":"true","aria-expanded":s,children:[p.jsx("span",{className:"h-6 w-6 rounded-full bg-[var(--color-accent)]/15 text-[var(--color-accent)] text-[11px] font-semibold flex items-center justify-center",children:u}),p.jsxs("span",{className:"flex flex-col items-start leading-tight",children:[p.jsx("span",{className:"text-xs text-[var(--text)]",children:(t==null?void 0:t.name)??"Account"}),p.jsx("span",{className:"text-[10px] text-[var(--text-dim)]",children:m})]}),p.jsx(Im,{className:"h-3.5 w-3.5 text-[var(--text-dim)]"})]}),s&&p.jsxs("div",{className:"absolute top-full right-0 mt-2 w-64 rounded-md border border-[var(--border)] bg-[var(--surface)] shadow-lg overflow-hidden",children:[p.jsxs("div",{className:"px-3 py-2",children:[p.jsx("div",{className:"text-[11px] text-[var(--text-dim)] mb-1",children:"System"}),p.jsxs("div",{className:"flex items-center justify-between text-xs text-[var(--text)]",children:[p.jsx("span",{className:"text-[var(--text-muted)]",children:"Version"}),p.jsxs("span",{className:"font-mono text-[var(--text-muted)]",children:["v","2.12.0"]})]})]}),p.jsx("div",{className:"h-px bg-[var(--border)]"}),p.jsxs("div",{className:"px-3 py-2 flex items-center justify-between gap-2",children:[p.jsx("span",{id:"theme-label",className:"text-xs text-[var(--text-muted)]",children:"Theme"}),p.jsx("div",{className:"seg seg-sm",role:"radiogroup","aria-labelledby":"theme-label",children:Dg.map(h=>p.jsx("button",{type:"button",role:"radio","aria-checked":i===h.value,className:`seg-btn${i===h.value?" seg-btn-active":""}`,onClick:()=>o(h.value),children:h.label},h.value))})]}),p.jsx("div",{className:"h-px bg-[var(--border)]"}),p.jsxs("button",{type:"button",onClick:()=>{l(!1),e("/profile")},className:"w-full flex items-center gap-2 px-3 py-2 text-xs text-[var(--text)] hover:bg-[var(--bg)] text-left",children:[p.jsx(yy,{className:"h-3.5 w-3.5 text-[var(--text-dim)]"}),"Profile"]}),t!=null&&t.authDisabled?p.jsx("p",{className:"px-3 py-2 text-xs text-[var(--text-muted)]",children:"Sign-in is off on this server."}):p.jsxs("button",{type:"button",onClick:()=>{l(!1),n()},className:"w-full flex items-center gap-2 px-3 py-2 text-xs text-[var(--red)] hover:bg-[var(--bg)] text-left",children:[p.jsx(Jm,{className:"h-3.5 w-3.5"}),"Logout"]})]})]})]})]})})};class $g extends y.Component{constructor(){super(...arguments),this.state={hasError:!1},this.handleReset=()=>{this.setState({hasError:!1}),window.location.reload()}}static getDerivedStateFromError(t){return{hasError:!0,error:t}}componentDidCatch(t,n){console.error("Uncaught error:",t,n)}render(){return this.state.hasError?this.props.fallback||p.jsxs("div",{className:"error-boundary-container",style:{padding:"4rem 2rem",textAlign:"center",display:"flex",flexDirection:"column",alignItems:"center",gap:"1.5rem",color:"var(--text)",background:"var(--bg-main)",minHeight:"100vh"},children:[p.jsx("div",{style:{color:"var(--accent-red)"},children:p.jsx(cy,{size:64})}),p.jsx("h2",{style:{fontSize:"2rem",fontWeight:700,margin:0},children:"Component exception detected"}),p.jsx("p",{style:{color:"var(--text-muted)",maxWidth:"500px",lineHeight:1.6},children:"An unexpected error occurred while rendering this section. Xenon's isolation engine has contained the fault to prevent a total system crash."}),this.state.error&&p.jsx("pre",{style:{background:"rgb(var(--rgb-black) / 0.3)",padding:"1rem",borderRadius:"8px",fontSize:"0.8rem",color:"var(--accent-red)",maxWidth:"80%",overflowX:"auto"},children:this.state.error.message}),p.jsxs("button",{onClick:this.handleReset,style:{background:"var(--color-accent)",color:"var(--secondary)",border:"none",padding:"0.75rem 2rem",borderRadius:"8px",fontWeight:700,cursor:"pointer",display:"flex",alignItems:"center",gap:"0.5rem",transition:"all 0.2s"},onMouseOver:t=>t.currentTarget.style.transform="translateY(-2px)",onMouseOut:t=>t.currentTarget.style.transform="translateY(0)",children:[p.jsx(Lf,{size:18}),"Reload application"]})]}):this.props.children}}const Ug=y.lazy(()=>V(()=>import("./overview-Cxe8aQ7C.js"),__vite__mapDeps([0,1,2,3,4,5,6,7]))),pu=y.lazy(()=>V(()=>import("./device-explorer-CoPR8DW3.js"),__vite__mapDeps([8,6,7,9,10,5,11,1,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,3,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,2,46,47,48,49,50,51]))),hu=y.lazy(()=>V(()=>import("./builds-page-JkzWKRpU.js"),__vite__mapDeps([52,53,54,40,13,41,32,12,14,43,1,37,36,33,3,4,55,6,7,15,16,38,39]))),Bg=y.lazy(()=>V(()=>import("./session-detail-page-BjLaJy8z.js"),__vite__mapDeps([56,53,54,45,33,1,9,10,37,36,55,27,57,2,58,59,38,39,5,60,43,30,31,21,18,22,61]))),zg=y.lazy(()=>V(()=>import("./runbook-page-mnsxgS1d.js"),__vite__mapDeps([62,45,63]))),bg=y.lazy(()=>V(()=>import("./apps-DIbcGVlU.js"),__vite__mapDeps([64,54,12,13,14,6,7,15,16,21,18,22,23,24,44,19,27,35,43,47,65]))),Fg=y.lazy(()=>V(()=>import("./webhook-settings-BMzyUcx5.js"),__vite__mapDeps([66,23,24,6,7,47,26,37,36,35,5,67,68])).then(e=>({default:e.WebhookSettings}))),Vg=y.lazy(()=>V(()=>import("./settings-B6cpMhsx.js"),__vite__mapDeps([69,70,12,13,14,71,21,18,22,6,7,36,25,34,19,5,72,57,68])).then(e=>({default:e.Settings}))),qg=y.lazy(()=>V(()=>import("./ai-settings-G9SymiPH.js"),__vite__mapDeps([73,70,12,13,14,71,6,7,48,36,5,68])).then(e=>({default:e.AISettings}))),Wg=y.lazy(()=>V(()=>import("./maintenance-settings-DcRmTLS6.js"),__vite__mapDeps([74,70,12,13,14,71,6,7,47,19,72,68])).then(e=>({default:e.MaintenanceSettings}))),Hg=y.lazy(()=>V(()=>import("./api-keys-CrGlbfn-.js"),__vite__mapDeps([75,54,30,31,23,24,6,7,21,18,22,12,13,14,40,41,15,16,26,47,19,27,68])).then(e=>({default:e.ApiKeys}))),Kg=y.lazy(()=>V(()=>import("./teams-uiiG4hZM.js"),__vite__mapDeps([76,54,30,31,23,24,6,7,21,18,22,12,13,14,40,41,15,16,77,26,45,47,68])).then(e=>({default:e.Teams}))),Qg=y.lazy(()=>V(()=>import("./selector-health-page-BdJb_x5L.js"),__vite__mapDeps([78,6,7,28,29,12,13,14,55,58,59,38,39,40,41,15,16,79,1,21,18,22,19,27]))),Gg=y.lazy(()=>V(()=>import("./selector-detail-redirect-CcI2j_Su.js"),__vite__mapDeps([80,79]))),Yg=y.lazy(()=>V(()=>import("./DeviceMosaicView-Ccc-pOls.js"),__vite__mapDeps([81,11,1,36,46,60,26,28,29,82,43,12,13,14,25,6,7]))),Xg=y.lazy(()=>V(()=>import("./profile-page--dkDiKbr.js"),__vite__mapDeps([83,6,7,54,15,13,16,27,47]))),Jg=y.lazy(()=>V(()=>import("./users-BDh1xjad.js"),__vite__mapDeps([84,77,54,6,7,12,13,14,40,41,15,16,26,47]))),Zg=y.lazy(()=>V(()=>import("./RecordingsPage-7kM1rB3i.js"),__vite__mapDeps([85,6,7,30,31,12,13,14,38,39,40,41,49,17,18,19,20,26,50,82,86,87]))),ev=y.lazy(()=>V(()=>import("./RecordingPage-Bwyf3WMl.js"),__vite__mapDeps([88,82,6,7,12,13,14,38,39,21,18,22,17,19,20,46,86,87,45,47,42,43]))),tv=()=>p.jsxs("div",{className:"flex items-center justify-center gap-2 h-full text-xs text-[var(--text-dim)]",children:[p.jsx(Lf,{className:"animate-spin",size:14}),p.jsx("span",{children:"Hydrating view…"})]}),nv=()=>p.jsx($g,{children:p.jsx(y.Suspense,{fallback:p.jsx(tv,{}),children:p.jsxs(Nf,{children:[p.jsx($,{path:"/",element:p.jsx(Wt,{to:"/overview",replace:!0})}),p.jsx($,{path:"/overview",element:p.jsx(Ug,{})}),p.jsx($,{path:"/devices",element:p.jsx(pu,{})}),p.jsx($,{path:"/devices/:udid/control/:tab?",element:p.jsx(pu,{})}),p.jsx($,{path:"/apps",element:p.jsx(bg,{})}),p.jsx($,{path:"/sessions",element:p.jsx(Wt,{to:"/builds",replace:!0})}),p.jsx($,{path:"/sessions/*",element:p.jsx(Wt,{to:"/builds",replace:!0})}),p.jsx($,{path:"/builds",element:p.jsx(hu,{})}),p.jsx($,{path:"/builds/:buildId",element:p.jsx(hu,{})}),p.jsx($,{path:"/builds/:buildId/sessions/:sessionId",element:p.jsx(Bg,{})}),p.jsx($,{path:"/notifications",element:p.jsx(Fg,{})}),p.jsx($,{path:"/settings",element:p.jsx(Vg,{})}),p.jsx($,{path:"/ai-settings",element:p.jsx(qg,{})}),p.jsx($,{path:"/maintenance",element:p.jsx(Wg,{})}),p.jsx($,{path:"/api-keys",element:p.jsx(Hg,{})}),p.jsx($,{path:"/teams",element:p.jsx(Kg,{})}),p.jsx($,{path:"/users",element:p.jsx(Jg,{})}),p.jsx($,{path:"/selector-health",element:p.jsx(Qg,{})}),p.jsx($,{path:"/selector-health/detail",element:p.jsx(Gg,{})}),p.jsx($,{path:"/devices/live",element:p.jsx(Yg,{})}),p.jsx($,{path:"/recordings",element:p.jsx(Zg,{})}),p.jsx($,{path:"/recordings/:groupId",element:p.jsx(ev,{})}),p.jsx($,{path:"/runbooks/:category",element:p.jsx(zg,{})}),p.jsx($,{path:"/profile",element:p.jsx(Xg,{})}),p.jsx($,{path:"*",element:p.jsx(Wt,{to:"/overview",replace:!0})})]})})});let mr=null;function mu(e){mr=e}const rv=new Set(["device_held_by_another_user","device_in_use_by_session"]),iv=new Set(["not_available_through_hub","not_available_for_cloud_phone"]);function ov(e){return!e||typeof e!="object"?!1:rv.has(e.error??"")}const sv=5e3,yu=new Map;function gu(e){if(!mr)return;const t=Date.now(),n=yu.get(e)??0;t-n<sv||(yu.set(e,t),mr(e,"error"))}class ed extends Error{constructor(t,n,r){super(t),this.status=n,this.body=r,this.name="ApiError"}}async function Eo(e,t){if(e.status===403){const n=await e.clone().json().catch(()=>({})),r=n&&(n.error||n.message)||"You do not have permission for this action.";mr&&mr(r,"error")}if(e.status===409){const n=await e.clone().json().catch(()=>({}));ov(n)&&gu(n.message||"This device is in use by another user.")}if(e.status===501){const n=await e.clone().json().catch(()=>({}));iv.has(n==null?void 0:n.error)&&n.message&&gu(n.message)}if(e.status===204||e.status===205)return null;if(t&&(e.status<200||e.status>=300)){const n=await e.json().catch(()=>null),r=n&&typeof n=="object"&&(n.error||n.message)||`Request failed (${e.status})`;throw new ed(String(r),e.status,n)}return e.json()}class lv{makeGETRequest(t){return fetch(this.formatUrl(t)).then(n=>Eo(n,!1))}makePOSTRequest(t,n,r,i={},o={}){return fetch(this.formatUrl(t),{method:"POST",body:JSON.stringify(r||{}),headers:{"Content-Type":"application/json"},...i}).then(s=>Eo(s,!o.resolveErrors))}makeDELETERequest(t,n={}){return fetch(this.formatUrl(t),{method:"DELETE"}).then(r=>Eo(r,!n.resolveErrors))}formatUrl(t){return`/xenon/api${t}`}}const R=new lv;function Bv(e){return e instanceof ed?`The server rejected the change: ${e.message}`:"Couldn't reach the Xenon server. Check your connection and try again."}const td=y.createContext(void 0),zv=()=>{const e=y.useContext(td);if(!e)throw new Error("useToast must be used within a ToastProvider");return e},av=({children:e})=>{const[t,n]=y.useState([]),r=y.useCallback(o=>{n(s=>s.filter(l=>l.id!==o))},[]),i=y.useCallback((o,s="info",l=4e3,a)=>{const u=Math.random().toString(36).substring(2,9);return n(m=>[...m,{id:u,message:o,type:s,duration:l,action:a}]),s!=="loading"&&l>0&&setTimeout(()=>{r(u)},l),u},[r]);return y.useEffect(()=>(mu((o,s="info")=>i(o,s)),()=>mu(null)),[i]),p.jsxs(td.Provider,{value:{toast:i,removeToast:r},children:[e,p.jsx("div",{className:"toast-container","aria-live":"polite","aria-atomic":"true",role:"status",children:t.map(o=>p.jsxs("div",{className:`toast-item toast-${o.type} animate-slide-in`,children:[p.jsxs("div",{className:"toast-icon",children:[o.type==="success"&&p.jsx(Um,{size:18}),o.type==="error"&&p.jsx(Mm,{size:18}),o.type==="info"&&p.jsx(qm,{size:18}),o.type==="loading"&&p.jsx(Ym,{size:18,className:"animate-spin"})]}),p.jsx("div",{className:"toast-message",children:o.message}),o.action&&p.jsx("button",{className:"toast-action",onClick:()=>{var s;r(o.id),(s=o.action)==null||s.onClick()},children:o.action.label}),p.jsx("button",{className:"toast-close",onClick:()=>r(o.id),"aria-label":`Close ${o.type} notification`,children:p.jsx(ky,{size:14})})]},o.id))})]})},uv=[{id:"overview",label:"Overview",icon:Qm,path:"/overview"},{id:"devices",label:"Devices",icon:ay,path:"/devices"},{id:"live-devices",label:"Live devices",icon:dy,path:"/devices/live"},{id:"recordings",label:"Recordings",icon:zm,path:"/recordings"},{id:"apps",label:"Apps",icon:Tm,path:"/apps"},{id:"sessions",label:"Sessions",icon:ey,path:"/builds"},{id:"selector-health",label:"Selector health",icon:Fm,path:"/selector-health"},{id:"notifications",label:"Notifications",icon:Pm,path:"/notifications"},{id:"settings",label:"Settings",icon:iy,path:"/settings",minRole:"ADMIN"},{id:"ai",label:"AI engine",icon:jm,path:"/ai-settings",minRole:"ADMIN"},{id:"maintenance",label:"Maintenance",icon:sy,path:"/maintenance",minRole:"ADMIN"},{id:"teams",label:"Teams",icon:vy,path:"/teams",minRole:"ADMIN"},{id:"users",label:"Users",icon:hy,path:"/users",minRole:"ADMIN"},{id:"apikeys",label:"API keys",icon:Hm,path:"/api-keys",minRole:"ADMIN"}],vu={SUPER_ADMIN:3,ADMIN:2,MEMBER:1};function cv(e,t){return t?(e?vu[e]??0:0)>=vu[t]:!0}const fv=()=>{const e=yn(),t=We(),{me:n}=El(),r=uv.filter(l=>cv(n==null?void 0:n.role,l.minRole)),i=t.pathname.replace(/\/$/,"")||"/",o=r.filter(l=>i===l.path||i.startsWith(l.path+"/")).sort((l,a)=>a.path.length-l.path.length)[0],s=l=>(o==null?void 0:o.path)===l;return p.jsxs("aside",{className:"fixed inset-y-0 left-0 z-30 w-14 border-r border-[var(--border)] bg-[var(--surface)] flex flex-col items-center py-3",children:[p.jsx("nav",{className:"flex-1 flex flex-col gap-1 w-full items-center",children:r.map(l=>{const a=l.icon,u=s(l.path);return p.jsxs("button",{type:"button",onClick:()=>e(l.path),className:`group relative w-full flex justify-center py-2.5 mx-1 rounded-md transition-colors ${u?"bg-[var(--surface-2)]":"hover:bg-[var(--surface-2)]/60"}`,"aria-label":l.label,"aria-current":u?"page":void 0,children:[p.jsx("span",{className:`absolute left-0 top-1 bottom-1 w-[3px] rounded-r transition-all ${u?"bg-[var(--color-accent)]":"bg-transparent"}`}),p.jsx(a,{className:`h-[18px] w-[18px] transition-colors ${u?"text-[var(--color-accent)]":"text-[var(--text-dim)] group-hover:text-[var(--text)]"}`,strokeWidth:u?2.25:2}),p.jsx("span",{className:"pointer-events-none absolute left-full ml-2 top-1/2 -translate-y-1/2 whitespace-nowrap rounded-md bg-[var(--surface-2)] border border-[var(--border-strong)] px-2 py-1 text-xs text-[var(--text)] opacity-0 group-hover:opacity-100 transition-opacity z-50 shadow-lg",children:l.label})]},l.id)})}),p.jsxs("button",{type:"button",className:"group relative w-full flex justify-center py-2.5 mt-2","aria-label":"API docs",onClick:()=>window.open(window.location.origin+"/xenon/api-docs","_blank"),children:[p.jsx(Om,{className:"h-[18px] w-[18px] text-[var(--text-dim)] group-hover:text-[var(--text)] transition-colors"}),p.jsx("span",{className:"pointer-events-none absolute left-full ml-2 top-1/2 -translate-y-1/2 whitespace-nowrap rounded-md bg-[var(--surface-2)] border border-[var(--border-strong)] px-2 py-1 text-xs text-[var(--text)] opacity-0 group-hover:opacity-100 transition-opacity z-50 shadow-lg",children:"API docs"})]})]})};class An{static getDevices(){return R.makeGETRequest(`/device?t=${Date.now()}`)}static getPendingSessionsCount(){return R.makeGETRequest("/queue/length")}static getPendingSessions(){return R.makeGETRequest("/queue")}static getQueueSummary(){return R.makeGETRequest("/queue/summary")}static getQueueStatus(t){return R.makeGETRequest(`/queue/status/${t}`)}static getBuilds(){return R.makeGETRequest("/build")}static getSessions(t={}){var i;let r=`/session?t=${Date.now()}`;return t.buildId&&(r+=`&buildId=${encodeURIComponent(t.buildId)}`),t.since&&(r+=`&since=${encodeURIComponent(t.since)}`),t.limit&&(r+=`&limit=${t.limit}`),t.before&&(r+=`&before=${encodeURIComponent(t.before)}`),t.beforeId&&(r+=`&beforeId=${encodeURIComponent(t.beforeId)}`),t.query&&(r+=`&query=${encodeURIComponent(t.query)}`),t.status&&(r+=`&status=${encodeURIComponent(t.status)}`),t.platform&&(r+=`&platform=${encodeURIComponent(t.platform)}`),(i=t.ids)!=null&&i.length&&(r+=`&ids=${t.ids.map(encodeURIComponent).join(",")}`),R.makeGETRequest(r)}static getSessionSummary(t={}){let n=`/session-summary?t=${Date.now()}`;return t.since&&(n+=`&since=${encodeURIComponent(t.since)}`),t.buildId&&(n+=`&buildId=${encodeURIComponent(t.buildId)}`),R.makeGETRequest(n)}static getSession(t){return R.makeGETRequest(`/session/${t}`)}static getSessionLogs(t){return R.makeGETRequest(`/session/${t}/session_log`)}static getDeviceLogs(t){return R.makeGETRequest(`/session/${t}/logs/device`)}static getDebugLogs(t){return R.makeGETRequest(`/session/${t}/logs/debug`)}static getProfilingData(t){return R.makeGETRequest(`/session/${t}/profiling`)}static getSessionMetrics(t){return R.makeGETRequest(`/session/${t}/metrics`)}static omniScan(t){return R.makeGETRequest(`/session/${t}/xenon/omni-scan`)}static omniScanControl(t){return R.makeGETRequest(`/control/${t}/omni-scan`)}static testAiLocator(t,n,r){return R.makePOSTRequest(`/session/${t}/xenon/test-locator`,{},{strategy:n,selector:r})}static getDisplayState(t){return R.makeGETRequest(`/control/${t}/display`)}static getAppiumSession(t){return R.makeGETRequest(`/control/${t}/appium-session`)}static async verifyLocator(t,n,r){const i=t.startsWith("/")?t:`/${t}`,s=await(await fetch(`${i}/session/${n}/xenon/verify-locator`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)})).json().catch(()=>({}));return(s==null?void 0:s.value)??s}static testAiLocatorControl(t,n,r){return R.makePOSTRequest(`/control/${t}/test-locator`,{},{strategy:n,selector:r})}static blockDevice(t,n){return R.makePOSTRequest("/block",{},{udid:t,host:n})}static unblockDevice(t,n){return R.makePOSTRequest("/unblock",{},{udid:t,host:n})}static updateDeviceTags(t,n,r){return R.makePOSTRequest("/device/tags",{},{udid:t,host:n,tags:r})}static async listTeams(){const t=await fetch("/xenon/api/teams",{credentials:"include"});if(!t.ok)throw new Error(`listTeams failed (${t.status})`);return(await t.json()).map(r=>({id:r.id,name:r.name}))}static async setDeviceTeam(t,n){const r=await fetch(`/xenon/api/grid/device/${encodeURIComponent(t)}/team`,{method:"PUT",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({teamId:n})});if(!r.ok&&r.status!==204){const i=await r.json().catch(()=>({}));throw new Error(i.error||`setDeviceTeam failed (${r.status})`)}}static getSessionLiveVideoUrl(t){return R.formatUrl(`/session/${t}/live_video`)}static getReservations(){return R.makeGETRequest("/reservation")}static reserveDevice(t,n,r,i,o){return R.makePOSTRequest("/reservation",{},{udid:t,host:n,reservedBy:r,duration:i,reason:o},{},{resolveErrors:!0})}static releaseReservation(t,n){return R.makeDELETERequest(`/reservation/${t}/${encodeURIComponent(n)}`)}static extendReservation(t,n,r){return R.makePOSTRequest(`/reservation/${t}/${encodeURIComponent(n)}/extend`,{},{duration:r})}static getAssetUrl(t){const n=(t??"").replace(/^[\\/]+/,"").split(/[\\/]/);if(n.length!==3||n.some(s=>!s))return"";const[r,i,o]=n;return["screenshots","video","performance"].includes(i)?`/xenon/api/session/${encodeURIComponent(r)}/asset/${i}/${encodeURIComponent(o)}`:""}static tap(t,n,r){return R.makePOSTRequest(`/control/${t}/tap`,{},{x:n,y:r})}static swipe(t,n,r,i,o){return R.makePOSTRequest(`/control/${t}/swipe`,{},{x:n,y:r,endX:i,endY:o})}static typeText(t,n){return R.makePOSTRequest(`/control/${t}/text`,{},{text:n})}static pressKey(t,n){return R.makePOSTRequest(`/control/${t}/keyevent`,{},{keyCode:n})}static getClipboard(t){return R.makeGETRequest(`/control/${t}/clipboard`)}static setClipboard(t,n){return R.makePOSTRequest(`/control/${t}/clipboard`,{},{content:n})}static getScreenshot(t){return R.makeGETRequest(`/control/${t}/screenshot`)}static touchAndHold(t,n,r,i){return R.makePOSTRequest(`/control/${t}/touchAndHold`,{},{x:n,y:r,duration:i})}static lock(t){return R.makePOSTRequest(`/control/${t}/lock`,{},{})}static unlock(t){return R.makePOSTRequest(`/control/${t}/unlock`,{},{})}static installApp(t,n){return R.makePOSTRequest(`/control/${t}/install`,{},{appPath:n})}static startStream(t){return R.makePOSTRequest(`/control/${t}/stream/start`,{},{},{},{resolveErrors:!0})}static stopStream(t){return R.makePOSTRequest(`/control/${t}/stream/stop`,{},{},{keepalive:!0})}static leaveStream(t){return R.makePOSTRequest(`/control/${t}/stream/leave`,{},{},{keepalive:!0})}static uninstallApp(t,n){return R.makePOSTRequest(`/control/${t}/uninstall`,{},{bundleId:n})}static uploadAndInstallApp(t,n){const r=new FormData;return r.append("app",n),fetch(`/xenon/api/control/${t}/upload-install`,{method:"POST",body:r}).then(i=>i.json())}static listApps(t){return R.makeGETRequest(`/control/${t}/apps`)}static getLogs(t){return R.makeGETRequest(`/control/${t}/logs`)}static getApps(){return R.makeGETRequest("/apps")}static uploadApp(t,n=null){const r=new FormData;return r.append("app",t),n&&r.append("teamId",n),fetch("/xenon/api/apps/upload",{method:"POST",body:r}).then(i=>i.json())}static async setAppTeam(t,n){const r=await fetch(`/xenon/api/apps/${encodeURIComponent(t)}/team`,{method:"PUT",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({teamId:n})});if(!r.ok){const i=await r.json().catch(()=>({}));throw new Error(i.error||`setAppTeam failed (${r.status})`)}}static deleteApp(t){return R.makeDELETERequest(`/apps/${t}`)}static installRepositoryApp(t,n){return R.makePOSTRequest(`/control/${t}/install-repository-app`,{},{appId:n},{},{resolveErrors:!0})}static executeShell(t,n){return R.makePOSTRequest(`/control/${t}/shell`,{},{command:n},{},{resolveErrors:!0})}static getInspectorSnapshot(t){return R.makeGETRequest(`/control/${t}/inspector/snapshot`)}static getWebhookConfigs(){return R.makeGETRequest("/webhook")}static addWebhookConfig(t,n,r,i){return R.makePOSTRequest("/webhook",{},{url:t,events:n,type:r,payloadTemplate:i})}static deleteWebhookConfig(t){return R.makeDELETERequest(`/webhook/${t}`)}static testWebhook(t,n){return R.makePOSTRequest("/webhook/test",{},{url:t,type:n})}static getGlobalConfig(){return R.makeGETRequest("/config")}static updateGlobalConfig(t){return R.makePOSTRequest("/config",{},t)}static testAIConfig(t){return R.makePOSTRequest("/config/test-ai",{},t,{},{resolveErrors:!0})}static resetMetrics(){return R.makePOSTRequest("/config/reset-metrics",{},{})}static getRecentHealingEvents(t=50){return R.makeGETRequest(`/healing/events?limit=${t}&t=${Date.now()}`)}static getHealingSummary(t=30,n=0){return R.makeGETRequest(`/healing/summary?windowDays=${t}&tz=${n}&t=${Date.now()}`)}static getHealingSelectors(t){const n=new URLSearchParams({tab:t.tab,days:String(t.days),sort:t.sort??"heals",page:String(t.page??1),pageSize:String(t.pageSize??50),t:String(Date.now())});return t.q&&n.set("q",t.q),t.platform&&n.set("platform",t.platform),t.method&&n.set("method",t.method),R.makeGETRequest(`/healing/selectors?${n.toString()}`)}static async getSelectorPanel(t,n,r,i){const o=new URLSearchParams({strategy:t,selector:n,days:String(r),tz:String(i),t:String(Date.now())}),s=await fetch(`/xenon/api/healing/selectors/detail?${o.toString()}`,{credentials:"include"}),l=await s.json().catch(()=>null);return{status:s.status,body:l}}static async postSelectorStateAction(t){const n=await fetch("/xenon/api/healing/selector/state",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok){const r=await n.json().catch(()=>({})),i=new Error(r.error??`Selector state action failed (${n.status})`);throw i.status=n.status,i.currentStatus=r.currentStatus??null,i}return n.json()}static sendHealingDigest(t={}){return R.makePOSTRequest("/healing/digest/send",{},t)}static async exportBuild(t,n,r){const i=await fetch(`/xenon/api/build/${encodeURIComponent(t)}/export`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({format:n,...r?{sessionIds:r}:{}})});if(!i.ok){const u=await i.text().catch(()=>i.statusText);throw new Error(`Export failed (${i.status}): ${u||i.statusText}`)}const o=i.headers.get("Content-Disposition")||"",s=/filename="?([^";]+)"?/.exec(o),l=s?s[1]:`build-${t}-sessions.${n}`;return{blob:await i.blob(),filename:l}}}function dv(e){if(!(e instanceof HTMLElement))return!1;if(e.isContentEditable)return!0;const t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||t==="SELECT"}function pv(){const[e,t]=y.useState(!1);return y.useEffect(()=>{const n=i=>{(i.metaKey||i.ctrlKey)&&i.key.toLowerCase()==="k"&&!dv(i.target)&&(i.preventDefault(),t(o=>!o)),i.key==="Escape"&&t(!1)},r=()=>t(!0);return window.addEventListener("keydown",n),window.addEventListener("xenon.open-command-palette",r),()=>{window.removeEventListener("keydown",n),window.removeEventListener("xenon.open-command-palette",r)}},[]),{open:e,setOpen:t}}function wu(e,t){if(!e)return 0;const n=e.toLowerCase(),r=t.toLowerCase();if(r===n)return 1e4;if(r.startsWith(n))return 5e3-(r.length-n.length);let i=0,o=0,s=0;for(let l=0;l<n.length;l++){const a=n[l],u=r.indexOf(a,i);if(u===-1)return 0;u===i?(s+=1,o+=20+s*5):(s=0,o+=10-Math.min(u-i,10)),i=u+1}return Math.max(o,1)}const ku=[{id:"nav:overview",kind:"nav",label:"Overview",path:"/overview"},{id:"nav:devices",kind:"nav",label:"Devices",path:"/devices"},{id:"nav:live",kind:"nav",label:"Live devices",path:"/devices/live"},{id:"nav:builds",kind:"nav",label:"Sessions",path:"/builds"},{id:"nav:apps",kind:"nav",label:"Apps",path:"/apps"},{id:"nav:selector-health",kind:"nav",label:"Selector health",path:"/selector-health"},{id:"nav:notifications",kind:"nav",label:"Notifications",path:"/notifications"},{id:"nav:settings",kind:"nav",label:"Settings",path:"/settings"},{id:"nav:ai-settings",kind:"nav",label:"AI engine",path:"/ai-settings"},{id:"nav:maintenance",kind:"nav",label:"Maintenance",path:"/maintenance"},{id:"nav:teams",kind:"nav",label:"Teams",path:"/teams"},{id:"nav:api-keys",kind:"nav",label:"API keys",path:"/api-keys"},{id:"nav:users",kind:"nav",label:"Users",path:"/users"},{id:"nav:profile",kind:"nav",label:"Profile",path:"/profile"}];class hv{constructor(){this.devices=[],this.builds=[],this.sessions=[],this.teams=[],this.keys=[],this.apps=[]}setDevices(t){this.devices=t.map(n=>({id:`device:${n.udid}`,kind:"device",label:n.name||n.udid,sub:n.udid,path:`/devices/${n.udid}/control`}))}setBuilds(t){this.builds=t.map(n=>({id:`build:${n.id}`,kind:"build",label:n.name||n.id,sub:typeof n.sessionCount=="number"?`${n.sessionCount} session${n.sessionCount===1?"":"s"}${n.failedCount?` · ${n.failedCount} failed`:""}`:n.id,path:`/builds/${encodeURIComponent(n.id)}`}))}setSessions(t){this.sessions=t.map(n=>({id:`session:${n.id}`,kind:"session",label:n.name||n.id,sub:n.id,path:`/builds?session=${encodeURIComponent(n.id)}`}))}setTeams(t){this.teams=t.map(n=>({id:`team:${n.id}`,kind:"team",label:n.name||n.id,sub:n.id,path:`/teams?team=${encodeURIComponent(n.id)}`}))}setKeys(t){this.keys=t.map(n=>({id:`key:${n.id}`,kind:"key",label:n.name||n.id,sub:n.id,path:`/api-keys?key=${encodeURIComponent(n.id)}`}))}setApps(t){this.apps=t.map(n=>({id:`app:${n.id}`,kind:"app",label:n.name||n.id,sub:n.id,path:`/apps?app=${encodeURIComponent(n.id)}`}))}search(t,n=8){return t.trim()?[...ku,...this.devices,...this.builds,...this.sessions,...this.teams,...this.keys,...this.apps].map(i=>{const o=wu(t,i.label),s=i.sub?wu(t,i.sub):0;return{it:i,score:Math.max(o,s)}}).filter(i=>i.score>0).sort((i,o)=>o.score-i.score).slice(0,n).map(i=>i.it):ku.slice(0,n)}}const mv={nav:"Navigation",device:"Devices",build:"Builds",session:"Running sessions",team:"Teams",key:"API keys",app:"Apps"},yv=["nav","device","build","session","team","key","app"],gv=()=>{const{open:e,setOpen:t}=pv(),[n,r]=y.useState(""),[i,o]=y.useState(0),s=yn(),l=y.useRef(new hv),a=y.useRef(null);y.useEffect(()=>{if(!e)return;Promise.all([An.getDevices().catch(()=>[]),An.getSessions().catch(()=>[]),An.getApps().catch(()=>[]),An.listTeams().catch(()=>[]),An.getBuilds().catch(()=>[])]).then(([k,c,f,d,g])=>{Array.isArray(k)&&l.current.setDevices(k),Array.isArray(g)&&l.current.setBuilds(g),Array.isArray(c)&&l.current.setSessions(c),Array.isArray(f)&&l.current.setApps(f),Array.isArray(d)&&l.current.setTeams(d)});const x=setTimeout(()=>{var k;return(k=a.current)==null?void 0:k.focus()},0);return()=>clearTimeout(x)},[e]),y.useEffect(()=>{e||(r(""),o(0))},[e]);const u=y.useMemo(()=>l.current.search(n,8),[n,e]),m=y.useMemo(()=>{const x=new Map;return u.forEach(k=>{const c=x.get(k.kind)||[];c.push(k),x.set(k.kind,c)}),x},[u]),v=y.useCallback(x=>{s(x.path),t(!1)},[s,t]),h=x=>{x.key==="ArrowDown"?(x.preventDefault(),o(k=>Math.min(k+1,Math.max(u.length-1,0)))):x.key==="ArrowUp"?(x.preventDefault(),o(k=>Math.max(k-1,0))):x.key==="Enter"&&(x.preventDefault(),u[i]&&v(u[i]))};if(!e)return null;let E=-1;return p.jsx("div",{className:"cp-overlay",onClick:()=>t(!1),children:p.jsxs("div",{className:"cp",role:"dialog","aria-modal":!0,"aria-label":"Command palette",onClick:x=>x.stopPropagation(),children:[p.jsxs("div",{className:"cp-input-row",children:[p.jsx(jf,{size:14}),p.jsx("input",{ref:a,className:"cp-input",placeholder:"Search devices, sessions, settings…",value:n,onChange:x=>{r(x.target.value),o(0)},onKeyDown:h}),p.jsx("span",{className:"cp-esc",children:"ESC"})]}),p.jsxs("div",{className:"cp-results",children:[u.length===0&&p.jsx("div",{className:"cp-empty",children:"No results."}),yv.filter(x=>m.has(x)).map(x=>p.jsxs("div",{className:"cp-group",children:[p.jsx("div",{className:"cp-group-head",children:mv[x]}),m.get(x).map(k=>{E+=1;const c=E===i;return p.jsxs("button",{type:"button",className:`cp-item${c?" cp-item-active":""}`,onMouseEnter:()=>{o(E)},onClick:()=>v(k),children:[p.jsx("span",{className:"cp-item-label",children:k.label}),k.sub&&p.jsx("span",{className:"cp-item-sub",children:k.sub})]},k.id)})]},x))]})]})})};function vv({children:e}){const{loading:t,me:n}=El(),r=We();if(t)return p.jsx("div",{style:{padding:40,textAlign:"center",color:"var(--text-dim)"},children:"Loading…"});if(!n){const i=encodeURIComponent(r.pathname+r.search),o=Ny()?"&reason=expired":"";return p.jsx(Wt,{to:`/login?next=${i}${o}`,replace:!0})}return p.jsx(p.Fragment,{children:e})}const xu="Xenon",wv={"/overview":"Overview","/devices":"Devices","/devices/live":"Live devices","/recordings":"Recordings","/apps":"Apps","/builds":"Sessions","/selector-health":"Selector health","/selector-health/detail":"Selector health","/notifications":"Notifications","/settings":"Settings","/ai-settings":"AI engine","/maintenance":"Maintenance","/teams":"Teams","/users":"Users","/api-keys":"API keys","/profile":"Profile","/login":"Sign in","/forgot-password":"Forgot password","/reset-password":"Reset password"},nd=new Map;function bv(e,t){t&&nd.set(e,t)}function kv(e){const t=e.replace(/\/+$/,"")||"/";let n=wv[t];if(!n){let r;if(r=t.match(/^\/devices\/([^/]+)\/control/)){const i=decodeURIComponent(r[1]);n=`${nd.get(i)||i} · Device`}else/^\/builds\/[^/]+\/sessions\//.test(t)?n="Session":/^\/builds\/[^/]+$/.test(t)?n="Sessions":/^\/recordings\/[^/]+$/.test(t)?n="Recording":(r=t.match(/^\/runbooks\/([^/]+)/))?n=`Runbook · ${decodeURIComponent(r[1])}`:t.startsWith("/reset-password/")&&(n="Reset password")}return n?`${n} · ${xu}`:xu}function xv(){const{pathname:e}=We();return y.useEffect(()=>{document.title=kv(e)},[e]),null}const Ev=y.lazy(()=>V(()=>import("./login-BJ8a7yVD.js"),__vite__mapDeps([89,13,90,91,61,48,25,2]))),_v=y.lazy(()=>V(()=>import("./forgot-password-B8WqMqBT.js"),__vite__mapDeps([92,90,91,61]))),Eu=y.lazy(()=>V(()=>import("./reset-password-KYWlfjia.js"),__vite__mapDeps([93,91,61]))),Sv=y.lazy(()=>V(()=>import("./ApiKeyGate-BThVlj_j.js"),[]).then(e=>({default:e.ApiKeyGate})));function Cv(){return p.jsx(av,{children:p.jsxs("div",{className:"min-h-screen w-full bg-[var(--bg)] text-[var(--text)]",children:[p.jsx(fv,{}),p.jsx(Mg,{}),p.jsx("main",{className:"pl-14 pt-14 h-screen overflow-y-auto",children:p.jsx(nv,{})}),p.jsx(gv,{})]})})}function Tv(){return p.jsxs(ym,{basename:"/xenon",children:[p.jsx(xv,{}),p.jsx(Oy,{children:p.jsx(y.Suspense,{fallback:p.jsx("div",{style:{padding:40},children:"Loading…"}),children:p.jsxs(Nf,{children:[p.jsx($,{path:"/login",element:p.jsx(Ev,{})}),p.jsx($,{path:"/forgot-password",element:p.jsx(_v,{})}),p.jsx($,{path:"/reset-password",element:p.jsx(Eu,{})}),p.jsx($,{path:"/reset-password/:token",element:p.jsx(Eu,{})}),p.jsx($,{path:"/api-key-gate",element:p.jsx(Sv,{children:p.jsx(Wt,{to:"/overview",replace:!0})})}),p.jsx($,{path:"*",element:p.jsx(vv,{children:p.jsx(Cv,{})})})]})})})]})}wf.render(p.jsx(y.StrictMode,{children:p.jsx(Tv,{})}),document.getElementById("root"));export{Av as $,Lf as A,$v as B,Mm as C,bv as D,kv as E,Ov as F,_u as G,Om as H,qm as I,Tm as J,Pm as K,ru as L,ey as M,Wt as N,Fm as O,iy as P,jm as Q,hd as R,sy as S,dy as T,yy as U,Bv as V,Hm as W,An as X,vy as Y,zm as Z,ov as _,We as a,hy as a0,Rv as a1,md as a2,El as b,B as c,Py as d,Nv as e,Ym as f,Iv as g,jv as h,Pv as i,p as j,Dv as k,Lv as l,Mv as m,Ig as n,Bi as o,Tg as p,ay as q,y as r,Qm as s,zv as t,yn as u,ky as v,Im as w,wf as x,cy as y,jf as z};
219
+ */const wy=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],ky=B("x",wy),Bi={"X-Appium-Is-Sensitive":"true"},gt="/xenon/api/auth";class ru extends Error{constructor(t,n,r=null){super(t),this.status=n,this.retryAfterSec=r,this.name="LoginError"}}async function Lv(e,t){let n;try{n=await fetch(`${gt}/login`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json",...Bi},body:JSON.stringify({email:e,password:t})})}catch(r){throw new ru(r.message||"Network error",0)}if(!n.ok){const r=await n.json().catch(()=>({})),i=Number(n.headers.get("Retry-After"));throw new ru(r.error||`Login failed (${n.status})`,n.status,Number.isFinite(i)&&i>0?i:null)}}async function jv(){try{const e=await fetch(`${gt}/options`,{credentials:"include"});return e.ok?{passwordReset:(await e.json()).passwordReset==="email"?"email":"admin"}:{passwordReset:"admin"}}catch{return{passwordReset:"admin"}}}async function xy(){await fetch(`${gt}/logout`,{method:"POST",credentials:"include"})}async function Ey(){const e=await fetch(`${gt}/me`,{credentials:"include"});if(e.status===401)return null;if(!e.ok)throw new Error(`Failed to fetch /me (${e.status})`);return e.json()}async function Av(e,t){const n=await fetch(`${gt}/change-password`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json",...Bi},body:JSON.stringify({oldPassword:e,newPassword:t})});if(!n.ok){const r=await n.json().catch(()=>({}));throw new Error(r.error||`Change password failed (${n.status})`)}}async function Iv(e){const t=await fetch(`${gt}/forgot-password`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:e})});if(!t.ok&&t.status!==204)throw t.status===429?new Error("Too many attempts — try again later."):new Error(`Request failed (${t.status})`)}async function Dv(e){return(await fetch(`${gt}/reset-password/check`,{method:"POST",headers:{"Content-Type":"application/json",...Bi},body:JSON.stringify({token:e})})).ok}async function Mv(e,t){const n=await fetch(`${gt}/reset-password`,{method:"POST",headers:{"Content-Type":"application/json",...Bi},body:JSON.stringify({token:e,newPassword:t})});if(!n.ok&&n.status!==204){const r=await n.json().catch(()=>({}));throw new Error(r.error||`Reset failed (${n.status})`)}}const Af="xenon-screenshots",He="captures",ps="udid";function If(e,t){return t.takenAt-e.takenAt||t.n-e.n}function iu(){const e=new Map;return{persistent:!1,async list(t){return Array.from(e.values()).filter(n=>n.udid===t).sort(If)},async put(t){e.set(t.id,t)},async delete(t){t.forEach(n=>e.delete(n))},async clear(t){Array.from(e.values()).filter(n=>n.udid===t).forEach(n=>e.delete(n.id))}}}function ou(e){return new Promise((t,n)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>n(e.error)})}function su(e){return new Promise((t,n)=>{e.oncomplete=()=>t(),e.onerror=()=>n(e.error),e.onabort=()=>n(e.error??new Error("transaction aborted"))})}function _y(e){return new Promise((t,n)=>{const r=e.open(Af,1);r.onupgradeneeded=()=>{r.result.createObjectStore(He,{keyPath:"id"}).createIndex(ps,"udid")},r.onsuccess=()=>{const i=r.result;i.onversionchange=()=>i.close(),t(i)},r.onerror=()=>n(r.error),r.onblocked=()=>n(new Error("blocked"))})}function Sy(e){const t=async n=>{const r=e.transaction(He,"readwrite");n(r.objectStore(He)),await su(r)};return{persistent:!0,async list(n){const r=e.transaction(He,"readonly");return(await ou(r.objectStore(He).index(ps).getAll(n))).sort(If)},put:n=>t(r=>r.put(n)),delete:n=>t(r=>n.forEach(i=>r.delete(i))),async clear(n){const r=e.transaction(He,"readwrite"),i=r.objectStore(He).index(ps);(await ou(i.getAllKeys(n))).forEach(s=>r.objectStore(He).delete(s)),await su(r)}}}function Df(){try{return typeof indexedDB>"u"?void 0:indexedDB}catch{return}}async function Cy(e=Df()){if(!e)return iu();try{return Sy(await _y(e))}catch{return iu()}}let Gr=null;function $v(){return Gr||(Gr=Cy()),Gr}async function Ty(e=Df(),t=1e3){if(Gr=null,!e)return;const n=new Promise(r=>{try{const i=e.deleteDatabase(Af);i.onsuccess=()=>r(),i.onerror=()=>r(),i.onblocked=()=>r()}catch{r()}});await Promise.race([n,new Promise(r=>setTimeout(r,t))])}const xl="xenon.hadSession";function Ry(){try{localStorage.setItem(xl,"1")}catch{}}function Py(){try{localStorage.removeItem(xl)}catch{}}function Ny(){try{return localStorage.getItem(xl)==="1"}catch{return!1}}const Mf=y.createContext(null);function Oy({children:e}){const[t,n]=y.useState(!0),[r,i]=y.useState(null);async function o(){try{const l=await Ey();l&&Ry(),i(l)}finally{n(!1)}}async function s(){Py(),await Promise.all([xy(),Ty()]),i(null),window.location.href="/xenon/login"}return y.useEffect(()=>{o()},[]),p.jsx(Mf.Provider,{value:{loading:t,me:r,refresh:o,signOut:s},children:e})}function El(){const e=y.useContext(Mf);if(!e)throw new Error("useAuth must be used inside AuthProvider");return e}const De=Object.create(null);De.open="0";De.close="1";De.ping="2";De.pong="3";De.message="4";De.upgrade="5";De.noop="6";const Yr=Object.create(null);Object.keys(De).forEach(e=>{Yr[De[e]]=e});const hs={type:"error",data:"parser error"},$f=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",Uf=typeof ArrayBuffer=="function",Bf=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,_l=({type:e,data:t},n,r)=>$f&&t instanceof Blob?n?r(t):lu(t,r):Uf&&(t instanceof ArrayBuffer||Bf(t))?n?r(t):lu(new Blob([t]),r):r(De[e]+(t||"")),lu=(e,t)=>{const n=new FileReader;return n.onload=function(){const r=n.result.split(",")[1];t("b"+(r||""))},n.readAsDataURL(e)};function au(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}let vo;function Ly(e,t){if($f&&e.data instanceof Blob)return e.data.arrayBuffer().then(au).then(t);if(Uf&&(e.data instanceof ArrayBuffer||Bf(e.data)))return t(au(e.data));_l(e,!1,n=>{vo||(vo=new TextEncoder),t(vo.encode(n))})}const uu="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Bn=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let e=0;e<uu.length;e++)Bn[uu.charCodeAt(e)]=e;const jy=e=>{let t=e.length*.75,n=e.length,r,i=0,o,s,l,a;e[e.length-1]==="="&&(t--,e[e.length-2]==="="&&t--);const u=new ArrayBuffer(t),m=new Uint8Array(u);for(r=0;r<n;r+=4)o=Bn[e.charCodeAt(r)],s=Bn[e.charCodeAt(r+1)],l=Bn[e.charCodeAt(r+2)],a=Bn[e.charCodeAt(r+3)],m[i++]=o<<2|s>>4,m[i++]=(s&15)<<4|l>>2,m[i++]=(l&3)<<6|a&63;return u},Ay=typeof ArrayBuffer=="function",Sl=(e,t)=>{if(typeof e!="string")return{type:"message",data:zf(e,t)};const n=e.charAt(0);return n==="b"?{type:"message",data:Iy(e.substring(1),t)}:Yr[n]?e.length>1?{type:Yr[n],data:e.substring(1)}:{type:Yr[n]}:hs},Iy=(e,t)=>{if(Ay){const n=jy(e);return zf(n,t)}else return{base64:!0,data:e}},zf=(e,t)=>{switch(t){case"blob":return e instanceof Blob?e:new Blob([e]);case"arraybuffer":default:return e instanceof ArrayBuffer?e:e.buffer}},bf="",Dy=(e,t)=>{const n=e.length,r=new Array(n);let i=0;e.forEach((o,s)=>{_l(o,!1,l=>{r[s]=l,++i===n&&t(r.join(bf))})})},My=(e,t)=>{const n=e.split(bf),r=[];for(let i=0;i<n.length;i++){const o=Sl(n[i],t);if(r.push(o),o.type==="error")break}return r};function $y(){return new TransformStream({transform(e,t){Ly(e,n=>{const r=n.length;let i;if(r<126)i=new Uint8Array(1),new DataView(i.buffer).setUint8(0,r);else if(r<65536){i=new Uint8Array(3);const o=new DataView(i.buffer);o.setUint8(0,126),o.setUint16(1,r)}else{i=new Uint8Array(9);const o=new DataView(i.buffer);o.setUint8(0,127),o.setBigUint64(1,BigInt(r))}e.data&&typeof e.data!="string"&&(i[0]|=128),t.enqueue(i),t.enqueue(n)})}})}let wo;function Mr(e){return e.reduce((t,n)=>t+n.length,0)}function $r(e,t){if(e[0].length===t)return e.shift();const n=new Uint8Array(t);let r=0;for(let i=0;i<t;i++)n[i]=e[0][r++],r===e[0].length&&(e.shift(),r=0);return e.length&&r<e[0].length&&(e[0]=e[0].slice(r)),n}function Uy(e,t){wo||(wo=new TextDecoder);const n=[];let r=0,i=-1,o=!1;return new TransformStream({transform(s,l){for(n.push(s);;){if(r===0){if(Mr(n)<1)break;const a=$r(n,1);o=(a[0]&128)===128,i=a[0]&127,i<126?r=3:i===126?r=1:r=2}else if(r===1){if(Mr(n)<2)break;const a=$r(n,2);i=new DataView(a.buffer,a.byteOffset,a.length).getUint16(0),r=3}else if(r===2){if(Mr(n)<8)break;const a=$r(n,8),u=new DataView(a.buffer,a.byteOffset,a.length),m=u.getUint32(0);if(m>Math.pow(2,21)-1){l.enqueue(hs);break}i=m*Math.pow(2,32)+u.getUint32(4),r=3}else{if(Mr(n)<i)break;const a=$r(n,i);l.enqueue(Sl(o?a:wo.decode(a),t)),r=0}if(i===0||i>e){l.enqueue(hs);break}}}})}const Ff=4;function G(e){if(e)return By(e)}function By(e){for(var t in G.prototype)e[t]=G.prototype[t];return e}G.prototype.on=G.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this};G.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this};G.prototype.off=G.prototype.removeListener=G.prototype.removeAllListeners=G.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var n=this._callbacks["$"+e];if(!n)return this;if(arguments.length==1)return delete this._callbacks["$"+e],this;for(var r,i=0;i<n.length;i++)if(r=n[i],r===t||r.fn===t){n.splice(i,1);break}return n.length===0&&delete this._callbacks["$"+e],this};G.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),n=this._callbacks["$"+e],r=1;r<arguments.length;r++)t[r-1]=arguments[r];if(n){n=n.slice(0);for(var r=0,i=n.length;r<i;++r)n[r].apply(this,t)}return this};G.prototype.emitReserved=G.prototype.emit;G.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]};G.prototype.hasListeners=function(e){return!!this.listeners(e).length};const zi=typeof Promise=="function"&&typeof Promise.resolve=="function"?t=>Promise.resolve().then(t):(t,n)=>n(t,0),ve=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),zy="arraybuffer";function Vf(e,...t){return t.reduce((n,r)=>(e.hasOwnProperty(r)&&(n[r]=e[r]),n),{})}const by=ve.setTimeout,Fy=ve.clearTimeout;function bi(e,t){t.useNativeTimers?(e.setTimeoutFn=by.bind(ve),e.clearTimeoutFn=Fy.bind(ve)):(e.setTimeoutFn=ve.setTimeout.bind(ve),e.clearTimeoutFn=ve.clearTimeout.bind(ve))}const Vy=1.33;function qy(e){return typeof e=="string"?Wy(e):Math.ceil((e.byteLength||e.size)*Vy)}function Wy(e){let t=0,n=0;for(let r=0,i=e.length;r<i;r++)t=e.charCodeAt(r),t<128?n+=1:t<2048?n+=2:t<55296||t>=57344?n+=3:(r++,n+=4);return n}function qf(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function Hy(e){let t="";for(let n in e)e.hasOwnProperty(n)&&(t.length&&(t+="&"),t+=encodeURIComponent(n)+"="+encodeURIComponent(e[n]));return t}function Ky(e){let t={},n=e.split("&");for(let r=0,i=n.length;r<i;r++){let o=n[r].split("=");t[decodeURIComponent(o[0])]=decodeURIComponent(o[1])}return t}class Qy extends Error{constructor(t,n,r){super(t),this.description=n,this.context=r,this.type="TransportError"}}class Cl extends G{constructor(t){super(),this.writable=!1,bi(this,t),this.opts=t,this.query=t.query,this.socket=t.socket,this.supportsBinary=!t.forceBase64}onError(t,n,r){return super.emitReserved("error",new Qy(t,n,r)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(t){this.readyState==="open"&&this.write(t)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(t){const n=Sl(t,this.socket.binaryType);this.onPacket(n)}onPacket(t){super.emitReserved("packet",t)}onClose(t){this.readyState="closed",super.emitReserved("close",t)}pause(t){}createUri(t,n={}){return t+"://"+this._hostname()+this._port()+this.opts.path+this._query(n)}_hostname(){const t=this.opts.hostname;return t.indexOf(":")===-1?t:"["+t+"]"}_port(){return this.opts.port&&(this.opts.secure&&Number(this.opts.port)!==443||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(t){const n=Hy(t);return n.length?"?"+n:""}}class Gy extends Cl{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(t){this.readyState="pausing";const n=()=>{this.readyState="paused",t()};if(this._polling||!this.writable){let r=0;this._polling&&(r++,this.once("pollComplete",function(){--r||n()})),this.writable||(r++,this.once("drain",function(){--r||n()}))}else n()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(t){const n=r=>{if(this.readyState==="opening"&&r.type==="open"&&this.onOpen(),r.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(r)};My(t,this.socket.binaryType).forEach(n),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){const t=()=>{this.write([{type:"close"}])};this.readyState==="open"?t():this.once("open",t)}write(t){this.writable=!1,Dy(t,n=>{this.doWrite(n,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const t=this.opts.secure?"https":"http",n=this.query||{};return this.opts.timestampRequests!==!1&&(n[this.opts.timestampParam]=qf()),!this.supportsBinary&&!n.sid&&(n.b64=1),this.createUri(t,n)}}let Wf=!1;try{Wf=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const Yy=Wf;function Xy(){}class Jy extends Gy{constructor(t){if(super(t),typeof location<"u"){const n=location.protocol==="https:";let r=location.port;r||(r=n?"443":"80"),this.xd=typeof location<"u"&&t.hostname!==location.hostname||r!==t.port}}doWrite(t,n){const r=this.request({method:"POST",data:t});r.on("success",n),r.on("error",(i,o)=>{this.onError("xhr post error",i,o)})}doPoll(){const t=this.request();t.on("data",this.onData.bind(this)),t.on("error",(n,r)=>{this.onError("xhr poll error",n,r)}),this.pollXhr=t}}class Ie extends G{constructor(t,n,r){super(),this.createRequest=t,bi(this,r),this._opts=r,this._method=r.method||"GET",this._uri=n,this._data=r.data!==void 0?r.data:null,this._create()}_create(){var t;const n=Vf(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");n.xdomain=!!this._opts.xd;const r=this._xhr=this.createRequest(n);try{r.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){r.setDisableHeaderCheck&&r.setDisableHeaderCheck(!0);for(let i in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(i)&&r.setRequestHeader(i,this._opts.extraHeaders[i])}}catch{}if(this._method==="POST")try{r.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{r.setRequestHeader("Accept","*/*")}catch{}(t=this._opts.cookieJar)===null||t===void 0||t.addCookies(r),"withCredentials"in r&&(r.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(r.timeout=this._opts.requestTimeout),r.onreadystatechange=()=>{var i;r.readyState===3&&((i=this._opts.cookieJar)===null||i===void 0||i.parseCookies(r.getResponseHeader("set-cookie"))),r.readyState===4&&(r.status===200||r.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof r.status=="number"?r.status:0)},0))},r.send(this._data)}catch(i){this.setTimeoutFn(()=>{this._onError(i)},0);return}typeof document<"u"&&(this._index=Ie.requestsCount++,Ie.requests[this._index]=this)}_onError(t){this.emitReserved("error",t,this._xhr),this._cleanup(!0)}_cleanup(t){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=Xy,t)try{this._xhr.abort()}catch{}typeof document<"u"&&delete Ie.requests[this._index],this._xhr=null}}_onLoad(){const t=this._xhr.responseText;t!==null&&(this.emitReserved("data",t),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}}Ie.requestsCount=0;Ie.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",cu);else if(typeof addEventListener=="function"){const e="onpagehide"in ve?"pagehide":"unload";addEventListener(e,cu,!1)}}function cu(){for(let e in Ie.requests)Ie.requests.hasOwnProperty(e)&&Ie.requests[e].abort()}const Zy=function(){const e=Hf({xdomain:!1});return e&&e.responseType!==null}();class eg extends Jy{constructor(t){super(t);const n=t&&t.forceBase64;this.supportsBinary=Zy&&!n}request(t={}){return Object.assign(t,{xd:this.xd},this.opts),new Ie(Hf,this.uri(),t)}}function Hf(e){const t=e.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!t||Yy))return new XMLHttpRequest}catch{}if(!t)try{return new ve[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const Kf=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class tg extends Cl{get name(){return"websocket"}doOpen(){const t=this.uri(),n=this.opts.protocols,r=Kf?{}:Vf(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(r.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(t,n,r)}catch(i){return this.emitReserved("error",i)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=t=>this.onClose({description:"websocket connection closed",context:t}),this.ws.onmessage=t=>this.onData(t.data),this.ws.onerror=t=>this.onError("websocket error",t)}write(t){this.writable=!1;for(let n=0;n<t.length;n++){const r=t[n],i=n===t.length-1;_l(r,this.supportsBinary,o=>{try{this.doWrite(r,o)}catch{}i&&zi(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const t=this.opts.secure?"wss":"ws",n=this.query||{};return this.opts.timestampRequests&&(n[this.opts.timestampParam]=qf()),this.supportsBinary||(n.b64=1),this.createUri(t,n)}}const ko=ve.WebSocket||ve.MozWebSocket;class ng extends tg{createSocket(t,n,r){return Kf?new ko(t,n,r):n?new ko(t,n):new ko(t)}doWrite(t,n){this.ws.send(n)}}class rg extends Cl{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(t){return this.emitReserved("error",t)}this._transport.closed.then(()=>{this.onClose()}).catch(t=>{this.onError("webtransport error",t)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(t=>{const n=Uy(Number.MAX_SAFE_INTEGER,this.socket.binaryType),r=t.readable.pipeThrough(n).getReader(),i=$y();i.readable.pipeTo(t.writable),this._writer=i.writable.getWriter();const o=()=>{r.read().then(({done:l,value:a})=>{l||(this.onPacket(a),o())}).catch(l=>{})};o();const s={type:"open"};this.query.sid&&(s.data=`{"sid":"${this.query.sid}"}`),this._writer.write(s).then(()=>this.onOpen())})})}write(t){this.writable=!1;for(let n=0;n<t.length;n++){const r=t[n],i=n===t.length-1;this._writer.write(r).then(()=>{i&&zi(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var t;(t=this._transport)===null||t===void 0||t.close()}}const ig={websocket:ng,webtransport:rg,polling:eg},og=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,sg=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function ms(e){if(e.length>8e3)throw"URI too long";const t=e,n=e.indexOf("["),r=e.indexOf("]");n!=-1&&r!=-1&&(e=e.substring(0,n)+e.substring(n,r).replace(/:/g,";")+e.substring(r,e.length));let i=og.exec(e||""),o={},s=14;for(;s--;)o[sg[s]]=i[s]||"";return n!=-1&&r!=-1&&(o.source=t,o.host=o.host.substring(1,o.host.length-1).replace(/;/g,":"),o.authority=o.authority.replace("[","").replace("]","").replace(/;/g,":"),o.ipv6uri=!0),o.pathNames=lg(o,o.path),o.queryKey=ag(o,o.query),o}function lg(e,t){const n=/\/{2,9}/g,r=t.replace(n,"/").split("/");return(t.slice(0,1)=="/"||t.length===0)&&r.splice(0,1),t.slice(-1)=="/"&&r.splice(r.length-1,1),r}function ag(e,t){const n={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(r,i,o){i&&(n[i]=o)}),n}const ys=typeof addEventListener=="function"&&typeof removeEventListener=="function",Xr=[];ys&&addEventListener("offline",()=>{Xr.forEach(e=>e())},!1);class at extends G{constructor(t,n){if(super(),this.binaryType=zy,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,t&&typeof t=="object"&&(n=t,t=null),t){const r=ms(t);n.hostname=r.host,n.secure=r.protocol==="https"||r.protocol==="wss",n.port=r.port,r.query&&(n.query=r.query)}else n.host&&(n.hostname=ms(n.host).host);bi(this,n),this.secure=n.secure!=null?n.secure:typeof location<"u"&&location.protocol==="https:",n.hostname&&!n.port&&(n.port=this.secure?"443":"80"),this.hostname=n.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=n.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},n.transports.forEach(r=>{const i=r.prototype.name;this.transports.push(i),this._transportsByName[i]=r}),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},n),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=Ky(this.opts.query)),ys&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},Xr.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(t){const n=Object.assign({},this.opts.query);n.EIO=Ff,n.transport=t,this.id&&(n.sid=this.id);const r=Object.assign({},this.opts,{query:n,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[t]);return new this._transportsByName[t](r)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const t=this.opts.rememberUpgrade&&at.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const n=this.createTransport(t);n.open(),this.setTransport(n)}setTransport(t){this.transport&&this.transport.removeAllListeners(),this.transport=t,t.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",n=>this._onClose("transport close",n))}onOpen(){this.readyState="open",at.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(t){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",t),this.emitReserved("heartbeat"),t.type){case"open":this.onHandshake(JSON.parse(t.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":const n=new Error("server error");n.code=t.data,this._onError(n);break;case"message":this.emitReserved("data",t.data),this.emitReserved("message",t.data);break}}onHandshake(t){this.emitReserved("handshake",t),this.id=t.sid,this.transport.query.sid=t.sid,this._pingInterval=t.pingInterval,this._pingTimeout=t.pingTimeout,this._maxPayload=t.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const t=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+t,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},t),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const t=this._getWritablePackets();this.transport.send(t),this._prevBufferLen=t.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let n=1;for(let r=0;r<this.writeBuffer.length;r++){const i=this.writeBuffer[r].data;if(i&&(n+=qy(i)),r>0&&n>this._maxPayload)return this.writeBuffer.slice(0,r);n+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const t=Date.now()>this._pingTimeoutTime;return t&&(this._pingTimeoutTime=0,zi(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),t}write(t,n,r){return this._sendPacket("message",t,n,r),this}send(t,n,r){return this._sendPacket("message",t,n,r),this}_sendPacket(t,n,r,i){if(typeof n=="function"&&(i=n,n=void 0),typeof r=="function"&&(i=r,r=null),this.readyState==="closing"||this.readyState==="closed")return;r=r||{},r.compress=r.compress!==!1;const o={type:t,data:n,options:r};this.emitReserved("packetCreate",o),this.writeBuffer.push(o),i&&this.once("flush",i),this.flush()}close(){const t=()=>{this._onClose("forced close"),this.transport.close()},n=()=>{this.off("upgrade",n),this.off("upgradeError",n),t()},r=()=>{this.once("upgrade",n),this.once("upgradeError",n)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?r():t()}):this.upgrading?r():t()),this}_onError(t){if(at.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",t),this._onClose("transport error",t)}_onClose(t,n){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing"){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),ys&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const r=Xr.indexOf(this._offlineEventListener);r!==-1&&Xr.splice(r,1)}this.readyState="closed",this.id=null,this.emitReserved("close",t,n),this.writeBuffer=[],this._prevBufferLen=0}}}at.protocol=Ff;class ug extends at{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let t=0;t<this._upgrades.length;t++)this._probe(this._upgrades[t])}_probe(t){let n=this.createTransport(t),r=!1;at.priorWebsocketSuccess=!1;const i=()=>{r||(n.send([{type:"ping",data:"probe"}]),n.once("packet",v=>{if(!r)if(v.type==="pong"&&v.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",n),!n)return;at.priorWebsocketSuccess=n.name==="websocket",this.transport.pause(()=>{r||this.readyState!=="closed"&&(m(),this.setTransport(n),n.send([{type:"upgrade"}]),this.emitReserved("upgrade",n),n=null,this.upgrading=!1,this.flush())})}else{const h=new Error("probe error");h.transport=n.name,this.emitReserved("upgradeError",h)}}))};function o(){r||(r=!0,m(),n.close(),n=null)}const s=v=>{const h=new Error("probe error: "+v);h.transport=n.name,o(),this.emitReserved("upgradeError",h)};function l(){s("transport closed")}function a(){s("socket closed")}function u(v){n&&v.name!==n.name&&o()}const m=()=>{n.removeListener("open",i),n.removeListener("error",s),n.removeListener("close",l),this.off("close",a),this.off("upgrading",u)};n.once("open",i),n.once("error",s),n.once("close",l),this.once("close",a),this.once("upgrading",u),this._upgrades.indexOf("webtransport")!==-1&&t!=="webtransport"?this.setTimeoutFn(()=>{r||n.open()},200):n.open()}onHandshake(t){this._upgrades=this._filterUpgrades(t.upgrades),super.onHandshake(t)}_filterUpgrades(t){const n=[];for(let r=0;r<t.length;r++)~this.transports.indexOf(t[r])&&n.push(t[r]);return n}}let cg=class extends ug{constructor(t,n={}){const r=typeof t=="object"?t:n;(!r.transports||r.transports&&typeof r.transports[0]=="string")&&(r.transports=(r.transports||["polling","websocket","webtransport"]).map(i=>ig[i]).filter(i=>!!i)),super(t,r)}};function fg(e,t="",n){let r=e;n=n||typeof location<"u"&&location,e==null&&(e=n.protocol+"//"+n.host),typeof e=="string"&&(e.charAt(0)==="/"&&(e.charAt(1)==="/"?e=n.protocol+e:e=n.host+e),/^(https?|wss?):\/\//.test(e)||(typeof n<"u"?e=n.protocol+"//"+e:e="https://"+e),r=ms(e)),r.port||(/^(http|ws)$/.test(r.protocol)?r.port="80":/^(http|ws)s$/.test(r.protocol)&&(r.port="443")),r.path=r.path||"/";const o=r.host.indexOf(":")!==-1?"["+r.host+"]":r.host;return r.id=r.protocol+"://"+o+":"+r.port+t,r.href=r.protocol+"://"+o+(n&&n.port===r.port?"":":"+r.port),r}const dg=typeof ArrayBuffer=="function",pg=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,Qf=Object.prototype.toString,hg=typeof Blob=="function"||typeof Blob<"u"&&Qf.call(Blob)==="[object BlobConstructor]",mg=typeof File=="function"||typeof File<"u"&&Qf.call(File)==="[object FileConstructor]";function Tl(e){return dg&&(e instanceof ArrayBuffer||pg(e))||hg&&e instanceof Blob||mg&&e instanceof File}function Jr(e,t){if(!e||typeof e!="object")return!1;if(Array.isArray(e)){for(let n=0,r=e.length;n<r;n++)if(Jr(e[n]))return!0;return!1}if(Tl(e))return!0;if(e.toJSON&&typeof e.toJSON=="function"&&arguments.length===1)return Jr(e.toJSON(),!0);for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&Jr(e[n]))return!0;return!1}function yg(e){const t=[],n=e.data,r=e;return r.data=gs(n,t),r.attachments=t.length,{packet:r,buffers:t}}function gs(e,t){if(!e)return e;if(Tl(e)){const n={_placeholder:!0,num:t.length};return t.push(e),n}else if(Array.isArray(e)){const n=new Array(e.length);for(let r=0;r<e.length;r++)n[r]=gs(e[r],t);return n}else if(typeof e=="object"&&!(e instanceof Date)){const n={};for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=gs(e[r],t));return n}return e}function gg(e,t){return e.data=vs(e.data,t),delete e.attachments,e}function vs(e,t){if(!e)return e;if(e&&e._placeholder===!0){if(typeof e.num=="number"&&e.num>=0&&e.num<t.length)return t[e.num];throw new Error("illegal attachments")}else if(Array.isArray(e))for(let n=0;n<e.length;n++)e[n]=vs(e[n],t);else if(typeof e=="object")for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(e[n]=vs(e[n],t));return e}const vg=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];var D;(function(e){e[e.CONNECT=0]="CONNECT",e[e.DISCONNECT=1]="DISCONNECT",e[e.EVENT=2]="EVENT",e[e.ACK=3]="ACK",e[e.CONNECT_ERROR=4]="CONNECT_ERROR",e[e.BINARY_EVENT=5]="BINARY_EVENT",e[e.BINARY_ACK=6]="BINARY_ACK"})(D||(D={}));class wg{constructor(t){this.replacer=t}encode(t){return(t.type===D.EVENT||t.type===D.ACK)&&Jr(t)?this.encodeAsBinary({type:t.type===D.EVENT?D.BINARY_EVENT:D.BINARY_ACK,nsp:t.nsp,data:t.data,id:t.id}):[this.encodeAsString(t)]}encodeAsString(t){let n=""+t.type;return(t.type===D.BINARY_EVENT||t.type===D.BINARY_ACK)&&(n+=t.attachments+"-"),t.nsp&&t.nsp!=="/"&&(n+=t.nsp+","),t.id!=null&&(n+=t.id),t.data!=null&&(n+=JSON.stringify(t.data,this.replacer)),n}encodeAsBinary(t){const n=yg(t),r=this.encodeAsString(n.packet),i=n.buffers;return i.unshift(r),i}}class Rl extends G{constructor(t){super(),this.reviver=t}add(t){let n;if(typeof t=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");n=this.decodeString(t);const r=n.type===D.BINARY_EVENT;r||n.type===D.BINARY_ACK?(n.type=r?D.EVENT:D.ACK,this.reconstructor=new kg(n),n.attachments===0&&super.emitReserved("decoded",n)):super.emitReserved("decoded",n)}else if(Tl(t)||t.base64)if(this.reconstructor)n=this.reconstructor.takeBinaryData(t),n&&(this.reconstructor=null,super.emitReserved("decoded",n));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+t)}decodeString(t){let n=0;const r={type:Number(t.charAt(0))};if(D[r.type]===void 0)throw new Error("unknown packet type "+r.type);if(r.type===D.BINARY_EVENT||r.type===D.BINARY_ACK){const o=n+1;for(;t.charAt(++n)!=="-"&&n!=t.length;);const s=t.substring(o,n);if(s!=Number(s)||t.charAt(n)!=="-")throw new Error("Illegal attachments");r.attachments=Number(s)}if(t.charAt(n+1)==="/"){const o=n+1;for(;++n&&!(t.charAt(n)===","||n===t.length););r.nsp=t.substring(o,n)}else r.nsp="/";const i=t.charAt(n+1);if(i!==""&&Number(i)==i){const o=n+1;for(;++n;){const s=t.charAt(n);if(s==null||Number(s)!=s){--n;break}if(n===t.length)break}r.id=Number(t.substring(o,n+1))}if(t.charAt(++n)){const o=this.tryParse(t.substr(n));if(Rl.isPayloadValid(r.type,o))r.data=o;else throw new Error("invalid payload")}return r}tryParse(t){try{return JSON.parse(t,this.reviver)}catch{return!1}}static isPayloadValid(t,n){switch(t){case D.CONNECT:return fu(n);case D.DISCONNECT:return n===void 0;case D.CONNECT_ERROR:return typeof n=="string"||fu(n);case D.EVENT:case D.BINARY_EVENT:return Array.isArray(n)&&(typeof n[0]=="number"||typeof n[0]=="string"&&vg.indexOf(n[0])===-1);case D.ACK:case D.BINARY_ACK:return Array.isArray(n)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class kg{constructor(t){this.packet=t,this.buffers=[],this.reconPack=t}takeBinaryData(t){if(this.buffers.push(t),this.buffers.length===this.reconPack.attachments){const n=gg(this.reconPack,this.buffers);return this.finishedReconstruction(),n}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}function fu(e){return Object.prototype.toString.call(e)==="[object Object]"}const xg=Object.freeze(Object.defineProperty({__proto__:null,Decoder:Rl,Encoder:wg,get PacketType(){return D}},Symbol.toStringTag,{value:"Module"}));function Re(e,t,n){return e.on(t,n),function(){e.off(t,n)}}const Eg=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class Gf extends G{constructor(t,n,r){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=t,this.nsp=n,r&&r.auth&&(this.auth=r.auth),this._opts=Object.assign({},r),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const t=this.io;this.subs=[Re(t,"open",this.onopen.bind(this)),Re(t,"packet",this.onpacket.bind(this)),Re(t,"error",this.onerror.bind(this)),Re(t,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...t){return t.unshift("message"),this.emit.apply(this,t),this}emit(t,...n){var r,i,o;if(Eg.hasOwnProperty(t))throw new Error('"'+t.toString()+'" is a reserved event name');if(n.unshift(t),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(n),this;const s={type:D.EVENT,data:n};if(s.options={},s.options.compress=this.flags.compress!==!1,typeof n[n.length-1]=="function"){const m=this.ids++,v=n.pop();this._registerAckCallback(m,v),s.id=m}const l=(i=(r=this.io.engine)===null||r===void 0?void 0:r.transport)===null||i===void 0?void 0:i.writable,a=this.connected&&!(!((o=this.io.engine)===null||o===void 0)&&o._hasPingExpired());return this.flags.volatile&&!l||(a?(this.notifyOutgoingListeners(s),this.packet(s)):this.sendBuffer.push(s)),this.flags={},this}_registerAckCallback(t,n){var r;const i=(r=this.flags.timeout)!==null&&r!==void 0?r:this._opts.ackTimeout;if(i===void 0){this.acks[t]=n;return}const o=this.io.setTimeoutFn(()=>{delete this.acks[t];for(let l=0;l<this.sendBuffer.length;l++)this.sendBuffer[l].id===t&&this.sendBuffer.splice(l,1);n.call(this,new Error("operation has timed out"))},i),s=(...l)=>{this.io.clearTimeoutFn(o),n.apply(this,l)};s.withError=!0,this.acks[t]=s}emitWithAck(t,...n){return new Promise((r,i)=>{const o=(s,l)=>s?i(s):r(l);o.withError=!0,n.push(o),this.emit(t,...n)})}_addToQueue(t){let n;typeof t[t.length-1]=="function"&&(n=t.pop());const r={id:this._queueSeq++,tryCount:0,pending:!1,args:t,flags:Object.assign({fromQueue:!0},this.flags)};t.push((i,...o)=>(this._queue[0],i!==null?r.tryCount>this._opts.retries&&(this._queue.shift(),n&&n(i)):(this._queue.shift(),n&&n(null,...o)),r.pending=!1,this._drainQueue())),this._queue.push(r),this._drainQueue()}_drainQueue(t=!1){if(!this.connected||this._queue.length===0)return;const n=this._queue[0];n.pending&&!t||(n.pending=!0,n.tryCount++,this.flags=n.flags,this.emit.apply(this,n.args))}packet(t){t.nsp=this.nsp,this.io._packet(t)}onopen(){typeof this.auth=="function"?this.auth(t=>{this._sendConnectPacket(t)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(t){this.packet({type:D.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},t):t})}onerror(t){this.connected||this.emitReserved("connect_error",t)}onclose(t,n){this.connected=!1,delete this.id,this.emitReserved("disconnect",t,n),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(t=>{if(!this.sendBuffer.some(r=>String(r.id)===t)){const r=this.acks[t];delete this.acks[t],r.withError&&r.call(this,new Error("socket has been disconnected"))}})}onpacket(t){if(t.nsp===this.nsp)switch(t.type){case D.CONNECT:t.data&&t.data.sid?this.onconnect(t.data.sid,t.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case D.EVENT:case D.BINARY_EVENT:this.onevent(t);break;case D.ACK:case D.BINARY_ACK:this.onack(t);break;case D.DISCONNECT:this.ondisconnect();break;case D.CONNECT_ERROR:this.destroy();const r=new Error(t.data.message);r.data=t.data.data,this.emitReserved("connect_error",r);break}}onevent(t){const n=t.data||[];t.id!=null&&n.push(this.ack(t.id)),this.connected?this.emitEvent(n):this.receiveBuffer.push(Object.freeze(n))}emitEvent(t){if(this._anyListeners&&this._anyListeners.length){const n=this._anyListeners.slice();for(const r of n)r.apply(this,t)}super.emit.apply(this,t),this._pid&&t.length&&typeof t[t.length-1]=="string"&&(this._lastOffset=t[t.length-1])}ack(t){const n=this;let r=!1;return function(...i){r||(r=!0,n.packet({type:D.ACK,id:t,data:i}))}}onack(t){const n=this.acks[t.id];typeof n=="function"&&(delete this.acks[t.id],n.withError&&t.data.unshift(null),n.apply(this,t.data))}onconnect(t,n){this.id=t,this.recovered=n&&this._pid===n,this._pid=n,this.connected=!0,this.emitBuffered(),this._drainQueue(!0),this.emitReserved("connect")}emitBuffered(){this.receiveBuffer.forEach(t=>this.emitEvent(t)),this.receiveBuffer=[],this.sendBuffer.forEach(t=>{this.notifyOutgoingListeners(t),this.packet(t)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(t=>t()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:D.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(t){return this.flags.compress=t,this}get volatile(){return this.flags.volatile=!0,this}timeout(t){return this.flags.timeout=t,this}onAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(t),this}prependAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(t),this}offAny(t){if(!this._anyListeners)return this;if(t){const n=this._anyListeners;for(let r=0;r<n.length;r++)if(t===n[r])return n.splice(r,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(t){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(t),this}prependAnyOutgoing(t){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(t),this}offAnyOutgoing(t){if(!this._anyOutgoingListeners)return this;if(t){const n=this._anyOutgoingListeners;for(let r=0;r<n.length;r++)if(t===n[r])return n.splice(r,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(t){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const n=this._anyOutgoingListeners.slice();for(const r of n)r.apply(this,t.data)}}}function gn(e){e=e||{},this.ms=e.min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}gn.prototype.duration=function(){var e=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),n=Math.floor(t*this.jitter*e);e=Math.floor(t*10)&1?e+n:e-n}return Math.min(e,this.max)|0};gn.prototype.reset=function(){this.attempts=0};gn.prototype.setMin=function(e){this.ms=e};gn.prototype.setMax=function(e){this.max=e};gn.prototype.setJitter=function(e){this.jitter=e};class ws extends G{constructor(t,n){var r;super(),this.nsps={},this.subs=[],t&&typeof t=="object"&&(n=t,t=void 0),n=n||{},n.path=n.path||"/socket.io",this.opts=n,bi(this,n),this.reconnection(n.reconnection!==!1),this.reconnectionAttempts(n.reconnectionAttempts||1/0),this.reconnectionDelay(n.reconnectionDelay||1e3),this.reconnectionDelayMax(n.reconnectionDelayMax||5e3),this.randomizationFactor((r=n.randomizationFactor)!==null&&r!==void 0?r:.5),this.backoff=new gn({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(n.timeout==null?2e4:n.timeout),this._readyState="closed",this.uri=t;const i=n.parser||xg;this.encoder=new i.Encoder,this.decoder=new i.Decoder,this._autoConnect=n.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(t){return arguments.length?(this._reconnection=!!t,t||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(t){return t===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=t,this)}reconnectionDelay(t){var n;return t===void 0?this._reconnectionDelay:(this._reconnectionDelay=t,(n=this.backoff)===null||n===void 0||n.setMin(t),this)}randomizationFactor(t){var n;return t===void 0?this._randomizationFactor:(this._randomizationFactor=t,(n=this.backoff)===null||n===void 0||n.setJitter(t),this)}reconnectionDelayMax(t){var n;return t===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=t,(n=this.backoff)===null||n===void 0||n.setMax(t),this)}timeout(t){return arguments.length?(this._timeout=t,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(t){if(~this._readyState.indexOf("open"))return this;this.engine=new cg(this.uri,this.opts);const n=this.engine,r=this;this._readyState="opening",this.skipReconnect=!1;const i=Re(n,"open",function(){r.onopen(),t&&t()}),o=l=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",l),t?t(l):this.maybeReconnectOnOpen()},s=Re(n,"error",o);if(this._timeout!==!1){const l=this._timeout,a=this.setTimeoutFn(()=>{i(),o(new Error("timeout")),n.close()},l);this.opts.autoUnref&&a.unref(),this.subs.push(()=>{this.clearTimeoutFn(a)})}return this.subs.push(i),this.subs.push(s),this}connect(t){return this.open(t)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const t=this.engine;this.subs.push(Re(t,"ping",this.onping.bind(this)),Re(t,"data",this.ondata.bind(this)),Re(t,"error",this.onerror.bind(this)),Re(t,"close",this.onclose.bind(this)),Re(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(t){try{this.decoder.add(t)}catch(n){this.onclose("parse error",n)}}ondecoded(t){zi(()=>{this.emitReserved("packet",t)},this.setTimeoutFn)}onerror(t){this.emitReserved("error",t)}socket(t,n){let r=this.nsps[t];return r?this._autoConnect&&!r.active&&r.connect():(r=new Gf(this,t,n),this.nsps[t]=r),r}_destroy(t){const n=Object.keys(this.nsps);for(const r of n)if(this.nsps[r].active)return;this._close()}_packet(t){const n=this.encoder.encode(t);for(let r=0;r<n.length;r++)this.engine.write(n[r],t.options)}cleanup(){this.subs.forEach(t=>t()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(t,n){var r;this.cleanup(),(r=this.engine)===null||r===void 0||r.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",t,n),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const t=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const n=this.backoff.duration();this._reconnecting=!0;const r=this.setTimeoutFn(()=>{t.skipReconnect||(this.emitReserved("reconnect_attempt",t.backoff.attempts),!t.skipReconnect&&t.open(i=>{i?(t._reconnecting=!1,t.reconnect(),this.emitReserved("reconnect_error",i)):t.onreconnect()}))},n);this.opts.autoUnref&&r.unref(),this.subs.push(()=>{this.clearTimeoutFn(r)})}}onreconnect(){const t=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",t)}}const jn={};function Zr(e,t){typeof e=="object"&&(t=e,e=void 0),t=t||{};const n=fg(e,t.path||"/socket.io"),r=n.source,i=n.id,o=n.path,s=jn[i]&&o in jn[i].nsps,l=t.forceNew||t["force new connection"]||t.multiplex===!1||s;let a;return l?a=new ws(r,t):(jn[i]||(jn[i]=new ws(r,t)),a=jn[i]),n.query&&!t.query&&(t.query=n.queryKey),a.socket(n.path,t)}Object.assign(Zr,{Manager:ws,Socket:Gf,io:Zr,connect:Zr});let xo=null;const zn=new Map;function _g(e,t){const n=zn.get(e);n&&Array.from(n).forEach(r=>r(t))}function Sg(){if(xo)return xo;const e=Zr(window.location.origin,{path:"/socket.io",reconnection:!0,withCredentials:!0});return e.on("connect",()=>{console.log("[Socket] Connected to Hub"),e.emit("register_dashboard")}),e.on("disconnect",()=>{console.log("[Socket] Disconnected from Hub")}),e.onAny((t,n)=>_g(t,n)),xo=e,e}function Cg(e,t){let n=zn.get(e);return n||(n=new Set,zn.set(e,n)),n.add(t),()=>{const r=zn.get(e);r&&(r.delete(t),r.size===0&&zn.delete(e))}}const Tg=()=>{const[e]=y.useState(Sg),[t,n]=y.useState(e.connected);y.useEffect(()=>{const i=()=>n(!0),o=()=>n(!1);return e.on("connect",i),e.on("disconnect",o),n(e.connected),()=>{e.off("connect",i),e.off("disconnect",o)}},[e]);const r=y.useCallback((i,o)=>Cg(i,o),[]);return{socket:e,isConnected:t,on:r}},Rg=6e4;function Pg(e,t,n,r=!0){if(e)return{tone:"live",label:"Live",title:"Connected to the Xenon server. Updates stream in as they happen."};const i=t??n;if(n-i<Rg)return r?{tone:"reconnecting",label:"Reconnecting…",title:"Lost the connection to the Xenon server. Retrying automatically."}:{tone:"reconnecting",label:"Connecting…",title:"Connecting to the Xenon server."};const o=new Date(i).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});return{tone:"down",label:`Disconnected · since ${o}`,title:`No connection to the Xenon server since ${o}. What's on screen may be out of date.`}}function Ng(){const{isConnected:e}=Tg(),[t,n]=y.useState(null),[r,i]=y.useState(()=>Date.now()),[o,s]=y.useState(e);return y.useEffect(()=>{n(e?null:Date.now()),e&&s(!0)},[e]),y.useEffect(()=>{if(e)return;const l=window.setInterval(()=>i(Date.now()),5e3);return()=>window.clearInterval(l)},[e]),Pg(e,t,r,o)}const Yf="xenon.theme",du="dark",Xf="(prefers-color-scheme: light)";function Og(){try{const e=localStorage.getItem(Yf);return e==="light"||e==="system"||e==="dark"?e:du}catch{return du}}function Jf(e,t){return e==="system"?t?"light":"dark":e}function Lg(){return typeof window.matchMedia=="function"&&window.matchMedia(Xf).matches}function Zf(e){document.documentElement.setAttribute("data-theme",e)}function jg(e){try{localStorage.setItem(Yf,e)}catch{}Zf(Jf(e,Lg()))}function Ag(){const[e,t]=y.useState(Og);return y.useEffect(()=>{var o;if(e!=="system"||typeof window.matchMedia!="function")return;const r=window.matchMedia(Xf),i=()=>Zf(Jf("system",r.matches));return(o=r.addEventListener)==null||o.call(r,"change",i),()=>{var s;return(s=r.removeEventListener)==null?void 0:s.call(r,"change",i)}},[e]),[e,r=>{jg(r),t(r)}]}function Ig({className:e,alt:t="Xenon"}){const n="/xenon/";return p.jsxs(p.Fragment,{children:[p.jsx("img",{src:`${n}logo.svg`,alt:t,className:`logo-for-dark ${e??""}`}),p.jsx("img",{src:`${n}logo-light.svg`,alt:t,className:`logo-for-light ${e??""}`})]})}const Dg=[{value:"dark",label:"Dark"},{value:"light",label:"Light"},{value:"system",label:"System"}],Mg=()=>{const e=yn(),{me:t,signOut:n}=El(),r=Ng(),[i,o]=Ag(),[s,l]=y.useState(!1),a=y.useRef(null),u=((t==null?void 0:t.name)??"A").split(" ").map(h=>h[0]).slice(0,2).join("").toUpperCase(),m=(t==null?void 0:t.role)==="SUPER_ADMIN"?"Super admin":(t==null?void 0:t.role)==="ADMIN"?"Admin":"Member";y.useEffect(()=>{const h=E=>{a.current&&!a.current.contains(E.target)&&l(!1)};return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[]);const v=()=>window.dispatchEvent(new CustomEvent("xenon.open-command-palette"));return p.jsx("header",{className:"fixed top-0 left-14 right-0 z-20 h-14 border-b border-[var(--border)] bg-[var(--bg)]/80 backdrop-blur-md",children:p.jsxs("div",{className:"flex items-center h-full px-4 gap-4",children:[p.jsx("button",{type:"button",onClick:()=>e("/overview"),className:"flex items-center gap-3 min-w-0 cursor-pointer","aria-label":"Xenon home",children:p.jsx("div",{className:"flex items-center gap-2",children:p.jsx(Ig,{alt:"Xenon Logo",className:"h-8 w-auto object-contain"})})}),p.jsx("div",{className:"flex-1 max-w-xl mx-auto",children:p.jsxs("button",{type:"button",onClick:v,className:"relative w-full h-9 flex items-center text-left","aria-label":"Open command palette",children:[p.jsx("div",{className:"w-full h-9 pl-9 pr-14 rounded-md bg-[var(--surface)] border border-[var(--border)] text-sm text-[var(--text-dim)] hover:border-[var(--border-strong)] hover:text-[var(--text)] transition-colors flex items-center",children:"Search devices, sessions, settings…"}),p.jsx(jf,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-[var(--text-dim)]"}),p.jsx("kbd",{className:"absolute right-3 top-1/2 -translate-y-1/2 font-mono text-[10px] text-[var(--text-dim)] border border-[var(--border)] rounded px-1.5 py-0.5",children:"⌘K"})]})}),p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsxs("div",{role:"status",title:r.title,className:`flex items-center gap-1.5 px-2.5 py-1 rounded-full border ${r.tone==="live"?"bg-[var(--color-success)]/10 border-[var(--color-success)]/20 text-[var(--color-success)]":r.tone==="reconnecting"?"bg-[var(--amber)]/10 border-[var(--amber)]/25 text-[var(--amber)]":"bg-[var(--red)]/10 border-[var(--red)]/25 text-[var(--red)]"}`,children:[p.jsx("span",{className:`h-1.5 w-1.5 rounded-full bg-current ${r.tone==="live"?"pulse-dot":""}`,"aria-hidden":"true"}),p.jsx("span",{className:"text-[11px] font-medium",children:r.label})]}),p.jsxs("div",{className:"relative",ref:a,children:[p.jsxs("button",{type:"button",className:"flex items-center gap-2 h-9 pl-1.5 pr-2.5 rounded-md border border-[var(--border)] hover:border-[var(--border-strong)] hover:bg-[var(--surface)] transition-colors",onClick:()=>l(h=>!h),"aria-haspopup":"true","aria-expanded":s,children:[p.jsx("span",{className:"h-6 w-6 rounded-full bg-[var(--color-accent)]/15 text-[var(--color-accent)] text-[11px] font-semibold flex items-center justify-center",children:u}),p.jsxs("span",{className:"flex flex-col items-start leading-tight",children:[p.jsx("span",{className:"text-xs text-[var(--text)]",children:(t==null?void 0:t.name)??"Account"}),p.jsx("span",{className:"text-[10px] text-[var(--text-dim)]",children:m})]}),p.jsx(Im,{className:"h-3.5 w-3.5 text-[var(--text-dim)]"})]}),s&&p.jsxs("div",{className:"absolute top-full right-0 mt-2 w-64 rounded-md border border-[var(--border)] bg-[var(--surface)] shadow-lg overflow-hidden",children:[p.jsxs("div",{className:"px-3 py-2",children:[p.jsx("div",{className:"text-[11px] text-[var(--text-dim)] mb-1",children:"System"}),p.jsxs("div",{className:"flex items-center justify-between text-xs text-[var(--text)]",children:[p.jsx("span",{className:"text-[var(--text-muted)]",children:"Version"}),p.jsxs("span",{className:"font-mono text-[var(--text-muted)]",children:["v","2.13.0"]})]})]}),p.jsx("div",{className:"h-px bg-[var(--border)]"}),p.jsxs("div",{className:"px-3 py-2 flex items-center justify-between gap-2",children:[p.jsx("span",{id:"theme-label",className:"text-xs text-[var(--text-muted)]",children:"Theme"}),p.jsx("div",{className:"seg seg-sm",role:"radiogroup","aria-labelledby":"theme-label",children:Dg.map(h=>p.jsx("button",{type:"button",role:"radio","aria-checked":i===h.value,className:`seg-btn${i===h.value?" seg-btn-active":""}`,onClick:()=>o(h.value),children:h.label},h.value))})]}),p.jsx("div",{className:"h-px bg-[var(--border)]"}),p.jsxs("button",{type:"button",onClick:()=>{l(!1),e("/profile")},className:"w-full flex items-center gap-2 px-3 py-2 text-xs text-[var(--text)] hover:bg-[var(--bg)] text-left",children:[p.jsx(yy,{className:"h-3.5 w-3.5 text-[var(--text-dim)]"}),"Profile"]}),t!=null&&t.authDisabled?p.jsx("p",{className:"px-3 py-2 text-xs text-[var(--text-muted)]",children:"Sign-in is off on this server."}):p.jsxs("button",{type:"button",onClick:()=>{l(!1),n()},className:"w-full flex items-center gap-2 px-3 py-2 text-xs text-[var(--red)] hover:bg-[var(--bg)] text-left",children:[p.jsx(Jm,{className:"h-3.5 w-3.5"}),"Logout"]})]})]})]})]})})};class $g extends y.Component{constructor(){super(...arguments),this.state={hasError:!1},this.handleReset=()=>{this.setState({hasError:!1}),window.location.reload()}}static getDerivedStateFromError(t){return{hasError:!0,error:t}}componentDidCatch(t,n){console.error("Uncaught error:",t,n)}render(){return this.state.hasError?this.props.fallback||p.jsxs("div",{className:"error-boundary-container",style:{padding:"4rem 2rem",textAlign:"center",display:"flex",flexDirection:"column",alignItems:"center",gap:"1.5rem",color:"var(--text)",background:"var(--bg-main)",minHeight:"100vh"},children:[p.jsx("div",{style:{color:"var(--accent-red)"},children:p.jsx(cy,{size:64})}),p.jsx("h2",{style:{fontSize:"2rem",fontWeight:700,margin:0},children:"Component exception detected"}),p.jsx("p",{style:{color:"var(--text-muted)",maxWidth:"500px",lineHeight:1.6},children:"An unexpected error occurred while rendering this section. Xenon's isolation engine has contained the fault to prevent a total system crash."}),this.state.error&&p.jsx("pre",{style:{background:"rgb(var(--rgb-black) / 0.3)",padding:"1rem",borderRadius:"8px",fontSize:"0.8rem",color:"var(--accent-red)",maxWidth:"80%",overflowX:"auto"},children:this.state.error.message}),p.jsxs("button",{onClick:this.handleReset,style:{background:"var(--color-accent)",color:"var(--secondary)",border:"none",padding:"0.75rem 2rem",borderRadius:"8px",fontWeight:700,cursor:"pointer",display:"flex",alignItems:"center",gap:"0.5rem",transition:"all 0.2s"},onMouseOver:t=>t.currentTarget.style.transform="translateY(-2px)",onMouseOut:t=>t.currentTarget.style.transform="translateY(0)",children:[p.jsx(Lf,{size:18}),"Reload application"]})]}):this.props.children}}const Ug=y.lazy(()=>V(()=>import("./overview-CxrZ7_6k.js"),__vite__mapDeps([0,1,2,3,4,5,6,7]))),pu=y.lazy(()=>V(()=>import("./device-explorer-BFXpRq6d.js"),__vite__mapDeps([8,6,7,9,10,5,11,1,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,3,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,2,46,47,48,49,50,51]))),hu=y.lazy(()=>V(()=>import("./builds-page-C0fTvIG8.js"),__vite__mapDeps([52,53,54,40,13,41,32,12,14,43,1,37,36,33,3,4,55,6,7,15,16,38,39]))),Bg=y.lazy(()=>V(()=>import("./session-detail-page-ZZyGM413.js"),__vite__mapDeps([56,53,54,45,33,1,9,10,37,36,55,27,57,2,58,59,38,39,5,60,43,30,31,21,18,22,61]))),zg=y.lazy(()=>V(()=>import("./runbook-page-Cnec3VSx.js"),__vite__mapDeps([62,45,63]))),bg=y.lazy(()=>V(()=>import("./apps-vUfu15lX.js"),__vite__mapDeps([64,54,12,13,14,6,7,15,16,21,18,22,23,24,44,19,27,35,43,47,65]))),Fg=y.lazy(()=>V(()=>import("./webhook-settings-DD1XjiOD.js"),__vite__mapDeps([66,23,24,6,7,47,26,37,36,35,5,67,68])).then(e=>({default:e.WebhookSettings}))),Vg=y.lazy(()=>V(()=>import("./settings-DGZ7B_AR.js"),__vite__mapDeps([69,70,12,13,14,71,21,18,22,6,7,36,25,34,19,5,72,57,68])).then(e=>({default:e.Settings}))),qg=y.lazy(()=>V(()=>import("./ai-settings-D7Te8o-a.js"),__vite__mapDeps([73,70,12,13,14,71,6,7,48,36,5,68])).then(e=>({default:e.AISettings}))),Wg=y.lazy(()=>V(()=>import("./maintenance-settings-DaOs00P6.js"),__vite__mapDeps([74,70,12,13,14,71,6,7,47,19,72,68])).then(e=>({default:e.MaintenanceSettings}))),Hg=y.lazy(()=>V(()=>import("./api-keys-DphSVzBr.js"),__vite__mapDeps([75,54,30,31,23,24,6,7,21,18,22,12,13,14,40,41,15,16,26,47,19,27,68])).then(e=>({default:e.ApiKeys}))),Kg=y.lazy(()=>V(()=>import("./teams-eHSyEpbD.js"),__vite__mapDeps([76,54,30,31,23,24,6,7,21,18,22,12,13,14,40,41,15,16,77,26,45,47,68])).then(e=>({default:e.Teams}))),Qg=y.lazy(()=>V(()=>import("./selector-health-page-DsyL58tb.js"),__vite__mapDeps([78,6,7,28,29,12,13,14,55,58,59,38,39,40,41,15,16,79,1,21,18,22,19,27]))),Gg=y.lazy(()=>V(()=>import("./selector-detail-redirect-BG3pxFLw.js"),__vite__mapDeps([80,79]))),Yg=y.lazy(()=>V(()=>import("./DeviceMosaicView-paDEFU4B.js"),__vite__mapDeps([81,11,1,36,46,60,26,28,29,82,43,12,13,14,25,6,7]))),Xg=y.lazy(()=>V(()=>import("./profile-page-BZ_e-Bgw.js"),__vite__mapDeps([83,6,7,54,15,13,16,27,47]))),Jg=y.lazy(()=>V(()=>import("./users-CcSQRoK9.js"),__vite__mapDeps([84,77,54,6,7,12,13,14,40,41,15,16,26,47]))),Zg=y.lazy(()=>V(()=>import("./RecordingsPage-CXfw7wpd.js"),__vite__mapDeps([85,6,7,30,31,12,13,14,38,39,40,41,49,17,18,19,20,26,50,82,86,87]))),ev=y.lazy(()=>V(()=>import("./RecordingPage-BvemyRiy.js"),__vite__mapDeps([88,82,6,7,12,13,14,38,39,21,18,22,17,19,20,46,86,87,45,47,42,43]))),tv=()=>p.jsxs("div",{className:"flex items-center justify-center gap-2 h-full text-xs text-[var(--text-dim)]",children:[p.jsx(Lf,{className:"animate-spin",size:14}),p.jsx("span",{children:"Hydrating view…"})]}),nv=()=>p.jsx($g,{children:p.jsx(y.Suspense,{fallback:p.jsx(tv,{}),children:p.jsxs(Nf,{children:[p.jsx($,{path:"/",element:p.jsx(Wt,{to:"/overview",replace:!0})}),p.jsx($,{path:"/overview",element:p.jsx(Ug,{})}),p.jsx($,{path:"/devices",element:p.jsx(pu,{})}),p.jsx($,{path:"/devices/:udid/control/:tab?",element:p.jsx(pu,{})}),p.jsx($,{path:"/apps",element:p.jsx(bg,{})}),p.jsx($,{path:"/sessions",element:p.jsx(Wt,{to:"/builds",replace:!0})}),p.jsx($,{path:"/sessions/*",element:p.jsx(Wt,{to:"/builds",replace:!0})}),p.jsx($,{path:"/builds",element:p.jsx(hu,{})}),p.jsx($,{path:"/builds/:buildId",element:p.jsx(hu,{})}),p.jsx($,{path:"/builds/:buildId/sessions/:sessionId",element:p.jsx(Bg,{})}),p.jsx($,{path:"/notifications",element:p.jsx(Fg,{})}),p.jsx($,{path:"/settings",element:p.jsx(Vg,{})}),p.jsx($,{path:"/ai-settings",element:p.jsx(qg,{})}),p.jsx($,{path:"/maintenance",element:p.jsx(Wg,{})}),p.jsx($,{path:"/api-keys",element:p.jsx(Hg,{})}),p.jsx($,{path:"/teams",element:p.jsx(Kg,{})}),p.jsx($,{path:"/users",element:p.jsx(Jg,{})}),p.jsx($,{path:"/selector-health",element:p.jsx(Qg,{})}),p.jsx($,{path:"/selector-health/detail",element:p.jsx(Gg,{})}),p.jsx($,{path:"/devices/live",element:p.jsx(Yg,{})}),p.jsx($,{path:"/recordings",element:p.jsx(Zg,{})}),p.jsx($,{path:"/recordings/:groupId",element:p.jsx(ev,{})}),p.jsx($,{path:"/runbooks/:category",element:p.jsx(zg,{})}),p.jsx($,{path:"/profile",element:p.jsx(Xg,{})}),p.jsx($,{path:"*",element:p.jsx(Wt,{to:"/overview",replace:!0})})]})})});let mr=null;function mu(e){mr=e}const rv=new Set(["device_held_by_another_user","device_in_use_by_session"]),iv=new Set(["not_available_through_hub","not_available_for_cloud_phone"]);function ov(e){return!e||typeof e!="object"?!1:rv.has(e.error??"")}const sv=5e3,yu=new Map;function gu(e){if(!mr)return;const t=Date.now(),n=yu.get(e)??0;t-n<sv||(yu.set(e,t),mr(e,"error"))}class ed extends Error{constructor(t,n,r){super(t),this.status=n,this.body=r,this.name="ApiError"}}async function Eo(e,t){if(e.status===403){const n=await e.clone().json().catch(()=>({})),r=n&&(n.error||n.message)||"You do not have permission for this action.";mr&&mr(r,"error")}if(e.status===409){const n=await e.clone().json().catch(()=>({}));ov(n)&&gu(n.message||"This device is in use by another user.")}if(e.status===501){const n=await e.clone().json().catch(()=>({}));iv.has(n==null?void 0:n.error)&&n.message&&gu(n.message)}if(e.status===204||e.status===205)return null;if(t&&(e.status<200||e.status>=300)){const n=await e.json().catch(()=>null),r=n&&typeof n=="object"&&(n.error||n.message)||`Request failed (${e.status})`;throw new ed(String(r),e.status,n)}return e.json()}class lv{makeGETRequest(t){return fetch(this.formatUrl(t)).then(n=>Eo(n,!1))}makePOSTRequest(t,n,r,i={},o={}){return fetch(this.formatUrl(t),{method:"POST",body:JSON.stringify(r||{}),headers:{"Content-Type":"application/json"},...i}).then(s=>Eo(s,!o.resolveErrors))}makeDELETERequest(t,n={}){return fetch(this.formatUrl(t),{method:"DELETE"}).then(r=>Eo(r,!n.resolveErrors))}formatUrl(t){return`/xenon/api${t}`}}const R=new lv;function Bv(e){return e instanceof ed?`The server rejected the change: ${e.message}`:"Couldn't reach the Xenon server. Check your connection and try again."}const td=y.createContext(void 0),zv=()=>{const e=y.useContext(td);if(!e)throw new Error("useToast must be used within a ToastProvider");return e},av=({children:e})=>{const[t,n]=y.useState([]),r=y.useCallback(o=>{n(s=>s.filter(l=>l.id!==o))},[]),i=y.useCallback((o,s="info",l=4e3,a)=>{const u=Math.random().toString(36).substring(2,9);return n(m=>[...m,{id:u,message:o,type:s,duration:l,action:a}]),s!=="loading"&&l>0&&setTimeout(()=>{r(u)},l),u},[r]);return y.useEffect(()=>(mu((o,s="info")=>i(o,s)),()=>mu(null)),[i]),p.jsxs(td.Provider,{value:{toast:i,removeToast:r},children:[e,p.jsx("div",{className:"toast-container","aria-live":"polite","aria-atomic":"true",role:"status",children:t.map(o=>p.jsxs("div",{className:`toast-item toast-${o.type} animate-slide-in`,children:[p.jsxs("div",{className:"toast-icon",children:[o.type==="success"&&p.jsx(Um,{size:18}),o.type==="error"&&p.jsx(Mm,{size:18}),o.type==="info"&&p.jsx(qm,{size:18}),o.type==="loading"&&p.jsx(Ym,{size:18,className:"animate-spin"})]}),p.jsx("div",{className:"toast-message",children:o.message}),o.action&&p.jsx("button",{className:"toast-action",onClick:()=>{var s;r(o.id),(s=o.action)==null||s.onClick()},children:o.action.label}),p.jsx("button",{className:"toast-close",onClick:()=>r(o.id),"aria-label":`Close ${o.type} notification`,children:p.jsx(ky,{size:14})})]},o.id))})]})},uv=[{id:"overview",label:"Overview",icon:Qm,path:"/overview"},{id:"devices",label:"Devices",icon:ay,path:"/devices"},{id:"live-devices",label:"Live devices",icon:dy,path:"/devices/live"},{id:"recordings",label:"Recordings",icon:zm,path:"/recordings"},{id:"apps",label:"Apps",icon:Tm,path:"/apps"},{id:"sessions",label:"Sessions",icon:ey,path:"/builds"},{id:"selector-health",label:"Selector health",icon:Fm,path:"/selector-health"},{id:"notifications",label:"Notifications",icon:Pm,path:"/notifications"},{id:"settings",label:"Settings",icon:iy,path:"/settings",minRole:"ADMIN"},{id:"ai",label:"AI engine",icon:jm,path:"/ai-settings",minRole:"ADMIN"},{id:"maintenance",label:"Maintenance",icon:sy,path:"/maintenance",minRole:"ADMIN"},{id:"teams",label:"Teams",icon:vy,path:"/teams",minRole:"ADMIN"},{id:"users",label:"Users",icon:hy,path:"/users",minRole:"ADMIN"},{id:"apikeys",label:"API keys",icon:Hm,path:"/api-keys",minRole:"ADMIN"}],vu={SUPER_ADMIN:3,ADMIN:2,MEMBER:1};function cv(e,t){return t?(e?vu[e]??0:0)>=vu[t]:!0}const fv=()=>{const e=yn(),t=We(),{me:n}=El(),r=uv.filter(l=>cv(n==null?void 0:n.role,l.minRole)),i=t.pathname.replace(/\/$/,"")||"/",o=r.filter(l=>i===l.path||i.startsWith(l.path+"/")).sort((l,a)=>a.path.length-l.path.length)[0],s=l=>(o==null?void 0:o.path)===l;return p.jsxs("aside",{className:"fixed inset-y-0 left-0 z-30 w-14 border-r border-[var(--border)] bg-[var(--surface)] flex flex-col items-center py-3",children:[p.jsx("nav",{className:"flex-1 flex flex-col gap-1 w-full items-center",children:r.map(l=>{const a=l.icon,u=s(l.path);return p.jsxs("button",{type:"button",onClick:()=>e(l.path),className:`group relative w-full flex justify-center py-2.5 mx-1 rounded-md transition-colors ${u?"bg-[var(--surface-2)]":"hover:bg-[var(--surface-2)]/60"}`,"aria-label":l.label,"aria-current":u?"page":void 0,children:[p.jsx("span",{className:`absolute left-0 top-1 bottom-1 w-[3px] rounded-r transition-all ${u?"bg-[var(--color-accent)]":"bg-transparent"}`}),p.jsx(a,{className:`h-[18px] w-[18px] transition-colors ${u?"text-[var(--color-accent)]":"text-[var(--text-dim)] group-hover:text-[var(--text)]"}`,strokeWidth:u?2.25:2}),p.jsx("span",{className:"pointer-events-none absolute left-full ml-2 top-1/2 -translate-y-1/2 whitespace-nowrap rounded-md bg-[var(--surface-2)] border border-[var(--border-strong)] px-2 py-1 text-xs text-[var(--text)] opacity-0 group-hover:opacity-100 transition-opacity z-50 shadow-lg",children:l.label})]},l.id)})}),p.jsxs("button",{type:"button",className:"group relative w-full flex justify-center py-2.5 mt-2","aria-label":"API docs",onClick:()=>window.open(window.location.origin+"/xenon/api-docs","_blank"),children:[p.jsx(Om,{className:"h-[18px] w-[18px] text-[var(--text-dim)] group-hover:text-[var(--text)] transition-colors"}),p.jsx("span",{className:"pointer-events-none absolute left-full ml-2 top-1/2 -translate-y-1/2 whitespace-nowrap rounded-md bg-[var(--surface-2)] border border-[var(--border-strong)] px-2 py-1 text-xs text-[var(--text)] opacity-0 group-hover:opacity-100 transition-opacity z-50 shadow-lg",children:"API docs"})]})]})};class An{static getDevices(){return R.makeGETRequest(`/device?t=${Date.now()}`)}static getPendingSessionsCount(){return R.makeGETRequest("/queue/length")}static getPendingSessions(){return R.makeGETRequest("/queue")}static getQueueSummary(){return R.makeGETRequest("/queue/summary")}static getQueueStatus(t){return R.makeGETRequest(`/queue/status/${t}`)}static getBuilds(){return R.makeGETRequest("/build")}static getSessions(t={}){var i;let r=`/session?t=${Date.now()}`;return t.buildId&&(r+=`&buildId=${encodeURIComponent(t.buildId)}`),t.since&&(r+=`&since=${encodeURIComponent(t.since)}`),t.limit&&(r+=`&limit=${t.limit}`),t.before&&(r+=`&before=${encodeURIComponent(t.before)}`),t.beforeId&&(r+=`&beforeId=${encodeURIComponent(t.beforeId)}`),t.query&&(r+=`&query=${encodeURIComponent(t.query)}`),t.status&&(r+=`&status=${encodeURIComponent(t.status)}`),t.platform&&(r+=`&platform=${encodeURIComponent(t.platform)}`),(i=t.ids)!=null&&i.length&&(r+=`&ids=${t.ids.map(encodeURIComponent).join(",")}`),R.makeGETRequest(r)}static getSessionSummary(t={}){let n=`/session-summary?t=${Date.now()}`;return t.since&&(n+=`&since=${encodeURIComponent(t.since)}`),t.buildId&&(n+=`&buildId=${encodeURIComponent(t.buildId)}`),R.makeGETRequest(n)}static getSession(t){return R.makeGETRequest(`/session/${t}`)}static getSessionLogs(t){return R.makeGETRequest(`/session/${t}/session_log`)}static getDeviceLogs(t){return R.makeGETRequest(`/session/${t}/logs/device`)}static getDebugLogs(t){return R.makeGETRequest(`/session/${t}/logs/debug`)}static getProfilingData(t){return R.makeGETRequest(`/session/${t}/profiling`)}static getSessionMetrics(t){return R.makeGETRequest(`/session/${t}/metrics`)}static omniScan(t){return R.makeGETRequest(`/session/${t}/xenon/omni-scan`)}static omniScanControl(t){return R.makeGETRequest(`/control/${t}/omni-scan`)}static testAiLocator(t,n,r){return R.makePOSTRequest(`/session/${t}/xenon/test-locator`,{},{strategy:n,selector:r})}static getDisplayState(t){return R.makeGETRequest(`/control/${t}/display`)}static getAppiumSession(t){return R.makeGETRequest(`/control/${t}/appium-session`)}static async verifyLocator(t,n,r){const i=t.startsWith("/")?t:`/${t}`,s=await(await fetch(`${i}/session/${n}/xenon/verify-locator`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)})).json().catch(()=>({}));return(s==null?void 0:s.value)??s}static testAiLocatorControl(t,n,r){return R.makePOSTRequest(`/control/${t}/test-locator`,{},{strategy:n,selector:r})}static blockDevice(t,n){return R.makePOSTRequest("/block",{},{udid:t,host:n})}static unblockDevice(t,n){return R.makePOSTRequest("/unblock",{},{udid:t,host:n})}static updateDeviceTags(t,n,r){return R.makePOSTRequest("/device/tags",{},{udid:t,host:n,tags:r})}static async listTeams(){const t=await fetch("/xenon/api/teams",{credentials:"include"});if(!t.ok)throw new Error(`listTeams failed (${t.status})`);return(await t.json()).map(r=>({id:r.id,name:r.name}))}static async setDeviceTeam(t,n){const r=await fetch(`/xenon/api/grid/device/${encodeURIComponent(t)}/team`,{method:"PUT",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({teamId:n})});if(!r.ok&&r.status!==204){const i=await r.json().catch(()=>({}));throw new Error(i.error||`setDeviceTeam failed (${r.status})`)}}static getSessionLiveVideoUrl(t){return R.formatUrl(`/session/${t}/live_video`)}static getReservations(){return R.makeGETRequest("/reservation")}static reserveDevice(t,n,r,i,o){return R.makePOSTRequest("/reservation",{},{udid:t,host:n,reservedBy:r,duration:i,reason:o},{},{resolveErrors:!0})}static releaseReservation(t,n){return R.makeDELETERequest(`/reservation/${t}/${encodeURIComponent(n)}`)}static extendReservation(t,n,r){return R.makePOSTRequest(`/reservation/${t}/${encodeURIComponent(n)}/extend`,{},{duration:r})}static getAssetUrl(t){const n=(t??"").replace(/^[\\/]+/,"").split(/[\\/]/);if(n.length!==3||n.some(s=>!s))return"";const[r,i,o]=n;return["screenshots","video","performance"].includes(i)?`/xenon/api/session/${encodeURIComponent(r)}/asset/${i}/${encodeURIComponent(o)}`:""}static tap(t,n,r){return R.makePOSTRequest(`/control/${t}/tap`,{},{x:n,y:r})}static swipe(t,n,r,i,o){return R.makePOSTRequest(`/control/${t}/swipe`,{},{x:n,y:r,endX:i,endY:o})}static typeText(t,n){return R.makePOSTRequest(`/control/${t}/text`,{},{text:n})}static pressKey(t,n){return R.makePOSTRequest(`/control/${t}/keyevent`,{},{keyCode:n})}static getClipboard(t){return R.makeGETRequest(`/control/${t}/clipboard`)}static setClipboard(t,n){return R.makePOSTRequest(`/control/${t}/clipboard`,{},{content:n})}static getScreenshot(t){return R.makeGETRequest(`/control/${t}/screenshot`)}static touchAndHold(t,n,r,i){return R.makePOSTRequest(`/control/${t}/touchAndHold`,{},{x:n,y:r,duration:i})}static lock(t){return R.makePOSTRequest(`/control/${t}/lock`,{},{})}static unlock(t){return R.makePOSTRequest(`/control/${t}/unlock`,{},{})}static installApp(t,n){return R.makePOSTRequest(`/control/${t}/install`,{},{appPath:n})}static startStream(t){return R.makePOSTRequest(`/control/${t}/stream/start`,{},{},{},{resolveErrors:!0})}static stopStream(t){return R.makePOSTRequest(`/control/${t}/stream/stop`,{},{},{keepalive:!0})}static leaveStream(t){return R.makePOSTRequest(`/control/${t}/stream/leave`,{},{},{keepalive:!0})}static uninstallApp(t,n){return R.makePOSTRequest(`/control/${t}/uninstall`,{},{bundleId:n})}static uploadAndInstallApp(t,n){const r=new FormData;return r.append("app",n),fetch(`/xenon/api/control/${t}/upload-install`,{method:"POST",body:r}).then(i=>i.json())}static listApps(t){return R.makeGETRequest(`/control/${t}/apps`)}static getLogs(t){return R.makeGETRequest(`/control/${t}/logs`)}static getApps(){return R.makeGETRequest("/apps")}static uploadApp(t,n=null){const r=new FormData;return r.append("app",t),n&&r.append("teamId",n),fetch("/xenon/api/apps/upload",{method:"POST",body:r}).then(i=>i.json())}static async setAppTeam(t,n){const r=await fetch(`/xenon/api/apps/${encodeURIComponent(t)}/team`,{method:"PUT",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({teamId:n})});if(!r.ok){const i=await r.json().catch(()=>({}));throw new Error(i.error||`setAppTeam failed (${r.status})`)}}static deleteApp(t){return R.makeDELETERequest(`/apps/${t}`)}static installRepositoryApp(t,n){return R.makePOSTRequest(`/control/${t}/install-repository-app`,{},{appId:n},{},{resolveErrors:!0})}static executeShell(t,n){return R.makePOSTRequest(`/control/${t}/shell`,{},{command:n},{},{resolveErrors:!0})}static getInspectorSnapshot(t){return R.makeGETRequest(`/control/${t}/inspector/snapshot`)}static getWebhookConfigs(){return R.makeGETRequest("/webhook")}static addWebhookConfig(t,n,r,i){return R.makePOSTRequest("/webhook",{},{url:t,events:n,type:r,payloadTemplate:i})}static deleteWebhookConfig(t){return R.makeDELETERequest(`/webhook/${t}`)}static testWebhook(t,n){return R.makePOSTRequest("/webhook/test",{},{url:t,type:n})}static getGlobalConfig(){return R.makeGETRequest("/config")}static updateGlobalConfig(t){return R.makePOSTRequest("/config",{},t)}static testAIConfig(t){return R.makePOSTRequest("/config/test-ai",{},t,{},{resolveErrors:!0})}static resetMetrics(){return R.makePOSTRequest("/config/reset-metrics",{},{})}static getRecentHealingEvents(t=50){return R.makeGETRequest(`/healing/events?limit=${t}&t=${Date.now()}`)}static getHealingSummary(t=30,n=0){return R.makeGETRequest(`/healing/summary?windowDays=${t}&tz=${n}&t=${Date.now()}`)}static getHealingSelectors(t){const n=new URLSearchParams({tab:t.tab,days:String(t.days),sort:t.sort??"heals",page:String(t.page??1),pageSize:String(t.pageSize??50),t:String(Date.now())});return t.q&&n.set("q",t.q),t.platform&&n.set("platform",t.platform),t.method&&n.set("method",t.method),R.makeGETRequest(`/healing/selectors?${n.toString()}`)}static async getSelectorPanel(t,n,r,i){const o=new URLSearchParams({strategy:t,selector:n,days:String(r),tz:String(i),t:String(Date.now())}),s=await fetch(`/xenon/api/healing/selectors/detail?${o.toString()}`,{credentials:"include"}),l=await s.json().catch(()=>null);return{status:s.status,body:l}}static async postSelectorStateAction(t){const n=await fetch("/xenon/api/healing/selector/state",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok){const r=await n.json().catch(()=>({})),i=new Error(r.error??`Selector state action failed (${n.status})`);throw i.status=n.status,i.currentStatus=r.currentStatus??null,i}return n.json()}static sendHealingDigest(t={}){return R.makePOSTRequest("/healing/digest/send",{},t)}static async exportBuild(t,n,r){const i=await fetch(`/xenon/api/build/${encodeURIComponent(t)}/export`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({format:n,...r?{sessionIds:r}:{}})});if(!i.ok){const u=await i.text().catch(()=>i.statusText);throw new Error(`Export failed (${i.status}): ${u||i.statusText}`)}const o=i.headers.get("Content-Disposition")||"",s=/filename="?([^";]+)"?/.exec(o),l=s?s[1]:`build-${t}-sessions.${n}`;return{blob:await i.blob(),filename:l}}}function dv(e){if(!(e instanceof HTMLElement))return!1;if(e.isContentEditable)return!0;const t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||t==="SELECT"}function pv(){const[e,t]=y.useState(!1);return y.useEffect(()=>{const n=i=>{(i.metaKey||i.ctrlKey)&&i.key.toLowerCase()==="k"&&!dv(i.target)&&(i.preventDefault(),t(o=>!o)),i.key==="Escape"&&t(!1)},r=()=>t(!0);return window.addEventListener("keydown",n),window.addEventListener("xenon.open-command-palette",r),()=>{window.removeEventListener("keydown",n),window.removeEventListener("xenon.open-command-palette",r)}},[]),{open:e,setOpen:t}}function wu(e,t){if(!e)return 0;const n=e.toLowerCase(),r=t.toLowerCase();if(r===n)return 1e4;if(r.startsWith(n))return 5e3-(r.length-n.length);let i=0,o=0,s=0;for(let l=0;l<n.length;l++){const a=n[l],u=r.indexOf(a,i);if(u===-1)return 0;u===i?(s+=1,o+=20+s*5):(s=0,o+=10-Math.min(u-i,10)),i=u+1}return Math.max(o,1)}const ku=[{id:"nav:overview",kind:"nav",label:"Overview",path:"/overview"},{id:"nav:devices",kind:"nav",label:"Devices",path:"/devices"},{id:"nav:live",kind:"nav",label:"Live devices",path:"/devices/live"},{id:"nav:builds",kind:"nav",label:"Sessions",path:"/builds"},{id:"nav:apps",kind:"nav",label:"Apps",path:"/apps"},{id:"nav:selector-health",kind:"nav",label:"Selector health",path:"/selector-health"},{id:"nav:notifications",kind:"nav",label:"Notifications",path:"/notifications"},{id:"nav:settings",kind:"nav",label:"Settings",path:"/settings"},{id:"nav:ai-settings",kind:"nav",label:"AI engine",path:"/ai-settings"},{id:"nav:maintenance",kind:"nav",label:"Maintenance",path:"/maintenance"},{id:"nav:teams",kind:"nav",label:"Teams",path:"/teams"},{id:"nav:api-keys",kind:"nav",label:"API keys",path:"/api-keys"},{id:"nav:users",kind:"nav",label:"Users",path:"/users"},{id:"nav:profile",kind:"nav",label:"Profile",path:"/profile"}];class hv{constructor(){this.devices=[],this.builds=[],this.sessions=[],this.teams=[],this.keys=[],this.apps=[]}setDevices(t){this.devices=t.map(n=>({id:`device:${n.udid}`,kind:"device",label:n.name||n.udid,sub:n.udid,path:`/devices/${n.udid}/control`}))}setBuilds(t){this.builds=t.map(n=>({id:`build:${n.id}`,kind:"build",label:n.name||n.id,sub:typeof n.sessionCount=="number"?`${n.sessionCount} session${n.sessionCount===1?"":"s"}${n.failedCount?` · ${n.failedCount} failed`:""}`:n.id,path:`/builds/${encodeURIComponent(n.id)}`}))}setSessions(t){this.sessions=t.map(n=>({id:`session:${n.id}`,kind:"session",label:n.name||n.id,sub:n.id,path:`/builds?session=${encodeURIComponent(n.id)}`}))}setTeams(t){this.teams=t.map(n=>({id:`team:${n.id}`,kind:"team",label:n.name||n.id,sub:n.id,path:`/teams?team=${encodeURIComponent(n.id)}`}))}setKeys(t){this.keys=t.map(n=>({id:`key:${n.id}`,kind:"key",label:n.name||n.id,sub:n.id,path:`/api-keys?key=${encodeURIComponent(n.id)}`}))}setApps(t){this.apps=t.map(n=>({id:`app:${n.id}`,kind:"app",label:n.name||n.id,sub:n.id,path:`/apps?app=${encodeURIComponent(n.id)}`}))}search(t,n=8){return t.trim()?[...ku,...this.devices,...this.builds,...this.sessions,...this.teams,...this.keys,...this.apps].map(i=>{const o=wu(t,i.label),s=i.sub?wu(t,i.sub):0;return{it:i,score:Math.max(o,s)}}).filter(i=>i.score>0).sort((i,o)=>o.score-i.score).slice(0,n).map(i=>i.it):ku.slice(0,n)}}const mv={nav:"Navigation",device:"Devices",build:"Builds",session:"Running sessions",team:"Teams",key:"API keys",app:"Apps"},yv=["nav","device","build","session","team","key","app"],gv=()=>{const{open:e,setOpen:t}=pv(),[n,r]=y.useState(""),[i,o]=y.useState(0),s=yn(),l=y.useRef(new hv),a=y.useRef(null);y.useEffect(()=>{if(!e)return;Promise.all([An.getDevices().catch(()=>[]),An.getSessions().catch(()=>[]),An.getApps().catch(()=>[]),An.listTeams().catch(()=>[]),An.getBuilds().catch(()=>[])]).then(([k,c,f,d,g])=>{Array.isArray(k)&&l.current.setDevices(k),Array.isArray(g)&&l.current.setBuilds(g),Array.isArray(c)&&l.current.setSessions(c),Array.isArray(f)&&l.current.setApps(f),Array.isArray(d)&&l.current.setTeams(d)});const x=setTimeout(()=>{var k;return(k=a.current)==null?void 0:k.focus()},0);return()=>clearTimeout(x)},[e]),y.useEffect(()=>{e||(r(""),o(0))},[e]);const u=y.useMemo(()=>l.current.search(n,8),[n,e]),m=y.useMemo(()=>{const x=new Map;return u.forEach(k=>{const c=x.get(k.kind)||[];c.push(k),x.set(k.kind,c)}),x},[u]),v=y.useCallback(x=>{s(x.path),t(!1)},[s,t]),h=x=>{x.key==="ArrowDown"?(x.preventDefault(),o(k=>Math.min(k+1,Math.max(u.length-1,0)))):x.key==="ArrowUp"?(x.preventDefault(),o(k=>Math.max(k-1,0))):x.key==="Enter"&&(x.preventDefault(),u[i]&&v(u[i]))};if(!e)return null;let E=-1;return p.jsx("div",{className:"cp-overlay",onClick:()=>t(!1),children:p.jsxs("div",{className:"cp",role:"dialog","aria-modal":!0,"aria-label":"Command palette",onClick:x=>x.stopPropagation(),children:[p.jsxs("div",{className:"cp-input-row",children:[p.jsx(jf,{size:14}),p.jsx("input",{ref:a,className:"cp-input",placeholder:"Search devices, sessions, settings…",value:n,onChange:x=>{r(x.target.value),o(0)},onKeyDown:h}),p.jsx("span",{className:"cp-esc",children:"ESC"})]}),p.jsxs("div",{className:"cp-results",children:[u.length===0&&p.jsx("div",{className:"cp-empty",children:"No results."}),yv.filter(x=>m.has(x)).map(x=>p.jsxs("div",{className:"cp-group",children:[p.jsx("div",{className:"cp-group-head",children:mv[x]}),m.get(x).map(k=>{E+=1;const c=E===i;return p.jsxs("button",{type:"button",className:`cp-item${c?" cp-item-active":""}`,onMouseEnter:()=>{o(E)},onClick:()=>v(k),children:[p.jsx("span",{className:"cp-item-label",children:k.label}),k.sub&&p.jsx("span",{className:"cp-item-sub",children:k.sub})]},k.id)})]},x))]})]})})};function vv({children:e}){const{loading:t,me:n}=El(),r=We();if(t)return p.jsx("div",{style:{padding:40,textAlign:"center",color:"var(--text-dim)"},children:"Loading…"});if(!n){const i=encodeURIComponent(r.pathname+r.search),o=Ny()?"&reason=expired":"";return p.jsx(Wt,{to:`/login?next=${i}${o}`,replace:!0})}return p.jsx(p.Fragment,{children:e})}const xu="Xenon",wv={"/overview":"Overview","/devices":"Devices","/devices/live":"Live devices","/recordings":"Recordings","/apps":"Apps","/builds":"Sessions","/selector-health":"Selector health","/selector-health/detail":"Selector health","/notifications":"Notifications","/settings":"Settings","/ai-settings":"AI engine","/maintenance":"Maintenance","/teams":"Teams","/users":"Users","/api-keys":"API keys","/profile":"Profile","/login":"Sign in","/forgot-password":"Forgot password","/reset-password":"Reset password"},nd=new Map;function bv(e,t){t&&nd.set(e,t)}function kv(e){const t=e.replace(/\/+$/,"")||"/";let n=wv[t];if(!n){let r;if(r=t.match(/^\/devices\/([^/]+)\/control/)){const i=decodeURIComponent(r[1]);n=`${nd.get(i)||i} · Device`}else/^\/builds\/[^/]+\/sessions\//.test(t)?n="Session":/^\/builds\/[^/]+$/.test(t)?n="Sessions":/^\/recordings\/[^/]+$/.test(t)?n="Recording":(r=t.match(/^\/runbooks\/([^/]+)/))?n=`Runbook · ${decodeURIComponent(r[1])}`:t.startsWith("/reset-password/")&&(n="Reset password")}return n?`${n} · ${xu}`:xu}function xv(){const{pathname:e}=We();return y.useEffect(()=>{document.title=kv(e)},[e]),null}const Ev=y.lazy(()=>V(()=>import("./login-Ct2iW066.js"),__vite__mapDeps([89,13,90,91,61,48,25,2]))),_v=y.lazy(()=>V(()=>import("./forgot-password-CoE7Ugtx.js"),__vite__mapDeps([92,90,91,61]))),Eu=y.lazy(()=>V(()=>import("./reset-password-lfNz8Rm1.js"),__vite__mapDeps([93,91,61]))),Sv=y.lazy(()=>V(()=>import("./ApiKeyGate-CA5KFHHJ.js"),[]).then(e=>({default:e.ApiKeyGate})));function Cv(){return p.jsx(av,{children:p.jsxs("div",{className:"min-h-screen w-full bg-[var(--bg)] text-[var(--text)]",children:[p.jsx(fv,{}),p.jsx(Mg,{}),p.jsx("main",{className:"pl-14 pt-14 h-screen overflow-y-auto",children:p.jsx(nv,{})}),p.jsx(gv,{})]})})}function Tv(){return p.jsxs(ym,{basename:"/xenon",children:[p.jsx(xv,{}),p.jsx(Oy,{children:p.jsx(y.Suspense,{fallback:p.jsx("div",{style:{padding:40},children:"Loading…"}),children:p.jsxs(Nf,{children:[p.jsx($,{path:"/login",element:p.jsx(Ev,{})}),p.jsx($,{path:"/forgot-password",element:p.jsx(_v,{})}),p.jsx($,{path:"/reset-password",element:p.jsx(Eu,{})}),p.jsx($,{path:"/reset-password/:token",element:p.jsx(Eu,{})}),p.jsx($,{path:"/api-key-gate",element:p.jsx(Sv,{children:p.jsx(Wt,{to:"/overview",replace:!0})})}),p.jsx($,{path:"*",element:p.jsx(vv,{children:p.jsx(Cv,{})})})]})})})]})}wf.render(p.jsx(y.StrictMode,{children:p.jsx(Tv,{})}),document.getElementById("root"));export{Av as $,Lf as A,$v as B,Mm as C,bv as D,kv as E,Ov as F,_u as G,Om as H,qm as I,Tm as J,Pm as K,ru as L,ey as M,Wt as N,Fm as O,iy as P,jm as Q,hd as R,sy as S,dy as T,yy as U,Bv as V,Hm as W,An as X,vy as Y,zm as Z,ov as _,We as a,hy as a0,Rv as a1,md as a2,El as b,B as c,Py as d,Nv as e,Ym as f,Iv as g,jv as h,Pv as i,p as j,Dv as k,Lv as l,Mv as m,Ig as n,Bi as o,Tg as p,ay as q,y as r,Qm as s,zv as t,yn as u,ky as v,Im as w,wf as x,cy as y,jf as z};
@@ -1 +1 @@
1
- import{r as p,j as o}from"./index-ClrpAMAT.js";import{c as e}from"./utils-CDN07tui.js";const n=p.forwardRef(({className:r,type:s,...t},a)=>o.jsx("input",{type:s,className:e("input-base",r),ref:a,...t}));n.displayName="Input";export{n as I};
1
+ import{r as p,j as o}from"./index-CHOr4JCs.js";import{c as e}from"./utils-CDN07tui.js";const n=p.forwardRef(({className:r,type:s,...t},a)=>o.jsx("input",{type:s,className:e("input-base",r),ref:a,...t}));n.displayName="Input";export{n as I};
@@ -1 +1 @@
1
- import{j as a,r as g}from"./index-ClrpAMAT.js";const I=({header:e,footer:t,action:n,padded:o=!0,className:s,children:x})=>a.jsxs("div",{className:`card${s?" "+s:""}`,children:[(e||n)&&a.jsxs("div",{className:"card-header",children:[a.jsx("div",{className:"card-header-title",children:e}),n&&a.jsx("div",{className:"card-header-action",children:n})]}),a.jsx("div",{className:o?"card-body":"card-body-flush",children:x}),t&&a.jsx("div",{className:"card-footer",children:t})]});function E(e){if(!e||typeof e!="object"||Array.isArray(e))return null;const t=e;return!Array.isArray(t.samples)||!t.series||typeof t.series!="object"?null:{platform:String(t.platform??""),intervalMs:Number(t.intervalMs)||2e3,appId:typeof t.appId=="string"?t.appId:null,series:{deviceCpu:!!t.series.deviceCpu,deviceMem:!!t.series.deviceMem,appCpu:!!t.series.appCpu,appMem:!!t.series.appMem},recording:t.recording==="sampling"||t.recording==="stopped"||t.recording==="off"?t.recording:null,samples:t.samples}}function L(e){let t=-1/0,n=0,o=0;for(const s of e)s===null||!Number.isFinite(s)||(t=Math.max(t,s),n+=s,o+=1);return o===0?null:{peak:t,average:n/o}}function k(e){const t=Math.max(0,Math.round(e/1e3)),n=Math.floor(t/3600),o=Math.floor(t%3600/60),s=String(t%60).padStart(2,"0");return n>0?`${n}:${String(o).padStart(2,"0")}:${s}`:`${o}:${s}`}function R(e){return e===0?"0%":`${e<10?e.toFixed(1):Math.round(e)}%`}function W(e){return e>=1024?`${(e/1024).toFixed(1)} GB`:`${Math.round(e)} MB`}const M=1e3,N=600;function $(e){if(!(e>0))return 1;const t=10**Math.floor(Math.log10(e));for(const n of[1,1.5,2,2.5,3,4,5,6,8,10])if(n*t>=e)return n*t;return 10*t}function w(e,t){if(e.length===0)return-1;let n=0,o=e.length-1;for(;n<o;){const s=n+o>>1;e[s]<t?n=s+1:o=s}return n>0&&t-e[n-1]<=e[n]-t?n-1:n}function S(e,t=N){const n=e.length;if(n<=t)return Array.from({length:n},(l,u)=>u);const o=Math.floor((t-2)/3),s=n/o,x=new Set([0,n-1]);for(let l=0;l<o;l+=1){const u=Math.min(n,Math.floor((l+1)*s));let i=-1,p=-1,f=-1;for(let c=Math.floor(l*s);c<u;c+=1){const h=e[c];if(h==null){f<0&&(f=c);continue}(i<0||h<e[i])&&(i=c),(p<0||h>e[p])&&(p=c)}for(const c of[i,p,f])c>=0&&x.add(c)}return Array.from(x).sort((l,u)=>l-u)}const b=e=>Math.round(e*100)/100;function A(e,t,n,o,s,x,l){const u=[];let i=!1;for(const p of n){const f=e[p];if(f==null){i=!1;continue}const c=t[p]/o*x,h=l-Math.min(f,s)/s*l;u.push(`${i?"L":"M"}${b(c)} ${b(h)}`),i=!0}return u.join(" ")}const B=({times:e,series:t,yMax:n,formatValue:o,formatTime:s,ariaLabel:x,height:l=140})=>{const u=g.useRef(null),[i,p]=g.useState(null),f=Math.max(e.length?e[e.length-1]:0,1),c=g.useMemo(()=>{if(n!==void 0)return n;let r=0;for(const d of t)for(const v of d.values)v!==null&&v>r&&(r=v);return $(r)},[t,n]),h=g.useMemo(()=>t.map(r=>S(r.values)),[t]),y=r=>{var j;const d=(j=u.current)==null?void 0:j.getBoundingClientRect();if(!d||d.width<=0||e.length===0)return;const v=Math.min(1,Math.max(0,(r.clientX-d.left)/d.width));p(w(e,v*f))},m=i!==null?e[i]/f*100:0;return a.jsxs("div",{className:"flex gap-2",children:[a.jsxs("div",{className:"flex w-14 flex-col justify-between text-right text-[10px] tabular-nums text-[var(--text-dim)]",style:{height:l},children:[a.jsx("span",{children:o(c)}),a.jsx("span",{children:o(0)})]}),a.jsxs("div",{ref:u,"data-testid":"line-chart",className:"relative min-w-0 flex-1",style:{height:l},onMouseMove:y,onMouseLeave:()=>p(null),children:[a.jsxs("svg",{role:"img","aria-label":x,viewBox:`0 0 ${M} ${l}`,preserveAspectRatio:"none",className:"absolute inset-0 h-full w-full overflow-visible",children:[[0,.5,1].map(r=>a.jsx("line",{x1:0,x2:M,y1:r*l,y2:r*l,stroke:"var(--border)",strokeWidth:1,vectorEffect:"non-scaling-stroke"},r)),t.map((r,d)=>a.jsx("path",{"data-series":r.key,d:A(r.values,e,h[d],f,c,M,l),fill:"none",stroke:r.color,strokeWidth:1.5,strokeLinejoin:"round",strokeDasharray:r.dashed?"4 3":void 0,vectorEffect:"non-scaling-stroke"},r.key)),i!==null&&a.jsx("line",{x1:m/100*M,x2:m/100*M,y1:0,y2:l,stroke:"var(--text-muted)",strokeWidth:1,vectorEffect:"non-scaling-stroke"})]}),i!==null&&a.jsxs("div",{role:"tooltip",className:"pointer-events-none absolute top-1 z-10 whitespace-nowrap rounded-md border border-[var(--border-strong)] bg-[var(--surface)] px-2 py-1 text-[11px] text-[var(--text)]",style:m>60?{right:`${100-m}%`,marginRight:8}:{left:`${m}%`,marginLeft:8},children:[a.jsx("div",{className:"tabular-nums text-[var(--text-dim)]",children:(s??k)(e[i])}),t.map(r=>{var v;const d=r.values[i];return a.jsxs("div",{className:"flex items-center gap-1.5 tabular-nums",children:[a.jsx("span",{className:"inline-block h-0.5 w-3",style:{background:r.color}}),a.jsx("span",{className:"text-[var(--text-muted)]",children:((v=r.pointLabels)==null?void 0:v[i])??r.label}),a.jsx("span",{className:"ml-auto pl-3",children:d==null?"—":o(d)})]},r.key)})]})]})]})};export{I as C,B as L,W as a,E as b,R as f,$ as n,L as s};
1
+ import{j as a,r as g}from"./index-CHOr4JCs.js";const I=({header:e,footer:t,action:n,padded:o=!0,className:s,children:x})=>a.jsxs("div",{className:`card${s?" "+s:""}`,children:[(e||n)&&a.jsxs("div",{className:"card-header",children:[a.jsx("div",{className:"card-header-title",children:e}),n&&a.jsx("div",{className:"card-header-action",children:n})]}),a.jsx("div",{className:o?"card-body":"card-body-flush",children:x}),t&&a.jsx("div",{className:"card-footer",children:t})]});function E(e){if(!e||typeof e!="object"||Array.isArray(e))return null;const t=e;return!Array.isArray(t.samples)||!t.series||typeof t.series!="object"?null:{platform:String(t.platform??""),intervalMs:Number(t.intervalMs)||2e3,appId:typeof t.appId=="string"?t.appId:null,series:{deviceCpu:!!t.series.deviceCpu,deviceMem:!!t.series.deviceMem,appCpu:!!t.series.appCpu,appMem:!!t.series.appMem},recording:t.recording==="sampling"||t.recording==="stopped"||t.recording==="off"?t.recording:null,samples:t.samples}}function L(e){let t=-1/0,n=0,o=0;for(const s of e)s===null||!Number.isFinite(s)||(t=Math.max(t,s),n+=s,o+=1);return o===0?null:{peak:t,average:n/o}}function k(e){const t=Math.max(0,Math.round(e/1e3)),n=Math.floor(t/3600),o=Math.floor(t%3600/60),s=String(t%60).padStart(2,"0");return n>0?`${n}:${String(o).padStart(2,"0")}:${s}`:`${o}:${s}`}function R(e){return e===0?"0%":`${e<10?e.toFixed(1):Math.round(e)}%`}function W(e){return e>=1024?`${(e/1024).toFixed(1)} GB`:`${Math.round(e)} MB`}const M=1e3,N=600;function $(e){if(!(e>0))return 1;const t=10**Math.floor(Math.log10(e));for(const n of[1,1.5,2,2.5,3,4,5,6,8,10])if(n*t>=e)return n*t;return 10*t}function w(e,t){if(e.length===0)return-1;let n=0,o=e.length-1;for(;n<o;){const s=n+o>>1;e[s]<t?n=s+1:o=s}return n>0&&t-e[n-1]<=e[n]-t?n-1:n}function S(e,t=N){const n=e.length;if(n<=t)return Array.from({length:n},(l,u)=>u);const o=Math.floor((t-2)/3),s=n/o,x=new Set([0,n-1]);for(let l=0;l<o;l+=1){const u=Math.min(n,Math.floor((l+1)*s));let i=-1,p=-1,f=-1;for(let c=Math.floor(l*s);c<u;c+=1){const h=e[c];if(h==null){f<0&&(f=c);continue}(i<0||h<e[i])&&(i=c),(p<0||h>e[p])&&(p=c)}for(const c of[i,p,f])c>=0&&x.add(c)}return Array.from(x).sort((l,u)=>l-u)}const b=e=>Math.round(e*100)/100;function A(e,t,n,o,s,x,l){const u=[];let i=!1;for(const p of n){const f=e[p];if(f==null){i=!1;continue}const c=t[p]/o*x,h=l-Math.min(f,s)/s*l;u.push(`${i?"L":"M"}${b(c)} ${b(h)}`),i=!0}return u.join(" ")}const B=({times:e,series:t,yMax:n,formatValue:o,formatTime:s,ariaLabel:x,height:l=140})=>{const u=g.useRef(null),[i,p]=g.useState(null),f=Math.max(e.length?e[e.length-1]:0,1),c=g.useMemo(()=>{if(n!==void 0)return n;let r=0;for(const d of t)for(const v of d.values)v!==null&&v>r&&(r=v);return $(r)},[t,n]),h=g.useMemo(()=>t.map(r=>S(r.values)),[t]),y=r=>{var j;const d=(j=u.current)==null?void 0:j.getBoundingClientRect();if(!d||d.width<=0||e.length===0)return;const v=Math.min(1,Math.max(0,(r.clientX-d.left)/d.width));p(w(e,v*f))},m=i!==null?e[i]/f*100:0;return a.jsxs("div",{className:"flex gap-2",children:[a.jsxs("div",{className:"flex w-14 flex-col justify-between text-right text-[10px] tabular-nums text-[var(--text-dim)]",style:{height:l},children:[a.jsx("span",{children:o(c)}),a.jsx("span",{children:o(0)})]}),a.jsxs("div",{ref:u,"data-testid":"line-chart",className:"relative min-w-0 flex-1",style:{height:l},onMouseMove:y,onMouseLeave:()=>p(null),children:[a.jsxs("svg",{role:"img","aria-label":x,viewBox:`0 0 ${M} ${l}`,preserveAspectRatio:"none",className:"absolute inset-0 h-full w-full overflow-visible",children:[[0,.5,1].map(r=>a.jsx("line",{x1:0,x2:M,y1:r*l,y2:r*l,stroke:"var(--border)",strokeWidth:1,vectorEffect:"non-scaling-stroke"},r)),t.map((r,d)=>a.jsx("path",{"data-series":r.key,d:A(r.values,e,h[d],f,c,M,l),fill:"none",stroke:r.color,strokeWidth:1.5,strokeLinejoin:"round",strokeDasharray:r.dashed?"4 3":void 0,vectorEffect:"non-scaling-stroke"},r.key)),i!==null&&a.jsx("line",{x1:m/100*M,x2:m/100*M,y1:0,y2:l,stroke:"var(--text-muted)",strokeWidth:1,vectorEffect:"non-scaling-stroke"})]}),i!==null&&a.jsxs("div",{role:"tooltip",className:"pointer-events-none absolute top-1 z-10 whitespace-nowrap rounded-md border border-[var(--border-strong)] bg-[var(--surface)] px-2 py-1 text-[11px] text-[var(--text)]",style:m>60?{right:`${100-m}%`,marginRight:8}:{left:`${m}%`,marginLeft:8},children:[a.jsx("div",{className:"tabular-nums text-[var(--text-dim)]",children:(s??k)(e[i])}),t.map(r=>{var v;const d=r.values[i];return a.jsxs("div",{className:"flex items-center gap-1.5 tabular-nums",children:[a.jsx("span",{className:"inline-block h-0.5 w-3",style:{background:r.color}}),a.jsx("span",{className:"text-[var(--text-muted)]",children:((v=r.pointLabels)==null?void 0:v[i])??r.label}),a.jsx("span",{className:"ml-auto pl-3",children:d==null?"—":o(d)})]},r.key)})]})]})]})};export{I as C,B as L,W as a,E as b,R as f,$ as n,L as s};
@@ -1,4 +1,4 @@
1
- import{c as a}from"./index-ClrpAMAT.js";/**
1
+ import{c as a}from"./index-CHOr4JCs.js";/**
2
2
  * @license lucide-react v0.555.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,4 +1,4 @@
1
- import{c}from"./index-ClrpAMAT.js";/**
1
+ import{c}from"./index-CHOr4JCs.js";/**
2
2
  * @license lucide-react v0.555.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,4 +1,4 @@
1
- import{c as g,L as X,u as z,a as H,b as K,r as a,d as O,j as e,N as B,I as W,e as Y,C as _,f as G,l as J}from"./index-ClrpAMAT.js";import{c as Q}from"./utils-CDN07tui.js";import{u as V}from"./use-password-reset-mode-BK4B9kRC.js";import{A as Z}from"./auth-shell-CHmBFmOz.js";import{L as ee}from"./lock-CVCe56TH.js";import{C as te}from"./clock-DMT60v1C.js";import{A as se}from"./arrow-right-zm-NagQh.js";import"./network-CBGUjJDJ.js";/**
1
+ import{c as g,L as X,u as z,a as H,b as K,r as a,d as O,j as e,N as B,I as W,e as Y,C as _,f as G,l as J}from"./index-CHOr4JCs.js";import{c as Q}from"./utils-CDN07tui.js";import{u as V}from"./use-password-reset-mode-DozShXkk.js";import{A as Z}from"./auth-shell-BYRHcZd6.js";import{L as ee}from"./lock-BSXM1xvq.js";import{C as te}from"./clock-EZfet0sS.js";import{A as se}from"./arrow-right-K6A5e_Ee.js";import"./network-Ba_uFxWo.js";/**
2
2
  * @license lucide-react v0.555.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,4 +1,4 @@
1
- import{c as N,t as M,r as d,X as C,j as e,A as D,S as y,I as w,V as A}from"./index-ClrpAMAT.js";/* empty css */import{S as o,A as k}from"./SettingCard-Clg_Ijbc.js";import{P as B}from"./page-header-B92DKLiq.js";import{T as z}from"./trash-2-NK_Iazmg.js";import{C as E}from"./check-DpbIM4E0.js";import{C as R}from"./calendar-C7eYYJTo.js";import"./button-CqhPBGRj.js";import"./utils-CDN07tui.js";/**
1
+ import{c as N,t as M,r as d,X as C,j as e,A as D,S as y,I as w,V as A}from"./index-CHOr4JCs.js";/* empty css */import{S as o,A as k}from"./SettingCard-Cw6lDD0l.js";import{P as B}from"./page-header-Cm1XL49f.js";import{T as z}from"./trash-2-CcSsv4fS.js";import{C as E}from"./check-R6V3bot0.js";import{C as R}from"./calendar-CqVsn28A.js";import"./button-BxnHCCsX.js";import"./utils-CDN07tui.js";/**
2
2
  * @license lucide-react v0.555.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,4 +1,4 @@
1
- import{c as e}from"./index-ClrpAMAT.js";/**
1
+ import{c as e}from"./index-CHOr4JCs.js";/**
2
2
  * @license lucide-react v0.555.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,4 +1,4 @@
1
- import{c as e}from"./index-ClrpAMAT.js";/**
1
+ import{c as e}from"./index-CHOr4JCs.js";/**
2
2
  * @license lucide-react v0.555.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,4 +1,4 @@
1
- import{c as e}from"./index-ClrpAMAT.js";/**
1
+ import{c as e}from"./index-CHOr4JCs.js";/**
2
2
  * @license lucide-react v0.555.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.